From efec909218fb08623af9efd852d32e6807903a59 Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Fri, 19 Apr 2024 14:37:14 +0530 Subject: [PATCH] Fix error builder in network image --- app/assets/locales/app_en.arb | 1 + app/ios/Runner/Base.lproj/Main.storyboard | 13 ++++++++----- .../accounts/components/settings_action_list.dart | 11 +++++++++++ .../network_image_preview.dart | 13 +++++++++---- data/lib/storage/app_preferences.dart | 5 +++++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/assets/locales/app_en.arb b/app/assets/locales/app_en.arb index 205015b..c251037 100644 --- a/app/assets/locales/app_en.arb +++ b/app/assets/locales/app_en.arb @@ -40,6 +40,7 @@ "load_local_media_button_text": "Load local media", "theme_text": "Theme", + "notification_text": "Notification", "light_theme_text": "Light", "dark_theme_text": "Dark", "system_theme_text": "System", diff --git a/app/ios/Runner/Base.lproj/Main.storyboard b/app/ios/Runner/Base.lproj/Main.storyboard index f3c2851..04bdd8d 100644 --- a/app/ios/Runner/Base.lproj/Main.storyboard +++ b/app/ios/Runner/Base.lproj/Main.storyboard @@ -1,8 +1,10 @@ - - + + + - + + @@ -14,13 +16,14 @@ - + - + + diff --git a/app/lib/ui/flow/accounts/components/settings_action_list.dart b/app/lib/ui/flow/accounts/components/settings_action_list.dart index a914518..eaca3b6 100644 --- a/app/lib/ui/flow/accounts/components/settings_action_list.dart +++ b/app/lib/ui/flow/accounts/components/settings_action_list.dart @@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:style/buttons/buttons_list.dart'; import 'package:style/buttons/segmented_button.dart'; +import 'package:style/buttons/switch.dart'; class SettingsActionList extends ConsumerWidget { const SettingsActionList({super.key}); @@ -11,7 +12,17 @@ class SettingsActionList extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final isDarkMode = ref.watch(AppPreferences.isDarkMode); + final notifications = ref.watch(AppPreferences.notifications); return ActionList(buttons: [ + ActionListButton( + title: context.l10n.notification_text, + trailing: AppSwitch( + value: notifications, + onChanged: (value) { + ref.read(AppPreferences.notifications.notifier).state = value; + }, + ), + ), ActionListButton( title: context.l10n.theme_text, trailing: AppSegmentedButton( diff --git a/app/lib/ui/flow/media_preview/components/network_image_preview/network_image_preview.dart b/app/lib/ui/flow/media_preview/components/network_image_preview/network_image_preview.dart index bce864d..53389e5 100644 --- a/app/lib/ui/flow/media_preview/components/network_image_preview/network_image_preview.dart +++ b/app/lib/ui/flow/media_preview/components/network_image_preview/network_image_preview.dart @@ -4,6 +4,7 @@ import 'package:data/models/media/media.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:style/indicators/circular_progress_indicator.dart'; +import '../../../../../components/app_page.dart'; import '../../../../../components/error_view.dart'; import 'network_image_preview_view_model.dart'; @@ -21,10 +22,14 @@ class NetworkImagePreview extends ConsumerWidget { } else if (state.filePath != null) { return Hero( tag: media, - child: Image.file( - File(state.filePath!), - fit: BoxFit.fitWidth, - ), + child: Image.file(File(state.filePath!), fit: BoxFit.fitWidth, + errorBuilder: (context, error, stackTrace) { + return AppPage( + body: ErrorView( + title: context.l10n.unable_to_load_media_error, + message: context.l10n.unable_to_load_media_message, + )); + }), ); } else if (state.error != null) { return ErrorView( diff --git a/data/lib/storage/app_preferences.dart b/data/lib/storage/app_preferences.dart index 35c6b4d..0bb6818 100644 --- a/data/lib/storage/app_preferences.dart +++ b/data/lib/storage/app_preferences.dart @@ -12,6 +12,11 @@ class AppPreferences { defaultValue: null, ); + static StateProvider notifications = createPrefProvider( + prefKey: "show_notifications", + defaultValue: true, + ); + static StateProvider canTakeAutoBackUpInGoogleDrive = createPrefProvider( prefKey: "google_drive_auto_backup",