public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TitleLabel.Text = Resources.Startdate;
            SaveButton.SetTitle(Resources.Save, UIControlState.Normal);

            prepareDatePicker();

            DatePicker.MinimumDate = ViewModel.MinDate.ToNSDate();
            DatePicker.MaximumDate = ViewModel.MaxDate.ToNSDate();

            DatePicker.Rx().Date()
            .Subscribe(ViewModel.CurrentDateTime.Accept)
            .DisposedBy(DisposeBag);

            ViewModel.CurrentDateTime
            .Subscribe(DatePicker.Rx().DateTimeObserver())
            .DisposedBy(DisposeBag);

            SaveButton.Rx()
            .BindAction(ViewModel.SaveCommand)
            .DisposedBy(DisposeBag);

            CloseButton.Rx()
            .BindAction(ViewModel.CloseCommand)
            .DisposedBy(DisposeBag);
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tableViewSource = new SelectTagsTableViewSource(TagsTableView);

            tableViewSource.Rx().ModelSelected()
            .Subscribe(ViewModel.SelectTag.Inputs)
            .DisposedBy(DisposeBag);

            var tagsReplay = ViewModel.Tags.Replay();

            tagsReplay
            .Subscribe(TagsTableView.Rx().ReloadItems(tableViewSource))
            .DisposedBy(DisposeBag);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                tagsReplay
                .Select((tags) =>
                {
                    var count         = tags.ToList().Count();
                    var contentHeight = count > 0
                            ? count * SelectTagsTableViewSource.RowHeight
                            : placeholderHeight;
                    return(new CoreGraphics.CGSize(0, contentHeight + headerHeight));
                })
                .Subscribe(this.Rx().PreferredContentSize())
                .DisposedBy(DisposeBag);
            }

            tagsReplay.Connect();

            ViewModel.IsEmpty
            .Subscribe(EmptyStateImage.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsEmpty
            .Subscribe(EmptyStateLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.FilterText
            .Subscribe(TextField.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            CloseButton.Rx().Tap()
            .Subscribe(ViewModel.CloseWithDefaultResult)
            .DisposedBy(DisposeBag);

            SaveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            TextField.Rx().Text()
            .Subscribe(ViewModel.FilterText)
            .DisposedBy(DisposeBag);

            BottomConstraint.Active |= UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CloseButton.SetTemplateColor(ColorAssets.Text2);

            TitleLabel.Text = Resources.ProjectColor;
            SaveButton.SetTitle(Resources.Save, UIControlState.Normal);

            prepareViews();

            //Collection View
            ColorCollectionView.RegisterNibForCell(ColorSelectionViewCell.Nib, ColorSelectionViewCell.Identifier);
            source = new ColorSelectionCollectionViewSource(ViewModel.SelectableColors);
            ColorCollectionView.Source = source;
            ViewModel.SelectableColors
            .Subscribe(replaceColors)
            .DisposedBy(DisposeBag);

            source.ColorSelected
            .Subscribe(ViewModel.SelectColor.Inputs)
            .DisposedBy(DisposeBag);

            // Commands
            SaveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            CloseButton.Rx().Tap()
            .Subscribe(() => ViewModel.CloseWithDefaultResult())
            .DisposedBy(DisposeBag);

            // Picker view
            PickerView.Rx().Hue()
            .Subscribe(ViewModel.SetHue.Inputs)
            .DisposedBy(DisposeBag);


            PickerView.Rx().Saturation()
            .Subscribe(ViewModel.SetSaturation.Inputs)
            .DisposedBy(DisposeBag);

            SliderView.Rx().Value()
            .Select(v => 1 - v)
            .Subscribe(ViewModel.SetValue.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Hue
            .Subscribe(PickerView.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(PickerView.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Value
            .Subscribe(PickerView.Rx().ValueObserver())
            .DisposedBy(DisposeBag);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CloseButton.SetTemplateColor(ColorAssets.Text2);

            SearchView.InsertSeparator();

            TitleLabel.Text       = Resources.Tags;
            TextField.Placeholder = Resources.AddFilterTags;
            EmptyStateLabel.Text  = Resources.EmptyTagText;
            SaveButton.SetTitle(Resources.Save, UIControlState.Normal);

            var tableViewSource = new SelectTagsTableViewSource(TagsTableView);

            tableViewSource.Rx().ModelSelected()
            .Subscribe(ViewModel.SelectTag.Inputs)
            .DisposedBy(DisposeBag);

            tableViewSource.Rx().DragStarted()
            .Subscribe(_ => TextField.ResignFirstResponder())
            .DisposedBy(DisposeBag);

            var tagsReplay = ViewModel.Tags.Replay();

            tagsReplay
            .Subscribe(TagsTableView.Rx().ReloadItems(tableViewSource))
            .DisposedBy(DisposeBag);

            tagsReplay.Connect();

            ViewModel.IsEmpty
            .Subscribe(EmptyStateImage.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsEmpty
            .Subscribe(EmptyStateLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.FilterText
            .Subscribe(TextField.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            CloseButton.Rx().Tap()
            .Subscribe(() => ViewModel.CloseWithDefaultResult())
            .DisposedBy(DisposeBag);

            SaveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            TextField.Rx().Text()
            .Subscribe(ViewModel.FilterText)
            .DisposedBy(DisposeBag);

            BottomConstraint.Active |= TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Compact;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tableViewSource = new SelectTagsTableViewSource(TagsTableView);

            tableViewSource.Rx().ModelSelected()
            .Subscribe(ViewModel.SelectTag.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Tags
            .Subscribe(TagsTableView.Rx().ReloadItems(tableViewSource))
            .DisposedBy(DisposeBag);

            ViewModel.IsEmpty
            .Subscribe(EmptyStateImage.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsEmpty
            .Subscribe(EmptyStateLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.FilterText
            .Subscribe(TextField.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            CloseButton.Rx()
            .BindAction(ViewModel.Close)
            .DisposedBy(DisposeBag);

            SaveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            TextField.Rx().Text()
            .Subscribe(ViewModel.FilterText)
            .DisposedBy(DisposeBag);
        }
        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);
        }