-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
SearchBarDisabledStatesGallery.xaml
91 lines (81 loc) · 4.54 KB
/
SearchBarDisabledStatesGallery.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:windowsSpecific="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core"
xmlns:androidSpecific="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:iosSpecific="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
x:Class="Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries.SearchBarDisabledStatesGallery"
Title="SearchBar Disabled States Gallery">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="SearchBar" x:Key="CustomDisabledState">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="Red" />
<Setter Property="PlaceholderColor" Value="LightCoral" />
<Setter Property="BackgroundColor" Value="Purple" />
<Setter Property="CancelButtonColor" Value="OrangeRed" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="SearchBar" x:Key="DefaultInInitialState">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="Green" />
<Setter Property="PlaceholderColor" Value="LightGreen" />
<Setter Property="BackgroundColor" Value="Black" />
<Setter Property="CancelButtonColor" Value="DarkSeaGreen"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView VerticalOptions="Fill" HorizontalOptions="Fill">
<StackLayout>
<!-- Not using the VSM at all; should exhibit pre-VSM default behavior -->
<Label Text="The SearchBar below uses the current XF defaults; when IsEnabled is false, it uses the default native colors for the control. (Legacy Color Behavior)"/>
<SearchBar x:Name="Search0" TextColor="Default" PlaceholderColor="LightBlue" BackgroundColor="Bisque"
Placeholder="search" CancelButtonColor="Aqua">
</SearchBar>
<Button Text="Toggle IsEnabled" x:Name="Button0" Clicked="Button0_OnClicked" />
<!-- Legacy Color Behavior turned off by the PlatformSpecific; ignores states entirely and uses
whatever colors are manually set for it -->
<Label Text="The SearchBar below has the Legacy Color Behavior disabled; it will stick with whatever colors are set, regardless of state"/>
<SearchBar x:Name="Search1" TextColor="Blue" PlaceholderColor="Green" Placeholder="placeholder"
BackgroundColor="Bisque" CancelButtonColor="GreenYellow"
windowsSpecific:VisualElement.IsLegacyColorModeEnabled="False"
androidSpecific:VisualElement.IsLegacyColorModeEnabled="False"
iosSpecific:VisualElement.IsLegacyColorModeEnabled="False"
/>
<Button Text="Toggle IsEnabled" x:Name="Button1" Clicked="Button1_OnClicked" />
<!-- Disabled colors fully managed by the VSM -->
<Label Text="The SearchBar below uses the VSM to customize the colors for the disabled state." />
<SearchBar x:Name="Search2" Style="{StaticResource CustomDisabledState}" TextColor="Green"
PlaceholderColor="LightGreen" Placeholder="placeholder" BackgroundColor="Beige"
CancelButtonColor="Aquamarine"/>
<Button Text="Toggle IsEnabled" x:Name="Button2" Clicked="Button2_OnClicked" />
<!-- This section verifies that the default colors for a searchbar's text and placeholder are cached and can be reverted to -->
<Label Text="This SearchBar uses Color.Default for the intial text/background, and colors from the VSM when disabled."/>
<SearchBar x:Name="Search3" Style="{StaticResource DefaultInInitialState}" TextColor="Default"
PlaceholderColor="Default" Placeholder="placeholder" BackgroundColor="Default"
CancelButtonColor="Default" />
<Button Text="Toggle IsEnabled" x:Name="Button3" Clicked="Button3_OnClicked" />
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>