|
@@ -38,10 +38,50 @@ extension CarbRatioEditor {
|
|
|
return formatter
|
|
return formatter
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var body: some View {
|
|
|
|
|
- Form {
|
|
|
|
|
|
|
+ var saveButton: some View {
|
|
|
|
|
+ ZStack {
|
|
|
let shouldDisableButton = state.shouldDisplaySaving || state.items.isEmpty || !state.hasChanges
|
|
let shouldDisableButton = state.shouldDisplaySaving || state.items.isEmpty || !state.hasChanges
|
|
|
|
|
|
|
|
|
|
+ Rectangle()
|
|
|
|
|
+ .frame(width: UIScreen.main.bounds.width, height: 65)
|
|
|
|
|
+ .foregroundStyle(colorScheme == .dark ? Color.bgDarkerDarkBlue : Color.white)
|
|
|
|
|
+ .background(.thinMaterial)
|
|
|
|
|
+ .opacity(0.8)
|
|
|
|
|
+ .clipShape(Rectangle())
|
|
|
|
|
+
|
|
|
|
|
+ Group {
|
|
|
|
|
+ HStack {
|
|
|
|
|
+ HStack {
|
|
|
|
|
+ Button {
|
|
|
|
|
+ let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
|
|
|
|
|
+ impactHeavy.impactOccurred()
|
|
|
|
|
+ state.save()
|
|
|
|
|
+
|
|
|
|
|
+ // deactivate saving display after 1.25 seconds
|
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
|
|
|
|
|
+ state.shouldDisplaySaving = false
|
|
|
|
|
+ }
|
|
|
|
|
+ } label: {
|
|
|
|
|
+ HStack {
|
|
|
|
|
+ if state.shouldDisplaySaving {
|
|
|
|
|
+ ProgressView().padding(.trailing, 10)
|
|
|
|
|
+ }
|
|
|
|
|
+ Text(state.shouldDisplaySaving ? "Saving..." : "Save")
|
|
|
|
|
+ }.padding(10)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
|
|
|
|
|
+ .disabled(shouldDisableButton)
|
|
|
|
|
+ .background(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
|
|
|
|
|
+ .tint(.white)
|
|
|
|
|
+ .clipShape(RoundedRectangle(cornerRadius: 8))
|
|
|
|
|
+ }
|
|
|
|
|
+ }.padding(5)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var body: some View {
|
|
|
|
|
+ Form {
|
|
|
if let autotune = state.autotune, !state.settingsManager.settings.onlyAutotuneBasals {
|
|
if let autotune = state.autotune, !state.settingsManager.settings.onlyAutotuneBasals {
|
|
|
Section(header: Text("Autotune")) {
|
|
Section(header: Text("Autotune")) {
|
|
|
HStack {
|
|
HStack {
|
|
@@ -56,31 +96,8 @@ extension CarbRatioEditor {
|
|
|
Section(header: Text("Schedule")) {
|
|
Section(header: Text("Schedule")) {
|
|
|
list
|
|
list
|
|
|
}.listRowBackground(Color.chart)
|
|
}.listRowBackground(Color.chart)
|
|
|
-
|
|
|
|
|
- Section {
|
|
|
|
|
- HStack {
|
|
|
|
|
- if state.shouldDisplaySaving {
|
|
|
|
|
- ProgressView().padding(.trailing, 10)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Button {
|
|
|
|
|
- let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
|
|
|
|
|
- impactHeavy.impactOccurred()
|
|
|
|
|
- state.save()
|
|
|
|
|
-
|
|
|
|
|
- // deactivate saving display after 1.25 seconds
|
|
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
|
|
|
|
|
- state.shouldDisplaySaving = false
|
|
|
|
|
- }
|
|
|
|
|
- } label: {
|
|
|
|
|
- Text(state.shouldDisplaySaving ? "Saving..." : "Save")
|
|
|
|
|
- }
|
|
|
|
|
- .disabled(shouldDisableButton)
|
|
|
|
|
- .frame(maxWidth: .infinity, alignment: .center)
|
|
|
|
|
- .tint(.white)
|
|
|
|
|
- }
|
|
|
|
|
- }.listRowBackground(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ .safeAreaInset(edge: .bottom, spacing: 30) { saveButton }
|
|
|
.scrollContentBackground(.hidden).background(color)
|
|
.scrollContentBackground(.hidden).background(color)
|
|
|
.onAppear(perform: configureView)
|
|
.onAppear(perform: configureView)
|
|
|
.navigationTitle("Carb Ratios")
|
|
.navigationTitle("Carb Ratios")
|