Skip to content

Commit

Permalink
Updates AddTokenScene
Browse files Browse the repository at this point in the history
  • Loading branch information
gemdev111 committed Jun 10, 2024
1 parent 9e674ef commit 8943eae
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions Gem/Assets/Scenes/AddTokenScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ struct AddTokenScene: View {
List {
if let chain = model.chain {
Section(Localized.Transfer.network) {
NavigationCustomLink(with: ChainView(chain: chain)) {
isPresentingSelectNetwork = true
}
NavigationCustomLink(with: ChainView(chain: chain), action: onSelectChain)
}
}
Section {
Expand All @@ -40,9 +38,7 @@ struct AddTokenScene: View {
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.submitLabel(.search)
.onSubmit {
onSubmitAddress()
}
.onSubmit(onSubmitAddress)
Spacer()
HStack(spacing: Spacing.medium) {
ListButton(image: Image(systemName: SystemImage.paste), action: onSelectPaste)
Expand Down Expand Up @@ -88,22 +84,18 @@ struct AddTokenScene: View {
.background(Colors.grayBackground)
.navigationTitle(model.title)
.sheet(isPresented: $isPresentingScanner) {
ScanQRCodeNavigationStack(isPresenting: $isPresentingScanner) {
onScanFinished($0)
}
ScanQRCodeNavigationStack(isPresenting: $isPresentingScanner, action: onScanFinished(_:))
}
.sheet(isPresented: $isPresentingSelectNetwork) {
if let chain = model.chain {
NetworkSelectorNavigationStack(
model: NetworkSelectorViewModel(chains: model.chains, selectedChain: chain),
isPresenting: $isPresentingSelectNetwork) { chain in
onSelectNewChain(chain)
}
isPresenting: $isPresentingSelectNetwork,
onSelectChain: onSelectNewChain(_:)
)
}
}
.taskOnce {
onTaskOnce()
}
.taskOnce(onTaskOnce)
.alert(item: $isPresentingErrorMessage) {
Alert(title: Text(""), message: Text($0))
}
Expand All @@ -126,6 +118,10 @@ extension AddTokenScene {
}
}

private func onSelectChain() {
isPresentingSelectNetwork = true
}

private func onSelectScan() {
isPresentingScanner = true
}
Expand Down Expand Up @@ -157,15 +153,15 @@ extension AddTokenScene {
}
}

// MARK: -
// MARK: - Data Fetching

extension AddTokenScene {
private func addToken(tokenId: String) async throws {
try await model.fetch(tokenId: tokenId)
}
}

// MARK: -
// MARK: - LocalizedError

extension TokenValidationError: LocalizedError {
public var errorDescription: String? {
Expand Down

0 comments on commit 8943eae

Please sign in to comment.