Minor Update

This commit is contained in:
Sebastian Lenzlinger 2023-07-10 15:15:34 +02:00
parent 5c46b317c6
commit c898dfa2c7
4 changed files with 41 additions and 9 deletions

View File

@ -9,11 +9,16 @@ import Foundation
struct Body: Codable {
let tag: String
let tag: Apps
let value: String
init(tag: String, value: String) {
init(tag: Apps = Apps.txt, value: String = "") {
self.tag = tag
self.value = value
}
}
enum Apps: Codable {
case nam
case txt
}

View File

@ -11,6 +11,7 @@ import CoreBluetooth
struct ContentView: View {
@ObservedObject private var bluetoothViewModel = BluetoothViewModel()
@StateObject private var store = FeedStore(feed: Feed.sampleFeed)
private var feedStores = [FeedStore(feed: Feed.sampleFeed), FeedStore(feed: Feed.sampleFeed2)]
var body: some View {
VStack {
@ -22,7 +23,10 @@ struct ContentView: View {
Button("Save Feed") {
Task {
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 {
fatalError(error.localizedDescription)
}
@ -36,6 +40,13 @@ struct ContentView: View {
}
.navigationTitle("Peripherals")
}
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button("Peers") {}
}
}
}
}
@ -44,3 +55,10 @@ struct ContentView_Previews: PreviewProvider {
ContentView()
}
}
enum CurrentView {
case peers
case feeds
case friends
case settings
}

View File

@ -23,11 +23,20 @@ extension Feed {
static let sampleData: [LogEntry] =
[
LogEntry(feedid: "BOB", sequenceNumber: 1, body: Body(tag: "nam", value: "Bob")),
LogEntry(feedid: "BOB", sequenceNumber: 2, body: Body(tag: "txt", value: "My first post!")),
LogEntry(feedid: "BOB", sequenceNumber: 3, body: Body(tag: "txt", value: "Welcome Alice"))
LogEntry(feedid: "BOB", sequenceNumber: 1, body: Body(tag: Apps.nam, value: "Bob")),
LogEntry(feedid: "BOB", sequenceNumber: 2, body: Body(tag: Apps.txt, value: "My first post!")),
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 sampleFeed2: Feed = Feed(feedID: "ALI", feed: sampleData2)
}

View File

@ -7,9 +7,9 @@
import Foundation
struct TextApp {
struct TextApp: Codable {
let t = Date()
let p: String
let t: Date
let p: String?
}