-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also: * update to remote EventSource package * Add HasLogger
- Loading branch information
1 parent
b6ef17f
commit f2a4c20
Showing
37 changed files
with
255 additions
and
810 deletions.
There are no files selected for viewing
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
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
9 changes: 9 additions & 0 deletions
9
...seDemo/PocketBaseDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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
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
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,61 @@ | ||
// | ||
// RawrView.swift | ||
// PocketBaseDemo | ||
// | ||
// Created by Brianna Zamora on 9/18/24. | ||
// | ||
|
||
import PocketBase | ||
import SwiftUI | ||
import os | ||
|
||
struct RawrView: View { | ||
@Environment(\.pocketbase) private var pocketbase | ||
|
||
private let rawr: Rawr | ||
|
||
@State private var isPresentingEditAlert: Bool = false | ||
@State private var editText: String = "" | ||
|
||
static let logger = Logger( | ||
subsystem: "PocketBaseDemo", | ||
category: "RawrView" | ||
) | ||
|
||
init(rawr: Rawr) { | ||
self.rawr = rawr | ||
} | ||
|
||
var body: some View { | ||
Button(rawr.field) { | ||
editText = rawr.field | ||
isPresentingEditAlert = true | ||
} | ||
.foregroundStyle(.primary) | ||
.alert("Update Rawr", isPresented: $isPresentingEditAlert) { | ||
TextField("Update Rawr", text: $editText) | ||
.onSubmit { | ||
save() | ||
} | ||
Button("Cancel", role: .cancel) { | ||
isPresentingEditAlert = false | ||
} | ||
Button("Save") { | ||
save() | ||
} | ||
} | ||
} | ||
|
||
private func save() { | ||
var rawr = self.rawr | ||
rawr.field = editText | ||
Task { | ||
do { | ||
try await pocketbase.collection(Rawr.self).update(rawr) | ||
isPresentingEditAlert = false | ||
} catch { | ||
Self.logger.error("Failed to update rawr with error: \(error)") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.