public override void OnViewModelLoadedOverride()
        {
            _itemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UIGroupedTimeView>(StackView)
            {
                ItemsSource = ViewModel.TimesGroupedByDay
            };

            base.OnViewModelLoadedOverride();
        }
        private void Initialize()
        {
            var stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis    = UILayoutConstraintAxis.Vertical,
                Spacing = 16
            };

            base.Add(stackView);
            stackView.StretchWidthAndHeight(this, right: 16);
            {
                UIStackView classesStackView = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 16
                };
                stackView.AddArrangedSubview(classesStackView);
                classesStackView.StretchWidth(stackView, left: 16);

                _itemsSourceClasses = new BareUIStackViewItemsSourceAdapter <UIEditClassScheduleView>(classesStackView);
                _itemsSourceClasses.OnViewCreated += _itemsSourceClasses_OnViewCreated;
                _itemsSourceClasses.ItemsSource    = ViewModel.SemesterViewItemsGroup.Classes;

                UIButton buttonAdd = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                buttonAdd.SetTitle("Add Class", UIControlState.Normal);
                buttonAdd.SetTitleColor(new UIColor(1, 1), UIControlState.Normal);
                buttonAdd.BackgroundColor = ColorResources.PowerPlannerBlueChromeColor;
                buttonAdd.TouchUpInside  += new WeakEventHandler <EventArgs>(delegate { ViewModel.AddClass(); }).Handler;
                stackView.AddArrangedSubview(buttonAdd);
                buttonAdd.StretchWidth(stackView, left: 16);
            }
        }
            public UIGroupedTimeView()
            {
                base.TranslatesAutoresizingMaskIntoConstraints = false;

                BindingHost.SetVisibilityBinding(this, nameof(Group.IsVisible));

                var stackView = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical,
                    TranslatesAutoresizingMaskIntoConstraints = false
                };

                var labelDayOfWeek = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredSubheadline
                };

                BindingHost.SetLabelTextBinding(labelDayOfWeek, nameof(Group.DayOfWeek));
                stackView.AddArrangedSubview(labelDayOfWeek);
                labelDayOfWeek.StretchWidth(stackView);

                var stackViewTimes = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Spacing = 8
                };

                _itemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UITimeView>(stackViewTimes);
                stackView.AddArrangedSubview(stackViewTimes);
                stackViewTimes.StretchWidth(stackView);

                base.AddSubview(stackView);
                stackView.StretchWidthAndHeight(this);
            }
Exemple #4
0
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(235f / 255f, 1);

            // [ [labelName] [labelGPA] ]
            // [ semesterView           ]
            // [ buttonAddSemester      ]

            // stackView
            // + viewNameAndGpa
            //   + labelName
            //   + labelGpa
            // + semesterView
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 12
            };

            // Name and GPA
            var viewNameAndGpa = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndGpa.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditYear?.Invoke(this, DataContext as ViewItemYear); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemYear.Name));
                viewNameAndGpa.AddSubview(labelName);

                var labelGpa = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelGpa, nameof(ViewItemYear.GPA), (gpa) =>
                {
                    return(((double)gpa).ToString("0.0##"));
                });
                viewNameAndGpa.AddSubview(labelGpa);

                viewNameAndGpa.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelGpa]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("labelName", labelName, "labelGpa", labelGpa)));
                labelName.StretchHeight(viewNameAndGpa);
                labelGpa.StretchHeight(viewNameAndGpa);
            }
            stackView.AddArrangedSubview(viewNameAndGpa);
            viewNameAndGpa.StretchWidth(stackView);

            // Semester
            var stackViewSemesters = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            _itemsSourceSemesters = new BareUIStackViewItemsSourceAdapter <UISemesterView>(stackViewSemesters);
            _itemsSourceSemesters.OnViewCreated += _itemsSourceSemesters_OnViewCreated;
            stackView.AddArrangedSubview(stackViewSemesters);
            stackViewSemesters.StretchWidth(stackView);

            // Add semester button
            var buttonAddSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAddSemester.SetTitle("Add Semester", UIControlState.Normal);
            buttonAddSemester.TouchUpInside += new WeakEventHandler(ButtonAddSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonAddSemester);
            buttonAddSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
