Skip to content

Commit

Permalink
💾 Feat: Display some key information in about page
Browse files Browse the repository at this point in the history
- UI will be updated soon
- Use custom build scripts we allow application to display last build timestamp
  • Loading branch information
Dynesshely committed Sep 8, 2024
1 parent 2fd456a commit 8877df2
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 36 deletions.
3 changes: 3 additions & 0 deletions KitX Website Flutter/kitx_website/build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Clean built files
flutter clean

## Make sure custom build scripts are executed
dart run build_runner build --delete-conflicting-outputs

## Build with web profile
flutter build web --release --web-renderer canvaskit --no-tree-shake-icons --no-web-resources-cdn

Expand Down
7 changes: 7 additions & 0 deletions KitX Website Flutter/kitx_website/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
builders:
package_name|appBuildTimestampGenerator:
import: "package:kitx_website/common/build/app_build_timestamp_generator.dart"
builder_factories: ["appBuildTimestampGenerator"]
build_extensions: { ".dart": [".my_gen.dart"] }
auto_apply: root_package
build_to: source
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Generated file on build.

/// Timestamp that records last build of the app. Can be shown in the app.
const int lastAppBuildTimestamp = 1725820249737;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'dart:io';

import 'package:build/build.dart';

Builder appBuildTimestampGenerator(BuilderOptions options) => AppBuildTimestampGeneratorBuilder();

class AppBuildTimestampGeneratorBuilder implements Builder {
@override
final buildExtensions = {
'.dart': ['.my_gen.dart']
};

@override
Future<void> build(BuildStep _) async {
final outputFile = File('lib/common/build/app_build_timestamp.g.dart');
await outputFile.writeAsString('''
// Generated file on build.
/// Timestamp that records last build of the app. Can be shown in the app.
const int lastAppBuildTimestamp = ${DateTime.now().millisecondsSinceEpoch};
''');
}
}
20 changes: 0 additions & 20 deletions KitX Website Flutter/kitx_website/lib/pages/about_page.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'package:community_material_icon/community_material_icon.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kitx_website/common/build/app_build_timestamp.g.dart';
import 'package:kitx_website/pages/controls/controls_helper.dart';
import 'package:kitx_website/pages/controls/download_items_block.dart';
import 'package:kitx_website/pages/controls/download_pages/platform_android.dart';
Expand All @@ -12,6 +13,7 @@ import 'package:kitx_website/pages/controls/download_pages/platform_macos.dart';
import 'package:kitx_website/pages/controls/download_pages/platform_windows.dart';
import 'package:kitx_website/utils/global.dart';
import 'package:kitx_website/utils/open_link.dart';
import 'package:package_info_plus/package_info_plus.dart';

var downloadSource = 'GitHub'.obs;

