-
Notifications
You must be signed in to change notification settings - Fork 53
Refactor sheet presentation logic in wallet scene #1026
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4c156c3
Refactor sheet presentation logic in wallet scene
gemdev111 111c8df
Refactor WalletSceneSheetType and navigation bindings
gemdev111 9769c8c
Merge branch 'main' into 973-walletscene-presenting
gemdev111 bd1633d
Merge branch 'main' into 973-walletscene-presenting
gemdev111 779465c
Update core
gemdev111 53320f1
Integrate set price alert into WalletSceneSheetType
gemdev111 21d48f1
Update core
gemdev111 3760a4a
Update core
gemdev111 5952259
Merge branch 'main'
gemdev111 3621460
Merge branch 'main' into 973-walletscene-presenting
gemdev111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
Features/WalletTab/Sources/Types/WalletSceneSheetType.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c). Gem Wallet. All rights reserved. | ||
|
||
import Foundation | ||
import InfoSheet | ||
import Primitives | ||
import SwiftUI | ||
|
||
public enum WalletSceneSheetType: Identifiable, Sendable { | ||
case wallets | ||
case selectAssetType(SelectAssetType) | ||
case info(InfoSheetType) | ||
case url(URL) | ||
case transferData(TransferData) | ||
case perpetualRecipientData(PerpetualRecipientData) | ||
case setPriceAlert(AssetId) | ||
|
||
public var id: String { | ||
switch self { | ||
case .wallets: "wallets" | ||
case let .selectAssetType(type): "select-asset-type-\(type.id)" | ||
case let .info(type): "info-\(type.id)" | ||
case let .url(url): "url-\(url)" | ||
case let .transferData(data): "transfer-data-\(data.id)" | ||
case let .perpetualRecipientData(data): "perpetual-recipient-data-\(data.id)" | ||
case let .setPriceAlert(assetId): "set-price-alert-\(assetId.identifier)" | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Binding extensions | ||
|
||
extension Binding where Value == WalletSceneSheetType? { | ||
public var selectAssetType: Binding<SelectAssetType?> { | ||
Binding<SelectAssetType?>( | ||
get: { | ||
if case .selectAssetType(let type) = wrappedValue { | ||
return type | ||
} | ||
return nil | ||
}, | ||
set: { newValue in | ||
wrappedValue = newValue.map { .selectAssetType($0) } | ||
} | ||
) | ||
} | ||
|
||
public var transferData: Binding<TransferData?> { | ||
Binding<TransferData?>( | ||
get: { | ||
if case .transferData(let data) = wrappedValue { | ||
return data | ||
} | ||
return nil | ||
}, | ||
set: { newValue in | ||
wrappedValue = newValue.map { .transferData($0) } | ||
} | ||
) | ||
} | ||
|
||
public var perpetualRecipientData: Binding<PerpetualRecipientData?> { | ||
Binding<PerpetualRecipientData?>( | ||
get: { | ||
if case .perpetualRecipientData(let data) = wrappedValue { | ||
return data | ||
} | ||
return nil | ||
}, | ||
set: { newValue in | ||
wrappedValue = newValue.map { .perpetualRecipientData($0) } | ||
} | ||
) | ||
} | ||
|
||
public var wallets: Binding<Bool> { | ||
Binding<Bool>( | ||
get: { | ||
if case .wallets = wrappedValue { return true } | ||
return false | ||
}, | ||
set: { newValue in | ||
wrappedValue = newValue ? .wallets : nil | ||
} | ||
) | ||
} | ||
|
||
public var setPriceAlert: Binding<AssetId?> { | ||
Binding<AssetId?>( | ||
get: { | ||
if case .setPriceAlert(let assetId) = wrappedValue { | ||
return assetId | ||
} | ||
return nil | ||
}, | ||
set: { newValue in | ||
wrappedValue = newValue.map { .setPriceAlert($0) } | ||
} | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
id
for the.transferData
case is constructed usingdata.id
, but theTransferData
type does not have anid
property and does not conform toIdentifiable
. This will result in a compilation error.Since
TransferData
conforms toHashable
, you can usedata.hashValue
to generate a unique identifier. This avoids having to modify theTransferData
struct if that's outside the scope of this PR.