Fixed Different Views and switching between them via the toolbar
This commit is contained in:
parent
988dca5ff1
commit
b71426d6b9
@ -19,13 +19,13 @@
|
|||||||
96BD33102A5C27B0007A6E53 /* NewFeedEntryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */; };
|
96BD33102A5C27B0007A6E53 /* NewFeedEntryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */; };
|
||||||
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33122A5C400B007A6E53 /* FeedListView.swift */; };
|
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33122A5C400B007A6E53 /* FeedListView.swift */; };
|
||||||
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33152A5C403C007A6E53 /* PeeringView.swift */; };
|
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33152A5C403C007A6E53 /* PeeringView.swift */; };
|
||||||
96BD33182A5C404F007A6E53 /* FriendsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33172A5C404F007A6E53 /* FriendsListView.swift */; };
|
|
||||||
F581F59B2A5AE72F0081C383 /* BluetoothViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F581F59A2A5AE72F0081C383 /* BluetoothViewModel.swift */; };
|
F581F59B2A5AE72F0081C383 /* BluetoothViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F581F59A2A5AE72F0081C383 /* BluetoothViewModel.swift */; };
|
||||||
F5847B622A599BF4009E28D4 /* Body.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B612A599BF4009E28D4 /* Body.swift */; };
|
F5847B622A599BF4009E28D4 /* Body.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B612A599BF4009E28D4 /* Body.swift */; };
|
||||||
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B632A599CC3009E28D4 /* LogEntry.swift */; };
|
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B632A599CC3009E28D4 /* LogEntry.swift */; };
|
||||||
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B652A599EA4009E28D4 /* Feed.swift */; };
|
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B652A599EA4009E28D4 /* Feed.swift */; };
|
||||||
F5847B6A2A59AB24009E28D4 /* FeedStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B692A59AB24009E28D4 /* FeedStore.swift */; };
|
F5847B6A2A59AB24009E28D4 /* FeedStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B692A59AB24009E28D4 /* FeedStore.swift */; };
|
||||||
F58EB2D02A5590E800E22DA6 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = F58EB2CF2A5590E800E22DA6 /* README.md */; };
|
F58EB2D02A5590E800E22DA6 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = F58EB2CF2A5590E800E22DA6 /* README.md */; };
|
||||||
|
F5A4B1212A5D4D1F00F5AE01 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5A4B1202A5D4D1F00F5AE01 /* SettingsView.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -61,13 +61,13 @@
|
|||||||
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewFeedEntryView.swift; sourceTree = "<group>"; };
|
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewFeedEntryView.swift; sourceTree = "<group>"; };
|
||||||
96BD33122A5C400B007A6E53 /* FeedListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListView.swift; sourceTree = "<group>"; };
|
96BD33122A5C400B007A6E53 /* FeedListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListView.swift; sourceTree = "<group>"; };
|
||||||
96BD33152A5C403C007A6E53 /* PeeringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeeringView.swift; sourceTree = "<group>"; };
|
96BD33152A5C403C007A6E53 /* PeeringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeeringView.swift; sourceTree = "<group>"; };
|
||||||
96BD33172A5C404F007A6E53 /* FriendsListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsListView.swift; sourceTree = "<group>"; };
|
|
||||||
F581F59A2A5AE72F0081C383 /* BluetoothViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothViewModel.swift; sourceTree = "<group>"; };
|
F581F59A2A5AE72F0081C383 /* BluetoothViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothViewModel.swift; sourceTree = "<group>"; };
|
||||||
F5847B612A599BF4009E28D4 /* Body.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Body.swift; sourceTree = "<group>"; };
|
F5847B612A599BF4009E28D4 /* Body.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Body.swift; sourceTree = "<group>"; };
|
||||||
F5847B632A599CC3009E28D4 /* LogEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogEntry.swift; sourceTree = "<group>"; };
|
F5847B632A599CC3009E28D4 /* LogEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogEntry.swift; sourceTree = "<group>"; };
|
||||||
F5847B652A599EA4009E28D4 /* Feed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
|
F5847B652A599EA4009E28D4 /* Feed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
|
||||||
F5847B692A59AB24009E28D4 /* FeedStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedStore.swift; sourceTree = "<group>"; };
|
F5847B692A59AB24009E28D4 /* FeedStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedStore.swift; sourceTree = "<group>"; };
|
||||||
F58EB2CF2A5590E800E22DA6 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
F58EB2CF2A5590E800E22DA6 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||||
|
F5A4B1202A5D4D1F00F5AE01 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -166,7 +166,7 @@
|
|||||||
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */,
|
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */,
|
||||||
96BD33122A5C400B007A6E53 /* FeedListView.swift */,
|
96BD33122A5C400B007A6E53 /* FeedListView.swift */,
|
||||||
96BD33152A5C403C007A6E53 /* PeeringView.swift */,
|
96BD33152A5C403C007A6E53 /* PeeringView.swift */,
|
||||||
96BD33172A5C404F007A6E53 /* FriendsListView.swift */,
|
F5A4B1202A5D4D1F00F5AE01 /* SettingsView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -305,7 +305,6 @@
|
|||||||
files = (
|
files = (
|
||||||
F5847B622A599BF4009E28D4 /* Body.swift in Sources */,
|
F5847B622A599BF4009E28D4 /* Body.swift in Sources */,
|
||||||
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */,
|
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */,
|
||||||
96BD33182A5C404F007A6E53 /* FriendsListView.swift in Sources */,
|
|
||||||
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */,
|
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */,
|
||||||
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */,
|
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */,
|
||||||
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */,
|
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */,
|
||||||
@ -313,6 +312,7 @@
|
|||||||
F5847B6A2A59AB24009E28D4 /* FeedStore.swift in Sources */,
|
F5847B6A2A59AB24009E28D4 /* FeedStore.swift in Sources */,
|
||||||
F581F59B2A5AE72F0081C383 /* BluetoothViewModel.swift in Sources */,
|
F581F59B2A5AE72F0081C383 /* BluetoothViewModel.swift in Sources */,
|
||||||
96454F1D2A558EBC0040BEBD /* ContentView.swift in Sources */,
|
96454F1D2A558EBC0040BEBD /* ContentView.swift in Sources */,
|
||||||
|
F5A4B1212A5D4D1F00F5AE01 /* SettingsView.swift in Sources */,
|
||||||
96BD330E2A5C254B007A6E53 /* TextApp.swift in Sources */,
|
96BD330E2A5C254B007A6E53 /* TextApp.swift in Sources */,
|
||||||
96454F1B2A558EBC0040BEBD /* RippleChatApp.swift in Sources */,
|
96454F1B2A558EBC0040BEBD /* RippleChatApp.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -9,47 +9,55 @@ import SwiftUI
|
|||||||
import CoreBluetooth
|
import CoreBluetooth
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@ObservedObject private var bluetoothViewModel = BluetoothViewModel()
|
@State var currentView = 0
|
||||||
@StateObject private var store = FeedStore(feed: Feed.sampleFeed)
|
|
||||||
private var feedStores = [FeedStore(feed: Feed.sampleFeed), FeedStore(feed: Feed.sampleFeed2)]
|
|
||||||
//@Binding var currentView: CurrentView
|
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "globe")
|
switch self.currentView {
|
||||||
.imageScale(.large)
|
case 0: PeeringView()
|
||||||
.foregroundColor(.accentColor)
|
case 1: FeedListView(feeds: [])
|
||||||
Text("Hello, world!")
|
case 2: SettingsView()
|
||||||
Button("Save Feed") {
|
default:
|
||||||
Task {
|
FeedListView(feeds: [])
|
||||||
do {
|
}
|
||||||
// try await store.save(feed: Feed.sampleFeed)
|
}
|
||||||
for feed in feedStores {
|
.padding()
|
||||||
try await feed.save(feed: feed.feed)
|
.toolbar {
|
||||||
}
|
ToolbarItemGroup(placement: .bottomBar) {
|
||||||
} catch {
|
Button(action: {
|
||||||
fatalError(error.localizedDescription)
|
self.currentView = 0
|
||||||
|
}) {
|
||||||
|
VStack {
|
||||||
|
Label("Discovery", systemImage: "dot.radiowaves.left.and.right")
|
||||||
|
Text("Discovery")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
Button(action: {
|
||||||
|
self.currentView = 1
|
||||||
|
}) {
|
||||||
|
VStack {
|
||||||
|
Label("Feeds", systemImage: "person.2")
|
||||||
|
Text("Feeds")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
Button(action: {
|
||||||
|
self.currentView = 2
|
||||||
|
}) {
|
||||||
|
VStack {
|
||||||
|
Label("Settings", systemImage: "gear")
|
||||||
|
Text("Settings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
Spacer()
|
|
||||||
NewFeedEntryView()
|
|
||||||
// NavigationView {
|
|
||||||
// List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in
|
|
||||||
// Text(peripheral)
|
|
||||||
// }
|
|
||||||
// .navigationTitle("Peripherals")
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
public static var cv = CurrentView.feeds
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ContentView()
|
ContentView()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,42 +9,10 @@ import SwiftUI
|
|||||||
|
|
||||||
@main
|
@main
|
||||||
struct RippleChatApp: App {
|
struct RippleChatApp: App {
|
||||||
//@State private var currentView: CurrentView = CurrentView.feeds
|
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
ContentView()
|
ContentView()
|
||||||
.toolbar {
|
|
||||||
ToolbarItemGroup(placement: .bottomBar) {
|
|
||||||
Button(action: {}) {
|
|
||||||
VStack {
|
|
||||||
Label("Discovery", systemImage: "dot.radiowaves.left.and.right")
|
|
||||||
Text("Discovery")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
Button(action: {}) {
|
|
||||||
VStack {
|
|
||||||
Label("Discovery", systemImage: "person.2")
|
|
||||||
Text("Feeds")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
Button(action: {}) {
|
|
||||||
VStack {
|
|
||||||
Label("Discovery", systemImage: "gear")
|
|
||||||
Text("Settings")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CurrentView {
|
|
||||||
case peers
|
|
||||||
case feeds
|
|
||||||
case friends
|
|
||||||
case settings
|
|
||||||
}
|
|
||||||
|
|||||||
@ -9,9 +9,26 @@ import SwiftUI
|
|||||||
|
|
||||||
struct FeedListView: View {
|
struct FeedListView: View {
|
||||||
@State var feeds: [Feed]
|
@State var feeds: [Feed]
|
||||||
|
@StateObject var store = FeedStore(feed: Feed.sampleFeed)
|
||||||
|
var feedStores = [FeedStore(feed: Feed.sampleFeed), FeedStore(feed: Feed.sampleFeed2)]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text("FeedListView")
|
Text("FeedListView")
|
||||||
|
Image(systemName: "globe")
|
||||||
|
.imageScale(.large)
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
Text("Hello, world!")
|
||||||
|
Button("Save Feed") {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
for feed in feedStores {
|
||||||
|
try await feed.save(feed: feed.feed)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
fatalError(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,16 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct PeeringView: View {
|
struct PeeringView: View {
|
||||||
|
@ObservedObject private var bluetoothViewModel = BluetoothViewModel()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text("Peering View")
|
Text("Peering View")
|
||||||
|
NavigationView {
|
||||||
|
List(bluetoothViewModel.peripheralNames, id: \.self) { peripheral in
|
||||||
|
Text(peripheral)
|
||||||
|
}
|
||||||
|
.navigationTitle("Peripherals")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
RippleChat/Views/SettingsView.swift
Normal file
20
RippleChat/Views/SettingsView.swift
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// SettingsView.swift
|
||||||
|
// RippleChat
|
||||||
|
//
|
||||||
|
// Created by Severin Memmishofer on 11.07.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct SettingsView: View {
|
||||||
|
var body: some View {
|
||||||
|
Text("Hello, Settings!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SettingsView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
SettingsView()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user