示例#1
0
 public override void LayoutSubviews()
 {
     if (loader == null)
     {
         loader = new UIActivityIndicatorView();
         loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
         loader.Color = Helpers.Constants.R231G72B0;
         this.AddSubview(loader);
         loader.AutoCenterInSuperview();
         loader.AutoSetDimensionsToSize(new CGSize(35, 35));
     }
     loader.StartAnimating();
 }
 public void SetLoader()
 {
     //Move to LayoutSubviews?
     if (loader == null)
     {
         loader = new UIActivityIndicatorView();
         loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
         loader.Color = Helpers.Constants.R231G72B0;
         ContentView.AddSubview(loader);
         loader.AutoCenterInSuperview();
         loader.AutoSetDimensionsToSize(new CGSize(35, 35));
         ContentView.AutoSetDimensionsToSize(new CGSize(UIScreen.MainScreen.Bounds.Width, 80));
     }
     loader.StartAnimating();
 }
示例#3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = Constants.R250G250B250;
            View.ClipsToBounds   = true;

            LoadData();
            SetBackButton();

            SetupHistoryCollection();

            _loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
            _loader.HidesWhenStopped           = true;
            _loader.Color = UIColor.Black;

            View.AddSubview(_loader);
            _loader.AutoCenterInSuperview();

            _historyCollection.Add(_refreshControl);
        }