Exemple #5
0
        public UIDayScheduleSnapshot()
        {
            var background = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor
            };

            {
                var paddingContainer = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    _stackViewHolidays = new UIStackView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Axis    = UILayoutConstraintAxis.Vertical,
                        Spacing = 1
                    };
                    paddingContainer.Add(_stackViewHolidays);
                    _stackViewHolidays.StretchWidth(paddingContainer);

                    _timetable = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _scheduleGapLines = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleGapLines);
                        _scheduleGapLines.StretchWidthAndHeight(_timetable);

                        _scheduleTimesColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleTimesColumn);
                        _scheduleTimesColumn.StretchHeight(_timetable);
                        _scheduleTimesColumn.SetWidth(TIME_INDICATOR_SIZE);
                        _scheduleTimesColumn.PinToLeft(_timetable);

                        var verticalDivider = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            BackgroundColor = UIColorCompat.SecondaryLabelColor
                        };
                        _timetable.Add(verticalDivider);
                        verticalDivider.StretchHeight(_timetable);
                        verticalDivider.SetWidth(GAP_SIZE);
                        verticalDivider.PinToLeft(_timetable, left: (int)TIME_INDICATOR_SIZE);

                        _scheduleItemsColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleItemsColumn);
                        _scheduleItemsColumn.StretchHeight(_timetable);
                        _scheduleItemsColumn.StretchWidth(_timetable, left: TIME_INDICATOR_SIZE + GAP_SIZE + 8, right: 8);

                        // Normally we would have used constraints to lay these out horizontally, but for some reason constraints
                        // are acting up and the horizontal constraints weren't working correctly, so just pinning things to the left
                        // and applying correct padding
                        // Maybe it was because I originally forgot TranslatesAutoresizing on the verticalDivider... that would explain it
                    }
                    paddingContainer.Add(_timetable);
                    _timetable.StretchWidth(paddingContainer);

                    _holidaysItemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UIMainCalendarItemView>(_stackViewHolidays);

                    paddingContainer.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[holidays][timetable]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                        "holidays", _stackViewHolidays,
                                                                                        "timetable", _timetable));
                }
                background.Add(paddingContainer);
                paddingContainer.StretchWidthAndHeight(background);
            }
            this.Add(background);
            background.StretchWidthAndHeight(this, top: 16, bottom: 16);
        }
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(247f / 255f, 1);

            // [ [labelName] [labelDates] ]
            // [ [class] [credits] [gpa]  ]
            // [ stackViewClasses         ]
            // [ buttonOpenSemester       ]

            // stackView
            // + viewNameAndDates
            //   + labelName
            //   + labelDates
            // + stackViewClassesTable
            //   + viewClassesTableHeader
            //     + labelHeaderClass
            //     + labelHeaderCredits
            //     + labelHeaderGpa
            //   + stackViewClasses
            //   + viewClassesTableFooter
            //     + labelTotal
            //     + labelTotalCredits
            //     + labelTotalGpa
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            // Name and dates
            var viewNameAndDates = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndDates.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemSemester.Name));
                viewNameAndDates.AddSubview(labelName);

                var labelDates = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = UIFont.PreferredCaption2,
                    TextColor     = UIColor.DarkGray,
                    Lines         = 0,
                    TextAlignment = UITextAlignment.Right
                };
                BindingHost.SetLabelTextBinding(labelDates, nameof(ViewItemSemester.Start), delegate
                {
                    return(SemesterToSemesterViewStartEndStringConverter.Convert(DataContext as ViewItemSemester));
                });
                viewNameAndDates.AddSubview(labelDates);

                viewNameAndDates.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelDates]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                        "labelName", labelName,
                                                                                        "labelDates", labelDates)));
                labelName.StretchHeight(viewNameAndDates);
                labelDates.StretchHeight(viewNameAndDates);
            }
            stackView.AddArrangedSubview(viewNameAndDates);
            viewNameAndDates.StretchWidth(stackView);

            // Table
            var classesTouchContainer = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            classesTouchContainer.TouchUpInside += new WeakEventHandler(delegate { OnRequestOpenSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var stackViewClassesTable = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical,
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    // Table header
                    var viewClassesTableHeader = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelHeaderClass = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text      = "Class",
                            Font      = UIFont.PreferredCaption2,
                            TextColor = UIColor.DarkGray
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderClass);

                        var labelHeaderCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "Credits",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderCredits);

                        var labelHeaderGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "GPA",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderGpa);

                        viewClassesTableHeader.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelHeaderClass]->=6-[labelHeaderCredits(50)]-6-[labelHeaderGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelHeaderClass", labelHeaderClass,
                                                                                                      "labelHeaderCredits", labelHeaderCredits,
                                                                                                      "labelHeaderGpa", labelHeaderGpa)));
                        labelHeaderClass.StretchHeight(viewClassesTableHeader);
                        labelHeaderCredits.StretchHeight(viewClassesTableHeader);
                        labelHeaderGpa.StretchHeight(viewClassesTableHeader);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableHeader);
                    viewClassesTableHeader.StretchWidth(stackViewClassesTable);

                    // Classes stack view
                    var stackViewClasses = new UIStackView()
                    {
                        Axis = UILayoutConstraintAxis.Vertical,
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    _itemsSourceClasses = new BareUIStackViewItemsSourceAdapter <UIClassView>(stackViewClasses);
                    stackViewClassesTable.AddArrangedSubview(stackViewClasses);
                    stackViewClasses.StretchWidth(stackViewClassesTable);

                    // Totals
                    var viewClassesTableFooter = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelTotal = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text = "Total",
                            Font = UIFont.PreferredFootnote
                        };
                        viewClassesTableFooter.AddSubview(labelTotal);

                        var labelTotalCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalCredits, nameof(ViewItemSemester.CreditsEarned), (credits) =>
                        {
                            return(CreditsToStringConverter.Convert(credits));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalCredits);

                        var labelTotalGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalGpa, nameof(ViewItemSemester.GPA), (gpa) =>
                        {
                            return(GpaToStringConverter.Convert(gpa));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalGpa);

                        viewClassesTableFooter.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelTotal]->=6-[labelTotalCredits(50)]-6-[labelTotalGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelTotal", labelTotal,
                                                                                                      "labelTotalCredits", labelTotalCredits,
                                                                                                      "labelTotalGpa", labelTotalGpa)));
                        labelTotal.StretchHeight(viewClassesTableFooter);
                        labelTotalCredits.StretchHeight(viewClassesTableFooter);
                        labelTotalGpa.StretchHeight(viewClassesTableFooter);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableFooter);
                    viewClassesTableFooter.StretchWidth(stackViewClassesTable);
                }
                classesTouchContainer.Add(stackViewClassesTable);
                stackViewClassesTable.StretchWidthAndHeight(classesTouchContainer);
            }
            stackView.AddArrangedSubview(classesTouchContainer);
            classesTouchContainer.StretchWidth(stackView);

            // Add semester button
            var buttonOpenSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonOpenSemester.SetTitle("Open Semester", UIControlState.Normal);
            buttonOpenSemester.TouchUpInside += new WeakEventHandler(ButtonOpenSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonOpenSemester);
            buttonOpenSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
 public UIAdditionalItemsView()
 {
     base.Spacing        = 2;
     _itemsSourceAdapter = new BareUIStackViewItemsSourceAdapter(this, CreateCircle);
     this.SetWidth(WIDTH);
 }
