private void onEditTimeTap(UITapGestureRecognizer recognizer) { if (DurationInput.IsEditing) { DurationInput.ResignFirstResponder(); } }
public void Duration_Verify() { var settingWrong1 = new DurationInput(0); var setting = new DurationInput(2); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Equal("-t 00:00:02.0", SettingSerializer.Serialize(setting)); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); if (ViewModel.IsDurationInitiallyFocused) { DurationInput.BecomeFirstResponder(); } }
private void onBackgroundTap(UITapGestureRecognizer recognizer) { if (DurationInput.IsEditing) { DurationInput.ResignFirstResponder(); } ViewModel.StopEditingTime.Execute(); }
public void Duration_Verify() { var settingWrong1 = new DurationInput(0); var setting = new DurationInput(2); Assert.Throws <InvalidOperationException>(() => { var s = settingWrong1.GetAndValidateString(); }); Assert.DoesNotThrow(() => { var s = setting.GetAndValidateString(); }); Assert.Equal(setting.GetAndValidateString(), "-t 00:00:02.0"); }
public override void ViewDidLoad() { base.ViewDidLoad(); StartLabel.Text = Resources.Start; EndLabel.Text = Resources.End; TitleLabel.Text = Resources.StartAndStopTime; SetEndButton.SetTitle(Resources.Stop, UIControlState.Normal); SaveButton.SetTitle(Resources.Save, UIControlState.Normal); prepareViews(); // Actions SaveButton.Rx() .BindAction(ViewModel.Save) .DisposedBy(disposeBag); CloseButton.Rx() .BindAction(ViewModel.Close) .DisposedBy(disposeBag); // Start and stop date/time ViewModel.StartTimeString .Subscribe(StartTimeLabel.Rx().Text()) .DisposedBy(disposeBag); ViewModel.StartDateString .Subscribe(StartDateLabel.Rx().Text()) .DisposedBy(disposeBag); ViewModel.StopTimeString .Subscribe(EndTimeLabel.Rx().Text()) .DisposedBy(disposeBag); ViewModel.StopDateString .Subscribe(EndDateLabel.Rx().Text()) .DisposedBy(disposeBag); // Editing start and end time StartView.Rx() .BindAction(ViewModel.EditStartTime) .DisposedBy(disposeBag); EndView.Rx() .BindAction(ViewModel.EditStopTime) .DisposedBy(disposeBag); SetEndButton.Rx() .BindAction(ViewModel.EditStopTime) .DisposedBy(disposeBag); // Visibility ViewModel.IsRunning .Subscribe(running => { SetEndButton.Hidden = !running; EndTimeLabel.Hidden = running; EndDateLabel.Hidden = running; }) .DisposedBy(disposeBag); // Stard and end colors ViewModel.IsEditingStartTime .Select(editingStartTime => editingStartTime ? Color.EditDuration.EditedTime.ToNativeColor() : Color.EditDuration.NotEditedTime.ToNativeColor() ) .Subscribe(color => { StartTimeLabel.TextColor = color; StartDateLabel.TextColor = color; }) .DisposedBy(disposeBag); ViewModel.IsEditingStopTime .Select(editingStartTime => editingStartTime ? Color.EditDuration.EditedTime.ToNativeColor() : Color.EditDuration.NotEditedTime.ToNativeColor() ) .Subscribe(color => { EndTimeLabel.TextColor = color; EndDateLabel.TextColor = color; }) .DisposedBy(disposeBag); // Date picker ViewModel.IsEditingTime .Subscribe(DatePickerContainer.Rx().AnimatedIsVisible()) .DisposedBy(disposeBag); DatePicker.Rx().Date() .Subscribe(ViewModel.ChangeActiveTime.Inputs) .DisposedBy(disposeBag); var startTime = ViewModel.IsEditingStartTime .Where(CommonFunctions.Identity) .SelectMany(_ => ViewModel.StartTime); var stopTime = ViewModel.IsEditingStopTime .Where(CommonFunctions.Identity) .SelectMany(_ => ViewModel.StopTime); Observable.Merge(startTime, stopTime) .Subscribe(v => DatePicker.SetDate(v.ToNSDate(), false)) .DisposedBy(disposeBag); ViewModel.IsEditingStartTime .Where(CommonFunctions.Identity) .SelectMany(_ => ViewModel.StartTime) .Subscribe(v => DatePicker.SetDate(v.ToNSDate(), false)) .DisposedBy(disposeBag); ViewModel.MinimumDateTime .Subscribe(v => DatePicker.MinimumDate = v.ToNSDate()) .DisposedBy(disposeBag); ViewModel.MaximumDateTime .Subscribe(v => DatePicker.MaximumDate = v.ToNSDate()) .DisposedBy(disposeBag); ViewModel.TimeFormat .Subscribe(v => DatePicker.Locale = v.IsTwentyFourHoursFormat ? new NSLocale("en_GB") : new NSLocale("en_US")) .DisposedBy(disposeBag); // DurationInput ViewModel.IsEditingTime .Invert() .Subscribe(DurationInput.Rx().Enabled()) .DisposedBy(disposeBag); ViewModel.Duration .Subscribe(v => DurationInput.Duration = v) .DisposedBy(disposeBag); ViewModel.DurationString .Subscribe(v => DurationInput.FormattedDuration = v) .DisposedBy(disposeBag); DurationInput.Rx().Duration() .Subscribe(ViewModel.ChangeDuration.Inputs) .DisposedBy(disposeBag); // The wheel ViewModel.IsEditingTime .Invert() .Subscribe(v => WheelView.UserInteractionEnabled = v) .DisposedBy(disposeBag); ViewModel.MinimumStartTime .Subscribe(v => WheelView.MinimumStartTime = v) .DisposedBy(disposeBag); ViewModel.MaximumStartTime .Subscribe(v => WheelView.MaximumStartTime = v) .DisposedBy(disposeBag); ViewModel.MinimumStopTime .Subscribe(v => WheelView.MinimumEndTime = v) .DisposedBy(disposeBag); ViewModel.MaximumStopTime .Subscribe(v => WheelView.MaximumEndTime = v) .DisposedBy(disposeBag); ViewModel.StartTime .Subscribe(v => WheelView.StartTime = v) .DisposedBy(disposeBag); ViewModel.StopTime .Subscribe(v => WheelView.EndTime = v) .DisposedBy(disposeBag); ViewModel.IsRunning .Subscribe(v => WheelView.IsRunning = v) .DisposedBy(disposeBag); WheelView.Rx().StartTime() .Subscribe(ViewModel.ChangeStartTime.Inputs) .DisposedBy(disposeBag); WheelView.Rx().EndTime() .Subscribe(ViewModel.ChangeStopTime.Inputs) .DisposedBy(disposeBag); // Interaction observables for analytics var editingStart = Observable.Merge( StartView.Rx().Tap().SelectValue(true), EndView.Rx().Tap().SelectValue(false) ); var dateComponentChanged = DatePicker.Rx().DateComponent() .WithLatestFrom(editingStart, (_, isStart) => isStart ? EditTimeSource.BarrelStartDate : EditTimeSource.BarrelStopDate ); var timeComponentChanged = DatePicker.Rx().TimeComponent() .WithLatestFrom(editingStart, (_, isStart) => isStart ? EditTimeSource.BarrelStartTime : EditTimeSource.BarrelStopTime ); var durationInputChanged = DurationInput.Rx().Duration() .SelectValue(EditTimeSource.NumpadDuration); Observable.Merge( dateComponentChanged, timeComponentChanged, WheelView.TimeEdited, durationInputChanged ) .Distinct() .Subscribe(ViewModel.TimeEditedWithSource) .DisposedBy(disposeBag); }
void ReleaseDesignerOutlets() { if (CloseButton != null) { CloseButton.Dispose(); CloseButton = null; } if (DatePicker != null) { DatePicker.Dispose(); DatePicker = null; } if (DatePickerContainer != null) { DatePickerContainer.Dispose(); DatePickerContainer = null; } if (DurationInput != null) { DurationInput.Dispose(); DurationInput = null; } if (EndDateLabel != null) { EndDateLabel.Dispose(); EndDateLabel = null; } if (EndLabel != null) { EndLabel.Dispose(); EndLabel = null; } if (EndTimeLabel != null) { EndTimeLabel.Dispose(); EndTimeLabel = null; } if (EndView != null) { EndView.Dispose(); EndView = null; } if (SaveButton != null) { SaveButton.Dispose(); SaveButton = null; } if (SetEndButton != null) { SetEndButton.Dispose(); SetEndButton = null; } if (StackView != null) { StackView.Dispose(); StackView = null; } if (StartDateLabel != null) { StartDateLabel.Dispose(); StartDateLabel = null; } if (StartLabel != null) { StartLabel.Dispose(); StartLabel = null; } if (StartTimeLabel != null) { StartTimeLabel.Dispose(); StartTimeLabel = null; } if (StartView != null) { StartView.Dispose(); StartView = null; } if (TitleLabel != null) { TitleLabel.Dispose(); TitleLabel = null; } if (WheelView != null) { WheelView.Dispose(); WheelView = null; } if (startIcon != null) { startIcon.Dispose(); startIcon = null; } if (endIcon != null) { endIcon.Dispose(); endIcon = null; } }