Refactor Names

This commit is contained in:
Sebastian Lenzlinger 2023-07-16 16:39:06 +02:00
parent 9bf4ffe51d
commit 275967989b
4 changed files with 20 additions and 24 deletions

View File

@ -15,11 +15,10 @@
96454F362A558EBE0040BEBD /* RippleChatUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96454F352A558EBE0040BEBD /* RippleChatUITests.swift */; };
96454F382A558EBE0040BEBD /* RippleChatUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96454F372A558EBE0040BEBD /* RippleChatUITestsLaunchTests.swift */; };
96454F452A5593900040BEBD /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 96454F442A5593900040BEBD /* .gitignore */; };
96BD330E2A5C254B007A6E53 /* TextApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD330D2A5C254B007A6E53 /* TextApp.swift */; };
96BD33102A5C27B0007A6E53 /* NewFeedEntryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */; };
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33122A5C400B007A6E53 /* FeedListView.swift */; };
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33152A5C403C007A6E53 /* PeeringView.swift */; };
F581F59B2A5AE72F0081C383 /* BluetoothController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F581F59A2A5AE72F0081C383 /* BluetoothController.swift */; };
96BD33162A5C403C007A6E53 /* DiscoveryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BD33152A5C403C007A6E53 /* DiscoveryView.swift */; };
F581F59B2A5AE72F0081C383 /* BTCentral.swift in Sources */ = {isa = PBXBuildFile; fileRef = F581F59A2A5AE72F0081C383 /* BTCentral.swift */; };
F5847B622A599BF4009E28D4 /* Bodyy.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B612A599BF4009E28D4 /* Bodyy.swift */; };
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B632A599CC3009E28D4 /* LogEntry.swift */; };
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5847B652A599EA4009E28D4 /* Feed.swift */; };
@ -63,11 +62,10 @@
96454F352A558EBE0040BEBD /* RippleChatUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RippleChatUITests.swift; sourceTree = "<group>"; };
96454F372A558EBE0040BEBD /* RippleChatUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RippleChatUITestsLaunchTests.swift; sourceTree = "<group>"; };
96454F442A5593900040BEBD /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
96BD330D2A5C254B007A6E53 /* TextApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextApp.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>"; };
96BD33152A5C403C007A6E53 /* PeeringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeeringView.swift; sourceTree = "<group>"; };
F581F59A2A5AE72F0081C383 /* BluetoothController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothController.swift; sourceTree = "<group>"; };
96BD33152A5C403C007A6E53 /* DiscoveryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryView.swift; sourceTree = "<group>"; };
F581F59A2A5AE72F0081C383 /* BTCentral.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTCentral.swift; sourceTree = "<group>"; };
F5847B612A599BF4009E28D4 /* Bodyy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bodyy.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>"; };
@ -135,7 +133,7 @@
96454F1A2A558EBC0040BEBD /* RippleChatApp.swift */,
96454F1C2A558EBC0040BEBD /* ContentView.swift */,
96BD33112A5C3FFC007A6E53 /* Views */,
F581F59A2A5AE72F0081C383 /* BluetoothController.swift */,
F581F59A2A5AE72F0081C383 /* BTCentral.swift */,
F5A4B1222A5D5F8B00F5AE01 /* BTPeripheral.swift */,
96454F1E2A558EBD0040BEBD /* Assets.xcassets */,
96454F202A558EBD0040BEBD /* Preview Content */,
@ -143,7 +141,6 @@
F5847B632A599CC3009E28D4 /* LogEntry.swift */,
F5847B652A599EA4009E28D4 /* Feed.swift */,
F5847B692A59AB24009E28D4 /* FeedStore.swift */,
96BD330D2A5C254B007A6E53 /* TextApp.swift */,
F5A4B1242A5D7A8D00F5AE01 /* DataStore.swift */,
);
path = RippleChat;
@ -179,7 +176,7 @@
children = (
96BD330F2A5C27B0007A6E53 /* NewFeedEntryView.swift */,
96BD33122A5C400B007A6E53 /* FeedListView.swift */,
96BD33152A5C403C007A6E53 /* PeeringView.swift */,
96BD33152A5C403C007A6E53 /* DiscoveryView.swift */,
F5A4B1202A5D4D1F00F5AE01 /* SettingsView.swift */,
F5A4B1262A5D861E00F5AE01 /* SettingsEditView.swift */,
F5F1419B2A5EFA3600C81B1A /* LogEntryView.swift */,
@ -322,7 +319,7 @@
buildActionMask = 2147483647;
files = (
F5847B622A599BF4009E28D4 /* Bodyy.swift in Sources */,
96BD33162A5C403C007A6E53 /* PeeringView.swift in Sources */,
96BD33162A5C403C007A6E53 /* DiscoveryView.swift in Sources */,
F5847B662A599EA4009E28D4 /* Feed.swift in Sources */,
96BD33132A5C400B007A6E53 /* FeedListView.swift in Sources */,
F5847B642A599CC3009E28D4 /* LogEntry.swift in Sources */,
@ -334,10 +331,9 @@
F5A4B1272A5D861E00F5AE01 /* SettingsEditView.swift in Sources */,
F59375722A5FF344001FA46A /* FeedDetailView.swift in Sources */,
F5F1419E2A5EFA4700C81B1A /* FeedCardView.swift in Sources */,
F581F59B2A5AE72F0081C383 /* BluetoothController.swift in Sources */,
F581F59B2A5AE72F0081C383 /* BTCentral.swift in Sources */,
96454F1D2A558EBC0040BEBD /* ContentView.swift in Sources */,
F5A4B1212A5D4D1F00F5AE01 /* SettingsView.swift in Sources */,
96BD330E2A5C254B007A6E53 /* TextApp.swift in Sources */,
96454F1B2A558EBC0040BEBD /* RippleChatApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -8,7 +8,7 @@
import SwiftUI
import CoreBluetooth
class BluetoothController: NSObject, ObservableObject {
class BTCentral: NSObject, ObservableObject {
private var centralManager: CBCentralManager?
private var peripherals: [CBPeripheral] = []
@Published var peripheralNames: [String] = []
@ -27,7 +27,7 @@ class BluetoothController: NSObject, ObservableObject {
// }
}
extension BluetoothController: CBCentralManagerDelegate, CBPeripheralDelegate {
extension BTCentral: CBCentralManagerDelegate, CBPeripheralDelegate {
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if central.state == .poweredOn {

View File

@ -11,7 +11,7 @@ import CoreBluetooth
struct ContentView: View {
@State var currentView = 0
@EnvironmentObject var dataStore: DataStore
@StateObject private var bluetoothController = BluetoothController()
@StateObject private var bluetoothController = BTCentral()
@StateObject private var bluetoothPeripheral = BluetoothPeripheral()
@Environment(\.scenePhase) private var scenePhase
let saveAction: ()->Void
@ -20,7 +20,7 @@ struct ContentView: View {
VStack {
switch self.currentView {
case 0:
PeeringView()
DiscoveryView()
.environmentObject(dataStore)
.environmentObject(bluetoothController)
.environmentObject(bluetoothPeripheral)

View File

@ -7,17 +7,17 @@
import SwiftUI
struct PeeringView: View {
struct DiscoveryView: View {
@EnvironmentObject var dataStore: DataStore
@EnvironmentObject var btController: BluetoothController
@EnvironmentObject var btCentral: BTCentral
@EnvironmentObject var btPeripheral: BluetoothPeripheral
var body: some View {
NavigationStack {
List(btController.peripheralNames, id: \.self) { peripheral in
List(btCentral.peripheralNames, id: \.self) { peripheral in
Text(peripheral)
}
.navigationTitle("Peering")
.navigationTitle("Peer Discovery")
.navigationViewStyle(StackNavigationViewStyle())
List {
ForEach(btPeripheral.wantVector.friends.keys.sorted(), id: \.self) { friend in
@ -34,7 +34,7 @@ struct PeeringView: View {
combinedDict[dataStore.personalFeed.feedID] = dataStore.personalFeed.feed.count
let WANT_msg = WantMessage(friends: combinedDict)
let encoded_msg = try JSONEncoder().encode(WANT_msg)
btController.writeToCharacteristics(message: String(data: encoded_msg, encoding: .utf8)!)
btCentral.writeToCharacteristics(message: String(data: encoded_msg, encoding: .utf8)!)
//btController.writeToCharacteristics(message: "Test")
print("Pressed Button")
} catch {
@ -62,11 +62,11 @@ struct PeeringView: View {
}
}
struct PeeringView_Previews: PreviewProvider {
struct DiscoveryView_Previews: PreviewProvider {
static var previews: some View {
PeeringView()
DiscoveryView()
.environmentObject(BluetoothPeripheral())
.environmentObject(BluetoothController())
.environmentObject(BTCentral())
}
}