Skip to content

Commit

Permalink
align cgm & pump config NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
mountrcg committed May 19, 2024
1 parent e007bd7 commit 4bd48c4
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 136 deletions.
188 changes: 93 additions & 95 deletions FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,125 +30,123 @@ extension CGM {
// @AppStorage(UserDefaults.BTKey.cgmTransmitterDeviceAddress.rawValue) private var cgmTransmitterDeviceAddress: String? = nil

var body: some View {
NavigationView {
Form {
Section(header: Text("CGM")) {
Picker("Type", selection: $state.cgmCurrent) {
ForEach(state.listOfCGM) { type in
VStack(alignment: .leading) {
Text(type.displayName)
Text(type.subtitle).font(.caption).foregroundColor(.secondary)
}.tag(type)
}
Form {
Section(header: Text("CGM")) {
Picker("Type", selection: $state.cgmCurrent) {
ForEach(state.listOfCGM) { type in
VStack(alignment: .leading) {
Text(type.displayName)
Text(type.subtitle).font(.caption).foregroundColor(.secondary)
}.tag(type)
}
if let link = state.cgmCurrent.type.externalLink {
Button("About this source") {
UIApplication.shared.open(link, options: [:], completionHandler: nil)
}
}
if let link = state.cgmCurrent.type.externalLink {
Button("About this source") {
UIApplication.shared.open(link, options: [:], completionHandler: nil)
}
}
if state.cgmCurrent.type == .plugin {
Section {
Button("CGM Configuration") {
setupCGM.toggle()
}
}
if state.cgmCurrent.type == .plugin {
Section {
Button("CGM Configuration") {
setupCGM.toggle()
}
}
if state.cgmCurrent.type == .xdrip {
Section(header: Text("Heartbeat")) {
VStack(alignment: .leading) {
if let cgmTransmitterDeviceAddress = state.cgmTransmitterDeviceAddress {
Text("CGM address :")
Text(cgmTransmitterDeviceAddress)
} else {
Text("CGM is not used as heartbeat.")
}
}
if state.cgmCurrent.type == .xdrip {
Section(header: Text("Heartbeat")) {
VStack(alignment: .leading) {
if let cgmTransmitterDeviceAddress = state.cgmTransmitterDeviceAddress {
Text("CGM address :")
Text(cgmTransmitterDeviceAddress)
} else {
Text("CGM is not used as heartbeat.")
}
}
}
if state.cgmCurrent.type == .plugin && state.cgmCurrent.id.contains("Libre") {
Section(header: Text("Calibrations")) {
Text("Calibrations").navigationLink(to: .calibrations, from: self)
}
}
if state.cgmCurrent.type == .plugin && state.cgmCurrent.id.contains("Libre") {
Section(header: Text("Calibrations")) {
Text("Calibrations").navigationLink(to: .calibrations, from: self)
}
}

if state.cgmCurrent.type == .nightscout {
Section(header: Text("Nightscout")) {
if state.url != nil {
Button(state.url!.absoluteString) {
UIApplication.shared.open(state.url!, options: [:], completionHandler: nil)
}
} else {
Text("You need to configure Nightscout URL")
if state.cgmCurrent.type == .nightscout {
Section(header: Text("Nightscout")) {
if state.url != nil {
Button(state.url!.absoluteString) {
UIApplication.shared.open(state.url!, options: [:], completionHandler: nil)
}
} else {
Text("You need to configure Nightscout URL")
}
}
}

Section(header: Text("Calendar")) {
Toggle("Create Events in Calendar", isOn: $state.createCalendarEvents)
if state.calendarIDs.isNotEmpty {
Picker("Calendar", selection: $state.currentCalendarID) {
ForEach(state.calendarIDs, id: \.self) {
Text($0).tag($0)
}
Section(header: Text("Calendar")) {
Toggle("Create Events in Calendar", isOn: $state.createCalendarEvents)
if state.calendarIDs.isNotEmpty {
Picker("Calendar", selection: $state.currentCalendarID) {
ForEach(state.calendarIDs, id: \.self) {
Text($0).tag($0)
}
Toggle("Display Emojis as Labels", isOn: $state.displayCalendarEmojis)
Toggle("Display IOB and COB", isOn: $state.displayCalendarIOBandCOB)
} else if state.createCalendarEvents {
if #available(iOS 17.0, *) {
Text(
"If you are not seeing calendars to choose here, please go to Settings -> iAPS -> Calendars and change permissions to \"Full Access\""
).font(.footnote)
}
Toggle("Display Emojis as Labels", isOn: $state.displayCalendarEmojis)
Toggle("Display IOB and COB", isOn: $state.displayCalendarIOBandCOB)
} else if state.createCalendarEvents {
if #available(iOS 17.0, *) {
Text(
"If you are not seeing calendars to choose here, please go to Settings -> iAPS -> Calendars and change permissions to \"Full Access\""
).font(.footnote)

Button("Open Settings") {
// Get the settings URL and open it
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url)
}
Button("Open Settings") {
// Get the settings URL and open it
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url)
}
}
}
}

Section(header: Text("Experimental")) {
Toggle("Smooth Glucose Value", isOn: $state.smoothGlucose)
}
}
.scrollContentBackground(.hidden).background(color)
.onAppear(perform: configureView)
.navigationTitle("CGM")
.navigationBarTitleDisplayMode(.automatic)
.navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
.sheet(isPresented: $setupCGM) {
if let cgmFetchManager = state.cgmManager,
let cgmManager = cgmFetchManager.cgmManager,
state.cgmCurrent.type == cgmFetchManager.cgmGlucoseSourceType,
state.cgmCurrent.id == cgmFetchManager.cgmGlucosePluginId
{
CGMSettingsView(
cgmManager: cgmManager,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
unit: state.settingsManager.settings.units,
completionDelegate: state
)
} else {
CGMSetupView(
CGMType: state.cgmCurrent,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
unit: state.settingsManager.settings.units,
completionDelegate: state,
setupDelegate: state,
pluginCGMManager: self.state.pluginCGMManager
)
}
}
.onChange(of: setupCGM) { setupCGM in
state.setupCGM = setupCGM

Section(header: Text("Experimental")) {
Toggle("Smooth Glucose Value", isOn: $state.smoothGlucose)
}
.onChange(of: state.setupCGM) { setupCGM in
self.setupCGM = setupCGM
}
.scrollContentBackground(.hidden).background(color)
.onAppear(perform: configureView)
.navigationTitle("CGM")
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
.sheet(isPresented: $setupCGM) {
if let cgmFetchManager = state.cgmManager,
let cgmManager = cgmFetchManager.cgmManager,
state.cgmCurrent.type == cgmFetchManager.cgmGlucoseSourceType,
state.cgmCurrent.id == cgmFetchManager.cgmGlucosePluginId
{
CGMSettingsView(
cgmManager: cgmManager,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
unit: state.settingsManager.settings.units,
completionDelegate: state
)
} else {
CGMSetupView(
CGMType: state.cgmCurrent,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
unit: state.settingsManager.settings.units,
completionDelegate: state,
setupDelegate: state,
pluginCGMManager: self.state.pluginCGMManager
)
}
}
.onChange(of: setupCGM) { setupCGM in
state.setupCGM = setupCGM
}
.onChange(of: state.setupCGM) { setupCGM in
self.setupCGM = setupCGM
}
}
}
}
80 changes: 39 additions & 41 deletions FreeAPS/Sources/Modules/PumpConfig/View/PumpConfigRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,51 @@ extension PumpConfig {
}

var body: some View {
NavigationView {
Form {
Section(header: Text("Model")) {
if let pumpState = state.pumpState {
Button {
state.setupPump = true
} label: {
HStack {
Image(uiImage: pumpState.image ?? UIImage()).padding()
Text(pumpState.name)
}
Form {
Section(header: Text("Model")) {
if let pumpState = state.pumpState {
Button {
state.setupPump = true
} label: {
HStack {
Image(uiImage: pumpState.image ?? UIImage()).padding()
Text(pumpState.name)
}
if state.alertNotAck {
Spacer()
Button("Acknowledge all alerts") { state.ack() }
}
} else {
Button("Add Medtronic") { state.addPump(.minimed) }
Button("Add Omnipod") { state.addPump(.omnipod) }
Button("Add Omnipod Dash") { state.addPump(.omnipodBLE) }
Button("Add Simulator") { state.addPump(.simulator) }
}
}
}
.scrollContentBackground(.hidden).background(color)
.onAppear(perform: configureView)
.navigationTitle("Pump config")
.navigationBarTitleDisplayMode(.automatic)
.sheet(isPresented: $state.setupPump) {
if let pumpManager = state.provider.apsManager.pumpManager {
PumpSettingsView(
pumpManager: pumpManager,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
completionDelegate: state,
setupDelegate: state
)
if state.alertNotAck {
Spacer()
Button("Acknowledge all alerts") { state.ack() }
}
} else {
PumpSetupView(
pumpType: state.setupPumpType,
pumpInitialSettings: state.initialSettings,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
completionDelegate: state,
setupDelegate: state
)
Button("Add Medtronic") { state.addPump(.minimed) }
Button("Add Omnipod") { state.addPump(.omnipod) }
Button("Add Omnipod Dash") { state.addPump(.omnipodBLE) }
Button("Add Simulator") { state.addPump(.simulator) }
}
}
}
.scrollContentBackground(.hidden).background(color)
.onAppear(perform: configureView)
.navigationTitle("Pump config")
.navigationBarTitleDisplayMode(.automatic)
.sheet(isPresented: $state.setupPump) {
if let pumpManager = state.provider.apsManager.pumpManager {
PumpSettingsView(
pumpManager: pumpManager,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
completionDelegate: state,
setupDelegate: state
)
} else {
PumpSetupView(
pumpType: state.setupPumpType,
pumpInitialSettings: state.initialSettings,
bluetoothManager: state.provider.apsManager.bluetoothManager!,
completionDelegate: state,
setupDelegate: state
)
}
}
}
}
}

0 comments on commit 4bd48c4

Please sign in to comment.