Exemple #8
0
        public override void OnViewModelLoadedOverride()
        {
            _loadingIndicator.StopAnimating();
            _loadingIndicator.RemoveFromSuperview();
            _loadingIndicator = null;

            _schoolBindingHost = new BindingHost()
            {
                BindingObject = ViewModel.YearsViewItemsGroup.School
            };

            var overallText = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.PreferredTitle1,
                AdjustsFontSizeToFitWidth = true,
                Lines = 1
            };
            Action updateOverallText = delegate
            {
                overallText.Text = "Overall: " + GpaToStringConverter.Convert(ViewModel.YearsViewItemsGroup.School.GPA, includeGpa: true) + " / " + CreditsToStringConverter.Convert(ViewModel.YearsViewItemsGroup.School.CreditsEarned, includeCredits: true);
            };

            _schoolBindingHost.SetBinding(nameof(ViewModel.YearsViewItemsGroup.School.GPA), updateOverallText);
            _schoolBindingHost.SetBinding(nameof(ViewModel.YearsViewItemsGroup.School.CreditsEarned), updateOverallText);
            StackView.AddArrangedSubview(overallText);
            overallText.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            }.SetHeight(16));

            var stackViewYears = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 16
            };

            _itemsSourceYears = new BareUIStackViewItemsSourceAdapter <UIYearView>(stackViewYears);
            _itemsSourceYears.OnViewCreated += _itemsSourceYears_OnViewCreated;
            _itemsSourceYears.ItemsSource    = ViewModel.YearsViewItemsGroup.School.Years;
            StackView.AddArrangedSubview(stackViewYears);
            stackViewYears.StretchWidth(StackView);

            StackView.AddSpacing(16);

            var buttonAddYear = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAddYear.SetTitle("Add Year", UIControlState.Normal);
            buttonAddYear.TouchUpInside += new WeakEventHandler(delegate { ViewModel.AddYear(); }).Handler;
            StackView.AddArrangedSubview(buttonAddYear);
            buttonAddYear.StretchWidth(StackView);

            MainScreenViewController.ListenToTabBarHeightChanged(ref _tabBarHeightListener, delegate
            {
                _scrollView.ContentInset = new UIEdgeInsets(0, 0, MainScreenViewController.TAB_BAR_HEIGHT, 0);
            });

            base.OnViewModelLoadedOverride();
        }
        public UIEditClassScheduleView()
        {
            base.BackgroundColor = new UIColor(235f / 255f, 1);

            var headerView = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                const int CIRCLE_HEIGHT = 18;

                _circle      = new CAShapeLayer();
                _circle.Path = CGPath.EllipseFromRect(new CGRect(8, 3, CIRCLE_HEIGHT, CIRCLE_HEIGHT));
                BindingHost.SetColorBinding(_circle, nameof(ViewItemClass.Color));
                headerView.Layer.AddSublayer(_circle);

                _labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font  = UIFont.PreferredTitle3,
                    Lines = 1
                };
                BindingHost.SetLabelTextBinding(_labelName, nameof(ViewItemClass.Name));
                headerView.Add(_labelName);
                _labelName.StretchWidthAndHeight(headerView, left:  CIRCLE_HEIGHT + 8 + 8, right: 8);

                headerView.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { OnRequestEditClass(this, DataContext as ViewItemClass); }).Handler;
            }
            this.Add(headerView);
            headerView.StretchWidth(this);

            // Times
            var stackViewTimes = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis    = UILayoutConstraintAxis.Vertical,
                Spacing = 8
            };

            {
                _timesAdapter = new BareUIStackViewItemsSourceAdapter <UIEditClassScheduleTimeView>(stackViewTimes);
                _timesAdapter.OnViewCreated += _timesAdapter_OnViewCreated;
            }
            this.Add(stackViewTimes);
            stackViewTimes.StretchWidth(this);

            // Button
            var buttonAdd = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAdd.SetTitle("Add Time", UIControlState.Normal);
            buttonAdd.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { OnRequestAddTime?.Invoke(this, DataContext as ViewItemClass); }).Handler;
            this.Add(buttonAdd);
            buttonAdd.StretchWidth(this, left: 8, right: 8);

            this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-8-[headerView]-8-[stackViewTimes]-8-[buttonAdd]-8-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                        "headerView", headerView,
                                                                        "stackViewTimes", stackViewTimes,
                                                                        "buttonAdd", buttonAdd)));
        }
