-
Notifications
You must be signed in to change notification settings - Fork 5
Button component added #13
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
base: master
Are you sure you want to change the base?
Conversation
Components/Button.ux
Outdated
| @@ -0,0 +1,71 @@ | |||
| <Panel ux:Class="Material.Button" Alignment="Center" Enabled="true" Raised="true" Height="48" MinWidth="88" Padding="8,0" HitTestMode="LocalBoundsAndChildren" BackgroundColor="White" InkColor="#ccc"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use HitTestMode="LocalBounds" instead, that seems sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Components/Button.ux
Outdated
| <float4 ux:Property="BackgroundColor"/> | ||
| <float4 ux:Property="InkColor"/> | ||
|
|
||
| <Rectangle ux:Name="RaisedButton_body" ZOffset="1" Height="36" Padding="8,0" CornerRadius="2"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When assigning a ux:Name to a node, the value should start with a lowercase letter and be in camelCase. This here, for example, should be ux:Name="raisedButtonBody".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And more of a question rather than a request for changes - is the ZOffset necessary? Can't you instead reorder the nodes so that the ones on top would be on top of the others in UX file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reordered, but the ZOffset is necessary actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary? I don't see any triggers involved in manipulating them, so I don't immediately see the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@igorls I tested and the ZOffsets do not seem to be necessary at all. You only need to put the nodes in the right order, just like layers in photoshop - the ones on top in UX are rendered on top of others.
Components/Button.ux
Outdated
| <float4 ux:Property="InkColor"/> | ||
|
|
||
| <Rectangle ux:Name="RaisedButton_body" ZOffset="1" Height="36" Padding="8,0" CornerRadius="2"> | ||
| <SolidColor Color="{ReadProperty this.BackgroundColor}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to prefix these properties with an explicit this.*, since they are referring to the whole ux:Class we are currently in and this.* is implied.
Components/Button.ux
Outdated
|
|
||
| <Rectangle ux:Name="RaisedButton_body" ZOffset="1" Height="36" Padding="8,0" CornerRadius="2"> | ||
| <SolidColor Color="{ReadProperty this.BackgroundColor}" /> | ||
| <WhileTrue Value="{ReadProperty this.Raised}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to prefix these properties with an explicit this.*, since they are referring to the whole ux:Class we are currently in and this.* is implied.
Components/Button.ux
Outdated
| </Rectangle> | ||
|
|
||
| <Rectangle ux:Name="innerPanel" ZOffset="3" Height="{ReadProperty RaisedButton_body.Height}" Padding="{ReadProperty RaisedButton_body.Padding}" CornerRadius="{ReadProperty RaisedButton_body.CornerRadius}" ClipToBounds="true"> | ||
| <Text Value="{ReadProperty this.Text}" Font="RobotoMedium" ux:Name="text" Alignment="Center" FontSize="14" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to prefix these properties with an explicit this.*, since they are referring to the whole ux:Class we are currently in and this.* is implied.
Components/Button.ux
Outdated
| <Text Value="{ReadProperty this.Text}" Font="RobotoMedium" ux:Name="text" Alignment="Center" FontSize="14" /> | ||
| </Rectangle> | ||
|
|
||
| <WhileTrue Value="{ReadProperty this.Enabled}" Invert="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to prefix these properties with an explicit this.*, since they are referring to the whole ux:Class we are currently in and this.* is implied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using <WhileTrue Invert="true"> can't you use a plain <WhileFalse>?
Components/Button.ux
Outdated
| </Rectangle> | ||
|
|
||
| <Rectangle ux:Name="innerPanel" ZOffset="3" Height="{ReadProperty RaisedButton_body.Height}" Padding="{ReadProperty RaisedButton_body.Padding}" CornerRadius="{ReadProperty RaisedButton_body.CornerRadius}" ClipToBounds="true"> | ||
| <Text Value="{ReadProperty this.Text}" Font="RobotoMedium" ux:Name="text" Alignment="Center" FontSize="14" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ux:Name should always be the first property on a node, followed by Value in case of <Text />.
Components/Button.ux
Outdated
|
|
||
| </WhileTrue> | ||
|
|
||
| <WhileTrue Value="{ReadProperty this.Enabled}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to prefix these properties with an explicit this.*, since they are referring to the whole ux:Class we are currently in and this.* is implied.
| <Set scaleAnimator.Duration="0.3" AtProgress="0" /> | ||
| <Set showInk.Value="true" AtProgress="0" /> | ||
| <Set showInk.Value="false" AtProgress="1" /> | ||
| <Set scaleAnimator.Duration="0.6" AtProgress="1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if these triggers were grouped together by the AtProgress value (0/1), otherwise it's hard to read what happens when.
| </Material.AppBar> | ||
|
|
||
| <Rectangle Dock="Top" Margin="5"> | ||
| <StackLayout/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a Rectangle with a StackLayout when you can just have a StackPanel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to use a stroke to separate the button example area from other upcoming examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still should be done differently though. Go with a StackPanel and we'll figure it out from there.
|
all requested changes were fixed, exception to the ZOffsets that were actually needed. |
Default Material typeface should be Roboto per the guidelines, changed Material.Text class to comply (https://material.io/guidelines/style/typography.html)
New class Material.Button according to the guidelines, adjustments are still needed. Current options are Raised/Flat Enabled/Disabled, as long as Background and Ink (ripple) colors. Demo added to the MainView.ux
| </StackPanel> | ||
| <StackPanel Orientation="Horizontal"> | ||
| <Material.Button Text="Flat Button - Enabled" Raised="false" Enabled="true" BackgroundColor="#FFFFFF00" InkColor="Material.Blue300"/> | ||
| <Material.Button Text="Flat Button - Disabled" Raised="false" Enabled="false" BackgroundColor="#FFFFFF00"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the background on these fully transparent on purpose? Wouldn't you want to reuse the same color as on the raised buttons, Material.Blue200?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to put no background on those to show that the ink effect applies to the area in case of a flat button, what do you think?
Style/Fonts.ux
Outdated
| @@ -0,0 +1,5 @@ | |||
| <Panel ux:Class="Material.Fonts"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add these fonts, it severely bloats the app.
This theme will use the platform's default font, which is Roboto on Android and San Francisco on iOS.
Bundling full Roboto will add 10MB to the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no problem, I also had a doubt about this
|
I think it's better for us to hold that PR until I replace my own implementation of the ink effect with the same one @Duckers has used in the other components, main reason being the glitch with the CornerRadius non-zero. Also to focus all effects on the same uno class, avoiding problems in the future |
New class Material.Button according to the guidelines, adjustments are still needed. Current options are Raised/Flat, Enabled/Disabled, Background and Ink (ripple) colors.
Demo added to the MainView.ux
Also adding Roboto default font:
Default Material typeface should be Roboto per the guidelines, changed Material.Text class to comply with https://material.io/guidelines/style/typography.html