From 988dca5ff1d3339cf1ce537d8fc654b6ad96c82f Mon Sep 17 00:00:00 2001 From: "severin.memmishofer" Date: Mon, 10 Jul 2023 17:49:42 +0200 Subject: [PATCH] Minor changes to the NewFeedEntryView; fixed some other classes because of compile errors --- RippleChat.xcodeproj/project.pbxproj | 2 +- RippleChat/Body.swift | 11 +++++++++-- RippleChat/ContentView.swift | 15 ++++++++------- RippleChat/RippleChatApp.swift | 2 +- RippleChat/Views/FeedListView.swift | 4 ++-- RippleChat/{ => Views}/NewFeedEntryView.swift | 12 +++++++++--- 6 files changed, 30 insertions(+), 16 deletions(-) rename RippleChat/{ => Views}/NewFeedEntryView.swift (53%) diff --git a/RippleChat.xcodeproj/project.pbxproj b/RippleChat.xcodeproj/project.pbxproj index 31d578c..e589f10 100644 --- a/RippleChat.xcodeproj/project.pbxproj +++ b/RippleChat.xcodeproj/project.pbxproj @@ -131,7 +131,6 @@ F5847B652A599EA4009E28D4 /* Feed.swift */, F5847B692A59AB24009E28D4 /* FeedStore.swift */, 96BD330D2A5C254B007A6E53 /* TextApp.swift */, - 96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */, ); path = RippleChat; sourceTree = ""; @@ -164,6 +163,7 @@ 96BD33112A5C3FFC007A6E53 /* Views */ = { isa = PBXGroup; children = ( + 96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */, 96BD33122A5C400B007A6E53 /* FeedListView.swift */, 96BD33152A5C403C007A6E53 /* PeeringView.swift */, 96BD33172A5C404F007A6E53 /* FriendsListView.swift */, diff --git a/RippleChat/Body.swift b/RippleChat/Body.swift index 1cc2bbc..8a57f12 100644 --- a/RippleChat/Body.swift +++ b/RippleChat/Body.swift @@ -9,11 +9,11 @@ import Foundation struct Body: Codable { - let tag: Apps + let tag: String let value: String init(tag: Apps = Apps.txt, value: String = "") { - self.tag = tag + self.tag = tag.description self.value = value } } @@ -21,4 +21,11 @@ struct Body: Codable { enum Apps: Codable { case nam case txt + + var description : String { + switch self { + case .nam: return "nam" + case .txt: return "txt" + } + } } diff --git a/RippleChat/ContentView.swift b/RippleChat/ContentView.swift index c23ce88..cccaaab 100644 --- a/RippleChat/ContentView.swift +++ b/RippleChat/ContentView.swift @@ -21,7 +21,6 @@ struct ContentView: View { .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") - Spacer() Button("Save Feed") { Task { do { @@ -36,12 +35,14 @@ struct ContentView: View { } } .padding() - NavigationView { - List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in - Text(peripheral) - } - .navigationTitle("Peripherals") - } + Spacer() + NewFeedEntryView() +// NavigationView { +// List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in +// Text(peripheral) +// } +// .navigationTitle("Peripherals") +// } } diff --git a/RippleChat/RippleChatApp.swift b/RippleChat/RippleChatApp.swift index b0aa386..e9299a5 100644 --- a/RippleChat/RippleChatApp.swift +++ b/RippleChat/RippleChatApp.swift @@ -9,7 +9,7 @@ import SwiftUI @main struct RippleChatApp: App { - @State private var currentView: CurrentView = CurrentView.feeds + //@State private var currentView: CurrentView = CurrentView.feeds var body: some Scene { WindowGroup { diff --git a/RippleChat/Views/FeedListView.swift b/RippleChat/Views/FeedListView.swift index 5843a79..36a9636 100644 --- a/RippleChat/Views/FeedListView.swift +++ b/RippleChat/Views/FeedListView.swift @@ -8,7 +8,7 @@ import SwiftUI struct FeedListView: View { - + @State var feeds: [Feed] var body: some View { Text("FeedListView") @@ -17,6 +17,6 @@ struct FeedListView: View { struct FeedListView_Previews: PreviewProvider { static var previews: some View { - FeedListView() + FeedListView(feeds: []) } } diff --git a/RippleChat/NewFeedEntryView.swift b/RippleChat/Views/NewFeedEntryView.swift similarity index 53% rename from RippleChat/NewFeedEntryView.swift rename to RippleChat/Views/NewFeedEntryView.swift index 3fc3978..64c4b08 100644 --- a/RippleChat/NewFeedEntryView.swift +++ b/RippleChat/Views/NewFeedEntryView.swift @@ -8,13 +8,19 @@ import SwiftUI struct NewFeedEntryView: View { - @State private var name: String = "Alice" + @State private var newEntry: String = "" var body: some View { VStack(alignment: .leading) { - TextField("Enter your name", text: $name) - Text("Hello, \(name)!") + HStack { + TextField("Enter your new feed message:", text: $newEntry) + Button(action: {}) { + Text("Send") + } + } + Text("New entry: \(newEntry)") } + .padding() } }