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
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            OverviewContainerView.AddSubview(overview);
            BarChartContainerView.AddSubview(barChart);
            overview.Frame = OverviewContainerView.Bounds;
            barChart.Frame = BarChartContainerView.Bounds;
        }
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;
            }
        }
Ejemplo n.º 4
0
        void ReleaseDesignerOutlets()
        {
            if (BarChartsContainerView != null)
            {
                BarChartsContainerView.Dispose();
                BarChartsContainerView = null;
            }

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

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

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

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

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

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

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

            if (ContentWidthConstraint != null)
            {
                ContentWidthConstraint.Dispose();
                ContentWidthConstraint = null;
            }
        }
Ejemplo n.º 5
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            OverviewContainerView.AddSubview(overview);
            BarChartContainerView.AddSubview(barChart);
            overview.Frame = OverviewContainerView.Bounds;
            barChart.Frame = BarChartContainerView.Bounds;

            EmptyStateTitleLabel.Text       = Resources.ReportsEmptyStateTitle;
            EmptyStateDescriptionLabel.Text = Resources.ReportsEmptyStateDescription;
        }
Ejemplo n.º 6
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            OverviewContainerView.AddSubview(overview);
            BarChartContainerView.AddSubview(barChart);
            overview.Frame = OverviewContainerView.Bounds;
            barChart.Frame = BarChartContainerView.Bounds;

            EmptyStateTitleLabel.Text       = Resources.ReportsEmptyStateTitle;
            EmptyStateDescriptionLabel.Text = Resources.ReportsEmptyStateDescription;

            PieChartBackground.BackgroundColor = TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular
                ? ColorAssets.CellBackground
                : UIColor.Clear;
        }
Ejemplo n.º 7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            calendarViewController = ViewControllerLocator.GetViewController(ViewModel.CalendarViewModel) as ReportsCalendarViewController;
            prepareViews();

            OverviewContainerView.AddSubview(overview);
            overview.Frame = OverviewContainerView.Bounds;
            overview.Item  = ViewModel;
            BarChartsContainerView.AddSubview(barChart);
            barChart.Frame = BarChartsContainerView.Bounds;
            barChart.Item  = ViewModel;

            calendarSizeDisposable = CalendarContainer.AddObserver(boundsKey, NSKeyValueObservingOptions.New, onCalendarSizeChanged);

            source = new ReportsTableViewSource(ReportsTableView, ViewModel);
            source.SetItems(ImmutableList <ChartSegment> .Empty);
            ReportsTableView.ReloadData();

            ViewModel.SegmentsObservable
            .Subscribe(ReportsTableView.Rx().ReloadItems(source))
            .DisposedBy(DisposeBag);

            source.ScrolledWithHeaderOffset
            .Subscribe(onReportsTableScrolled)
            .DisposedBy(DisposeBag);

            ReportsTableView.Source = source;

            bool areThereEnoughWorkspaces(ICollection <SelectOption <IThreadSafeWorkspace> > workspaces) => workspaces.Count > 1;

            bool isWorkspaceNameTooLong(string workspaceName)
            {
                var attributes = new UIStringAttributes {
                    Font = WorkspaceLabel.Font
                };
                var size     = new NSString(workspaceName).GetSizeUsingAttributes(attributes);
                var maxWidth = TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular
                    ? maximumWorkspaceNameLabelWidthRegular
                    : maximumWorkspaceNameLabelWidthCompact;

                return(size.Width >= maxWidth);
            };

            //Text
            ViewModel.WorkspaceNameObservable
            .Subscribe(WorkspaceLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentDateRange
            .Subscribe(titleButton.Rx().Title())
            .DisposedBy(DisposeBag);

            //Visibility
            ViewModel.WorkspacesObservable
            .Select(areThereEnoughWorkspaces)
            .Subscribe(WorkspaceButton.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.WorkspaceNameObservable
            .Select(isWorkspaceNameTooLong)
            .Subscribe(WorkspaceFadeView.Rx().FadeRight())
            .DisposedBy(DisposeBag);

            //Commands
            titleButton.Rx().Tap()
            .Subscribe(toggleCalendar)
            .DisposedBy(DisposeBag);

            ReportsTableView.Rx().Tap()
            .Subscribe(HideCalendar)
            .DisposedBy(DisposeBag);

            WorkspaceButton.Rx()
            .BindAction(ViewModel.SelectWorkspace)
            .DisposedBy(DisposeBag);

            void toggleCalendar()
            {
                if (calendarIsVisible)
                {
                    HideCalendar();
                    return;
                }

                if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Compact)
                {
                    ShowCalendar();
                    return;
                }

                ShowPopoverCalendar();
            }
        }
