-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db29b24
commit c28b8c8
Showing
43 changed files
with
8,731 additions
and
6,699 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
14,644 changes: 8,569 additions & 6,075 deletions
14,644
rust/ios/Cove/Cove.swift → ios/Cove/Cove.swift
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
ios/Cove/Flows/SelectedWalletFlow/SelectedWalletContainer.swift
This file contains 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,78 @@ | ||
// | ||
// SelectedWalletScreen.swift | ||
// Cove | ||
// | ||
// Created by Praveen Perera on 7/1/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SelectedWalletContainer: View { | ||
@Environment(\.colorScheme) private var colorScheme | ||
@Environment(MainViewModel.self) private var app | ||
@Environment(\.navigate) private var navigate | ||
|
||
let id: WalletId | ||
@State private var model: WalletViewModel? = nil | ||
|
||
func loadModel() { | ||
if model != nil { return } | ||
|
||
do { | ||
Log.debug("Getting wallet \(id)") | ||
model = try app.getWalletViewModel(id: id) | ||
} catch { | ||
Log.error("Something went very wrong: \(error)") | ||
navigate(Route.listWallets) | ||
} | ||
} | ||
|
||
var body: some View { | ||
Group { | ||
if let model { | ||
SelectedWalletScreen(model: model) | ||
.background( | ||
model.loadState == .loading ? | ||
LinearGradient(colors: [ | ||
.black.opacity(colorScheme == .dark ? 0.9 : 0), | ||
.black.opacity(colorScheme == .dark ? 0.9 : 0), | ||
], startPoint: .top, endPoint: .bottom) : | ||
LinearGradient(stops: [ | ||
.init(color: .midnightBlue, location: 0.45), | ||
.init(color: colorScheme == .dark ? .black.opacity(0.9) : .clear, location: 0.55), | ||
], startPoint: .top, endPoint: .bottom) | ||
) | ||
.background(Color.white) | ||
|
||
} else { | ||
Text("Loading...") | ||
} | ||
} | ||
.onAppear { | ||
loadModel() | ||
} | ||
.task { | ||
// small delay and then start scanning wallet | ||
if let model { | ||
do { | ||
try? await Task.sleep(for: .milliseconds(400)) | ||
try await model.rust.startWalletScan() | ||
} catch { | ||
Log.error("Wallet Scan Failed \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
.onChange(of: model?.loadState) { _, loadState in | ||
if case .loaded = loadState { | ||
if let model { | ||
app.updateWalletVm(model) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
SelectedWalletContainer(id: WalletId()) | ||
.environment(MainViewModel()) | ||
} |
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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