Skip to content

Update ContentView.swift #1

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update ContentView.swift
  • Loading branch information
noxonsu authored Oct 18, 2023
commit c1f56882ae1570a611e85c68a907db6de9c941c9
33 changes: 30 additions & 3 deletions Onout Watch App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import SwiftUI
struct ContentView: View {
@StateObject private var viewModel = BalanceViewModel()

@State private var inputString = ""
@State private var showingInputDialog = false
@State private var showWalletInputView = false

var body: some View {
VStack {
Expand All @@ -25,14 +25,41 @@ struct ContentView: View {
.actionSheet(isPresented: $showingInputDialog) {
ActionSheet(title: Text("Choose input method"), buttons: [
.default(Text("Enter on iPhone")) {
// Present a view or a screen on iPhone for input
showWalletInputView = true
},
.default(Text("Enter on Watch")) {
// Here you can retain the existing logic or modify as needed for the watch input
// Logic for watch input (if any)
},
.cancel()
])
}
.sheet(isPresented: $showWalletInputView) {
WalletInputView(viewModel: viewModel)
}
.padding()
}
.padding()
}
}

struct WalletInputView: View {
@ObservedObject var viewModel: BalanceViewModel
@State private var inputString = ""
@Environment(\.dismiss) var dismiss

var body: some View {
VStack {
TextField("Enter new wallet", text: $inputString, onCommit: {
viewModel.updateWallet(wallet: inputString)
dismiss()
})
.textFieldStyle(.roundedBorder)
.padding()

Button("Submit") {
viewModel.updateWallet(wallet: inputString)
dismiss()
}
.padding()
}
.padding()
Expand Down