From dc99ae2e6564b8bb748885568ecefb0f7dd3e535 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 08:06:59 -0400 Subject: [PATCH 1/7] Update java to 17 --- .github/workflows/release.yml | 2 +- android/app/build.gradle | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae18d24..1f2d192 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: '11' + java-version: '17' - name: Install flutter uses: subosito/flutter-action@v2 diff --git a/android/app/build.gradle b/android/app/build.gradle index ed72850..9cf20bb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -29,12 +29,12 @@ android { compileSdkVersion 34 compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = JavaVersion.VERSION_17 } sourceSets { From 70b344bbbdad18d30aa9d597233eae3da557c4bb Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 08:43:26 -0400 Subject: [PATCH 2/7] Use java toolchain instead of explicit targets --- android/app/build.gradle | 15 ++++++--------- android/settings.gradle | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9cf20bb..1f8ad57 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -28,15 +28,6 @@ android { compileSdkVersion 34 - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17 - } - sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -72,6 +63,12 @@ android { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + flutter { source '../..' } diff --git a/android/settings.gradle b/android/settings.gradle index 3192560..3ff10ee 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -17,6 +17,7 @@ pluginManagement { } plugins { + id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0" id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version '8.6.1' apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false From 4403fef32e7f9ba6e20aa0bd22fdddcca0dbb42a Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 14:02:25 -0400 Subject: [PATCH 3/7] Fix flutter format command It was removed in 3.12: https://github.com/flutter/flutter/pull/129360 --- .github/workflows/flutterfmt.sh | 2 +- README.md | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/flutterfmt.sh b/.github/workflows/flutterfmt.sh index 5dfddc8..a003ccb 100755 --- a/.github/workflows/flutterfmt.sh +++ b/.github/workflows/flutterfmt.sh @@ -3,7 +3,7 @@ DIRS="lib test" EXIT=0 for DIR in $DIRS; do - OUT="$(flutter format -l 120 --suppress-analytics "$DIR" | sed -e "s/^Formatted \(.*\)/::error file=$DIR\/\1::Not formatted/g")" + OUT="$(dart format -l 120 --suppress-analytics "$DIR" | sed -e "s/^Formatted \(.*\)/::error file=$DIR\/\1::Not formatted/g")" echo "$OUT" | grep "::error" && EXIT=1 done diff --git a/README.md b/README.md index f302413..ea89994 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,16 @@ If you are having issues with iOS pods, try blowing it all away! `cd ios && rm - # Formatting -`flutter format` can be used to format the code in `lib` and `test` but it's default is 80 char line limit, it's 2020 +`dart format` can be used to format the code in `lib` and `test`. We use a line-length of 120 characters. Use: ```sh -flutter format lib/ test/ -l 120 +dart format lib/ test/ -l 120 ``` +In Android Studio, set the line length using Preferences -> Editor -> Code Style -> Dart -> Line length, set it to 120. Enable auto-format with Preferences -> Languages & Frameworks -> Flutter -> Format code on save. + + # Release Update `version` in `pubspec.yaml` to reflect this release, then @@ -53,4 +56,4 @@ Upload the android bundle to the google play store https://play.google.com/apps/ ## iOS -In xcode, Release -> Archive then follow the directions to upload to the app store. If you have issues, https://flutter.dev/docs/deployment/ios#create-a-build-archive +In xcode, Release -> Archive then follow the directions to upload to the app store. If you have issues, https://flutter.dev/docs/deployment/ios#create-a-build-archive \ No newline at end of file From 0556ff612e99dc178622764c418162d798df2b72 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 14:15:54 -0400 Subject: [PATCH 4/7] Simplify/fix dart formatting in CI --- .github/workflows/flutterfmt.sh | 10 ---------- .github/workflows/flutterfmt.yml | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100755 .github/workflows/flutterfmt.sh diff --git a/.github/workflows/flutterfmt.sh b/.github/workflows/flutterfmt.sh deleted file mode 100755 index a003ccb..0000000 --- a/.github/workflows/flutterfmt.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -DIRS="lib test" -EXIT=0 - -for DIR in $DIRS; do - OUT="$(dart format -l 120 --suppress-analytics "$DIR" | sed -e "s/^Formatted \(.*\)/::error file=$DIR\/\1::Not formatted/g")" - echo "$OUT" | grep "::error" && EXIT=1 -done - -exit $EXIT \ No newline at end of file diff --git a/.github/workflows/flutterfmt.yml b/.github/workflows/flutterfmt.yml index 597e914..60ec34b 100644 --- a/.github/workflows/flutterfmt.yml +++ b/.github/workflows/flutterfmt.yml @@ -23,5 +23,5 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: flutter format - run: $GITHUB_WORKSPACE/.github/workflows/flutterfmt.sh + - name: Check formating + run: dart format -l120 lib/ test/ --set-exit-if-changed --suppress-analytics \ No newline at end of file From 13435757f5744c0433de0b58c4daf646a221f737 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 14:23:51 -0400 Subject: [PATCH 5/7] Do not actually change files --- .github/workflows/flutterfmt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutterfmt.yml b/.github/workflows/flutterfmt.yml index 60ec34b..490be43 100644 --- a/.github/workflows/flutterfmt.yml +++ b/.github/workflows/flutterfmt.yml @@ -24,4 +24,4 @@ jobs: uses: actions/checkout@v3 - name: Check formating - run: dart format -l120 lib/ test/ --set-exit-if-changed --suppress-analytics \ No newline at end of file + run: dart format -l120 lib/ test/ --set-exit-if-changed --suppress-analytics --output none \ No newline at end of file From 9d0c3640fec38d0e279a71ad68c8ad406fd40131 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 14:24:09 -0400 Subject: [PATCH 6/7] We don't have tests --- .github/workflows/flutterfmt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutterfmt.yml b/.github/workflows/flutterfmt.yml index 490be43..5f73213 100644 --- a/.github/workflows/flutterfmt.yml +++ b/.github/workflows/flutterfmt.yml @@ -24,4 +24,4 @@ jobs: uses: actions/checkout@v3 - name: Check formating - run: dart format -l120 lib/ test/ --set-exit-if-changed --suppress-analytics --output none \ No newline at end of file + run: dart format -l120 lib/ --set-exit-if-changed --suppress-analytics --output none \ No newline at end of file From cf97068d7bf17e089cf2c79b25d778f95541d60a Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 27 Sep 2024 14:27:13 -0400 Subject: [PATCH 7/7] Format main.dart --- lib/main.dart | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index a5a3047..9cb6745 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -85,44 +85,44 @@ class _AppState extends State { return MaterialApp( theme: brightness == Brightness.light ? lightTheme : darkTheme, home: Scaffold( - body: PlatformProvider( - //initialPlatform: initialPlatform, - builder: (context) => PlatformApp( - debugShowCheckedModeBanner: false, - localizationsDelegates: >[ - DefaultMaterialLocalizations.delegate, - DefaultWidgetsLocalizations.delegate, - DefaultCupertinoLocalizations.delegate, - ], - title: 'Nebula', - material: (_, __) { - return new MaterialAppData( - themeMode: brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark, - ); - }, - cupertino: (_, __) => CupertinoAppData( - theme: CupertinoThemeData(brightness: brightness), - ), - onGenerateRoute: (settings) { - if (settings.name == '/') { - return platformPageRoute(context: context, builder: (context) => MainScreen(this.dnEnrolled)); - } - - final uri = Uri.parse(settings.name!); - if (uri.path == EnrollmentScreen.routeName) { - // TODO: maybe implement this as a dialog instead of a page, you can stack multiple enrollment screens which is annoying in dev - return platformPageRoute( - context: context, - builder: (context) => - EnrollmentScreen(code: EnrollmentScreen.parseCode(settings.name!), stream: this.dnEnrolled), + body: PlatformProvider( + //initialPlatform: initialPlatform, + builder: (context) => PlatformApp( + debugShowCheckedModeBanner: false, + localizationsDelegates: >[ + DefaultMaterialLocalizations.delegate, + DefaultWidgetsLocalizations.delegate, + DefaultCupertinoLocalizations.delegate, + ], + title: 'Nebula', + material: (_, __) { + return new MaterialAppData( + themeMode: brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark, ); - } + }, + cupertino: (_, __) => CupertinoAppData( + theme: CupertinoThemeData(brightness: brightness), + ), + onGenerateRoute: (settings) { + if (settings.name == '/') { + return platformPageRoute(context: context, builder: (context) => MainScreen(this.dnEnrolled)); + } - return null; - }, + final uri = Uri.parse(settings.name!); + if (uri.path == EnrollmentScreen.routeName) { + // TODO: maybe implement this as a dialog instead of a page, you can stack multiple enrollment screens which is annoying in dev + return platformPageRoute( + context: context, + builder: (context) => + EnrollmentScreen(code: EnrollmentScreen.parseCode(settings.name!), stream: this.dnEnrolled), + ); + } + + return null; + }, + ), ), ), - ), ); } }