示例#4
0
        private void CreateView()
        {
            View.UserInteractionEnabled = true;

            var viewTap = new UITapGestureRecognizer(() =>
            {
                _amountTextField.ResignFirstResponder();
            });

            View.AddGestureRecognizer(viewTap);

            View.BackgroundColor = Constants.R250G250B250;

            var topBackground = new UIView();

            topBackground.BackgroundColor = UIColor.White;
            View.AddSubview(topBackground);

            topBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 20);
            topBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            topBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            var steemView = new UIView();

            topBackground.AddSubview(steemView);

            var label = new UILabel();

            label.Text = "Steem";
            label.Font = Constants.Semibold14;
            steemView.AddSubview(label);

            label.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            label.AutoPinEdgeToSuperviewEdge(ALEdge.Left);

            _firstTokenText.BaselineAdjustment        = UIBaselineAdjustment.AlignCenters;
            _firstTokenText.AdjustsFontSizeToFitWidth = true;
            _firstTokenText.TextAlignment             = UITextAlignment.Right;
            steemView.AddSubview(_firstTokenText);

            _firstTokenText.AutoAlignAxis(ALAxis.Horizontal, label);
            _firstTokenText.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            _firstTokenText.AutoPinEdge(ALEdge.Left, ALEdge.Right, label, 5);
            _firstTokenText.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            steemView.AutoSetDimension(ALDimension.Height, 70);
            steemView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            steemView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);
            steemView.AutoPinEdgeToSuperviewEdge(ALEdge.Top);

            var separator = new UIView();

            separator.BackgroundColor = Constants.R245G245B245;

            topBackground.AddSubview(separator);

            separator.AutoSetDimension(ALDimension.Height, 1);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);
            separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, steemView);

            var spView = new UIView();

            topBackground.AddSubview(spView);

            var label2 = new UILabel();

            label2.Text = "Steem Power";
            label2.Font = Constants.Semibold14;
            spView.AddSubview(label2);

            label2.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            label2.AutoPinEdgeToSuperviewEdge(ALEdge.Left);

            _secondTokenText.BaselineAdjustment        = UIBaselineAdjustment.AlignCenters;
            _secondTokenText.AdjustsFontSizeToFitWidth = true;
            _secondTokenText.TextAlignment             = UITextAlignment.Right;
            spView.AddSubview(_secondTokenText);

            _secondTokenText.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            _secondTokenText.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            _secondTokenText.AutoPinEdge(ALEdge.Left, ALEdge.Right, label2, 5);
            _secondTokenText.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            spView.AutoSetDimension(ALDimension.Height, 70);
            spView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, separator);
            spView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            spView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);
            spView.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);

            var amountBackground = new UIView();

            amountBackground.BackgroundColor = UIColor.White;
            View.AddSubview(amountBackground);

            amountBackground.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, topBackground, 10);
            amountBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            amountBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            var amountLabel = new UILabel();

            amountLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Amount);
            amountLabel.Font = Constants.Semibold14;
            amountBackground.AddSubview(amountLabel);

            amountLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15);
            amountLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);

            _amountTextField = new SearchTextField(AppSettings.LocalizationManager.GetText(LocalizationKeys.TransferAmountHint), new AmountFieldDelegate(), false);
            _amountTextField.EditingChanged    += AmountEditOnTextChanged;
            _amountTextField.KeyboardType       = UIKeyboardType.DecimalPad;
            _amountTextField.Layer.CornerRadius = 25;
            amountBackground.AddSubview(_amountTextField);

            _amountTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            _amountTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, amountLabel, 16);
            _amountTextField.AutoSetDimension(ALDimension.Height, 50);
            _amountTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 20);

            _amountTextField.TouchUpOutside += (object sender, EventArgs e) =>
            {
                _amountTextField.ResignFirstResponder();
            };

            errorMessage = new UILabel
            {
                Font      = Constants.Semibold14,
                TextColor = Constants.R255G34B5,
                Text      = AppSettings.LocalizationManager.GetText(LocalizationKeys.AmountLimitFull),
                Hidden    = true,
            };
            amountBackground.AddSubview(errorMessage);

            errorMessage.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, _amountTextField);
            errorMessage.AutoPinEdge(ALEdge.Left, ALEdge.Left, _amountTextField);
            errorMessage.AutoPinEdge(ALEdge.Right, ALEdge.Right, _amountTextField);

            var max = new UIButton();

            max.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Max), UIControlState.Normal);
            max.SetTitleColor(UIColor.Black, UIControlState.Normal);
            max.Font = Constants.Semibold14;
            max.Layer.BorderWidth  = 1;
            max.Layer.BorderColor  = Constants.R245G245B245.CGColor;
            max.Layer.CornerRadius = 25;

            amountBackground.AddSubview(max);

            max.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);
            max.AutoPinEdge(ALEdge.Left, ALEdge.Right, _amountTextField, 10);
            max.AutoSetDimensionsToSize(new CGSize(80, 50));
            max.AutoAlignAxis(ALAxis.Horizontal, _amountTextField);
            max.TouchDown += MaxBtnOnClick;

            _actionButton.SetTitle(AppSettings.LocalizationManager.GetText(_powerAction == PowerAction.PowerUp ? LocalizationKeys.PowerUp : LocalizationKeys.PowerDown), UIControlState.Normal);
            _actionButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _actionButton.SetTitleColor(UIColor.Clear, UIControlState.Disabled);

            View.AddSubview(_actionButton);

            _actionButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, amountBackground, 30);
            _actionButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            _actionButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);
            _actionButton.AutoSetDimension(ALDimension.Height, 50);

            _actionButton.LayoutIfNeeded();
            _actionButton.TouchDown += PowerBtnOnClick;

            _loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.White;
            _loader.HidesWhenStopped           = true;
            _actionButton.AddSubview(_loader);
            _loader.AutoCenterInSuperview();

            Constants.CreateGradient(_actionButton, 25);
            Constants.CreateShadowFromZeplin(_actionButton, Constants.R231G72B0, 0.3f, 0, 10, 20, 0);
        }
