Ver código fonte

Improved alert management

Jonas Björkert 1 ano atrás
pai
commit
9ea1e365c5

+ 19 - 17
LoopFollow/Info.plist

@@ -2,8 +2,6 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>CFBundleDisplayName</key>
-	<string>$(display_name)</string>
 	<key>AppGroupIdentifier</key>
 	<string>group.com.$(unique_id).LoopFollow$(app_suffix)</string>
 	<key>BGTaskSchedulerPermittedIdentifiers</key>
@@ -12,6 +10,8 @@
 	</array>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>$(DEVELOPMENT_LANGUAGE)</string>
+	<key>CFBundleDisplayName</key>
+	<string>$(display_name)</string>
 	<key>CFBundleExecutable</key>
 	<string>$(EXECUTABLE_NAME)</string>
 	<key>CFBundleIdentifier</key>
@@ -24,14 +24,31 @@
 	<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
 	<key>CFBundleShortVersionString</key>
 	<string>$(LOOP_FOLLOW_MARKETING_VERSION)</string>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>loopfollow</string>
+			</array>
+		</dict>
+	</array>
 	<key>CFBundleVersion</key>
 	<string>1</string>
+	<key>ITSAppUsesNonExemptEncryption</key>
+	<false/>
 	<key>LSApplicationCategoryType</key>
 	<string>public.app-category.medical</string>
+	<key>LSMinimumSystemVersion</key>
+	<string>13.0</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
+	<key>NSCalendarsFullAccessUsageDescription</key>
+	<string>Loop Follow would like to access your calendar to update BG readings</string>
 	<key>NSCalendarsUsageDescription</key>
 	<string>Loop Follow would like to access your calendar to save BG readings</string>
+	<key>NSFaceIDUsageDescription</key>
+	<string>This app requires Face ID for secure authentication.</string>
 	<key>UIApplicationSceneManifest</key>
 	<dict>
 		<key>UIApplicationSupportsMultipleScenes</key>
@@ -85,20 +102,5 @@
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
-	<key>NSCalendarsFullAccessUsageDescription</key>
-	<string>Loop Follow would like to access your calendar to update BG readings</string>
-	<key>CFBundleURLTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleURLSchemes</key>
-			<array>
-				<string>loopfollow</string>
-			</array>
-		</dict>
-	</array>
-	<key>ITSAppUsesNonExemptEncryption</key>
-	<false/>
-	<key>LSMinimumSystemVersion</key>
-	<string>13.0</string>
 </dict>
 </plist>

+ 5 - 8
LoopFollow/Remote/TRC/BolusView.swift

@@ -54,9 +54,11 @@ struct BolusView: View {
                         isLoading: isLoading,
                         action: {
                             bolusFieldIsFocused = false
-                            if bolusAmount.doubleValue(for: HKUnit.internationalUnit()) > 0.0 {
-                                alertType = .confirmBolus
-                                showAlert = true
+                            DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
+                                if bolusAmount.doubleValue(for: HKUnit.internationalUnit()) > 0.0 {
+                                    alertType = .confirmBolus
+                                    showAlert = true
+                                }
                             }
                         },
                         isDisabled: isLoading
@@ -75,10 +77,6 @@ struct BolusView: View {
                             authenticateUser { success in
                                 if success {
                                     sendBolus()
-                                } else {
-                                    statusMessage = "Authentication failed. Please try again."
-                                    alertType = .status
-                                    showAlert = true
                                 }
                             }
                         }),
@@ -105,7 +103,6 @@ struct BolusView: View {
 
     private func sendBolus() {
         isLoading = true
-        bolusFieldIsFocused = false
 
         pushNotificationManager.sendBolusPushNotification(commandType: "bolus", bolusAmount: bolusAmount) { success, errorMessage in
             DispatchQueue.main.async {

+ 9 - 8
LoopFollow/Remote/TRC/MealView.swift

@@ -89,11 +89,13 @@ struct MealView: View {
                             proteinFieldIsFocused = false
                             fatFieldIsFocused = false
 
-                            let carbsAmount = carbs.doubleValue(for: HKUnit.gram())
-                            let proteinAmount = protein.doubleValue(for: HKUnit.gram())
-                            let fatAmount = fat.doubleValue(for: HKUnit.gram())
+                            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 carbsAmount > 0 || proteinAmount > 0 || fatAmount > 0 {
                                 alertType = .confirmMeal
                                 showAlert = true
                             }
@@ -129,7 +131,9 @@ struct MealView: View {
                         title: Text("Confirm Meal"),
                         message: Text(message),
                         primaryButton: .default(Text("Confirm"), action: {
-                            sendMealCommand()
+                            DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
+                                sendMealCommand()
+                            }
                         }),
                         secondaryButton: .cancel()
                     )
@@ -161,9 +165,6 @@ struct MealView: View {
     }
 
     private func sendMealCommand() {
-        carbsFieldIsFocused = false
-        proteinFieldIsFocused = false
-        fatFieldIsFocused = false
         isLoading = true
 
         pushNotificationManager.sendMealPushNotification(carbs: carbs, protein: protein, fat: fat) { success, errorMessage in