示例#1
0
 /// <summary>
 /// get the end date text
 /// </summary>
 /// <returns>text</returns>
 public string GetEndDate()
 {
     EndDateLabel.Wait(2);
     if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
     {
         EndDateLabel.Text = FakeText;
     }
     return(EndDateLabel.Text);
 }
        void ReleaseDesignerOutlets()
        {
            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (EndDateLabel != null)
            {
                EndDateLabel.Dispose();
                EndDateLabel = null;
            }
        }
        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);
        }
示例#4
0
        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;
            }
        }
示例#5
0
        protected override void UpdateViewBinding()
        {
            // Bar chart
            Item.WorkspaceHasBillableFeatureEnabled
            .Subscribe(ColorsLegendContainerView.Rx().IsVisible())
            .DisposedBy(disposeBag);

            Item.StartDate
            .CombineLatest(
                Item.BarChartViewModel.DateFormat,
                (startDate, format) => startDate.ToString(format.Short, CultureInfo.InvariantCulture))
            .Subscribe(StartDateLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.EndDate
            .CombineLatest(
                Item.BarChartViewModel.DateFormat,
                (endDate, format) => endDate.ToString(format.Short, CultureInfo.InvariantCulture))
            .Subscribe(EndDateLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.MaximumHoursPerBar
            .Select(hours => $"{hours} h")
            .Subscribe(MaximumHoursLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.MaximumHoursPerBar
            .Select(hours => $"{hours / 2} h")
            .Subscribe(HalfHoursLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.HorizontalLegend
            .Where(legend => legend == null)
            .Subscribe((DateTimeOffset[] _) =>
            {
                HorizontalLegendStackView.Subviews.ForEach(subview => subview.RemoveFromSuperview());
                StartDateLabel.Hidden = false;
                EndDateLabel.Hidden   = false;
            })
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.HorizontalLegend
            .Where(legend => legend != null)
            .CombineLatest(Item.BarChartViewModel.DateFormat, createHorizontalLegendLabels)
            .Do(_ =>
            {
                StartDateLabel.Hidden = true;
                EndDateLabel.Hidden   = true;
            })
            .Subscribe(HorizontalLegendStackView.Rx().ArrangedViews())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.Bars
            .Select(createBarViews)
            .Subscribe(BarsStackView.Rx().ArrangedViews())
            .DisposedBy(disposeBag);

            var spacingObservable = Item.BarChartViewModel.Bars
                                    .CombineLatest(updateLayout, (bars, _) => bars)
                                    .Select(bars => BarsStackView.Frame.Width / bars.Length * barChartSpacingProportion);

            spacingObservable
            .Subscribe(BarsStackView.Rx().Spacing())
            .DisposedBy(disposeBag);

            spacingObservable
            .Subscribe(HorizontalLegendStackView.Rx().Spacing())
            .DisposedBy(disposeBag);
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            var templateImage = TotalDurationGraph.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);

            TotalDurationGraph.Image = templateImage;

            prepareViews();

            var colorConverter = new BoolToConstantValueConverter <UIColor>(
                Color.Reports.Disabled.ToNativeColor(),
                Color.Reports.TotalTimeActivated.ToNativeColor()
                );

            var durationCombiner = new DurationValueCombiner();

            this.DelayBind(() =>
            {
                var bindingSet = this.CreateBindingSet <ReportsHeaderView, ReportsViewModel>();

                //Text
                bindingSet.Bind(BillablePercentageLabel)
                .For(v => v.AttributedText)
                .To(vm => vm.BillablePercentage)
                .WithConversion(new ReportPercentageLabelValueConverter());

                bindingSet.Bind(TotalDurationLabel)
                .For(v => v.Text)
                .ByCombining(durationCombiner,
                             vm => vm.TotalTime,
                             vm => vm.DurationFormat);

                //Loading chart
                bindingSet.Bind(LoadingPieChartView)
                .For(v => v.BindVisibilityWithFade())
                .To(vm => vm.IsLoading);

                bindingSet.Bind(LoadingCardView)
                .For(v => v.BindVisibilityWithFade())
                .To(vm => vm.IsLoading);

                //Pretty stuff
                bindingSet.Bind(PieChartView)
                .For(v => v.Segments)
                .To(vm => vm.GroupedSegments);

                bindingSet.Bind(BillablePercentageView)
                .For(v => v.Percentage)
                .To(vm => vm.BillablePercentage);

                bindingSet.Bind(TotalDurationGraph)
                .For(v => v.TintColor)
                .To(vm => vm.TotalTimeIsZero)
                .WithConversion(colorConverter);

                bindingSet.Bind(TotalDurationLabel)
                .For(v => v.TextColor)
                .To(vm => vm.TotalTimeIsZero)
                .WithConversion(colorConverter);

                // Bar chart

                if (ViewModel == null)
                {
                    throw new InvalidOperationException($"The {nameof(ViewModel)} value must be set for {nameof(ReportsHeaderView)} before defining bindings.");
                }

                ViewModel.WorkspaceHasBillableFeatureEnabled
                .Subscribe(ColorsLegendContainerView.Rx().IsVisible())
                .DisposedBy(disposeBag);

                ViewModel.StartDate
                .CombineLatest(
                    ViewModel.BarChartViewModel.DateFormat,
                    (startDate, format) => startDate.ToString(format.Short))
                .Subscribe(StartDateLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.EndDate
                .CombineLatest(
                    ViewModel.BarChartViewModel.DateFormat,
                    (endDate, format) => endDate.ToString(format.Short))
                .Subscribe(EndDateLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.MaximumHoursPerBar
                .Select(hours => $"{hours} h")
                .Subscribe(MaximumHoursLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.MaximumHoursPerBar
                .Select(hours => $"{hours/2} h")
                .Subscribe(HalfHoursLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.HorizontalLegend
                .Where(legend => legend == null)
                .Subscribe((DateTimeOffset[] _) =>
                {
                    HorizontalLegendStackView.Subviews.ForEach(subview => subview.RemoveFromSuperview());
                    StartDateLabel.Hidden = false;
                    EndDateLabel.Hidden   = false;
                })
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.HorizontalLegend
                .Where(legend => legend != null)
                .CombineLatest(ViewModel.BarChartViewModel.DateFormat, createHorizontalLegendLabels)
                .Do(_ =>
                {
                    StartDateLabel.Hidden = true;
                    EndDateLabel.Hidden   = true;
                })
                .Subscribe(HorizontalLegendStackView.Rx().ArrangedViews())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.Bars
                .Select(createBarViews)
                .Subscribe(BarsStackView.Rx().ArrangedViews())
                .DisposedBy(disposeBag);

                var spacingObservable = ViewModel.BarChartViewModel.Bars
                                        .CombineLatest(updateLayout, (bars, _) => bars)
                                        .Select(bars => BarsStackView.Frame.Width / bars.Length * barChartSpacingProportion);

                spacingObservable
                .Subscribe(BarsStackView.Rx().Spacing())
                .DisposedBy(disposeBag);

                spacingObservable
                .Subscribe(HorizontalLegendStackView.Rx().Spacing())
                .DisposedBy(disposeBag);

                ViewModel.IsLoadingObservable
                .Select(CommonFunctions.Invert)
                .Subscribe(BarChartContainerView.Rx().IsVisible())
                .DisposedBy(disposeBag);

                //Visibility
                bindingSet.Bind(EmptyStateView)
                .For(v => v.BindVisible())
                .To(vm => vm.ShowEmptyState);

                bindingSet.Apply();
            });
        }
示例#7
0
        protected override void UpdateView()
        {
            //Text
            var reportPercentageConverter = new ReportPercentageLabelValueConverter();

            Item.BillablePercentageObservable
            .Select(reportPercentageConverter.Convert)
            .Subscribe(BillablePercentageLabel.Rx().AttributedText())
            .DisposedBy(disposeBag);

            Item.TotalTimeObservable
            .CombineLatest(Item.DurationFormatObservable,
                           (totalTime, durationFormat) => totalTime.ToFormattedString(durationFormat))
            .Subscribe(TotalDurationLabel.Rx().Text())
            .DisposedBy(disposeBag);

            //Loading chart
            Item.IsLoadingObservable
            .Subscribe(LoadingPieChartView.Rx().IsVisibleWithFade())
            .DisposedBy(disposeBag);

            Item.IsLoadingObservable
            .Subscribe(LoadingOverviewView.Rx().IsVisibleWithFade())
            .DisposedBy(disposeBag);

            //Pretty stuff
            Item.GroupedSegmentsObservable
            .Subscribe(groupedSegments => PieChartView.Segments = groupedSegments)
            .DisposedBy(disposeBag);

            Item.BillablePercentageObservable
            .Subscribe(percentage => BillablePercentageView.Percentage = percentage)
            .DisposedBy(disposeBag);

            var totalDurationColorObservable = Item.TotalTimeIsZeroObservable
                                               .Select(isZero => isZero
                    ? Foundation.MvvmCross.Helper.Color.Reports.Disabled.ToNativeColor()
                    : Foundation.MvvmCross.Helper.Color.Reports.TotalTimeActivated.ToNativeColor());

            totalDurationColorObservable
            .Subscribe(TotalDurationGraph.Rx().TintColor())
            .DisposedBy(disposeBag);

            totalDurationColorObservable
            .Subscribe(TotalDurationLabel.Rx().TextColor())
            .DisposedBy(disposeBag);

            // Bar chart
            Item.WorkspaceHasBillableFeatureEnabled
            .Subscribe(ColorsLegendContainerView.Rx().IsVisible())
            .DisposedBy(disposeBag);

            Item.StartDate
            .CombineLatest(
                Item.BarChartViewModel.DateFormat,
                (startDate, format) => startDate.ToString(format.Short, CultureInfo.InvariantCulture))
            .Subscribe(StartDateLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.EndDate
            .CombineLatest(
                Item.BarChartViewModel.DateFormat,
                (endDate, format) => endDate.ToString(format.Short, CultureInfo.InvariantCulture))
            .Subscribe(EndDateLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.MaximumHoursPerBar
            .Select(hours => $"{hours} h")
            .Subscribe(MaximumHoursLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.MaximumHoursPerBar
            .Select(hours => $"{hours / 2} h")
            .Subscribe(HalfHoursLabel.Rx().Text())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.HorizontalLegend
            .Where(legend => legend == null)
            .Subscribe((DateTimeOffset[] _) =>
            {
                HorizontalLegendStackView.Subviews.ForEach(subview => subview.RemoveFromSuperview());
                StartDateLabel.Hidden = false;
                EndDateLabel.Hidden   = false;
            })
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.HorizontalLegend
            .Where(legend => legend != null)
            .CombineLatest(Item.BarChartViewModel.DateFormat, createHorizontalLegendLabels)
            .Do(_ =>
            {
                StartDateLabel.Hidden = true;
                EndDateLabel.Hidden   = true;
            })
            .Subscribe(HorizontalLegendStackView.Rx().ArrangedViews())
            .DisposedBy(disposeBag);

            Item.BarChartViewModel.Bars
            .Select(createBarViews)
            .Subscribe(BarsStackView.Rx().ArrangedViews())
            .DisposedBy(disposeBag);

            var spacingObservable = Item.BarChartViewModel.Bars
                                    .CombineLatest(updateLayout, (bars, _) => bars)
                                    .Select(bars => BarsStackView.Frame.Width / bars.Length * barChartSpacingProportion);

            spacingObservable
            .Subscribe(BarsStackView.Rx().Spacing())
            .DisposedBy(disposeBag);

            spacingObservable
            .Subscribe(HorizontalLegendStackView.Rx().Spacing())
            .DisposedBy(disposeBag);

            Item.IsLoadingObservable
            .Select(CommonFunctions.Invert)
            .Subscribe(BarChartContainerView.Rx().IsVisible())
            .DisposedBy(disposeBag);

            //Visibility
            Item.ShowEmptyStateObservable
            .Subscribe(EmptyStateView.Rx().IsVisible())
            .DisposedBy(disposeBag);
        }
        void ReleaseDesignerOutlets()
        {
            if (BarChartCardView != null)
            {
                BarChartCardView.Dispose();
                BarChartCardView = null;
            }

            if (BarChartContainerView != null)
            {
                BarChartContainerView.Dispose();
                BarChartContainerView = null;
            }

            if (BarsStackView != null)
            {
                BarsStackView.Dispose();
                BarsStackView = null;
            }

            if (BillableLegendLabel != null)
            {
                BillableLegendLabel.Dispose();
                BillableLegendLabel = null;
            }

            if (BillablePercentageLabel != null)
            {
                BillablePercentageLabel.Dispose();
                BillablePercentageLabel = null;
            }

            if (BillablePercentageView != null)
            {
                BillablePercentageView.Dispose();
                BillablePercentageView = null;
            }

            if (BillableTitleLabel != null)
            {
                BillableTitleLabel.Dispose();
                BillableTitleLabel = null;
            }

            if (ClockedHoursTitleLabel != null)
            {
                ClockedHoursTitleLabel.Dispose();
                ClockedHoursTitleLabel = null;
            }

            if (EmptyStateView != null)
            {
                EmptyStateView.Dispose();
                EmptyStateView = null;
            }

            if (EndDateLabel != null)
            {
                EndDateLabel.Dispose();
                EndDateLabel = null;
            }

            if (HalfHoursLabel != null)
            {
                HalfHoursLabel.Dispose();
                HalfHoursLabel = null;
            }

            if (HorizontalLegendStackView != null)
            {
                HorizontalLegendStackView.Dispose();
                HorizontalLegendStackView = null;
            }

            if (LoadingCardView != null)
            {
                LoadingCardView.Dispose();
                LoadingCardView = null;
            }

            if (LoadingPieChartView != null)
            {
                LoadingPieChartView.Dispose();
                LoadingPieChartView = null;
            }

            if (MaximumHoursLabel != null)
            {
                MaximumHoursLabel.Dispose();
                MaximumHoursLabel = null;
            }

            if (NonBillableLegendLabel != null)
            {
                NonBillableLegendLabel.Dispose();
                NonBillableLegendLabel = null;
            }

            if (OverviewCardView != null)
            {
                OverviewCardView.Dispose();
                OverviewCardView = null;
            }

            if (PieChartView != null)
            {
                PieChartView.Dispose();
                PieChartView = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (TotalDurationGraph != null)
            {
                TotalDurationGraph.Dispose();
                TotalDurationGraph = null;
            }

            if (TotalDurationLabel != null)
            {
                TotalDurationLabel.Dispose();
                TotalDurationLabel = null;
            }

            if (TotalTitleLabel != null)
            {
                TotalTitleLabel.Dispose();
                TotalTitleLabel = null;
            }

            if (ColorsLegendContainerView != null)
            {
                ColorsLegendContainerView.Dispose();
                ColorsLegendContainerView = null;
            }
        }
示例#9
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            TotalTitleLabel.Text        = Resources.Total.ToUpper();
            BillableTitleLabel.Text     = Resources.Billable.ToUpper();
            ClockedHoursTitleLabel.Text = Resources.ClockedHours.ToUpper();
            BillableLegendLabel.Text    = Resources.Billable.ToUpper();
            NonBillableLegendLabel.Text = Resources.NonBillable.ToUpper();

            var templateImage = TotalDurationGraph.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);

            TotalDurationGraph.Image = templateImage;

            prepareViews();

            this.DelayBind(() =>
            {
                //Text
                var reportPercentageConverter = new ReportPercentageLabelValueConverter();
                ViewModel.BillablePercentageObservable
                .Select(reportPercentageConverter.Convert)
                .Subscribe(BillablePercentageLabel.Rx().AttributedText())
                .DisposedBy(disposeBag);

                ViewModel.TotalTimeObservable
                .CombineLatest(ViewModel.DurationFormatObservable,
                               (totalTime, durationFormat) => totalTime.ToFormattedString(durationFormat))
                .Subscribe(TotalDurationLabel.Rx().Text())
                .DisposedBy(disposeBag);

                //Loading chart
                ViewModel.IsLoadingObservable
                .Subscribe(LoadingPieChartView.Rx().IsVisibleWithFade())
                .DisposedBy(disposeBag);

                ViewModel.IsLoadingObservable
                .Subscribe(LoadingOverviewView.Rx().IsVisibleWithFade())
                .DisposedBy(disposeBag);

                //Pretty stuff
                ViewModel.GroupedSegmentsObservable
                .Subscribe(groupedSegments => PieChartView.Segments = groupedSegments)
                .DisposedBy(disposeBag);

                ViewModel.BillablePercentageObservable
                .Subscribe(percentage => BillablePercentageView.Percentage = percentage)
                .DisposedBy(disposeBag);

                var totalDurationColorObservable = ViewModel.TotalTimeIsZeroObservable
                                                   .Select(isZero => isZero
                        ? Foundation.MvvmCross.Helper.Color.Reports.Disabled.ToNativeColor()
                        : Foundation.MvvmCross.Helper.Color.Reports.TotalTimeActivated.ToNativeColor());

                totalDurationColorObservable
                .Subscribe(TotalDurationGraph.Rx().TintColor())
                .DisposedBy(disposeBag);

                totalDurationColorObservable
                .Subscribe(TotalDurationLabel.Rx().TextColor())
                .DisposedBy(disposeBag);
                // Bar chart

                if (ViewModel == null)
                {
                    throw new InvalidOperationException($"The {nameof(ViewModel)} value must be set for {nameof(ReportsHeaderView)} before defining bindings.");
                }

                ViewModel.WorkspaceHasBillableFeatureEnabled
                .Subscribe(ColorsLegendContainerView.Rx().IsVisible())
                .DisposedBy(disposeBag);

                ViewModel.StartDate
                .CombineLatest(
                    ViewModel.BarChartViewModel.DateFormat,
                    (startDate, format) => startDate.ToString(format.Short, CultureInfo.InvariantCulture))
                .Subscribe(StartDateLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.EndDate
                .CombineLatest(
                    ViewModel.BarChartViewModel.DateFormat,
                    (endDate, format) => endDate.ToString(format.Short, CultureInfo.InvariantCulture))
                .Subscribe(EndDateLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.MaximumHoursPerBar
                .Select(hours => $"{hours} h")
                .Subscribe(MaximumHoursLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.MaximumHoursPerBar
                .Select(hours => $"{hours / 2} h")
                .Subscribe(HalfHoursLabel.Rx().Text())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.HorizontalLegend
                .Where(legend => legend == null)
                .Subscribe((DateTimeOffset[] _) =>
                {
                    HorizontalLegendStackView.Subviews.ForEach(subview => subview.RemoveFromSuperview());
                    StartDateLabel.Hidden = false;
                    EndDateLabel.Hidden   = false;
                })
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.HorizontalLegend
                .Where(legend => legend != null)
                .CombineLatest(ViewModel.BarChartViewModel.DateFormat, createHorizontalLegendLabels)
                .Do(_ =>
                {
                    StartDateLabel.Hidden = true;
                    EndDateLabel.Hidden   = true;
                })
                .Subscribe(HorizontalLegendStackView.Rx().ArrangedViews())
                .DisposedBy(disposeBag);

                ViewModel.BarChartViewModel.Bars
                .Select(createBarViews)
                .Subscribe(BarsStackView.Rx().ArrangedViews())
                .DisposedBy(disposeBag);

                var spacingObservable = ViewModel.BarChartViewModel.Bars
                                        .CombineLatest(updateLayout, (bars, _) => bars)
                                        .Select(bars => BarsStackView.Frame.Width / bars.Length * barChartSpacingProportion);

                spacingObservable
                .Subscribe(BarsStackView.Rx().Spacing())
                .DisposedBy(disposeBag);

                spacingObservable
                .Subscribe(HorizontalLegendStackView.Rx().Spacing())
                .DisposedBy(disposeBag);

                ViewModel.IsLoadingObservable
                .Select(CommonFunctions.Invert)
                .Subscribe(BarChartContainerView.Rx().IsVisible())
                .DisposedBy(disposeBag);

                //Visibility
                ViewModel.ShowEmptyStateObservable
                .Subscribe(EmptyStateView.Rx().IsVisible())
                .DisposedBy(disposeBag);
            });
        }
示例#10
0
        void ReleaseDesignerOutlets()
        {
            if (BarChartCardView != null)
            {
                BarChartCardView.Dispose();
                BarChartCardView = null;
            }

            if (BarChartContainerView != null)
            {
                BarChartContainerView.Dispose();
                BarChartContainerView = null;
            }

            if (BarsStackView != null)
            {
                BarsStackView.Dispose();
                BarsStackView = null;
            }

            if (BillableLegendLabel != null)
            {
                BillableLegendLabel.Dispose();
                BillableLegendLabel = null;
            }

            if (ClockedHoursTitleLabel != null)
            {
                ClockedHoursTitleLabel.Dispose();
                ClockedHoursTitleLabel = null;
            }

            if (ColorsLegendContainerView != null)
            {
                ColorsLegendContainerView.Dispose();
                ColorsLegendContainerView = null;
            }

            if (EndDateLabel != null)
            {
                EndDateLabel.Dispose();
                EndDateLabel = null;
            }

            if (HalfHoursLabel != null)
            {
                HalfHoursLabel.Dispose();
                HalfHoursLabel = null;
            }

            if (HorizontalLegendStackView != null)
            {
                HorizontalLegendStackView.Dispose();
                HorizontalLegendStackView = null;
            }

            if (MaximumHoursLabel != null)
            {
                MaximumHoursLabel.Dispose();
                MaximumHoursLabel = null;
            }

            if (NonBillableLegendLabel != null)
            {
                NonBillableLegendLabel.Dispose();
                NonBillableLegendLabel = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }
        }