public JVFloatLabeledEntryElement(string placeholder, string value = null, string caption = null, bool isPassword = false)
     : base(caption, placeholder, value, isPassword)
 {
     _textField = new JVFloatLabeledTextField(RectangleF.Empty)
     {
         AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleLeftMargin,
         Placeholder      = placeholder,
         Text             = value,
         SecureTextEntry  = isPassword
     };
 }
 public JVFloatLabeledEntryElement(string placeholder, string value = null, string caption = null, bool isPassword = false)
     : base(caption, placeholder, value, isPassword)
 {
     _textField = new JVFloatLabeledTextField(RectangleF.Empty)
     {
         AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleLeftMargin,
         Placeholder = placeholder,
         Text = value,
         SecureTextEntry = isPassword
     };
 }
Ejemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Floating Label Demo";

            View.BackgroundColor = UIColor.White;

            float topOffset = UIApplication.SharedApplication.StatusBarFrame.Size.Height + NavigationController.NavigationBar.Frame.Size.Height;
            UIColor floatingLabelColor = UIColor.Gray, floatingLabelActiveColor = UIColor.Blue;

            var titleField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin, topOffset,
                                                                        View.Frame.Size.Width - 2 * JVFieldHMargin,
                                                                        JVFieldHeight))
            {
                Placeholder = "Title",
                Font = UIFont.SystemFontOfSize(JVFieldFontSize),
                ClearButtonMode = UITextFieldViewMode.WhileEditing,
                FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize),
                FloatingLabelTextColor = floatingLabelColor,
                FloatingLabelActiveTextColor = floatingLabelActiveColor
            };
            View.AddSubview(titleField);

            var div1 = new UIView(new RectangleF(JVFieldHMargin,
                                                 titleField.Frame.Y + titleField.Frame.Size.Height,
                                                 View.Frame.Size.Width - 2 * JVFieldHMargin, 1))
            {
                BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f)
            };
            View.AddSubview(div1);

            var priceField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin,
                                                                        div1.Frame.Y + div1.Frame.Size.Height,
                                                                        80, JVFieldHeight))
            {
                Placeholder = "Price",
                Font = UIFont.SystemFontOfSize(JVFieldFontSize),
                FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize),
                FloatingLabelTextColor = floatingLabelColor,
                FloatingLabelActiveTextColor = floatingLabelActiveColor,
                Text = "3.14"
            };
            View.AddSubview(priceField);

            var div2 = new UIView(new RectangleF(JVFieldHMargin + priceField.Frame.Size.Width,
                                                 titleField.Frame.Y + titleField.Frame.Size.Height,
                                                 1, JVFieldHeight))
            {
                BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f)
            };
            View.AddSubview(div2);

            var locationField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin + JVFieldHMargin + priceField.Frame.Size.Width + 1.0f,
                                                                           div1.Frame.Y + div1.Frame.Size.Height,
                                                                           View.Frame.Size.Width - 3 * JVFieldHMargin - priceField.Frame.Size.Width - 1.0f,
                                                                           JVFieldHeight))
            {
                Placeholder = "Specific Location (optional)",
                Font = UIFont.SystemFontOfSize(JVFieldFontSize),
                FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize),
                FloatingLabelTextColor = floatingLabelColor,
                FloatingLabelActiveTextColor = floatingLabelActiveColor
            };
            View.AddSubview(locationField);

            var div3 = new UIView(new RectangleF(JVFieldHMargin,
                                                 priceField.Frame.Y + priceField.Frame.Size.Height,
                                                 View.Frame.Size.Width - 2 * JVFieldHMargin, 1))
            {
                BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f)
            };
            View.AddSubview(div3);

            var descriptionField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin,
                                                                              div3.Frame.Y + div3.Frame.Size.Height,
                                                                              View.Frame.Size.Width - 2 * JVFieldHMargin,
                                                                              JVFieldHeight))
            {
                Placeholder = "Description",
                Font = UIFont.SystemFontOfSize(JVFieldFontSize),
                FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize),
                FloatingLabelTextColor = floatingLabelColor,
                FloatingLabelActiveTextColor = floatingLabelActiveColor
            };
            View.AddSubview(descriptionField);

            titleField.BecomeFirstResponder();

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Dialog Demo", UIBarButtonItemStyle.Plain, delegate
            {
                this.NavigationController.PushViewController(new DialogDemoViewController(), true);
            });
        }
