Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var bindingSet = this.CreateBindingSet <SessionListingView, SessionListingViewModel>();

            bindingSet = BindLoader(bindingSet);

            var refreshButton = new UIButton(UIButtonType.Custom);

            refreshButton.SetImage(UIImage.FromBundle("Images/refresh.png"), UIControlState.Normal);
            refreshButton.Frame = new RectangleF(0, 0, 30, 30);

            bindingSet.Bind(refreshButton)
            .For("TouchUpInside")
            .To(vm => vm.RefreshCommand).Apply();

            var addButton = new UIButton(UIButtonType.Custom);

            addButton.SetImage(UIImage.FromBundle("Images/add.png"), UIControlState.Normal);
            addButton.Frame = new RectangleF(0, 0, 30, 30);

            bindingSet.Bind(addButton)
            .For("TouchUpInside")
            .To(vm => vm.NavigateToAddCommand).Apply();

            NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace, null, null)
                {
                    Width = -10f
                },
                new UIBarButtonItem(refreshButton),
                new UIBarButtonItem(addButton),
            }, false);

            _table = new TTableView();
            Add(_table);

            var tableSource = new SessionTableSource(_table);

            bindingSet.Bind(tableSource).To(vm => vm.SessionsCollection).Apply();
            bindingSet.Bind(tableSource).For(vm => vm.SelectionChangedCommand).To(vm => vm.NavigateCommand).Apply();

            View.AddConstraints(new FluentLayout[]
            {
                _table.AtTopOf(View),
                _table.AtLeftOf(View),
                _table.WithSameWidth(View),
                _table.AtBottomOf(View)
            });

            _table.Source = tableSource;
            _table.ReloadData();
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var bindingSet = this.CreateBindingSet <AddSessionView, AddSessionViewModel>();

            bindingSet = BindLoader(bindingSet);

            var sessionDateTextField = new TFloatingPicker(new CGRect())
            {
                Placeholder = "When?"
            };

            this.View.Add(sessionDateTextField);
            bindingSet.Bind(sessionDateTextField).To("Format('{0:d MMM yyyy}', SessionDate)").Apply();
            bindingSet.Bind(sessionDateTextField).For("ValidationError").To(vm => vm.ValidationErrors[nameof(AddSessionViewModel.SessionDate)]).Apply();

            /* picker */
            /* ******************************************************* */
            var sessionDatePicker = new UIDatePicker();

            sessionDatePicker.Mode = UIDatePickerMode.Date;

            var sessionDateToolbar = new UIToolbar(new CGRect(0.0f, 0.0f, sessionDatePicker.Frame.Size.Width, 44.0f));

            sessionDateTextField.InputAccessoryView = sessionDateToolbar;
            sessionDateTextField.InputView          = sessionDatePicker;

            sessionDateToolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
                {
                    sessionDateTextField.ResignFirstResponder();
                })
            };

            bindingSet.Bind(sessionDatePicker).To(vm => vm.SessionDate).Apply();
            /* ******************************************************* */

            var gameTextField = new TFloatingTextField(new CGRect())
            {
                Placeholder = "What?",
                Editable    = false
            };

            this.View.Add(gameTextField);
            bindingSet.Bind(gameTextField).To(vm => vm.SelectedGame).Apply();
            bindingSet.Bind(gameTextField).For("ValidationError").To(vm => vm.ValidationErrors[nameof(AddSessionViewModel.SelectedGame)]).Apply();

            /* picker */
            /* ******************************************************* */
            var gamePicker          = new UIPickerView();
            var gamePickerViewModel = new MvxPickerViewModel(gamePicker);

            gamePicker.Model = gamePickerViewModel;

            var gamePickerToolbar = new UIToolbar(new CGRect(0.0f, 0.0f, gamePicker.Frame.Size.Width, 44.0f));

            gameTextField.InputAccessoryView = gamePickerToolbar;
            gameTextField.InputView          = gamePicker;

            gamePickerToolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
                {
                    gameTextField.ResignFirstResponder();
                })
            };

            bindingSet.Bind(gamePickerViewModel).For(p => p.SelectedItem).To(vm => vm.SelectedGame).Apply();
            bindingSet.Bind(gamePickerViewModel).For(p => p.ItemsSource).To(vm => vm.GamesCollection).Apply();
            /* ******************************************************* */

            var whereTextField = new TFloatingTextField(new CGRect())
            {
                Placeholder = "Where?"
            };

            this.View.Add(whereTextField);
            bindingSet.Bind(whereTextField).To(vm => vm.Venue).Apply();
            bindingSet.Bind(whereTextField).For("ValidationError").To(vm => vm.ValidationErrors[nameof(AddSessionViewModel.Venue)]).Apply();

            var playerListing = new TTableView
            {
                AllowsSelection = false
            };

            this.View.Add(playerListing);

            var tableSource = new PlayerTableSource(playerListing);

            bindingSet.Bind(tableSource).To(vm => vm.PlayerCollection).Apply();

            var saveButton = new TButtonView("Save");

            this.View.Add(saveButton);
            bindingSet.Bind(saveButton).To(vm => vm.SaveCommand).Apply();

            var gradientTopView = new TGradientView(ColorPalette.Carnelian, ColorPalette.Carnelian.ColorWithAlpha(0));

            this.View.Add(gradientTopView);

            var gradientBottomView = new TGradientView(ColorPalette.Carnelian.ColorWithAlpha(0), ColorPalette.Carnelian);

            this.View.Add(gradientBottomView);

            this.View.AddConstraints(new FluentLayout[] {
                sessionDateTextField.AtTopOf(this.View, Constants.MARGIN),
                sessionDateTextField.AtLeftOf(this.View, Constants.MARGIN),
                sessionDateTextField.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),

                gameTextField.Below(sessionDateTextField, Constants.MARGIN),
                gameTextField.AtLeftOf(this.View, Constants.MARGIN),
                gameTextField.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),

                whereTextField.Below(gameTextField, Constants.MARGIN),
                whereTextField.AtLeftOf(this.View, Constants.MARGIN),
                whereTextField.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),

                playerListing.Below(whereTextField, Constants.MARGIN),
                playerListing.AtLeftOf(this.View, Constants.MARGIN),
                playerListing.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),
                playerListing.Above(saveButton, Constants.MARGIN),

                saveButton.AtBottomOf(this.View, Constants.MARGIN),
                saveButton.Height().EqualTo(Constants.BUTTON_HEIGHT),
                saveButton.AtLeftOf(this.View, Constants.MARGIN),
                saveButton.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),

                gradientTopView.Below(whereTextField, Constants.MARGIN),
                gradientTopView.AtLeftOf(this.View, Constants.MARGIN),
                gradientTopView.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),
                gradientTopView.Height().EqualTo(10f),

                gradientBottomView.Above(saveButton, Constants.MARGIN),
                gradientBottomView.AtLeftOf(this.View, Constants.MARGIN),
                gradientBottomView.WithSameWidth(this.View).Minus(Constants.MARGIN * 2),
                gradientBottomView.Height().EqualTo(10f),
            });

            playerListing.Source = tableSource;
            playerListing.ReloadData();
        }
Ejemplo n.º 3
0
 public PlayerTableSource(TTableView tableView) : base(tableView)
 {
     tableView.RegisterClassForCellReuse(typeof(PlayerListingItemCell), PlayerListingItemCell.CellIdentifier);
 }
Ejemplo n.º 4
0
 public SessionTableSource(TTableView tableView) : base(tableView)
 {
     tableView.RegisterClassForCellReuse(typeof(SessionListingItemCell), SessionListingItemCell.CellIdentifier);
 }