Skip to content

Commit

Permalink
Change version string to include build
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisme committed May 7, 2021
1 parent c8246d3 commit c4c7524
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
15 changes: 8 additions & 7 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:notifi/utils/icons.dart';
import 'package:notifi/utils/pallete.dart';
import 'package:notifi/utils/utils.dart';
import 'package:notifi/utils/version.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:toast/toast.dart';
Expand All @@ -29,19 +30,19 @@ class SettingsScreen extends StatefulWidget {
}

class SettingsScreenState extends State<SettingsScreen> {
ValueNotifier<String> _version;
ValueNotifier<String> _versionString;
ValueNotifier<bool> _hasUpgrade;

@override
void initState() {
_version = ValueNotifier<String>('');
_versionString = ValueNotifier<String>('');
_hasUpgrade = ValueNotifier<bool>(false);
super.initState();
}

@override
void dispose() {
_version.dispose();
_versionString.dispose();
_hasUpgrade.dispose();
super.dispose();
}
Expand All @@ -51,9 +52,9 @@ class SettingsScreenState extends State<SettingsScreen> {
const double leadingWidth = 60.0;

if (!isTest()) {
getVersion().then((String version) {
_version.value = version;
hasUpgrade(version).then((bool hasUpgrade) {
PackageInfo.fromPlatform().then((PackageInfo package) {
_versionString.value = '${package.version} (${package.buildNumber})';
hasUpgrade(package.version).then((bool hasUpgrade) {
_hasUpgrade.value = hasUpgrade;
});
});
Expand Down Expand Up @@ -200,7 +201,7 @@ class SettingsScreenState extends State<SettingsScreen> {
),
if (!isTest())
ValueListenableBuilder<String>(
valueListenable: _version,
valueListenable: _versionString,
// ignore: always_specify_types
builder: (BuildContext context, String version, Widget child) {
return Container(
Expand Down
6 changes: 0 additions & 6 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart' as dot_env;
import 'package:package_info/package_info.dart';
import 'package:toast/toast.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -52,11 +51,6 @@ class MenuBarIcon {
}
}

Future<String> getVersion() async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.buildNumber;
}

Future<void> loadDotEnv() async {
await dot_env.load();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/ws.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:notifi/user.dart';
import 'package:notifi/utils/utils.dart';
import 'package:package_info/package_info.dart';
import 'package:web_socket_channel/io.dart';

Future<IOWebSocketChannel> connectToWS(
UserStruct user,
Future<List<String>> Function(String) onMessage,
Function(bool) setErr) async {
final PackageInfo package = await PackageInfo.fromPlatform();
final Map<String, dynamic> headers = <String, dynamic>{
'Sec-Key': env['SERVER_KEY'],
'Uuid': user.uuid,
'Credentials': user.credentials,
'Key': user.credentialKey,
'Version': await getVersion(),
'Version': package.version,
};

if (shouldUseFirebase) {
Expand Down

0 comments on commit c4c7524

Please sign in to comment.