diff --git a/Komusou/KomusouApp.swift b/Komusou/KomusouApp.swift index 175c4eb..6e7dede 100644 --- a/Komusou/KomusouApp.swift +++ b/Komusou/KomusouApp.swift @@ -9,10 +9,7 @@ import Combine import SwiftUI // TODO: -// - Reconnecting to Peripherals https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/BestPracticesForInteractingWithARemotePeripheralDevice/BestPracticesForInteractingWithARemotePeripheralDevice.html#//apple_ref/doc/uid/TP40013257-CH6-SW6 -// - ユーザがセンサーを選ぶ画面を作る → ユーザが選んだセンサーがあればそれに接続する ということをすればそれぞれのセンサーを扱うクラスを安全に分離できそう // - Mac対応 -// - Bluetoothが有効にされていないときの対応 // - i18n @main diff --git a/Komusou/PlayView.swift b/Komusou/PlayView.swift index 824d52d..80f2769 100644 --- a/Komusou/PlayView.swift +++ b/Komusou/PlayView.swift @@ -27,6 +27,12 @@ struct PlayView: View { .sheet(isPresented: $isSettingsPresented) { SettingsView() } +// .alert("Bluetoothを有効にしてください", isPresented: .constant(BluetoothManager.shared.isBluetoothEnabled)) { +// // TODO: 設定画面に飛ばす +// Button("OK") { +// print("TODO: 設定画面に飛ばす") +// } +// } message: {} } } diff --git a/Komusou/Settings/SensorSettingView.swift b/Komusou/Settings/SensorSettingView.swift index 369cd16..ed2409c 100644 --- a/Komusou/Settings/SensorSettingView.swift +++ b/Komusou/Settings/SensorSettingView.swift @@ -168,6 +168,9 @@ final class BluetoothManager: NSObject { static let shared = BluetoothManager() private static let kSavedSpeedSensorUUIDKey = "speed_sensor_uuid_key" + var isBluetoothEnabled: Bool { + centralManager.state == .poweredOn + } @Published private(set) var discoveredPeripherals = [UUID: CBPeripheral]() @@ -194,16 +197,12 @@ final class BluetoothManager: NSObject { private var speedSensorPromise: ConnectingWithPeripheralFuture.Promise? private let centralManager = CBCentralManager() - private var isBluetoothEnabled: Bool { - centralManager.state == .poweredOn - } private var cancellables = Set() override init() { super.init() - // TODO: 起動時の処理 - // Bluetoothの許可の確認 + // TODO: Bluetoothが有効にされているか確認する/ダイアログを出す centralManager.delegate = self