Skip to content

Commit

Permalink
Show Stake Claim NFT details (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhenadieVP committed Dec 13, 2023
1 parent 38cff46 commit 5da1120
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
23 changes: 11 additions & 12 deletions RadixWallet/Core/FeaturePrelude/AddressView/AddressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,20 @@ extension AddressView {
}
}

@ViewBuilder
private var addressView: some View {
Group {
if format == .full {
Text("\(identifiable.address.formatted(format))\(image)")
.lineLimit(nil)
} else {
HStack(spacing: .small3) {
Text(identifiable.address.formatted(format))
.lineLimit(1)
image
}
if format == .full {
Text("\(identifiable.address.formatted(format))\(image)")
.lineLimit(nil)
.multilineTextAlignment(.leading)
.minimumScaleFactor(0.5)
} else {
HStack(spacing: .small3) {
Text(identifiable.address.formatted(format))
.lineLimit(1)
image
}
}
.multilineTextAlignment(.leading)
.minimumScaleFactor(0.5)
}

private var image: Image {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,13 @@ extension NonFungibleTokenDetails.ViewState.TokenDetails {
}

extension OnLedgerEntity.NonFungibleToken.NFTData {
private static let standardFields: [OnLedgerEntity.NonFungibleToken.NFTData.StandardField] = [.name, .description, .keyImageURL]

fileprivate var arbitraryDataFields: [NonFungibleTokenDetails.ViewState.TokenDetails.ArbitraryDataField] {
let standardFields = OnLedgerEntity.NonFungibleToken.NFTData.StandardField.allCases.map(\.rawValue)
return fields.compactMap { field in
fields.compactMap { field in
guard let fieldName = field.fieldName,
let kind = field.fieldKind,
!standardFields.contains(fieldName) // Filter out standard fields
!Self.standardFields.map(\.rawValue).contains(fieldName) // Filter out standard fields
else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,25 @@ private extension StoreOf<LSUStake> {
private extension View {
func destinations(with store: StoreOf<LSUStake>) -> some View {
let destinationStore = store.destination
return sheet(
return lsuDetails(with: destinationStore)
.stakeClaimNFTDetails(with: destinationStore)
}

private func lsuDetails(with destinationStore: PresentationStoreOf<LSUStake.Destination>) -> some View {
sheet(
store: destinationStore,
state: /LSUStake.Destination.State.details,
action: LSUStake.Destination.Action.details,
content: { LSUDetails.View(store: $0) }
)
}

private func stakeClaimNFTDetails(with destinationStore: PresentationStoreOf<LSUStake.Destination>) -> some View {
sheet(
store: destinationStore,
state: /LSUStake.Destination.State.stakeClaimDetails,
action: LSUStake.Destination.Action.stakeClaimDetails,
content: { NonFungibleTokenDetails.View(store: $0) }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public struct LSUStake: FeatureReducer {
public struct Destination: DestinationReducer {
public enum State: Sendable, Hashable {
case details(LSUDetails.State)
case stakeClaimDetails(NonFungibleTokenDetails.State)
}

public enum Action: Sendable, Equatable {
case details(LSUDetails.Action)
case stakeClaimDetails(NonFungibleTokenDetails.Action)
}

public var body: some ReducerOf<Self> {
Expand All @@ -40,6 +42,12 @@ public struct LSUStake: FeatureReducer {
action: /Action.details,
child: LSUDetails.init
)

Scope(
state: /State.stakeClaimDetails,
action: /Action.stakeClaimDetails,
child: NonFungibleTokenDetails.init
)
}
}

Expand Down Expand Up @@ -87,7 +95,9 @@ public struct LSUStake: FeatureReducer {
guard case let .success(stakeDetails) = state.stakeDetails else {
return .none
}
guard let token = stakeDetails.stakeClaimTokens?.tokens.first(where: { $0.id == id }) else {
guard let nftResource = stakeDetails.stakeClaimTokens,
let token = nftResource.tokens.first(where: { $0.id == id })
else {
assertionFailure("Did tapp a missing NFT?")
return .none
}
Expand All @@ -96,7 +106,12 @@ public struct LSUStake: FeatureReducer {
state.selectedStakeClaimAssets?.toggle(token)
}

// TODO: Show details
state.destination = .stakeClaimDetails(.init(
resourceAddress: nftResource.resource.resourceAddress,
resourceDetails: .success(nftResource.resource),
token: token,
ledgerState: nftResource.resource.atLedgerState
))
return .none
}
}
Expand Down

0 comments on commit 5da1120

Please sign in to comment.