Add version number to appbar
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:hiddify/core/app/app.dart';
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/data/data_providers.dart';
|
||||
import 'package:hiddify/features/common/active_profile/active_profile_notifier.dart';
|
||||
import 'package:hiddify/features/common/common.dart';
|
||||
import 'package:hiddify/features/common/window/window_controller.dart';
|
||||
import 'package:hiddify/features/system_tray/system_tray.dart';
|
||||
import 'package:hiddify/services/deep_link_service.dart';
|
||||
@@ -86,6 +87,7 @@ Future<void> initControllers(
|
||||
[
|
||||
read(activeProfileProvider.future),
|
||||
read(deepLinkServiceProvider.future),
|
||||
read(runtimeDetailsNotifierProvider.future),
|
||||
if (PlatformUtils.isDesktop) read(systemTrayControllerProvider.future),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -2,3 +2,4 @@ export 'confirmation_dialogs.dart';
|
||||
export 'custom_app_bar.dart';
|
||||
export 'profile_tile.dart';
|
||||
export 'qr_code_scanner_screen.dart';
|
||||
export 'runtime_details.dart';
|
||||
|
||||
@@ -32,6 +32,8 @@ class RuntimeDetails with _$RuntimeDetails {
|
||||
required String clashVersion,
|
||||
}) = _RuntimeDetails;
|
||||
|
||||
String get fullVersion => version + buildNumber;
|
||||
|
||||
factory RuntimeDetails.fromJson(Map<String, dynamic> json) =>
|
||||
_$RuntimeDetailsFromJson(json);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/router/router.dart';
|
||||
import 'package:hiddify/domain/failures.dart';
|
||||
@@ -40,7 +41,13 @@ class HomePage extends HookConsumerWidget {
|
||||
CustomScrollView(
|
||||
slivers: [
|
||||
NestedTabAppBar(
|
||||
title: Text(t.general.appTitle.titleCase),
|
||||
title: Row(
|
||||
children: [
|
||||
Text(t.general.appTitle.titleCase),
|
||||
const Gap(4),
|
||||
const AppVersionLabel(),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => const AddProfileRoute().push(context),
|
||||
@@ -82,3 +89,40 @@ class HomePage extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppVersionLabel extends HookConsumerWidget {
|
||||
const AppVersionLabel({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final version = ref.watch(
|
||||
runtimeDetailsNotifierProvider.select(
|
||||
(value) => switch (value) {
|
||||
AsyncData(:final value) => value.fullVersion,
|
||||
_ => "",
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (version.isEmpty) return const SizedBox();
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 1,
|
||||
),
|
||||
child: Text(
|
||||
version,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user