using Xamarin.Forms.CustomAttributes; namespace Xamarin.Forms.Controls { internal class SearchBarCoreGalleryPage : CoreGalleryPage { // TODO protected override bool SupportsTapGestureRecognizer { get { return false; } } protected override void Build (StackLayout stackLayout) { base.Build (stackLayout); var placeholderContainer = new ViewContainer (Test.SearchBar.PlaceHolder, new SearchBar { Placeholder = "Placeholder" }); var searchButtonPressedContainer = new EventViewContainer (Test.SearchBar.SearchButtonPressed, new SearchBar { }); searchButtonPressedContainer.View.SearchButtonPressed += (sender, args) => searchButtonPressedContainer.EventFired (); var searchCommandContainer = new ViewContainer (Test.SearchBar.SearchCommand, new SearchBar { SearchCommand = new Command (async () => await DisplayAlert ("Search command", "Fired", "Ok")) } ); var textContainer = new ViewContainer (Test.SearchBar.Text, new SearchBar { Text = "I am text" }); var textChangedContainer = new EventViewContainer (Test.SearchBar.TextChanged, new SearchBar { Placeholder = "I am text changed" }); textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired (); var cancelButtonColor = new ViewContainer ( Test.SearchBar.CancelButtonColor, new SearchBar { Placeholder = "Should have a red cancel button", CancelButtonColor = Color.Red } ); var textFontAttributesContainer = new ViewContainer (Test.SearchBar.FontAttributes, new SearchBar { Text = "I have italic text", FontAttributes = FontAttributes.Italic }); var textFamilyContainer1 = new ViewContainer (Test.SearchBar.FontFamily, new SearchBar { Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS" }); var textFamilyContainer2 = new ViewContainer (Test.SearchBar.FontFamily, new SearchBar { Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold }); var textFontSizeContainer = new ViewContainer (Test.SearchBar.FontSize, new SearchBar { Text = "I have default size text" }); var textFontSizeDefaultContainer = new ViewContainer (Test.SearchBar.FontSize, new SearchBar { Text = "I also have default size text" }); textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize (NamedSize.Default, textFontSizeDefaultContainer.View); var textFontSizeLargeContainer = new ViewContainer (Test.SearchBar.FontSize, new SearchBar { Text = "I have size 48 (huge) text", FontSize = 48 }); var textAlignmentStartContainer = new ViewContainer (Test.SearchBar.TextAlignmentStart, new SearchBar { Text = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start }); var textAlignmentCenterContainer = new ViewContainer (Test.SearchBar.TextAlignmentCenter, new SearchBar { Text = "I should be centered", HorizontalTextAlignment = TextAlignment.Center }); var textAlignmentEndContainer = new ViewContainer (Test.SearchBar.TextAlignmentEnd, new SearchBar { Text = "I should be at the end", HorizontalTextAlignment = TextAlignment.End }); var placeholderAlignmentStartContainer = new ViewContainer (Test.SearchBar.PlaceholderAlignmentStart, new SearchBar { Placeholder = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start }); var placeholderAlignmentCenterContainer = new ViewContainer (Test.SearchBar.PlaceholderAlignmentCenter, new SearchBar { Placeholder = "I should be centered", HorizontalTextAlignment = TextAlignment.Center }); var placeholderAlignmentEndContainer = new ViewContainer (Test.SearchBar.PlaceholderAlignmentEnd, new SearchBar { Placeholder = "I should be at the end", HorizontalTextAlignment = TextAlignment.End }); var textColorContainer = new ViewContainer (Test.SearchBar.TextColor, new SearchBar { Text = "I should be red", TextColor = Color.Red }); var placeholderColorContainer = new ViewContainer (Test.SearchBar.PlaceholderColor, new SearchBar { Placeholder = "I should be red", PlaceholderColor = Color.Red }); Add (placeholderContainer); Add (searchButtonPressedContainer); Add (searchCommandContainer); Add (textContainer); Add (textChangedContainer); Add (textFontAttributesContainer); Add (textFamilyContainer1); Add (textFamilyContainer2); Add (textFontSizeContainer); Add (textFontSizeDefaultContainer); Add (textFontSizeLargeContainer); Add (cancelButtonColor); Add (textAlignmentStartContainer); Add (textAlignmentCenterContainer); Add (textAlignmentEndContainer); Add (placeholderAlignmentStartContainer); Add (placeholderAlignmentCenterContainer); Add (placeholderAlignmentEndContainer); Add (textColorContainer); Add (placeholderColorContainer); } } }