Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add TextBox playground #1161

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion Uno.Gallery/Views/SamplePages/TextBoxSamplePage.xaml
kazo0 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:SamplePageLayout>
<local:SamplePageLayout x:Name="SamplePageLayout">

<local:SamplePageLayout.FluentTemplate>
<DataTemplate>
Expand Down Expand Up @@ -217,6 +217,45 @@

</StackPanel>
</smtx:XamlDisplay>

<smtx:XamlDisplay UniqueKey="TextBoxSamplePage_Material_Playground"
smtx:XamlDisplayExtensions.Header="TextBox Playground"
smtx:XamlDisplayExtensions.IgnorePath="XamlDisplay\StackPanel">

<StackPanel Spacing="10"
Padding="20"
HorizontalAlignment="Center"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Orientation="Vertical">
<TextBox Style="{StaticResource MaterialFilledTextBoxStyle}"
x:Name="txtFilled"
Width="270" />
<TextBox Style="{StaticResource MaterialOutlinedTextBoxStyle}"
x:Name="txtOutlined"
Width="270" />
<StackPanel HorizontalAlignment="Center"
Spacing="8"
Orientation="Horizontal">
<Button Content="Add Header"
Click="AddHeader" />
<Button Content="Add Placeholder"
Click="AddPlaceholder" />
<Button Content="Add Text"
Click="AddText" />
</StackPanel>

<StackPanel VerticalAlignment="Center"
Spacing="8"
Orientation="Horizontal">
<Button Content="Remove Header"
Click="RemoveHeader" />
<Button Content="Remove Placeholder"
Click="RemovePlaceholder" />
<Button Content="Remove Text"
Click="RemoveText" />
kazo0 marked this conversation as resolved.
Show resolved Hide resolved
</StackPanel>
</StackPanel>
</smtx:XamlDisplay>
</StackPanel>
</DataTemplate>
</local:SamplePageLayout.MaterialTemplate>
Expand Down
87 changes: 87 additions & 0 deletions Uno.Gallery/Views/SamplePages/TextBoxSamplePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,96 @@ namespace Uno.Gallery.Views.Samples
[SamplePage(SampleCategory.UIComponents, "TextBox", Description = "This control allows users to input a textual value.", DocumentationLink = "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.textbox")]
public sealed partial class TextBoxSamplePage : Page
{
private TextBox txtFilled;
private TextBox txtOutlined;

public TextBoxSamplePage()
{
this.InitializeComponent();

Loaded += (s, e) =>
{
txtFilled = SamplePageLayout.GetSampleChild<TextBox>(Design.Material, "txtFilled");
txtOutlined = SamplePageLayout.GetSampleChild<TextBox>(Design.Material, "txtOutlined");
};
}

private void AddHeader(object sender, RoutedEventArgs e)
{
if (txtFilled != null)
{
txtFilled.Header = "Header";
}

if (txtOutlined != null)
{
txtOutlined.Header = "Header";
}
}

private void RemoveHeader(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Header = null;
}

if(txtOutlined != null)
{
txtOutlined.Header = null;
}
}

private void AddPlaceholder(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.PlaceholderText = "Placeholder";
}

if(txtOutlined != null)
{
txtOutlined.PlaceholderText = "Placeholder";
}
}

private void RemovePlaceholder(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.PlaceholderText = null;
}

if(txtOutlined != null)
{
txtOutlined.PlaceholderText = null;
}
}

private void AddText(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Text = "Text";
}

if(txtOutlined != null)
{
txtOutlined.Text = "Text";
}
}

private void RemoveText(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Text = null;
}

if(txtOutlined != null)
{
txtOutlined.Text = null;
}
}
}
}
Loading