diff --git a/lib/data/appProviders/preferences_provider.dart b/lib/data/appProviders/preferences_provider.dart index de440ef..4ed0b1d 100644 --- a/lib/data/appProviders/preferences_provider.dart +++ b/lib/data/appProviders/preferences_provider.dart @@ -1,5 +1,5 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:iccm_eu_app/data/dataProviders/events_provider.dart'; import 'package:shared_preferences/shared_preferences.dart' show SharedPreferences; class PreferencesProvider { @@ -75,7 +75,7 @@ class PreferencesProvider { static Future loadUseTestData() async { bool value = false; - if (kDebugMode) { + if (EventsProvider.showTestDataOption()) { final prefs = await SharedPreferences.getInstance(); value = prefs.getBool(_useTestDataKey) ?? false; // Default } @@ -83,7 +83,7 @@ class PreferencesProvider { } static Future setUseTestData(bool value) async { - if (kDebugMode) { + if (EventsProvider.showTestDataOption()) { useTestDataNotifier.value = value; final prefs = await SharedPreferences.getInstance(); await prefs.setBool(_useTestDataKey, value); diff --git a/lib/data/dataProviders/events_provider.dart b/lib/data/dataProviders/events_provider.dart index 5534f49..2754a08 100644 --- a/lib/data/dataProviders/events_provider.dart +++ b/lib/data/dataProviders/events_provider.dart @@ -29,7 +29,8 @@ class EventsProvider with ChangeNotifier { } void updateCache() { - if (kDebugMode && PreferencesProvider.useTestDataNotifier.value) { + if (EventsProvider.showTestDataOption() && + PreferencesProvider.useTestDataNotifier.value) { _cacheClear(); for (EventData item in TestData.getEvents()) { _cacheAdd(item); @@ -282,4 +283,11 @@ class EventsProvider with ChangeNotifier { return next.start; } } + + static bool showTestDataOption() { + bool value = kDebugMode; + // Overwrite during development + value = true; + return value; + } } diff --git a/lib/data/dataProviders/gsheets_provider.dart b/lib/data/dataProviders/gsheets_provider.dart index e34eea5..6ac8f98 100644 --- a/lib/data/dataProviders/gsheets_provider.dart +++ b/lib/data/dataProviders/gsheets_provider.dart @@ -172,7 +172,8 @@ class GsheetsProvider with ChangeNotifier { return; } - if (!kDebugMode || !PreferencesProvider.useTestDataNotifier.value) { + if (!EventsProvider.showTestDataOption() || + !PreferencesProvider.useTestDataNotifier.value) { List workSheetTitles = []; workSheetTitles.add(EventsProvider.worksheetTitle); workSheetTitles.add(RoomsProvider.worksheetTitle); diff --git a/lib/data/dataProviders/rooms_provider.dart b/lib/data/dataProviders/rooms_provider.dart index 493bb1c..d9e622a 100644 --- a/lib/data/dataProviders/rooms_provider.dart +++ b/lib/data/dataProviders/rooms_provider.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:iccm_eu_app/data/appProviders/preferences_provider.dart'; +import 'package:iccm_eu_app/data/dataProviders/events_provider.dart'; import 'package:iccm_eu_app/data/dataProviders/gsheets_provider.dart'; import 'package:iccm_eu_app/data/definitions/item_colors_dictionary.dart'; import 'package:iccm_eu_app/data/model/room_data.dart'; @@ -31,7 +32,8 @@ class RoomsProvider with ChangeNotifier { } void updateCache() { - if (kDebugMode && PreferencesProvider.useTestDataNotifier.value) { + if (EventsProvider.showTestDataOption() && + PreferencesProvider.useTestDataNotifier.value) { _cacheClear(); for (RoomData item in TestData.rooms) { _cacheAdd(item); diff --git a/lib/data/dataProviders/speakers_provider.dart b/lib/data/dataProviders/speakers_provider.dart index 3e8f436..46ea02a 100644 --- a/lib/data/dataProviders/speakers_provider.dart +++ b/lib/data/dataProviders/speakers_provider.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:iccm_eu_app/data/appProviders/preferences_provider.dart'; +import 'package:iccm_eu_app/data/dataProviders/events_provider.dart'; import 'package:iccm_eu_app/data/dataProviders/gsheets_provider.dart'; import 'package:iccm_eu_app/data/model/speaker_data.dart'; import 'package:iccm_eu_app/data/testData/test_data.dart'; @@ -29,7 +30,8 @@ class SpeakersProvider with ChangeNotifier { } void updateCache() { - if (kDebugMode && PreferencesProvider.useTestDataNotifier.value) { + if (EventsProvider.showTestDataOption() && + PreferencesProvider.useTestDataNotifier.value) { _cacheClear(); for (SpeakerData item in TestData.speakers) { _cacheAdd(item); diff --git a/lib/data/dataProviders/tracks_provider.dart b/lib/data/dataProviders/tracks_provider.dart index da1b5e2..89d49fb 100644 --- a/lib/data/dataProviders/tracks_provider.dart +++ b/lib/data/dataProviders/tracks_provider.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:iccm_eu_app/data/appProviders/preferences_provider.dart'; +import 'package:iccm_eu_app/data/dataProviders/events_provider.dart'; import 'package:iccm_eu_app/data/dataProviders/gsheets_provider.dart'; import 'package:iccm_eu_app/data/definitions/item_colors_dictionary.dart'; import 'package:iccm_eu_app/data/model/track_data.dart'; @@ -33,7 +34,8 @@ class TracksProvider with ChangeNotifier { } void updateCache() { - if (kDebugMode && PreferencesProvider.useTestDataNotifier.value) { + if (EventsProvider.showTestDataOption() && + PreferencesProvider.useTestDataNotifier.value) { Debug.msg("Updating TrackData cache from TestData ($kDebugMode, ${PreferencesProvider.useTestDataNotifier.value})."); _cacheClear(); for (TrackData item in TestData.tracks) { diff --git a/lib/pages/preferences_page.dart b/lib/pages/preferences_page.dart index a45cf3d..d161291 100644 --- a/lib/pages/preferences_page.dart +++ b/lib/pages/preferences_page.dart @@ -1,9 +1,9 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:iccm_eu_app/components/toggle_button.dart'; import 'package:iccm_eu_app/components/toggle_is_dark_mode.dart'; import 'package:iccm_eu_app/data/appProviders/preferences_provider.dart'; import 'package:iccm_eu_app/data/dataProviders/error_provider.dart'; +import 'package:iccm_eu_app/data/dataProviders/events_provider.dart'; import 'package:iccm_eu_app/data/dataProviders/gsheets_provider.dart'; import 'package:provider/provider.dart'; @@ -73,11 +73,11 @@ class PreferencesPage extends StatelessWidget { ); }, ), - if (kDebugMode) + if (EventsProvider.showTestDataOption()) const Divider() else const SizedBox.shrink(), - if (kDebugMode) + if (EventsProvider.showTestDataOption()) Text('Test Data', style: Theme .of(context) @@ -86,7 +86,7 @@ class PreferencesPage extends StatelessWidget { ) else const SizedBox.shrink(), - if (kDebugMode) + if (EventsProvider.showTestDataOption()) ValueListenableBuilder( valueListenable: PreferencesProvider.useTestDataNotifier, builder: (context, builderValue, child) {