From 3be26b8fb632ccca2834f238403d9d68150a0a4f Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Tue, 9 Jan 2024 19:27:30 +0100 Subject: [PATCH] Update riverpod to 1.0 --- .../actions/calendar_action_handler.dart | 2 +- lib/background/main_background.dart | 7 +++--- lib/background/modules/apps_background.dart | 12 +++++----- .../modules/calendar_background.dart | 10 ++++----- .../modules/notifications_background.dart | 4 ++-- .../notification/notification_manager.dart | 2 +- lib/domain/api/appstore/appstore.dart | 2 +- lib/domain/api/auth/auth.dart | 7 +++--- lib/domain/api/auth/oauth.dart | 2 +- lib/domain/api/boot/boot.dart | 2 +- lib/domain/apps/app_logs.dart | 2 +- .../device_calendar_plugin_provider.dart | 4 ++-- .../raw_incoming_packets_provider.dart | 2 +- .../db/dao/active_notification_dao.dart | 2 +- lib/domain/db/dao/app_dao.dart | 2 +- lib/domain/db/dao/locker_cache_dao.dart | 2 +- .../db/dao/notification_channel_dao.dart | 2 +- lib/domain/db/dao/timeline_pin_dao.dart | 2 +- lib/domain/package_details.dart | 2 +- lib/domain/permissions.dart | 4 ++-- lib/domain/preferences.dart | 2 +- lib/domain/secure_storage.dart | 2 +- lib/domain/timeline/watch_apps_syncer.dart | 2 +- .../timeline/watch_timeline_syncer.dart | 2 +- .../backgroundcomm/BackgroundRpc.dart | 2 +- .../datasources/paired_storage.dart | 4 ++-- .../datasources/preferences.dart | 22 +++++++++---------- .../datasources/secure_storage.dart | 6 ++--- lib/main.dart | 12 +++++----- lib/ui/devoptions/debug_options_page.dart | 12 +++++----- lib/ui/devoptions/dev_options_page.dart | 12 +++++----- lib/ui/devoptions/test_logs_page.dart | 6 ++--- lib/ui/home/tabs/locker_tab.dart | 12 +++++----- lib/ui/home/tabs/locker_tab/apps_item.dart | 5 +++-- lib/ui/home/tabs/locker_tab/faces_card.dart | 5 +++-- lib/ui/home/tabs/test_tab.dart | 14 ++++++------ lib/ui/home/tabs/watches_tab.dart | 14 ++++++------ lib/ui/screens/alerting_app_details.dart | 10 ++++----- lib/ui/screens/alerting_apps.dart | 9 ++++---- lib/ui/screens/calendar.dart | 20 ++++++++--------- lib/ui/screens/install_prompt.dart | 10 ++++----- lib/ui/screens/notifications.dart | 12 +++++----- lib/ui/screens/settings.dart | 8 +++---- lib/ui/setup/boot/rebble_setup.dart | 6 ++--- lib/ui/setup/boot/rebble_setup_fail.dart | 6 ++--- lib/ui/setup/boot/rebble_setup_success.dart | 8 +++---- lib/ui/setup/pair_page.dart | 16 +++++++------- lib/ui/splash/splash_page.dart | 6 ++--- lib/util/container_extensions.dart | 12 +++++----- pubspec.lock | 20 +++++------------ pubspec.yaml | 2 +- test/domain/calendar/calendar_list_test.dart | 10 ++++----- .../domain/calendar/calendar_syncer_test.dart | 20 ++++++++--------- test/domain/setup/pair_page_test.dart | 2 +- 54 files changed, 190 insertions(+), 195 deletions(-) diff --git a/lib/background/actions/calendar_action_handler.dart b/lib/background/actions/calendar_action_handler.dart index 73d34956..f4f17618 100644 --- a/lib/background/actions/calendar_action_handler.dart +++ b/lib/background/actions/calendar_action_handler.dart @@ -210,7 +210,7 @@ class CalendarActionHandler implements ActionHandler { } } -final calendarActionHandlerProvider = Provider((ref) => +final calendarActionHandlerProvider = Provider((ref) => CalendarActionHandler( ref.read(timelinePinDaoProvider), ref.read(calendarSyncerProvider), diff --git a/lib/background/main_background.dart b/lib/background/main_background.dart index 6bac550d..e1a96254 100644 --- a/lib/background/main_background.dart +++ b/lib/background/main_background.dart @@ -52,10 +52,9 @@ class BackgroundReceiver implements TimelineCallbacks { masterActionHandler = container.read(masterActionHandlerProvider); - connectionSubscription = container.listen( - connectionStateProvider, - mayHaveChanged: (sub) { - final currentConnectedWatch = sub.read().currentConnectedWatch; + connectionSubscription = container.listen( + connectionStateProvider, (previous, sub) { + final currentConnectedWatch = sub.currentConnectedWatch; if (isConnectedToWatch()! && currentConnectedWatch!.name!.isNotEmpty) { onWatchConnected(currentConnectedWatch); } diff --git a/lib/background/modules/apps_background.dart b/lib/background/modules/apps_background.dart index 67c3a0a9..5f7f3feb 100644 --- a/lib/background/modules/apps_background.dart +++ b/lib/background/modules/apps_background.dart @@ -27,15 +27,15 @@ class AppsBackground implements BackgroundAppInstallCallbacks { AppsBackground(this.container); void init() async { - watchAppsSyncer = container.listen(watchAppSyncerProvider).read(); - appDao = container.listen(appDaoProvider).read(); - appLifecycleManager = container.listen(appLifecycleManagerProvider).read(); - preferences = container.listen(preferencesProvider.future).read(); + watchAppsSyncer = container.listen(watchAppSyncerProvider, (previous, value) {}).read(); + appDao = container.listen(appDaoProvider, (previous, value) {}).read(); + appLifecycleManager = container.listen(appLifecycleManagerProvider, (previous, value) {}).read(); + preferences = container.listen>(preferencesProvider.future, (previous, value) {}).read(); BackgroundAppInstallCallbacks.setup(this); - connectionSubscription = container.listen( - connectionStateProvider, + connectionSubscription = container.listen( + connectionStateProvider, (previous, value) {}, ); } diff --git a/lib/background/modules/calendar_background.dart b/lib/background/modules/calendar_background.dart index 460113fd..4bbdce98 100644 --- a/lib/background/modules/calendar_background.dart +++ b/lib/background/modules/calendar_background.dart @@ -21,14 +21,14 @@ class CalendarBackground implements CalendarCallbacks { CalendarBackground(this.container); void init() async { - calendarSyncer = container.listen(calendarSyncerProvider).read(); - watchTimelineSyncer = container.listen(watchTimelineSyncerProvider).read(); - timelinePinDao = container.listen(timelinePinDaoProvider).read(); + calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); + watchTimelineSyncer = container.listen(watchTimelineSyncerProvider, (previous, value) {}).read(); + timelinePinDao = container.listen(timelinePinDaoProvider, (previous, value) {}).read(); CalendarCallbacks.setup(this); - connectionSubscription = container.listen( - connectionStateProvider, + connectionSubscription = container.listen( + connectionStateProvider, (previous, value) {}, ); } diff --git a/lib/background/modules/notifications_background.dart b/lib/background/modules/notifications_background.dart index 3cf64489..dcc68b6f 100644 --- a/lib/background/modules/notifications_background.dart +++ b/lib/background/modules/notifications_background.dart @@ -14,8 +14,8 @@ class NotificationsBackground implements NotificationListening { NotificationsBackground(this.container); void init() async { - notificationManager = container.listen(notificationManagerProvider).read(); - _notificationChannelDao = container.listen(notifChannelDaoProvider).read(); + notificationManager = container.listen(notificationManagerProvider, (previous, value) {}).read(); + _notificationChannelDao = container.listen(notifChannelDaoProvider, (previous, value) {}).read(); NotificationListening.setup(this); } diff --git a/lib/background/notification/notification_manager.dart b/lib/background/notification/notification_manager.dart index 554b830b..4e77fd3d 100644 --- a/lib/background/notification/notification_manager.dart +++ b/lib/background/notification/notification_manager.dart @@ -232,7 +232,7 @@ class NotificationManager { } } -final notificationManagerProvider = Provider((ref) => NotificationManager(ref.read(activeNotifDaoProvider), ref.read(notifChannelDaoProvider), ref.read(sharedPreferencesProvider))); +final notificationManagerProvider = Provider((ref) => NotificationManager(ref.read(activeNotifDaoProvider), ref.read(notifChannelDaoProvider), ref.read(sharedPreferencesProvider))); final disabledActionPackagesKey = "disabledActionPackages"; diff --git a/lib/domain/api/appstore/appstore.dart b/lib/domain/api/appstore/appstore.dart index c6e072dd..5bcbc0a4 100644 --- a/lib/domain/api/appstore/appstore.dart +++ b/lib/domain/api/appstore/appstore.dart @@ -6,7 +6,7 @@ import 'package:cobble/infrastructure/datasources/secure_storage.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:cobble/infrastructure/datasources/web_services/appstore.dart'; -final appstoreServiceProvider = FutureProvider((ref) async { +final appstoreServiceProvider = FutureProvider((ref) async { final boot = await (await ref.watch(bootServiceProvider.future)).config; final token = await (await ref.watch(tokenProvider.last)); final oauth = await ref.watch(oauthClientProvider.future); diff --git a/lib/domain/api/auth/auth.dart b/lib/domain/api/auth/auth.dart index 00d861fd..f3cdc23a 100644 --- a/lib/domain/api/auth/auth.dart +++ b/lib/domain/api/auth/auth.dart @@ -1,4 +1,5 @@ import 'package:cobble/domain/api/auth/oauth.dart'; +import 'package:cobble/domain/api/auth/user.dart'; import 'package:cobble/domain/api/boot/boot.dart'; import 'package:cobble/domain/api/no_token_exception.dart'; import 'package:cobble/infrastructure/datasources/preferences.dart'; @@ -6,7 +7,7 @@ import 'package:cobble/infrastructure/datasources/secure_storage.dart'; import 'package:cobble/infrastructure/datasources/web_services/auth.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -final authServiceProvider = FutureProvider((ref) async { +final authServiceProvider = FutureProvider((ref) async { final boot = await (await ref.watch(bootServiceProvider.future)).config; final token = await (await ref.watch(tokenProvider.last)); final oauth = await ref.watch(oauthClientProvider.future); @@ -17,11 +18,11 @@ final authServiceProvider = FutureProvider((ref) async { return AuthService(boot.auth.base, prefs, oauth, token); }); -final authUserProvider = FutureProvider((ref) async { +final authUserProvider = FutureProvider((ref) async { try { final auth = await ref.watch(authServiceProvider.future); return await auth.user; } on NoTokenException { return null; } -}); \ No newline at end of file +}); diff --git a/lib/domain/api/auth/oauth.dart b/lib/domain/api/auth/oauth.dart index 7a508346..de8cff9a 100644 --- a/lib/domain/api/auth/oauth.dart +++ b/lib/domain/api/auth/oauth.dart @@ -186,7 +186,7 @@ class OAuthException implements Exception { String toString() => "OAuthException: $errorCode"; } -final oauthClientProvider = FutureProvider((ref) async { +final oauthClientProvider = FutureProvider((ref) async { final boot = await (await ref.watch(bootServiceProvider.future)).config; final prefs = await ref.watch(preferencesProvider.future); final secureStorage = ref.watch(secureStorageProvider); diff --git a/lib/domain/api/boot/boot.dart b/lib/domain/api/boot/boot.dart index ae1a7874..d7907c2a 100644 --- a/lib/domain/api/boot/boot.dart +++ b/lib/domain/api/boot/boot.dart @@ -2,6 +2,6 @@ import 'package:cobble/infrastructure/datasources/preferences.dart'; import 'package:cobble/infrastructure/datasources/web_services/boot.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -final bootServiceProvider = FutureProvider( +final bootServiceProvider = FutureProvider( (ref) async => BootService(await ref.watch(bootUrlProvider.last) ?? ""), ); \ No newline at end of file diff --git a/lib/domain/apps/app_logs.dart b/lib/domain/apps/app_logs.dart index 8e624517..c3d15b5d 100644 --- a/lib/domain/apps/app_logs.dart +++ b/lib/domain/apps/app_logs.dart @@ -27,7 +27,7 @@ class AppLogReceiver extends StateNotifier> } } -final recievedLogsProvider = StateNotifierProvider.autoDispose((ref) { +final recievedLogsProvider = StateNotifierProvider.autoDispose((ref) { final receiver = AppLogReceiver(); ref.onDispose(() { diff --git a/lib/domain/calendar/device_calendar_plugin_provider.dart b/lib/domain/calendar/device_calendar_plugin_provider.dart index 01d04cac..5a326b5d 100644 --- a/lib/domain/calendar/device_calendar_plugin_provider.dart +++ b/lib/domain/calendar/device_calendar_plugin_provider.dart @@ -2,6 +2,6 @@ import 'package:cobble/infrastructure/pigeons/pigeons.g.dart'; import 'package:device_calendar/device_calendar.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -final deviceCalendarPluginProvider = Provider((ref) => DeviceCalendarPlugin()); +final deviceCalendarPluginProvider = Provider((ref) => DeviceCalendarPlugin()); -final calendarControlProvider = Provider((ref) => CalendarControl()); +final calendarControlProvider = Provider((ref) => CalendarControl()); diff --git a/lib/domain/connection/raw_incoming_packets_provider.dart b/lib/domain/connection/raw_incoming_packets_provider.dart index 07d4151e..6d26f4e4 100644 --- a/lib/domain/connection/raw_incoming_packets_provider.dart +++ b/lib/domain/connection/raw_incoming_packets_provider.dart @@ -36,5 +36,5 @@ class RawIncomingPacketsProvider implements RawIncomingPacketsCallbacks { Stream get stream => _streamController.stream; } -final Provider> rawPacketStreamProvider = Provider((ref) => RawIncomingPacketsProvider().stream); +final Provider> rawPacketStreamProvider = Provider>((ref) => RawIncomingPacketsProvider().stream); diff --git a/lib/domain/db/dao/active_notification_dao.dart b/lib/domain/db/dao/active_notification_dao.dart index dacd8799..ff614fcd 100644 --- a/lib/domain/db/dao/active_notification_dao.dart +++ b/lib/domain/db/dao/active_notification_dao.dart @@ -67,7 +67,7 @@ class ActiveNotificationDao { } } -final AutoDisposeProvider activeNotifDaoProvider = Provider.autoDispose((ref) { +final AutoDisposeProvider activeNotifDaoProvider = Provider.autoDispose((ref) { final dbFuture = ref.watch(databaseProvider.future); return ActiveNotificationDao(dbFuture); }); diff --git a/lib/domain/db/dao/app_dao.dart b/lib/domain/db/dao/app_dao.dart index 60b51d89..a090354b 100644 --- a/lib/domain/db/dao/app_dao.dart +++ b/lib/domain/db/dao/app_dao.dart @@ -213,7 +213,7 @@ class AppDao { } } -final AutoDisposeProvider appDaoProvider = Provider.autoDispose((ref) { +final AutoDisposeProvider appDaoProvider = Provider.autoDispose((ref) { final dbFuture = ref.watch(databaseProvider.future); return AppDao(dbFuture); }); diff --git a/lib/domain/db/dao/locker_cache_dao.dart b/lib/domain/db/dao/locker_cache_dao.dart index 204df50c..c99f43e0 100644 --- a/lib/domain/db/dao/locker_cache_dao.dart +++ b/lib/domain/db/dao/locker_cache_dao.dart @@ -54,7 +54,7 @@ class LockerCacheDao { } } -final AutoDisposeProvider lockerCacheDaoProvider = Provider.autoDispose((ref) { +final AutoDisposeProvider lockerCacheDaoProvider = Provider.autoDispose((ref) { final dbFuture = ref.watch(databaseProvider.future); return LockerCacheDao(dbFuture); }); diff --git a/lib/domain/db/dao/notification_channel_dao.dart b/lib/domain/db/dao/notification_channel_dao.dart index 1e7c6cbf..c64a3846 100644 --- a/lib/domain/db/dao/notification_channel_dao.dart +++ b/lib/domain/db/dao/notification_channel_dao.dart @@ -61,7 +61,7 @@ class NotificationChannelDao { } } -final AutoDisposeProvider notifChannelDaoProvider = Provider.autoDispose((ref) { +final AutoDisposeProvider notifChannelDaoProvider = Provider.autoDispose((ref) { final dbFuture = ref.watch(databaseProvider!.future); return NotificationChannelDao(dbFuture); }); \ No newline at end of file diff --git a/lib/domain/db/dao/timeline_pin_dao.dart b/lib/domain/db/dao/timeline_pin_dao.dart index 74de9732..5fdbb297 100644 --- a/lib/domain/db/dao/timeline_pin_dao.dart +++ b/lib/domain/db/dao/timeline_pin_dao.dart @@ -136,7 +136,7 @@ class TimelinePinDao { } final AutoDisposeProvider timelinePinDaoProvider = - Provider.autoDispose((ref) { + Provider.autoDispose((ref) { final dbFuture = ref.watch(databaseProvider.future); return TimelinePinDao(dbFuture); }); diff --git a/lib/domain/package_details.dart b/lib/domain/package_details.dart index 37e218a4..f29ebc6a 100644 --- a/lib/domain/package_details.dart +++ b/lib/domain/package_details.dart @@ -2,4 +2,4 @@ import 'package:cobble/infrastructure/pigeons/pigeons.g.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; final packageDetailsProvider = - Provider((ref) => PackageDetails()); \ No newline at end of file + Provider((ref) => PackageDetails()); \ No newline at end of file diff --git a/lib/domain/permissions.dart b/lib/domain/permissions.dart index 16b20c77..195a7d3a 100644 --- a/lib/domain/permissions.dart +++ b/lib/domain/permissions.dart @@ -1,5 +1,5 @@ import 'package:cobble/infrastructure/pigeons/pigeons.g.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -final permissionControlProvider = Provider((ref) => PermissionControl()); -final permissionCheckProvider = Provider((ref) => PermissionCheck()); +final permissionControlProvider = Provider((ref) => PermissionControl()); +final permissionCheckProvider = Provider((ref) => PermissionCheck()); diff --git a/lib/domain/preferences.dart b/lib/domain/preferences.dart index 6bc6d0ef..617cad34 100644 --- a/lib/domain/preferences.dart +++ b/lib/domain/preferences.dart @@ -2,4 +2,4 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; final sharedPreferencesProvider = - Provider((ref) => SharedPreferences.getInstance()); + Provider>((ref) => SharedPreferences.getInstance()); diff --git a/lib/domain/secure_storage.dart b/lib/domain/secure_storage.dart index 7b104fa2..3663814c 100644 --- a/lib/domain/secure_storage.dart +++ b/lib/domain/secure_storage.dart @@ -3,4 +3,4 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; const _androidOptions = AndroidOptions(encryptedSharedPreferences: true); final flutterSecureStorageProvider = - Provider((ref) => const FlutterSecureStorage(aOptions: _androidOptions)); \ No newline at end of file + Provider((ref) => const FlutterSecureStorage(aOptions: _androidOptions)); \ No newline at end of file diff --git a/lib/domain/timeline/watch_apps_syncer.dart b/lib/domain/timeline/watch_apps_syncer.dart index a00882e0..e38cab72 100644 --- a/lib/domain/timeline/watch_apps_syncer.dart +++ b/lib/domain/timeline/watch_apps_syncer.dart @@ -160,4 +160,4 @@ Provider.autoDispose((ref) { ); }); -final appInstallControlProvider = Provider((ref) => AppInstallControl()); +final appInstallControlProvider = Provider((ref) => AppInstallControl()); diff --git a/lib/domain/timeline/watch_timeline_syncer.dart b/lib/domain/timeline/watch_timeline_syncer.dart index 4e1392a9..e1ab11d0 100644 --- a/lib/domain/timeline/watch_timeline_syncer.dart +++ b/lib/domain/timeline/watch_timeline_syncer.dart @@ -168,4 +168,4 @@ final AutoDisposeProvider watchTimelineSyncerProvider = ); }); -final timelineSyncControlProvider = Provider((ref) => TimelineSyncControl()); +final timelineSyncControlProvider = Provider((ref) => TimelineSyncControl()); diff --git a/lib/infrastructure/backgroundcomm/BackgroundRpc.dart b/lib/infrastructure/backgroundcomm/BackgroundRpc.dart index 15a6e821..3dbb53c9 100644 --- a/lib/infrastructure/backgroundcomm/BackgroundRpc.dart +++ b/lib/infrastructure/backgroundcomm/BackgroundRpc.dart @@ -71,7 +71,7 @@ class BackgroundRpc { } else if (receivedMessage.errorResult != null) { result = AsyncValue.error( receivedMessage.errorResult!, - receivedMessage.errorStacktrace, + stackTrace: receivedMessage.errorStacktrace, ); } else { result = AsyncValue.error("Received result without any data."); diff --git a/lib/infrastructure/datasources/paired_storage.dart b/lib/infrastructure/datasources/paired_storage.dart index 4c67cba6..dc83e8ee 100644 --- a/lib/infrastructure/datasources/paired_storage.dart +++ b/lib/infrastructure/datasources/paired_storage.dart @@ -86,7 +86,7 @@ class PairedStorage extends StateNotifier> { } final pairedStorageProvider = StateNotifierProvider>((ref) => PairedStorage()); -final defaultWatchProvider = Provider((ref) => ref +final defaultWatchProvider = Provider((ref) => ref .watch(pairedStorageProvider) .firstWhereOrNull((element) => element.isDefault!) ?.device); @@ -94,4 +94,4 @@ final ProviderFamily? specificWatchProvider = Provider.family(((ref, dynamic address) => ref .watch(pairedStorageProvider) .firstWhereOrNull((element) => element.device.address == address) - ?.device) as PebbleScanDevice Function(ProviderReference, dynamic)); + ?.device) as PebbleScanDevice Function(Ref, dynamic)); diff --git a/lib/infrastructure/datasources/preferences.dart b/lib/infrastructure/datasources/preferences.dart index 39c7ef47..b84e960a 100644 --- a/lib/infrastructure/datasources/preferences.dart +++ b/lib/infrastructure/datasources/preferences.dart @@ -166,23 +166,23 @@ final preferencesProvider = FutureProvider((ref) async { return Preferences(sharedPreferences); }); -final calendarSyncEnabledProvider = _createPreferenceProvider( +final calendarSyncEnabledProvider = _createPreferenceProvider( (preferences) => preferences.isCalendarSyncEnabled(), ); -final phoneNotificationsMuteProvider = _createPreferenceProvider( +final phoneNotificationsMuteProvider = _createPreferenceProvider( (preferences) => preferences.isPhoneNotificationMuteEnabled(), ); -final phoneCallsMuteProvider = _createPreferenceProvider( +final phoneCallsMuteProvider = _createPreferenceProvider( (preferences) => preferences.isPhoneCallMuteEnabled(), ); -final notificationToggleProvider = _createPreferenceProvider( +final notificationToggleProvider = _createPreferenceProvider( (preferences) => preferences.areNotificationsEnabled(), ); -final notificationsMutedPackagesProvider = _createPreferenceProvider( +final notificationsMutedPackagesProvider = _createPreferenceProvider>( (preferences) => preferences.getNotificationsMutedPackages(), ); @@ -197,29 +197,29 @@ final notificationsMutedPackagesProvider = _createPreferenceProvider( /// hasBeenConnected.then((value) => /*...*/); /// }, []); /// ``` -final hasBeenConnectedProvider = _createPreferenceProvider( +final hasBeenConnectedProvider = _createPreferenceProvider( (preferences) => preferences.hasBeenConnected(), ); -final wasSetupSuccessfulProvider = _createPreferenceProvider( +final wasSetupSuccessfulProvider = _createPreferenceProvider( (preferences) => preferences.wasSetupSuccessful(), ); -final bootUrlProvider = _createPreferenceProvider( +final bootUrlProvider = _createPreferenceProvider( (preferences) { return preferences.getBoot(); }, ); -final overrideBootValueProvider = _createPreferenceProvider( +final overrideBootValueProvider = _createPreferenceProvider( (preferences) => preferences.getOverrideBootValue(), ); -final shouldOverrideBootProvider = _createPreferenceProvider( +final shouldOverrideBootProvider = _createPreferenceProvider( (preferences) => preferences.shouldOverrideBoot(), ); -final oauthTokenCreationDateProvider = _createPreferenceProvider( +final oauthTokenCreationDateProvider = _createPreferenceProvider( (preferences) => preferences.getOAuthTokenCreationDate(), ); diff --git a/lib/infrastructure/datasources/secure_storage.dart b/lib/infrastructure/datasources/secure_storage.dart index c13b91c4..3744b50f 100644 --- a/lib/infrastructure/datasources/secure_storage.dart +++ b/lib/infrastructure/datasources/secure_storage.dart @@ -38,10 +38,10 @@ class SecureStorage { } final secureStorageProvider = - Provider((ref) => SecureStorage(ref.watch(flutterSecureStorageProvider))); + Provider((ref) => SecureStorage(ref.watch(flutterSecureStorageProvider))); final tokenProvider = - _createSecureStorageItemProvider((secureStorage) => secureStorage.getToken()); + _createSecureStorageItemProvider>((secureStorage) => secureStorage.getToken()); StreamProvider _createSecureStorageItemProvider( T Function(SecureStorage secureStorage) mapper, @@ -54,4 +54,4 @@ StreamProvider _createSecureStorageItemProvider( .map(mapper) .distinct(); }); -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index a51d48b1..d05ae4c9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -46,13 +46,13 @@ void initBackground() { BackgroundSetupControl().setupBackground(wrapper); } -class MyApp extends HookWidget { +class MyApp extends HookConsumerWidget { @override - Widget build(BuildContext context) { - final permissionControl = useProvider(permissionControlProvider); - final permissionCheck = useProvider(permissionCheckProvider); - final defaultWatch = useProvider(defaultWatchProvider); - final preferences = useProvider(preferencesProvider.future); + Widget build(BuildContext context, WidgetRef ref) { + final permissionControl = ref.watch(permissionControlProvider); + final permissionCheck = ref.watch(permissionCheckProvider); + final defaultWatch = ref.watch(defaultWatchProvider); + final preferences = ref.watch(preferencesProvider.future); useEffect(() { Future.microtask(() async { diff --git a/lib/ui/devoptions/debug_options_page.dart b/lib/ui/devoptions/debug_options_page.dart index bf627af5..e8d75a0a 100644 --- a/lib/ui/devoptions/debug_options_page.dart +++ b/lib/ui/devoptions/debug_options_page.dart @@ -7,15 +7,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class DebugOptionsPage extends HookWidget implements CobbleScreen { +class DebugOptionsPage extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final preferences = useProvider(preferencesProvider); - final bootUrl = useProvider(bootUrlProvider).data?.value ?? ""; + Widget build(BuildContext context, WidgetRef ref) { + final preferences = ref.watch(preferencesProvider); + final bootUrl = ref.watch(bootUrlProvider).data?.value ?? ""; final shouldOverrideBoot = - useProvider(shouldOverrideBootProvider).data?.value ?? false; + ref.watch(shouldOverrideBootProvider).data?.value ?? false; final overrideBootUrl = - useProvider(overrideBootValueProvider).data?.value ?? ""; + ref.watch(overrideBootValueProvider).data?.value ?? ""; final bootUrlController = useTextEditingController(); final bootOverrideUrlController = useTextEditingController(); diff --git a/lib/ui/devoptions/dev_options_page.dart b/lib/ui/devoptions/dev_options_page.dart index b033f203..791027e1 100644 --- a/lib/ui/devoptions/dev_options_page.dart +++ b/lib/ui/devoptions/dev_options_page.dart @@ -19,15 +19,15 @@ import 'package:share_plus/share_plus.dart'; enum ActionItem { debugOptions } -class DevOptionsPage extends HookWidget implements CobbleScreen { +class DevOptionsPage extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final devConControl = useProvider(devConnectionProvider.notifier); - final devConnState = useProvider(devConnectionProvider); + Widget build(BuildContext context, WidgetRef ref) { + final devConControl = ref.watch(devConnectionProvider.notifier); + final devConnState = ref.watch(devConnectionProvider); - final connectionState = useProvider(connectionStateProvider); + final connectionState = ref.watch(connectionStateProvider); final ConnectionControl connectionControl = ConnectionControl(); - final pairedStorage = useProvider(pairedStorageProvider.notifier); + final pairedStorage = ref.watch(pairedStorageProvider.notifier); void _onDisconnectPressed(bool inSettings) { connectionControl.disconnect(); diff --git a/lib/ui/devoptions/test_logs_page.dart b/lib/ui/devoptions/test_logs_page.dart index f8752d76..4f6520f2 100644 --- a/lib/ui/devoptions/test_logs_page.dart +++ b/lib/ui/devoptions/test_logs_page.dart @@ -4,10 +4,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class TestLogsPage extends HookWidget implements CobbleScreen { +class TestLogsPage extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final logs = useProvider(recievedLogsProvider); + Widget build(BuildContext context, WidgetRef ref) { + final logs = ref.watch(recievedLogsProvider); return ListView.builder( itemBuilder: (context, index) { diff --git a/lib/ui/home/tabs/locker_tab.dart b/lib/ui/home/tabs/locker_tab.dart index a0a840b3..99c4e0e8 100644 --- a/lib/ui/home/tabs/locker_tab.dart +++ b/lib/ui/home/tabs/locker_tab.dart @@ -18,15 +18,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class LockerTab extends HookWidget implements CobbleScreen { +class LockerTab extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final connectionState = useProvider(connectionStateProvider); + Widget build(BuildContext context, WidgetRef ref) { + final connectionState = ref.watch(connectionStateProvider); final currentWatch = connectionState.currentConnectedWatch; - final appManager = useProvider(appManagerProvider.notifier); - List allPackages = useProvider(appManagerProvider); + final appManager = ref.watch(appManagerProvider.notifier); + List allPackages = ref.watch(appManagerProvider); List incompatibleApps = allPackages.where((element) => !element.isWatchface).toList(); List incompatibleFaces = @@ -36,7 +36,7 @@ class LockerTab extends HookWidget implements CobbleScreen { WatchType watchType; bool circleConnected = false; PebbleWatchLine lineConnected = PebbleWatchLine.unknown; - var lockerCache = useProvider(lockerCacheDaoProvider).getAll().then((value) => { for (var v in value) v.id : v }); + var lockerCache = ref.watch(lockerCacheDaoProvider).getAll().then((value) => { for (var v in value) v.id : v }); if (currentWatch != null) { watchType = currentWatch.runningFirmware.hardwarePlatform.getWatchType(); diff --git a/lib/ui/home/tabs/locker_tab/apps_item.dart b/lib/ui/home/tabs/locker_tab/apps_item.dart index 10544c60..2132cf6c 100644 --- a/lib/ui/home/tabs/locker_tab/apps_item.dart +++ b/lib/ui/home/tabs/locker_tab/apps_item.dart @@ -9,8 +9,9 @@ import 'package:cobble/ui/common/icons/fonts/rebble_icons.dart'; import 'package:cobble/ui/home/tabs/locker_tab/apps_sheet.dart'; import 'package:cobble/ui/theme/with_cobble_theme.dart'; import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; -class AppsItem extends StatelessWidget { +class AppsItem extends ConsumerWidget { final App app; final bool compatible; final AppManager appManager; @@ -29,7 +30,7 @@ class AppsItem extends StatelessWidget { }) : super(key: key); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { return Container( key: key, child: Row( diff --git a/lib/ui/home/tabs/locker_tab/faces_card.dart b/lib/ui/home/tabs/locker_tab/faces_card.dart index 3bd75e9b..ddc85e65 100644 --- a/lib/ui/home/tabs/locker_tab/faces_card.dart +++ b/lib/ui/home/tabs/locker_tab/faces_card.dart @@ -6,8 +6,9 @@ import 'package:cobble/ui/common/components/cobble_button.dart'; import 'package:cobble/ui/common/icons/fonts/rebble_icons.dart'; import 'package:cobble/ui/home/tabs/locker_tab/faces_sheet.dart'; import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; -class FacesCard extends StatelessWidget { +class FacesCard extends ConsumerWidget { final App face; final bool compatible; final AppManager appManager; @@ -26,7 +27,7 @@ class FacesCard extends StatelessWidget { }) : super(key: key); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { return Card( key: key, child: Container( diff --git a/lib/ui/home/tabs/test_tab.dart b/lib/ui/home/tabs/test_tab.dart index 717e9c11..9e25005e 100644 --- a/lib/ui/home/tabs/test_tab.dart +++ b/lib/ui/home/tabs/test_tab.dart @@ -16,20 +16,20 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../../common/icons/fonts/rebble_icons.dart'; -class TestTab extends HookWidget implements CobbleScreen { +class TestTab extends HookConsumerWidget implements CobbleScreen { final NotificationsControl notifications = NotificationsControl(); final ConnectionControl connectionControl = ConnectionControl(); @override - Widget build(BuildContext context) { - final defaultWatch = useProvider(defaultWatchProvider); + Widget build(BuildContext context, WidgetRef ref) { + final defaultWatch = ref.watch(defaultWatchProvider); - final permissionControl = useProvider(permissionControlProvider); - final permissionCheck = useProvider(permissionCheckProvider); + final permissionControl = ref.watch(permissionControlProvider); + final permissionCheck = ref.watch(permissionCheckProvider); - final preferences = useProvider(preferencesProvider); - final neededWorkarounds = useProvider(neededWorkaroundsProvider).when( + final preferences = ref.watch(preferencesProvider); + final neededWorkarounds = ref.watch(neededWorkaroundsProvider).when( data: (data) => data, loading: () => List.empty(), error: (e, s) => List.empty(), diff --git a/lib/ui/home/tabs/watches_tab.dart b/lib/ui/home/tabs/watches_tab.dart index cd944f74..1a0a169c 100644 --- a/lib/ui/home/tabs/watches_tab.dart +++ b/lib/ui/home/tabs/watches_tab.dart @@ -26,7 +26,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../../common/icons/fonts/rebble_icons.dart'; -class MyWatchesTab extends HookWidget implements CobbleScreen { +class MyWatchesTab extends HookConsumerWidget implements CobbleScreen { final Color _disconnectedColor = Color.fromRGBO(255, 255, 255, 0.5); final Color _connectedColor = Color.fromARGB(255, 0, 169, 130); @@ -35,12 +35,12 @@ class MyWatchesTab extends HookWidget implements CobbleScreen { final ConnectionControl connectionControl = ConnectionControl(); @override - Widget build(BuildContext context) { - final connectionState = useProvider(connectionStateProvider); - final defaultWatch = useProvider(defaultWatchProvider); - final pairedStorage = useProvider(pairedStorageProvider.notifier); - final allWatches = useProvider(pairedStorageProvider); - final preferencesFuture = useProvider(preferencesProvider.future); + Widget build(BuildContext context, WidgetRef ref) { + final connectionState = ref.watch(connectionStateProvider); + final defaultWatch = ref.watch(defaultWatchProvider); + final pairedStorage = ref.watch(pairedStorageProvider.notifier); + final allWatches = ref.watch(pairedStorageProvider); + final preferencesFuture = ref.watch(preferencesProvider.future); List allWatchesList = allWatches.map((e) => e.device).toList(); diff --git a/lib/ui/screens/alerting_app_details.dart b/lib/ui/screens/alerting_app_details.dart index 3e7ce31b..0f5cf428 100644 --- a/lib/ui/screens/alerting_app_details.dart +++ b/lib/ui/screens/alerting_app_details.dart @@ -14,15 +14,15 @@ import 'package:flutter_svg_provider/flutter_svg_provider.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:cobble/ui/theme/with_cobble_theme.dart'; -class AlertingAppDetails extends HookWidget implements CobbleScreen { +class AlertingAppDetails extends HookConsumerWidget implements CobbleScreen { AlertingApp app; AlertingAppDetails(this.app); @override - Widget build(BuildContext context) { - final channelDao = useProvider(notifChannelDaoProvider); - final mutedPackages = useProvider(notificationsMutedPackagesProvider); - final preferences = useProvider(preferencesProvider); + Widget build(BuildContext context, WidgetRef ref) { + final channelDao = ref.watch(notifChannelDaoProvider); + final mutedPackages = ref.watch(notificationsMutedPackagesProvider); + final preferences = ref.watch(preferencesProvider); final StreamController> streamController = StreamController(); diff --git a/lib/ui/screens/alerting_apps.dart b/lib/ui/screens/alerting_apps.dart index 5b902dd0..4edeae0f 100644 --- a/lib/ui/screens/alerting_apps.dart +++ b/lib/ui/screens/alerting_apps.dart @@ -25,16 +25,17 @@ class AlertingApp { AlertingApp(this.name, this.enabled, this.packageId); } -class AlertingApps extends HookWidget implements CobbleScreen { - final packageDetails = useProvider(packageDetailsProvider).getPackageList(); +class AlertingApps extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final packageDetails = ref.watch(packageDetailsProvider).getPackageList(); + final random = Random(); final filter = useState(SheetOnChanged.initial); final sheet = CobbleSheet.useInline(); - final mutedPackages = useProvider(notificationsMutedPackagesProvider); + final mutedPackages = ref.watch(notificationsMutedPackagesProvider); return CobbleScaffold.tab( title: tr.alertingApps.title, diff --git a/lib/ui/screens/calendar.dart b/lib/ui/screens/calendar.dart index f0952765..2185ccc7 100644 --- a/lib/ui/screens/calendar.dart +++ b/lib/ui/screens/calendar.dart @@ -14,19 +14,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class Calendar extends HookWidget implements CobbleScreen { +class Calendar extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final calendars = useProvider(calendarListProvider); - final calendarSelector = useProvider(calendarListProvider.notifier); - final calendarControl = useProvider(calendarControlProvider); - final backgroundRpc = useProvider(backgroundRpcProvider); + Widget build(BuildContext context, WidgetRef ref) { + final calendars = ref.watch(calendarListProvider); + final calendarSelector = ref.watch(calendarListProvider.notifier); + final calendarControl = ref.watch(calendarControlProvider); + final backgroundRpc = ref.watch(backgroundRpcProvider); - final preferences = useProvider(preferencesProvider); - final calendarSyncEnabled = useProvider(calendarSyncEnabledProvider); - final permissionControl = useProvider(permissionControlProvider); - final permissionCheck = useProvider(permissionCheckProvider); + final preferences = ref.watch(preferencesProvider); + final calendarSyncEnabled = ref.watch(calendarSyncEnabledProvider); + final permissionControl = ref.watch(permissionControlProvider); + final permissionCheck = ref.watch(permissionCheckProvider); useEffect(() { Future.microtask(() async { diff --git a/lib/ui/screens/install_prompt.dart b/lib/ui/screens/install_prompt.dart index d99b030c..b41b49a8 100644 --- a/lib/ui/screens/install_prompt.dart +++ b/lib/ui/screens/install_prompt.dart @@ -12,20 +12,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class InstallPrompt extends HookWidget implements CobbleScreen { +class InstallPrompt extends HookConsumerWidget implements CobbleScreen { final String _appUri; final PbwAppInfo _appInfo; InstallPrompt(this._appUri, this._appInfo); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { final userInitiatedInstall = useState(false); final watchUploadHasStarted = useState(false); - final installStatus = useProvider(appInstallStatusProvider); - final appManager = useProvider(appManagerProvider.notifier); - final connectionStatus = useProvider(connectionStateProvider); + final installStatus = ref.watch(appInstallStatusProvider); + final appManager = ref.watch(appManagerProvider.notifier); + final connectionStatus = ref.watch(connectionStateProvider); final connectedWatch = connectionStatus.currentConnectedWatch; diff --git a/lib/ui/screens/notifications.dart b/lib/ui/screens/notifications.dart index 3a3d0cc4..2ba6c32a 100644 --- a/lib/ui/screens/notifications.dart +++ b/lib/ui/screens/notifications.dart @@ -11,14 +11,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class Notifications extends HookWidget implements CobbleScreen { +class Notifications extends HookConsumerWidget implements CobbleScreen { @override - Widget build(BuildContext context) { - final preferences = useProvider(preferencesProvider); - final notifcationsEnabled = useProvider(notificationToggleProvider); + Widget build(BuildContext context, WidgetRef ref) { + final preferences = ref.watch(preferencesProvider); + final notifcationsEnabled = ref.watch(notificationToggleProvider); final phoneNotificationsMuteEnabled = - useProvider(phoneNotificationsMuteProvider); - final phoneCallsMuteEnabled = useProvider(phoneCallsMuteProvider); + ref.watch(phoneNotificationsMuteProvider); + final phoneCallsMuteEnabled = ref.watch(phoneCallsMuteProvider); return CobbleScaffold.tab( title: tr.notifications.title, diff --git a/lib/ui/screens/settings.dart b/lib/ui/screens/settings.dart index 7524f71e..1cba1cd0 100644 --- a/lib/ui/screens/settings.dart +++ b/lib/ui/screens/settings.dart @@ -23,13 +23,13 @@ import 'package:flutter_svg_provider/flutter_svg_provider.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:url_launcher/url_launcher.dart'; -class Settings extends HookWidget implements CobbleScreen { +class Settings extends HookConsumerWidget implements CobbleScreen { const Settings({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - final auth = useProvider(authServiceProvider.future); - final webviews = useProvider(bootServiceProvider.future).then((value) async => (await value.config).webviews); + Widget build(BuildContext context, WidgetRef ref) { + final auth = ref.watch(authServiceProvider.future); + final webviews = ref.watch(bootServiceProvider.future).then((value) async => (await value.config).webviews); return CobbleScaffold.tab( title: tr.settings.title, child: ListView( diff --git a/lib/ui/setup/boot/rebble_setup.dart b/lib/ui/setup/boot/rebble_setup.dart index cedf38bd..5a498682 100644 --- a/lib/ui/setup/boot/rebble_setup.dart +++ b/lib/ui/setup/boot/rebble_setup.dart @@ -14,15 +14,15 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:logging/logging.dart'; -class RebbleSetup extends HookWidget implements CobbleScreen { +class RebbleSetup extends HookConsumerWidget implements CobbleScreen { static final IntentControl lifecycleControl = IntentControl(); static final Logger _logger = Logger('RebbleSetup'); const RebbleSetup({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - final oauthClient = useProvider(oauthClientProvider); + Widget build(BuildContext context, WidgetRef ref) { + final oauthClient = ref.watch(oauthClientProvider); return CobbleScaffold.page( title: "Activate Rebble services", diff --git a/lib/ui/setup/boot/rebble_setup_fail.dart b/lib/ui/setup/boot/rebble_setup_fail.dart index 429c4afb..fccc4902 100644 --- a/lib/ui/setup/boot/rebble_setup_fail.dart +++ b/lib/ui/setup/boot/rebble_setup_fail.dart @@ -11,12 +11,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class RebbleSetupFail extends HookWidget implements CobbleScreen { +class RebbleSetupFail extends HookConsumerWidget implements CobbleScreen { const RebbleSetupFail({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - final preferences = useProvider(preferencesProvider); + Widget build(BuildContext context, WidgetRef ref) { + final preferences = ref.watch(preferencesProvider); return CobbleScaffold.page( title: tr.setup.failure.title, child: CobbleStep( diff --git a/lib/ui/setup/boot/rebble_setup_success.dart b/lib/ui/setup/boot/rebble_setup_success.dart index 1a2ce8d2..fa5a5928 100644 --- a/lib/ui/setup/boot/rebble_setup_success.dart +++ b/lib/ui/setup/boot/rebble_setup_success.dart @@ -13,13 +13,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class RebbleSetupSuccess extends HookWidget implements CobbleScreen { +class RebbleSetupSuccess extends HookConsumerWidget implements CobbleScreen { const RebbleSetupSuccess({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - final preferences = useProvider(preferencesProvider); - final userFuture = useProvider(authUserProvider.future); + Widget build(BuildContext context, WidgetRef ref) { + final preferences = ref.watch(preferencesProvider); + final userFuture = ref.watch(authUserProvider.future); return CobbleScaffold.page( title: tr.setup.success.title, diff --git a/lib/ui/setup/pair_page.dart b/lib/ui/setup/pair_page.dart index e66a5cc6..823b0068 100644 --- a/lib/ui/setup/pair_page.dart +++ b/lib/ui/setup/pair_page.dart @@ -23,7 +23,7 @@ final ConnectionControl connectionControl = ConnectionControl(); final UiConnectionControl uiConnectionControl = UiConnectionControl(); final ScanControl scanControl = ScanControl(); -class PairPage extends HookWidget implements CobbleScreen { +class PairPage extends HookConsumerWidget implements CobbleScreen { final bool fromLanding; const PairPage._({ @@ -48,11 +48,11 @@ class PairPage extends HookWidget implements CobbleScreen { ); @override - Widget build(BuildContext context) { - final pairedStorage = useProvider(pairedStorageProvider.notifier); - final scan = useProvider(scanProvider); - final pair = useProvider(pairProvider).data?.value; - final preferences = useProvider(preferencesProvider); + Widget build(BuildContext context, WidgetRef ref) { + final pairedStorage = ref.watch(pairedStorageProvider.notifier); + final scan = ref.watch(scanProvider); + final pair = ref.watch(pairProvider).data?.value; + final preferences = ref.watch(preferencesProvider); useEffect(() { if (pair == null || scan.devices.isEmpty) return null; @@ -83,14 +83,14 @@ class PairPage extends HookWidget implements CobbleScreen { final _refreshDevicesBle = () { if (!scan.scanning) { - context.refresh(scanProvider.notifier).onScanStarted(); + ref.refresh(scanProvider.notifier).onScanStarted(); scanControl.startBleScan(); } }; final _refreshDevicesClassic = () { if (!scan.scanning) { - context.refresh(scanProvider.notifier).onScanStarted(); + ref.refresh(scanProvider.notifier).onScanStarted(); scanControl.startClassicScan(); } }; diff --git a/lib/ui/splash/splash_page.dart b/lib/ui/splash/splash_page.dart index e389a9ee..5b71fee2 100644 --- a/lib/ui/splash/splash_page.dart +++ b/lib/ui/splash/splash_page.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class SplashPage extends HookWidget { +class SplashPage extends HookConsumerWidget { const SplashPage({Key? key}) : super(key: key); void Function() _openHome( @@ -23,8 +23,8 @@ class SplashPage extends HookWidget { }; @override - Widget build(BuildContext context) { - final hasBeenConnected = useProvider(hasBeenConnectedProvider).data; + Widget build(BuildContext context, WidgetRef ref) { + final hasBeenConnected = ref.watch(hasBeenConnectedProvider).data; // Let's not do a timed splash screen here, it's a waste of // the user's time and there are better platform ways to do it useEffect(() { diff --git a/lib/util/container_extensions.dart b/lib/util/container_extensions.dart index 452f95f4..6797f086 100644 --- a/lib/util/container_extensions.dart +++ b/lib/util/container_extensions.dart @@ -6,19 +6,19 @@ import 'stream_extensions.dart'; extension ContainerExtension on ProviderContainer { Future> readUntilFirstSuccessOrError( - ProviderBase> provider) { + ProviderBase> provider) { return this.listenStream(provider).firstSuccessOrError() as Future>; } /// Listen to the provider as stream - Stream listenStream(ProviderBase provider) { + Stream listenStream(ProviderBase provider) { ProviderSubscription? subscription; // ignore: close_sinks late StreamController controller; controller = StreamController(onListen: () { - subscription = listen(provider, mayHaveChanged: (sub) { - controller.add(sub.read()); + subscription = listen(provider, (_, sub) { + controller.add(sub); }); controller.add(subscription!.read()); @@ -30,9 +30,9 @@ extension ContainerExtension on ProviderContainer { } } -extension ProviderReferenceExtension on ProviderReference { +extension ProviderReferenceExtension on Ref { Future> readUntilFirstSuccessOrError( - ProviderBase> provider) { + ProviderBase> provider) { return this.container.listenStream(provider).firstSuccessOrError() as Future>; } } diff --git a/pubspec.lock b/pubspec.lock index 3df25e19..30549676 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -359,10 +359,10 @@ packages: dependency: transitive description: name: flutter_riverpod - sha256: "2885685ad4ff8c62e84b6295cc13c24c733164006edd2b4ac1204beec0e35e54" + sha256: d84e180f039a6b963e610d2e4435641fdfe8f12437e8770e963632e05af16d80 url: "https://pub.dev" source: hosted - version: "0.14.0+3" + version: "1.0.4" flutter_secure_storage: dependency: "direct main" description: @@ -437,14 +437,6 @@ packages: description: flutter source: sdk version: "0.0.0" - freezed_annotation: - dependency: transitive - description: - name: freezed_annotation - sha256: "70776c4541e5cacfe45bcaf00fe79137b8c61aa34fb5765a05ce6c57fd72c6e9" - url: "https://pub.dev" - source: hosted - version: "0.14.3" frontend_server_client: dependency: transitive description: @@ -481,10 +473,10 @@ packages: dependency: "direct main" description: name: hooks_riverpod - sha256: d2b87754e36ff2d862c03cb1522832ef8fffa4caf9f202bee1f684dfb5a8ad66 + sha256: c2264035396e5fc238e98ef053b07b9cab298450e39c6a8704634c8452c61bbe url: "https://pub.dev" source: hosted - version: "0.14.0+5" + version: "1.0.4" http: dependency: transitive description: @@ -825,10 +817,10 @@ packages: dependency: transitive description: name: riverpod - sha256: "13cbe0e17b659f38027986df967b3eaf7f42c519786352167fc3db1be44eae07" + sha256: e7f097159b9512f5953ff544164c19057f45ce28fd0cb971fc4cad1f7b28217d url: "https://pub.dev" source: hosted - version: "0.14.0+3" + version: "1.0.3" rxdart: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 2e3477bb..f377fa9f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: sqflite: ^2.2.0 package_info_plus: ^3.0.0 state_notifier: ^0.7.0 - hooks_riverpod: ^0.14.0 + hooks_riverpod: ^1.0.1 flutter_hooks: ^0.18.0 device_calendar: ^4.3.0 uuid_type: ^2.0.0 diff --git a/test/domain/calendar/calendar_list_test.dart b/test/domain/calendar/calendar_list_test.dart index d0ea1b80..89a08c19 100644 --- a/test/domain/calendar/calendar_list_test.dart +++ b/test/domain/calendar/calendar_list_test.dart @@ -14,7 +14,7 @@ import '../../fakes/fake_device_calendar_plugin.dart'; import '../../fakes/fake_permissions_check.dart'; import '../../fakes/memory_shared_preferences.dart'; -void main() { +void main(WidgetRef ref) { test('CalendarList should report list of calendars', () async { final calendarPlugin = FakeDeviceCalendarPlugin(); final permissionCheck = FakePermissionCheck(); @@ -88,9 +88,9 @@ void main() { ]; await container - .listen(calendarListProvider.notifier + .listen(calendarListProvider.notifier .read() - .setCalendarEnabled("22", false); + .setCalendarEnabled("22", false), (previous, value) {}; final expectedReceivedCalendars = [ SelectableCalendar("Calendar A", "22", false, 0xFFFFFFFF), @@ -123,11 +123,11 @@ void main() { ]; await container - .listen(calendarListProvider.notifier) + .listen(calendarListProvider.notifier, (previous, value) {}) .read() .setCalendarEnabled("22", false); await container - .listen(calendarListProvider.notifier) + .listen(calendarListProvider.notifier, (previous, value) {}) .read() .setCalendarEnabled("22", true); diff --git a/test/domain/calendar/calendar_syncer_test.dart b/test/domain/calendar/calendar_syncer_test.dart index b5d363a3..6279653f 100644 --- a/test/domain/calendar/calendar_syncer_test.dart +++ b/test/domain/calendar/calendar_syncer_test.dart @@ -105,7 +105,7 @@ void main() async { ) ]; - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final insertedEvents = await pinDao.getAllPins(); @@ -255,7 +255,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); await calendarSyncer.syncDeviceCalendarsToDb(); final eventsInDao = await pinDao.getAllPins(); @@ -378,7 +378,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); expect(anyChanges, false); @@ -432,7 +432,7 @@ void main() async { ) ]; - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); await calendarSyncer.syncDeviceCalendarsToDb(); final insertedEvents = await pinDao.getAllPins(); @@ -512,7 +512,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final eventsInDao = await pinDao.getAllPins(); @@ -621,7 +621,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final eventsInDao = await pinDao.getAllPins(); @@ -729,7 +729,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final eventsInDao = await pinDao.getAllPins(); @@ -892,7 +892,7 @@ void main() async { ), ); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final eventsInDao = await pinDao.getAllPins(); @@ -1076,7 +1076,7 @@ void main() async { ), ]; - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final insertedEvents = await pinDao.getAllPins(); @@ -1245,7 +1245,7 @@ void main() async { calendarList.setCalendarEnabled("23", false); - final calendarSyncer = container.listen(calendarSyncerProvider).read(); + final calendarSyncer = container.listen(calendarSyncerProvider, (previous, value) {}).read(); final anyChanges = await calendarSyncer.syncDeviceCalendarsToDb(); final insertedEvents = await pinDao.getAllPins(); diff --git a/test/domain/setup/pair_page_test.dart b/test/domain/setup/pair_page_test.dart index 67f95c46..219105b2 100644 --- a/test/domain/setup/pair_page_test.dart +++ b/test/domain/setup/pair_page_test.dart @@ -58,7 +58,7 @@ Widget wrapper( pairMock ?? StreamProvider((ref) async* { yield null; - } as Stream Function(ProviderReference)), + } as Stream Function(StreamProviderRef)), ) ], child: MaterialApp(