π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Migrate remaining title bars (#11759)
aman-pilot93b28eb78b15
diff --git a/mobile/apps/photos/lib/ui/components/title_bar_widget.dart b/mobile/apps/photos/lib/ui/components/title_bar_widget.dartdeleted file mode 100644index cd4a6b85fb..0000000000--- a/mobile/apps/photos/lib/ui/components/title_bar_widget.dart+++ /dev/null@@ -1,239 +0,0 @@-import 'package:flutter/material.dart';-import 'package:photos/theme/ente_theme.dart';-import 'package:photos/ui/components/buttons/icon_button_widget.dart';--class TitleBarWidget extends StatelessWidget {- final IconButtonWidget? leading;- final String? title;- final String? caption;- final Widget? flexibleSpaceTitle;- final String? flexibleSpaceCaption;- final List<Widget>? actionIcons;- final bool isTitleH2WithoutLeading;- final bool isFlexibleSpaceDisabled;- final bool isOnTopOfScreen;- final Color? backgroundColor;- final bool isSliver;- final double? expandedHeight;- final double reducedExpandedHeight;-- const TitleBarWidget({- this.leading,- this.title,- this.caption,- this.flexibleSpaceTitle,- this.flexibleSpaceCaption,- this.actionIcons,- this.isTitleH2WithoutLeading = false,- this.isFlexibleSpaceDisabled = false,- this.isOnTopOfScreen = true,- this.backgroundColor,- this.isSliver = true,- this.expandedHeight,- this.reducedExpandedHeight = 0,- super.key,- });-- @override- Widget build(BuildContext context) {- const toolbarHeight = 48.0;- if (isSliver) {- return SliverAppBar(- backgroundColor: backgroundColor,- primary: isOnTopOfScreen ? true : false,- toolbarHeight: toolbarHeight,- leadingWidth: 48,- automaticallyImplyLeading: false,- pinned: true,- expandedHeight:- expandedHeight ??- (isFlexibleSpaceDisabled ? toolbarHeight : 102) -- reducedExpandedHeight,- centerTitle: false,- titleSpacing: 4,- title: TitleWidget(- title: title,- caption: caption,- isTitleH2WithoutLeading: isTitleH2WithoutLeading,- ),- actions: [- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: Row(children: _actionsWithPaddingInBetween()),- ),- ],- leading: isTitleH2WithoutLeading- ? null- : leading ??- IconButtonWidget(- icon: Icons.adaptive.arrow_back_outlined,- iconButtonType: IconButtonType.primary,- onTap: () {- Navigator.pop(context);- },- ),- flexibleSpace: isFlexibleSpaceDisabled- ? null- : FlexibleSpaceBarWidget(- flexibleSpaceTitle,- flexibleSpaceCaption,- toolbarHeight,- maxLines: expandedHeight == null ? 1 : 2,- ),- );- } else {- return AppBar(- backgroundColor: backgroundColor,- primary: isOnTopOfScreen ? true : false,- toolbarHeight: toolbarHeight,- leadingWidth: 48,- automaticallyImplyLeading: false,- centerTitle: false,- titleSpacing: 4,- title: TitleWidget(- title: title,- caption: caption,- isTitleH2WithoutLeading: isTitleH2WithoutLeading,- ),- actions: [- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: Row(children: _actionsWithPaddingInBetween()),- ),- ],- leading: isTitleH2WithoutLeading- ? null- : leading ??- IconButtonWidget(- icon: Icons.adaptive.arrow_back_outlined,- iconButtonType: IconButtonType.primary,- onTap: () {- Navigator.pop(context);- },- ),- flexibleSpace: isFlexibleSpaceDisabled- ? null- : FlexibleSpaceBarWidget(- flexibleSpaceTitle,- flexibleSpaceCaption,- toolbarHeight,- maxLines: expandedHeight == null ? 1 : 2,- ),- );- }- }-- List<Widget> _actionsWithPaddingInBetween() {- if (actionIcons == null) {- return <Widget>[const SizedBox.shrink()];- }- final actions = <Widget>[];- bool addWhiteSpace = false;- final length = actionIcons!.length;- int index = 0;- if (length == 0) {- return <Widget>[const SizedBox.shrink()];- }- if (length == 1) {- return actionIcons!;- }- while (index < length) {- if (!addWhiteSpace) {- actions.add(actionIcons![index]);- index++;- addWhiteSpace = true;- } else {- actions.add(const SizedBox(width: 4));- addWhiteSpace = false;- }- }- return actions;- }-}--class TitleWidget extends StatelessWidget {- final String? title;- final String? caption;- final bool isTitleH2WithoutLeading;- const TitleWidget({- this.title,- this.caption,- required this.isTitleH2WithoutLeading,- super.key,- });-- @override- Widget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- return Padding(- padding: EdgeInsets.only(left: isTitleH2WithoutLeading ? 16 : 0),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.start,- children: [- title == null- ? const SizedBox.shrink()- : Text(- title!,- style: isTitleH2WithoutLeading- ? textTheme.h2Bold- : textTheme.largeBold,- ),- caption == null || isTitleH2WithoutLeading- ? const SizedBox.shrink()- : Text(caption!, style: textTheme.miniMuted),- ],- ),- );- }-}--class FlexibleSpaceBarWidget extends StatelessWidget {- final Widget? flexibleSpaceTitle;- final String? flexibleSpaceCaption;- final double toolbarHeight;- final int maxLines;-- const FlexibleSpaceBarWidget(- this.flexibleSpaceTitle,- this.flexibleSpaceCaption,- this.toolbarHeight, {- super.key,- required this.maxLines,- });-- @override- Widget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- return FlexibleSpaceBar(- background: SafeArea(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: <Widget>[- SizedBox(height: toolbarHeight),- Padding(- padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- flexibleSpaceTitle == null- ? const SizedBox.shrink()- : flexibleSpaceTitle!,- flexibleSpaceCaption == null- ? const SizedBox.shrink()- : Text(- flexibleSpaceCaption!,- style: textTheme.smallMuted,- overflow: TextOverflow.ellipsis,- maxLines: maxLines,- ),- ],- ),- ),- ],- ),- ),- );- }-}diff --git a/mobile/apps/photos/lib/ui/payment/add_on_page.dart b/mobile/apps/photos/lib/ui/payment/add_on_page.dartindex c166e9734e..fc14da66aa 100644--- a/mobile/apps/photos/lib/ui/payment/add_on_page.dart+++ b/mobile/apps/photos/lib/ui/payment/add_on_page.dart@@ -1,12 +1,11 @@+import "package:ente_components/components/app_bar_component.dart";+import "package:ente_components/theme/text_styles.dart";+import "package:ente_components/theme/theme.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:intl/intl.dart";import "package:photos/gateways/storage_bonus/models/bonus.dart";import "package:photos/generated/l10n.dart";-import "package:photos/theme/ente_theme.dart";-import 'package:photos/ui/components/buttons/icon_button_widget.dart';-import "package:photos/ui/components/title_bar_title_widget.dart";-import "package:photos/ui/components/title_bar_widget.dart";class AddOnPage extends StatelessWidget {final BonusData bonusData;@@ -31,26 +30,10 @@ class AddOnPage extends StatelessWidget {@overrideWidget build(BuildContext context) {return Scaffold(- body: CustomScrollView(- primary: false,+ body: AppBarComponent(+ title: AppLocalizations.of(context).addOns,+ subtitle: AppLocalizations.of(context).addOnPageSubtitle,slivers: <Widget>[- TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(- title: AppLocalizations.of(context).addOns,- ),- flexibleSpaceCaption: AppLocalizations.of(- context,- ).addOnPageSubtitle,- actionIcons: [- IconButtonWidget(- icon: Icons.close_outlined,- iconButtonType: IconButtonType.secondary,- onTap: () {- Navigator.of(context).pop();- },- ),- ],- ),SliverPadding(padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16),sliver: SliverList(@@ -87,8 +70,7 @@ class AddOnViewSection extends StatelessWidget {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textStyle = getEnteTextTheme(context);+ final colors = context.componentColors;return Column(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -97,7 +79,7 @@ class AddOnViewSection extends StatelessWidget {children: [Text(sectionName,- style: textStyle.body.copyWith(color: colorScheme.textMuted),+ style: TextStyles.large.copyWith(color: colors.textLight),),if (bonus.validTill != 0)Text(@@ -113,7 +95,7 @@ class AddOnViewSection extends StatelessWidget {).toString(),),- style: textStyle.body.copyWith(color: colorScheme.textMuted),+ style: TextStyles.large.copyWith(color: colors.textLight),),],),@@ -123,7 +105,7 @@ class AddOnViewSection extends StatelessWidget {children: [TextSpan(text: convertBytesToReadableFormat(bonus.storage).toString(),- style: textStyle.h3,+ style: TextStyles.display2.copyWith(color: colors.textBase),),],),diff --git a/mobile/apps/photos/lib/ui/settings/ml/ml_user_dev_screen.dart b/mobile/apps/photos/lib/ui/settings/ml/ml_user_dev_screen.dartindex 272af1182b..cd6588e7aa 100644--- a/mobile/apps/photos/lib/ui/settings/ml/ml_user_dev_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/ml/ml_user_dev_screen.dart@@ -15,10 +15,9 @@ import "package:photos/theme/ente_theme.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";import "package:photos/ui/components/settings/settings_grouped_card.dart";-import "package:photos/ui/components/title_bar_title_widget.dart";-import "package:photos/ui/components/title_bar_widget.dart";import "package:photos/ui/components/toggle_switch_widget.dart";import "package:photos/ui/notification/toast.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";import "package:photos/utils/dialog_util.dart";final Logger _logger = Logger("MLUserDeveloperOptions");@@ -79,135 +78,102 @@ class _MLUserDeveloperOptionsState extends State<MLUserDeveloperOptions> {@overrideWidget build(BuildContext context) {- return Scaffold(- body: CustomScrollView(- primary: false,- slivers: <Widget>[- const TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(title: "ML debug options"),- ),- SliverList(- delegate: SliverChildBuilderDelegate(- (delegateBuildContext, index) => Padding(- padding: const EdgeInsets.only(left: 16, right: 16),- child: Column(- children: [- Text(- "Only use if you know what you're doing",- textAlign: TextAlign.left,- style: getEnteTextTheme(context).body.copyWith(- color: getEnteColorScheme(context).textMuted,- ),- ),- const SizedBox(height: 48),- widget.mlIsEnabled- ? ButtonWidget(- buttonType: ButtonType.neutral,- labelText: "Purge empty indices",- onTap: () async {- await deleteEmptyIndices(context);- },- )- : const SizedBox(),- widget.mlIsEnabled- ? const SizedBox(height: 24)- : const SizedBox(),- widget.mlIsEnabled- ? ButtonWidget(- buttonType: ButtonType.neutral,- labelText: "Reset all local ML",- onTap: () async {- await deleteAllLocalML(context);- },- )- : const SizedBox(),- widget.mlIsEnabled- ? const SizedBox(height: 24)- : const SizedBox(),- widget.mlIsEnabled- ? MenuComponent(- title: "Remote fetch",- trailing: ToggleSwitchComponent.async(- value: () => localSettings.remoteFetchEnabled,- onChanged: () async {- try {- await localSettings.toggleRemoteFetch();- _logger.info(- 'Remote fetch is turned ${localSettings.remoteFetchEnabled ? 'on' : 'off'}',- );- if (mounted) {- setState(() {});- }- } catch (e, s) {- _logger.warning(- 'Remote fetch toggle failed ',- e,- s,- );- if (!context.mounted) return;- await showGenericErrorDialog(- context: context,- error: e,- );- }- },- ),- )- : const SizedBox(),- widget.mlIsEnabled- ? const SizedBox(height: 24)- : const SizedBox.shrink(),- widget.mlIsEnabled- ? MenuComponent(- title: "Run ML on interactions",- trailing: ToggleSwitchComponent.async(- value: () =>- localSettings.runMLDuringInteractionOverride,- onChanged: () async {- try {- final enabled = !localSettings- .runMLDuringInteractionOverride;- await computeController- .setMLInteractionOverride(- turnOn: enabled,- );- _logger.info(- 'run ML during interaction is turned ${enabled ? 'on' : 'off'}',- );- if (mounted) {- setState(() {});- }- } catch (e, s) {- _logger.warning(- 'run ML during interaction toggle failed ',- e,- s,- );- if (!context.mounted) return;- await showGenericErrorDialog(- context: context,- error: e,- );- }- },- ),- )- : const SizedBox.shrink(),- widget.mlIsEnabled- ? const SizedBox(height: 24)- : const SizedBox.shrink(),- widget.mlIsEnabled- ? _buildThresholdsCard(context)- : const SizedBox.shrink(),- const SafeArea(child: SizedBox(height: 12)),- ],+ return SettingsPageScaffold(+ title: "ML debug options",+ children: [+ Text(+ "Only use if you know what you're doing",+ textAlign: TextAlign.left,+ style: getEnteTextTheme(+ context,+ ).body.copyWith(color: getEnteColorScheme(context).textMuted),+ ),+ const SizedBox(height: 48),+ widget.mlIsEnabled+ ? ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: "Purge empty indices",+ onTap: () async {+ await deleteEmptyIndices(context);+ },+ )+ : const SizedBox(),+ widget.mlIsEnabled ? const SizedBox(height: 24) : const SizedBox(),+ widget.mlIsEnabled+ ? ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: "Reset all local ML",+ onTap: () async {+ await deleteAllLocalML(context);+ },+ )+ : const SizedBox(),+ widget.mlIsEnabled ? const SizedBox(height: 24) : const SizedBox(),+ widget.mlIsEnabled+ ? MenuComponent(+ title: "Remote fetch",+ trailing: ToggleSwitchComponent.async(+ value: () => localSettings.remoteFetchEnabled,+ onChanged: () async {+ try {+ await localSettings.toggleRemoteFetch();+ _logger.info(+ 'Remote fetch is turned ${localSettings.remoteFetchEnabled ? 'on' : 'off'}',+ );+ if (mounted) {+ setState(() {});+ }+ } catch (e, s) {+ _logger.warning('Remote fetch toggle failed ', e, s);+ if (!context.mounted) return;+ await showGenericErrorDialog(context: context, error: e);+ }+ },),- ),- childCount: 1,- ),- ),- ],- ),+ )+ : const SizedBox(),+ widget.mlIsEnabled+ ? const SizedBox(height: 24)+ : const SizedBox.shrink(),+ widget.mlIsEnabled+ ? MenuComponent(+ title: "Run ML on interactions",+ trailing: ToggleSwitchComponent.async(+ value: () => localSettings.runMLDuringInteractionOverride,+ onChanged: () async {+ try {+ final enabled =+ !localSettings.runMLDuringInteractionOverride;+ await computeController.setMLInteractionOverride(+ turnOn: enabled,+ );+ _logger.info(+ 'run ML during interaction is turned ${enabled ? 'on' : 'off'}',+ );+ if (mounted) {+ setState(() {});+ }+ } catch (e, s) {+ _logger.warning(+ 'run ML during interaction toggle failed ',+ e,+ s,+ );+ if (!context.mounted) return;+ await showGenericErrorDialog(context: context, error: e);+ }+ },+ ),+ )+ : const SizedBox.shrink(),+ widget.mlIsEnabled+ ? const SizedBox(height: 24)+ : const SizedBox.shrink(),+ widget.mlIsEnabled+ ? _buildThresholdsCard(context)+ : const SizedBox.shrink(),+ const SizedBox(height: 12),+ ],);}