diff --git a/mobile/apps/photos/assets/2.0x/enable-streaming-static.png b/mobile/apps/photos/assets/2.0x/enable-streaming-static.png new file mode 100644 index 0000000000..1fd5758562 Binary files /dev/null and b/mobile/apps/photos/assets/2.0x/enable-streaming-static.png differ diff --git a/mobile/apps/photos/assets/3.0x/enable-streaming-static.png b/mobile/apps/photos/assets/3.0x/enable-streaming-static.png new file mode 100644 index 0000000000..e792c11e16 Binary files /dev/null and b/mobile/apps/photos/assets/3.0x/enable-streaming-static.png differ diff --git a/mobile/apps/photos/assets/enable-streaming-static.png b/mobile/apps/photos/assets/enable-streaming-static.png new file mode 100644 index 0000000000..b14fb8befe Binary files /dev/null and b/mobile/apps/photos/assets/enable-streaming-static.png differ diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb index 135b97e502..46da096a64 100644 --- a/mobile/apps/photos/lib/l10n/intl_en.arb +++ b/mobile/apps/photos/lib/l10n/intl_en.arb @@ -1832,6 +1832,5 @@ "totalVideos": "Total videos", "skippedVideos": "Skipped videos", "videoStreamingDescription": "Play videos instantly on any device. Enable to process video streams on this device.", - "videoStreamingDescriptionClickable": "More information here.", "videoStreamingNote": "Only videos from last 60 days and under 1 minute are processed on this device. For older/longer videos, enable streaming in the desktop app." } \ No newline at end of file diff --git a/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart b/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart index 95529acc12..ea485a0235 100644 --- a/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart +++ b/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart @@ -412,6 +412,7 @@ class _ButtonChildWidgetState extends State { if (widget.onTap != null) { _debouncer.run( () => Future(() { + if (!mounted) return; setState(() { executionState = ExecutionState.inProgress; }); @@ -432,6 +433,7 @@ class _ButtonChildWidgetState extends State { : null; _debouncer.cancelDebounceTimer(); if (executionState == ExecutionState.successful) { + if (!mounted) return; setState(() {}); } @@ -470,6 +472,7 @@ class _ButtonChildWidgetState extends State { } } if (executionState == ExecutionState.error) { + if (!mounted) return; setState(() { executionState = ExecutionState.idle; widget.isInAlert @@ -512,6 +515,7 @@ class _ButtonChildWidgetState extends State { } void _onTapDown(details) { + if (!mounted) return; setState(() { buttonColor = widget.buttonStyle.pressedButtonColor ?? widget.buttonStyle.defaultButtonColor; @@ -527,13 +531,17 @@ class _ButtonChildWidgetState extends State { void _onTapUp(details) { Future.delayed( const Duration(milliseconds: 84), - () => setState(() { - setAllStylesToDefault(); - }), + () { + if (!mounted) return; + setState(() { + setAllStylesToDefault(); + }); + }, ); } void _onTapCancel() { + if (!mounted) return; setState(() { setAllStylesToDefault(); }); diff --git a/mobile/apps/photos/lib/ui/components/toggle_switch_widget.dart b/mobile/apps/photos/lib/ui/components/toggle_switch_widget.dart index ec631f6fa8..73333bc599 100644 --- a/mobile/apps/photos/lib/ui/components/toggle_switch_widget.dart +++ b/mobile/apps/photos/lib/ui/components/toggle_switch_widget.dart @@ -106,12 +106,14 @@ class _ToggleSwitchWidgetState extends State { } Future _onChanged(bool negationOfToggleValue) async { + if (!mounted) return; setState(() { toggleValue = negationOfToggleValue; //start showing inProgress statu icons if toggle takes more than debounce time _debouncer.run( () => Future( () { + if (!mounted) return; setState(() { executionState = ExecutionState.inProgress; }); @@ -129,16 +131,16 @@ class _ToggleSwitchWidgetState extends State { _debouncer.cancelDebounceTimer(); final newValue = widget.value.call(); + if (!mounted) return; setState(() { if (toggleValue == newValue) { if (executionState == ExecutionState.inProgress) { executionState = ExecutionState.successful; Future.delayed(const Duration(seconds: 2), () { - if (mounted) { - setState(() { - executionState = ExecutionState.idle; - }); - } + if (!mounted) return; + setState(() { + executionState = ExecutionState.idle; + }); }); } } else { diff --git a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart index 09d3872129..91b924e074 100644 --- a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart +++ b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart @@ -63,97 +63,114 @@ class _VideoStreamingSettingsPageState ), ) : null, - body: CustomScrollView( - primary: false, - slivers: [ - TitleBarWidget( - reducedExpandedHeight: 16, - flexibleSpaceTitle: TitleBarTitleWidget( - title: AppLocalizations.of(context).videoStreaming, - ), - actionIcons: [ - IconButtonWidget( - icon: Icons.close_outlined, - iconButtonType: IconButtonType.secondary, - onTap: () { - Navigator.pop(context); - if (Navigator.canPop(context)) Navigator.pop(context); - if (Navigator.canPop(context)) Navigator.pop(context); - }, + appBar: hasEnabled + ? null + : PreferredSize( + preferredSize: const Size.fromHeight(154), + child: TitleBarWidget( + reducedExpandedHeight: 16, + flexibleSpaceTitle: TitleBarTitleWidget( + title: AppLocalizations.of(context).videoStreaming, + ), + actionIcons: [ + IconButtonWidget( + icon: Icons.close_outlined, + iconButtonType: IconButtonType.secondary, + onTap: () { + Navigator.pop(context); + if (Navigator.canPop(context)) Navigator.pop(context); + if (Navigator.canPop(context)) Navigator.pop(context); + }, + ), + ], + isSliver: false, ), - ], - ), - if (hasEnabled) ...[ - SliverToBoxAdapter( - child: Container( - height: MediaQuery.sizeOf(context).height * 0.88, - padding: const EdgeInsets.only(left: 16, right: 16), - child: Column( - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: AppLocalizations.of(context) - .videoStreamingDescription, - ), - if (hasEnabled) ...[ - const TextSpan(text: " "), - TextSpan( - text: AppLocalizations.of(context) - .videoStreamingDescriptionClickable, - style: const TextStyle( - decoration: TextDecoration.underline, - ), - recognizer: TapGestureRecognizer() - ..onTap = openHelp, - ), - ], - ], - ), - textAlign: TextAlign.justify, - style: getEnteTextTheme(context).mini.copyWith( - color: getEnteColorScheme(context).textMuted, - ), + ), + body: hasEnabled + ? CustomScrollView( + primary: false, + slivers: [ + TitleBarWidget( + reducedExpandedHeight: 16, + flexibleSpaceTitle: TitleBarTitleWidget( + title: AppLocalizations.of(context).videoStreaming, + ), + actionIcons: [ + IconButtonWidget( + icon: Icons.close_outlined, + iconButtonType: IconButtonType.secondary, + onTap: () { + Navigator.pop(context); + if (Navigator.canPop(context)) Navigator.pop(context); + if (Navigator.canPop(context)) Navigator.pop(context); + }, ), ], ), - ), - ), - SliverToBoxAdapter( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, - ).copyWith(top: 30), - child: _getStreamingSettings(context), - ), - ), - ] else ...[ - SliverToBoxAdapter( - child: SizedBox( - width: double.infinity, + SliverToBoxAdapter( + child: Container( + padding: const EdgeInsets.only(left: 16, right: 16), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: AppLocalizations.of(context) + .videoStreamingDescription, + ), + const TextSpan(text: " "), + TextSpan( + text: AppLocalizations.of(context).moreDetails, + style: TextStyle( + color: getEnteColorScheme(context).primary500, + ), + recognizer: TapGestureRecognizer() + ..onTap = openHelp, + ), + ], + ), + textAlign: TextAlign.justify, + style: getEnteTextTheme(context).mini.copyWith( + color: getEnteColorScheme(context).textMuted, + ), + ), + ], + ), + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + ).copyWith(top: 30), + child: _getStreamingSettings(context), + ), + ), + ], + ) + : Center( + child: SingleChildScrollView( child: Column( - mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( - "assets/albums-widget-static.png", + "assets/enable-streaming-static.png", height: 160, ), const SizedBox(height: 16), Text.rich( TextSpan( - text: AppLocalizations.of(context).addSomePhotosDesc1, + text: AppLocalizations.of(context) + .videoStreamingDescription + + " ", children: [ TextSpan( - text: - AppLocalizations.of(context).addSomePhotosDesc2, + text: AppLocalizations.of(context).moreDetails, style: TextStyle( color: getEnteColorScheme(context).primary500, ), - ), - TextSpan( - text: - AppLocalizations.of(context).addSomePhotosDesc3, + recognizer: TapGestureRecognizer() + ..onTap = openHelp, ), ], ), @@ -165,9 +182,6 @@ class _VideoStreamingSettingsPageState ), ), ), - ], - ], - ), ); } @@ -185,6 +199,7 @@ class _VideoStreamingSettingsPageState final isEnabled = VideoPreviewService.instance.isVideoStreamingEnabled; await VideoPreviewService.instance.setIsVideoStreamingEnabled(!isEnabled); + if (!mounted) return; setState(() {}); }