Skip to content
Open
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
37 changes: 21 additions & 16 deletions LoopFollow/Remote/LoopAPNS/LoopAPNSBolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,6 @@ struct LoopAPNSBolusView: View {
}
}

Section {
Button(action: sendInsulin) {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending...")
}
} else {
Text("Send Insulin")
}
}
.disabled(insulinAmount.doubleValue(for: .internationalUnit()) <= 0 || isLoading || isTOTPBlocked)
.frame(maxWidth: .infinity)
}

// TOTP Blocking Warning Section
if isTOTPBlocked && showTOTPWarning {
Section {
Expand Down Expand Up @@ -168,6 +152,27 @@ struct LoopAPNSBolusView: View {
}
}
}
.safeAreaInset(edge: .bottom) {
Button(action: sendInsulin) {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending...")
}
.frame(maxWidth: .infinity)
} else {
Text("Send Insulin")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
.disabled(insulinAmount.doubleValue(for: .internationalUnit()) <= 0 || isLoading || isTOTPBlocked)
.padding(.horizontal)
.padding(.vertical, 8)
.background(.bar)
}
.navigationTitle("Insulin")
.navigationBarTitleDisplayMode(.inline)
}
Expand Down
37 changes: 21 additions & 16 deletions LoopFollow/Remote/LoopAPNS/LoopAPNSCarbsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,6 @@ struct LoopAPNSCarbsView: View {
.buttonStyle(.plain)
}
}
Section {
Button(action: sendCarbs) {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending...")
}
} else {
Text("Send Carbs")
}
}
.disabled(carbsAmount.doubleValue(for: .gram()) <= 0 || isLoading || isTOTPBlocked)
.frame(maxWidth: .infinity)
}

// TOTP Blocking Warning Section
if isTOTPBlocked && showTOTPWarning {
Section {
Expand Down Expand Up @@ -292,6 +276,27 @@ struct LoopAPNSCarbsView: View {
}
}
}
.safeAreaInset(edge: .bottom) {
Button(action: sendCarbs) {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending...")
}
.frame(maxWidth: .infinity)
} else {
Text("Send Carbs")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
.disabled(carbsAmount.doubleValue(for: .gram()) <= 0 || isLoading || isTOTPBlocked)
.padding(.horizontal)
.padding(.vertical, 8)
.background(.bar)
}
.navigationTitle("Carbs")
.navigationBarTitleDisplayMode(.inline)
}
Expand Down
51 changes: 32 additions & 19 deletions LoopFollow/Remote/TRC/BolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,39 @@ struct BolusView: View {
}
)
}

LoadingButtonView(
buttonText: "Send Bolus",
progressText: "Sending Bolus...",
isLoading: isLoading,
action: {
bolusFieldIsFocused = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
let rawValue = self.bolusAmount.doubleValue(for: .internationalUnit())
let steppedAmount = roundedToStep(rawValue)

if steppedAmount > 0 {
bolusAmount = HKQuantity(unit: .internationalUnit(), doubleValue: steppedAmount)
alertType = .confirmBolus
showAlert = true
}
}
.safeAreaInset(edge: .bottom) {
Button {
bolusFieldIsFocused = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
let rawValue = self.bolusAmount.doubleValue(for: .internationalUnit())
let steppedAmount = roundedToStep(rawValue)

if steppedAmount > 0 {
bolusAmount = HKQuantity(unit: .internationalUnit(), doubleValue: steppedAmount)
alertType = .confirmBolus
showAlert = true
}
},
isDisabled: isLoading
)
}
} label: {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending Bolus...")
}
.frame(maxWidth: .infinity)
} else {
Text("Send Bolus")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
.disabled(isLoading)
.padding(.horizontal)
.padding(.vertical, 8)
.background(.bar)
}
.navigationTitle("Bolus")
.navigationBarTitleDisplayMode(.inline)
Expand Down
59 changes: 36 additions & 23 deletions LoopFollow/Remote/TRC/MealView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,44 @@ struct MealView: View {
}
}
}
}
.safeAreaInset(edge: .bottom) {
Button {
carbsFieldIsFocused = false
proteinFieldIsFocused = false
fatFieldIsFocused = false

LoadingButtonView(
buttonText: "Send Meal",
progressText: "Sending Meal Data...",
isLoading: isLoading,
action: {
carbsFieldIsFocused = false
proteinFieldIsFocused = false
fatFieldIsFocused = false

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
guard carbs.doubleValue(for: .gram()) != 0 ||
protein.doubleValue(for: .gram()) != 0 ||
fat.doubleValue(for: .gram()) != 0
else {
return
}
if !showAlert {
alertType = .confirmMeal
showAlert = true
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
guard carbs.doubleValue(for: .gram()) != 0 ||
protein.doubleValue(for: .gram()) != 0 ||
fat.doubleValue(for: .gram()) != 0
else {
return
}
},
isDisabled: isButtonDisabled
)
if !showAlert {
alertType = .confirmMeal
showAlert = true
}
}
} label: {
if isLoading {
HStack {
ProgressView()
.scaleEffect(0.8)
Text("Sending Meal Data...")
}
.frame(maxWidth: .infinity)
} else {
Text("Send Meal")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
.disabled(isButtonDisabled)
.padding(.horizontal)
.padding(.vertical, 8)
.background(.bar)
}
.navigationTitle("Meal")
.navigationBarTitleDisplayMode(.inline)
Expand Down