/** * Displays a loading dialog with a loading spinner, and a message * * - parameter message: The message displayed to the user while its loading * - returns: The Loading Dialog */ public static NBMaterialLoadingDialog Show(NBMaterialLoadingDialogSettings settings) { var containerView = new UIView(); var circularLoadingActivity = new NBMaterialCircularActivityIndicator(); var loadingLabel = new UILabel(); //circularLoadingActivity.initialize() circularLoadingActivity.TranslatesAutoresizingMaskIntoConstraints = false; circularLoadingActivity.LineWidth = 3.5f; circularLoadingActivity.TintColor = NBConfig.AccentColor; containerView.AddSubview(circularLoadingActivity); loadingLabel.TranslatesAutoresizingMaskIntoConstraints = false; loadingLabel.Font = UIFontExtensions.ArialFont(14); loadingLabel.TextColor = NBConfig.PrimaryTextDark; loadingLabel.Text = settings.Text; // TODO: Add support for multiple lines, probably need to fix the dynamic dialog height todo first loadingLabel.Lines = 0; containerView.AddSubview(loadingLabel); // Setup constraints NSMutableDictionary constraintViews = new NSMutableDictionary(); constraintViews.SetValueForKey(circularLoadingActivity, new NSString("spinner")); constraintViews.SetValueForKey(loadingLabel, new NSString("label")); containerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[spinner(==32)]-16-[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, metrics: null, views: constraintViews)); containerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[spinner(==32)]", NSLayoutFormatOptions.DirectionLeadingToTrailing, metrics: null, views: constraintViews)); // Center Y needs to be set manually, not through VFL containerView.AddConstraint( NSLayoutConstraint.Create( circularLoadingActivity, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)); containerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, metrics: null, views: constraintViews)); // Initialize dialog and display var dialog = new NBMaterialLoadingDialog(); settings.Content = containerView; settings.DialogHeight = settings.DialogHeight ?? dialog.kMinimumHeight; dialog.SetLoadingLabel(loadingLabel); dialog.ShowDialog(settings); // Start spinner circularLoadingActivity.StartAnimating(); return(dialog); }
protected void SetupTitleLabelWithTitle(string title) { titleLabel = new UILabel(); if (title != null) { titleLabel.TranslatesAutoresizingMaskIntoConstraints = false; titleLabel.Font = UIFontExtensions.MontserratFontSemiBold(20); titleLabel.TextColor = UIColor.FromWhiteAlpha(white: 0.13f, alpha: 1.0f); titleLabel.Lines = 0; titleLabel.Text = title; containerView.AddSubview(titleLabel); } }
public static NBMaterialAlertDialog Show(NBAlertDialogSettings settings) { var alertLabel = new UILabel(); alertLabel.Lines = 0; alertLabel.Font = UIFontExtensions.ArialFont(settings.FontSize); alertLabel.TextColor = NBConfig.PrimaryTextDark; alertLabel.Text = settings.Text; alertLabel.SizeToFit(); var dialog = new NBMaterialAlertDialog(); settings.Content = alertLabel; settings.DialogHeight = settings.DialogHeight ?? dialog.kMinimumHeight; dialog.ShowDialog(settings); return(dialog); }
protected void SetupButtonWithTitle(string title, BFPaperButton button, bool isStacked) { button.TranslatesAutoresizingMaskIntoConstraints = false; button.SetTitle(title.ToUpper(), UIControlState.Normal); button.SetTitleColor(NBConfig.AccentColor, UIControlState.Normal); button.IsRaised = false; if (button.TitleLabel != null) { button.TitleLabel.Font = UIFontExtensions.MontserratFontSemiBold(14); } if (isStacked) { //button.. = UIControlContentHorizontalAlignment.Right; button.ContentEdgeInsets = new UIEdgeInsets(0, 0, 0, 20); } else { button.ContentEdgeInsets = new UIEdgeInsets(0, 8, 0, 8); } containerView.AddSubview(button); }
public override NBMaterialDialog ShowDialog(NBDialogSettings settings) { _hideDialogOnTapOnOverlay = settings.HideDialogOnTapOnOverlay; _dialogHeight = _pages[_currentPage].DialogHeight; isStacked = settings.StackedButtons; nfloat totalButtonTitleLength = 0.0f; windowView = settings.WindowView; var windowSize = windowView.Bounds; windowView.AddSubview(View); View.Frame = windowView.Bounds; tappableView.Frame = View.Frame; tapGesture = new UITapGestureRecognizer(TappedBg); tappableView.AddGestureRecognizer(tapGesture); SetupContainerView(); // Add content to contentView contentView = _pages[_currentPage].View; SetupContentView(); if (settings.Title != null) { SetupTitleLabelWithTitle(settings.Title); } if (settings.OkButtonTitle != null) { UIStringAttributes attribs = new UIStringAttributes { Font = UIFontExtensions.MontserratFontSemiBold(14f) }; totalButtonTitleLength += new NSString(settings.OkButtonTitle.ToUpper()).GetSizeUsingAttributes(attribs).Width + 8; if (settings.CancelButtonTitle != null) { totalButtonTitleLength += new NSString(settings.CancelButtonTitle.ToUpper()).GetSizeUsingAttributes(attribs).Width + 8; } // Calculate if the combined button title lengths are longer than max allowed for this dialog, if so use stacked buttons. nfloat buttonTotalMaxLength = (windowSize.Width - (kWidthMargin * 2)) - 16 - 16 - 8; if (totalButtonTitleLength > buttonTotalMaxLength) { isStacked = true; } } // Always display a close/ok button, but setting a title is optional. if (settings.OkButtonTitle != null) { if (okButton == null) { okButton = new BFPaperButton(); okButton.Tag = 0; okButton.TouchUpInside += (sender, args) => PressedAnyButton(sender as NSObject); } SetupButtonWithTitle(settings.OkButtonTitle, button: okButton, isStacked: isStacked); } if (settings.CancelButtonTitle != null) { if (cancelButton == null) { cancelButton = new BFPaperButton(); cancelButton.Tag = 1; cancelButton.TouchUpInside += (sender, args) => PressedAnyButton(sender as NSObject); } SetupButtonWithTitle(settings.CancelButtonTitle, button: cancelButton, isStacked: isStacked); } userAction = settings.ButtonAction; SetupViewConstraints(); //// To get dynamic width to work we need to comment this out and uncomment the stuff in setupViewConstraints. But its currently not working.. SetContainerSize(); return(this); }