feat: 版本号增加
This commit is contained in:
parent
e82480b937
commit
dbcdf8b8a4
@ -12,6 +12,8 @@ class HIMenuController extends GetxController {
|
||||
final KRSubscribeService kr_subscribeService = KRSubscribeService();
|
||||
// 版本号
|
||||
final RxString kr_version = ''.obs;
|
||||
final RxString kr_buildNumber = ''.obs;
|
||||
final RxBool kr_showBuild = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -23,5 +25,10 @@ class HIMenuController extends GetxController {
|
||||
Future<void> _kr_getVersion() async {
|
||||
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
kr_version.value = packageInfo.version;
|
||||
kr_buildNumber.value = packageInfo.buildNumber;
|
||||
}
|
||||
|
||||
void toggleVersionDisplay() {
|
||||
kr_showBuild.value = !kr_showBuild.value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,18 +82,19 @@ class HIMenuView extends GetView<HIMenuController> implements HasSwipeConfig {
|
||||
),
|
||||
// 版本号信息
|
||||
Obx(() {
|
||||
// 1. 从 Obx 的回调函数中 return 一个 Widget
|
||||
return Positioned(
|
||||
bottom: 40.0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
'当前版本:${controller.kr_version.value}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
// 2. 建议使用更稳定的颜色,避免主题切换时出现问题
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 10.w,
|
||||
child: GestureDetector(
|
||||
onDoubleTap: () => controller.toggleVersionDisplay(),
|
||||
child: Text(
|
||||
'当前版本:${controller.kr_showBuild.value ? '${controller.kr_version.value}.${controller.kr_buildNumber.value}' : controller.kr_version.value}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 10.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -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
|
||||
# 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.
|
||||
version: 0.0.4
|
||||
version: 0.0.4+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.5.0 <4.0.0'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user