From c898dfa2c796f9148f180eb205a0dd4fe647f8c5 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger <74497638+sebaschi@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:15:34 +0200 Subject: [PATCH] Minor Update --- RippleChat/Body.swift | 9 +++++++-- RippleChat/ContentView.swift | 20 +++++++++++++++++++- RippleChat/Feed.swift | 15 ++++++++++++--- RippleChat/TextApp.swift | 6 +++--- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/RippleChat/Body.swift b/RippleChat/Body.swift index c16836c..1cc2bbc 100644 --- a/RippleChat/Body.swift +++ b/RippleChat/Body.swift @@ -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 +} diff --git a/RippleChat/ContentView.swift b/RippleChat/ContentView.swift index 439bd7c..346ee46 100644 --- a/RippleChat/ContentView.swift +++ b/RippleChat/ContentView.swift @@ -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 +} diff --git a/RippleChat/Feed.swift b/RippleChat/Feed.swift index 1579375..7869992 100644 --- a/RippleChat/Feed.swift +++ b/RippleChat/Feed.swift @@ -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) } diff --git a/RippleChat/TextApp.swift b/RippleChat/TextApp.swift index c489865..c15a00b 100644 --- a/RippleChat/TextApp.swift +++ b/RippleChat/TextApp.swift @@ -7,9 +7,9 @@ import Foundation -struct TextApp { +struct TextApp: Codable { - let t = Date() - let p: String + let t: Date + let p: String? }