Ejemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (BarChartContainerView != null)
            {
                BarChartContainerView.Dispose();
                BarChartContainerView = null;
            }

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

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

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

            if (PieChartView != null)
            {
                PieChartView.Dispose();
                PieChartView = null;
            }
        }
Ejemplo n.º 2
0
        protected override void UpdateView()
        {
            overview.Item = Item;
            barChart.Item = Item;

            //Loading chart
            Item.GroupedSegmentsObservable
            .Select(segments => segments == null)
            .Subscribe(LoadingPieChartView.Rx().IsVisibleWithFade())
            .DisposedBy(disposeBag);

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

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

            //Visibility
            Item.ShowEmptyStateObservable
            .Subscribe(EmptyStateView.Rx().IsVisible())
            .DisposedBy(disposeBag);
        }
Ejemplo n.º 3
0
        void ReleaseDesignerOutlets()
        {
            if (BarChartContainerView != null)
            {
                BarChartContainerView.Dispose();
                BarChartContainerView = null;
            }

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

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

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

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

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

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

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

            if (PieChartBackground != null)
            {
                PieChartBackground.Dispose();
                PieChartBackground = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (EmptyStateButton != null)
            {
                EmptyStateButton.Dispose();
                EmptyStateButton = null;
            }

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

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

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

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

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

            if (WelcomeImageView != null)
            {
                WelcomeImageView.Dispose();
                WelcomeImageView = null;
            }
        }
Ejemplo n.º 5
0
        void ReleaseDesignerOutlets()
        {
            if (BillablePercentageLabel != null)
            {
                BillablePercentageLabel.Dispose();
                BillablePercentageLabel = null;
            }

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

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

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

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

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

            if (TotalDurationLabel != null)
            {
                TotalDurationLabel.Dispose();
                TotalDurationLabel = null;
            }
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 8
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);
            });
        }