public ConfigureClassPassingGradeViewController()
        {
            Title = PowerPlannerResources.GetString("Settings_GradeOptions_ListItemPassingGrade.Title");

            PowerPlannerUIHelper.ConfigureForInputsStyle(this);

            var cancelButton = new UIBarButtonItem()
            {
                Title = PowerPlannerResources.GetStringCancel()
            };

            cancelButton.Clicked            += new WeakEventHandler <EventArgs>(CancelButton_Clicked).Handler;
            NavigationItem.LeftBarButtonItem = cancelButton;

            var saveButton = new UIBarButtonItem()
            {
                Title = PowerPlannerResources.GetStringSave()
            };

            saveButton.Clicked += new WeakEventHandler <EventArgs>(SaveButton_Clicked).Handler;
            NavigationItem.RightBarButtonItem = saveButton;

            StackView.AddSectionDivider();

            var textFieldPassingGrade = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                KeyboardType = UIKeyboardType.DecimalPad,
                AdjustsFontSizeToFitWidth = true,
                Placeholder = PowerPlannerResources.GetExamplePlaceholderString(60.ToString())
            };

            BindingHost.SetTextFieldTextBinding <double>(textFieldPassingGrade, nameof(ViewModel.PassingGrade), converter: TextToDoubleConverter.Convert, backConverter: TextToDoubleConverter.ConvertBack);
            AddTextField(StackView, textFieldPassingGrade, firstResponder: true);

            StackView.AddSectionDivider();
            StackView.AddSpacing(16);

            var labelDescription = new UILabel()
            {
                Text      = PowerPlannerResources.GetString("Settings_GradeOptions_PassingGrade_Explanation.Text"),
                Lines     = 0,
                Font      = UIFont.PreferredCaption1,
                TextColor = UIColor.LightGray
            };

            StackView.AddArrangedSubview(labelDescription);
            labelDescription.StretchWidth(StackView, left: 16, right: 16);

            StackView.AddSpacing(16);
            StackView.AddBottomSectionDivider();
        }
Esempio n. 2
0
        public override void OnViewModelLoadedOverride()
        {
            AddTopSectionDivider();

            if (ViewModel.Message != null)
            {
                StackView.AddSpacing(8);

                var labelMessage = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text  = ViewModel.Message,
                    Font  = UIFont.PreferredCaption1,
                    Lines = 0
                };

                StackView.AddArrangedSubview(labelMessage);
                labelMessage.StretchWidth(StackView, left: 16, right: 16);

                StackView.AddSpacing(8);

                AddSectionDivider();
            }

            AddTextField(new UITextField()
            {
                Placeholder                   = "Username",
                AutocapitalizationType        = UITextAutocapitalizationType.None,
                AutocorrectionType            = UITextAutocorrectionType.No,
                KeyboardType                  = UIKeyboardType.ASCIICapable,
                ReturnKeyType                 = UIReturnKeyType.Next,
                EnablesReturnKeyAutomatically = true
            }, nameof(ViewModel.Username), firstResponder: true);

            AddDivider();

            AddTextField(new UITextField()
            {
                Placeholder     = "Password",
                SecureTextEntry = true,
                ReturnKeyType   = UIReturnKeyType.Go,
                EnablesReturnKeyAutomatically = true
            }, nameof(ViewModel.Password));

            AddSectionDivider();

            _buttonLogin = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _buttonLogin.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { Login(); }).Handler;
            _buttonLogin.SetTitle("Log In", UIControlState.Normal);
            StackView.AddArrangedSubview(_buttonLogin);
            _buttonLogin.StretchWidth(StackView);
            _buttonLogin.SetHeight(44);

            AddDivider(fullWidth: true);

            var forgotViews = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = ColorResources.InputSectionDividers
            };

            {
                var leftSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                forgotViews.Add(leftSpacer);
                var rightSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                forgotViews.Add(rightSpacer);

                var buttonForgotUsername = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HorizontalAlignment = UIControlContentHorizontalAlignment.Right,
                    Font = UIFont.PreferredCaption1
                };
                buttonForgotUsername.TouchUpInside += new WeakEventHandler(delegate { ViewModel.ForgotUsername(); }).Handler;
                buttonForgotUsername.SetTitle("Forgot Username", UIControlState.Normal);
                forgotViews.Add(buttonForgotUsername);
                buttonForgotUsername.StretchHeight(forgotViews);

                var verticalDivider = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = UIColor.FromWhiteAlpha(0.7f, 1)
                };
                forgotViews.Add(verticalDivider);
                verticalDivider.StretchHeight(forgotViews, top: 16, bottom: 16);

                var buttonForgotPassword = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HorizontalAlignment = UIControlContentHorizontalAlignment.Left,
                    Font = UIFont.PreferredCaption1
                };
                buttonForgotPassword.TouchUpInside += new WeakEventHandler(delegate { ViewModel.ForgotPassword(); }).Handler;
                buttonForgotPassword.SetTitle("Forgot Password", UIControlState.Normal);
                forgotViews.Add(buttonForgotPassword);
                buttonForgotPassword.StretchHeight(forgotViews);

                forgotViews.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[leftSpacer][forgotUsername]-8-[verticalDivider(1)]-8-[forgotPassword][rightSpacer(==leftSpacer)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                   "forgotUsername", buttonForgotUsername,
                                                                                   "verticalDivider", verticalDivider,
                                                                                   "forgotPassword", buttonForgotPassword,
                                                                                   "leftSpacer", leftSpacer,
                                                                                   "rightSpacer", rightSpacer)));
            }
            StackView.AddArrangedSubview(forgotViews);
            forgotViews.StretchWidth(StackView);
            forgotViews.SetHeight(44);

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

            base.OnViewModelLoadedOverride();
        }
Esempio n. 3
0
        public ViewGradeViewController()
        {
            Title = "View Grade";

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonDelete = new UIBarButtonItem(UIBarButtonSystemItem.Trash);

            buttonDelete.Clicked += new WeakEventHandler(ButtonDelete_Clicked).Handler;

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonDelete,
                buttonEdit
            };

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Grade.Name));
            StackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

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

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemGrade.GradeSubtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            StackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelDate = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredSubheadline,
                TextColor = UIColor.DarkGray
            };

            _itemBindingHost.SetBinding <DateTime>(nameof(ViewItemGrade.Date), (date) =>
            {
                labelDate.Text = date.ToString("d");
            });
            StackView.AddArrangedSubview(labelDate);
            labelDate.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            StackView.AddSpacing(12);

            var textViewDetails = new UITextView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.PreferredBody,
                TextColor     = UIColor.DarkGray,
                Editable      = false,
                ScrollEnabled = false,

                // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html
                DataDetectorTypes = UIDataDetectorType.All
            };

            // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
            textViewDetails.TextContainerInset = UIEdgeInsets.Zero;
            textViewDetails.TextContainer.LineFragmentPadding = 0;

            _itemBindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewItemGrade.Details));
            StackView.AddArrangedSubview(textViewDetails);
            textViewDetails.StretchWidth(StackView);
        }
Esempio n. 4
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();
        }