Skip to content

Improve Android button appearances (closes #849, #896)#907

Closed
kherock wants to merge 2 commits into
GeekyAnts:masterfrom
kherock:patch-1
Closed

Improve Android button appearances (closes #849, #896)#907
kherock wants to merge 2 commits into
GeekyAnts:masterfrom
kherock:patch-1

Conversation

@kherock

@kherock kherock commented May 31, 2017

Copy link
Copy Markdown
Contributor

This implements proper behavior for Material Design flat buttons and icon toggles - these buttons ripple as soon as the touch starts. Conveniently, React Native supports masking these ripples to the parent View's border radius. This also fixes a breakage introduced in #808 that closes #896.

This does not completely fix the ripples for regular buttons with rounded corners. However, once React Native actually supports masking bounded ripples (likely if something like react/react-native#6515 is reimplemented) they should be fixed here as well.

This also fixes a bug where if you click on a child of the button, the ripple origin is misplaced (see the gif of the before screen with the block button).

I have a demo repo if you want to see what I've tested so far.

Before:

Proposed:

I've also brought most the button stylings up to MD specs. The way ripple color is determined is as follows:

  • Use variables.androidRippleColorDark by default.
  • Use the background or androidRippleColor attributes above everything.
  • If the transparent prop is true, use the backgroundColor with alpha 0.26 from the styles prop
  • If the button is not transparent, use the light ripple color (variables.androidRippleColor) if the contrast ratio between backgroundColor and rgb(0, 0, 0) is less than 3:1.

I still need to test that this doesn't dramatically impact layouts and styles on iOS. I'll update with that here soon.

@kherock kherock changed the title Improve Android button appearances (closes #848, #896) Improve Android button appearances (closes #849, #896) May 31, 2017
This implements proper behavior for Material Design flat buttons and icon toggles - these buttons ripple as soon as the touch starts. Conveniently, React Native supports masking these ripples to the parent View's border radius. This also fixes a breakage introduced in GeekyAnts#808 that closes GeekyAnts#896.
@kherock

kherock commented May 31, 2017

Copy link
Copy Markdown
Contributor Author

Ok, I just made a few adjustments and now iOS looks pretty good. I managed to keep it mostly the same.

iOS before:
screen shot 2017-05-31 at 1 58 21 pm

after:
screen shot 2017-05-31 at 5 43 16 pm

@shivrajkumar shivrajkumar self-assigned this Jun 2, 2017
@shivrajkumar shivrajkumar added the 4 label Jun 2, 2017
@shivrajkumar

shivrajkumar commented Jun 5, 2017

Copy link
Copy Markdown
Collaborator

@rockmacaca Looks great, but this breaks some of the others components. Like Bordered/Outline Button, left padding of Left Header Button seems more...

@shivrajkumar

Copy link
Copy Markdown
Collaborator

Do check you patch with demo app on NativeBase https://github.com/GeekyAnts/NativeBase-KitchenSink

@shivrajkumar shivrajkumar removed the 4 label Jun 5, 2017
@shivrajkumar shivrajkumar removed their assignment Jun 5, 2017
@shivrajkumar

Copy link
Copy Markdown
Collaborator

Closing this due to breaking changes.
You can resolve the above mentioned issues and submit a new PR

@ludalex

ludalex commented Jan 5, 2018

Copy link
Copy Markdown

This is great. I had to remove rippleEffect since with the current implementation the button press feedback feels sluggish. Is there a chance you can reopen the PR with the current master?

@SupriyaKalghatgi

Copy link
Copy Markdown
Contributor

@ludalex You can ask @specialkk to do so

@kherock

kherock commented Jan 8, 2018

Copy link
Copy Markdown
Contributor Author

@ludalex I haven't been very active with the project I was using this for recently, there are also just too many adjustments that have to be done that are potentially breaking changes so I probably won't be doing it any time soon.

Btw, the reason it might feel sluggish is because Android has two separate ripple types: solid buttons show a highlight and then ripple on release, whereas transparent buttons use "borderless" ripples that ripple on the initial touch. Both usually feel ok as long as the highlighted color is clearly visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button does not support conditional JSX in children list on Android.

4 participants