Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Jun 30, 2024
1 parent b2d6ebb commit 52334ba
Show file tree
Hide file tree
Showing 22 changed files with 177 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
// MARK: - CardCarouselClient
public struct CardCarouselClient: Sendable {
public var cards: Cards
public var tappedCard: TappedCard
public var closeCard: CloseCard

init(
cards: @escaping Cards,
tappedCard: @escaping TappedCard,
closeCard: @escaping CloseCard
) {
self.cards = cards
self.tappedCard = tappedCard
self.closeCard = closeCard
}
}

// MARK: - CarouselCard
public enum CarouselCard: Hashable, Sendable {
case rejoinRadQuest
case discoverRadix
case continueOnDapp
case useDappsOnDesktop
case threeSixtyDegrees
case connect
case somethingElse
}

extension CardCarouselClient {
public typealias Cards = @Sendable () -> AnyAsyncSequence<[CarouselCard]>
public typealias TappedCard = @Sendable (CarouselCard) -> Void
public typealias CloseCard = @Sendable (CarouselCard) -> Void
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ import ComposableArchitecture

extension CardCarouselClient: DependencyKey {
public static let liveValue: Self = {
let cardSubject = AsyncCurrentValueSubject<[CarouselCard]>([.threeSixtyDegrees, .connect, .somethingElse])

// Just delete the ones that are not needed
@Dependency(\.errorQueue) var errorQueue
@Dependency(\.appPreferencesClient) var appPreferencesClient
@Dependency(\.cacheClient) var cacheClient
@Dependency(\.radixConnectClient) var radixConnectClient
@Dependency(\.userDefaults) var userDefaults

let allCards: [CarouselCard] = [.rejoinRadQuest, .discoverRadix, .continueOnDapp, .useDappsOnDesktop, .threeSixtyDegrees]
let cardSubject = AsyncCurrentValueSubject(allCards)

return Self(
cards: {
cardSubject.eraseToAnyAsyncSequence()
},
tappedCard: { _ in
// TODO: Store the fact that we have tapped this card somewhere
},
closeCard: { card in
guard let index = cardSubject.value.firstIndex(of: card) else { return }
cardSubject.value.remove(at: index)
// TODO: Store the fact that we have closed this card somewhere
}
)
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ extension CardCarouselClient: TestDependencyKey {

public static let testValue = Self(
cards: unimplemented("\(Self.self).cards"),
tappedCard: unimplemented("\(Self.self).tappedCard"),
closeCard: unimplemented("\(Self.self).closeCard")
)
}

extension CardCarouselClient {
public static let noop = Self(
cards: { AsyncLazySequence([]).eraseToAnyAsyncSequence() },
tappedCard: { _ in },
closeCard: { _ in }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public enum AssetResource {
public static let supplyFlexible = ImageAsset(name: "supply-flexible")
public static let supplyIncreasableByAnyone = ImageAsset(name: "supply-increasable-by-anyone")
public static let supplyIncreasable = ImageAsset(name: "supply-increasable")
public static let carouselBackgroundConnect = ImageAsset(name: "carousel_background_connect")
public static let carouselBackgroundRadquest = ImageAsset(name: "carousel_background_radquest")
public static let carouselFullBackground360 = ImageAsset(name: "carousel_full_background_360")
public static let carouselIconContinueOnDapp = ImageAsset(name: "carousel_icon_continueOnDapp")
public static let arrowBack = ImageAsset(name: "arrow-back")
public static let check = ImageAsset(name: "check")
public static let checkmarkBig = ImageAsset(name: "checkmark-big")
Expand Down Expand Up @@ -144,7 +148,6 @@ public enum AssetResource {
public static let transactionReviewDepositSetting = ImageAsset(name: "transactionReview_depositSetting")
public static let transactionReviewDepositing = ImageAsset(name: "transactionReview_depositing")
public static let transactionReviewWithdrawing = ImageAsset(name: "transactionReview_withdrawing")
public static let cardBackgroundTEMPORARY = ImageAsset(name: "card_background_TEMPORARY")
public static let checkCircle = ImageAsset(name: "check_circle")
public static let cloud = ImageAsset(name: "cloud")
public static let configurationBackup = ImageAsset(name: "configuration_backup")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "carousel_background_connect.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "carousel_background_connect@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "carousel_background_connect@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "carousel_background_radquest.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "carousel_background_radquest@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "carousel_background_radquest@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "carousel_icon_continueOnDapp.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "carousel_icon_continueOnDapp@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "carousel_icon_continueOnDapp@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion RadixWallet/Features/CardCarousel/CardCarousel+Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ComposableArchitecture
public struct CardCarousel: FeatureReducer, Sendable {
@ObservableState
public struct State: Hashable, Sendable {
public var cards: [CarouselCard]
public var cards: [CarouselCard] = [.continueOnDapp]
}

public typealias Action = FeatureAction<Self>
Expand Down Expand Up @@ -39,6 +39,19 @@ public struct CardCarousel: FeatureReducer, Sendable {
} catch {}
}
case let .cardTapped(card):
switch card {
case .rejoinRadQuest:
break
case .discoverRadix:
break
case .continueOnDapp:
break
case .useDappsOnDesktop:
break
case .threeSixtyDegrees:
break
}
cardCarouselClient.tappedCard(card)
return .none
case let .closeTapped(card):
cardCarouselClient.closeCard(card)
Expand Down
82 changes: 65 additions & 17 deletions RadixWallet/Features/CardCarousel/CardCarousel+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ extension CardCarousel {
}
.padding(.horizontal, margin - 0.5 * spacing)
.frame(height: height)
.onAppear {
store.send(.view(.didAppear))
}
.transition(.scale(scale: 0.8).combined(with: .opacity))
}
}
.onAppear {
store.send(.view(.didAppear))
}
}

@MainActor
Expand Down Expand Up @@ -112,16 +112,14 @@ public struct CarouselCardView: View {
.padding(.bottom, .small1)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.background(alignment: .trailing) {
Image(.cardBackgroundTEMPORARY)
.resizable()
.aspectRatio(contentMode: .fill)
background
}
.background(.app.gray5)
.cornerRadius(.small1)
}
.overlay(alignment: .topTrailing) {
CloseButton(action: closeAction)
}
// .overlay(alignment: .topTrailing) {
// CloseButton(action: closeAction)
// }
}

public struct Dummy: View {
Expand All @@ -135,23 +133,73 @@ public struct CarouselCardView: View {

private var title: String {
switch card {
case .rejoinRadQuest:
"360 Degrees of Security"
case .discoverRadix:
""
case .continueOnDapp:
""
case .useDappsOnDesktop:
""
case .threeSixtyDegrees:
"360 Degrees of Security"
case .connect:
"Link to connector"
case .somethingElse:
"Something Lorem Ipsum"
}
}

private var message: String {
switch card {
case .rejoinRadQuest:
"360 Degrees of Security"
case .discoverRadix:
""
case .continueOnDapp:
""
case .useDappsOnDesktop:
""
case .threeSixtyDegrees:
"Secure your Accounts and Personas with Security shields"
case .connect:
"Do it now"
case .somethingElse:
"Blabbely bla"
}
}

private var background: some View {
switch card {
case .rejoinRadQuest:
cardBackground(.carouselBackgroundRadquest, type: .gradient)
case .discoverRadix:
cardBackground(.carouselBackgroundRadquest, type: .gradient)
case .continueOnDapp:
cardBackground(.carouselIconContinueOnDapp, type: .icon)
case .useDappsOnDesktop:
cardBackground(.carouselBackgroundConnect, type: .gradient)
case .threeSixtyDegrees:
cardBackground(.carouselFullBackground360, type: .full)
}
}

@ViewBuilder
private func cardBackground(_ imageResource: ImageResource, type: BackgroundType) -> some View {
switch type {
case .icon:
Image(imageResource)
.padding(.trailing, .medium2)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
case .gradient:
Image(imageResource)
.resizable()
.aspectRatio(contentMode: .fill)
.mask {
LinearGradient(colors: [.clear, .white, .white], startPoint: .leading, endPoint: .trailing)
}
case .full:
Image(imageResource)
.resizable()
.aspectRatio(contentMode: .fill)
}
}

private enum BackgroundType {
case icon
case gradient
case full
}
}
2 changes: 1 addition & 1 deletion RadixWallet/Features/HomeFeature/Coordinator/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct Home: Sendable, FeatureReducer {

public struct State: Sendable, Hashable {
// MARK: - Components
public var carousel: CardCarousel.State = .init(cards: [.threeSixtyDegrees, .connect, .somethingElse])
public var carousel: CardCarousel.State = .init()

public var accountRows: IdentifiedArrayOf<Home.AccountRow.State> = []
fileprivate var problems: [SecurityProblem] = []
Expand Down

0 comments on commit 52334ba

Please sign in to comment.