From 47697c3d59eeb2bbb87d2926e7c586487a8bd7d3 Mon Sep 17 00:00:00 2001 From: sherlockvn Date: Tue, 17 Jan 2023 23:38:36 +0700 Subject: [PATCH] TF-1194 edit default identity: update presentation layer --- .../identity_creator_controller.dart | 18 +++++++++++++----- .../presentation/identity_creator_view.dart | 6 ++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/features/identity_creator/presentation/identity_creator_controller.dart b/lib/features/identity_creator/presentation/identity_creator_controller.dart index 5c3c3234c..11964ea78 100644 --- a/lib/features/identity_creator/presentation/identity_creator_controller.dart +++ b/lib/features/identity_creator/presentation/identity_creator_controller.dart @@ -252,12 +252,20 @@ class IdentityCreatorController extends BaseController { .getSmallestOrderedIdentity(identities) ?.map((identity) => identity.id!); - // if all identities have same sortOrder, it means it don't have default identity - if (listDefaultIdentityIds?.length == identities?.length) { - isDefaultIdentity.value = false; + if (haveDefaultIdentities(identities, listDefaultIdentityIds) && + listDefaultIdentityIds?.contains(identity?.id) == true + ) { + isDefaultIdentity.value = true; } else { - isDefaultIdentity.value = listDefaultIdentityIds?.contains(identity?.id) ?? false; - } + isDefaultIdentity.value = false; + } + } + + bool haveDefaultIdentities( + Iterable? allIdentities, + Iterable? defaultIdentityIds + ) { + return defaultIdentityIds?.length != allIdentities?.length; } void selectSignatureType(BuildContext context, SignatureType newSignatureType) async { diff --git a/lib/features/identity_creator/presentation/identity_creator_view.dart b/lib/features/identity_creator/presentation/identity_creator_view.dart index a0cc4e369..217c3678d 100644 --- a/lib/features/identity_creator/presentation/identity_creator_view.dart +++ b/lib/features/identity_creator/presentation/identity_creator_view.dart @@ -205,10 +205,12 @@ class IdentityCreatorView extends GetWidget { Column(children: [ Padding( padding: const EdgeInsets.only(top: 14), - child: Text(controller.actionType.value == IdentityActionType.create + child: Obx(() { + return Text(controller.actionType.value == IdentityActionType.create ? AppLocalizations.of(context).createNewIdentity.inCaps : AppLocalizations.of(context).edit_identity.inCaps, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: Colors.black))), + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: Colors.black)); + })), const SizedBox(height: 8), Expanded( child: KeyboardRichText(