From 8acfb2855e48a0f9714bf28e56877a58fc577a06 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 21 Aug 2024 10:10:43 +0300 Subject: [PATCH 1/2] MOB-2170 - Fixed issue when buy domain was available if FF is disabled --- .../PreviewUDFeatureFlagsService.swift | 7 +++- .../Extensions/Extension-String+Preview.swift | 2 ++ .../Modules/Home/Explore/HomeExplore.swift | 17 +++++++++- .../Subviews/HomeExploreEmptyStateView.swift | 8 +++-- .../SelectCryptoAssetToSendEmptyView.swift | 18 ++++++++--- .../SelectCryptoAssetToSendView.swift | 4 ++- .../HomeWalletView+Entities.swift | 7 ++-- .../HomeWalletView/HomeWalletView.swift | 16 +++++++--- .../Subviews/HomeWalletHeaderRowView.swift | 26 ++++++++++----- .../HomeWalletsDomainsSectionView.swift | 32 ++++++++++++++++++- .../Localization/en.lproj/Localizable.strings | 2 ++ 11 files changed, 113 insertions(+), 26 deletions(-) diff --git a/unstoppable-ios-app/domains-manager-ios-preview/AppContext/PreviewUDFeatureFlagsService.swift b/unstoppable-ios-app/domains-manager-ios-preview/AppContext/PreviewUDFeatureFlagsService.swift index 238e41507..b70509d3c 100644 --- a/unstoppable-ios-app/domains-manager-ios-preview/AppContext/PreviewUDFeatureFlagsService.swift +++ b/unstoppable-ios-app/domains-manager-ios-preview/AppContext/PreviewUDFeatureFlagsService.swift @@ -16,7 +16,12 @@ final class UDFeatureFlagsService: UDFeatureFlagsServiceProtocol { } func valueFor(flag: UDFeatureFlag) -> Bool { - true + switch flag { + case .isBuyDomainEnabled, .isBuyCryptoEnabled: + return true + default: + return true + } } func addListener(_ listener: UDFeatureFlagsListener) { diff --git a/unstoppable-ios-app/domains-manager-ios/Extensions/Extension-String+Preview.swift b/unstoppable-ios-app/domains-manager-ios/Extensions/Extension-String+Preview.swift index fc3e990c3..fdab20e67 100644 --- a/unstoppable-ios-app/domains-manager-ios/Extensions/Extension-String+Preview.swift +++ b/unstoppable-ios-app/domains-manager-ios/Extensions/Extension-String+Preview.swift @@ -1117,6 +1117,8 @@ extension String { static let homeWalletTokensComeSubtitle = "HOME_WALLET_TOKENS_COME_SUBTITLE" static let homeWalletCollectiblesEmptyTitle = "HOME_WALLET_COLLECTIBLES_EMPTY_TITLE" static let homeWalletCollectiblesEmptySubtitle = "HOME_WALLET_COLLECTIBLES_EMPTY_SUBTITLE" + static let homeWalletDomainsEmptyTitle = "HOME_WALLET_DOMAINS_EMPTY_TITLE" + static let homeWalletDomainsEmptySubtitle = "HOME_WALLET_DOMAINS_EMPTY_SUBTITLE" static let nftDetailsAboutCollectionHeader = "NFT_DETAILS_ABOUT_COLLECTION_HEADER" static let buyNewDomain = "BUY_NEW_DOMAIN" static let selectPrimaryDomainTitle = "SELECT_PRIMARY_DOMAIN_TITLE" diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/HomeExplore.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/HomeExplore.swift index 1c9f3ccd5..f63adc19b 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/HomeExplore.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/HomeExplore.swift @@ -43,7 +43,11 @@ extension HomeExplore { var title: String { switch self { case .noProfile: - String.Constants.exploreEmptyNoProfileTitle.localized() + if isActionAvailable { + String.Constants.exploreEmptyNoProfileTitle.localized() + } else { + String.Constants.homeWalletDomainsEmptyTitle.localized() + } case .noFollowers: String.Constants.exploreEmptyNoFollowersTitle.localized() case .noFollowing: @@ -62,6 +66,17 @@ extension HomeExplore { } } + var isActionAvailable: Bool { + switch self { + case .noProfile: + appContext.udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) + case .noFollowers: + true + case .noFollowing: + true + } + } + var actionTitle: String { switch self { case .noProfile: diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/Subviews/HomeExploreEmptyStateView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/Subviews/HomeExploreEmptyStateView.swift index eeadfeb4b..e93934648 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/Subviews/HomeExploreEmptyStateView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Explore/Subviews/HomeExploreEmptyStateView.swift @@ -35,9 +35,11 @@ struct HomeExploreEmptyStateView: View, ViewAnalyticsLogger { private extension HomeExploreEmptyStateView { @ViewBuilder func actionButtonView() -> some View { - UDButtonView(text: state.actionTitle, style: state.actionStyle) { - logButtonPressedAnalyticEvents(button: state.analyticButton) - viewModel.didSelectActionInEmptyState(state) + if state.isActionAvailable { + UDButtonView(text: state.actionTitle, style: state.actionStyle) { + logButtonPressedAnalyticEvents(button: state.analyticButton) + viewModel.didSelectActionInEmptyState(state) + } } } } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendEmptyView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendEmptyView.swift index 98d3194ef..aefce01d8 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendEmptyView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendEmptyView.swift @@ -70,16 +70,24 @@ private extension SelectCryptoAssetToSendEmptyView { } } + var isActionButtonVisible: Bool { + switch assetType { + case .tokens: + return udFeatureFlagsService.valueFor(flag: .isBuyCryptoEnabled) + case .domains: + return udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) + } + } + @ViewBuilder func actionButton() -> some View { - if case .tokens = assetType, - !udFeatureFlagsService.valueFor(flag: .isBuyCryptoEnabled) { - EmptyView() - } else { + if isActionButtonVisible { UDButtonView(text: actionButtonTitle, icon: .plusIconNav, style: .medium(.raisedTertiary), callback: actionCallback) + } else { + EmptyView() } } @@ -94,6 +102,6 @@ private extension SelectCryptoAssetToSendEmptyView { } #Preview { - SelectCryptoAssetToSendEmptyView(assetType: .tokens, + SelectCryptoAssetToSendEmptyView(assetType: .domains, actionCallback: { }) } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendView.swift index f12222fe6..170505990 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/SendCryptoAsset/SelectAssetToSend/SelectCryptoAssetToSendView.swift @@ -108,7 +108,8 @@ private extension SelectCryptoAssetToSendView { } func setDomainsData() { - domainsData.setDomains(filteredDomains) + domainsData.setDomains(filteredDomains, + walletAddress: viewModel.sourceWallet.address) domainsData.sortDomains(.alphabeticalAZ) domainsData.isSearching = !searchDomainsKey.isEmpty } @@ -298,4 +299,5 @@ private extension SelectCryptoAssetToSendView { #Preview { SelectCryptoAssetToSendView(receiver: MockEntitiesFabric.SendCrypto.mockReceiver()) .environmentObject(MockEntitiesFabric.SendCrypto.mockViewModel()) + .environmentObject(MockEntitiesFabric.Home.createHomeTabRouter()) } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView+Entities.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView+Entities.swift index f887cefb3..d1d2e11db 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView+Entities.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView+Entities.swift @@ -303,6 +303,7 @@ extension HomeWalletView { extension HomeWalletView { struct DomainsSectionData { + private(set) var walletAddress: String = "" private(set) var domainsGroups: [DomainsTLDGroup] = [] private(set) var subdomains: [DomainDisplayInfo] = [] private(set) var mintingDomains: [DomainDisplayInfo] = [] @@ -310,14 +311,16 @@ extension HomeWalletView { var domainsTLDsExpandedList: Set = [] var isSearching: Bool = false - mutating func setDomains(_ domains: [DomainDisplayInfo]) { + mutating func setDomains(_ domains: [DomainDisplayInfo], + walletAddress: String) { domainsGroups = DomainsTLDGroup.createFrom(domains: domains.filter({ !$0.isSubdomain })) subdomains = domains.filter({ $0.isSubdomain }) mintingDomains = domains.filter { $0.isMinting } } mutating func setDomainsFrom(wallet: WalletEntity) { - setDomains(wallet.domains) + setDomains(wallet.domains, + walletAddress: wallet.address) } mutating func sortDomains(_ sortOption: HomeWalletView.DomainsSortingOptions) { diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView.swift index 46764b3d5..b58bb9854 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/HomeWalletView.swift @@ -9,6 +9,7 @@ import SwiftUI struct HomeWalletView: View, ViewAnalyticsLogger { + @Environment(\.udFeatureFlagsService) var udFeatureFlagsService @Environment(\.analyticsViewName) var analyticsName @Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters @@ -183,6 +184,16 @@ private extension HomeWalletView { } } + var additionalDomainsSectionAction: HomeWalletSortingSelectorView.ActionDescription? { + if udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) { + return .init(title: String.Constants.buy.localized(), + icon: .plusIconNav, + analyticName: .buyDomainsSectionHeader, + callback: viewModel.buyDomainPressed) + } + return nil + } + @ViewBuilder func sortingOptionsForSelectedType() -> some View { switch viewModel.selectedContentType { @@ -195,10 +206,7 @@ private extension HomeWalletView { case .domains: HomeWalletSortingSelectorView(sortingOptions: DomainsSortingOptions.allCases, selectedOption: $viewModel.selectedDomainsSortingOption, - additionalAction: .init(title: String.Constants.buy.localized(), - icon: .plusIconNav, - analyticName: .buyDomainsSectionHeader, - callback: viewModel.buyDomainPressed)) + additionalAction: additionalDomainsSectionAction) } } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletHeaderRowView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletHeaderRowView.swift index 282a942a3..d0e3411bb 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletHeaderRowView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletHeaderRowView.swift @@ -10,6 +10,7 @@ import SwiftUI struct HomeWalletHeaderRowView: View, ViewAnalyticsLogger { @Environment(\.imageLoadingService) private var imageLoadingService + @Environment(\.udFeatureFlagsService) private var udFeatureFlagsService @Environment(\.analyticsViewName) var analyticsName @Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters @@ -135,6 +136,10 @@ private extension HomeWalletHeaderRowView { .buttonStyle(.plain) } + var isBuyDomainsEnabled: Bool { + udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) + } + @MainActor @ViewBuilder func getAvatarViewToGetDomain() -> some View { @@ -147,19 +152,24 @@ private extension HomeWalletHeaderRowView { Circle() .foregroundStyle(Color.backgroundWarning) .background(.ultraThinMaterial) - VStack(spacing: 4) { - Image.plusIconNav + if isBuyDomainsEnabled { + VStack(spacing: 4) { + Image.plusIconNav + .resizable() + .squareFrame(20) + Text(String.Constants.domain.localized()) + .font(.currentFont(size: 13, weight: .medium)) + .frame(height: 20) + } + .foregroundStyle(Color.foregroundWarning) + } else { + Image.domainSharePlaceholder .resizable() - .squareFrame(20) - Text(String.Constants.domain.localized()) - .font(.currentFont(size: 13, weight: .medium)) - .frame(height: 20) } - .foregroundStyle(Color.foregroundWarning) } - } .buttonStyle(.plain) + .allowsHitTesting(isBuyDomainsEnabled) } func getProfileSelectionTitle() -> String { diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletsDomainsSectionView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletsDomainsSectionView.swift index 8f6f8a10d..a8e89d004 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletsDomainsSectionView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Home/Wallet/HomeWalletView/Subviews/HomeWalletsDomainsSectionView.swift @@ -9,6 +9,7 @@ import SwiftUI struct HomeWalletsDomainsSectionView: View, ViewAnalyticsLogger { + @Environment(\.udFeatureFlagsService) var udFeatureFlagsService @Environment(\.analyticsViewName) var analyticsName @Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters @@ -98,7 +99,11 @@ private extension HomeWalletsDomainsSectionView { func domainsGroupsView() -> some View { if domainsGroups.isEmpty, !domainsData.isSearching { - buyDomainView() + if udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) { + buyDomainView() + } else { + emptyView() + } } else { ForEach(domainsGroups) { domainsGroup in Section { @@ -152,6 +157,31 @@ private extension HomeWalletsDomainsSectionView { .buttonStyle(.plain) } } + + @ViewBuilder + func emptyView() -> some View { + VStack(spacing: 16) { + Image.layoutGridEmptyIcon + .resizable() + .renderingMode(.template) + .squareFrame(32) + VStack(spacing: 8) { + Text(String.Constants.homeWalletDomainsEmptyTitle.localized()) + .font(.currentFont(size: 20, weight: .bold)) + Text(String.Constants.homeWalletDomainsEmptySubtitle.localized()) + .font(.currentFont(size: 14)) + } + .multilineTextAlignment(.center) + + UDButtonView(text: String.Constants.copyAddress.localized(), icon: .squareBehindSquareIcon, style: .small(.raisedTertiary)) { + CopyWalletAddressPullUpHandler.copyToClipboard(address: domainsData.walletAddress, + ticker: BlockchainType.Ethereum.shortCode) + } + } + .foregroundStyle(Color.foregroundSecondary) + .frame(maxWidth: .infinity) + .padding(.top, 36) + } } #Preview { diff --git a/unstoppable-ios-app/domains-manager-ios/SupportingFiles/Localization/en.lproj/Localizable.strings b/unstoppable-ios-app/domains-manager-ios/SupportingFiles/Localization/en.lproj/Localizable.strings index 125ee63ab..d1d4e0402 100644 --- a/unstoppable-ios-app/domains-manager-ios/SupportingFiles/Localization/en.lproj/Localizable.strings +++ b/unstoppable-ios-app/domains-manager-ios/SupportingFiles/Localization/en.lproj/Localizable.strings @@ -1011,6 +1011,8 @@ "HOME_WALLET_TOKENS_COME_SUBTITLE" = "We currently support Ethereum, Solana, Polygon and Base tokens"; "HOME_WALLET_COLLECTIBLES_EMPTY_TITLE" = "No collectibles in your wallet"; "HOME_WALLET_COLLECTIBLES_EMPTY_SUBTITLE" = "To receive collectibles and see them here, just copy your wallet address below."; +"HOME_WALLET_DOMAINS_EMPTY_TITLE" = "No domains in your wallet"; +"HOME_WALLET_DOMAINS_EMPTY_SUBTITLE" = "To receive domains and see them here, just copy your wallet address below."; "NFT_DETAILS_ABOUT_COLLECTION_HEADER" = "About %@"; "BUY_NEW_DOMAIN" = "Buy new domain"; "SELECT_PRIMARY_DOMAIN_TITLE" = "Select primary domain for %@"; From 1cdccc937fbf39d9026ed2b52e448a695bd89420 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 21 Aug 2024 10:20:41 +0300 Subject: [PATCH 2/2] Update launch darkly SDK --- .../project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj index 61d03de81..90028704b 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj @@ -12400,7 +12400,7 @@ repositoryURL = "https://github.com/launchdarkly/ios-client-sdk.git"; requirement = { kind = exactVersion; - version = 9.5.0; + version = 9.10.0; }; }; C69698962ACBCC9B0000738C /* XCRemoteSwiftPackageReference "Starscream" */ = { diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b493fc887..aefc978c9 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -64,6 +64,15 @@ "version" : "1.8.2" } }, + { + "identity" : "datacompression", + "kind" : "remoteSourceControl", + "location" : "https://github.com/mw99/DataCompression", + "state" : { + "revision" : "5ab15951321b08b74511601cbd0497667649d70b", + "version" : "3.8.0" + } + }, { "identity" : "generic-json-swift", "kind" : "remoteSourceControl", @@ -87,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/launchdarkly/ios-client-sdk.git", "state" : { - "revision" : "cf82f0687ee505b291f8e8f5fe978122892b74ab", - "version" : "9.5.0" + "revision" : "319735e7c4eb00f02b07402429bf19e02594b60e", + "version" : "9.10.0" } }, { @@ -212,8 +221,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/LaunchDarkly/swift-eventsource.git", "state" : { - "revision" : "3d45eacab476f9bb2c58662cfb2d35088140b25b", - "version" : "3.1.1" + "revision" : "57051701c58a93603ffa2051f8e9cf0c8cff7814", + "version" : "3.3.0" } }, {