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

            calendarCollectionViewSource = new ReportsCalendarCollectionViewSource(CalendarCollectionView);
            var calendarCollectionViewLayout = new ReportsCalendarCollectionViewLayout();

            CalendarCollectionView.Delegate             = calendarCollectionViewSource;
            CalendarCollectionView.DataSource           = calendarCollectionViewSource;
            CalendarCollectionView.CollectionViewLayout = calendarCollectionViewLayout;

            var quickSelectCollectionViewSource = new ReportsCalendarQuickSelectCollectionViewSource(QuickSelectCollectionView);

            QuickSelectCollectionView.Source = quickSelectCollectionViewSource;

            ViewModel.DayHeadersObservable
            .Subscribe(setupDayHeaders)
            .DisposedBy(disposeBag);

            ViewModel.MonthsObservable
            .Subscribe(calendarCollectionViewSource.UpdateMonths)
            .DisposedBy(disposeBag);

            calendarCollectionViewSource.DayTaps
            .Subscribe(ViewModel.SelectDay.Inputs)
            .DisposedBy(disposeBag);

            ViewModel.HighlightedDateRangeObservable
            .Subscribe(calendarCollectionViewSource.UpdateSelection)
            .DisposedBy(disposeBag);

            ViewModel.CurrentMonthObservable
            .Select(month => month.Year.ToString())
            .Subscribe(CurrentYearLabel.Rx().Text())
            .DisposedBy(disposeBag);

            ViewModel.CurrentMonthObservable
            .Select(month => month.Month)
            .Select(CultureInfo.GetCultureInfo("en-US").DateTimeFormat.GetMonthName)
            .Subscribe(CurrentMonthLabel.Rx().Text())
            .DisposedBy(disposeBag);

            ViewModel.SelectedDateRangeObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateSelection)
            .DisposedBy(disposeBag);

            quickSelectCollectionViewSource.ShortcutTaps
            .Subscribe(ViewModel.SelectShortcut.Inputs)
            .DisposedBy(disposeBag);

            ViewModel.QuickSelectShortcutsObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateShortcuts)
            .DisposedBy(disposeBag);
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            PreferredContentSize = popoverPreferedSize;

            calendarCollectionViewSource = new ReportsCalendarCollectionViewSource(CalendarCollectionView);
            var calendarCollectionViewLayout = new ReportsCalendarCollectionViewLayout();

            CalendarCollectionView.Delegate             = calendarCollectionViewSource;
            CalendarCollectionView.DataSource           = calendarCollectionViewSource;
            CalendarCollectionView.CollectionViewLayout = calendarCollectionViewLayout;

            var quickSelectCollectionViewSource = new ReportsCalendarQuickSelectCollectionViewSource(QuickSelectCollectionView);

            QuickSelectCollectionView.Source = quickSelectCollectionViewSource;

            ViewModel.DayHeadersObservable
            .Subscribe(setupDayHeaders)
            .DisposedBy(DisposeBag);

            ViewModel.MonthsObservable
            .Subscribe(calendarCollectionViewSource.UpdateMonths)
            .DisposedBy(DisposeBag);

            calendarCollectionViewSource.DayTaps
            .Subscribe(ViewModel.SelectDay.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.HighlightedDateRangeObservable
            .Subscribe(calendarCollectionViewSource.UpdateSelection)
            .DisposedBy(DisposeBag);

            ViewModel.CurrentMonthObservable
            .Select(month =>
            {
                var dateTime = month.ToDateTime();
                var pattern  = CultureInfo.CurrentCulture.DateTimeFormat.YearMonthPattern;

                var yearMonthString = dateTime.ToString(pattern);

                var year       = month.Year.ToString();
                var rangeStart = yearMonthString.IndexOf(year);
                var rangeEnd   = year.Length;
                var range      = new NSRange(rangeStart, rangeEnd);

                var attributedString = new NSMutableAttributedString(
                    yearMonthString,
                    new UIStringAttributes {
                    ForegroundColor = ColorAssets.Text
                });
                attributedString.AddAttributes(
                    new UIStringAttributes {
                    ForegroundColor = ColorAssets.Text2
                },
                    range);

                return(attributedString);
            })
            .Subscribe(CurrentMonthLabel.Rx().AttributedText())
            .DisposedBy(DisposeBag);

            ViewModel.SelectedDateRangeObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateSelection)
            .DisposedBy(DisposeBag);

            quickSelectCollectionViewSource.ShortcutTaps
            .Do(shortcut =>
            {
                IosDependencyContainer.Instance.IntentDonationService.DonateShowReport(shortcut.Period);
            })
            .Subscribe(ViewModel.SelectShortcut.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.QuickSelectShortcutsObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateShortcuts)
            .DisposedBy(DisposeBag);

            ViewModel.ReloadObservable
            .Select(_ => ViewModel.CurrentPage)
            .Subscribe(calendarCollectionViewSource.RefreshUIAtPage)
            .DisposedBy(DisposeBag);
        }
        void ReleaseDesignerOutlets()
        {
            if (CalendarCollectionView != null)
            {
                CalendarCollectionView.Dispose();
                CalendarCollectionView = null;
            }

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

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

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

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

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

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

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

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

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

            if (QuickSelectCollectionViewLayout != null)
            {
                QuickSelectCollectionViewLayout.Dispose();
                QuickSelectCollectionViewLayout = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            PreferredContentSize = popoverPreferedSize;

            calendarCollectionViewSource = new ReportsCalendarCollectionViewSource(CalendarCollectionView);
            var calendarCollectionViewLayout = new ReportsCalendarCollectionViewLayout();

            CalendarCollectionView.Delegate             = calendarCollectionViewSource;
            CalendarCollectionView.DataSource           = calendarCollectionViewSource;
            CalendarCollectionView.CollectionViewLayout = calendarCollectionViewLayout;

            var quickSelectCollectionViewSource = new ReportsCalendarQuickSelectCollectionViewSource(QuickSelectCollectionView);

            QuickSelectCollectionView.Source = quickSelectCollectionViewSource;

            ViewModel.DayHeadersObservable
            .Subscribe(setupDayHeaders)
            .DisposedBy(DisposeBag);

            ViewModel.MonthsObservable
            .Subscribe(calendarCollectionViewSource.UpdateMonths)
            .DisposedBy(DisposeBag);

            calendarCollectionViewSource.DayTaps
            .Subscribe(ViewModel.SelectDay.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.HighlightedDateRangeObservable
            .Subscribe(calendarCollectionViewSource.UpdateSelection)
            .DisposedBy(DisposeBag);

            ViewModel.CurrentMonthObservable
            .Select(month => month.Year.ToString())
            .Subscribe(CurrentYearLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentMonthObservable
            .Select(month => month.Month)
            .Select(CultureInfo.GetCultureInfo("en-US").DateTimeFormat.GetMonthName)
            .Subscribe(CurrentMonthLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.SelectedDateRangeObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateSelection)
            .DisposedBy(DisposeBag);

            quickSelectCollectionViewSource.ShortcutTaps
            .Do(shortcut =>
            {
                IosDependencyContainer.Instance.IntentDonationService.DonateShowReport(shortcut.Period);
            })
            .Subscribe(ViewModel.SelectShortcut.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.QuickSelectShortcutsObservable
            .Subscribe(quickSelectCollectionViewSource.UpdateShortcuts)
            .DisposedBy(DisposeBag);

            ViewModel.ReloadObservable
            .Select(_ => ViewModel.CurrentPage)
            .Subscribe(calendarCollectionViewSource.RefreshUIAtPage)
            .DisposedBy(DisposeBag);
        }