Skip to content

Commit

Permalink
Clean architecture (#29)
Browse files Browse the repository at this point in the history
Upgrade dependencies, add a separate viewmodel to extract logic
  • Loading branch information
OroshiX authored Sep 29, 2024
2 parents 0200267 + 1581667 commit fb22531
Show file tree
Hide file tree
Showing 28 changed files with 1,255 additions and 834 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.10.0'
flutter_version: '3.24.3'
java_version: '11'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
workflow_dispatch:

env:
flutter_version: '3.10.0'
flutter_version: '3.24.3'
java_version: '11'

jobs:
Expand Down
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -42,7 +42,7 @@ android {
defaultConfig {
applicationId "com.aroxoft.tagros.points"
minSdkVersion 26
targetSdkVersion 33
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -73,6 +73,6 @@ flutter {

dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:runner:1.6.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}
2 changes: 1 addition & 1 deletion android/fastlane
24 changes: 21 additions & 3 deletions integration_test/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,33 @@ Future<void> createApp(WidgetTester widgetTester,
/// Take a screenshot of the current screen.
/// Cannot take more than one screenshot per test.
Future<void> takeScreenshot(
IntegrationTestWidgetsFlutterBinding binding, WidgetTester tester,
{required String screenshotName, bool settle = true}) async {
IntegrationTestWidgetsFlutterBinding binding,
WidgetTester tester, {
required int screenshotNumber,
bool settle = true,
required String locale,
DeviceType deviceType = DeviceType.phone,
}) async {
if (UniversalPlatform.isAndroid) {
await binding.convertFlutterSurfaceToImage();
if (settle) {
await tester.pumpAndSettle();
}
}
await binding.takeScreenshot(screenshotName);
await binding
.takeScreenshot('${screenshotNumber}_${locale}_${deviceType.folderName}');
}

enum DeviceType {
phone("phoneScreenshots"),
sevenInchTablet("sevenInchScreenshots"),
tenInchTablet("tenInchScreenshots"),
tv("tvScreenshots"),
wearable("wearScreenshots");

final String folderName;

const DeviceType(this.folderName);
}

class _FakeThemeRepository extends Fake implements ThemeRepository {
Expand Down
8 changes: 4 additions & 4 deletions integration_test/screenshots_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
await _addRandomRound(t, namesEn);
}

await takeScreenshot(binding, t, screenshotName: '1_en-US');
await takeScreenshot(binding, t, screenshotNumber: 1, locale: 'en');
});
testWidgets('Player dialog with 5 players fr', (t) async {
await createApp(t, lang: 'fr');
Expand All @@ -31,7 +31,7 @@ void main() {
await _addRandomRound(t, namesFr);
}

await takeScreenshot(binding, t, screenshotName: '1_fr-FR');
await takeScreenshot(binding, t, screenshotNumber: 1, locale: 'fr');
});

testWidgets('Edit game en', (t) async {
Expand All @@ -42,7 +42,7 @@ void main() {

await _editGame(t, names);
await takeScreenshot(binding, t,
screenshotName: '2_en-US', settle: false);
screenshotNumber: 2, settle: false, locale: 'en');
});

testWidgets('Edit game fr', (t) async {
Expand All @@ -53,7 +53,7 @@ void main() {
await _editGame(t, names);

await takeScreenshot(binding, t,
screenshotName: '2_fr-FR', settle: false);
screenshotNumber: 2, settle: false, locale: 'fr');
});
});
}
Expand Down
1 change: 1 addition & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
build/ios/Pods.build/

# Exceptions to above rules.
!default.mode1v3
Expand Down
3 changes: 2 additions & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

