Minor changes to the NewFeedEntryView; fixed some other classes because of compile errors

This commit is contained in:
severin.memmishofer 2023-07-10 17:49:42 +02:00
parent 1f664b4250
commit 988dca5ff1
6 changed files with 30 additions and 16 deletions

View File

@ -131,7 +131,6 @@
F5847B652A599EA4009E28D4 /* Feed.swift */, F5847B652A599EA4009E28D4 /* Feed.swift */,
F5847B692A59AB24009E28D4 /* FeedStore.swift */, F5847B692A59AB24009E28D4 /* FeedStore.swift */,
96BD330D2A5C254B007A6E53 /* TextApp.swift */, 96BD330D2A5C254B007A6E53 /* TextApp.swift */,
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */,
); );
path = RippleChat; path = RippleChat;
sourceTree = "<group>"; sourceTree = "<group>";
@ -164,6 +163,7 @@
96BD33112A5C3FFC007A6E53 /* Views */ = { 96BD33112A5C3FFC007A6E53 /* Views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */,
96BD33122A5C400B007A6E53 /* FeedListView.swift */, 96BD33122A5C400B007A6E53 /* FeedListView.swift */,
96BD33152A5C403C007A6E53 /* PeeringView.swift */, 96BD33152A5C403C007A6E53 /* PeeringView.swift */,
96BD33172A5C404F007A6E53 /* FriendsListView.swift */, 96BD33172A5C404F007A6E53 /* FriendsListView.swift */,

View File

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

View File

@ -21,7 +21,6 @@ struct ContentView: View {
.imageScale(.large) .imageScale(.large)
.foregroundColor(.accentColor) .foregroundColor(.accentColor)
Text("Hello, world!") Text("Hello, world!")
Spacer()
Button("Save Feed") { Button("Save Feed") {
Task { Task {
do { do {
@ -36,12 +35,14 @@ struct ContentView: View {
} }
} }
.padding() .padding()
NavigationView { Spacer()
List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in NewFeedEntryView()
Text(peripheral) // NavigationView {
} // List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in
.navigationTitle("Peripherals") // Text(peripheral)
} // }
// .navigationTitle("Peripherals")
// }
} }

View File

@ -9,7 +9,7 @@ import SwiftUI
@main @main
struct RippleChatApp: App { struct RippleChatApp: App {
@State private var currentView: CurrentView = CurrentView.feeds //@State private var currentView: CurrentView = CurrentView.feeds
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {

View File

@ -8,7 +8,7 @@
import SwiftUI import SwiftUI
struct FeedListView: View { struct FeedListView: View {
@State var feeds: [Feed]
var body: some View { var body: some View {
Text("FeedListView") Text("FeedListView")
@ -17,6 +17,6 @@ struct FeedListView: View {
struct FeedListView_Previews: PreviewProvider { struct FeedListView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
FeedListView() FeedListView(feeds: [])
} }
} }

View File

@ -8,14 +8,20 @@
import SwiftUI import SwiftUI
struct NewFeedEntryView: View { struct NewFeedEntryView: View {
@State private var name: String = "Alice" @State private var newEntry: String = ""
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
TextField("Enter your name", text: $name) HStack {
Text("Hello, \(name)!") TextField("Enter your new feed message:", text: $newEntry)
Button(action: {}) {
Text("Send")
} }
} }
Text("New entry: \(newEntry)")
}
.padding()
}
} }
struct NewFeedEntryView_Previews: PreviewProvider { struct NewFeedEntryView_Previews: PreviewProvider {