Skip to content

Commit

Permalink
Fix error builder in network image
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Apr 19, 2024
1 parent fc66486 commit efec909
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 8 additions & 5 deletions app/ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="109" y="-77"/>
</scene>
</scenes>
</document>
11 changes: 11 additions & 0 deletions app/lib/ui/flow/accounts/components/settings_action_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ 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});

@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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions data/lib/storage/app_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class AppPreferences {
defaultValue: null,
);

static StateProvider<bool> notifications = createPrefProvider<bool>(
prefKey: "show_notifications",
defaultValue: true,
);

static StateProvider<bool> canTakeAutoBackUpInGoogleDrive =
createPrefProvider<bool>(
prefKey: "google_drive_auto_backup",
Expand Down

0 comments on commit efec909

Please sign in to comment.