protected override void SetToolbar() { _toolbar = View.FindViewById <Toolbar>(Resource.Id.app_basket_delivery_on_point_toolbar); _toolbar.Title = Title; _toolbar.SetNavigationIcon(Resource.Drawable.abc_ic_clear_material); _toolbar.NavigationClick += OnBackClick; _toolbar.MenuItemClick += OnSearchMenuItemClick; var searchMenuItem = _toolbar.Menu.Add(0, MENU_SEARCH_ID, 0, ""); var typedValue = new TypedValue(); Activity.Theme.ResolveAttribute(Resource.Attribute.app_basket_delivery_on_point_ic_toolbar_search, typedValue, true); searchMenuItem.SetIcon(Resources.GetDrawable(typedValue.ResourceId, Context.Theme)); searchMenuItem.SetShowAsAction(ShowAsAction.Always); _toolbarInSearchState = View.FindViewById <Toolbar>(Resource.Id.app_basket_delivery_on_point_toolbar_onSearch); _toolbarInSearchState.SetNavigationIcon(Resource.Drawable.abc_ic_ab_back_material); _toolbarInSearchState.NavigationClick += OnBackToToolbarClick; _toolbarInSearchState.MenuItemClick += OnClearSearchClick; var clearMenuItem = _toolbarInSearchState.Menu.Add(0, MENU_CLEAR_ID, 0, ""); clearMenuItem.SetIcon(Resource.Drawable.abc_ic_clear_material); clearMenuItem.SetShowAsAction(ShowAsAction.Always); _searchEditText = View.FindViewById <Android.Widget.EditText>(Resource.Id.app_basket_delivery_on_point_toolbar_onSearch_input); _searchEditText.SetOnKeyListener(this); }
/// <inheritdoc/> public void BindToNative(object nativeView, BindOptions options = BindOptions.None) { if (nativeView == null) { throw new ArgumentNullException("nativeView"); } UnbindFromNative(); editText = ViewHelpers.GetView <Android.Widget.EditText> (nativeView); if (options.HasFlag(BindOptions.PreserveNativeProperties)) { text = editText.Text; placeholder = editText.Hint; enabled = editText.Enabled; } else { editText.Text = text; editText.Hint = placeholder; editText.Enabled = enabled; } editText.TextChanged += EditText_TextChanged; }
/// <inheritdoc/> public void UnbindFromNative() { if (editText == null) { return; } editText.TextChanged -= EditText_TextChanged; editText = null; }
private void DrawLine(Android.Widget.EditText control, Android.Graphics.Color color) { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { control.BackgroundTintList = ColorStateList.ValueOf(color); } else { control.Background.SetColorFilter(color, PorterDuff.Mode.SrcAtop); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.TryInstantConnect); // Extract PdfActivity configuration from extras. configuration = Intent.GetParcelableExtra(ConfigurationArg).JavaCast <PdfActivityConfiguration> (); if (configuration is null) { throw new InvalidOperationException("'InstantExampleConnectionActivity' was not initialized with proper arguments: Missing configuration extra!"); } // Configure toolbar. var toolbar = FindViewById <Toolbar> (Resource.Id.toolbar); SetSupportActionBar(toolbar); // Configure new document button. var documentButton = FindViewById <Android.Widget.Button> (Resource.Id.button_new_document); documentButton.Click += async(sender, e) => await CreateNewDocument(); // Configure edit document button. var editDocumentButton = FindViewById <Android.Widget.Button> (Resource.Id.button_edit_document); editDocumentButton.Enabled = false; editDocumentButton.Click += async(sender, e) => await EditDocument(documentCodeEditText.Text); // Configure document code edit box. documentCodeEditText = FindViewById <Android.Widget.EditText> (Resource.Id.edit_text_document_code); documentCodeEditText.EditorAction += async(sender, e) => { if (e.ActionId == ImeAction.Go && (e.Event == null || e.Event?.Action == KeyEventActions.Up)) { await EditDocument(documentCodeEditText.Text); e.Handled = true; } e.Handled = false; }; documentCodeEditText.AfterTextChanged += (sender, e) => { var code = (sender as Android.Widget.EditText).Text; editDocumentButton.Enabled = code?.Length == WebPreviewApiClient.CodeLength; }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); View view = this.BindingInflate(Resource.Layout.LoginLayout, null); var prefs = Application.Context.GetSharedPreferences("Fildo", FileCreationMode.Private); this.cultureInfo = ((MainView)this.Activity).CultureInfo; if (!string.IsNullOrEmpty(((BaseViewModel)((MainView)this.Activity).ViewModel).PlayingArtist)) { ((MainView)this.Activity).FindViewById <Android.Widget.LinearLayout>(Resource.Id.miniPlayer).Visibility = ViewStates.Visible; } this.progress = new Bindables.BindableProgress(view.Context, this.ViewModel); var set = this.CreateBindingSet <LoginView, LoginViewModel>(); set.Bind(this.progress).For(p => p.Visible).To(vm => vm.IsBusy); set.Bind(this.progress).For(p => p.NoInternet).To(vm => vm.NoInternet); set.Bind(this).For(p => p.Logged).To(vm => vm.Logged); set.Apply(); this.username = view.FindViewById <Android.Widget.EditText>(Resource.Id.UsernameEditText); this.password = view.FindViewById <Android.Widget.EditText>(Resource.Id.PasswordEditText); this.username.Text = prefs.GetString("Username", string.Empty); this.password.Text = prefs.GetString("Password", string.Empty); if (this.ViewModel != null) { view.FindViewById <Android.Widget.TextView>(Resource.Id.loginText).Text = ((BaseViewModel)this.ViewModel).GetString("LoginText", this.cultureInfo); } if (!string.IsNullOrEmpty(this.username.Text) && !string.IsNullOrEmpty(this.password.Text)) { ((LoginViewModel)this.ViewModel).DoLogin(); GAService.GetGASInstance().Track_App_Page("My Playlists"); return(this.BindingInflate(Resource.Layout.EmptyLayout, null)); } GAService.GetGASInstance().Track_App_Page("Login"); return(view); }
private async Task CreateItemFromDialogAsync(EditText control) { if (control.Text != null) { var item = new TodoItem { Title = control.Text, IsComplete = false }; try { await TodoService.SaveItemAsync(item); RunOnUiThread(() => todoAdapter.AddItem(item)); } catch (Exception error) { ShowError(error); } } }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); view = inflater.Inflate(Resource.Layout.Clientes_view, null); Nombre = view.FindViewById <Android.Widget.EditText>(Resource.Id.Nombre); //Rfc = view.FindViewById<Android.Widget.EditText>(Resource.Id.Rfc); //Total = view.FindViewById<Android.Widget.EditText>(Resource.Id.Total); Contratados = view.FindViewById <Android.Widget.EditText>(Resource.Id.Contratados); Disponibles = view.FindViewById <Android.Widget.EditText>(Resource.Id.Disponibles); Emitidos = view.FindViewById <Android.Widget.EditText>(Resource.Id.Emitidos); Cancelados = view.FindViewById <Android.Widget.EditText>(Resource.Id.Cancelados); UltimaFactura = view.FindViewById <Android.Widget.EditText>(Resource.Id.Ultima); Registrar = view.FindViewById <Android.Widget.Button>(Resource.Id.btnInsertar); Registrar.Click += Registrar_Click; return(view); }
//functions public void BuildPageObjects() { var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)); //Layout innerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { #if __ANDROID__ new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, #endif #if __IOS__ new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } #endif }, #if __IOS__ ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } #endif }; outerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; //View objects playListNameLbl = new Label { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = -5, #endif Text = "Name:" }; playListNameEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize * .75, #endif Placeholder = "Leg Lasso List" }; playListDescriptionLbl = new Label { Text = "Description:", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = -5, #endif }; playListDescriptionEditor = new Editor { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Editor)), #if __IOS__ FontFamily = "AmericanTypewriter-Bold", #endif #if __ANDROID__ FontFamily = "Roboto Bold", BackgroundColor = Color.White #endif }; editorFrame = new Frame { Content = playListDescriptionEditor, BorderColor = Color.Black, BackgroundColor = Color.Black, HasShadow = false, Padding = 3 }; backBtn = new Button { Style = (Style)Application.Current.Resources["common-red-btn"], Image = "back.png" }; createBtn = new Button { Style = (Style)Application.Current.Resources["common-blue-btn"], Text = "Create", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = btnSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = btnSize * 1.25, #endif }; #if __ANDROID__ var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174)); pd.SetCornerRadius(100); androidPlaylistNameEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidPlaylistNameEntry.Hint = "Enter Name"; androidPlaylistNameEntry.Typeface = Constants.COMMONFONT; androidPlaylistNameEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100); androidPlaylistNameEntry.SetTextColor(Android.Graphics.Color.Black); androidPlaylistNameEntry.Gravity = Android.Views.GravityFlags.Start; androidPlaylistNameEntry.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; androidPlaylistDescriptionEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidPlaylistDescriptionEntry.Hint = "Enter Description"; androidPlaylistDescriptionEntry.Typeface = Constants.COMMONFONT; androidPlaylistDescriptionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidPlaylistDescriptionEntry.SetTextColor(Android.Graphics.Color.Black); androidPlaylistDescriptionEntry.Gravity = Android.Views.GravityFlags.Start; androidPlaylistDescriptionEntry.InputType = Android.Text.InputTypes.TextVariationLongMessage; androidCreateBtn = new Android.Widget.Button(MainApplication.ActivityContext); androidCreateBtn.Text = "Create Playlist"; androidCreateBtn.Typeface = Constants.COMMONFONT; androidCreateBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidCreateBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255)); androidCreateBtn.SetBackground(pd); androidCreateBtn.Gravity = Android.Views.GravityFlags.Center; androidCreateBtn.SetAllCaps(false); androidCreateBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await CreatePlaylist(sender, e); ToggleButtons(); }; contentViewAndroidPlaylistNameEntry = new ContentView(); contentViewAndroidPlaylistNameEntry.Content = androidPlaylistNameEntry.ToView(); contentViewAndroidPlaylistDescriptionEntry = new ContentView(); contentViewAndroidPlaylistDescriptionEntry.Content = androidPlaylistDescriptionEntry.ToView(); contentViewAndroidCreateBtn = new ContentView(); contentViewAndroidCreateBtn.Content = androidCreateBtn.ToView(); #endif //events backBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PopModalAsync(); ToggleButtons(); }; createBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await CreatePlaylist(sender, e); ToggleButtons(); }; #if __IOS__ //building grid innerGrid.Children.Add(playListNameLbl, 0, 0); playListNameLbl.VerticalTextAlignment = TextAlignment.Center; playListNameLbl.HorizontalTextAlignment = TextAlignment.Center; Grid.SetColumnSpan(playListNameLbl, 2); innerGrid.Children.Add(playListNameEntry, 0, 1); Grid.SetColumnSpan(playListNameEntry, 2); innerGrid.Children.Add(playListDescriptionLbl, 0, 2); Grid.SetColumnSpan(playListDescriptionLbl, 2); playListDescriptionLbl.VerticalTextAlignment = TextAlignment.Center; playListDescriptionLbl.HorizontalTextAlignment = TextAlignment.Center; innerGrid.Children.Add(editorFrame, 0, 3); Grid.SetRowSpan(editorFrame, 3); Grid.SetColumnSpan(editorFrame, 2); innerGrid.Children.Add(backBtn, 0, 7); innerGrid.Children.Add(createBtn, 1, 7); #endif #if __ANDROID__ //building grid innerGrid.Children.Add(contentViewAndroidPlaylistNameEntry, 0, 2); innerGrid.Children.Add(contentViewAndroidPlaylistDescriptionEntry, 0, 3); innerGrid.Children.Add(contentViewAndroidCreateBtn, 0, 6); #endif outerGrid.Children.Add(innerGrid, 0, 0); Content = outerGrid; }
private void BuildPageObjects() { var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)); var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry)); stackLayout = new StackLayout(); entryLayout = new StackLayout(); buttonGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; #if __ANDROID__ var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174)); pd.SetCornerRadius(100); outerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; innerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; androidHeaderLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidHeaderLbl.Text = "Forgot Password"; androidHeaderLbl.Typeface = Constants.COMMONFONT; androidHeaderLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100); androidHeaderLbl.SetTextColor(Android.Graphics.Color.Black); androidHeaderLbl.Gravity = Android.Views.GravityFlags.Center; androidEmailLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidEmailLbl.Text = "E-Mail Address"; androidEmailLbl.Typeface = Constants.COMMONFONT; androidEmailLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 100); androidEmailLbl.SetTextColor(Android.Graphics.Color.Black); androidEmailLbl.Gravity = Android.Views.GravityFlags.Center; androidEmailEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidEmailEntry.Hint = "Enter E-Mail"; androidEmailEntry.Typeface = Constants.COMMONFONT; androidEmailEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidEmailEntry.SetTextColor(Android.Graphics.Color.Black); androidEmailEntry.Gravity = Android.Views.GravityFlags.Center; androidEmailEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress; androidNextBtn = new Android.Widget.Button(MainApplication.ActivityContext); androidNextBtn.Text = "Next"; androidNextBtn.Typeface = Constants.COMMONFONT; androidNextBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidNextBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255)); androidNextBtn.Gravity = Android.Views.GravityFlags.Center; androidNextBtn.SetBackground(pd); androidNextBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await CheckIfUserExists(sender, e); ToggleButtons(); }; androidNextImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext); androidNextImgBtn.SetImageResource(2130837802); androidNextImgBtn.SetAdjustViewBounds(true); androidNextImgBtn.SetBackground(pd); androidNextImgBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await CheckIfUserExists(sender, e); ToggleButtons(); }; contentViewHeaderLbl = new ContentView(); contentViewHeaderLbl.Content = androidHeaderLbl.ToView(); contentViewEmailLbl = new ContentView(); contentViewEmailLbl.Content = androidEmailLbl.ToView(); contentViewEmailEntry = new ContentView(); contentViewEmailEntry.Content = androidEmailEntry.ToView(); contentViewNextBtn = new ContentView(); contentViewNextBtn.Content = androidNextImgBtn.ToView(); #endif headerLbl = new Label { Text = "Forgot Password", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.StartAndExpand }; emailLbl = new Label { Text = "E-Mail Address", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize * .75, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; emailEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize * 1.25, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = entrySize * .75, #endif Placeholder = "Enter E-Mail" }; backBtn = new Button { Image = "back.png", Style = (Style)Application.Current.Resources["common-red-btn"] }; nextBtn = new Button { Style = (Style)Application.Current.Resources["common-blue-btn"], Image = "next.png", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; //events backBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PopModalAsync(); ToggleButtons(); }; nextBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await CheckIfUserExists(sender, e); ToggleButtons(); }; //building layouts #if __ANDROID__ innerGrid.Children.Add(contentViewHeaderLbl, 0, 0); innerGrid.Children.Add(contentViewEmailLbl, 0, 3); innerGrid.Children.Add(contentViewEmailEntry, 0, 4); innerGrid.Children.Add(contentViewNextBtn, 0, 7); outerGrid.Children.Add(innerGrid, 0, 0); Content = outerGrid; #endif #if __IOS__ buttonGrid.Children.Add(backBtn, 0, 0); buttonGrid.Children.Add(nextBtn, 1, 0); entryLayout.Children.Add(emailLbl); entryLayout.Children.Add(emailEntry); entryLayout.HorizontalOptions = LayoutOptions.FillAndExpand; entryLayout.VerticalOptions = LayoutOptions.FillAndExpand; stackLayout.Children.Add(headerLbl); stackLayout.Children.Add(entryLayout); stackLayout.Children.Add(buttonGrid); Content = stackLayout; #endif }
private void SetDisabledColors(Android.Widget.EditText control, Android.Graphics.Color color) { control.SetTextColor(Element.IsEnabled ? Element.TextColor.ToAndroid() : color); }
private void BuildPageObjects() { var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)); var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry)); stackLayout = new StackLayout(); scrollView = new ScrollView(); buttonGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) } } }; headerLbl = new Label { Text = "Change Password", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; secretQuestionLbl = new Label { Text = _user.SecretQuestion, #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize * .75, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; secretQuestionEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = entrySize * .75, #endif VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; newPasswordLbl = new Label { Text = "New Password", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize * .75, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; newPasswordEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = entrySize * .75, #endif IsPassword = true, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; backBtn = new Button { Image = "back.png", Style = (Style)Application.Current.Resources["common-red-btn"] }; submitBtn = new Button { Style = (Style)Application.Current.Resources["common-blue-btn"], #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = btnSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = btnSize * .75, #endif Text = "Submit" }; #if __ANDROID__ var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174)); pd.SetCornerRadius(100); innerGrid = new Grid(); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); innerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }); outerGrid = new Grid(); outerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); androidSecretQuestionLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidSecretQuestionLbl.Text = _user.SecretQuestion; androidSecretQuestionLbl.Typeface = Constants.COMMONFONT; androidSecretQuestionLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidSecretQuestionLbl.SetTextColor(Android.Graphics.Color.Black); androidSecretQuestionLbl.Gravity = Android.Views.GravityFlags.Center; androidSecretQuestionEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidSecretQuestionEntry.Typeface = Constants.COMMONFONT; androidSecretQuestionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidSecretQuestionEntry.SetTextColor(Android.Graphics.Color.Black); androidSecretQuestionEntry.Gravity = Android.Views.GravityFlags.Start; androidSecretQuestionEntry.InputType = Android.Text.InputTypes.TextVariationShortMessage; androidNewPasswordLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidNewPasswordLbl.Text = "New Password"; androidNewPasswordLbl.Typeface = Constants.COMMONFONT; androidNewPasswordLbl.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidNewPasswordLbl.SetTextColor(Android.Graphics.Color.Black); androidNewPasswordLbl.Gravity = Android.Views.GravityFlags.Center; androidNewPasswordEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidNewPasswordEntry.Typeface = Constants.COMMONFONT; androidNewPasswordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidNewPasswordEntry.SetTextColor(Android.Graphics.Color.Black); androidNewPasswordEntry.Gravity = Android.Views.GravityFlags.Start; androidNewPasswordEntry.InputType = Android.Text.InputTypes.TextVariationPassword; androidNewPasswordEntry.TransformationMethod = new PasswordTransformationMethod(); androidSubmitBtn = new Android.Widget.Button(MainApplication.ActivityContext); androidSubmitBtn.Text = "Change Password"; androidSubmitBtn.Typeface = Constants.COMMONFONT; androidSubmitBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidSubmitBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255)); androidSubmitBtn.SetBackground(pd); androidSubmitBtn.SetAllCaps(false); androidSubmitBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await ChangePassword(sender, e); ToggleButtons(); }; contentViewAndroidSecretQuestionLbl = new ContentView(); contentViewAndroidSecretQuestionLbl.Content = androidSecretQuestionLbl.ToView(); contentViewAndroidSecretQuestionEntry = new ContentView(); contentViewAndroidSecretQuestionEntry.Content = androidSecretQuestionEntry.ToView(); contentViewAndroidNewPasswordLbl = new ContentView(); contentViewAndroidNewPasswordLbl.Content = androidNewPasswordLbl.ToView(); contentViewAndroidNewPasswordEntry = new ContentView(); contentViewAndroidNewPasswordEntry.Content = androidNewPasswordEntry.ToView(); contentViewAndroidSubmitBtn = new ContentView(); contentViewAndroidSubmitBtn.Content = androidSubmitBtn.ToView(); #endif //events backBtn.Clicked += (sender, e) => { backBtn.IsEnabled = false; Navigation.PopModalAsync(); backBtn.IsEnabled = true; }; submitBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await ChangePassword(sender, e); ToggleButtons(); }; //layout #if __ANDROID__ innerGrid.Children.Add(contentViewAndroidSecretQuestionLbl, 0, 3); innerGrid.Children.Add(contentViewAndroidSecretQuestionEntry, 0, 4); innerGrid.Children.Add(contentViewAndroidNewPasswordLbl, 0, 6); innerGrid.Children.Add(contentViewAndroidNewPasswordEntry, 0, 7); innerGrid.Children.Add(contentViewAndroidSubmitBtn, 0, 10); outerGrid.Children.Add(innerGrid, 0, 0); Content = outerGrid; #endif #if __IOS__ buttonGrid.Children.Add(backBtn, 0, 0); buttonGrid.Children.Add(submitBtn, 1, 0); stackLayout.Children.Add(headerLbl); stackLayout.Children.Add(secretQuestionLbl); stackLayout.Children.Add(secretQuestionEntry); stackLayout.Children.Add(newPasswordLbl); stackLayout.Children.Add(newPasswordEntry); stackLayout.Children.Add(buttonGrid); scrollView.Content = stackLayout; Content = scrollView; #endif }
//functions private void SetContent() { var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)); var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry)); //View objects beltLbl = new Label { Text = "Belt", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = new Thickness(0, -5, 0, -5), #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; beltList = new ObservableCollection <string>(); beltList.Add("White"); beltList.Add("Blue"); beltList.Add("Purple"); beltList.Add("Brown"); beltList.Add("Black"); beltPicker = new Picker { Title = "Choose Your Rank", ItemsSource = beltList }; nameLbl = new Label { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = new Thickness(0, -5, 0, -5), #endif Text = "Name", VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; nameEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = entrySize * .5, Margin = new Thickness(0, -5, 0, -5), #endif Placeholder = "Brian Mahecha", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; emailAddressLbl = new Label { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = new Thickness(0, -5, 0, -5), #endif Text = "E-Mail Address", VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; emailAddressEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize, #endif #if __ANDROID__ FontFamily = "Roboto Bold", Margin = new Thickness(0, -5, 0, -5), FontSize = entrySize * .5, #endif Placeholder = "*****@*****.**", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; passWordLbl = new Label { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", Margin = new Thickness(0, -5, 0, -5), FontSize = lblSize, #endif Text = "Password", VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; passWordEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize, #endif #if __ANDROID__ FontFamily = "Roboto Bold", Margin = new Thickness(0, -5, 0, -5), FontSize = entrySize * .5, #endif IsPassword = true, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; secretQuestionLbl = new Label { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 1.5, #endif #if __ANDROID__ FontFamily = "Roboto Bold", Margin = new Thickness(0, -5, 0, -5), FontSize = lblSize, #endif Text = "Secret Questions", VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; secretQuestionList = new ObservableCollection <String>(); secretQuestionList.Add("What city were you born in?"); secretQuestionList.Add("What city was your high school?"); secretQuestionList.Add("Name of favorite instructor."); secretQuestionPicker = new Picker { Title = "Select a secret question to answer!", ItemsSource = secretQuestionList }; secretQuestionEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = entrySize, #endif #if __ANDROID__ FontFamily = "Roboto Bold", Margin = new Thickness(0, -5, 0, -5), FontSize = entrySize * .5, #endif Placeholder = "Answer for your own security!", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; nextBtn = new Button { Style = (Style)Application.Current.Resources["common-blue-btn"], Image = "next.png", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; backBtn = new Button { Style = (Style)Application.Current.Resources["common-red-btn"], Image = "back.png", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; clearBtn = new Button { Style = (Style)Application.Current.Resources["common-red-btn"], #if __IOS__ FontFamily = "AmericanTypewriter-Bold", #endif #if __ANDROID__ FontFamily = "Roboto Bold", #endif Text = "Clear", FontSize = btnSize }; #if __ANDROID__ var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174)); pd.SetCornerRadius(100); androidNameEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidNameEntry.Hint = "Name"; androidNameEntry.Typeface = Constants.COMMONFONT; androidNameEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidNameEntry.SetTextColor(Android.Graphics.Color.Black); androidNameEntry.Gravity = Android.Views.GravityFlags.Start; androidNameEntry.InputType = Android.Text.InputTypes.TextVariationPersonName; androidBeltLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidBeltLbl.Text = "Belt"; androidBeltLbl.Typeface = Constants.COMMONFONT; androidBeltLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidBeltLbl.SetTextColor(Android.Graphics.Color.Black); androidBeltLbl.Gravity = Android.Views.GravityFlags.Start; androidEmailAddressEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidEmailAddressEntry.Hint = "E-Mail Address"; androidEmailAddressEntry.Typeface = Constants.COMMONFONT; androidEmailAddressEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidEmailAddressEntry.SetTextColor(Android.Graphics.Color.Black); androidEmailAddressEntry.Gravity = Android.Views.GravityFlags.Start; androidEmailAddressEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress; androidPassWordEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidPassWordEntry.Hint = "Password"; androidPassWordEntry.Typeface = Constants.COMMONFONT; androidPassWordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidPassWordEntry.SetTextColor(Android.Graphics.Color.Black); androidPassWordEntry.Gravity = Android.Views.GravityFlags.Start; androidPassWordEntry.InputType = Android.Text.InputTypes.TextVariationPassword; androidPassWordEntry.TransformationMethod = new PasswordTransformationMethod(); androidSecretQuestionsLbl = new Android.Widget.TextView(MainApplication.ActivityContext); androidSecretQuestionsLbl.Text = "Secret Questions"; androidSecretQuestionsLbl.Typeface = Constants.COMMONFONT; androidSecretQuestionsLbl.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidSecretQuestionsLbl.SetTextColor(Android.Graphics.Color.Black); androidSecretQuestionsLbl.Gravity = Android.Views.GravityFlags.Start; androidSecretQuestionEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidSecretQuestionEntry.Hint = "Answer for your own security!"; androidSecretQuestionEntry.Typeface = Constants.COMMONFONT; androidSecretQuestionEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidSecretQuestionEntry.SetTextColor(Android.Graphics.Color.Black); androidSecretQuestionEntry.Gravity = Android.Views.GravityFlags.Start; androidSecretQuestionEntry.InputType = Android.Text.InputTypes.TextVariationShortMessage; androidNextImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext); androidNextImgBtn.SetImageResource(2130837802); androidNextImgBtn.SetAdjustViewBounds(true); androidNextImgBtn.SetBackground(pd); androidNextImgBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await Validate(); ToggleButtons(); }; #endif //Events nextBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Validate(); ToggleButtons(); }; backBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PopModalAsync(); ToggleButtons(); }; //passWordRepeatEntry.Unfocused += PasswordMatch; //TODO add specific validation events to make sure entries are correct. tableView = new TableView(); tableView.BackgroundColor = Color.FromHex("#F1ECCE"); tableView.Intent = TableIntent.Form; tableView.Root = new TableRoot() { new TableSection() { new ViewCell { View = nameLbl }, new ViewCell { View = nameEntry }, new ViewCell { View = emailAddressLbl }, new ViewCell { View = emailAddressEntry }, new ViewCell { View = beltLbl }, new ViewCell { View = beltPicker }, new ViewCell { View = passWordLbl }, new ViewCell { View = passWordEntry }, new ViewCell { View = secretQuestionLbl }, new ViewCell { View = secretQuestionPicker }, new ViewCell { View = secretQuestionEntry } } }; #if __IOS__ buttonGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; buttonGrid.Children.Add(backBtn, 0, 0); buttonGrid.Children.Add(nextBtn, 1, 0); #endif #if __ANDROID__ buttonGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; buttonGrid.Children.Add(androidNextImgBtn.ToView(), 0, 0); #endif scrollView = new ScrollView(); #if __IOS__ stackLayout = new StackLayout { Children = { tableView } }; #endif #if __ANDROID__ stackLayout = new StackLayout { Children = { androidNameEntry.ToView(), androidEmailAddressEntry.ToView(), androidBeltLbl.ToView(), beltPicker, androidPassWordEntry.ToView(), androidSecretQuestionsLbl.ToView(), secretQuestionPicker, androidSecretQuestionEntry.ToView() } }; #endif scrollView.Content = stackLayout; #if __ANDROID__ scrollView.IsClippedToBounds = true; #endif #if __IOS__ innerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(9, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; #endif #if __ANDROID__ innerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(9, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; #endif outerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; innerGrid.Children.Add(scrollView, 0, 0); innerGrid.Children.Add(buttonGrid, 0, 1); outerGrid.Children.Add(innerGrid); Content = outerGrid; }
public static async void OpenInputDialog(string title, Action <string> callback, int max_length = 0, object[] args = null) { if (PlatformFunctions.IsDialogOpen) { return; } PlatformFunctions.IsDialogOpen = true; string result = ""; Engine.Pause(); #if ANDROID var builder = new Android.App.AlertDialog.Builder(NeonPartyGamesControllerGame.AndroidContext); var input = new Android.Widget.EditText(NeonPartyGamesControllerGame.AndroidContext); var tcs = new System.Threading.Tasks.TaskCompletionSource <bool>(); builder.SetTitle(title); if (args != null && args.Length > 0) { input.InputType = (Android.Text.InputTypes)args[0]; } else { input.InputType = Android.Text.InputTypes.ClassText; } if (max_length > 0) { input.SetFilters(new Android.Text.IInputFilter[] { new Android.Text.InputFilterLengthFilter(max_length) }); } builder.SetView(input); builder.SetPositiveButton("OK", (sender_alert, sender_args) => { VibrationHelper.Vibrate(); result = input.Text; }); builder.SetOnDismissListener(new OnDismissListener(() => tcs.TrySetResult(true))); builder.Show(); await tcs.Task; #elif IOS var tcs = new System.Threading.Tasks.TaskCompletionSource <bool>(); UIKit.UIAlertView alert = new UIKit.UIAlertView(); alert.Title = title; alert.AddButton("OK"); alert.AlertViewStyle = UIKit.UIAlertViewStyle.PlainTextInput; alert.Clicked += (object s, UIKit.UIButtonEventArgs ev) => { if (ev.ButtonIndex == 0) { result = alert.GetTextField(0).Text; } }; alert.Dismissed += (object s, UIKit.UIButtonEventArgs ev) => { tcs.TrySetResult(true); }; alert.Show(); await tcs.Task; #elif NETFX_CORE await Xamarin.Essentials.MainThread.InvokeOnMainThreadAsync(async() => { var input_text_box = new Windows.UI.Xaml.Controls.TextBox { AcceptsReturn = false, Height = 32 }; if (max_length > 0) { input_text_box.MaxLength = max_length; } var dialog = new Windows.UI.Xaml.Controls.ContentDialog { Content = input_text_box, Title = title, PrimaryButtonText = "Ok", IsSecondaryButtonEnabled = true, SecondaryButtonText = "Cancel", DefaultButton = Windows.UI.Xaml.Controls.ContentDialogButton.Primary }; if (await dialog.ShowAsync() == Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { result = input_text_box.Text; } else { result = ""; } }); #else #if DEBUG await System.Threading.Tasks.Task.Run(() => { var debugger = Engine.GetFirstInstanceByType <DebuggerWithTerminal>(); debugger?.OpenConsoleWithCustomEvaluator(value => result = value); while (debugger != null && debugger.ConsoleOpen) { System.Threading.Thread.Sleep(1); } }); #endif #endif Engine.Resume(); PlatformFunctions.IsDialogOpen = false; if (!string.IsNullOrWhiteSpace(result)) { callback?.Invoke(result); } }
//functions private void BuildPageObjects() { var btnSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)); var lblSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); var entrySize = Device.GetNamedSize(NamedSize.Large, typeof(Entry)); scrollView = new ScrollView(); stackLayout = new StackLayout(); buttonLayout = new StackLayout(); emailLayout = new StackLayout(); passwordLayout = new StackLayout(); innerStackLayout = new StackLayout(); innerStackLayout.Spacing = 50; //View objects innerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(7, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(2, GridUnitType.Star) } } }; outerGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } } }; buttonGrid = new Grid { ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; emailGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) } } }; passwordGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) } } }; mahechaLogo = new Image { Source = ImageSource.FromResource("mahechabjjlogo.png"), Aspect = Aspect.AspectFit }; emailImg = new Image { Source = "mail.png", Aspect = Aspect.AspectFit }; emailLbl = new Label { Text = "E-Mail Address", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = -5, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; emailEntry = new Entry { #if __IOS__ FontFamily = "AmericanTypewriter-Bold", #endif #if __ANDROID__ FontFamily = "Roboto Bold", Placeholder = "E-Mail Address", #endif FontSize = entrySize, HorizontalOptions = LayoutOptions.FillAndExpand }; passwordImg = new Image { Source = "password.png", Aspect = Aspect.AspectFit }; passwordLbl = new Label { Text = "Password", #if __IOS__ FontFamily = "AmericanTypewriter-Bold", FontSize = lblSize * 2, #endif #if __ANDROID__ FontFamily = "Roboto Bold", FontSize = lblSize, Margin = -5, #endif VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; passwordEntry = new Entry { IsPassword = true, #if __IOS__ FontFamily = "AmericanTypewriter-Bold", #endif #if __ANDROID__ FontFamily = "Roboto Bold", Placeholder = "Password", #endif FontSize = entrySize, HorizontalOptions = LayoutOptions.FillAndExpand }; loginBtn = new Button { Text = "Login", FontFamily = "AmericanTypewriter-Bold", FontSize = btnSize * 2, Style = (Style)Application.Current.Resources["common-blue-btn"], VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; backBtn = new Button { Image = "back.png", Style = (Style)Application.Current.Resources["common-red-btn"], VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; forgotPasswordBtn = new Button { Image = "forgotpassword.png", Style = (Style)Application.Current.Resources["common-blue-btn"], VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; #if __ANDROID__ var pd = new PaintDrawable(Android.Graphics.Color.Rgb(58, 93, 174)); pd.SetCornerRadius(100); var pdTwo = new PaintDrawable(Android.Graphics.Color.Rgb(124, 37, 41)); pdTwo.SetCornerRadius(100); androidLoginBtn = new Android.Widget.Button(MainApplication.ActivityContext); androidLoginBtn.Text = "Login"; androidLoginBtn.Typeface = Constants.COMMONFONT; androidLoginBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidLoginBtn.SetBackground(pd); androidLoginBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255)); androidLoginBtn.Gravity = Android.Views.GravityFlags.Center; androidLoginBtn.SetAllCaps(false); androidForgotPasswordBtn = new Android.Widget.Button(MainApplication.ActivityContext); androidForgotPasswordBtn.Text = "?"; androidForgotPasswordBtn.Typeface = Constants.COMMONFONT; androidForgotPasswordBtn.SetAutoSizeTextTypeWithDefaults(Android.Widget.AutoSizeTextType.Uniform); androidForgotPasswordBtn.SetBackground(pdTwo); androidForgotPasswordBtn.SetTextColor(Android.Graphics.Color.Rgb(242, 253, 255)); androidForgotPasswordBtn.Gravity = Android.Views.GravityFlags.Center; androidForgotPasswordBtn.SetAllCaps(false); androidForgetPasswordImgBtn = new Android.Widget.ImageButton(MainApplication.ActivityContext); androidForgetPasswordImgBtn.SetImageResource(2130837598); androidForgetPasswordImgBtn.SetAdjustViewBounds(true); androidForgetPasswordImgBtn.SetBackground(pdTwo); androidEmailEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidEmailEntry.Typeface = Constants.COMMONFONT; androidEmailEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidEmailEntry.SetPadding(0, 10, 0, 10); androidEmailEntry.SetTextColor(Android.Graphics.Color.Black); androidEmailEntry.InputType = Android.Text.InputTypes.TextVariationEmailAddress; androidImageEmail = new Android.Widget.ImageView(MainApplication.ActivityContext); androidImageEmail.SetImageResource(2130837780); androidImageEmail.SetAdjustViewBounds(true); androidPasswordEntry = new Android.Widget.EditText(MainApplication.ActivityContext); androidPasswordEntry.Typeface = Constants.COMMONFONT; androidPasswordEntry.SetTextSize(Android.Util.ComplexUnitType.Fraction, 75); androidPasswordEntry.SetPadding(0, 0, 0, 0); androidPasswordEntry.SetTextColor(Android.Graphics.Color.Black); androidPasswordEntry.SetHighlightColor(Android.Graphics.Color.Transparent); androidPasswordEntry.InputType = Android.Text.InputTypes.TextVariationWebPassword; androidPasswordEntry.TransformationMethod = new PasswordTransformationMethod(); androidImagePassword = new Android.Widget.ImageView(MainApplication.ActivityContext); androidImagePassword.SetImageResource(2130837816); androidImagePassword.SetAdjustViewBounds(true); #endif //Events loginBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Validate(sender, e); ToggleButtons(); }; backBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PopModalAsync(); ToggleButtons(); }; forgotPasswordBtn.Clicked += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PushModalAsync(new ForgotPasswordPage()); ToggleButtons(); }; #if __ANDROID__ androidLoginBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await Validate(sender, e); ToggleButtons(); }; androidForgetPasswordImgBtn.Click += async(object sender, EventArgs e) => { ToggleButtons(); await Navigation.PushModalAsync(new ForgotPasswordPage()); ToggleButtons(); }; #endif #if __IOS__ buttonLayout.Children.Add(backBtn); buttonLayout.Children.Add(loginBtn); buttonLayout.Children.Add(forgotPasswordBtn); buttonLayout.Orientation = StackOrientation.Horizontal; emailLayout.Children.Add(emailImg); emailLayout.Children.Add(emailEntry); emailLayout.Orientation = StackOrientation.Horizontal; passwordLayout.Children.Add(passwordImg); passwordLayout.Children.Add(passwordEntry); passwordLayout.Orientation = StackOrientation.Horizontal; innerStackLayout.Children.Add(emailLayout); innerStackLayout.Children.Add(passwordLayout); //innerStackLayout.Children.Add(emailImg); //innerStackLayout.Children.Add(emailEntry); //innerStackLayout.Children.Add(passwordImg); //innerStackLayout.Children.Add(passwordEntry); innerStackLayout.Children.Add(buttonLayout); stackLayout.Children.Add(mahechaLogo); stackLayout.Children.Add(innerStackLayout); stackLayout.Orientation = StackOrientation.Vertical; stackLayout.VerticalOptions = LayoutOptions.CenterAndExpand; stackLayout.HorizontalOptions = LayoutOptions.CenterAndExpand; scrollView.Content = stackLayout; Content = scrollView; #endif #if __ANDROID__ buttonGrid.Children.Add(androidLoginBtn.ToView(), 0, 0); buttonGrid.Children.Add(androidForgetPasswordImgBtn.ToView(), 1, 0); emailGrid.Children.Add(androidImageEmail.ToView(), 0, 0); emailGrid.Children.Add(androidEmailEntry.ToView(), 1, 0); emailGrid.Padding = new Thickness(10, 0); passwordGrid.Children.Add(androidImagePassword.ToView(), 0, 0); passwordGrid.Children.Add(androidPasswordEntry.ToView(), 1, 0); passwordGrid.Padding = new Thickness(10, 0); innerGrid.Children.Add(mahechaLogo, 0, 0); innerGrid.Children.Add(emailGrid, 0, 2); innerGrid.Children.Add(passwordGrid, 0, 4); innerGrid.Children.Add(buttonGrid, 0, 6); outerGrid.Children.Add(innerGrid, 0, 0); Content = outerGrid; #endif }
static View Create(Context context) { GridLayout p = new GridLayout(context); p.UseDefaultMargins = true; p.AlignmentMode = GridLayout.AlignBounds; var configuration = context.Resources.Configuration; if ((configuration.Orientation == Android.Content.Res.Orientation.Portrait)) { p.ColumnOrderPreserved = false; } else { p.RowOrderPreserved = false; } var titleRow = GridLayout.InvokeSpec(0); var introRow = GridLayout.InvokeSpec(1); var emailRow = GridLayout.InvokeSpec(2, GridLayout.BaselineAlignment); var passwordRow = GridLayout.InvokeSpec(3, GridLayout.BaselineAlignment); var button1Row = GridLayout.InvokeSpec(5); var button2Row = GridLayout.InvokeSpec(6); var centerInAllColumns = GridLayout.InvokeSpec(0, 4, GridLayout.CenterAlignment); var leftAlignInAllColumns = GridLayout.InvokeSpec(0, 4, GridLayout.LeftAlignment); var labelColumn = GridLayout.InvokeSpec(0, GridLayout.RightAlignment); var fieldColumn = GridLayout.InvokeSpec(1, GridLayout.LeftAlignment); var defineLastColumn = GridLayout.InvokeSpec(3); var fillLastColumn = GridLayout.InvokeSpec(3, GridLayout.FillAlignment); { var c = new Android.Widget.TextView(context); c.TextSize = 32; c.Text = "Email setup"; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(titleRow, centerInAllColumns)); } { var c = new Android.Widget.TextView(context); c.TextSize = 16; c.Text = "You can configure email in a few simple steps:"; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(introRow, leftAlignInAllColumns)); } { var c = new Android.Widget.TextView(context); c.Text = "Email address:"; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(emailRow, labelColumn)); } { var c = new Android.Widget.EditText(context); c.SetEms(10); c.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationEmailAddress; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(emailRow, fieldColumn)); } { var c = new Android.Widget.TextView(context); c.Text = "Password:"******"Manual setup"; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(button1Row, defineLastColumn)); c.Click += delegate { Android.Widget.Toast.MakeText(Application.Context, "Manual Tapped!", Android.Widget.ToastLength.Short).Show(); }; } { var c = new Android.Widget.Button(context); c.Text = "Next"; p.AddView(c, new Android.Support.V7.Widget.GridLayout.LayoutParams(button2Row, fillLastColumn)); c.Click += delegate { Android.Widget.Toast.MakeText(Application.Context, "Next Tapped!", Android.Widget.ToastLength.Short).Show(); }; } return(p); }