π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Migrate link picker components (#11769)
aman-pilot9855f937b9d3
diff --git a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dartindex 09bb92fc5f..74103e0878 100644--- a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart+++ b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart@@ -4,10 +4,6 @@ import "dart:convert";import 'package:ente_components/ente_components.dart';import "package:ente_crypto_api/ente_crypto_api.dart";import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:ente_ui/components/captioned_text_widget_v2.dart";-import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget_v2.dart";-import "package:ente_ui/components/toggle_switch_widget.dart";import "package:ente_ui/utils/dialog_util.dart";import "package:ente_ui/utils/toast_util.dart";import "package:ente_utils/share_utils.dart";@@ -50,222 +46,202 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {widget.collection!,);return Scaffold(- appBar: AppBar(- elevation: 0,- centerTitle: false,- title: Text(context.l10n.manageLink),- ),- body: SingleChildScrollView(- child: ListBody(- children: <Widget>[- Padding(- padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),+ backgroundColor: colors.backgroundBase,+ body: AppBarComponent(+ title: context.l10n.manageLink,+ slivers: [+ SliverPadding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.lg,+ Spacing.md,+ Spacing.lg,+ Spacing.md,+ ),+ sliver: SliverToBoxAdapter(child: Column(- crossAxisAlignment: CrossAxisAlignment.start,children: [- MenuItemWidgetV2(- alignCaptionedTextToLeft: true,- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.linkExpiry,- subTitle: url.hasExpiry- ? (url.isExpired- ? context.l10n.linkExpired- : getFormattedTime(- DateTime.fromMicrosecondsSinceEpoch(- url.validTill,- ),- ))- : context.l10n.never,- subTitleColor: url.isExpired ? colors.warning : null,- ),- trailingWidget: HugeIcon(- icon: HugeIcons.strokeRoundedArrowRight01,- color: colors.textLight,- size: 20,- ),- menuItemColor: colors.fillLight,- surfaceExecutionStates: false,- onTap: () async {- unawaited(- routeToPage(- context,- LinkExpiryPickerPage(widget.collection!),- ).then((value) {- if (mounted) {- setState(() {});- }- }),- );- },- ),- const Padding(padding: EdgeInsets.only(top: 24)),- MenuItemWidgetV2(- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.linkDeviceLimit,- subTitle: url.deviceLimit == 0- ? context.l10n.noDeviceLimit- : "${url.deviceLimit}",- ),- trailingWidget: HugeIcon(- icon: HugeIcons.strokeRoundedArrowRight01,- color: colors.textLight,- size: 20,- ),- menuItemColor: colors.fillLight,- alignCaptionedTextToLeft: true,- isBottomBorderRadiusRemoved: true,- onTap: () async {- unawaited(- routeToPage(- context,- DeviceLimitPickerPage(widget.collection!),- ).then((value) {- if (mounted) {- setState(() {});- }- }),- );- },- surfaceExecutionStates: false,- ),- DividerWidget(- dividerType: DividerType.menu,- bgColor: colors.fillLight,- ),- MenuItemWidgetV2(- key: ValueKey("Password lock ${url.passwordEnabled}"),- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.passwordLock,- ),- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- menuItemColor: colors.fillLight,- trailingWidget: ToggleSwitchWidget(- value: () => url.passwordEnabled,- onChanged: () async {- if (!url.passwordEnabled) {- await showTextInputSheet(- context,- title: context.l10n.setAPassword,- submitButtonLabel: context.l10n.lockButtonLabel,- hintText: context.l10n.enterPassword,- onSubmit: (String password) async {- if (password.trim().isEmpty) {- return;+ MenuGroupComponent(+ items: [+ MenuComponent(+ title: context.l10n.linkExpiry,+ subtitle: url.hasExpiry+ ? (url.isExpired+ ? context.l10n.linkExpired+ : getFormattedTime(+ DateTime.fromMicrosecondsSinceEpoch(+ url.validTill,+ ),+ ))+ : context.l10n.never,+ subtitleColor: url.isExpired ? colors.warning : null,+ trailing: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowRight01,+ color: colors.textLight,+ size: 20,+ ),+ onTap: () async {+ unawaited(+ routeToPage(+ context,+ LinkExpiryPickerPage(widget.collection!),+ ).then((value) {+ if (mounted) {+ setState(() {});}- final propToUpdate = await _getEncryptedPassword(- password,- );- await _updateUrlSettings(- context.mounted ? context : null,- propToUpdate,- showProgressDialog: false,- );- },- isPasswordInput: true,- textCapitalization: TextCapitalization.none,- maxLength: 256,+ }),);- } else {- await _updateUrlSettings(context, {- 'disablePassword': true,- });- }- },- ),- ),- const SizedBox(height: 24),- if (url.isExpired)- MenuItemWidgetV2(- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.linkExpired,- textColor: colors.warning,+ },),- leadingIcon: Icons.error_outline,- leadingIconColor: colors.warning,- menuItemColor: colors.fillLight,- ),- if (!url.isExpired)- MenuItemWidgetV2(- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.copyLink,- makeTextBold: true,- ),- leadingIconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedCopy01,- color: colors.textBase,- size: 20,+ ],+ ),+ const SizedBox(height: Spacing.xxl),+ MenuGroupComponent(+ items: [+ MenuComponent(+ title: context.l10n.linkDeviceLimit,+ subtitle: url.deviceLimit == 0+ ? context.l10n.noDeviceLimit+ : "${url.deviceLimit}",+ trailing: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowRight01,+ color: colors.textLight,+ size: 20,+ ),+ onTap: () async {+ unawaited(+ routeToPage(+ context,+ DeviceLimitPickerPage(widget.collection!),+ ).then((value) {+ if (mounted) {+ setState(() {});+ }+ }),+ );+ },),- menuItemColor: colors.fillLight,- showOnlyLoadingState: true,- onTap: () async {- await Clipboard.setData(ClipboardData(text: urlValue));- if (!context.mounted) {- return;- }- showShortToast(- context,- context.l10n.linkCopiedToClipboard,- );- },- isBottomBorderRadiusRemoved: true,- ),- if (!url.isExpired)- DividerWidget(- dividerType: DividerType.menu,- bgColor: colors.fillLight,- ),- if (!url.isExpired)- MenuItemWidgetV2(- key: sendLinkButtonKey,- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.sendLink,- makeTextBold: true,+ MenuComponent(+ key: ValueKey("Password lock ${url.passwordEnabled}"),+ title: context.l10n.passwordLock,+ trailing: ToggleSwitchComponent.async(+ value: () => url.passwordEnabled,+ onChanged: () async {+ if (!url.passwordEnabled) {+ await showTextInputSheet(+ context,+ title: context.l10n.setAPassword,+ submitButtonLabel: context.l10n.lockButtonLabel,+ hintText: context.l10n.enterPassword,+ onSubmit: (String password) async {+ if (password.trim().isEmpty) {+ return;+ }+ final propToUpdate =+ await _getEncryptedPassword(password);+ await _updateUrlSettings(+ context.mounted ? context : null,+ propToUpdate,+ showProgressDialog: false,+ );+ },+ isPasswordInput: true,+ textCapitalization: TextCapitalization.none,+ maxLength: 256,+ );+ } else {+ await _updateUrlSettings(context, {+ 'disablePassword': true,+ });+ }+ },+ ),),- leadingIconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedShare08,- color: colors.textBase,- size: 20,+ ],+ ),+ const SizedBox(height: Spacing.xxl),+ MenuGroupComponent(+ items: [+ if (url.isExpired)+ MenuComponent(+ title: context.l10n.linkExpired,+ titleColor: colors.warning,+ iconColor: colors.warning,+ leading: const Icon(Icons.error_outline),+ ),+ if (!url.isExpired)+ MenuComponent(+ title: context.l10n.copyLink,+ titleBold: true,+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedCopy01,+ color: colors.textBase,+ size: 20,+ ),+ showOnlyLoadingState: true,+ onTap: () async {+ await Clipboard.setData(+ ClipboardData(text: urlValue),+ );+ if (!context.mounted) {+ return;+ }+ showShortToast(+ context,+ context.l10n.linkCopiedToClipboard,+ );+ },+ ),+ if (!url.isExpired)+ MenuComponent(+ key: sendLinkButtonKey,+ title: context.l10n.sendLink,+ titleBold: true,+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedShare08,+ color: colors.textBase,+ size: 20,+ ),+ onTap: () async {+ unawaited(shareText(urlValue, context: context));+ },+ ),+ ],+ ),+ const SizedBox(height: Spacing.xxl),+ MenuGroupComponent(+ items: [+ MenuComponent(+ title: context.l10n.removeLink,+ titleBold: true,+ titleColor: colors.warning,+ iconColor: colors.warning,+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete02,+ color: colors.warning,+ size: 20,+ ),+ onTap: () async {+ final bool result =+ await CollectionActions.disableUrl(+ context,+ widget.collection!,+ );+ if (!context.mounted || !result) {+ return;+ }+ Navigator.of(context).pop();+ if (widget.collection!.isQuickLinkCollection()) {+ Navigator.of(context).pop();+ }+ },),- menuItemColor: colors.fillLight,- onTap: () async {- unawaited(shareText(urlValue, context: context));- },- isTopBorderRadiusRemoved: true,- ),- const SizedBox(height: 24),- MenuItemWidgetV2(- captionedTextWidget: CaptionedTextWidgetV2(- title: context.l10n.removeLink,- textColor: colors.warning,- makeTextBold: true,- ),- leadingIconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- color: colors.warning,- size: 20,- ),- menuItemColor: colors.fillLight,- surfaceExecutionStates: false,- onTap: () async {- final bool result = await CollectionActions.disableUrl(- context,- widget.collection!,- );- if (!context.mounted || !result) {- return;- }- Navigator.of(context).pop();- if (widget.collection!.isQuickLinkCollection()) {- Navigator.of(context).pop();- }- },+ ],),],),),- ],- ),+ ),+ ],),);}diff --git a/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart b/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dartindex f721a490cb..7f034e4bbe 100644--- a/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart+++ b/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart@@ -1,10 +1,4 @@import 'package:ente_components/ente_components.dart';-import "package:ente_ui/components/captioned_text_widget_v2.dart";-import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget_v2.dart";-import "package:ente_ui/components/separators.dart";-import "package:ente_ui/components/title_bar_title_widget.dart";-import "package:ente_ui/components/title_bar_widget.dart";import 'package:flutter/material.dart';import "package:locker/core/constants.dart";import "package:locker/l10n/l10n.dart";@@ -19,34 +13,19 @@ class DeviceLimitPickerPage extends StatelessWidget {@overrideWidget build(BuildContext context) {return Scaffold(- body: CustomScrollView(- primary: false,- slivers: <Widget>[- TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(- title: context.l10n.linkDeviceLimit,+ backgroundColor: context.componentColors.backgroundBase,+ body: AppBarComponent(+ title: context.l10n.linkDeviceLimit,+ slivers: [+ SliverPadding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.lg,+ Spacing.xl,+ Spacing.lg,+ Spacing.xl,),+ sliver: SliverToBoxAdapter(child: ItemsWidget(collection)),),- SliverList(- delegate: SliverChildBuilderDelegate((context, index) {- return Padding(- padding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 20,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- ClipRRect(- borderRadius: const BorderRadius.all(Radius.circular(8)),- child: ItemsWidget(collection),- ),- ],- ),- );- }, childCount: 1),- ),- const SliverPadding(padding: EdgeInsets.symmetric(vertical: 12)),],),);@@ -64,7 +43,6 @@ class ItemsWidget extends StatefulWidget {class _ItemsWidgetState extends State<ItemsWidget> {late int currentDeviceLimit;late int initialDeviceLimit;- List<Widget> items = [];bool isCustomLimit = false;@overridevoid initState() {@@ -78,51 +56,23 @@ class _ItemsWidgetState extends State<ItemsWidget> {@overrideWidget build(BuildContext context) {- items.clear();+ final items = <Widget>[];if (isCustomLimit) {- items.add(- _menuItemForPicker(- initialDeviceLimit,- isFirst: true,- isLast: publicLinkDeviceLimits.isEmpty,- ),- );+ items.add(_menuItemForPicker(initialDeviceLimit));}- for (int index = 0; index < publicLinkDeviceLimits.length; index++) {- final deviceLimit = publicLinkDeviceLimits[index];- items.add(- _menuItemForPicker(- deviceLimit,- isFirst: !isCustomLimit && index == 0,- isLast: index == publicLinkDeviceLimits.length - 1,- ),- );+ for (final deviceLimit in publicLinkDeviceLimits) {+ items.add(_menuItemForPicker(deviceLimit));}- items = addSeparators(- items,- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: context.componentColors.fillLight,- ),- );- return Column(mainAxisSize: MainAxisSize.min, children: items);+ return MenuGroupComponent(items: items);}- Widget _menuItemForPicker(- int deviceLimit, {- required bool isFirst,- required bool isLast,- }) {- return MenuItemWidgetV2(+ Widget _menuItemForPicker(int deviceLimit) {+ return MenuComponent(key: ValueKey(deviceLimit),- menuItemColor: context.componentColors.fillLight,- captionedTextWidget: CaptionedTextWidgetV2(- title: deviceLimit == 0 ? context.l10n.noDeviceLimit : "$deviceLimit",- ),- trailingIcon: currentDeviceLimit == deviceLimit ? Icons.check : null,- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: !isFirst,- isBottomBorderRadiusRemoved: !isLast,+ title: deviceLimit == 0 ? context.l10n.noDeviceLimit : "$deviceLimit",+ trailing: currentDeviceLimit == deviceLimit+ ? Icon(Icons.check, color: context.componentColors.primary)+ : null,showOnlyLoadingState: true,onTap: () async {await _updateUrlSettings(context, {'deviceLimit': deviceLimit});diff --git a/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart b/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dartindex d98f814929..bd984caa3b 100644--- a/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart+++ b/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart@@ -1,10 +1,4 @@import 'package:ente_components/ente_components.dart';-import "package:ente_ui/components/captioned_text_widget_v2.dart";-import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget_v2.dart";-import "package:ente_ui/components/separators.dart";-import "package:ente_ui/components/title_bar_title_widget.dart";-import "package:ente_ui/components/title_bar_widget.dart";import 'package:flutter/material.dart';import "package:locker/l10n/l10n.dart";import "package:locker/services/collections/collections_api_client.dart";@@ -20,34 +14,19 @@ class LinkExpiryPickerPage extends StatelessWidget {@overrideWidget build(BuildContext context) {return Scaffold(- body: CustomScrollView(- primary: false,- slivers: <Widget>[- TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(- title: context.l10n.linkExpiry,+ backgroundColor: context.componentColors.backgroundBase,+ body: AppBarComponent(+ title: context.l10n.linkExpiry,+ slivers: [+ SliverPadding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.lg,+ Spacing.xl,+ Spacing.lg,+ Spacing.xl,),+ sliver: SliverToBoxAdapter(child: ItemsWidget(collection)),),- SliverList(- delegate: SliverChildBuilderDelegate((context, index) {- return Padding(- padding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 20,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- ClipRRect(- borderRadius: const BorderRadius.all(Radius.circular(8)),- child: ItemsWidget(collection),- ),- ],- ),- );- }, childCount: 1),- ),- const SliverPadding(padding: EdgeInsets.symmetric(vertical: 12)),],),);@@ -77,45 +56,25 @@ class _ItemsWidgetState extends State<ItemsWidget> {@overrideWidget build(BuildContext context) {- List<Widget> items = [];- for (int index = 0; index < _expiryOptions.length; index++) {- final expiryOpiton = _expiryOptions[index];- items.add(- _menuItemForPicker(- context,- expiryOpiton,- isFirst: index == 0,- isLast: index == _expiryOptions.length - 1,- ),- );- }- items = addSeparators(- items,- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: context.componentColors.fillLight,- ),+ return MenuGroupComponent(+ items: [+ for (final expiryOption in _expiryOptions)+ _menuItemForPicker(context, expiryOption),+ ],);- return Column(mainAxisSize: MainAxisSize.min, children: items);}Widget _menuItemForPicker(BuildContext context,- Tuple2<String, int> expiryOpiton, {- required bool isFirst,- required bool isLast,- }) {- return MenuItemWidgetV2(- menuItemColor: context.componentColors.fillLight,- captionedTextWidget: CaptionedTextWidgetV2(title: expiryOpiton.item1),- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: !isFirst,- isBottomBorderRadiusRemoved: !isLast,- alwaysShowSuccessState: true,- surfaceExecutionStates: expiryOpiton.item2 == -1 ? false : true,+ Tuple2<String, int> expiryOption,+ ) {+ return MenuComponent(+ title: expiryOption.item1,+ shouldSurfaceExecutionStates: expiryOption.item2 != -1,+ shouldShowSuccessConfirmation: expiryOption.item2 != -1,onTap: () async {int newValidTill = -1;- final int expireAfterInMicroseconds = expiryOpiton.item2;+ final int expireAfterInMicroseconds = expiryOption.item2;// need to manually select timeif (expireAfterInMicroseconds < 0) {final now = DateTime.now();diff --git a/mobile/packages/ente_components/lib/components/menu_component.dart b/mobile/packages/ente_components/lib/components/menu_component.dartindex a96eb76b6f..1598dcd52e 100644--- a/mobile/packages/ente_components/lib/components/menu_component.dart+++ b/mobile/packages/ente_components/lib/components/menu_component.dart@@ -41,6 +41,8 @@ class MenuComponent extends StatefulWidget {this.titleMaxLines = 2,this.subtitleMaxLines = 2,this.titleColor,+ this.subtitleColor,+ this.titleBold = false,this.iconColor,});@@ -59,6 +61,8 @@ class MenuComponent extends StatefulWidget {final int titleMaxLines;final int subtitleMaxLines;final Color? titleColor;+ final Color? subtitleColor;+ final bool titleBold;final Color? iconColor;@override@@ -157,9 +161,15 @@ class _MenuComponentState extends State<MenuComponent> {widget.title,maxLines: titleMaxLines,overflow: TextOverflow.ellipsis,- style: TextStyles.body.copyWith(- color: widget.titleColor ?? colors.textBase,- ),+ style:+ (widget.titleBold+ ? TextStyles.bodyBold+ : TextStyles.body)+ .copyWith(+ color:+ widget.titleColor ??+ colors.textBase,+ ),),if (widget.subtitle != null) ...[const SizedBox(height: Spacing.xs),@@ -168,7 +178,9 @@ class _MenuComponentState extends State<MenuComponent> {maxLines: subtitleMaxLines,overflow: TextOverflow.ellipsis,style: TextStyles.mini.copyWith(- color: colors.textLight,+ color:+ widget.subtitleColor ??+ colors.textLight,),),],diff --git a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dartindex 17f50fa56a..7763f4b9c7 100644--- a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart+++ b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart@@ -55,6 +55,8 @@ void main() {),selected: true,titleColor: ColorTokens.light.warning,+ subtitleColor: ColorTokens.light.primary,+ titleBold: true,iconColor: ColorTokens.light.primary,onTap: () async => tapped = true,),@@ -76,6 +78,14 @@ void main() {tester.widget<Text>(find.text('Camera uploads')).style?.color,ColorTokens.light.warning,);+ expect(+ tester.widget<Text>(find.text('Camera uploads')).style?.fontWeight,+ TextStyles.bodyBold.fontWeight,+ );+ expect(+ tester.widget<Text>(find.text('Enabled on Wi-Fi')).style?.color,+ ColorTokens.light.primary,+ );expect(IconTheme.of(tester.element(find.byIcon(Icons.cloud_upload_outlined)),diff --git a/mobile/packages/ui/lib/components/buttons/icon_button_widget.dart b/mobile/packages/ui/lib/components/buttons/icon_button_widget.dartdeleted file mode 100644index d4fc78fcd8..0000000000--- a/mobile/packages/ui/lib/components/buttons/icon_button_widget.dart+++ /dev/null@@ -1,104 +0,0 @@-import 'package:ente_ui/theme/colors.dart';-import 'package:ente_ui/theme/ente_theme.dart';-import 'package:flutter/material.dart';--enum IconButtonType { primary, secondary, rounded }--class IconButtonWidget extends StatefulWidget {- final IconButtonType iconButtonType;- final IconData icon;- final bool disableGestureDetector;- final VoidCallback? onTap;- final Color? defaultColor;- final Color? pressedColor;- final Color? iconColor;- const IconButtonWidget({- super.key,- required this.icon,- required this.iconButtonType,- this.disableGestureDetector = false,- this.onTap,- this.defaultColor,- this.pressedColor,- this.iconColor,- });-- @override- State<IconButtonWidget> createState() => _IconButtonWidgetState();-}--class _IconButtonWidgetState extends State<IconButtonWidget> {- Color? iconStateColor;- @override- void didChangeDependencies() {- setState(() {- iconStateColor = null;- });- super.didChangeDependencies();- }-- @override- Widget build(BuildContext context) {- final bool hasPressedState = widget.onTap != null;- final colorTheme = getEnteColorScheme(context);- iconStateColor ??- (iconStateColor =- widget.defaultColor ??- (widget.iconButtonType == IconButtonType.rounded- ? colorTheme.fillFaint- : null));- return widget.disableGestureDetector- ? _iconButton(colorTheme)- : GestureDetector(- onTapDown: hasPressedState ? _onTapDown : null,- onTapUp: hasPressedState ? _onTapUp : null,- onTapCancel: hasPressedState ? _onTapCancel : null,- onTap: widget.onTap,- child: _iconButton(colorTheme),- );- }-- Widget _iconButton(EnteColorScheme colorTheme) {- return AnimatedContainer(- duration: const Duration(milliseconds: 20),- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(20),- color: iconStateColor,- ),- child: Icon(- widget.icon,- color:- widget.iconColor ??- (widget.iconButtonType == IconButtonType.secondary- ? colorTheme.strokeMuted- : colorTheme.strokeBase),- size: 24,- ),- );- }-- void _onTapDown(TapDownDetails details) {- final colorTheme = getEnteColorScheme(context);- setState(() {- iconStateColor =- widget.pressedColor ??- (widget.iconButtonType == IconButtonType.rounded- ? colorTheme.fillMuted- : colorTheme.fillFaint);- });- }-- void _onTapUp(TapUpDetails details) {- Future.delayed(const Duration(milliseconds: 100), () {- setState(() {- iconStateColor = null;- });- });- }-- void _onTapCancel() {- setState(() {- iconStateColor = null;- });- }-}diff --git a/mobile/packages/ui/lib/components/title_bar_widget.dart b/mobile/packages/ui/lib/components/title_bar_widget.dartdeleted file mode 100644index 0802918058..0000000000--- a/mobile/packages/ui/lib/components/title_bar_widget.dart+++ /dev/null@@ -1,150 +0,0 @@-import 'package:ente_ui/components/buttons/icon_button_widget.dart';-import 'package:ente_ui/theme/ente_theme.dart';-import 'package:flutter/material.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;- const TitleBarWidget({- super.key,- this.leading,- this.title,- this.caption,- this.flexibleSpaceTitle,- this.flexibleSpaceCaption,- this.actionIcons,- this.isTitleH2WithoutLeading = false,- this.isFlexibleSpaceDisabled = false,- this.isOnTopOfScreen = true,- this.backgroundColor,- });-- @override- Widget build(BuildContext context) {- const toolbarHeight = 48.0;- final textTheme = getEnteTextTheme(context);- final colorTheme = getEnteColorScheme(context);- return SliverAppBar(- backgroundColor: backgroundColor,- primary: isOnTopOfScreen ? true : false,- toolbarHeight: toolbarHeight,- leadingWidth: 48,- automaticallyImplyLeading: false,- pinned: true,- expandedHeight: isFlexibleSpaceDisabled ? toolbarHeight : 102,- centerTitle: false,- titleSpacing: 4,- title: 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.mini.copyWith(color: colorTheme.textMuted),- ),- ],- ),- ),- actions: [- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: Row(children: _actionsWithPaddingInBetween()),- ),- ],- leading: isTitleH2WithoutLeading- ? null- : leading ??- IconButtonWidget(- icon: Icons.arrow_back_outlined,- iconButtonType: IconButtonType.primary,- onTap: () {- Navigator.pop(context);- },- ),- flexibleSpace: isFlexibleSpaceDisabled- ? null- : FlexibleSpaceBar(- background: SafeArea(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: <Widget>[- const 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.small.copyWith(- color: colorTheme.textMuted,- ),- overflow: TextOverflow.ellipsis,- maxLines: 1,- ),- ],- ),- ),- ],- ),- ),- ),- );- }-- 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;- }-}diff --git a/mobile/packages/ui/lib/components/toggle_switch_widget.dart b/mobile/packages/ui/lib/components/toggle_switch_widget.dartdeleted file mode 100644index 88a5831e85..0000000000--- a/mobile/packages/ui/lib/components/toggle_switch_widget.dart+++ /dev/null@@ -1,160 +0,0 @@-import "dart:io";--import 'package:ente_base/typedefs.dart';-import 'package:ente_pure_utils/ente_pure_utils.dart';-import 'package:ente_ui/components/loading_widget.dart';-import 'package:ente_ui/models/execution_states.dart';-import "package:ente_ui/theme/colors.dart";-import 'package:ente_ui/theme/ente_theme.dart';-import 'package:flutter/cupertino.dart';-import 'package:flutter/material.dart';--typedef OnChangedCallBack = void Function(bool);--class ToggleSwitchWidget extends StatefulWidget {- final BoolCallBack value;- final FutureVoidCallback onChanged;- const ToggleSwitchWidget({- required this.value,- required this.onChanged,- super.key,- });-- @override- State<ToggleSwitchWidget> createState() => _ToggleSwitchWidgetState();-}--class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {- bool? toggleValue;- ExecutionState executionState = ExecutionState.idle;- final _debouncer = Debouncer(const Duration(milliseconds: 300));-- @override- void initState() {- toggleValue = widget.value.call();- super.initState();- }-- @override- void didUpdateWidget(covariant ToggleSwitchWidget oldWidget) {- super.didUpdateWidget(oldWidget);- final newValue = widget.value.call();- if (toggleValue != newValue) {- setState(() {- toggleValue = newValue;- });- }- }-- @override- Widget build(BuildContext context) {- final enteColorScheme = getEnteColorScheme(context);- final Widget stateIcon = _stateIcon(enteColorScheme);- final isDarwin = Platform.isIOS || Platform.isMacOS;-- return Row(- children: [- Padding(- padding: const EdgeInsets.only(right: 2),- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 175),- switchInCurve: Curves.easeInExpo,- switchOutCurve: Curves.easeOutExpo,- child: stateIcon,- ),- ),- SizedBox(- height: 31,- child: FittedBox(- fit: BoxFit.contain,- child: !isDarwin- ? Switch(- inactiveTrackColor: enteColorScheme.fillMuted,- activeTrackColor: enteColorScheme.primary500,- activeThumbColor: Colors.white,- inactiveThumbColor: enteColorScheme.primary500,- trackOutlineColor: WidgetStateColor.resolveWith(- (states) => enteColorScheme.primary500,- ),- materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,- value: toggleValue ?? false,- onChanged: _handleToggleChange,- )- : CupertinoSwitch(- activeTrackColor: enteColorScheme.primary500,- inactiveTrackColor: enteColorScheme.fillMuted,- thumbColor: Colors.white,- value: toggleValue ?? false,- onChanged: _handleToggleChange,- ),- ),- ),- ],- );- }-- Future<void> _handleToggleChange(bool negationOfToggleValue) async {- setState(() {- toggleValue = negationOfToggleValue;- //start showing inProgress statu icons if toggle takes more than debounce time- _debouncer.run(- () => Future(() {- setState(() {- executionState = ExecutionState.inProgress;- });- }),- );- });- final Stopwatch stopwatch = Stopwatch()..start();- await widget.onChanged.call().onError(- (error, stackTrace) => _debouncer.cancelDebounce(),- );- //for toggle feedback on short unsuccessful onChanged- await _feedbackOnUnsuccessfulToggle(stopwatch);- //debouncer gets canceled if onChanged takes less than debounce time- _debouncer.cancelDebounce();-- final newValue = widget.value.call();- setState(() {- if (toggleValue == newValue) {- if (executionState == ExecutionState.inProgress) {- executionState = ExecutionState.successful;- Future.delayed(const Duration(seconds: 2), () {- setState(() {- executionState = ExecutionState.idle;- });- });- }- } else {- toggleValue = !toggleValue!;- executionState = ExecutionState.idle;- }- });- }-- Widget _stateIcon(EnteColorScheme enteColorScheme) {- if (executionState == ExecutionState.idle) {- return const SizedBox(width: 24);- } else if (executionState == ExecutionState.inProgress) {- return EnteLoadingWidget(color: enteColorScheme.strokeMuted);- } else if (executionState == ExecutionState.successful) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 1),- child: Icon(- Icons.check_outlined,- size: 22,- color: enteColorScheme.primary500,- ),- );- } else {- return const SizedBox(width: 24);- }- }-- Future<void> _feedbackOnUnsuccessfulToggle(Stopwatch stopwatch) async {- final timeElapsed = stopwatch.elapsedMilliseconds;- if (timeElapsed < 200) {- await Future.delayed(Duration(milliseconds: 200 - timeElapsed));- }- }-}