static async Task ShowSelectTimeAlert(TipScheduler scheduler, TimeSpan?maybeTime = null) { var isEdit = maybeTime != null; var time = maybeTime ?? DateTime.Now.TimeOfDay; var tp = new TimePicker { Format = "HH:mm", Time = time.MinutesOnly() }; var cancelButton = new AlertButton { Text = isEdit ? "Verwijder" : "Annuleer", IsDestructive = isEdit, Action = () => { if (isEdit) { scheduler.RemoveTime(time); } return(false); } }; tp.PropertyChanged += (sender, e) => { if (e.PropertyName == TimePicker.TimeProperty.PropertyName) { return; // TODO: change delete into cancel button } }; await Alert.Show( "Tijd " + (isEdit ? "bewerken" : "toevoegen"), "Voer hieronder de tijd in waarop je een tip wil ontvangen.", tp, cancelButton, new AlertButton { Text = "Opslaan", IsPreferred = true, Action = () => { var newTime = tp.Time.MinutesOnly(); if (!isEdit || newTime != time) { if (isEdit) { scheduler.RemoveTime(time); } scheduler.AddTime(newTime); } return(false); } } ); }
static async Task ShowSelectTimeAndroid(TipScheduler scheduler, TimeSpan?maybeTime = null) { Func <int, TimePicker> createTP = (int hours) => new TimePicker { Time = TimeSpan.FromHours(hours), Format = "HH:mm" }; var tp = createTP(12); tp.Focus(); scheduler.AddTime(tp.Time.MinutesOnly()); }