/// <summary> /// Adds a new wrapping word Label to the target visualElement. Type can be BoldLabel, ItalicLabel or Label /// </summary> /// <typeparam name="T"></typeparam> /// <param name="textToAdd">The text inside the word label.</param> /// <param name="elementList">Redundant storage, mostly used for automated testing.</param> /// <param name="addToVisualElement">Parent container for the word Label.</param> static void AddLabel <T>(string textToAdd, List <VisualElement> elementList, VisualElement addToVisualElement) where T : Label { Label wordLabel = null; Type LabelType = typeof(T); if (LabelType == typeof(ItalicLabel)) { wordLabel = new ItalicLabel(textToAdd); } else if (LabelType == typeof(BoldLabel)) { wordLabel = new BoldLabel(textToAdd); } else if (LabelType == typeof(TextLabel)) { wordLabel = new TextLabel(textToAdd); } if (wordLabel == null) { Debug.LogError("Error: Unsupported Label type used. Use TextLabel, BoldLabel or ItalicLabel."); return; } elementList.Add(wordLabel); addToVisualElement.Add(wordLabel); }
public LoginPage() { NavigationPage.SetHasNavigationBar(this, false); // Status bar for iOS. var statusBar = new BoxView(); if (Device.OS == TargetPlatform.iOS) { statusBar.BackgroundColor = StyleManager.DarkAccentColor; statusBar.HeightRequest = 20; } // Application title & subtitle. var titleString = new FormattedString(); titleString.Spans.Add(new Span { ForegroundColor = StyleManager.AccentColor, FontAttributes = FontAttributes.Italic, FontSize = 40, Text = "Todo " }); titleString.Spans.Add(new Span { ForegroundColor = StyleManager.DarkAccentColor, FontAttributes = FontAttributes.Italic, FontSize = 32, Text = "app" }); var title = new DefaultLabel { FormattedText = titleString, HorizontalOptions = LayoutOptions.Center }; var subtitle = new ItalicLabel { Text = "Helping you doing everything", TextColor = StyleManager.AccentColor }; var titleLayout = new StackLayout { Children = { title, subtitle }, Spacing = 2, Padding = new Thickness(0, 30) }; // Start layout (down arrow). var login = new ItalicLabel { Text = "Log in", CustomFontSize = NamedSize.Medium }; var downArrow = new Image { Source = "down_button.png", HeightRequest = 60 }; var startLayout = new StackLayout { Padding = new Thickness(0, 100), Spacing = 18, Children = { login, downArrow } }; // Login layout. emailTextBox = new DefaultEntry { Placeholder = "Email" }; passwordTextBox = new DefaultEntry { Placeholder = "Password", IsPassword = true }; var entryLayout = new StackLayout { Spacing = 15, Children = { emailTextBox, passwordTextBox } }; submitButton = new DefaultButton { Command = new Command(Submit) }; signUpString = new FormattedString(); signUpString.Spans.Add(new Span { ForegroundColor = StyleManager.AccentColor, FontAttributes = FontAttributes.Italic }); signUpString.Spans.Add(new Span { ForegroundColor = StyleManager.DarkAccentColor, FontAttributes = FontAttributes.Bold }); var toggleModeLabel = new DefaultLabel { FormattedText = signUpString, HorizontalOptions = LayoutOptions.Center }; var signInLayout = new StackLayout { Padding = new Thickness(0, 20), Spacing = 30, Children = { submitButton, toggleModeLabel } }; var loginLayout = new StackLayout { Padding = new Thickness(0, 35), Children = { entryLayout, signInLayout }, IsVisible = false }; downArrow.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { loginLayout.IsVisible = true; startLayout.IsVisible = false; }) }); var toggleModeGestureRecognizer = new TapGestureRecognizer(); toggleModeGestureRecognizer.Tapped += (sender, ev) => toggleMode(); toggleModeLabel.GestureRecognizers.Add(toggleModeGestureRecognizer); // Main content layout. var contentLayout = new StackLayout { Padding = 25, HorizontalOptions = LayoutOptions.Center, Children = { titleLayout, startLayout, loginLayout } }; Content = new StackLayout { Children = { statusBar, contentLayout } }; setLoginMode(); }
public MenuPage() { Padding = new Thickness(0, Device.OnPlatform(0, 0, 0), 0, 0); Title = "Menu"; var perfectedLogo = new Image { Source = "perfectedtech-logo-white.png", HeightRequest = 60 }; var perfectedLabel = new ItalicLabel { Text = "Created in PerfectedTech 2015", CustomFontSize = NamedSize.Medium, TextColor = Color.White }; var perfectedLinkGestureRecognizer = new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://perfectedtech.com/"))) }; perfectedLogo.GestureRecognizers.Add(perfectedLinkGestureRecognizer); perfectedLabel.GestureRecognizers.Add(perfectedLinkGestureRecognizer); var strongloopLogo = new Image { Source = "strongloop.png", HeightRequest = 60 }; var strongloopLabel = new ItalicLabel { Text = "Powered by Strongloop", CustomFontSize = NamedSize.Medium, TextColor = Color.White }; var strongloopLinkGestureRecognier = new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("https://strongloop.com/"))) }; strongloopLogo.GestureRecognizers.Add(strongloopLinkGestureRecognier); strongloopLabel.GestureRecognizers.Add(strongloopLinkGestureRecognier); var logoLayout = new StackLayout { Padding = new Thickness(0, 20), Spacing = 30, Children = { perfectedLogo, perfectedLabel, strongloopLogo, strongloopLabel }, BackgroundColor = StyleManager.MainColor }; var menuTemplate = new DataTemplate(typeof(ImageCell)); menuTemplate.SetBinding(TextCell.TextProperty, "Text"); menuTemplate.SetBinding(ImageCell.ImageSourceProperty, "ImageSource"); menuTemplate.SetBinding(TextCell.CommandProperty, "Command"); var menuList = new ListView { ItemsSource = new List <object> { new { Text = "Logout", Command = new Command(() => Navigation.PopAsync()), ImageSource = "logout.png" } }, ItemTemplate = menuTemplate, SeparatorVisibility = SeparatorVisibility.None }; BackgroundColor = Color.White; Content = new StackLayout { Children = { logoLayout, menuList } }; }