soarcn / BottomSheet

One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation.
http://soarcn.github.io/BottomSheet
2.22k stars 409 forks source link

Make BottomSheet.List layout animation configurable #16

Closed EmileEmile closed 9 years ago

EmileEmile commented 9 years ago

In the current version it is possible to change the animation for the dialog as whole, however, it not possible to change the layout animation for the BottomSheet.List. It would be nice if it was a styleable attr.

soarcn commented 9 years ago

Yes, I will support this soon.

soarcn commented 9 years ago

You can try to fully customize the List as you wish with master branch code. A sample has also been provided.

EmileEmile commented 9 years ago

Thanks, that's great.

EmileEmile commented 9 years ago

Using the code from the latest master the List layout animation can be customized which is great, however, because the all the List items inherent their style from list Bottom.List they continue to play the layout animation. It would be good if a change to the layoutAnimation in bs_listStyle affected it's children as well.

soarcn commented 9 years ago

@EmileEmile I don't quite understand the problem you mentioned, can you describe the difference between your expectation and current looking? or it would be great if you could change the code to make it align your needs and show me here.

EmileEmile commented 9 years ago

My proposal would be to have bs_layout_animation as a styleable attribute. This can be used to set the layoutAnimation for Bottom.List (which we can currently set through bs_listStyle) this would then set all the layoutAnimation for all styles that inherent from Bottom.List e.g. BottomSheet.List.Item (which we currently can't set).

See the example code below:

    <style name="BottomSheet.Dialog" parent="android:style/Theme.Dialog">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:backgroundDimAmount">0.3</item>
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:windowAnimationStyle">@style/BottomSheet.Animation</item>
        <item name="android:textColorPrimary">#DD000000</item>
        <item name="android:textColorSecondary">#8A000000</item>
        <item name="android:textColorHint">#42000000</item>
        <item name="bs_dialogBackground">@android:color/background_light</item>
        <item name="bs_dividerColor">@color/bs_divider_color</item>
        <item name="bs_numColumns">@integer/bs_grid_colum</item>
        <item name="bs_titleTextAppearance">@style/Text.Headline</item>
        <item name="bs_listItemTitleTextAppearance">@style/Text.Title</item>
        <item name="bs_gridItemTitleTextAppearance">@style/Text.Hint</item>
        <item name="bs_moreText">@string/bs_more</item>
        <item name="bs_closeDrawable">@drawable/bs_ic_clear</item>
        <item name="bs_moreDrawable">@drawable/bs_ic_more_light</item>
        <item name="bs_listStyle">@style/BottomSheet.List</item>
        <item name="bs_layout_animation">@style/BottomSheet.List</item>
    </style>

   .....

    <style name="BottomSheet.List">
        <item name="android:listSelector">@drawable/bs_list_selector</item>
        <item name="android:drawSelectorOnTop">false</item>
        <item name="android:layoutAnimation">?bs_layout_animation</item>
    </style>
soarcn commented 9 years ago

I'm a little bit confuse, you mean you want to set animation to each items? but that is the way layout animation works. the sample I provided will make each items slide in from left side. you don't have to set animation for each items.

Or if I misunderstood what you need, would you please show me the animation you want to implement?

EmileEmile commented 9 years ago

Actually, I want to be able to set all the layout animations to null.

soarcn commented 9 years ago

well, that would be quite simple

<style name="BottomSheet.List">
    <item name="android:listSelector">@drawable/bs_list_selector</item>
    <item name="android:layoutAnimation">@null</item>        <-----
</style>
EmileEmile commented 9 years ago

Yes, but you currently cannot do that without editing the source. It would be nice if you could do that while including library through Gradle.

soarcn commented 9 years ago

it will be included in the next release. should be tomorrow.

EmileEmile commented 9 years ago

Great news, thank you.

On Wed, Dec 10, 2014 at 11:48 PM, Liao Kai notifications@github.com wrote:

it will be included in the next release. should be tomorrow.

— Reply to this email directly or view it on GitHub https://github.com/soarcn/BottomSheet/issues/16#issuecomment-66446765.

EmileEmile commented 9 years ago

Hi, I was just wondering if the new release has been uploaded yet?

soarcn commented 9 years ago

Yes, the lastest release is 0.5 http://search.maven.org/#search%7Cga%7C1%7Cbottomsheet

EmileEmile commented 9 years ago

Sorry, I still can't work out how to set the layoutAnimation to null in the new release.

soarcn commented 9 years ago

https://github.com/soarcn/BottomSheet/blob/master/example/src/main/res/values/styles.xml#L26 this is an example how to customize layoutanimation, you just need to set it to @null

EmileEmile commented 9 years ago

But as we discussed before the layoutAnimation (@anim/bs_list_layout_anim_in) is still being used BottomSheet.List.Item etc. I thought you were including a way to customise it that would affect the child styles as well. If you like I can create a pull request to show you what I mean.

soarcn commented 9 years ago

Ok, code shows everything. :)

soarcn commented 9 years ago

@EmileEmile I just realized I made a mistake of naming the style, Bottomsheet.list,item will automaticlly inherit from bottomsheet,list ( which I didn't know before :P), so that is the key of this issue. I will change the name of those style and break the Inheritance. Things would works then.

soarcn commented 9 years ago

0.6 has been release and uploaded to maven, few hours would be needed to sync up

EmileEmile commented 9 years ago

@soarcn Yes, I think your solution is actually much simpler. I was trying to explain the style inheritance problem before but I think I did a bad job. I didn't think of just changing the style inheritance. Thanks for the quick response.