示例#5
0
        public CustomAlertView Create(Post post, UINavigationController controller, UIView view)
        {
            _pickedCoin = CurrencyType.Steem;
            _coins      = new List <CurrencyType>();
            switch (AppSettings.User.Chain)
            {
            case KnownChains.Steem:
                _coins.AddRange(new[] { CurrencyType.Steem, CurrencyType.Sbd });
                break;

            case KnownChains.Golos:
                _coins.AddRange(new[] { CurrencyType.Golos, CurrencyType.Gbg });
                break;
            }

            var popup = new UIView();

            popup.ClipsToBounds      = true;
            popup.Layer.CornerRadius = 20;
            popup.BackgroundColor    = Constants.R255G255B255;

            var _alert = new CustomAlertView(popup, controller);

            var dialogWidth = UIScreen.MainScreen.Bounds.Width - 10 * 2;

            popup.AutoSetDimension(ALDimension.Width, dialogWidth);

            var commonMargin = 20;

            var title = new UILabel();

            title.Font          = Constants.Semibold14;
            title.Text          = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromotePost);
            title.TextAlignment = UITextAlignment.Center;
            popup.AddSubview(title);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            title.AutoSetDimension(ALDimension.Height, 70);

            var topSeparator = new UIView();

            topSeparator.BackgroundColor = Constants.R245G245B245;
            popup.AddSubview(topSeparator);

            topSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, title);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            topSeparator.AutoSetDimension(ALDimension.Height, 1);

            var container = new UIView();

            popup.AddSubview(container);

            container.AutoSetDimension(ALDimension.Height, 142);
            container.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, topSeparator);
            container.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            container.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);

            var promotionLabel = new UILabel();

            promotionLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Amount);
            promotionLabel.Font = Constants.Semibold14;

            container.AddSubview(promotionLabel);

            promotionLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 27);
            promotionLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left);

            balanceLoader = new UIActivityIndicatorView();
            balanceLoader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.White;
            balanceLoader.Color            = UIColor.Black;
            balanceLoader.HidesWhenStopped = true;
            balanceLoader.StartAnimating();

            container.AddSubview(balanceLoader);

            balanceLoader.AutoPinEdge(ALEdge.Left, ALEdge.Right, promotionLabel, 10);
            balanceLoader.AutoAlignAxis(ALAxis.Horizontal, promotionLabel);

            balanceLabel               = new UILabel();
            balanceLabel.Font          = Constants.Semibold14;
            balanceLabel.TextColor     = Constants.R151G155B158;
            balanceLabel.TextAlignment = UITextAlignment.Right;

            container.AddSubview(balanceLabel);

            balanceLabel.AutoAlignAxis(ALAxis.Horizontal, promotionLabel);
            balanceLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            balanceLabel.AutoPinEdge(ALEdge.Left, ALEdge.Right, promotionLabel, 5);
            balanceLabel.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            GetBalance();

            var rightView = new UIView();

            container.AddSubview(rightView);
            rightView.AutoSetDimension(ALDimension.Height, 50);

            UIImageView pickerImage = new UIImageView(UIImage.FromBundle("ic_currency_picker.png"));

            rightView.AddSubview(pickerImage);
            pickerImage.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            pickerImage.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 10);

            UILabel _pickerLabel = new UILabel();

            _pickerLabel.Text          = "STEEM";
            _pickerLabel.TextAlignment = UITextAlignment.Center;
            _pickerLabel.Font          = Constants.Semibold14;
            _pickerLabel.TextColor     = Constants.R255G71B5;
            rightView.AddSubview(_pickerLabel);
            _pickerLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            _pickerLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            _pickerLabel.AutoPinEdge(ALEdge.Right, ALEdge.Left, pickerImage, -5);

            rightView.LayoutIfNeeded();

            _amountTextField = new SearchTextField(AppSettings.LocalizationManager.GetText(LocalizationKeys.TransferAmountHint),
                                                   new UIEdgeInsets(0, 20, 0, 0), new AmountFieldDelegate(), false, rightView);
            _amountTextField.KeyboardType       = UIKeyboardType.DecimalPad;
            _amountTextField.Layer.CornerRadius = 25;
            container.AddSubview(_amountTextField);

            _amountTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            _amountTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, promotionLabel, 16);
            _amountTextField.AutoSetDimension(ALDimension.Height, 50);

            errorMessage           = new UILabel();
            errorMessage.Font      = Constants.Semibold14;
            errorMessage.TextColor = Constants.R255G34B5;
            container.AddSubview(errorMessage);

            errorMessage.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, _amountTextField);
            errorMessage.AutoPinEdge(ALEdge.Left, ALEdge.Left, _amountTextField);
            errorMessage.AutoPinEdge(ALEdge.Right, ALEdge.Right, _amountTextField);

            _amountTextField.EditingChanged += IsEnoughBalance;
            var max = new UIButton();

            max.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Max), UIControlState.Normal);
            max.SetTitleColor(UIColor.Black, UIControlState.Normal);
            max.Font = Constants.Semibold14;
            max.Layer.BorderWidth  = 1;
            max.Layer.BorderColor  = Constants.R245G245B245.CGColor;
            max.Layer.CornerRadius = 25;

            container.AddSubview(max);

            max.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            max.AutoPinEdge(ALEdge.Left, ALEdge.Right, _amountTextField, 10);
            max.AutoSetDimensionsToSize(new CGSize(80, 50));
            max.AutoAlignAxis(ALAxis.Horizontal, _amountTextField);
            max.TouchDown += MaxBtnOnClick;

            rightView.AutoAlignAxis(ALAxis.Horizontal, _amountTextField);
            rightView.AutoPinEdge(ALEdge.Right, ALEdge.Right, _amountTextField);
            container.BringSubviewToFront(rightView);

            UIPickerView picker = new UIPickerView();

            picker.Select(_coins.IndexOf(_pickedCoin), 0, true);
            picker.Model           = new CoinPickerViewModel(_coins);
            picker.BackgroundColor = Constants.R255G255B255;
            popup.AddSubview(picker);

            picker.AutoMatchDimension(ALDimension.Height, ALDimension.Height, container);
            picker.AutoMatchDimension(ALDimension.Width, ALDimension.Width, container);
            picker.AutoPinEdge(ALEdge.Top, ALEdge.Top, container);
            var pickerHidden  = picker.AutoPinEdge(ALEdge.Right, ALEdge.Left, container, -20);
            var pickerVisible = picker.AutoPinEdge(ALEdge.Right, ALEdge.Right, container);

            pickerVisible.Active = false;

            var promoteContainer = new UIView();

            promoteContainer.BackgroundColor = Constants.R255G255B255;
            popup.AddSubview(promoteContainer);

            promoteContainer.AutoMatchDimension(ALDimension.Height, ALDimension.Height, container);
            promoteContainer.AutoMatchDimension(ALDimension.Width, ALDimension.Width, container);
            promoteContainer.AutoPinEdge(ALEdge.Top, ALEdge.Top, container);
            var promoteHidden  = promoteContainer.AutoPinEdge(ALEdge.Left, ALEdge.Right, container, 20);
            var promoteVisible = promoteContainer.AutoPinEdge(ALEdge.Left, ALEdge.Left, container);

            promoteVisible.Active = false;

            var avatar = new UIImageView();

            avatar.Layer.CornerRadius = 20;
            avatar.ClipsToBounds      = true;
            promoteContainer.AddSubview(avatar);

            avatar.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 16);
            avatar.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            avatar.AutoSetDimensionsToSize(new CGSize(40, 40));

            var promoterLogin = new UILabel();

            promoterLogin.Font      = Constants.Semibold14;
            promoterLogin.TextColor = Constants.R255G34B5;
            promoteContainer.AddSubview(promoterLogin);

            promoterLogin.AutoPinEdge(ALEdge.Left, ALEdge.Right, avatar, 20);
            promoterLogin.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            promoterLogin.AutoAlignAxis(ALAxis.Horizontal, avatar);

            var expectedTimeBackground = new UIView();

            expectedTimeBackground.Layer.CornerRadius = 10;
            expectedTimeBackground.BackgroundColor    = Constants.R250G250B250;
            promoteContainer.AddSubview(expectedTimeBackground);

            expectedTimeBackground.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, avatar, 15);
            expectedTimeBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            expectedTimeBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            expectedTimeBackground.AutoSetDimension(ALDimension.Height, 50);

            var expectedTimeLabel = new UILabel();

            expectedTimeLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.ExpectedVoteTime);
            expectedTimeLabel.Font = Constants.Regular14;
            expectedTimeBackground.AddSubview(expectedTimeLabel);

            expectedTimeLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, DeviceHelper.IsSmallDevice ? 10 : 20);
            expectedTimeLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            var expectedTimeValue = new UILabel();

            expectedTimeValue.TextAlignment = UITextAlignment.Right;
            expectedTimeValue.Font          = Constants.Light20;
            expectedTimeBackground.AddSubview(expectedTimeValue);

            expectedTimeValue.AutoPinEdge(ALEdge.Left, ALEdge.Right, expectedTimeLabel);
            expectedTimeValue.AutoPinEdgeToSuperviewEdge(ALEdge.Right, DeviceHelper.IsSmallDevice ? 10 : 20);
            expectedTimeValue.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            var sureText = new UILabel();

            sureText.BackgroundColor = Constants.R255G255B255;
            sureText.Lines           = 4;
            sureText.TextAlignment   = UITextAlignment.Center;
            sureText.Font            = Constants.Regular20;
            popup.AddSubview(sureText);

            sureText.AutoMatchDimension(ALDimension.Height, ALDimension.Height, container);
            sureText.AutoMatchDimension(ALDimension.Width, ALDimension.Width, container);
            sureText.AutoPinEdge(ALEdge.Top, ALEdge.Top, container);
            var sureTextHidden  = sureText.AutoPinEdge(ALEdge.Left, ALEdge.Right, container, 20);
            var sureTextVisible = sureText.AutoPinEdge(ALEdge.Left, ALEdge.Left, container);

            sureTextVisible.Active = false;

            var completeText = new UILabel();

            completeText.BackgroundColor = Constants.R255G255B255;
            completeText.Lines           = 4;
            completeText.TextAlignment   = UITextAlignment.Center;
            completeText.Font            = Constants.Regular20;
            popup.AddSubview(completeText);

            completeText.AutoMatchDimension(ALDimension.Height, ALDimension.Height, container);
            completeText.AutoMatchDimension(ALDimension.Width, ALDimension.Width, container);
            completeText.AutoPinEdge(ALEdge.Top, ALEdge.Top, container);
            var completeTextHidden  = completeText.AutoPinEdge(ALEdge.Left, ALEdge.Right, container, 20);
            var completeTextVisible = completeText.AutoPinEdge(ALEdge.Left, ALEdge.Left, container);

            completeTextVisible.Active = false;

            var separator = new UIView();

            separator.BackgroundColor = Constants.R245G245B245;
            popup.AddSubview(separator);

            separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, container);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            separator.AutoSetDimension(ALDimension.Height, 1);

            var selectButton = new UIButton();

            selectButton.SetTitle(string.Empty, UIControlState.Disabled);
            selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.FindPromoter), UIControlState.Normal);
            selectButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            selectButton.Layer.CornerRadius = 25;
            selectButton.Font = Constants.Bold14;
            popup.AddSubview(selectButton);

            selectButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, separator, 20);
            selectButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            selectButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            selectButton.AutoSetDimension(ALDimension.Height, 50);
            selectButton.LayoutIfNeeded();

            var loader = new UIActivityIndicatorView();

            loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.White;
            loader.HidesWhenStopped           = true;

            selectButton.AddSubview(loader);

            loader.AutoCenterInSuperview();

            var tap = new UITapGestureRecognizer(() =>
            {
                if (balances == null)
                {
                    return;
                }

                _amountTextField.ResignFirstResponder();
                pickerHidden.Active  = false;
                pickerVisible.Active = true;

                UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                {
                    popup.LayoutIfNeeded();
                }, () =>
                {
                    title.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.SelectToken);
                    selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Select), UIControlState.Normal);
                });
            });

            rightView.AddGestureRecognizer(tap);

            var cancelButton = new UIButton();

            cancelButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Close), UIControlState.Normal);
            cancelButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            cancelButton.Layer.CornerRadius = 25;
            cancelButton.Font = Constants.Semibold14;
            cancelButton.Layer.BorderWidth = 1;
            cancelButton.Layer.BorderColor = Constants.R245G245B245.CGColor;
            popup.AddSubview(cancelButton);

            cancelButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, selectButton, 20);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, commonMargin);
            cancelButton.AutoSetDimension(ALDimension.Height, 50);

            controller.View.EndEditing(true);

            Timer timer = null;

            OperationResult <PromoteResponse> promoter = null;

            selectButton.TouchDown += async(sender, e) =>
            {
                if (balanceLoader.IsAnimating)
                {
                    return;
                }

                IsEnoughBalance(null, null);

                if (pickerVisible.Active)
                {
                    _pickedCoin       = _coins[(int)picker.SelectedRowInComponent(0)];
                    _pickerLabel.Text = _pickedCoin.ToString().ToUpper();

                    var balance = balances?.Find(x => x.CurrencyType == _pickedCoin);
                    balanceLabel.Text = $"{AppSettings.LocalizationManager.GetText(LocalizationKeys.Balance)}: {balance?.Value}";

                    pickerHidden.Active  = true;
                    pickerVisible.Active = false;
                    UIView.Animate(0.5, () =>
                    {
                        popup.LayoutIfNeeded();
                    }, () =>
                    {
                        title.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromotePost);
                        selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.FindPromoter), UIControlState.Normal);
                        _amountTextField.UpdateRightViewRect();
                    });
                }
                else if (sureTextVisible.Active)
                {
                    if (!AppSettings.User.HasActivePermission)
                    {
                        _alert.Hidden = true;

                        controller.PushViewController(new LoginViewController(false), true);
                        return;
                    }

                    selectButton.Enabled = false;
                    loader.StartAnimating();

                    sureTextHidden.Active  = true;
                    sureTextVisible.Active = false;

                    var transferResponse = await _presenter.TryTransfer(AppSettings.User.UserInfo, promoter.Result.Bot.Author, _amountTextField.GetDoubleValue().ToString(), _pickedCoin, $"https://steemit.com{post.Url}");

                    if (transferResponse.IsSuccess)
                    {
                        completeText.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.SuccessPromote);
                    }
                    else
                    {
                        completeText.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.TokenTransferError);
                    }

                    completeTextHidden.Active  = false;
                    completeTextVisible.Active = true;

                    UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                    {
                        popup.LayoutIfNeeded();
                    }, () =>
                    {
                        selectButton.Enabled = true;
                        loader.StopAnimating();
                        title.Text = true ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoteComplete) : AppSettings.LocalizationManager.GetText(LocalizationKeys.TransferError);
                        selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoteAgain), UIControlState.Normal);

                        promoteVisible.Active = false;
                        promoteHidden.Active  = true;
                        popup.LayoutIfNeeded();
                        timer?.Dispose();
                    });
                }
                else if (promoteVisible.Active)
                {
                    var promoteConfirmation = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoteConfirmation,
                                                                                      _amountTextField.GetDoubleValue().ToString(),
                                                                                      _pickedCoin == CurrencyType.Sbd ? "SBD" : "Steem",
                                                                                      promoter.Result.Bot.Author);

                    sureText.Text          = promoteConfirmation;
                    sureTextHidden.Active  = false;
                    sureTextVisible.Active = true;

                    UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                    {
                        popup.LayoutIfNeeded();
                    }, () =>
                    {
                        selectButton.SetTitle("Yes", UIControlState.Normal);
                    });
                }
                else if (completeTextVisible.Active)
                {
                    completeTextHidden.Active  = true;
                    completeTextVisible.Active = false;

                    UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                    {
                        popup.LayoutIfNeeded();
                    }, () =>
                    {
                        title.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromotePost);
                        selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.FindPromoter), UIControlState.Normal);
                    });
                }
                else
                {
                    if (_amountTextField.GetDoubleValue() > balances?.Find(x => x.CurrencyType == _pickedCoin).Value)
                    {
                        errorMessage.Text   = AppSettings.LocalizationManager.GetText(LocalizationKeys.NotEnoughBalance);
                        errorMessage.Hidden = false;
                        return;
                    }

                    if (string.IsNullOrEmpty(_amountTextField.Text) || !IsValidAmount())
                    {
                        return;
                    }

                    selectButton.Enabled = false;
                    loader.StartAnimating();

                    var pr = new PromoteRequest()
                    {
                        Amount        = _amountTextField.GetDoubleValue(),
                        CurrencyType  = _pickedCoin,
                        PostToPromote = post,
                    };

                    promoter = await _presenter.FindPromoteBot(pr);

                    if (promoter.IsSuccess)
                    {
                        var expectedUpvoteTime = promoter.Result.ExpectedUpvoteTime;
                        if (expectedUpvoteTime.ToString().Length > 8)
                        {
                            expectedTimeValue.Text = expectedUpvoteTime.ToString().Remove(8);
                        }
                        timer = new Timer((obj) =>
                        {
                            expectedUpvoteTime = expectedUpvoteTime.Subtract(TimeSpan.FromSeconds(1));
                            view.InvokeOnMainThread(() =>
                            {
                                if (expectedUpvoteTime.ToString().Length > 8)
                                {
                                    expectedTimeValue.Text = expectedUpvoteTime.ToString().Remove(8);
                                }
                                else
                                {
                                    expectedTimeValue.Text = expectedUpvoteTime.ToString();
                                }
                            });
                        }, null, DateTime.Now.Add(expectedUpvoteTime).Millisecond, (int)TimeSpan.FromSeconds(1).TotalMilliseconds);

                        promoterLogin.Text = $"@{promoter.Result.Bot.Author}";

                        if (!string.IsNullOrEmpty(promoter.Result.Bot.Avatar))
                        {
                            ImageLoader.Load(promoter.Result.Bot.Avatar, avatar, size: new CGSize(300, 300));
                        }
                        else
                        {
                            avatar.Image = UIImage.FromBundle("ic_noavatar");
                        }

                        promoteHidden.Active  = false;
                        promoteVisible.Active = true;
                        UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                        {
                            popup.LayoutIfNeeded();
                        }, () =>
                        {
                            selectButton.Enabled = true;
                            loader.StopAnimating();
                            title.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoterFound);
                            selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Promote), UIControlState.Normal);
                        });
                    }
                    else
                    {
                        completeText.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoterNotFound);

                        completeTextHidden.Active  = false;
                        completeTextVisible.Active = true;

                        UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                        {
                            popup.LayoutIfNeeded();
                        }, () =>
                        {
                            selectButton.Enabled = true;
                            loader.StopAnimating();
                            title.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PromoterSearchResult);
                            selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.SearchAgain), UIControlState.Normal);
                        });
                    }
                }
            };
            cancelButton.TouchDown += (sender, e) =>
            {
                _alert.Close();
            };

            var popuptap = new UITapGestureRecognizer(() =>
            {
                _amountTextField.ResignFirstResponder();
            });

            popup.AddGestureRecognizer(popuptap);

            Constants.CreateGradient(selectButton, 25);
            Constants.CreateShadowFromZeplin(selectButton, Constants.R231G72B0, 0.3f, 0, 10, 20, 0);
            popup.BringSubviewToFront(selectButton);

            _alert.Show();

            return(_alert);
        }
