49 lines
1.7 KiB
Swift
49 lines
1.7 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
struct NotesView: View {
|
||
|
|
@Binding var notes: String
|
||
|
|
let total: Double
|
||
|
|
let discrepancy: Double
|
||
|
|
let expectedFloat: Double
|
||
|
|
@Environment(\.dismiss) private var dismiss
|
||
|
|
|
||
|
|
var body: some View {
|
||
|
|
NavigationStack {
|
||
|
|
TextEditor(text: $notes)
|
||
|
|
.padding()
|
||
|
|
.navigationTitle("Session Notes")
|
||
|
|
.navigationBarTitleDisplayMode(.inline)
|
||
|
|
.toolbar {
|
||
|
|
ToolbarItem(placement: .navigationBarLeading) {
|
||
|
|
Button("Done") { dismiss() }
|
||
|
|
}
|
||
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||
|
|
ShareLink(item: notes)
|
||
|
|
}
|
||
|
|
// Keyboard extension tools
|
||
|
|
ToolbarItemGroup(placement: .keyboard) {
|
||
|
|
Button(action: injectTotal) { Label("Total", systemImage: "dollarsign.circle") }
|
||
|
|
Spacer()
|
||
|
|
Button(action: injectDeposit) { Label("Deposit", systemImage: "arrow.down.circle") }
|
||
|
|
Spacer()
|
||
|
|
Button(action: injectTime) { Label("Time", systemImage: "clock") }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private func injectTotal() {
|
||
|
|
notes += "\nTotal Count: \(String(format: "$%.2f", total))"
|
||
|
|
}
|
||
|
|
|
||
|
|
private func injectDeposit() {
|
||
|
|
if expectedFloat > 0 {
|
||
|
|
notes += "\nFloat: \(String(format: "$%.2f", expectedFloat)) | Deposit: \(String(format: "$%.2f", discrepancy))"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private func injectTime() {
|
||
|
|
notes += "\nChecked at: \(Date.now.formatted(date: .omitted, time: .shortened))"
|
||
|
|
}
|
||
|
|
}
|