Expand Down Expand Up @@ -259,7 +261,105 @@ Widget getDownloadList(BuildContext context) {
subTitle: ('Download_LookingForElderVersions'.tr, null),
leading: const Icon(CommunityMaterialIcons.view_list),
trailing: const Icon(CommunityMaterialIcons.open_in_new),
onTap: () => openLink('GitHubRepo_KitX_Releases'),
onTap: () {
Get.back();
openLink('GitHubRepo_KitX_Releases');
},
),
const SizedBox(height: tilesPadding),
listTileItem(
title: 'View_AboutPage'.tr,
subTitle: ('View_AboutPage_Tip'.tr, null),
leading: const Icon(Icons.info),
trailing: const Icon(CommunityMaterialIcons.open_in_new),
onTap: () {
var appName = ''.obs;
var packageName = ''.obs;
var version = ''.obs;
var buildNumber = ''.obs;

Future.sync(() async {
var packageInfo = await PackageInfo.fromPlatform();

appName.value = packageInfo.appName;
packageName.value = packageInfo.packageName;
version.value = packageInfo.version;
buildNumber.value = packageInfo.buildNumber;
});

var content = Center(
child: Container(
width: 500,
margin: EdgeInsets.all(30),
child: Card(
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Container(
margin: EdgeInsets.all(30),
child: Column(
children: [
Text(
'About',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 20),
Obx(
() => Text(
'App Name: ${appName.value}',
style: TextStyle(
fontSize: 16,
),
),
),
Obx(
() => Text(
'Package Name: ${packageName.value}',
style: TextStyle(
fontSize: 16,
),
),
),
Obx(
() => Text(
'Version: ${version.value}',
style: TextStyle(
fontSize: 16,
),
),
),
Obx(
() => Text(
'Build Number: ${buildNumber.value}',
style: TextStyle(
fontSize: 16,
),
),
),
Text(
'Build timestamp: $lastAppBuildTimestamp',
style: TextStyle(
fontSize: 16,
),
),
],
),
),
),
),
);

Get.back();
Get.to(
() => Scaffold(
appBar: AppBar(
title: Text('About_Page'.tr),
),
body: content,
),
);
},
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ class AppDrawer extends StatelessWidget {
title: Text('Settings_Page'.tr),
onTap: () => navigateTo(3),
),
ListTile(
leading: const Icon(Icons.info),
title: Text('About_Page'.tr),
onTap: () => navigateTo(4),
),
Divider(),
ListTile(
leading: const Icon(CommunityMaterialIcons.github),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:html';
import 'package:community_material_icon/community_material_icon.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kitx_website/pages/about_page.dart';
import 'package:kitx_website/pages/controls/drawer.dart';
import 'package:kitx_website/pages/controls/navigation_page_actions.dart';
import 'package:kitx_website/pages/home_page.dart';
Expand Down Expand Up @@ -89,12 +88,6 @@ class _NavigationPageState extends State<NavigationPage> {
label: Text('Settings_Page'.tr),
padding: EdgeInsets.symmetric(vertical: _buttonsPadding),
),
NavigationRailDestination(
icon: const Icon(Icons.info),
selectedIcon: const Icon(Icons.info_outline),
label: Text('About_Page'.tr),
padding: EdgeInsets.symmetric(vertical: _buttonsPadding),
),
],
),
)
Expand Down Expand Up @@ -133,7 +126,6 @@ class _NavigationPageState extends State<NavigationPage> {
const ClipRect(child: const PluginsPage()),
const ClipRect(child: const MilestonesPage()),
const ClipRect(child: const SettingsPage()),
const ClipRect(child: const AboutPage()),
],
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const Map<String, String> en_US = {
'Public_Recommended': 'Recommended',
'Home_Page': 'Home',
'Plugins_Page': 'Plugins',
// 'Docs_Page': 'Docs',
'Milestones_Page': 'Milestones',
'Settings_Page': 'Settings',
'About_Page': 'About',
'View_AboutPage': 'View About Page',
'View_AboutPage_Tip': 'About this website',
'Download_Tested': 'Tested on @content',
'Download_Supported': '@content supported',
'Download_NoTest': 'No test yet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const Map<String, String> zh_CN = {
'Public_Recommended': '推荐',
'Home_Page': '主页',
'Plugins_Page': '插件',
// 'Docs_Page': '文档',
'Milestones_Page': '里程碑',
'Settings_Page': '设置',
'About_Page': '关于',
'View_AboutPage': '查看关于',
'View_AboutPage_Tip': '关于此网站',
'Download_Tested': '在 @content 上通过测试',
'Download_Supported': '支持 @content',
'Download_NoTest': '尚未测试',
Expand Down
3 changes: 3 additions & 0 deletions KitX Website Flutter/kitx_website/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ dependencies:
sdk: flutter
get: ^4.6.6
loading_animation_widget: ^1.2.1
package_info_plus: ^8.0.2
timelines: ^0.1.0
websafe_svg: ^3.0.1+2

dev_dependencies:
build: ^2.4.1
build_runner: ^2.4.12
flutter_lints: ^4.0.0
flutter_test:
sdk: flutter
Expand Down

0 comments on commit 8877df2

Please sign in to comment.