π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] UI to select option for custom icons
Aman Rajee7c7a447d3c
diff --git a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart b/auth/lib/onboarding/view/setup_enter_secret_key_page.dartindex 0491f48bdc..22c2621d0c 100644--- a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart+++ b/auth/lib/onboarding/view/setup_enter_secret_key_page.dart@@ -13,7 +13,10 @@ import 'package:ente_auth/onboarding/view/common/tag_chip.dart';import 'package:ente_auth/store/code_display_store.dart';import 'package:ente_auth/theme/ente_theme.dart';import 'package:ente_auth/ui/components/buttons/button_widget.dart';+import 'package:ente_auth/ui/components/custom_icon_widget.dart';import 'package:ente_auth/ui/components/models/button_result.dart';+import 'package:ente_auth/ui/custom_icon_page.dart';+import 'package:ente_auth/ui/utils/icon_utils.dart';import 'package:ente_auth/utils/dialog_util.dart';import 'package:ente_auth/utils/toast_util.dart';import 'package:ente_auth/utils/totp_util.dart';@@ -42,6 +45,9 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {late List<String> selectedTags = [...?widget.code?.display.tags];List<String> allTags = [];StreamSubscription<CodesUpdatedEvent>? _streamSubscription;+ bool isCustomIcon = false;+ String _customIcon = "";+ late IconType _iconType;@overridevoid initState() {@@ -81,6 +87,10 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {_limitTextLength(_accountController, _otherTextLimit);_limitTextLength(_secretController, _otherTextLimit);}++ isCustomIcon = widget.code?.display.isCustomIcon ?? false;+ _customIcon = widget.code?.display.customIconData ?? "ente";+ _iconType = widget.code?.display.iconType ?? IconType.simpleIcon;super.initState();}@@ -305,6 +315,44 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {child: Text(l10n.saveAction),),),+ const SizedBox(height: 32),+ if (widget.code != null)+ Row(+ children: [+ CustomIconWidget(+ isCustomIcon: isCustomIcon,+ iconData: _customIcon,+ onTap: () {+ setState(() {+ isCustomIcon = true;+ });+ },+ ),+ const SizedBox(width: 24),+ CustomIconWidget(+ isCustomIcon: !isCustomIcon,+ iconData: widget.code!.issuer,+ onTap: () {+ setState(() {+ isCustomIcon = false;+ });+ },+ ),+ ],+ ),+ const SizedBox(height: 24),+ if (widget.code != null)+ GestureDetector(+ onTap: () async {+ await navigateToCustomIconPage();+ },+ child: Text(+ "Change Icon",+ style: isCustomIcon+ ? getEnteTextTheme(context).small+ : getEnteTextTheme(context).smallFaint,+ ),+ ),],),),@@ -324,6 +372,13 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {widget.code?.display.copyWith(tags: selectedTags) ??CodeDisplay(tags: selectedTags);display.note = notes;+ if (isCustomIcon) {+ display.isCustomIcon = true;+ display.customIconData = _customIcon.toLowerCase();+ display.iconType = _iconType;+ } else {+ display.isCustomIcon = false;+ }if (widget.code != null && widget.code!.secret != secret) {ButtonResult? result = await showChoiceActionSheet(context,@@ -373,4 +428,30 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {message ?? context.l10n.pleaseVerifyDetails,);}++ Future<void> navigateToCustomIconPage() async {+ if (isCustomIcon) {+ final allIcons = IconUtils.instance.getAllIcons();+ String currentIcon;+ if (widget.code!.display.isCustomIcon) {+ currentIcon = widget.code!.display.customIconData;+ } else {+ currentIcon = widget.code!.issuer;+ }+ final AllIconData newCustomIcon = await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (context) {+ return CustomIconPage(+ currentIcon: currentIcon,+ allIcons: allIcons,+ );+ },+ ),+ );+ setState(() {+ _customIcon = newCustomIcon.title;+ _iconType = newCustomIcon.type;+ });+ }+ }}diff --git a/auth/lib/ui/components/custom_icon_widget.dart b/auth/lib/ui/components/custom_icon_widget.dartnew file mode 100644index 0000000000..9fd8fbc0a2--- /dev/null+++ b/auth/lib/ui/components/custom_icon_widget.dart@@ -0,0 +1,40 @@+import 'package:ente_auth/theme/ente_theme.dart';+import 'package:ente_auth/ui/utils/icon_utils.dart';+import 'package:ente_auth/utils/totp_util.dart';+import 'package:flutter/material.dart';++class CustomIconWidget extends StatelessWidget {+ final bool isCustomIcon;+ final String iconData;+ final void Function() onTap;+ CustomIconWidget({+ super.key,+ required this.isCustomIcon,+ required this.iconData,+ required this.onTap,+ });++ @override+ Widget build(BuildContext context) {+ return GestureDetector(+ onTap: onTap,+ child: Container(+ decoration: BoxDecoration(+ border: Border.all(+ width: 1.5,+ color: isCustomIcon+ ? getEnteColorScheme(context).tagChipSelectedColor+ : getEnteColorScheme(context).tagChipUnselectedColor,+ ),+ borderRadius: const BorderRadius.all(Radius.circular(12.0)),+ ),+ padding: const EdgeInsets.all(8),+ child: IconUtils.instance.getIcon(+ context,+ safeDecode(iconData).trim(),+ width: 50,+ ),+ ),+ );+ }+}