Skip to content

Commit 795fc38

Browse files
committed
Restore update functionality
1 parent e166f8e commit 795fc38

File tree

2 files changed

+69
-43
lines changed

2 files changed

+69
-43
lines changed

2002/dev_2002.patch

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ index 0b4cb551..9d97f342 100644
5252
ForEach(pluginMenuItems.filter {$0.section == .configuration}) { item in
5353
item.view
5454
}
55-
Submodule LoopKit 8e58b7e..eaa182f:
55+
Submodule LoopKit 8e58b7e..9e69b31:
5656
diff --git a/LoopKit/LoopKit.xcodeproj/project.pbxproj b/LoopKit/LoopKit.xcodeproj/project.pbxproj
5757
index bfdc9db..7dded80 100644
5858
--- a/LoopKit/LoopKit.xcodeproj/project.pbxproj
@@ -998,10 +998,10 @@ index 0000000..6de3598
998998
+}
999999
diff --git a/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift b/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift
10001000
new file mode 100644
1001-
index 0000000..3f99636
1001+
index 0000000..1c6244a
10021002
--- /dev/null
10031003
+++ b/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift
1004-
@@ -0,0 +1,160 @@
1004+
@@ -0,0 +1,173 @@
10051005
+//
10061006
+// ProfileView.swift
10071007
+// LoopKitUI
@@ -1022,9 +1022,17 @@ index 0000000..3f99636
10221022
+ @State private var newProfileName: String = ""
10231023
+ @State private var isAddingNewProfile = false
10241024
+ @State private var selectedProfileIndex: Int? = nil
1025-
+ @State private var showUpdateAlert = false
10261025
+ @State private var refreshID = UUID()
1027-
+ @State private var showInfoAlert = false
1026+
+
1027+
+ enum ActiveAlert: String, Identifiable {
1028+
+ case update, info
1029+
+
1030+
+ var id: String {
1031+
+ return self.rawValue
1032+
+ }
1033+
+ }
1034+
+ @State private var activeAlert: ActiveAlert?
1035+
+
10281036
+ public init(viewModel: ProfileViewModel) {
10291037
+ self.viewModel = viewModel
10301038
+ }
@@ -1085,7 +1093,7 @@ index 0000000..3f99636
10851093
+ Image(systemName: "plus")
10861094
+ }
10871095
+
1088-
+ Button(action: { showInfoAlert.toggle() }) {
1096+
+ Button(action: { activeAlert = .info }) {
10891097
+ Image(systemName: "info.circle")
10901098
+ .resizable()
10911099
+ .frame(width: 24, height: 24)
@@ -1098,22 +1106,27 @@ index 0000000..3f99636
10981106
+ .navigationBarHidden(false)
10991107
+ .background(Color(.systemGroupedBackground))
11001108
+ .onAppear {
1101-
+ showUpdateAlert = viewModel.isCurrentProfileOutOfSync()
1102-
+ }
1103-
+ .alert(isPresented: $showUpdateAlert) {
1104-
+ Alert(
1105-
+ title: Text("Profile Outdated"),
1106-
+ message: Text("The current therapy settings have changed. Do you want to update the profile named: \(viewModel.currentProfileName ?? "")?"),
1107-
+ primaryButton: .default(Text("Update")) {
1108-
+ viewModel.saveProfile(withName: viewModel.currentProfileName ?? "")
1109-
+ },
1110-
+ secondaryButton: .cancel()
1111-
+ )
1109+
+ if viewModel.isCurrentProfileOutOfSync() {
1110+
+ activeAlert = .update
1111+
+ }
11121112
+ }
1113-
+ .alert(isPresented: $showInfoAlert) {
1114-
+ Alert(title: Text("Information"),
1115-
+ message: Text("A checkmark next to a profile name indicates that it's the active one.\n\nUse ‘+’ to create a new profile capturing your glucose targets, carb ratios, basal rates, and insulin sensitivities.\n\nTap on any profile to review its settings in detail. In detail view, you can Load, Rename or Delete that particular profile.\n\nWant to change the order of profiles? Simply press and hold on a profile, then drag it to your desired position."),
1116-
+ dismissButton: .default(Text("Got it!")))
1113+
+
1114+
+ .alert(item: $activeAlert) { alertType in
1115+
+ switch alertType {
1116+
+ case .update:
1117+
+ return Alert(
1118+
+ title: Text("Profile Outdated"),
1119+
+ message: Text("The current therapy settings have changed. Do you want to update the profile named: \(viewModel.currentProfileName ?? "")?"),
1120+
+ primaryButton: .default(Text("Update")) {
1121+
+ viewModel.saveProfile(withName: viewModel.currentProfileName ?? "")
1122+
+ },
1123+
+ secondaryButton: .cancel()
1124+
+ )
1125+
+ case .info:
1126+
+ return Alert(title: Text("Information"),
1127+
+ message: Text("A checkmark next to a profile name indicates that it's the active one.\n\nUse ‘+’ to create a new profile capturing your glucose targets, carb ratios, basal rates, and insulin sensitivities.\n\nTap on any profile to review its settings in detail. In detail view, you can Load, Rename or Delete that particular profile.\n\nWant to change the order of profiles? Simply press and hold on a profile, then drag it to your desired position."),
1128+
+ dismissButton: .default(Text("Got it!")))
1129+
+ }
11171130
+ }
11181131
+
11191132
+ if isAddingNewProfile {

2002/main_2002.patch

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ index 90859273..187a17c1 100644
5252
ForEach(configurationMenuItemsForSupportPlugins) { item in
5353
item.view
5454
}
55-
Submodule LoopKit 9835a29..b041710:
55+
Submodule LoopKit 9835a29..d2042f9:
5656
diff --git a/LoopKit/LoopKit.xcodeproj/project.pbxproj b/LoopKit/LoopKit.xcodeproj/project.pbxproj
5757
index 6b13fc8..c6bcc64 100644
5858
--- a/LoopKit/LoopKit.xcodeproj/project.pbxproj
@@ -997,10 +997,10 @@ index 0000000..abe31ad
997997
+}
998998
diff --git a/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift b/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift
999999
new file mode 100644
1000-
index 0000000..5293e85
1000+
index 0000000..de24519
10011001
--- /dev/null
10021002
+++ b/LoopKit/LoopKitUI/Views/Settings Editors/ProfileView.swift
1003-
@@ -0,0 +1,160 @@
1003+
@@ -0,0 +1,173 @@
10041004
+//
10051005
+// ProfileView.swift
10061006
+// LoopKitUI
@@ -1021,9 +1021,17 @@ index 0000000..5293e85
10211021
+ @State private var newProfileName: String = ""
10221022
+ @State private var isAddingNewProfile = false
10231023
+ @State private var selectedProfileIndex: Int? = nil
1024-
+ @State private var showUpdateAlert = false
10251024
+ @State private var refreshID = UUID()
1026-
+ @State private var showInfoAlert = false
1025+
+
1026+
+ enum ActiveAlert: String, Identifiable {
1027+
+ case update, info
1028+
+
1029+
+ var id: String {
1030+
+ return self.rawValue
1031+
+ }
1032+
+ }
1033+
+ @State private var activeAlert: ActiveAlert?
1034+
+
10271035
+ public init(viewModel: ProfileViewModel) {
10281036
+ self.viewModel = viewModel
10291037
+ }
@@ -1083,8 +1091,8 @@ index 0000000..5293e85
10831091
+ Button(action: { withAnimation { isAddingNewProfile = true } }) {
10841092
+ Image(systemName: "plus")
10851093
+ }
1086-
+
1087-
+ Button(action: { showInfoAlert.toggle() }) {
1094+
+
1095+
+ Button(action: { activeAlert = .info }) {
10881096
+ Image(systemName: "info.circle")
10891097
+ .resizable()
10901098
+ .frame(width: 24, height: 24)
@@ -1097,22 +1105,27 @@ index 0000000..5293e85
10971105
+ .navigationBarHidden(false)
10981106
+ .background(Color(.systemGroupedBackground))
10991107
+ .onAppear {
1100-
+ showUpdateAlert = viewModel.isCurrentProfileOutOfSync()
1101-
+ }
1102-
+ .alert(isPresented: $showUpdateAlert) {
1103-
+ Alert(
1104-
+ title: Text("Profile Outdated"),
1105-
+ message: Text("The current therapy settings have changed. Do you want to update the profile named: \(viewModel.currentProfileName ?? "")?"),
1106-
+ primaryButton: .default(Text("Update")) {
1107-
+ viewModel.saveProfile(withName: viewModel.currentProfileName ?? "")
1108-
+ },
1109-
+ secondaryButton: .cancel()
1110-
+ )
1108+
+ if viewModel.isCurrentProfileOutOfSync() {
1109+
+ activeAlert = .update
1110+
+ }
11111111
+ }
1112-
+ .alert(isPresented: $showInfoAlert) {
1113-
+ Alert(title: Text("Information"),
1114-
+ message: Text("A checkmark next to a profile name indicates that it's the active one.\n\nUse ‘+’ to create a new profile capturing your glucose targets, carb ratios, basal rates, and insulin sensitivities.\n\nTap on any profile to review its settings in detail. In detail view, you can Load, Rename or Delete that particular profile.\n\nWant to change the order of profiles? Simply press and hold on a profile, then drag it to your desired position."),
1115-
+ dismissButton: .default(Text("Got it!")))
1112+
+
1113+
+ .alert(item: $activeAlert) { alertType in
1114+
+ switch alertType {
1115+
+ case .update:
1116+
+ return Alert(
1117+
+ title: Text("Profile Outdated"),
1118+
+ message: Text("The current therapy settings have changed. Do you want to update the profile named: \(viewModel.currentProfileName ?? "")?"),
1119+
+ primaryButton: .default(Text("Update")) {
1120+
+ viewModel.saveProfile(withName: viewModel.currentProfileName ?? "")
1121+
+ },
1122+
+ secondaryButton: .cancel()
1123+
+ )
1124+
+ case .info:
1125+
+ return Alert(title: Text("Information"),
1126+
+ message: Text("A checkmark next to a profile name indicates that it's the active one.\n\nUse ‘+’ to create a new profile capturing your glucose targets, carb ratios, basal rates, and insulin sensitivities.\n\nTap on any profile to review its settings in detail. In detail view, you can Load, Rename or Delete that particular profile.\n\nWant to change the order of profiles? Simply press and hold on a profile, then drag it to your desired position."),
1127+
+ dismissButton: .default(Text("Got it!")))
1128+
+ }
11161129
+ }
11171130
+
11181131
+ if isAddingNewProfile {

0 commit comments

Comments
 (0)