Exemple #10
0
        public UIScheduleView(ScheduleViewModel viewModel)
        {
            this.MaximumZoomScale            = 1f;
            this.MinimumZoomScale            = 0.3f;
            this.ViewForZoomingInScrollView += delegate { return(_mainView); };
            this.BackgroundColor             = UIColorCompat.SystemBackgroundColor;

            ViewModel = viewModel;
            ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;

            _mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            this.Add(_mainView);
            _mainView.ConfigureForMultiDirectionScrolling(this);

            _timesColumn = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SystemGray4Color
            };
            _mainView.Add(_timesColumn);
            _timesColumn.StretchHeight(_mainView);

            _contentColumn = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _mainView.Add(_contentColumn);
            _contentColumn.StretchHeight(_mainView);
            _mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[timesColumn][contentColumn]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                             "timesColumn", _timesColumn,
                                                                             "contentColumn", _contentColumn)));

            // Days row
            _daysRow = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SystemGray4Color
            };
            _contentColumn.Add(_daysRow);
            _daysRow.StretchWidth(_contentColumn);

            // All day items row
            _allDayItemsRow = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _contentColumn.Add(_allDayItemsRow);
            _allDayItemsRow.StretchWidth(_contentColumn);

            // Schedule row
            _scheduleRow = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _contentColumn.Add(_scheduleRow);
            _scheduleRow.StretchWidth(_contentColumn);

            //_daysRow.PinToTop(_contentColumn);
            //_scheduleRow.StretchHeight(_contentColumn);
            _contentColumn.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|[daysRow][allDayItemsRow][scheduleRow]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                  "daysRow", _daysRow,
                                                                                  "allDayItemsRow", _allDayItemsRow,
                                                                                  "scheduleRow", _scheduleRow)));

            // Make scheduleRow be the big one, allDayItemsRow shrink
            _scheduleRow.SetContentCompressionResistancePriority(501, UILayoutConstraintAxis.Vertical);
            _allDayItemsRow.SetContentCompressionResistancePriority(499, UILayoutConstraintAxis.Vertical);

            // Populate days columns
            UIView prevDayLabel       = null;
            UIView prevAllDayItems    = null;
            UIView prevScheduleColumn = null;

            for (int i = 0; i < 7; i++)
            {
                // Day header
                var dayLabel = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font  = UIFont.PreferredSubheadline,
                    Lines = 1
                };
                _daysRow.Add(dayLabel);
                if (prevDayLabel == null)
                {
                    dayLabel.PinToLeft(_daysRow, COL_PADDING);
                }
                else
                {
                    dayLabel.SetToRightOf(prevDayLabel, _daysRow, COL_PADDING);
                }
                dayLabel.SetWidth(COL_WIDTH - COL_PADDING);
                dayLabel.StretchHeight(_daysRow, top: 3, bottom: 3);
                _dayLabels[i] = dayLabel;
                prevDayLabel  = dayLabel;

                // All day items
                var allDayItemsStackView = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 1
                };
                {
                    var itemsSource = new BareUIStackViewItemsSourceAdapter(allDayItemsStackView, CreateAllDayItemView);
                    _allDayItemSourceAdapters[i] = itemsSource;
                }
                UIView allDayItemsView = allDayItemsStackView;
                // Have to place the stack view in a view since background doesn't render on stack view itself
                allDayItemsView = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor
                };
                allDayItemsView.Add(allDayItemsStackView);
                allDayItemsStackView.StretchWidthAndHeight(allDayItemsView, right: 1);
                if (i % 2 != 0)
                {
                    // Alternate light and dark
                    allDayItemsView.BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor;
                }
                else
                {
                    allDayItemsView.BackgroundColor = UIColorCompat.SystemBackgroundColor;
                }
                _allDayItemsRow.Add(allDayItemsView);
                if (prevAllDayItems == null)
                {
                    allDayItemsView.PinToLeft(_allDayItemsRow);
                }
                else
                {
                    allDayItemsView.SetToRightOf(prevAllDayItems, _allDayItemsRow);
                }
                allDayItemsView.SetWidth(COL_WIDTH);
                allDayItemsView.StretchHeight(_allDayItemsRow);
                prevAllDayItems = allDayItemsView;

                // Schedule column
                var scheduleColumn = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                if (i % 2 != 0)
                {
                    // Alternate light and dark
                    scheduleColumn.BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor;
                }
                _scheduleRow.Add(scheduleColumn);
                if (prevScheduleColumn == null)
                {
                    scheduleColumn.PinToLeft(_scheduleRow);
                }
                else
                {
                    scheduleColumn.SetToRightOf(prevScheduleColumn, _scheduleRow);
                }
                scheduleColumn.SetWidth(COL_WIDTH);
                scheduleColumn.StretchHeight(_scheduleRow);
                _scheduleColumns[i] = scheduleColumn;
                prevScheduleColumn  = scheduleColumn;
            }

            ViewModel.InitializeArrangers(HEIGHT_OF_HOUR, UIScheduleViewEventItemCollapsed.SPACING_WITH_NO_ADDITIONAL, UIScheduleViewEventItemCollapsed.SPACING_WITH_ADDITIONAL, UIScheduleViewEventItemCollapsed.WIDTH_OF_COLLAPSED_ITEM);
            ViewModel.OnFullReset           += new WeakEventHandler <EventArgs>(ViewModel_OnFullReset).Handler;
            ViewModel.OnItemsForDateChanged += new WeakEventHandler <DateTime>(ViewModel_OnItemsForDateChanged).Handler;

            MainScreenViewController.ListenToTabBarHeightChanged(ref _tabBarHeightListener, delegate
            {
                // Plus 44 for the toolbar that also appears
                this.ContentInset = new UIEdgeInsets(0, 0, MainScreenViewController.TAB_BAR_HEIGHT + 44, 0);
            });

            UpdateWidth();

            Render();
        }