feat: add version label in settings
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../models/settings.dart';
|
import '../models/settings.dart';
|
||||||
@@ -15,6 +16,9 @@ class SettingsScreenView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SettingsScreenViewState extends State<SettingsScreenView> {
|
class _SettingsScreenViewState extends State<SettingsScreenView> {
|
||||||
|
String _appVersion = '';
|
||||||
|
int _versionTaps = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -22,6 +26,32 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.read<SettingsViewModel>().ensureLoaded();
|
context.read<SettingsViewModel>().ensureLoaded();
|
||||||
context.read<PinLockViewModel>().ensureLoaded();
|
context.read<PinLockViewModel>().ensureLoaded();
|
||||||
|
_loadVersion();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> currentVersion() async {
|
||||||
|
final info = await PackageInfo.fromPlatform();
|
||||||
|
debugPrint("Current app version: ${info.version}");
|
||||||
|
return info.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onVersionTap() {
|
||||||
|
_versionTaps++;
|
||||||
|
|
||||||
|
if (_versionTaps >= 7) {
|
||||||
|
_versionTaps = 0;
|
||||||
|
context.push('/dev');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadVersion() async {
|
||||||
|
final version = await currentVersion();
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_appVersion = version;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +259,25 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _onVersionTap,
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Version $_appVersion',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall
|
||||||
|
?.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface
|
||||||
|
.withValues(alpha: 0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.0+1
|
version: 2.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.12.2
|
sdk: ^3.12.2
|
||||||
|
|||||||
Reference in New Issue
Block a user