Example #1
0
		internal static FlowDirection ToFlowDirection(this UIUserInterfaceLayoutDirection direction)
		{
			switch (direction)
			{
				case UIUserInterfaceLayoutDirection.LeftToRight:
					return FlowDirection.LeftToRight;
				case UIUserInterfaceLayoutDirection.RightToLeft:
					return FlowDirection.RightToLeft;
				default:
					return FlowDirection.MatchParent;
			}
		}
Example #2
0
        public static FlowDirection ToFlowDirection(this UIUserInterfaceLayoutDirection direction)
        {
            switch (direction)
            {
            case UIUserInterfaceLayoutDirection.LeftToRight:
                return(FlowDirection.LeftToRight);

            case UIUserInterfaceLayoutDirection.RightToLeft:
                return(FlowDirection.RightToLeft);

            default:
                throw new NotSupportedException($"ToFlowDirection: {direction}");
            }
        }
Example #3
0
        void AddButtonsToView(UIView view)
        {
            nfloat buttonWidth = view.Bounds.Size.Width / 2;

            CGRect leftButtonFrame  = new CGRect(0, view.Bounds.Size.Height - kDefaultButtonHeight, buttonWidth, kDefaultButtonHeight);
            CGRect rightButtonFrame = new CGRect(buttonWidth, view.Bounds.Size.Height - kDefaultButtonHeight, buttonWidth, kDefaultButtonHeight);

            if (!this.showCancelButton)
            {
                buttonWidth      = view.Bounds.Size.Width;
                leftButtonFrame  = CGRect.Empty;
                rightButtonFrame = new CGRect(0, view.Bounds.Size.Height - kDefaultButtonHeight, buttonWidth, kDefaultButtonHeight);
            }

            UIUserInterfaceLayoutDirection interfaceLayoutDirection = UIApplication.SharedApplication.UserInterfaceLayoutDirection;
            bool isLeftToRightDirection = interfaceLayoutDirection == UIUserInterfaceLayoutDirection.LeftToRight;

            if (this.showCancelButton)
            {
                UIButton cancelButton = new UIButton(UIButtonType.Custom)
                {
                    Frame = isLeftToRightDirection ? leftButtonFrame : rightButtonFrame
                };
                cancelButton.SetTitleColor(this.cancelButtonColor, UIControlState.Normal);
                cancelButton.SetTitleColor(this.cancelButtonColor, UIControlState.Highlighted);
                cancelButton.TitleLabel.Font    = this.font?.WithSize((nfloat)14.0) ?? UIFont.SystemFontOfSize((nfloat)14.0);
                cancelButton.Layer.CornerRadius = kCornerRadius;
                cancelButton.AddTarget(OnButtonTapped, UIControlEvent.TouchUpInside);
                view.AddSubview(cancelButton);
                this.cancelButton = cancelButton;
            }

            UIButton doneButton = new UIButton(UIButtonType.Custom)
            {
                Tag   = kPickerDialogDoneButtonTag,
                Frame = isLeftToRightDirection ? rightButtonFrame : leftButtonFrame
            };

            doneButton.SetTitleColor(this.buttonColor, UIControlState.Normal);
            doneButton.SetTitleColor(this.buttonColor, UIControlState.Highlighted);
            doneButton.TitleLabel.Font    = this.font?.WithSize((nfloat)14.0) ?? UIFont.SystemFontOfSize((nfloat)14.0);
            doneButton.Layer.CornerRadius = kCornerRadius;
            doneButton.AddTarget(OnButtonTapped, UIControlEvent.TouchUpInside);
            view.AddSubview(doneButton);
            this.doneButton = doneButton;
        }
 // this is needed for Compatibility Unit Tests
 internal static FlowDirection ToFlowDirection(this UIUserInterfaceLayoutDirection direction)
 {
     return(Microsoft.Maui.FlowDirectionExtensions.ToFlowDirection(direction));
 }