Skip to content

Commit

Permalink
Wrap with AppLocalizationResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai committed Nov 20, 2024
2 parents c2b357b + 46caed0 commit 14a5424
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ app.*.map.json

lib/util/*secret.dart
*secret.dart

scripts/venv
1 change: 1 addition & 0 deletions lib/entity/some_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pilll/components/molecules/indicator.dart';
import 'package:pilll/provider/pill_sheet_group.dart';
import 'package:pilll/provider/setting.dart';

// NOTE: [Migrate:PillSheetAppearanceMode] setting -> latestPillSheetGroup の移行処理
class PillSheetAppearanceModeMigrationResolver extends HookConsumerWidget {
final Widget Function(BuildContext) builder;

const PillSheetAppearanceModeMigrationResolver({
super.key,
required this.builder,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
final setting = ref.watch(settingProvider);
final latestPillSheetGroup = ref.watch(latestPillSheetGroupProvider);
final setPillSheetGroup = ref.watch(setPillSheetGroupProvider);
final resolved = useState(false);

useEffect(() {
final f = (() async {
final settingData = setting.asData?.value;
final latestPillSheetGroupData = latestPillSheetGroup.asData?.value;
if (settingData == null || latestPillSheetGroupData == null) {
return;
}

try {
// NOTE: [Migrate:PillSheetAppearanceMode] SelectAppearanceModeModalでもsettingと同期をとっている。なので、移行が完了した後も実行し続けてもずれることはない
await setPillSheetGroup(
latestPillSheetGroupData.copyWith(
pillSheetAppearanceMode: settingData.pillSheetAppearanceMode,
),
);
if (!resolved.value) {
resolved.value = true;
}
} catch (error) {
debugPrint(error.toString());
}
});
f();
return null;
}, [latestPillSheetGroup.asData?.value != null, setting.asData?.value != null]);

if (resolved.value) {
return builder(context);
} else {
return const ScaffoldIndicator();
}
}
}
31 changes: 1 addition & 30 deletions lib/features/root/resolver/sync_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SyncDataResolver extends HookConsumerWidget {
final user = ref.watch(userProvider);
final setting = ref.watch(settingProvider);
final latestPillSheetGroup = ref.watch(latestPillSheetGroupProvider);
final setPillSheetGroup = ref.watch(setPillSheetGroupProvider);
useAutomaticKeepAlive(wantKeepAlive: true);

useEffect(() {
Expand Down Expand Up @@ -56,8 +55,7 @@ class SyncDataResolver extends HookConsumerWidget {
return;
}
try {
syncActivePillSheetValue(
pillSheetGroup: latestPillSheetGroup.asData?.value);
syncActivePillSheetValue(pillSheetGroup: latestPillSheetGroup.asData?.value);
} catch (error) {
debugPrint(error.toString());
}
Expand All @@ -67,33 +65,6 @@ class SyncDataResolver extends HookConsumerWidget {
return null;
}, [latestPillSheetGroup.asData?.value]);

// NOTE: [Migrate:PillSheetAppearanceMode] setting -> latestPillSheetGroup の移行処理
useEffect(() {
final f = (() async {
final settingData = setting.asData?.value;
final latestPillSheetGroupData = latestPillSheetGroup.asData?.value;
if (settingData == null || latestPillSheetGroupData == null) {
return;
}

try {
// NOTE: [Migrate:PillSheetAppearanceMode] SelectAppearanceModeModalでもsettingと同期をとっている。なので、移行が完了した後も実行し続けてもずれることはない
setPillSheetGroup(
latestPillSheetGroupData.copyWith(
pillSheetAppearanceMode: settingData.pillSheetAppearanceMode,
),
);
} catch (error) {
debugPrint(error.toString());
}
});
f();
return null;
}, [
latestPillSheetGroup.asData?.value != null,
setting.asData?.value != null
]);

return const SizedBox();
}
}
9 changes: 7 additions & 2 deletions lib/features/root/root_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:pilll/features/root/resolver/firebase_auth_resolver.dart';
import 'package:pilll/features/root/resolver/force_update.dart';
import 'package:pilll/features/root/resolver/initial_setting_or_app_page.dart';
import 'package:pilll/features/root/resolver/migration20240819.dart';
import 'package:pilll/features/root/resolver/pill_sheet_appearance_mode_migration.dart';
import 'package:pilll/features/root/resolver/show_paywall_on_app_launch.dart';
import 'package:pilll/features/root/resolver/skip_initial_setting.dart';
import 'package:pilll/features/root/resolver/sync_data.dart';
Expand All @@ -33,10 +34,14 @@ class RootPage extends HookConsumerWidget {
initialSettingPageBuilder: (_) => ShowPaywallOnAppLaunch(
builder: (_) => SkipInitialSetting(
initialSettingPageBuilder: (context) => InitialSettingPillSheetGroupPageRoute.screen(),
homePageBuilder: (_) => const HomePage(),
homePageBuilder: (_) => PillSheetAppearanceModeMigrationResolver(
builder: (_) => const HomePage(),
),
),
),
homePageBuilder: (_) => const HomePage(),
homePageBuilder: (_) => PillSheetAppearanceModeMigrationResolver(
builder: (_) => const HomePage(),
),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 202411.18.135853
version: 202411.21.074218

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit 14a5424

Please sign in to comment.