Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3439] Card Carousel #1187

Merged
merged 36 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
81bf003
wip
kugel3 Jun 17, 2024
c1ddf49
wip
kugel3 Jun 19, 2024
39a880b
wip
kugel3 Jun 20, 2024
ca0373a
wip
kugel3 Jun 25, 2024
5ce4ed4
wip
kugel3 Jun 26, 2024
da8f3d7
wip
kugel3 Jun 26, 2024
af2b0f2
wip
kugel3 Jun 27, 2024
6cb0b7e
works
kugel3 Jun 27, 2024
dc784df
Simpler
kugel3 Jun 27, 2024
4939e65
refactor
kugel3 Jun 27, 2024
0072003
TEMP add development asset
kugel3 Jun 27, 2024
dc98d28
Better card
kugel3 Jun 27, 2024
489c66b
Refactor
kugel3 Jun 27, 2024
b62daca
CardCarouselClient
kugel3 Jun 27, 2024
1060d2c
Flexible size
kugel3 Jun 28, 2024
5fac7ed
wip
kugel3 Jun 30, 2024
2a6e024
wip
kugel3 Jun 30, 2024
24b0205
refactored
kugel3 Jun 30, 2024
84dc42e
Small refactor
kugel3 Jun 30, 2024
08ddac9
Merge branch 'main' into ABW-3439_Card-carousel
matiasbzurovski Jul 5, 2024
1ac02ee
Home Cards logic and UI updates (#1199)
matiasbzurovski Jul 5, 2024
0b0479e
Updates from Demo
matiasbzurovski Jul 5, 2024
a79a0f5
first round of feedback
matiasbzurovski Jul 5, 2024
179daae
Merge branch 'main' into ABW-3439_Card-carousel
matiasbzurovski Jul 8, 2024
3f4f83d
Extend CloseButton to support a kind
matiasbzurovski Jul 8, 2024
800a610
Refactor AppEventsClient
matiasbzurovski Jul 8, 2024
b0f8ac4
Add bootstrap client
matiasbzurovski Jul 8, 2024
345d591
Add bootstrap client to project
matiasbzurovski Jul 9, 2024
4b927fc
Use new Sargon methods
matiasbzurovski Jul 9, 2024
7c05410
Send wallet created event only when it corresponds
matiasbzurovski Jul 9, 2024
0bf524f
Bump Sargon and manually set user defaults
matiasbzurovski Jul 9, 2024
50da244
Remove Home radix banner
matiasbzurovski Jul 10, 2024
6f9f6f0
Remove Connector banner from Settings
matiasbzurovski Jul 10, 2024
1be9f16
Merge branch 'main' into ABW-3439_Card-carousel
matiasbzurovski Jul 10, 2024
3d3c477
Move to event to OnboardingCoordinator
matiasbzurovski Jul 10, 2024
0cab947
Split delegate calls in 2
matiasbzurovski Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions RadixWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,9 @@
5B1C4FD52BBB0B0C00B9436F /* AppsFlyerLib-Strict in Frameworks */ = {isa = PBXBuildFile; productRef = 5B1C4FD42BBB0B0C00B9436F /* AppsFlyerLib-Strict */; };
5B1C4FD82BBB0C1E00B9436F /* AppsFlyerClient+Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C4FD72BBB0C1E00B9436F /* AppsFlyerClient+Interface.swift */; };
5B1C4FDA2BBB0DCF00B9436F /* AppsFlyerClient+Live.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C4FD92BBB0DCF00B9436F /* AppsFlyerClient+Live.swift */; };
5B272DD72C36E89600B74F1F /* AppEventsClient+Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B272DD62C36E89600B74F1F /* AppEventsClient+Interface.swift */; };
5B272DD92C36E93100B74F1F /* AppEventsClient+Live.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B272DD82C36E93100B74F1F /* AppEventsClient+Live.swift */; };
5B272DDB2C36E9D300B74F1F /* AppEventsClient+Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B272DDA2C36E9D300B74F1F /* AppEventsClient+Test.swift */; };
5B2A45022BD6680400AEC8AD /* ContactSupportClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B2A45012BD6680400AEC8AD /* ContactSupportClient.swift */; };
5B2A45042BD6689100AEC8AD /* ContactSupportClient+Live.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B2A45032BD6689100AEC8AD /* ContactSupportClient+Live.swift */; };
5B43B08B2BDAAD4B00AA1E92 /* AddressDetails+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B43B0892BDAAD4B00AA1E92 /* AddressDetails+View.swift */; };
Expand Down Expand Up @@ -1079,6 +1082,12 @@
A4CFB55D2BA8CA3200778BDD /* TransactionHistory+TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB55C2BA8CA3200778BDD /* TransactionHistory+TableView.swift */; };
A4CFB55F2BAA821E00778BDD /* HScrollBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB55E2BAA821E00778BDD /* HScrollBar.swift */; };
A4CFB5612BAA826E00778BDD /* Measure+Position.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB5602BAA826E00778BDD /* Measure+Position.swift */; };
A4DBBEB32C20305000D0A59E /* CardCarousel+Reducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DBBEB22C20305000D0A59E /* CardCarousel+Reducer.swift */; };
A4DBBEB52C20305700D0A59E /* CardCarousel+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DBBEB42C20305700D0A59E /* CardCarousel+View.swift */; };
A4DCCC4B2C2DA08000438A7B /* GeometryExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DCCC4A2C2DA08000438A7B /* GeometryExtensions.swift */; };
A4DCCC502C2DA32C00438A7B /* HomeCardsClient+Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DCCC4D2C2DA26100438A7B /* HomeCardsClient+Interface.swift */; };
A4DCCC512C2DA33100438A7B /* HomeCardsClient+Live.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DCCC4E2C2DA26100438A7B /* HomeCardsClient+Live.swift */; };
A4DCCC522C2DA33300438A7B /* HomeCardsClient+Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4DCCC4F2C2DA26200438A7B /* HomeCardsClient+Test.swift */; };
A4EB37C82B6272F3003FE31D /* TrackedValidatorInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4EB37C72B6272F3003FE31D /* TrackedValidatorInteraction.swift */; };
A4EBB5D62BD0777C00D05FDE /* ConfigurationBackup+Reducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4EBB5D52BD0777C00D05FDE /* ConfigurationBackup+Reducer.swift */; };
A4EBB5D82BD0777F00D05FDE /* ConfigurationBackup+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4EBB5D72BD0777F00D05FDE /* ConfigurationBackup+View.swift */; };
Expand Down Expand Up @@ -2012,6 +2021,9 @@
48FFFAF12ADC23AC00B2B213 /* Exports.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Exports.swift; sourceTree = "<group>"; };
5B1C4FD72BBB0C1E00B9436F /* AppsFlyerClient+Interface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppsFlyerClient+Interface.swift"; sourceTree = "<group>"; };
5B1C4FD92BBB0DCF00B9436F /* AppsFlyerClient+Live.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppsFlyerClient+Live.swift"; sourceTree = "<group>"; };
5B272DD62C36E89600B74F1F /* AppEventsClient+Interface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppEventsClient+Interface.swift"; sourceTree = "<group>"; };
5B272DD82C36E93100B74F1F /* AppEventsClient+Live.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppEventsClient+Live.swift"; sourceTree = "<group>"; };
5B272DDA2C36E9D300B74F1F /* AppEventsClient+Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppEventsClient+Test.swift"; sourceTree = "<group>"; };
5B2A45012BD6680400AEC8AD /* ContactSupportClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactSupportClient.swift; sourceTree = "<group>"; };
5B2A45032BD6689100AEC8AD /* ContactSupportClient+Live.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContactSupportClient+Live.swift"; sourceTree = "<group>"; };
5B43B0892BDAAD4B00AA1E92 /* AddressDetails+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AddressDetails+View.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2215,6 +2227,12 @@
A4CFB55C2BA8CA3200778BDD /* TransactionHistory+TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TransactionHistory+TableView.swift"; sourceTree = "<group>"; };
A4CFB55E2BAA821E00778BDD /* HScrollBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HScrollBar.swift; sourceTree = "<group>"; };
A4CFB5602BAA826E00778BDD /* Measure+Position.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Measure+Position.swift"; sourceTree = "<group>"; };
A4DBBEB22C20305000D0A59E /* CardCarousel+Reducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardCarousel+Reducer.swift"; sourceTree = "<group>"; };
A4DBBEB42C20305700D0A59E /* CardCarousel+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardCarousel+View.swift"; sourceTree = "<group>"; };
A4DCCC4A2C2DA08000438A7B /* GeometryExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeometryExtensions.swift; sourceTree = "<group>"; };
A4DCCC4D2C2DA26100438A7B /* HomeCardsClient+Interface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeCardsClient+Interface.swift"; sourceTree = "<group>"; };
A4DCCC4E2C2DA26100438A7B /* HomeCardsClient+Live.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeCardsClient+Live.swift"; sourceTree = "<group>"; };
A4DCCC4F2C2DA26200438A7B /* HomeCardsClient+Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeCardsClient+Test.swift"; sourceTree = "<group>"; };
A4EB37C72B6272F3003FE31D /* TrackedValidatorInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackedValidatorInteraction.swift; sourceTree = "<group>"; };
A4EBB5D52BD0777C00D05FDE /* ConfigurationBackup+Reducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConfigurationBackup+Reducer.swift"; sourceTree = "<group>"; };
A4EBB5D72BD0777F00D05FDE /* ConfigurationBackup+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConfigurationBackup+View.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2514,6 +2532,7 @@
48CFBC602ADC10D800E77A5C /* Features */ = {
isa = PBXGroup;
children = (
A4DBBEB12C20302B00D0A59E /* CardCarousel */,
E7AE2D082C05F22700830BAA /* ClaimWallet */,
A43F1E242BC96EF2001DD3FA /* SecurityCenterFeature */,
48D5F3972BD8DE0A000DE964 /* DebugInspectProfile */,
Expand Down Expand Up @@ -4256,6 +4275,8 @@
48CFBF522ADC10D900E77A5C /* Clients */ = {
isa = PBXGroup;
children = (
5B272DD52C36E88700B74F1F /* AppEventsClient */,
A4DCCC4C2C2DA23E00438A7B /* HomeCardsClient */,
8329ACE22BBAB9CD005FD9DC /* DeepLinkHandlerClient */,
E7A5AC942C09F428006CB6EC /* ResetWalletClient */,
A4ECE2782BEEB01800468BF6 /* CloudBackupClient */,
Expand Down Expand Up @@ -5094,6 +5115,7 @@
48CFC11A2ADC10D900E77A5C /* FixedSpacer.swift */,
5BBC43A82BBAC6B0005747B1 /* AppTextEditor.swift */,
5B6499B92BCFDB1E000F2176 /* ShareView.swift */,
A4DCCC4A2C2DA08000438A7B /* GeometryExtensions.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -5568,6 +5590,16 @@
path = AppsFlyerClient;
sourceTree = "<group>";
};
5B272DD52C36E88700B74F1F /* AppEventsClient */ = {
isa = PBXGroup;
children = (
5B272DD62C36E89600B74F1F /* AppEventsClient+Interface.swift */,
5B272DD82C36E93100B74F1F /* AppEventsClient+Live.swift */,
5B272DDA2C36E9D300B74F1F /* AppEventsClient+Test.swift */,
);
path = AppEventsClient;
sourceTree = "<group>";
};
5B2A45002BD667FB00AEC8AD /* ContactSupportClient */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5892,6 +5924,25 @@
path = TransactionReviewDepositSetting;
sourceTree = "<group>";
};
A4DBBEB12C20302B00D0A59E /* CardCarousel */ = {
isa = PBXGroup;
children = (
A4DBBEB22C20305000D0A59E /* CardCarousel+Reducer.swift */,
A4DBBEB42C20305700D0A59E /* CardCarousel+View.swift */,
);
path = CardCarousel;
sourceTree = "<group>";
};
A4DCCC4C2C2DA23E00438A7B /* HomeCardsClient */ = {
isa = PBXGroup;
children = (
A4DCCC4D2C2DA26100438A7B /* HomeCardsClient+Interface.swift */,
A4DCCC4E2C2DA26100438A7B /* HomeCardsClient+Live.swift */,
A4DCCC4F2C2DA26200438A7B /* HomeCardsClient+Test.swift */,
);
path = HomeCardsClient;
sourceTree = "<group>";
};
A4ECE2712BEEAFFC00468BF6 /* SecurityCenterClient */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -6800,6 +6851,7 @@
4813AFEB2BC9AF4A0046BCAD /* RawRepresentable+Extensions.swift in Sources */,
A462B5852B83672300C26D20 /* StreamTransactionsRequestAllOfManifestClassFilter.swift in Sources */,
48CFC29C2ADC10D900E77A5C /* TransactionReview+View.swift in Sources */,
A4DCCC4B2C2DA08000438A7B /* GeometryExtensions.swift in Sources */,
48CFC2A72ADC10D900E77A5C /* AuthorizedDApps+View.swift in Sources */,
83EE5EEF2BE3C16F00B1531D /* AccountAuthorizedDepositorsResourceBadge.swift in Sources */,
4855B19A2BCA557D00DD0A47 /* Stage2MigrateToSargon+Persona.swift in Sources */,
Expand Down Expand Up @@ -6830,7 +6882,9 @@
48D5F3982BD8DE0A000DE964 /* DebugInspectProfile.swift in Sources */,
48CFC2872ADC10D900E77A5C /* MinimumPercentageStepper+View.swift in Sources */,
E76645A42C23138300065D9A /* Throwable.swift in Sources */,
5B272DD72C36E89600B74F1F /* AppEventsClient+Interface.swift in Sources */,
48CFC2A12ADC10D900E77A5C /* PersonaFeature.swift in Sources */,
A4DCCC502C2DA32C00438A7B /* HomeCardsClient+Interface.swift in Sources */,
48CFC4162ADC10DA00E77A5C /* PasteboardClient+Test.swift in Sources */,
48CFC34E2ADC10D900E77A5C /* Login+View.swift in Sources */,
48CFC3122ADC10D900E77A5C /* AccountsToImport.swift in Sources */,
Expand Down Expand Up @@ -6967,6 +7021,7 @@
48CFC57C2ADC10DA00E77A5C /* NonFungibleResourcesCollectionItem.swift in Sources */,
48CFC3F92ADC10D900E77A5C /* SignalingClientFactory.swift in Sources */,
48CFC3192ADC10D900E77A5C /* CreateAccountCoordinator+View.swift in Sources */,
A4DBBEB32C20305000D0A59E /* CardCarousel+Reducer.swift in Sources */,
48CFC4CA2ADC10DA00E77A5C /* OpenISO8601DateFormatter.swift in Sources */,
48CFC2492ADC10D900E77A5C /* ResourcesList+View.swift in Sources */,
4813AFE22BC9A9AD0046BCAD /* Stage1MigrateToSargon+NetworkDefinition.swift in Sources */,
Expand Down Expand Up @@ -7001,6 +7056,7 @@
48CFC2C22ADC10D900E77A5C /* ChooseReceivingAccount+View.swift in Sources */,
48CFC3862ADC10D900E77A5C /* DetailsContainerWithHeaderView.swift in Sources */,
48CFC2862ADC10D900E77A5C /* SubmitTransaction.swift in Sources */,
A4DBBEB52C20305700D0A59E /* CardCarousel+View.swift in Sources */,
48CFC53B2ADC10DA00E77A5C /* ValidatorCollectionItemActiveInEpoch.swift in Sources */,
E6A98FA82AE15324003953E2 /* BuildConfiguration.swift in Sources */,
48CFC2C62ADC10D900E77A5C /* MessageMode+Reducer.swift in Sources */,
Expand Down Expand Up @@ -7047,6 +7103,7 @@
48CFC2932ADC10D900E77A5C /* AdvancedFeesCustomization+View.swift in Sources */,
48CFC4042ADC10D900E77A5C /* KeychainHolder.swift in Sources */,
48CFC4392ADC10DA00E77A5C /* Sorted.swift in Sources */,
5B272DD92C36E93100B74F1F /* AppEventsClient+Live.swift in Sources */,
48CFC5622ADC10DA00E77A5C /* FungibleResourcesCollectionItemGloballyAggregated.swift in Sources */,
48CFC4F62ADC10DA00E77A5C /* StateKeyValueStoreDataResponse.swift in Sources */,
48CFC34B2ADC10D900E77A5C /* OneTimePersonaData.swift in Sources */,
Expand Down Expand Up @@ -7114,6 +7171,7 @@
48CFC5732ADC10DA00E77A5C /* Configuration.swift in Sources */,
48CFC5A42ADC10DA00E77A5C /* PrimaryTextButtonStyle.swift in Sources */,
83EE47862AF0EE3C00155F03 /* ProgrammaticScryptoSborValueMap.swift in Sources */,
A4DCCC522C2DA33300438A7B /* HomeCardsClient+Test.swift in Sources */,
A462B57D2B83656900C26D20 /* MetadataNonFungibleGlobalIdArrayValueAllOfValues.swift in Sources */,
5B80FCC72C298F13008444F5 /* ArbitraryDataField+Models.swift in Sources */,
48CFC2A92ADC10D900E77A5C /* DappDetails+View.swift in Sources */,
Expand Down Expand Up @@ -7259,6 +7317,7 @@
48CFC5562ADC10DA00E77A5C /* GatewayInfoResponseReleaseInfo.swift in Sources */,
48CFC47F2ADC10DA00E77A5C /* ROLAClient+Interface.swift in Sources */,
48CFC46B2ADC10DA00E77A5C /* ImportLegacyWalletClient+Interface.swift in Sources */,
A4DCCC512C2DA33100438A7B /* HomeCardsClient+Live.swift in Sources */,
48CFC4D82ADC10DA00E77A5C /* TransactionStatusResponseKnownPayloadItem.swift in Sources */,
48CFC4522ADC10DA00E77A5C /* NetworkSwitchingClient+Interface.swift in Sources */,
83AAAC6D2B483D1B00222B64 /* StakeSummaryView.swift in Sources */,
Expand Down Expand Up @@ -7342,6 +7401,7 @@
48CFC5F42ADC10DA00E77A5C /* L10n.generated.swift in Sources */,
48CFC4D52ADC10DA00E77A5C /* MetadataU32Value.swift in Sources */,
48CFC5992ADC10DA00E77A5C /* InfoPair.swift in Sources */,
5B272DDB2C36E9D300B74F1F /* AppEventsClient+Test.swift in Sources */,
48CFC33F2ADC10D900E77A5C /* DappInteractionModels.swift in Sources */,
48CFC65A2ADC10DB00E77A5C /* Profile+UpdateNetwork.swift in Sources */,
48CFC49B2ADC10DA00E77A5C /* StateEntityMetadataPageRequest.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// MARK: - AppEventsClient
public struct AppEventsClient: Sendable {
public var handleEvent: HandleEvent

init(handleEvent: @escaping HandleEvent) {
self.handleEvent = handleEvent
}
}

// MARK: AppEventsClient.HandleEvent
extension AppEventsClient {
public typealias HandleEvent = @Sendable (AppEvent) -> Void
}

extension DependencyValues {
public var appEventsClient: AppEventsClient {
get { self[AppEventsClient.self] }
set { self[AppEventsClient.self] = newValue }
}
}

// MARK: - AppEvent
public enum AppEvent: Sendable, Hashable {
case appStarted
case walletCreated
case deepLinkReceived(String)
}
18 changes: 18 additions & 0 deletions RadixWallet/Clients/AppEventsClient/AppEventsClient+Live.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extension AppEventsClient: DependencyKey {
public static let liveValue: AppEventsClient = {
@Dependency(\.homeCardsClient) var homeCardsClient

return .init(
handleEvent: { event in
switch event {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not 100% sure about this approach. Should AppEventsClient perform some actions on the events, or should it just propagate the events?
In the later case the, HomeCardsClients would listen for the events emitted by the AppEventsClient and perform the actions on its own.

wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked this idea a lot, so gave it a try here. However, there seems to be a race condition error since the .appStarted event is never received by the listener. I even added this handy method to be called by the AppEventsClient on its initialization, to make sure the HomeCardsClient subscribes to events before the first one is dispatched, but problem was still present.

We can work on some delays but even having the AppsEventsClient starting the HomeCardsClient (and whatever other listener client we would have in the future) goes against the whole reasoning behind this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved with AsyncReplaySubject

case .appStarted:
homeCardsClient.walletStarted()
case .walletCreated:
homeCardsClient.walletCreated()
case let .deepLinkReceived(value):
homeCardsClient.deepLinkReceived(value)
}
}
)
}()
}
14 changes: 14 additions & 0 deletions RadixWallet/Clients/AppEventsClient/AppEventsClient+Test.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// MARK: - AppEventsClient + TestDependencyKey
extension AppEventsClient: TestDependencyKey {
public static let previewValue = Self.noop

public static let testValue = Self(
handleEvent: unimplemented("\(Self.self).handleEvent")
)
}

extension AppEventsClient {
public static let noop = Self(
handleEvent: { _ in }
)
}
11 changes: 4 additions & 7 deletions RadixWallet/Clients/AppsFlyerClient/AppsFlyerClient+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ extension AppsFlyerClient: DependencyKey {
}

private class Delegate: NSObject, DeepLinkDelegate, @unchecked Sendable {
@Dependency(\.appEventsClient) var appEventsClient

func didResolveDeepLink(_ result: DeepLinkResult) {
if let deepLink = result.deepLink {
loggerGlobal.info("did resolve deep link. Is deferred: \(deepLink.isDeferred). Click events: \(deepLink.clickEvent)")
if deepLink.isDeferred {
let message = if let deepLinkValue = deepLink.clickEvent["deep_link_value"] as? String {
"Resolved deferred DL with value \(deepLinkValue)"
} else {
"Resolved deferred DL without value"
}
AppsFlyerLib.shared().logEvent(message, withValues: deepLink.clickEvent)
if deepLink.isDeferred, let value = deepLink.clickEvent["deep_link_value"] as? String {
appEventsClient.handleEvent(.deepLinkReceived(value))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have DeepLinkHandlerClient, could we extend it to handle the deferred deepLink?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm I am not sure I prefer it this way, since DeepLinkHandlerClient is about non deferred deep links. The logic for deferred vs non deferred is totally different, so not sure if it wouldn't add more confusion to put it there just for the sake of being a deep link.

}
} else if let error = result.error {
loggerGlobal.info("failed to resolve deep link. Status: \(result.status), Error: \(error.localizedDescription)")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// MARK: - HomeCardsClient
public struct HomeCardsClient: Sendable {
public var cards: Cards
public var removeCard: RemoveCard
public var walletStarted: WalletStarted
public var walletCreated: WalletCreated
public var deepLinkReceived: DeepLinkReceived
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should express some command, like handle..., or on.... similar to the remove above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignored as per changes to AppEventClient


init(
cards: @escaping Cards,
removeCard: @escaping RemoveCard,
walletStarted: @escaping WalletStarted,
walletCreated: @escaping WalletCreated,
deepLinkReceived: @escaping DeepLinkReceived
) {
self.cards = cards
self.removeCard = removeCard
self.walletStarted = walletStarted
self.walletCreated = walletCreated
self.deepLinkReceived = deepLinkReceived
}
}

extension HomeCardsClient {
public typealias Cards = @Sendable () -> AnyAsyncSequence<[HomeCard]>

Check failure on line 25 in RadixWallet/Clients/HomeCardsClient/HomeCardsClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'HomeCard' in scope
public typealias RemoveCard = @Sendable (HomeCard) -> Void

Check failure on line 26 in RadixWallet/Clients/HomeCardsClient/HomeCardsClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'HomeCard' in scope
public typealias WalletStarted = @Sendable () -> Void
public typealias WalletCreated = @Sendable () -> Void
public typealias DeepLinkReceived = @Sendable (String) -> Void
}

extension DependencyValues {
public var homeCardsClient: HomeCardsClient {
get { self[HomeCardsClient.self] }
set { self[HomeCardsClient.self] = newValue }
}
}
63 changes: 63 additions & 0 deletions RadixWallet/Clients/HomeCardsClient/HomeCardsClient+Live.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import ComposableArchitecture

// MARK: - HomeCardsClient + DependencyKey
extension HomeCardsClient: DependencyKey {
public static let liveValue: Self = {
let observer = HomeCardsObserver()

// We are hardcoding to `.mainnet` because the cards are currently gateway agnostic. In the future, when Profile is integrated into Sargon, it will be Sargon
// observing the current gateway and defining the networkId to use.
let manager = HomeCardsManager(networkAntenna: URLSession.shared, networkId: .mainnet, cardsStorage: HomeCardsStorage(), observer: observer)

return Self(
cards: {
observer.subject.eraseToAnyAsyncSequence()
},
removeCard: { card in
Task {
try? await manager.cardDismissed(card: card)
}
},
walletStarted: {
Task {
try? await manager.walletStarted()
}
},
walletCreated: {
Task {
try? await manager.walletCreated()
}
},
deepLinkReceived: { value in
Task {
try? await manager.deepLinkReceived(encodedValue: value)
}
}
)
}()
}

// MARK: - HomeCardsManager + Sendable
extension HomeCardsManager: @unchecked Sendable {}

// MARK: - HomeCardsStorage
private final class HomeCardsStorage: Sargon.HomeCardsStorage {
@Dependency(\.userDefaults) var userDefaults
GhenadieVP marked this conversation as resolved.
Show resolved Hide resolved

func saveCards(encodedCards: Data) async throws {
userDefaults.setHomeCards(encodedCards)
}

func loadCards() async throws -> Data? {
userDefaults.getHomeCards()
}
}

// MARK: - HomeCardsObserver
private final class HomeCardsObserver: Sargon.HomeCardsObserver, Sendable {
let subject: AsyncCurrentValueSubject<[HomeCard]> = .init([])

func handleCardsUpdate(cards: [HomeCard]) {
subject.send(cards)
}
}
Loading
Loading