-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ios): RequestedTheme will now affects KeyboardAppearance
- Loading branch information
Showing
8 changed files
with
200 additions
and
3 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
63 changes: 63 additions & 0 deletions
63
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_iOS_Theme.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,63 @@ | ||
<Page x:Class="UITests.Windows_UI_Xaml_Input.Keyboard.Keyboard_iOS_Theme" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Input.Keyboard" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ios="http://uno.ui/ios" | ||
mc:Ignorable="d ios" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<ScrollViewer> | ||
<StackPanel> | ||
<TextBlock Text="Requested Theme:" /> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<RadioButton Grid.Column="0" Content="Default" Click="UpdateTheme" HorizontalAlignment="Stretch" /> | ||
<RadioButton Grid.Column="1" Content="Light" Click="UpdateTheme" HorizontalAlignment="Stretch" /> | ||
<RadioButton Grid.Column="2" Content="Dark" Click="UpdateTheme" HorizontalAlignment="Stretch" /> | ||
</Grid> | ||
|
||
<TextBlock Text="KB Appearance: for 'custom' text/password-box" /> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<RadioButton Grid.Column="0" Content="Default" Click="UpdateKeyboardAppearance" HorizontalAlignment="Stretch" /> | ||
<RadioButton Grid.Column="1" Content="Light" Click="UpdateKeyboardAppearance" HorizontalAlignment="Stretch" /> | ||
<RadioButton Grid.Column="2" Content="Dark" Click="UpdateKeyboardAppearance" HorizontalAlignment="Stretch" /> | ||
</Grid> | ||
<TextBlock Text="note: Dark will be displayed as Alert because it shared the same value." | ||
TextWrapping="WrapWholeWords" /> | ||
|
||
<StackPanel x:Name="TestPanel"> | ||
<TextBlock Text="TextBox" Margin="0,20,0,0" /> | ||
<TextBox PlaceholderText="default" /> | ||
<TextBox PlaceholderText="light" ios:KeyboardAppearance="Light" /> | ||
<TextBox PlaceholderText="dark" ios:KeyboardAppearance="Dark" /> | ||
<TextBox PlaceholderText="custom:" /> | ||
|
||
<TextBlock Text="PasswordBox" Margin="0,20,0,0" /> | ||
<PasswordBox PlaceholderText="default" /> | ||
<PasswordBox PlaceholderText="light" ios:KeyboardAppearance="Light" /> | ||
<PasswordBox PlaceholderText="dark" ios:KeyboardAppearance="Dark" /> | ||
<PasswordBox PlaceholderText="custom:" /> | ||
</StackPanel> | ||
|
||
<TextBlock TextWrapping="WrapWholeWords"> | ||
<Run>The 'device theme' can be changed by (ios)Settings > Developer > Dark Appearance.</Run><LineBreak /><LineBreak /> | ||
<Run>'default' should be affected by requested theme or os theme.</Run><LineBreak /> | ||
<Run>'dark/light' should always be that theme.</Run><LineBreak /> | ||
<Run>'custom' should be affected by 'KB Appearance', requested theme or os theme.</Run><LineBreak /> | ||
</TextBlock> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Page> |
74 changes: 74 additions & 0 deletions
74
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_iOS_Theme.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,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Uno.UI.Samples.Controls; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
namespace UITests.Windows_UI_Xaml_Input.Keyboard | ||
{ | ||
[SampleControlInfo("Keyboard", nameof(Keyboard_iOS_Theme), | ||
description: Description, | ||
ignoreInSnapshotTests: true, | ||
isManualTest: true)] | ||
public sealed partial class Keyboard_iOS_Theme : Page | ||
{ | ||
private const string Description = "[iOS-only] Keyboard theme should be determined based on the following precedences: KeyboardAppearance > RequestedTheme > Device Theme."; | ||
|
||
public Keyboard_iOS_Theme() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void UpdateTheme(object sender, RoutedEventArgs e) | ||
{ | ||
var root = global::Windows.UI.Xaml.Window.Current.Content as FrameworkElement; | ||
var theme = (sender as RadioButton).Content switch | ||
{ | ||
"Light" => ElementTheme.Light, | ||
"Dark" => ElementTheme.Dark, | ||
"Default" => ElementTheme.Default, | ||
|
||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
|
||
root.RequestedTheme = theme; | ||
} | ||
|
||
private void UpdateKeyboardAppearance(object sender, RoutedEventArgs e) | ||
{ | ||
#if __IOS__ | ||
var appearance = (sender as RadioButton).Content switch | ||
{ | ||
"Light" => UIKit.UIKeyboardAppearance.Light, | ||
"Dark" => UIKit.UIKeyboardAppearance.Dark, | ||
"Default" => UIKit.UIKeyboardAppearance.Default, | ||
|
||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
foreach (var item in TestPanel.Children.OfType<FrameworkElement>()) | ||
{ | ||
if (item is TextBox tbox && tbox.PlaceholderText?.StartsWith("custom") == true) | ||
{ | ||
tbox.PlaceholderText = $"custom: {appearance}"; | ||
tbox.KeyboardAppearance = appearance; | ||
} | ||
else if (item is PasswordBox pbox && pbox.PlaceholderText?.StartsWith("custom") == true) | ||
{ | ||
pbox.PlaceholderText = $"custom: {appearance}"; | ||
pbox.KeyboardAppearance = appearance; | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
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