Ejemplo n.º 4
0
        protected override void SetupUserInterface()
        {
            View.BackgroundColor   = MobileCore.Values.Colors.LightGray.ToNative();
            EdgesForExtendedLayout = UIRectEdge.None;

            logo = new UIImageView(UIImage.FromFile("logo.png"));
            Add(logo);

            username = new JVFloatLabeledTextField(RectangleF.Empty)
            {
                Placeholder = MobileCore.Values.Strings.Login_Username,
                FloatingLabelActiveTextColor = MobileCore.Values.Colors.Orange.ToNative(),
                BorderStyle  = UITextBorderStyle.RoundedRect,
                KeyboardType = UIKeyboardType.EmailAddress
            };
            username.RoundedViewBackground(MobileCore.Values.Colors.White.ToNative());
            Add(username);

            password = new JVFloatLabeledTextField(RectangleF.Empty)
            {
                SecureTextEntry = true,
                Placeholder     = MobileCore.Values.Strings.Login_Password,
                FloatingLabelActiveTextColor = MobileCore.Values.Colors.Orange.ToNative(),
                BorderStyle = UITextBorderStyle.RoundedRect,
            };
            password.RoundedViewBackground(MobileCore.Values.Colors.White.ToNative());
            Add(password);

            login = new FlatButton(RectangleF.Empty);
            login.SetTitle(MobileCore.Values.Strings.Login_Login, UIControlState.Normal);
            login.TintColor = MobileCore.Values.Colors.White.ToNative();
            login.SetBackgroundColor(MobileCore.Values.Colors.DarkGray.ToNative(), UIControlState.Normal);
            Add(login);

            createNewAccount = new UIButton(UIButtonType.System);
            createNewAccount.SetTitle(MobileCore.Values.Strings.Login_CreateNewAccount, UIControlState.Normal);
            Add(createNewAccount);

            forgotPassword = new UIButton(UIButtonType.System);
            forgotPassword.SetTitle(MobileCore.Values.Strings.Login_ForgotPassword, UIControlState.Normal);
            Add(forgotPassword);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                logo.AtTopOf(View, Constants.Layout.VerticalPadding * 4f),
                logo.WithSameCenterX(View),

                username.Below(logo, Constants.Layout.VerticalPadding),
                username.AtLeftOf(View, Constants.Layout.HorizontalPadding),
                username.AtRightOf(View, Constants.Layout.HorizontalPadding),
                username.Height().EqualTo(Constants.Layout.MinimumTouchControlSize),

                password.Below(username, Constants.Layout.VerticalPadding),
                password.AtLeftOf(View, Constants.Layout.HorizontalPadding),
                password.AtRightOf(View, Constants.Layout.HorizontalPadding),
                password.Height().EqualTo(Constants.Layout.MinimumTouchControlSize),

                login.Below(password, Constants.Layout.VerticalPadding),
                login.AtLeftOf(View, Constants.Layout.HorizontalPadding),
                login.AtRightOf(View, Constants.Layout.HorizontalPadding),
                login.Height().EqualTo(Constants.Layout.MinimumTouchControlSize),

                createNewAccount.Below(login, Constants.Layout.VerticalPadding),
                createNewAccount.AtLeftOf(View, Constants.Layout.HorizontalPadding),
                createNewAccount.AtRightOf(View, Constants.Layout.HorizontalPadding),

                forgotPassword.Below(createNewAccount, Constants.Layout.VerticalPadding),
                forgotPassword.AtLeftOf(View, Constants.Layout.HorizontalPadding),
                forgotPassword.AtRightOf(View, Constants.Layout.HorizontalPadding)
                );
        }