Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Manage Accounts";
            NavigationController.NavigationBar.PrefersLargeTitles = true;
            View.BackgroundColor = ColorHelper.Background0.ToPlatformColor();

            // Create table source
            var source = new AccountsTableViewSource(TableView);

            TableView.Source = source;

            // Init bindings
            var set = this.CreateBindingSet <AccountsView, AccountsViewModel>();

            set.Bind(source).For(x => x.ItemsSource).To(vm => vm.MusicProviderAccounts);
            set.Bind(source).For(x => x.SelectionChangedCommand).To(vm => vm.InvokeCommand);
            set.Apply();

            // Load Content
            TableView.ReloadData();

            // Cancel button
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Plain, delegate { ViewModel.CloseCommand.Execute(); });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            nsfwSwitch.On     = BasePresenter.User.IsNsfw;
            lowRatedSwitch.On = BasePresenter.User.IsLowRated;

            versionLabel.Font = Constants.Regular12;
            reportButton.Font = termsButton.Font = guideButton.Font = lowRatedLabel.Font = nsfwLabel.Font = addAccountButton.TitleLabel.Font = Constants.Semibold14;
            Constants.CreateShadow(addAccountButton, Constants.R231G72B0, 0.5f, 25, 10, 12);

            _tableSource             = new AccountsTableViewSource();
            _tableSource.Accounts    = BasePresenter.User.GetAllAccounts();
            _tableSource.CellAction += CellAction;

            accountsTable.Source        = _tableSource;
            accountsTable.LayoutMargins = UIEdgeInsets.Zero;
            accountsTable.RegisterClassForCellReuse(typeof(AccountTableViewCell), nameof(AccountTableViewCell));
            accountsTable.RegisterNibForCellReuse(UINib.FromName(nameof(AccountTableViewCell), NSBundle.MainBundle), nameof(AccountTableViewCell));
            accountsTable.RowHeight = 60f;

            lowRatedSwitch.Layer.CornerRadius = nsfwSwitch.Layer.CornerRadius = 16;

            var forwardImage  = new UIImageView();
            var forwardImage2 = new UIImageView();
            var forwardImage3 = new UIImageView();

            forwardImage2.Image = forwardImage3.Image = forwardImage.Image = UIImage.FromBundle("ic_forward");
            guideButton.AddSubview(forwardImage);
            termsButton.AddSubview(forwardImage2);
            reportButton.AddSubview(forwardImage3);

            forwardImage.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            forwardImage.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 0f);

            forwardImage2.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            forwardImage2.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 0f);

            forwardImage3.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            forwardImage3.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 0f);

            var appInfoService = AppSettings.Container.Resolve <IAppInfo>();

            versionLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.AppVersion2, appInfoService.GetAppVersion(), appInfoService.GetBuildVersion());

            reportButton.TouchDown      += SendReport;
            termsButton.TouchDown       += ShowTos;
            guideButton.TouchDown       += ShowGuide;
            lowRatedSwitch.ValueChanged += SwitchLowRated;
            nsfwSwitch.ValueChanged     += SwitchNSFW;
            SetBackButton();

#if !DEBUG
            lowRatedLabel.Hidden = nsfwLabel.Hidden = nsfwSwitch.Hidden = lowRatedSwitch.Hidden = true;
#endif
        }