Skip to content

Commit

Permalink
MOB-2170 - Fixed issue when buy domain was available if FF is disabled (
Browse files Browse the repository at this point in the history
#649)

* MOB-2170 - Fixed issue when buy domain was available if FF is disabled

* Update launch darkly SDK
  • Loading branch information
Oleg-Pecheneg authored Aug 21, 2024
1 parent 380fe8c commit 4fead01
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand All @@ -94,6 +102,6 @@ private extension SelectCryptoAssetToSendEmptyView {
}

#Preview {
SelectCryptoAssetToSendEmptyView(assetType: .tokens,
SelectCryptoAssetToSendEmptyView(assetType: .domains,
actionCallback: { })
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -298,4 +299,5 @@ private extension SelectCryptoAssetToSendView {
#Preview {
SelectCryptoAssetToSendView(receiver: MockEntitiesFabric.SendCrypto.mockReceiver())
.environmentObject(MockEntitiesFabric.SendCrypto.mockViewModel())
.environmentObject(MockEntitiesFabric.Home.createHomeTabRouter())
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,24 @@ 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] = []
var isSubdomainsVisible: Bool = false
var domainsTLDsExpandedList: Set<String> = []
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct HomeWalletView: View, ViewAnalyticsLogger {

@Environment(\.udFeatureFlagsService) var udFeatureFlagsService
@Environment(\.analyticsViewName) var analyticsName
@Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters

Expand Down Expand Up @@ -183,6 +184,16 @@ private extension HomeWalletView {
}
}

var additionalDomainsSectionAction: HomeWalletSortingSelectorView<DomainsSortingOptions>.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 {
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -135,6 +136,10 @@ private extension HomeWalletHeaderRowView {
.buttonStyle(.plain)
}

var isBuyDomainsEnabled: Bool {
udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled)
}

@MainActor
@ViewBuilder
func getAvatarViewToGetDomain() -> some View {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct HomeWalletsDomainsSectionView: View, ViewAnalyticsLogger {

@Environment(\.udFeatureFlagsService) var udFeatureFlagsService
@Environment(\.analyticsViewName) var analyticsName
@Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %@";
Expand Down

0 comments on commit 4fead01

Please sign in to comment.