summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/core/utils/widgets/back_button.dart4
-rw-r--r--lib/data/data_providers/app_provider.dart21
-rw-r--r--lib/presentation/common_widget/custom_bottom_bar.dart2
-rw-r--r--lib/presentation/screens/home/home.dart8
-rw-r--r--lib/presentation/screens/media/play_list_table.dart3
-rw-r--r--lib/presentation/screens/media/radio_preset_table.dart3
-rw-r--r--lib/presentation/screens/settings/settings_screens/audio_settings/audio_settings_screen.dart7
-rw-r--r--lib/presentation/screens/settings/widgets/settings_content.dart30
-rw-r--r--lib/presentation/screens/splash/widget/splash_content.dart5
9 files changed, 45 insertions, 38 deletions
diff --git a/lib/core/utils/widgets/back_button.dart b/lib/core/utils/widgets/back_button.dart
index 8f0862b..9d7db02 100644
--- a/lib/core/utils/widgets/back_button.dart
+++ b/lib/core/utils/widgets/back_button.dart
@@ -7,9 +7,7 @@ class CustomBackButton extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
return BackButton(
onPressed: () {
- ref.read(appProvider.notifier).update(
- (state) => state = AppState.home,
- );
+ ref.read(appProvider.notifier).update(AppState.home);
},
);
}
diff --git a/lib/data/data_providers/app_provider.dart b/lib/data/data_providers/app_provider.dart
index ee6d29e..a74c0fd 100644
--- a/lib/data/data_providers/app_provider.dart
+++ b/lib/data/data_providers/app_provider.dart
@@ -47,7 +47,26 @@ enum AppState {
year
}
-final appProvider = StateProvider<AppState>((ref) => AppState.splash);
+class AppStateNotifier extends Notifier<AppState> {
+ AppState previous = AppState.home;
+
+ @override
+ AppState build() {
+ return AppState.splash;
+ }
+
+ void update(AppState newState) {
+ previous = state;
+ state = newState;
+ }
+
+ void back() {
+ state = previous;
+ }
+}
+
+final appProvider =
+ NotifierProvider<AppStateNotifier, AppState>(AppStateNotifier.new);
final valClientProvider = Provider((ref) {
KuksaConfig config = ref.watch(appConfigProvider).kuksaConfig;
diff --git a/lib/presentation/common_widget/custom_bottom_bar.dart b/lib/presentation/common_widget/custom_bottom_bar.dart
index 19c56b9..ee5168d 100644
--- a/lib/presentation/common_widget/custom_bottom_bar.dart
+++ b/lib/presentation/common_widget/custom_bottom_bar.dart
@@ -46,7 +46,7 @@ class CustomBottomBarState extends ConsumerState<CustomBottomBar> {
});
ref.read(appLauncherProvider).activateApp("homescreen");
ref.read(currentTimeProvider.notifier).isYearChanged = false;
- ref.read(appProvider.notifier).update((state) => state = status);
+ ref.read(appProvider.notifier).update(status);
}
@override
diff --git a/lib/presentation/screens/home/home.dart b/lib/presentation/screens/home/home.dart
index 3d80f92..8f0d125 100644
--- a/lib/presentation/screens/home/home.dart
+++ b/lib/presentation/screens/home/home.dart
@@ -28,7 +28,7 @@ class HomeScreenState extends ConsumerState<HomeScreen> {
BuildContext context,
) {
return Consumer(builder: (context, ref, child) {
- final state = ref.read(appProvider);
+ final appState = ref.watch(appProvider);
final bool disableBkgAnimation =
ref.read(appConfigProvider).disableBkgAnimation;
if (disableBkgAnimation) {
@@ -48,13 +48,13 @@ class HomeScreenState extends ConsumerState<HomeScreen> {
repeat: true,
),
FlowBuilder<AppState>(
- state: ref.watch(appProvider),
+ state: appState,
onGeneratePages: onGenerateAppViewPages,
observers: [
HeroController(),
],
),
- if (state != AppState.splash)
+ if (appState != AppState.splash)
Positioned(
top: 0,
bottom: 0,
@@ -66,7 +66,7 @@ class HomeScreenState extends ConsumerState<HomeScreen> {
],
),
bottomNavigationBar:
- state == AppState.splash ? null : const CustomBottomBar(),
+ appState == AppState.splash ? null : const CustomBottomBar(),
);
});
}
diff --git a/lib/presentation/screens/media/play_list_table.dart b/lib/presentation/screens/media/play_list_table.dart
index 71d2fc9..28cb970 100644
--- a/lib/presentation/screens/media/play_list_table.dart
+++ b/lib/presentation/screens/media/play_list_table.dart
@@ -61,6 +61,9 @@ class _PlayListTableState extends ConsumerState<PlayListTable> {
onTap: () {
setState(() {
isAudioSettingsEnabled = !isAudioSettingsEnabled;
+ ref
+ .read(appProvider.notifier)
+ .update(AppState.audioSettings);
});
},
child: Padding(
diff --git a/lib/presentation/screens/media/radio_preset_table.dart b/lib/presentation/screens/media/radio_preset_table.dart
index 97affb8..fcf8e2b 100644
--- a/lib/presentation/screens/media/radio_preset_table.dart
+++ b/lib/presentation/screens/media/radio_preset_table.dart
@@ -64,6 +64,9 @@ class _RadioPresetTableState extends ConsumerState<RadioPresetTable> {
onTap: () {
setState(() {
isAudioSettingsEnabled = !isAudioSettingsEnabled;
+ ref
+ .read(appProvider.notifier)
+ .update(AppState.audioSettings);
});
},
child: Padding(
diff --git a/lib/presentation/screens/settings/settings_screens/audio_settings/audio_settings_screen.dart b/lib/presentation/screens/settings/settings_screens/audio_settings/audio_settings_screen.dart
index 3c3508e..2b14b7f 100644
--- a/lib/presentation/screens/settings/settings_screens/audio_settings/audio_settings_screen.dart
+++ b/lib/presentation/screens/settings/settings_screens/audio_settings/audio_settings_screen.dart
@@ -2,7 +2,6 @@ import 'package:flutter_ics_homescreen/export.dart';
import 'widget/audio_content.dart';
-
class AudioSettingsPage extends ConsumerWidget {
const AudioSettingsPage({super.key});
@@ -17,14 +16,12 @@ class AudioSettingsPage extends ConsumerWidget {
title: 'Audio Settings',
hasBackButton: true,
onPressed: () {
- context.flow<AppState>().update((state) => AppState.settings);
+ ref.read(appProvider.notifier).back();
},
),
- const Expanded(
- child: AudioContent()),
+ const Expanded(child: AudioContent()),
],
),
);
}
}
-
diff --git a/lib/presentation/screens/settings/widgets/settings_content.dart b/lib/presentation/screens/settings/widgets/settings_content.dart
index f73bf6d..6d0df50 100644
--- a/lib/presentation/screens/settings/widgets/settings_content.dart
+++ b/lib/presentation/screens/settings/widgets/settings_content.dart
@@ -2,13 +2,13 @@ import 'package:flutter_ics_homescreen/export.dart';
import '../../../custom_icons/custom_icons.dart';
-class Settings extends StatelessWidget {
+class Settings extends ConsumerWidget {
const Settings({
super.key,
});
@override
- Widget build(BuildContext context) {
+ Widget build(BuildContext context, WidgetRef ref) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
//crossAxisAlignment: CrossAxisAlignment.center,
@@ -25,66 +25,56 @@ class Settings extends StatelessWidget {
title: 'Date & Time',
hasSwich: false,
voidCallback: () async {
- context
- .flow<AppState>()
- .update((next) => AppState.dateTime);
+ ref.read(appProvider.notifier).update(AppState.dateTime);
}),
SettingsTile(
icon: Icons.bluetooth,
title: 'Bluetooth',
hasSwich: true,
voidCallback: () {
- context
- .flow<AppState>()
- .update((next) => AppState.bluetooth);
+ ref.read(appProvider.notifier).update(AppState.bluetooth);
}),
SettingsTile(
icon: Icons.wifi,
title: 'Wifi',
hasSwich: true,
voidCallback: () {
- context.flow<AppState>().update((next) => AppState.wifi);
+ ref.read(appProvider.notifier).update(AppState.wifi);
}),
SettingsTile(
icon: CustomIcons.wiredicon,
title: 'Wired',
hasSwich: false,
voidCallback: () {
- context.flow<AppState>().update((next) => AppState.wired);
+ ref.read(appProvider.notifier).update(AppState.wired);
}),
SettingsTile(
icon: Icons.tune,
title: 'Audio Settings',
hasSwich: false,
voidCallback: () {
- context
- .flow<AppState>()
- .update((next) => AppState.audioSettings);
+ ref.read(appProvider.notifier).update(AppState.audioSettings);
}),
SettingsTile(
icon: Icons.person_2_outlined,
title: 'Profiles',
hasSwich: false,
voidCallback: () {
- context
- .flow<AppState>()
- .update((next) => AppState.profiles);
+ ref.read(appProvider.notifier).update(AppState.profiles);
}),
SettingsTile(
icon: Icons.straighten,
title: 'Units',
hasSwich: false,
voidCallback: () {
- context.flow<AppState>().update((next) => AppState.units);
+ ref.read(appProvider.notifier).update(AppState.units);
}),
SettingsTile(
icon: Icons.help_sharp,
title: 'Version Info',
hasSwich: false,
voidCallback: () {
- context
- .flow<AppState>()
- .update((next) => AppState.versionInfo);
+ ref.read(appProvider.notifier).update(AppState.versionInfo);
}),
],
),
diff --git a/lib/presentation/screens/splash/widget/splash_content.dart b/lib/presentation/screens/splash/widget/splash_content.dart
index 51ee71f..6051dcf 100644
--- a/lib/presentation/screens/splash/widget/splash_content.dart
+++ b/lib/presentation/screens/splash/widget/splash_content.dart
@@ -131,10 +131,7 @@ class SplashContentState extends ConsumerState<SplashContent>
width: 452,
text: 'Continue',
onTap: () {
- // ref.read(vehicleProvider.notifier).setInitialState();
- ref
- .read(appProvider.notifier)
- .update((state) => state = AppState.dashboard);
+ ref.read(appProvider.notifier).update(AppState.dashboard);
},
),
const SizedBox(