Minor Update
This commit is contained in:
parent
5c46b317c6
commit
c898dfa2c7
@ -9,11 +9,16 @@ import Foundation
|
|||||||
|
|
||||||
struct Body: Codable {
|
struct Body: Codable {
|
||||||
|
|
||||||
let tag: String
|
let tag: Apps
|
||||||
let value: String
|
let value: String
|
||||||
|
|
||||||
init(tag: String, value: String) {
|
init(tag: Apps = Apps.txt, value: String = "") {
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.value = value
|
self.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Apps: Codable {
|
||||||
|
case nam
|
||||||
|
case txt
|
||||||
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import CoreBluetooth
|
|||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@ObservedObject private var bluetoothViewModel = BluetoothViewModel()
|
@ObservedObject private var bluetoothViewModel = BluetoothViewModel()
|
||||||
@StateObject private var store = FeedStore(feed: Feed.sampleFeed)
|
@StateObject private var store = FeedStore(feed: Feed.sampleFeed)
|
||||||
|
private var feedStores = [FeedStore(feed: Feed.sampleFeed), FeedStore(feed: Feed.sampleFeed2)]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
@ -22,7 +23,10 @@ struct ContentView: View {
|
|||||||
Button("Save Feed") {
|
Button("Save Feed") {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
try await store.save(feed: Feed.sampleFeed)
|
// try await store.save(feed: Feed.sampleFeed)
|
||||||
|
for feed in feedStores {
|
||||||
|
try await feed.save(feed: feed.feed)
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
fatalError(error.localizedDescription)
|
fatalError(error.localizedDescription)
|
||||||
}
|
}
|
||||||
@ -36,6 +40,13 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle("Peripherals")
|
.navigationTitle("Peripherals")
|
||||||
}
|
}
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .bottomBar) {
|
||||||
|
Button("Peers") {}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,3 +55,10 @@ struct ContentView_Previews: PreviewProvider {
|
|||||||
ContentView()
|
ContentView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CurrentView {
|
||||||
|
case peers
|
||||||
|
case feeds
|
||||||
|
case friends
|
||||||
|
case settings
|
||||||
|
}
|
||||||
|
|||||||
@ -23,11 +23,20 @@ extension Feed {
|
|||||||
|
|
||||||
static let sampleData: [LogEntry] =
|
static let sampleData: [LogEntry] =
|
||||||
[
|
[
|
||||||
LogEntry(feedid: "BOB", sequenceNumber: 1, body: Body(tag: "nam", value: "Bob")),
|
LogEntry(feedid: "BOB", sequenceNumber: 1, body: Body(tag: Apps.nam, value: "Bob")),
|
||||||
LogEntry(feedid: "BOB", sequenceNumber: 2, body: Body(tag: "txt", value: "My first post!")),
|
LogEntry(feedid: "BOB", sequenceNumber: 2, body: Body(tag: Apps.txt, value: "My first post!")),
|
||||||
LogEntry(feedid: "BOB", sequenceNumber: 3, body: Body(tag: "txt", value: "Welcome Alice"))
|
LogEntry(feedid: "BOB", sequenceNumber: 3, body: Body(tag: Apps.txt, value: "Welcome Alice"))
|
||||||
|
]
|
||||||
|
|
||||||
|
static let sampleData2: [LogEntry] =
|
||||||
|
[
|
||||||
|
LogEntry(feedid: "ALI", sequenceNumber: 1, body: Body(tag: Apps.nam, value: "Alice")),
|
||||||
|
LogEntry(feedid: "ALI", sequenceNumber: 2, body: Body(tag: Apps.txt, value: "Alice' first post!")),
|
||||||
|
LogEntry(feedid: "ALI", sequenceNumber: 3, body: Body(tag: Apps.txt, value: "Welcome Bob")),
|
||||||
|
LogEntry(feedid: "ALI", sequenceNumber: 4, body: Body(tag: Apps.txt, value: "Whaddup DAWG"))
|
||||||
]
|
]
|
||||||
|
|
||||||
static let sampleFeed: Feed = Feed(feedID: "BOB", feed: sampleData)
|
static let sampleFeed: Feed = Feed(feedID: "BOB", feed: sampleData)
|
||||||
|
static let sampleFeed2: Feed = Feed(feedID: "ALI", feed: sampleData2)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct TextApp {
|
struct TextApp: Codable {
|
||||||
|
|
||||||
let t = Date()
|
let t: Date
|
||||||
let p: String
|
let p: String?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user