private void SetStyle() { MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = StyleConverter; multiBinding.Bindings.Add(new Binding { RelativeSource = RelativeSource.Self }); multiBinding.Bindings.Add(new Binding("State")); AppButton.SetBinding(StyleProperty, multiBinding); }
protected override View CreateContent() { var logoWidth = MainPage.PageWidth / 4.4366; var logoHeight = MainPage.PageHeight / 7.3297; var logoTopOffset = MainPage.PageHeight / 6.0636; var welcomeTextOffset = MainPage.PageHeight / 17.1026; var emailHeight = MainPage.PageHeight / 7.0211; var passwordHeight = MainPage.PageHeight / 8.2346; var errorHeight = MainPage.PageHeight / 12.5849; var errorBottomOffset = MainPage.PageHeight / 60.6363; var forgotTopOffset = MainPage.PageHeight / 95.2857; var signUpTopOffset = MainPage.PageHeight / 11.9107; var textFontSize = MainPage.PageHeight / 60.6364; var entryFontSize = MainPage.PageHeight / 39.2353; var signUpFontSize = MainPage.PageHeight / 55.5833; var horizontalPadding = MainPage.PageWidth / 7.8125; var color = Color.White; var placeholderColor = Color.White; var errorColor = Color.White; // Color.FromHex("#E27A73"); var commandColor = Color.FromHex("#61A8A1"); var imageSize = MainPage.PageWidth / 17.0455; var imageOffset = imageSize / 2; #region Logo var logo = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = logoWidth, HeightRequest = logoHeight, Source = "logo" }; var logoContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, logoTopOffset, 0, 0), Content = logo }; #endregion #region Welcome var welcome = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = Color.White }; welcome.SetBinding(AppLabel.TextProperty, new Binding("LoginPanelWelcomeText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); var welcomeContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, welcomeTextOffset, 0, 0), Content = welcome }; #endregion #region Сontent #region Email _email = new AppEntryEditor { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, HeightRequest = emailHeight, AppFont = AppFonts.Quicksand, FontSize = entryFontSize, TextColor = color, ErrorTextColor = errorColor, PlaceholderColor = placeholderColor, ImageSource = "email_white", ErrorImageSource = "email_red", ImageSize = imageSize, ImageOffset = imageOffset, Keyboard = Keyboard.Email }; _email.SetBinding(AppEntryEditor.TextProperty, "Email", BindingMode.TwoWay); _email.SetBinding(AppEntryEditor.PlaceholderProperty, new Binding("LoginPanelEmailPlaceholderText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _email.SetBinding(AppEntryEditor.IsErrorProperty, "IsErrorEmail"); #endregion #region Password _password = new AppEntryEditor { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, HeightRequest = passwordHeight, AppFont = AppFonts.Quicksand, FontSize = entryFontSize, TextColor = color, ErrorTextColor = errorColor, PlaceholderColor = placeholderColor, ImageSource = "lock_white", ErrorImageSource = "lock_red", ImageSize = imageSize, ImageOffset = imageOffset, Keyboard = Keyboard.Default, IsPassword = true }; _password.SetBinding(AppEntryEditor.TextProperty, "Password", BindingMode.TwoWay); _password.SetBinding(AppEntryEditor.PlaceholderProperty, new Binding("LoginPanelPasswordPlaceholderText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _password.SetBinding(AppEntryEditor.IsErrorProperty, "IsErrorPassword"); #endregion #region Error var error = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Center, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = errorColor }; error.SetBinding(AppLabel.TextProperty, "ErrorText"); error.SetBinding(AppLabel.IsVisibleProperty, "IsError"); var errorContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, HeightRequest = errorHeight, Padding = new Thickness(0, 0, 0, errorBottomOffset), Content = error }; #endregion #region LogIn _logIn = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; _logIn.SetBinding(AppButton.TextProperty, new Binding("LoginPanelLogInButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _logIn.SetBinding(AppButton.CommandProperty, "LogInCommand"); var logInContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Content = _logIn }; #endregion #region Forgot Password var forgot = new AppCommand { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, IsUnderline = true, FontSize = 14, TextColor = commandColor, DisableTextColor = commandColor }; forgot.SetBinding(AppCommand.TextProperty, new Binding("LoginPanelForgotCommandText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); forgot.SetBinding(AppCommand.CommandProperty, "ForgotCommand"); var forgotContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, forgotTopOffset, 0, 0), Content = forgot }; #endregion #region SignUp var signUp = new AppCommand { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, IsUnderline = true, FontSize = 14, TextColor = commandColor, DisableTextColor = commandColor }; signUp.SetBinding(AppCommand.TextProperty, new Binding("LoginPanelSignUpCommandText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); signUp.SetBinding(AppCommand.CommandProperty, "SignUpCommand"); var signUpContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, signUpTopOffset, 0, 0), Content = signUp }; #endregion var content = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(horizontalPadding, 0, horizontalPadding, 0), RowSpacing = 0, ColumnSpacing = 0, 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) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } } }; content.Children.Add(_email, 0, 0); content.Children.Add(_password, 0, 1); content.Children.Add(errorContent, 0, 2); content.Children.Add(logInContent, 0, 3); content.Children.Add(forgotContent, 0, 4); content.Children.Add(signUpContent, 0, 5); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, RowSpacing = 0, ColumnSpacing = 0, 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) } } }; grid.Children.Add(logoContent, 0, 0); grid.Children.Add(welcomeContent, 0, 1); grid.Children.Add(content, 0, 2); _email.Completed += (sender, args) => { _password.SetFocus(); }; _password.Completed += (sender, args) => { if ((_logIn.Command != null) && (_logIn.Command.CanExecute(_logIn.CommandParameter))) { _logIn.Command.Execute(_logIn.CommandParameter); } }; _scroll = new ScrollView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Content = grid }; return(_scroll); }
private View CreateContent() { #region Content var converter = new TestResultToImageConverter(); var image = new Image { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, HeightRequest = 100, WidthRequest = 100, }; image.SetBinding(Image.SourceProperty, new Binding("Result", BindingMode.OneWay, converter, null, null, this)); var messageLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), TextColor = Color.Black, }; messageLabel.SetBinding(Label.TextProperty, new Binding("Text", BindingMode.OneWay, null, null, null, this)); var content = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, ColumnSpacing = 10, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; content.Children.Add(image, 0, 0); content.Children.Add(messageLabel, 1, 0); #endregion #region Commands var continueCommand = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = "CONTINUE" }; continueCommand.SetBinding(AppButton.CommandProperty, new Binding("ContinueCommand", BindingMode.OneWay, null, null, null, this)); var commands = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, RowSpacing = 0, ColumnSpacing = 0 }; commands.Children.Add(continueCommand); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Center, RowSpacing = 10, ColumnSpacing = 0, BackgroundColor = Color.Gray, Padding = new Thickness(20, 10, 20, 10), 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) } } }; grid.Children.Add(content, 0, 1); grid.Children.Add(commands, 0, 2); return(grid); }
protected override View CreateContent() { var logoWidth = MainPage.PageWidth / 4.4366; var logoHeight = MainPage.PageHeight / 7.3297; var logoTopOffset = MainPage.PageHeight / 6.0636; var welcomeTextOffset = MainPage.PageHeight / 17.1026; var buttonsOffset = MainPage.PageHeight / 6.2925; var facebookSize = MainPage.PageHeight / 26.6800; var facebookHOffset = MainPage.PageWidth / 5.0000; #region Logo var logo = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = logoWidth, HeightRequest = logoHeight, Source = "logo" }; var logoContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, logoTopOffset, 0, 0), Content = logo }; #endregion #region Welcome var welcome = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = Color.White }; welcome.SetBinding(AppLabel.TextProperty, new Binding("StartPanelWelcomeText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); var welcomeContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, welcomeTextOffset, 0, 0), Content = welcome }; #endregion #region Buttons var logIn = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; logIn.SetBinding(AppButton.TextProperty, new Binding("StartPanelLogInButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); logIn.SetBinding(AppButton.CommandProperty, "LogInCommand"); var createAccount = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; createAccount.SetBinding(AppButton.TextProperty, new Binding("StartPanelCreateAccountButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); createAccount.SetBinding(AppButton.CommandProperty, "CreateAccountCommand"); var facebookLogin = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppButtonStyle = AppButtonStyles.Facebook, Image = "facebook_white", WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; facebookLogin.SetBinding(AppButton.TextProperty, new Binding("StartPanelFacebookLoginButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); facebookLogin.SetBinding(AppButton.CommandProperty, "FacebookLoginCommand"); var buttons = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Spacing = MainPage.PageHeight / 29, Padding = new Thickness(0, buttonsOffset, 0, 0) }; buttons.Children.Add(logIn); buttons.Children.Add(createAccount); buttons.Children.Add(facebookLogin); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, RowSpacing = 0, ColumnSpacing = 0, 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) } } }; grid.Children.Add(logoContent, 0, 0); grid.Children.Add(welcomeContent, 0, 1); grid.Children.Add(buttons, 0, 2); return(grid); }