From e88a0ddb222e11ddf5954d73e1f1972690cb85a5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 8 Jun 2024 13:28:49 +0800 Subject: [PATCH] :sparkles: About page --- lib/router.dart | 6 ++++ lib/screens/about.dart | 69 ++++++++++++++++++++++++++++++++++++++++ lib/screens/account.dart | 1 + lib/translations.dart | 4 +-- pubspec.lock | 2 +- pubspec.yaml | 1 + 6 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 lib/screens/about.dart diff --git a/lib/router.dart b/lib/router.dart index 04d43bc..0af4ad8 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -1,6 +1,7 @@ import 'package:go_router/go_router.dart'; import 'package:solian/models/channel.dart'; import 'package:solian/models/realm.dart'; +import 'package:solian/screens/about.dart'; import 'package:solian/screens/account.dart'; import 'package:solian/screens/account/friend.dart'; import 'package:solian/screens/account/personalize.dart'; @@ -87,6 +88,11 @@ abstract class AppRouter { name: 'accountPersonalize', builder: (context, state) => const PersonalizeScreen(), ), + GoRoute( + path: '/about', + name: 'about', + builder: (context, state) => const AboutScreen(), + ), ], ), ShellRoute( diff --git a/lib/screens/about.dart b/lib/screens/about.dart new file mode 100644 index 0000000..09171a9 --- /dev/null +++ b/lib/screens/about.dart @@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:url_launcher/url_launcher_string.dart'; + +class AboutScreen extends StatelessWidget { + const AboutScreen({super.key}); + + @override + Widget build(BuildContext context) { + const denseButtonStyle = + ButtonStyle(visualDensity: VisualDensity(vertical: -4)); + + return Material( + color: Theme.of(context).colorScheme.surface, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('assets/logo.png', width: 64, height: 64), + Text( + 'Solian', + style: Theme.of(context).textTheme.headlineMedium, + ), + const Text( + 'The Solar Network', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ), + const SizedBox(height: 8), + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const SizedBox(); + } + + return Text( + 'v${snapshot.data!.version} · ${snapshot.data!.buildNumber}', + style: const TextStyle(fontFamily: 'monospace'), + ); + }, + ), + Text('Copyright © ${DateTime.now().year} Solsynth LLC'), + const SizedBox(height: 16), + TextButton( + style: denseButtonStyle, + child: const Text('More Information'), + onPressed: () { + launchUrlString('https://solsynth.dev/products/solar-network'); + }, + ), + TextButton( + style: denseButtonStyle, + onPressed: () { + launchUrlString('https://solsynth.dev'); + }, + child: const Text('Official Website'), + ), + const SizedBox(height: 16), + const Text( + 'Open-sourced under AGPLv3', + style: TextStyle( + fontWeight: FontWeight.w300, + fontSize: 12, + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/account.dart b/lib/screens/account.dart index 847edb3..ec4d939 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -24,6 +24,7 @@ class _AccountScreenState extends State { 'accountPersonalize' ), (const Icon(Icons.diversity_1), 'accountFriend'.tr, 'accountFriend'), + (const Icon(Icons.info_outline), 'about'.tr, 'about'), ]; final AuthProvider provider = Get.find(); diff --git a/lib/translations.dart b/lib/translations.dart index 09e5eea..77dd152 100644 --- a/lib/translations.dart +++ b/lib/translations.dart @@ -16,6 +16,7 @@ class SolianMessages extends Translations { 'confirm': 'Confirm', 'leave': 'Leave', 'loading': 'Loading...', + 'about': 'About', 'edit': 'Edit', 'delete': 'Delete', 'search': 'Search', @@ -199,7 +200,6 @@ class SolianMessages extends Translations { 'pushNotifyRegisterDone': 'Push notifications has been activated.', 'pushNotifyRegisterFailed': 'Unable to active push notification... @reason', - 'about': 'About', }, 'zh_CN': { 'hide': '隐藏', @@ -210,6 +210,7 @@ class SolianMessages extends Translations { 'confirm': '确认', 'leave': '离开', 'loading': '载入中…', + 'about': '关于', 'edit': '编辑', 'delete': '删除', 'page': '页面', @@ -384,7 +385,6 @@ class SolianMessages extends Translations { '激活推送通知便可以让你在应用程序完全关闭的时候仍然获取到我们最新的通知。在 iOS/macOS 设备上我们使用 Apple 官方的推送服务;其他设备则通过 Google Firebase 提供推送通知。要注册推送通知设备,您可能需要连接到 Google 的服务器(在中国大陆不可用)并在您的设备上安装 Google Framework。即使您关闭此对话框,下次启动应用程序时仍会自动执行此注册。', 'pushNotifyRegisterDone': '推送通知已成功激活', 'pushNotifyRegisterFailed': '推送通知激活失败…… @reason', - 'about': '关于', } }; } diff --git a/pubspec.lock b/pubspec.lock index ec53d79..587d909 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -793,7 +793,7 @@ packages: source: hosted version: "2.0.0" package_info_plus: - dependency: transitive + dependency: "direct main" description: name: package_info_plus sha256: b93d8b4d624b4ea19b0a5a208b2d6eff06004bc3ce74c06040b120eeadd00ce0 diff --git a/pubspec.yaml b/pubspec.yaml index fbf6cec..ddb28d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: firebase_core: ^3.0.0 firebase_messaging: ^15.0.0 platform_device_id: ^1.0.1 + package_info_plus: ^8.0.0 dev_dependencies: flutter_test: