Skip to content

Commit

Permalink
Merge branch 'shadowStyle'
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed Nov 10, 2021
2 parents f1673d8 + 3740325 commit 5c7d60d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
8 changes: 8 additions & 0 deletions demo/src/main/res/drawable/my_above_shadow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FFDFC2"
android:endColor="@android:color/transparent"
android:angle="90" >
</gradient>
</shape>
3 changes: 2 additions & 1 deletion demo/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
sothree:umanoPanelHeight="68dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoScrollableView="@+id/listView"
sothree:umanoShadowHeight="4dp">
sothree:umanoShadowHeight="50dp"
sothree:umanoAboveShadowStyle="@drawable/my_above_shadow">

<!-- MAIN CONTENT -->
<FrameLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ public enum PanelState {
*/
private boolean mIsTouchEnabled;

/**
* Shadow style which will replace default if provided
*/
private int mAboveShadowResId;
private int mBelowShadowResId;

private float mPrevMotionX;
private float mPrevMotionY;
private float mInitialMotionX;
Expand Down Expand Up @@ -326,6 +332,9 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoDragView, -1);
mScrollableViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoScrollableView, -1);

mAboveShadowResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoAboveShadowStyle, -1);
mBelowShadowResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoBelowShadowStyle, -1);

mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoOverlay, DEFAULT_OVERLAY_FLAG);
mClipPanel = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoClipPanel, DEFAULT_CLIP_PANEL_FLAG);

Expand Down Expand Up @@ -357,9 +366,17 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
// If the shadow height is zero, don't show the shadow
if (mShadowHeight > 0) {
if (mIsSlidingUp) {
mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.above_shadow);
if (mAboveShadowResId == -1) {
mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.above_shadow);
} else {
mShadowDrawable = ContextCompat.getDrawable(context, mAboveShadowResId);
}
} else {
mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.below_shadow);
if (mBelowShadowResId == -1) {
mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.below_shadow);
} else {
mShadowDrawable = ContextCompat.getDrawable(context, mBelowShadowResId);
}
}
} else {
mShadowDrawable = null;
Expand Down
2 changes: 2 additions & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</attr>
<attr name="umanoScrollInterpolator" format="reference" />
<attr name="umanoMaxSlidingOffset" format="float" />
<attr name="umanoAboveShadowStyle" format="reference" />
<attr name="umanoBelowShadowStyle" format="reference" />
</declare-styleable>

</resources>

0 comments on commit 5c7d60d

Please sign in to comment.