示例#6
0
        private void ShowClaimPopUp(object sender, EventArgs e)
        {
            var popup = new UIView();

            popup.ClipsToBounds      = true;
            popup.Layer.CornerRadius = 20;
            popup.BackgroundColor    = Constants.R250G250B250;

            var _alert = new CustomAlertView(popup, NavigationController);

            var dialogWidth = UIScreen.MainScreen.Bounds.Width - 10 * 2;

            popup.AutoSetDimension(ALDimension.Width, dialogWidth);

            var commonMargin = 20;

            var title = new UILabel();

            title.Lines         = 2;
            title.TextAlignment = UITextAlignment.Center;
            title.Font          = Constants.Light27;
            title.Text          = "Hello! It's time to collect rewards!";
            popup.AddSubview(title);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 32);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            title.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);

            var steemAmountView = new UIView();

            steemAmountView.BackgroundColor    = Constants.R250G250B250;
            steemAmountView.Layer.CornerRadius = 8;
            popup.AddSubview(steemAmountView);

            steemAmountView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, title, 37);
            steemAmountView.AutoSetDimension(ALDimension.Height, 50);
            steemAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            steemAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);

            var steemAmountLabel = new UILabel();

            steemAmountLabel.Text = "Steem";
            steemAmountLabel.Font = Constants.Semibold14;
            steemAmountView.AddSubview(steemAmountLabel);

            steemAmountLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            steemAmountLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            var steemAmount = new UILabel();

            steemAmount.Text          = _presenter.Balances[0].RewardSteem.ToBalanceValueString();
            steemAmount.Font          = Constants.Semibold14;
            steemAmount.TextColor     = Constants.R255G34B5;
            steemAmount.TextAlignment = UITextAlignment.Right;
            steemAmountView.AddSubview(steemAmount);
            steemAmount.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            steemAmount.AutoPinEdge(ALEdge.Left, ALEdge.Right, steemAmountLabel, 5);
            steemAmount.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            steemAmount.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);

            var sbdAmountView = new UIView();

            sbdAmountView.BackgroundColor    = Constants.R250G250B250;
            sbdAmountView.Layer.CornerRadius = 8;
            popup.AddSubview(sbdAmountView);

            sbdAmountView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, steemAmountView, 10);
            sbdAmountView.AutoSetDimension(ALDimension.Height, 50);
            sbdAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            sbdAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);

            var sbdAmountLabel = new UILabel();

            sbdAmountLabel.Text = "SBD";
            sbdAmountLabel.Font = Constants.Semibold14;
            sbdAmountView.AddSubview(sbdAmountLabel);

            sbdAmountLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            sbdAmountLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            var sbdAmount = new UILabel();

            sbdAmount.Text          = _presenter.Balances[0].RewardSbd.ToBalanceValueString();
            sbdAmount.Font          = Constants.Semibold14;
            sbdAmount.TextColor     = Constants.R255G34B5;
            sbdAmount.TextAlignment = UITextAlignment.Right;
            sbdAmountView.AddSubview(sbdAmount);
            sbdAmount.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            sbdAmount.AutoPinEdge(ALEdge.Left, ALEdge.Right, sbdAmountLabel, 5);
            sbdAmount.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            sbdAmount.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);

            var spAmountView = new UIView();

            spAmountView.BackgroundColor    = Constants.R250G250B250;
            spAmountView.Layer.CornerRadius = 8;
            popup.AddSubview(spAmountView);

            spAmountView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, sbdAmountView, 10);
            spAmountView.AutoSetDimension(ALDimension.Height, 50);
            spAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            spAmountView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);

            var spAmountLabel = new UILabel();

            spAmountLabel.Text = "Steem Power";
            spAmountLabel.Font = Constants.Semibold14;
            spAmountView.AddSubview(spAmountLabel);

            spAmountLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 20);
            spAmountLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            var spAmount = new UILabel();

            spAmount.Text          = _presenter.Balances[0].RewardSp.ToBalanceValueString();
            spAmount.Font          = Constants.Semibold14;
            spAmount.TextColor     = Constants.R255G34B5;
            spAmount.TextAlignment = UITextAlignment.Right;
            spAmountView.AddSubview(spAmount);
            spAmount.SetContentHuggingPriority(1, UILayoutConstraintAxis.Horizontal);

            spAmount.AutoPinEdge(ALEdge.Left, ALEdge.Right, spAmountLabel, 5);
            spAmount.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            spAmount.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 20);

            var separator = new UIView();

            separator.BackgroundColor = Constants.R245G245B245;
            popup.AddSubview(separator);

            separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, spAmountView, 20);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            separator.AutoSetDimension(ALDimension.Height, 1);

            var selectButton = new UIButton();

            selectButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.ClaimRewards), UIControlState.Normal);
            selectButton.SetTitle(string.Empty, UIControlState.Disabled);
            selectButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            selectButton.Layer.CornerRadius = 25;
            selectButton.Font = Constants.Bold14;
            popup.AddSubview(selectButton);

            selectButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, separator, 20);
            selectButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            selectButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            selectButton.AutoSetDimension(ALDimension.Height, 50);
            selectButton.LayoutIfNeeded();

            var loader = new UIActivityIndicatorView();

            loader.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.White;

            selectButton.AddSubview(loader);
            loader.AutoCenterInSuperview();

            var cancelButton = new UIButton();

            cancelButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.Close), UIControlState.Normal);
            cancelButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            cancelButton.Layer.CornerRadius = 25;
            cancelButton.Font = Constants.Semibold14;
            cancelButton.Layer.BorderWidth = 1;
            cancelButton.Layer.BorderColor = Constants.R245G245B245.CGColor;
            popup.AddSubview(cancelButton);

            cancelButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, selectButton, 10);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, commonMargin);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, commonMargin);
            cancelButton.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, commonMargin);
            cancelButton.AutoSetDimension(ALDimension.Height, 50);

            NavigationController.View.EndEditing(true);

            selectButton.TouchDown += async(s, ev) =>
            {
                selectButton.Enabled = false;
                loader.StartAnimating();
                var exception = await _presenter.TryClaimRewards(_presenter.Balances[0]);

                loader.StopAnimating();
                selectButton.Enabled = true;

                if (exception == null)
                {
                    LoadData();
                    _alert.Close();
                }
                else
                {
                    ShowAlert(exception);
                }
            };
            cancelButton.TouchDown += (s, ev) => { _alert.Close(); };

            Constants.CreateGradient(selectButton, 25);
            Constants.CreateShadowFromZeplin(selectButton, Constants.R231G72B0, 0.3f, 0, 10, 20, 0);
            popup.BringSubviewToFront(selectButton);
            _alert.Show();
        }