From 52027329641771d5e3e71e644c9f8c30f9ad291e Mon Sep 17 00:00:00 2001 From: Lukas Heiligenbrunner Date: Wed, 2 Nov 2022 23:31:44 +0000 Subject: [PATCH] fix merge issues --- .gitignore | 2 ++ .gitlab-ci.yml | 4 +++ gen/metagen.dart | 45 ++++++++++++++++++++++++++++++ gen/pubspec.lock | 47 ++++++++++++++++++++++++++++++++ gen/pubspec.yaml | 8 ++++++ lib/gen/meta.dart | 8 ++++++ lib/pages/settings_page.dart | 26 ++++++++++++++++++ lib/widgets/collapse_drawer.dart | 9 +++++- 8 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 gen/metagen.dart create mode 100644 gen/pubspec.lock create mode 100644 gen/pubspec.yaml create mode 100644 lib/gen/meta.dart create mode 100644 lib/pages/settings_page.dart diff --git a/.gitignore b/.gitignore index 24476c5..e57f7f9 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +lib/gen/meta.dart diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8bbf445..2d927a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,8 @@ flutter_build_android: - flutter packages get - flutter clean script: + - cd gen && flutter pub get + - dart run metagen.dart && cd .. - flutter build apk --target-platform android-arm64 - mv build/app/outputs/apk/release/app-release.apk ./notes.apk artifacts: @@ -22,6 +24,8 @@ linux_build: - apt-get install -y --no-install-recommends cmake ninja-build clang build-essential pkg-config libgtk-3-dev liblzma-dev lcov libvlc-dev vlc libsecret-1-dev libjsoncpp-dev - flutter config --enable-linux-desktop - flutter packages get + - cd gen && flutter pub get + - dart run metagen.dart && cd .. - flutter build linux artifacts: paths: diff --git a/gen/metagen.dart b/gen/metagen.dart new file mode 100644 index 0000000..22b5f6a --- /dev/null +++ b/gen/metagen.dart @@ -0,0 +1,45 @@ +import 'dart:io'; +import 'package:yaml/yaml.dart'; + +void main() { + print('generating version file'); + MetaUpdate('../pubspec.yaml').writeMetaDartFile('../lib/gen/meta.dart'); +} + +class MetaUpdate { + String pathToYaml = ''; + String metaDartFileContents = ''; + MetaUpdate(this.pathToYaml); + + void writeMetaDartFile(String metaDartFilePath) { + File metaDartFile = File(metaDartFilePath); + + final version = getPubSpec('version'); + final time = DateTime.now().millisecondsSinceEpoch; + print('Version: $version'); + print('BuildTime: $time'); + + String metaDartFileContents = """ +/// DO NOT EDIT THIS FILE EXCEPT TO ENTER INITIAL VERSION AND OTHER META INFO +/// THIS FILE IS AUTOMATICALLY OVERWRITTEN + +class Meta { + static const String version = '$version'; + static const int buildTime = $time; + static const bool devBuild = false; +} + """; + + metaDartFile.writeAsStringSync(metaDartFileContents); + } + + String getPubSpec(String pubSpecParam) { + File f = File(pathToYaml); + + String yamlText = f.readAsStringSync(); + // ignore: always_specify_types + Map yaml = loadYaml(yamlText); + + return yaml[pubSpecParam]; + } +} diff --git a/gen/pubspec.lock b/gen/pubspec.lock new file mode 100644 index 0000000..99e9fea --- /dev/null +++ b/gen/pubspec.lock @@ -0,0 +1,47 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.17.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + yaml: + dependency: "direct main" + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.18.2 <3.0.0" diff --git a/gen/pubspec.yaml b/gen/pubspec.yaml new file mode 100644 index 0000000..53aec21 --- /dev/null +++ b/gen/pubspec.yaml @@ -0,0 +1,8 @@ +name: gen +version: 1.0.0+1 + +environment: + sdk: '>=2.18.2 <3.0.0' + +dependencies: + yaml: diff --git a/lib/gen/meta.dart b/lib/gen/meta.dart new file mode 100644 index 0000000..bd23de7 --- /dev/null +++ b/lib/gen/meta.dart @@ -0,0 +1,8 @@ +/// DO NOT EDIT THIS FILE EXCEPT TO ENTER INITIAL VERSION AND OTHER META INFO +/// THIS FILE IS AUTOMATICALLY OVERWRITTEN + +class Meta { + static const String version = '0.0.0+0-dev'; + static const int buildTime = 71727248562000; + static const bool devBuild = true; +} diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart new file mode 100644 index 0000000..6db742a --- /dev/null +++ b/lib/pages/settings_page.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +import '../gen/meta.dart'; + +class SettingsPage extends StatelessWidget { + const SettingsPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final buildTimeString = + DateTime.fromMillisecondsSinceEpoch(Meta.buildTime).toIso8601String(); + + return Scaffold( + appBar: AppBar(), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Notes'), + const Text('Version: ${Meta.version}'), + Text('Build Time: $buildTimeString'), + if (Meta.devBuild) const Text('Attention, this is a dev build!') + ], + ))); + } +} diff --git a/lib/widgets/collapse_drawer.dart b/lib/widgets/collapse_drawer.dart index c4785cd..d3519ab 100644 --- a/lib/widgets/collapse_drawer.dart +++ b/lib/widgets/collapse_drawer.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../context/file_change_notifier.dart'; +import '../pages/settings_page.dart'; import 'drawer_item.dart'; enum View { all, shared, recycle, folders } @@ -86,7 +87,13 @@ class _CollapseDrawerState extends State icon: const Icon(Icons.settings_outlined), iconSize: 26, color: const Color(0xffa8a8a8), - onPressed: () {}, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsPage(), + )); + }, ), ), const SizedBox(