Improved UI. Now upload requires pressing upload.

This commit is contained in:
eduardopietre 2021-12-27 10:59:44 -03:00 committed by Johan Degraeve
parent 956c23b29d
commit 48f63752a2
17 changed files with 62 additions and 21 deletions

View File

@ -112,9 +112,6 @@ public class NightScoutUploadManager:NSObject {
// upload calibrations
uploadCalibrationsToNightScout()
// upload treatments
uploadTreatmentsToNightScout()
// upload activeSensor if needed
if UserDefaults.standard.uploadSensorStartTimeToNS, let activeSensor = sensorsAccessor.fetchActiveSensor() {
@ -358,7 +355,7 @@ public class NightScoutUploadManager:NSObject {
/// upload treatments to nightscout
/// Only checks recents ones
public func uploadTreatmentsToNightScout() {
public func uploadTreatmentsToNightScout(sucessHandler: (() -> Void)?) {
trace("in uploadTreatmentsToNightScout", log: self.oslog, category: ConstantsLog.categoryNightScoutUploadManager, type: .info)
// get the latest treatments from the last maxDaysToUpload days
@ -387,6 +384,10 @@ public class NightScoutUploadManager:NSObject {
self.coreDataManager.saveChanges()
}
if let sucessHandler = sucessHandler {
sucessHandler()
}
})
}

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -4,3 +4,5 @@
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -7,4 +7,6 @@
"treatments_new_entry" = "New Entry";
"treatments_carbs_with_unit" = "Carbs (g):";
"treatments_insulin_with_unit" = "Insulin (U):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_exercise_with_unit" = "Exercise (min):";
"treatments_success" = "Success";
"treatments_upload_complete" = "Upload complete.";

View File

@ -27,5 +27,13 @@ enum Texts_TreatmentsView {
static let exerciseWithUnit:String = {
return NSLocalizedString("treatments_exercise_with_unit", tableName: filename, bundle: Bundle.main, value: "Exercise (min):", comment: "Exercise with unit.")
}()
static let success:String = {
return NSLocalizedString("treatments_success", tableName: filename, bundle: Bundle.main, value: "Success", comment: "Success.")
}()
static let uploadCompleted:String = {
return NSLocalizedString("treatments_upload_complete", tableName: filename, bundle: Bundle.main, value: "Upload completed.", comment: "Upload completed.")
}()
}

View File

@ -35,10 +35,14 @@ class TreatmentsViewController : UIViewController {
}
@IBAction func uploadButtonTapped(_ sender: UIButton) {
nightScoutUploadManager?.uploadTreatmentsToNightScout()
let alert = UIAlertController(title: Texts_Common.Ok, message: Texts_Common.Ok, actionHandler: nil)
self.present(alert, animated: true, completion: nil)
nightScoutUploadManager?.uploadTreatmentsToNightScout(sucessHandler: {
// Make sure to run alert in the correct thread.
DispatchQueue.main.async {
let alert = UIAlertController(title: Texts_TreatmentsView.success, message: Texts_TreatmentsView.uploadCompleted, actionHandler: nil)
self.present(alert, animated: true, completion: nil)
}
})
}