示例#1
0
        public LoginPage()
        {
            BindingContext           = App.Locator.Main;
            GlobalObject.curMainPage = this;
            _loginGridView           = new Grid()
            {
                Style          = (Style)App.Current.Resources[ConfigConstants.GRID_VIEW_LAYOUT],
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };
            _loginScreenLabel = new Label()
            {
                Style     = (Style)App.Current.Resources[ConfigConstants.LABEL_VIEW_LAYOUT],
                Text      = "Welcome Biometric Authentication",
                TextColor = Color.Orange
            };
            _userNameEntry = new Entry()
            {
                Style            = (Style)App.Current.Resources[ConfigConstants.TEXTFIELD_VIEW_LAYOUT],
                Placeholder      = "Username",
                PlaceholderColor = Color.DimGray
            };
            _userNameEntry.SetBinding(Entry.TextProperty, ConfigConstants.USERNAME);

            _passwordEntry = new Entry()
            {
                Style            = (Style)App.Current.Resources[ConfigConstants.TEXTFIELD_VIEW_LAYOUT],
                Placeholder      = "Password",
                IsPassword       = true,
                PlaceholderColor = Color.DimGray
            };
            _userNameEntry.SetBinding(Entry.TextProperty, ConfigConstants.PASSWORD);


            _loginButton = new Button()
            {
                Style = (Style)App.Current.Resources[ConfigConstants.BUTTON_VIEW_LAYOUT]
            };

            _biometrickTextLabel = new Label()
            {
                IsVisible = false,
                Style     = (Style)App.Current.Resources[ConfigConstants.LABEL_VIEW_LAYOUT]
            };
            var tgr = new TapGestureRecognizer();

            tgr.Tapped += Tgr_Tapped;
            _biometrickTextLabel.GestureRecognizers.Add(tgr);

            _loginGridView.Children.Add(_loginScreenLabel, 0, 0);
            _loginGridView.Children.Add(_userNameEntry, 0, 1);
            _loginGridView.Children.Add(_passwordEntry, 0, 2);
            _loginGridView.Children.Add(_loginButton, 0, 3);
            _loginGridView.Children.Add(_biometrickTextLabel, 0, 5);

            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    _loginGridView
                }
            };
        }