Uno.Themes
Uno.Themes copied to clipboard
feat: Introducing Header and Placeholder
GitHub Issue: #974 #842
PR Type
What kind of change does this PR introduce?
- Feature
Description
Introducing Header as Label and Placeholder to TextBox.
The former PlaceholderText was replaced by Header and a new Placeholder was added. The goal is to reproduce the Material 3 Textbox behavior.
PR Checklist
Please check if your PR fulfills the following requirements:
- Commits must be following the Conventional Commits specification
- [X] Tested UWP
- [ ] Tested iOS
- [X] Tested Android
- [X] Tested WASM
- [X] Tested GTK
- [ ] Tested MacOS
- [ ] Contains No breaking changes
If the pull request contains breaking changes, commit message must contain a detailed description of the action to take for the consumer of this library. As explained by the Conventional Commits specification
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Windows
WASM
GTK
Gtk cursor seems to be a bit bugged
Android
Android Obs
It feels like Android TextBox Header and Placeholder are a bit below of the center when unfocused. Do you feel the same? Would we add a proper Margin/Padding/Alignment only for Android to fix it?
@kazo0 @agneszitte @Xiaoy312
While testing the azure static web link, seems that the icon is not properly aligned vertically
While testing the azure static web link, seems that the icon is not properly aligned vertically
Thanks @agneszitte, will fix it ☺️
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
I'm having a problem with the TextBox cursor:
When I have Placeholder and Header the ContentElement_CompositeTransform.TranslateY
(cursor position) has value of 8 which means the cursor is aligned with the Placeholder position like this:
But when I have only Header the cursor should start with the position 0, which means it would be aligned with the Header text and when I type something it would go down (position 8). But ContentElement_CompositeTransform.TranslateY
(cursor position) is starting with value 8 already, like this:
When I type:
I can't find a way of check Text, PlaceholderText and Header at the same time to manipulate the cursor position as desired. Do you guys have any ideas?
I have pushed my changes.
@agneszitte @kazo0
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
@eriklimakc I will pull your branch to take a look and help you fix this issue
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
@eriklimakc I have pushed on your branch a commit to fix the MaterialFilledTextBoxStyle so it can follow the proper specs we agreed on for the related issue.
Here some things to note:
- The style follows the specs and works appropriately on Windows at the moment if I did not miss anything (I quickly added more samples so it is easy to test all the scenarios for MaterialFilledTextBoxStyle)
- I quickly tested the style on the other platforms and on specific cases we have some issues, so you will need to check them more closely. Since it works properly on Windows, the goal will be to determine what is not working on the Uno side.
- You will be able to use the same logic for the MaterialOutlinedTextBoxStyle
- Naming for the converter I added (+ related resources) will need to be adjusted for something better at the end if it will be the way to go for the final changes
(cc @kazo0)
@eriklimakc I have pushed on your branch a commit to fix the MaterialFilledTextBoxStyle so it can follow the proper specs we agreed on for the related issue.
Here some things to note:
- The style follows the specs and works appropriately on Windows at the moment if I did not miss anything (I quickly added more samples so it is easy to test all the scenarios for MaterialFilledTextBoxStyle)
- I quickly tested the style on the other platforms and on specific cases we have some issues, so you will need to check them more closely. Since it works properly on Windows, the goal will be to determine what is not working on the Uno side.
- You will be able to use the same logic for the MaterialOutlinedTextBoxStyle
- Naming for the converter I added (+ related resources) will need to be adjusted for something better at the end if it will be the way to go for the final changes
(cc @kazo0)
As an additional note, the converter is working fine on Windows but for the other platforms, the converter is only trigged once for each state. It seems like once it is triggered it won't trigger anymore for that state.
Related Issue for the Converter/VisualStates issue: https://github.com/unoplatform/uno/issues/12556
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Regarding animations all seems to be working fine after https://github.com/unoplatform/uno/issues/12556.
Only getting this behavior on non-windows platforms:
When TextBox is pressed and Placeholder/Text + Header is present they get back to the center and then animates to their right position:
https://github.com/unoplatform/Uno.Themes/assets/114886335/675e4f89-8f9d-4e1d-bf62-c38f30582dae
@eriklimakc what's the current status of this? Any remaining blockers?
Regarding animations all seems to be working fine after #974.
Only getting this behavior on non-windows platforms:
When TextBox is pressed and Placeholder/Text + Header is present they get back to the center and then animates to their right position:
TextBox.PnH.issue.mp4
@kazo0, there is only this behavior on non-windows platforms that I mentioned above with the video.
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Skia X Win
Apparently when the animation code is executed, the Text, Header, and Placeholder are quickly set to their default state and after that they are animated.
In order to test I replaced the animation code for Setters
like below and we don't have that behavior.
<Setter Target="HeaderElement_CompositeTransform.TranslateY"
Value="-11" />
<Setter Target="ContentElement_CompositeTransform.TranslateY"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EmptyToFocusedContentCompositeTransformTranslateY}, TargetNullValue=0, FallbackValue=0}" />
<Setter Target="PlaceholderElement_CompositeTransform.TranslateY"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EmptyToFocusedContentCompositeTransformTranslateY}, TargetNullValue=0, FallbackValue=0}" />
<Setter Target="HeaderElement_CompositeTransform.ScaleX"
Value="0.7" />
<Setter Target="HeaderElement_CompositeTransform.ScaleY"
Value="0.7" />
cc @Xiaoy312 @kazo0 @agneszitte
@eriklimakc re: https://github.com/unoplatform/Uno.Themes/pull/1014#issuecomment-1792223480 At a glance, this seems like an issue with the animation not picking up the current set/animated value as the starting point for the (start...end) animation. This is not probably not something we will fix here, but in uno. Can you can open an issue in uno and @ me there. Also, is this happening on other platforms as well, like ios/droid or wasm?
Thanks for the info @Xiaoy312
Yes, this happens in all platforms except Windows.
Here's the issue on Uno https://github.com/unoplatform/uno/issues/14262.
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-rock-0cfebe70f-1014.eastus2.azurestaticapps.net