platform :ios, '14.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
134 changes: 49 additions & 85 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,104 +2,66 @@ PODS:
- Flutter (1.0.0)
- flutter_native_splash (0.0.1):
- Flutter
- Google-Mobile-Ads-SDK (10.4.0):
- GoogleAppMeasurement (< 11.0, >= 7.0)
- Google-Mobile-Ads-SDK (11.2.0):
- GoogleUserMessagingPlatform (>= 1.1)
- google_mobile_ads (1.0.0):
- google_mobile_ads (5.1.0):
- Flutter
- Google-Mobile-Ads-SDK (~> 10.4.0)
- Google-Mobile-Ads-SDK (~> 11.2.0)
- webview_flutter_wkwebview
- GoogleAppMeasurement (10.11.0):
- GoogleAppMeasurement/AdIdSupport (= 10.11.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (10.11.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.11.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (10.11.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleUserMessagingPlatform (2.0.1)
- GoogleUtilities/AppDelegateSwizzler (7.11.1):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.1):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.1):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.11.1):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.11.1):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.1)"
- GoogleUtilities/Reachability (7.11.1):
- GoogleUtilities/Logger
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- GoogleUserMessagingPlatform (2.5.0)
- integration_test (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- PromisesObjC (2.2.0)
- purchases_flutter (5.6.0):
- purchases_flutter (8.1.0):
- Flutter
- PurchasesHybridCommon (= 5.6.0)
- PurchasesHybridCommon (5.6.0):
- RevenueCat (= 4.25.2)
- RevenueCat (4.25.2)
- sqlite3 (3.41.2):
- sqlite3/common (= 3.41.2)
- sqlite3/common (3.41.2)
- sqlite3/fts5 (3.41.2):
- PurchasesHybridCommon (= 13.1.0)
- PurchasesHybridCommon (13.1.0):
- RevenueCat (= 5.3.0)
- RevenueCat (5.3.0)
- "sqlite3 (3.46.1+1)":
- "sqlite3/common (= 3.46.1+1)"
- "sqlite3/common (3.46.1+1)"
- "sqlite3/dbstatvtab (3.46.1+1)":
- sqlite3/common
- "sqlite3/fts5 (3.46.1+1)":
- sqlite3/common
- sqlite3/perf-threadsafe (3.41.2):
- "sqlite3/perf-threadsafe (3.46.1+1)":
- sqlite3/common
- sqlite3/rtree (3.41.2):
- "sqlite3/rtree (3.46.1+1)":
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
- sqlite3 (~> 3.41.2)
- "sqlite3 (~> 3.46.0+1)"
- sqlite3/dbstatvtab
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
- url_launcher_ios (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- google_mobile_ads (from `.symlinks/plugins/google_mobile_ads/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- purchases_flutter (from `.symlinks/plugins/purchases_flutter/ios`)
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)

SPEC REPOS:
trunk:
- Google-Mobile-Ads-SDK
- GoogleAppMeasurement
- GoogleUserMessagingPlatform
- GoogleUtilities
- nanopb
- PromisesObjC
- PurchasesHybridCommon
- RevenueCat
- sqlite3
Expand All @@ -111,6 +73,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_native_splash/ios"
google_mobile_ads:
:path: ".symlinks/plugins/google_mobile_ads/ios"
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
Expand All @@ -119,28 +83,28 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/purchases_flutter/ios"
sqlite3_flutter_libs:
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
Google-Mobile-Ads-SDK: 32fe7836431a06a29f7734ae092b600137c8108d
google_mobile_ads: 53b1f0d74445963e5810e34ac38dfb27aabe278e
GoogleAppMeasurement: d3dabccdb336fc0ae44b633c8abaa26559893cd9
GoogleUserMessagingPlatform: 5f8b30daf181805317b6b985bb51c1ff3beca054
GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
purchases_flutter: 3dc327cc188495bdbf5ed695cc6a774160b57b73
PurchasesHybridCommon: 45fc4487e06787e4b071510f9230e180f49a0a5f
RevenueCat: 3997b7af3ded18a59346e76f1365cae5a64f4281
sqlite3: fd89671d969f3e73efe503ce203e28b016b58f68
sqlite3_flutter_libs: 04ba0d14a04335a2fbf9a331e8664f401fbccdd5
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
Google-Mobile-Ads-SDK: 5a6d005a6cb5b5e8f4c7b69ca05cdea79c181139
google_mobile_ads: 9379c80fdfa9988fb0e105a407890ff8deb3cf86
GoogleUserMessagingPlatform: 6b4f48a370e77ce121d034c908cc6ee4fdafaf13
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
purchases_flutter: 81d2654605bb5c9f7d777f8b51e4c949ffea83cd
PurchasesHybridCommon: 04828bd308b446146db7976c35b54d62f3659a9b
RevenueCat: 4ad1d1c656f4d66bbfde7c83a4669fa1c1cb6527
sqlite3: 0bb0e6389d824e40296f531b858a2a0b71c0d2fb
sqlite3_flutter_libs: c00457ebd31e59fa6bb830380ddba24d44fbcd3b
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: 775997f741c536251164e3eacf6e34abf2eb7a17

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
1 change: 1 addition & 0 deletions ios/build/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f0f7b7c74e0cb0abb7131f886e5ff844
8 changes: 4 additions & 4 deletions lib/common/presentation/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class SettingsScreen extends StatelessWidget {
title: Text(S.of(context).settingsCleanUnusedPlayers),
onTap: () => const CleanupRoute().push(context),
),
ListTile(
title: Text(S.of(context).settingsGuide),
onTap: () => const GuideRoute().push(context),
),
// ListTile(
// title: Text(S.of(context).settingsGuide),
// onTap: () => const GuideRoute().push(context),
// ),
ListTile(
title: Text(S.of(context).settingsTheme),
onTap: () => const ThemeRoute().push(context),
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MyApp extends HookConsumerWidget {
initialLocation: HomeRoute.path,
debugLogDiagnostics: true,
routes: $appRoutes,
redirect: notifier.redirect),
redirect: (context, state) => notifier.redirect(state)),
[notifier],
);
return MaterialApp.router(
Expand Down
2 changes: 1 addition & 1 deletion lib/navigation/router_listenable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RouterListenable extends _$RouterListenable implements Listenable {
});
}

String? redirect(BuildContext context, GoRouterState state) {
String? redirect(GoRouterState state) {
if (state.error != null) {
return '/error';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tagros/data/source/db/app_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ part 'app_database.g.dart';
const bool kDebuggingDatabase = false;

class Players extends Table {
IntColumn get id => integer().autoIncrement().nullable()();
IntColumn get id => integer().autoIncrement()();

TextColumn get pseudo => text()();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/tagros/data/source/db/games_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class GamesDao extends DatabaseAccessor<AppDatabase> with _$GamesDaoMixin {
// This method is called whenever the list of games changes. For each
// game, now we want to load all the players in it
// Create a map from id to game, for performance reasons
final idToGame = {for (var game in games) game.id: game};
final idToGame = {for (final game in games) game.id: game};
final ids = idToGame.keys;

// Select all players that are included in any game that we found
Expand All @@ -106,7 +106,7 @@ class GamesDao extends DatabaseAccessor<AppDatabase> with _$GamesDaoMixin {

// Finally, merge the map of games with the map of players
return [
for (var id in ids)
for (final id in ids)
GameWithPlayers(
game: idToGame[id]!.toCompanion(true),
players: idToPlayers[id] ?? [])
Expand Down Expand Up @@ -172,7 +172,7 @@ class GamesDao extends DatabaseAccessor<AppDatabase> with _$GamesDaoMixin {
final id = await _newPlayer(playersCompanion: player);
playersIds.add(id);
} else {
playersIds.add(single.id!);
playersIds.add(single.id);
}
}
return playersIds;
Expand Down
Loading

0 comments on commit fb22531

Please sign in to comment.