Ejemplo n.º 8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var separator = NavigationController.NavigationBar.InsertSeparator();

            separator.BackgroundColor = ColorAssets.OpaqueSeparator;

            calendarViewController = ViewControllerLocator.GetViewController(ViewModel.CalendarViewModel) as ReportsCalendarViewController;
            prepareViews();

            OverviewContainerView.AddSubview(overview);
            overview.Frame = OverviewContainerView.Bounds;
            overview.Item  = ViewModel;
            BarChartsContainerView.AddSubview(barChart);
            barChart.Frame = BarChartsContainerView.Bounds;
            barChart.Item  = ViewModel;

            calendarSizeDisposable = CalendarContainer.AddObserver(boundsKey, NSKeyValueObservingOptions.New, onCalendarSizeChanged);

            source = new ReportsTableViewSource(ReportsTableView, ViewModel);
            source.SetItems(ImmutableList <ChartSegment> .Empty);
            ReportsTableView.ReloadData();

            ViewModel.SegmentsObservable
            .Subscribe(ReportsTableView.Rx().ReloadItems(source))
            .DisposedBy(DisposeBag);

            source.ScrolledWithHeaderOffset
            .Subscribe(onReportsTableScrolled)
            .DisposedBy(DisposeBag);

            ReportsTableView.Source = source;

            bool areThereEnoughWorkspaces(ICollection <SelectOption <IThreadSafeWorkspace> > workspaces) => workspaces.Count > 1;

            bool isWorkspaceNameTooLong(string workspaceName)
            {
                var attributes = new UIStringAttributes {
                    Font = WorkspaceLabel.Font
                };
                var size     = new NSString(workspaceName).GetSizeUsingAttributes(attributes);
                var maxWidth = TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular
                    ? maximumWorkspaceNameLabelWidthRegular
                    : maximumWorkspaceNameLabelWidthCompact;

                return(size.Width >= maxWidth);
            };

            //Text
            ViewModel.WorkspaceNameObservable
            .Subscribe(WorkspaceLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentDateRange
            .Subscribe(titleButton.Rx().TitleAdaptive())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentDateRange
            .Select(range => range == null)
            .DistinctUntilChanged()
            .Subscribe(shouldCenter =>
            {
                if (shouldCenter)
                {
                    activityIndicator.Frame = activityIndicatorCenteredFrame;
                }
                else
                {
                    activityIndicator.Frame = activityIndicatorLeftAlignedFrame;
                }
            })
            .DisposedBy(DisposeBag);

            //Visibility
            ViewModel.WorkspacesObservable
            .Select(areThereEnoughWorkspaces)
            .Do(updateWorkspaceButtonInsets)
            .Subscribe(WorkspaceButton.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.WorkspaceNameObservable
            .Select(isWorkspaceNameTooLong)
            .Subscribe(WorkspaceFadeView.Rx().FadeRight())
            .DisposedBy(DisposeBag);

            ViewModel.IsLoadingObservable
            .Subscribe(activityIndicator.Rx().IsAnimating())
            .DisposedBy(DisposeBag);

            //Commands
            titleButton.Rx().Tap()
            .Subscribe(toggleCalendar)
            .DisposedBy(DisposeBag);

            ReportsTableView.Rx().Tap()
            .Subscribe(HideCalendar)
            .DisposedBy(DisposeBag);

            WorkspaceButton.Rx()
            .BindAction(ViewModel.SelectWorkspace)
            .DisposedBy(DisposeBag);

            //Handoff
            viewDidAppearSubject.AsObservable()
            .CombineLatest(
                ViewModel.WorkspaceId,
                ViewModel.StartDate,
                ViewModel.EndDate,
                (_, workspaceId, start, end) => createUserActivity(workspaceId, start, end))
            .Subscribe(updateUserActivity);

            NSUserActivity createUserActivity(long workspaceId, DateTimeOffset start, DateTimeOffset end)
            {
                var userActivity = new NSUserActivity(Handoff.Action.Reports);

                userActivity.EligibleForHandoff = true;
                userActivity.WebPageUrl         = Handoff.Url.Reports(workspaceId, start, end);
                return(userActivity);
            }

            void updateUserActivity(NSUserActivity userActivity)
            {
                UserActivity = userActivity;
                UserActivity.BecomeCurrent();
            }

            void toggleCalendar()
            {
                if (calendarIsVisible)
                {
                    HideCalendar();
                    return;
                }

                if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Compact)
                {
                    ShowCalendar();
                    return;
                }

                ShowPopoverCalendar();
            }
        }