Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions LoopFollow/Settings/SettingsMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import SwiftUI
import UIKit

struct SettingsMenuView: View {
// MARK: – Call-backs
// MARK: - Observed Objects

let onNightscoutVisibilityChange: (_ enabled: Bool) -> Void
@ObservedObject private var nightscoutURL = Storage.shared.url

// MARK: – Local state

Expand Down Expand Up @@ -45,7 +45,7 @@ struct SettingsMenuView: View {
path.append(Sheet.graph)
}

if IsNightscoutEnabled() {
if !nightscoutURL.value.isEmpty {
NavigationRow(title: "Information Display Settings",
icon: "info.circle")
{
Expand Down Expand Up @@ -154,9 +154,6 @@ struct SettingsMenuView: View {
path.append(Sheet.dexcom)
}
}
.onAppear {
onNightscoutVisibilityChange(IsNightscoutEnabled())
}
}

@ViewBuilder
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/Storage/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
*/

class Storage {
var remoteType = StorageValue<RemoteType>(key: "remoteType", defaultValue: .nightscout)
var remoteType = StorageValue<RemoteType>(key: "remoteType", defaultValue: .none)
var deviceToken = StorageValue<String>(key: "deviceToken", defaultValue: "")
var expirationDate = StorageValue<Date?>(key: "expirationDate", defaultValue: nil)
var sharedSecret = StorageValue<String>(key: "sharedSecret", defaultValue: "")
Expand Down
7 changes: 7 additions & 0 deletions LoopFollow/ViewControllers/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
}
.store(in: &cancellables)

Storage.shared.url.$value
.receive(on: DispatchQueue.main)
.sink { [weak self] value in
self?.tabBarController?.tabBar.items?[3].isEnabled = !value.isEmpty
}
.store(in: &cancellables)

updateQuickActions()

speechSynthesizer.delegate = self
Expand Down
5 changes: 1 addition & 4 deletions LoopFollow/ViewControllers/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ final class SettingsViewController: UIViewController {
super.viewDidLoad()

// Build SwiftUI menu
host = UIHostingController(
rootView: SettingsMenuView { [weak self] nightscoutEnabled in
self?.tabBarController?.tabBar.items?[3].isEnabled = nightscoutEnabled
})
host = UIHostingController(rootView: SettingsMenuView())

// Dark-mode override
if Storage.shared.forceDarkMode.value {
Expand Down