π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Update video streaming settings design
AmanRajSinghMouryab5cb2347f005
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.dartindex 8cc85b0a87..3f230798d6 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@@ -1,20 +1,17 @@import "dart:async";-import "package:flutter/gestures.dart";+import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";+import "package:hugeicons/hugeicons.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/video_preview_state_changed_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";import "package:photos/models/preview/preview_item_status.dart";import "package:photos/services/video_preview_service.dart";-import "package:photos/theme/ente_theme.dart";import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/common/web_page.dart";-import "package:photos/ui/components/buttons/button_widget.dart";-import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";-import "package:photos/ui/components/models/button_type.dart";-import "package:photos/ui/components/toggle_switch_widget.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";const helpUrl ="https://ente.com/help/photos/features/utilities/video-streaming#related-faqs";@@ -41,29 +38,28 @@ class _VideoStreamingSettingsPageState@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;-- final pageBackgroundColor =- isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);-+ final l10n = AppLocalizations.of(context);final hasEnabled = VideoPreviewService.instance.isVideoStreamingEnabled;+ final children = hasEnabled+ ? _enabledChildren(context)+ : _disabledChildren(+ context,+ );- return Scaffold(- backgroundColor: pageBackgroundColor,+ return SettingsPageScaffold(+ title: l10n.videoStreaming,bottomNavigationBar: !hasEnabled? SafeArea(child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16)- .copyWith(bottom: 20),+ padding: const EdgeInsets.symmetric(+ horizontal: 16,+ ).copyWith(bottom: 20),child: Column(mainAxisSize: MainAxisSize.min,children: [const SizedBox(height: 12),- ButtonWidget(- buttonType: ButtonType.primary,- labelText: context.l10n.enable,+ ButtonComponent(+ label: context.l10n.enable,onTap: () async {await toggleVideoStreaming();},@@ -73,136 +69,113 @@ class _VideoStreamingSettingsPageState),): null,- body: SafeArea(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(height: 24),- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,+ children: children,+ );+ }++ List<Widget> _enabledChildren(BuildContext context) {+ final colors = context.componentColors;+ final l10n = AppLocalizations.of(context);+ return [+ Text.rich(+ TextSpan(+ children: [+ TextSpan(text: l10n.videoStreamingDescriptionLine1),+ const TextSpan(text: " "),+ TextSpan(text: l10n.videoStreamingDescriptionLine2),+ const TextSpan(text: "\n"),+ WidgetSpan(+ alignment: PlaceholderAlignment.baseline,+ baseline: TextBaseline.alphabetic,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: openHelp,+ child: Text(+ l10n.moreDetails,+ style: TextStyles.bodyLink.copyWith(+ color: colors.primary,+ decorationColor: colors.primary,+ ),),),- const SizedBox(height: 24),- Text(- AppLocalizations.of(context).videoStreaming,- style: textTheme.h3Bold,- ),- const SizedBox(height: 24),- Expanded(- child: hasEnabled- ? SingleChildScrollView(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text.rich(- TextSpan(- children: [- TextSpan(- text: AppLocalizations.of(context)- .videoStreamingDescriptionLine1,- ),- const TextSpan(text: " "),- TextSpan(- text: AppLocalizations.of(context)- .videoStreamingDescriptionLine2,- ),- const TextSpan(text: " "),- TextSpan(- text: AppLocalizations.of(context)- .moreDetails,- style: TextStyle(- color: colorScheme.primary500,- ),- recognizer: TapGestureRecognizer()- ..onTap = openHelp,- ),- ],- ),- style: textTheme.mini- .copyWith(color: colorScheme.textMuted),- ),- const SizedBox(height: 24),- MenuItemWidgetNew(- title: AppLocalizations.of(context).enabled,- trailingWidget: ToggleSwitchWidget(- value: () => hasEnabled,- onChanged: () async {- await toggleVideoStreaming();- },- ),- ),- const SizedBox(height: 8),- const VideoStreamingStatusWidget(),- ],- ),- )- : Center(- child: SingleChildScrollView(- child: Column(- children: [- Image.asset(- "assets/enable-streaming-static.png",- height: 160,- ),- const SizedBox(height: 16),- Padding(- padding:- const EdgeInsets.symmetric(horizontal: 12),- child: Text.rich(- TextSpan(- children: [- TextSpan(- text: AppLocalizations.of(context)- .videoStreamingDescriptionLine1,- ),- const TextSpan(text: "\n"),- TextSpan(- text: AppLocalizations.of(context)- .videoStreamingDescriptionLine2,- ),- const TextSpan(text: "\n"),- TextSpan(- text: AppLocalizations.of(context)- .moreDetails,- style: TextStyle(- color: colorScheme.primary500,- ),- recognizer: TapGestureRecognizer()- ..onTap = openHelp,- ),- ],- ),- style: textTheme.smallMuted,- textAlign: TextAlign.center,- ),- ),- const SizedBox(height: 140),- ],- ),- ),- ),+ ),+ ],+ ),+ style: TextStyles.body.copyWith(color: colors.textLight),+ ),+ const SizedBox(height: 24),+ MenuComponent(+ title: l10n.enabled,+ leading: _streamingMenuIcon(+ context,+ HugeIcons.strokeRoundedToggleOn,+ ),+ trailing: ToggleSwitchComponent.async(+ value: () => VideoPreviewService.instance.isVideoStreamingEnabled,+ onChanged: () async {+ await toggleVideoStreaming();+ },+ ),+ ),+ const SizedBox(height: 8),+ const VideoStreamingStatusWidget(),+ ];+ }++ List<Widget> _disabledChildren(BuildContext context) {+ final colors = context.componentColors;+ final l10n = AppLocalizations.of(context);+ return [+ const SizedBox(height: 80),+ Image.asset(+ "assets/enable-streaming-static.png",+ height: 160,+ ),+ const SizedBox(height: 16),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12),+ child: Text.rich(+ TextSpan(+ children: [+ TextSpan(text: l10n.videoStreamingDescriptionLine1),+ const TextSpan(text: "\n"),+ TextSpan(text: l10n.videoStreamingDescriptionLine2),+ const TextSpan(text: "\n"),+ WidgetSpan(+ alignment: PlaceholderAlignment.baseline,+ baseline: TextBaseline.alphabetic,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: openHelp,+ child: Text(+ l10n.moreDetails,+ style: TextStyles.bodyLink.copyWith(+ color: colors.primary,+ decorationColor: colors.primary,+ ),+ ),+ ),),],),+ style: TextStyles.body.copyWith(color: colors.textLight),+ textAlign: TextAlign.center,),),- );+ const SizedBox(height: 140),+ ];}Future<void> openHelp() async {- Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return WebPage(AppLocalizations.of(context).help, helpUrl);- },- ),- ).ignore();+ Navigator.of(context)+ .push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return WebPage(AppLocalizations.of(context).help, helpUrl);+ },+ ),+ )+ .ignore();}Future<void> toggleVideoStreaming() async {@@ -231,8 +204,9 @@ class VideoStreamingStatusWidgetStatevoid initState() {super.initState();init();- _subscription =- Bus.instance.on<VideoPreviewStateChangedEvent>().listen((event) {+ _subscription = Bus.instance.on<VideoPreviewStateChangedEvent>().listen((+ event,+ ) {final status = event.status;// Handle different states@@ -258,8 +232,7 @@ class VideoStreamingStatusWidgetState@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- final colorScheme = getEnteColorScheme(context);+ final colors = context.componentColors;return Column(children: [@@ -267,13 +240,17 @@ class VideoStreamingStatusWidgetStateColumn(crossAxisAlignment: CrossAxisAlignment.start,children: [- MenuItemWidgetNew(+ MenuComponent(title: AppLocalizations.of(context).processed,- trailingWidget: Text(+ leading: _streamingMenuIcon(+ context,+ HugeIcons.strokeRoundedClock01,+ ),+ trailing: Text(_netProcessed == 0? '0%': '${(_netProcessed! * 100.0).toStringAsFixed(2)}%',- style: textTheme.small,+ style: TextStyles.mini.copyWith(color: colors.textLight),),key: ValueKey("processed_items_$_netProcessed"),),@@ -282,7 +259,7 @@ class VideoStreamingStatusWidgetStatepadding: const EdgeInsets.symmetric(horizontal: 16),child: Text(AppLocalizations.of(context).videoStreamingNote,- style: textTheme.mini.copyWith(color: colorScheme.textMuted),+ style: TextStyles.body.copyWith(color: colors.textLight),),),],@@ -293,3 +270,15 @@ class VideoStreamingStatusWidgetState);}}++Widget _streamingMenuIcon(+ BuildContext context,+ List<List<dynamic>> icon,+) {+ return HugeIcon(+ icon: icon,+ color: context.componentColors.textLight,+ size: IconSizes.small,+ strokeWidth: 1.6,+ );+}