diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index cb7e498..9c30324 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -151,11 +151,12 @@ void main() async { await tester.pumpAndSettle(); Plan plan = providerContainer.read(plansProvider).plans.first; + buildContext = tester.element(find.byKey(const Key('plans-grid'))); expect(plan.name, null); expect(plan.scheduleKey.type, ScheduleType.chronological); expect(plan.scheduleKey.duration, ScheduleDuration.y1); expect(plan.scheduleKey.version, '1.0'); - expect(plan.language, 'en'); + expect(plan.language, Localizations.localeOf(buildContext).languageCode); expect(plan.withTargetDate, true); expect(plan.showEvents, true); expect(plan.showLocations, false); diff --git a/lib/src/plans/entities/plan.dart b/lib/src/plans/entities/plan.dart index 4f0d390..a60960d 100644 --- a/lib/src/plans/entities/plan.dart +++ b/lib/src/plans/entities/plan.dart @@ -135,7 +135,7 @@ class Plan extends Equatable { required this.id, this.name, required this.scheduleKey, - required this.language, + this.language, required this.bookmark, this.startDate, this.lastDate, @@ -148,7 +148,7 @@ class Plan extends Equatable { final String id; final String? name; final ScheduleKey scheduleKey; - final String language; + final String? language; final Bookmark bookmark; final DateTime? startDate; final DateTime? lastDate; diff --git a/lib/src/plans/entities/plans.dart b/lib/src/plans/entities/plans.dart index 7327f9c..1f4870c 100644 --- a/lib/src/plans/entities/plans.dart +++ b/lib/src/plans/entities/plans.dart @@ -30,7 +30,6 @@ class PlansNotifier extends Notifier { return Plan( id: planId, scheduleKey: scheduleKey, - language: 'en', bookmark: const Bookmark(dayIndex: 0, sectionIndex: -1), withTargetDate: true, showEvents: true, diff --git a/lib/src/plans/presentations/plan_language_tile.dart b/lib/src/plans/presentations/plan_language_tile.dart index 1be50ca..657737c 100644 --- a/lib/src/plans/presentations/plan_language_tile.dart +++ b/lib/src/plans/presentations/plan_language_tile.dart @@ -13,6 +13,11 @@ class PlanLanguageTile extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final plan = ref.watch(planEditProviderFamily(planId)); final planEdit = ref.read(planEditProviderFamily(planId).notifier); + Future.microtask(() { + if (plan.language == null && context.mounted) { + planEdit.updateLanguage(Localizations.localeOf(context).languageCode); + } + }); final bibleLanguages = ref.watch(bibleLanguagesProvider).valueOrNull; return ListTile( diff --git a/lib/src/plans/presentations/plans_page.dart b/lib/src/plans/presentations/plans_page.dart index b4519fc..b1bfa78 100644 --- a/lib/src/plans/presentations/plans_page.dart +++ b/lib/src/plans/presentations/plans_page.dart @@ -48,7 +48,9 @@ class PlansPageState extends ConsumerState { ), ], ), - body: PlansGrid(), + body: PlansGrid( + key: const Key('plans-grid'), + ), floatingActionButton: FloatingActionButton( tooltip: context.loc.plansPageAddPlanTooltip, onPressed: () => showDialog( diff --git a/lib/src/plans/repositories/plans_serializer.dart b/lib/src/plans/repositories/plans_serializer.dart index 2b0c583..43f9670 100644 --- a/lib/src/plans/repositories/plans_serializer.dart +++ b/lib/src/plans/repositories/plans_serializer.dart @@ -12,7 +12,7 @@ class PlansSerializer { 'id': plan.id, if (plan.name != null) 'name': plan.name, 'scheduleKey': _convertScheduleKeyToMap(plan.scheduleKey), - 'language': plan.language, + if (plan.language != null) 'language': plan.language, 'bookmark': _convertBookmarkToMap(plan.bookmark), if (plan.startDate != null) 'startDate': plan.startDate!.toIso8601String(),