This repository has been archived by the owner on May 1, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Port from old VSM branch * Add PS and notes * Checkpoint: entry text UWP mostly working, need to check on background colors * Remove irrelevant samples from the EntryDisabledStatesGallery Make Background color work on UWP Entry with VSM * Add platform specific for disabling legacy colors on Android * Add OnPlatform example to visual state manager gallery * Add example OnIdiom in Visual State Manager * Add platform specific for disabling legacy color mode on iOS Entry * Add gallery for Button disabled states Handling legacy colors for Buttons on Android * Split out disabled states galleries; disabled legacy handling for Picker * TimePicker disabled states * DatePicker color management on Android * Color management for pre-AppCompat button * Button legacy color handling on iOS * Consolidate Platform Specifics; legacy colors working for iOS Picker and DatePicker * Fix broken search bar color management SearchBar color management working with VSM Add test page for SearchBar disabled color management Consolidate legacy color management check code into extension method on Android * Legacy color management for Editor on Android * Fix legacy color stuff for SearchBar Cancel button on iOS * C# 7 cleanup * Add colors for Cancel Button * Make sure VisualStateGroup collections set by styles are distinct objects * Validation example * Make common state names consts * Make the Windows VSM and Forms VSM work together * Update galleries for Windows * Make new methods internal * Split gallery classes and add more explanation to validation example * Remove debugging statements * Add a quick code-only example * Make legacy color management work for fast button renderer * Remove old TODO * Update docs * Move RunTimeNamePropertyAttribute to Xamarin.Forms.Xaml namespace * Verify XF namespace when looking for VisualState * Use nameof * Make common states constants public * Cast VisualElement directly so it crashes if the property is set on the wrong type * Collection -> IList for VisualStateManager * Setting fromStyle to true * Remove extraneous `private set` * Seal VSM classes * Use constraints instead of == * Add teardown method; use constraints rather than == * Remove null checking with GetVisualStateGroups * Don't explicitly initialize collections on elements * Actually, turns out that fromStyle:false *was* correct * Direct casts * Use GetIsDefault check in GoToState * Validate parents in FindTypeForVisualState * Validate group and state names on Add * Fixed check for setter collection * Fix issues with "duplicate" names when VisualStateGroups declared directly on VisualElements * Add gallery example for VSGs directly on VisualElements * Update docs * Fix bug where initial TextColor isn't set for FastRenderer Button * Move to explicit VisualStateGroupList in Setter * Fix return types for unit tests * Using string.CompareOrdinal in GetState * Update docs * Add check for null/empty VisualState Name properties
- Loading branch information
Showing
94 changed files
with
4,550 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
....Forms.Controls/GalleryPages/VisualStateManagerGalleries/ButtonDisabledStatesGallery.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?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.ButtonDisabledStatesGallery" | ||
Title="Button Disabled States Gallery"> | ||
|
||
<ContentPage.Resources> | ||
<ResourceDictionary> | ||
|
||
<Style TargetType="Button" x:Key="CustomDisabledState"> | ||
<Setter Property="VisualStateManager.VisualStateGroups"> | ||
<VisualStateGroupList> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal" /> | ||
<!-- Because we're creating our own PointerOver state here, the Forms VSM will override | ||
the Windows VSM for UWP. So this button won't display the native PointerOver behavior. | ||
If we remove this next line, the usual PointerOver behavior will be restored. --> | ||
<VisualState x:Name="PointerOver" /> | ||
<VisualState x:Name="Disabled"> | ||
<VisualState.Setters> | ||
<Setter Property="TextColor" Value="Red" /> | ||
<Setter Property="BackgroundColor" Value="Purple" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateGroupList> | ||
</Setter> | ||
</Style> | ||
|
||
<Style TargetType="Button" 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="BackgroundColor" Value="Black" /> | ||
</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 Button below uses the current XF defaults; when IsEnabled is false, it uses the default native colors for the control. (Legacy Color Behavior)"/> | ||
<Button Text="Button" x:Name="Button0" TextColor="Blue" BackgroundColor="Bisque" /> | ||
<Button Text="Toggle IsEnabled" x:Name="Button0_Toggle" Clicked="Button0_Toggle_OnClicked" /> | ||
|
||
<!-- Legacy Color Behavior turned off by the PlatformSpecific; ignores states entirely and uses | ||
whatever colors are manually set for it --> | ||
<Label Text="The Button below has the Legacy Color Behavior disabled; it will stick with whatever colors are set, regardless of state"/> | ||
<Button Text="Button" x:Name="Button1" TextColor="Blue" BackgroundColor="Bisque" | ||
androidSpecific:VisualElement.IsLegacyColorModeEnabled="False" | ||
iosSpecific:VisualElement.IsLegacyColorModeEnabled="False" | ||
windowsSpecific:VisualElement.IsLegacyColorModeEnabled="False" | ||
/> | ||
<Button Text="Toggle IsEnabled" x:Name="Button1_Toggle" Clicked="Button1_Toggle_OnClicked" /> | ||
|
||
<!-- Disabled colors fully managed by the VSM --> | ||
<Label Text="The Button below uses the VSM to customize the colors for the disabled state." /> | ||
<Button Text="Button" x:Name="Button2" Style="{StaticResource CustomDisabledState}" TextColor="Green" | ||
BackgroundColor="Beige" /> | ||
<Button Text="Toggle IsEnabled" x:Name="Button2_Toggle" Clicked="Button2_Toggle_OnClicked" /> | ||
|
||
<!-- This section verifies that the default colors for an entry's text and placeholder are cached and can be reverted to --> | ||
<Label Text="This Button uses Color.Default for the intial text/background, and colors from the VSM when disabled."/> | ||
<Button Text="Button" x:Name="Button3" Style="{StaticResource DefaultInInitialState}" TextColor="Default" | ||
BackgroundColor="Default" /> | ||
<Button Text="Toggle IsEnabled" x:Name="Button3_Toggle" Clicked="Button3_Toggle_OnClicked" /> | ||
</StackLayout> | ||
</ScrollView> | ||
</ContentPage.Content> | ||
</ContentPage> |
48 changes: 48 additions & 0 deletions
48
...rms.Controls/GalleryPages/VisualStateManagerGalleries/ButtonDisabledStatesGallery.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class ButtonDisabledStatesGallery : ContentPage | ||
{ | ||
public ButtonDisabledStatesGallery () | ||
{ | ||
InitializeComponent (); | ||
} | ||
|
||
void Button0_Toggle_OnClicked(object sender, EventArgs e) | ||
{ | ||
var button = sender as Button; | ||
ToggleIsEnabled(Button0, button); | ||
} | ||
|
||
void Button1_Toggle_OnClicked(object sender, EventArgs e) | ||
{ | ||
var button = sender as Button; | ||
ToggleIsEnabled(Button1, button); | ||
} | ||
|
||
void Button2_Toggle_OnClicked(object sender, EventArgs e) | ||
{ | ||
var button = sender as Button; | ||
ToggleIsEnabled(Button2, button); | ||
} | ||
|
||
void Button3_Toggle_OnClicked(object sender, EventArgs e) | ||
{ | ||
var button = sender as Button; | ||
ToggleIsEnabled(Button3, button); | ||
} | ||
|
||
void ToggleIsEnabled(Button button, Button toggleButton) | ||
{ | ||
button.IsEnabled = !button.IsEnabled; | ||
|
||
if (toggleButton != null) | ||
{ | ||
toggleButton.Text = $"Toggle IsEnabled (Currently {button.IsEnabled})"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.