Skip to content

Commit

Permalink
Merge pull request #8 from avouspierre/dev-aISF-closeButton
Browse files Browse the repository at this point in the history
fix the issue to close the screen CGM and pump config
  • Loading branch information
mountrcg authored Oct 28, 2024
2 parents 4491a82 + 8ca5ad1 commit 4ef2249
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions FreeAPS/Sources/Modules/Base/BaseStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BaseStateModel<Provider>: StateModel, Injectable where Provider: FreeAPS.P

func hideModal() {
router.mainModalScreen.send(nil)
router.mainSecondaryModalView.send(nil)
}

func view(for screen: Screen) -> AnyView {
Expand Down
4 changes: 2 additions & 2 deletions FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ extension CGM {
.background(color)
.onAppear(perform: configureView)
.navigationTitle("CGM")
.navigationBarTitleDisplayMode(.inline)
// .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
.navigationBarTitleDisplayMode(.automatic)
.navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
.sheet(isPresented: $setupCGM) {
if let cgmFetchManager = state.cgmManager,
let cgmManager = cgmFetchManager.cgmManager,
Expand Down
2 changes: 2 additions & 0 deletions FreeAPS/Sources/Modules/Home/HomeStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ extension Home {
setupDelegate: self
).asAny()
self.router.mainSecondaryModalView.send(view)
} else if show {
self.router.mainSecondaryModalView.send(self.router.view(for: .pumpConfigDirect))
} else {
self.router.mainSecondaryModalView.send(nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Swinject
extension PumpConfig {
struct RootView: BaseView {
let resolver: Resolver
let displayClose: Bool
@StateObject var state = StateModel()

@Environment(\.colorScheme) var colorScheme
Expand Down Expand Up @@ -54,6 +55,7 @@ extension PumpConfig {
.onAppear(perform: configureView)
.navigationTitle("Pump config")
.navigationBarTitleDisplayMode(.automatic)
.navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
.sheet(isPresented: $state.setupPump) {
if let pumpManager = state.provider.apsManager.pumpManager {
PumpSettingsView(
Expand Down
5 changes: 4 additions & 1 deletion FreeAPS/Sources/Router/Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum Screen: Identifiable, Hashable {
case nighscoutConfig
case nighscoutConfigDirect
case pumpConfig
case pumpConfigDirect
case pumpSettingsEditor
case basalProfileEditor
case isfEditor
Expand Down Expand Up @@ -60,7 +61,9 @@ extension Screen {
case .nighscoutConfigDirect:
NightscoutConfig.RootView(resolver: resolver, displayClose: true)
case .pumpConfig:
PumpConfig.RootView(resolver: resolver)
PumpConfig.RootView(resolver: resolver, displayClose: false)
case .pumpConfigDirect:
PumpConfig.RootView(resolver: resolver, displayClose: true)
case .pumpSettingsEditor:
PumpSettingsEditor.RootView(resolver: resolver)
case .basalProfileEditor:
Expand Down

0 comments on commit 4ef2249

Please sign in to comment.