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

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

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

            var quickSelectCollectionViewSource = new ReportsCalendarQuickSelectCollectionViewSource(QuickSelectCollectionView, ReportsCalendarQuickSelectViewCell.Font);

            QuickSelectCollectionView.Source = quickSelectCollectionViewSource;

            setupDayHeaders();

            var bindingSet = this.CreateBindingSet <ReportsCalendarViewController, ReportsCalendarViewModel>();

            //Calendar collection view
            bindingSet.Bind(calendarCollectionViewSource).To(vm => vm.Months);
            bindingSet.Bind(calendarCollectionViewSource)
            .For(v => v.CellTappedCommand)
            .To(vm => vm.CalendarDayTappedCommand);

            //Quick select collection view
            bindingSet.Bind(quickSelectCollectionViewSource).To(vm => vm.QuickSelectShortcuts);
            bindingSet.Bind(quickSelectCollectionViewSource)
            .For(v => v.SelectionChangedCommand)
            .To(vm => vm.QuickSelectCommand);

            //Text
            bindingSet.Bind(CurrentYearLabel).To(vm => vm.CurrentMonth.Year);
            bindingSet.Bind(CurrentMonthLabel)
            .To(vm => vm.CurrentMonth.Month)
            .WithConversion(new IntToMonthNameConverter());

            bindingSet.Apply();
        }
Esempio n. 3
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);
        }
        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);
        }