Skip to content

Commit

Permalink
Update changes
Browse files Browse the repository at this point in the history
  • Loading branch information
imkhalid committed Dec 12, 2019
1 parent 39770c5 commit f14ee9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.view.Gravity
import android.view.View
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.drawable.DrawableCompat
import kotlinx.android.synthetic.main.activity_main.*

Expand All @@ -27,16 +26,10 @@ class MainActivity : AppCompatActivity() {
// content.scaleX = 1 - slideOffset / scaleFactor
content.scaleY = 1 - slideOffset / scaleFactor
if (slideOffset > 0f) {
val unwrappedDrawable =
AppCompatResources.getDrawable(this@MainActivity, R.drawable.rounded)
val wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable!!)
DrawableCompat.setTint(
wrappedDrawable,
resources.getColor(R.color.colorAccent)
)
DrawableCompat.setTint(resources.getDrawable(R.drawable.rounded),Color.BLUE)
content.setBackgroundResource(R.drawable.rounded)
} else {
content.setBackgroundColor(resources.getColor(R.color.colorPrimary))
content.setBackgroundColor(resources.getColor(R.color.colorAccent))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void onDrawerSlide(View drawerView, float slideOffset) {

float slideX=drawerView.getWidth()*slideOffset;
v.setTranslationX(slideX);
// v.setScaleX(1- (slideOffset / scaleFactor));
v.setScaleX(1- (slideOffset / scaleFactor));
v.setScaleY(1- (slideOffset / scaleFactor));
}
};
Expand All @@ -40,7 +40,7 @@ public void onDrawerSlide(View drawerView, float slideOffset) {

float slideX=drawerView.getWidth()*slideOffset;
v.setTranslationX(slideX);
// v.setScaleX(1- (slideOffset / scaleFactor));
v.setScaleX(1- (slideOffset / scaleFactor));
v.setScaleY(1- (slideOffset / scaleFactor));
}
};
Expand Down Expand Up @@ -70,7 +70,7 @@ public void onDrawerSlide(View drawerView, float slideOffset) {

float slideX=drawerView.getWidth()*slideOffset;
container.setTranslationX(slideX);
// v.setScaleX(1- (slideOffset / scaleFactor));
container.setScaleX(1- (slideOffset / scaleFactor));
container.setScaleY(1- (slideOffset / scaleFactor));
if (slideOffset>0f) {
Drawable unwrappedDrawable = AppCompatResources.getDrawable(activity, R.drawable.rounded);
Expand All @@ -88,13 +88,12 @@ public void onDrawerSlide(View drawerView, float slideOffset) {
mDrawerLayout.addDrawerListener(mActionbarToggle);
}

public SlidingDrawerLayout(Activity mActivity, final DrawerLayout mDrawerLayout, final View container, View toggleBtn, float mScaleFactor, final int containerColor){
public SlidingDrawerLayout(Activity mActivity, final DrawerLayout mDrawerLayout,
final View container, View toggleBtn, float mScaleFactor, final int containerColor){

/*
this function has Drawable with rounded container, custom color and toggle btn
*/


if (mScaleFactor!=0f)
scaleFactor=mScaleFactor;

Expand All @@ -106,12 +105,10 @@ public void onDrawerSlide(View drawerView, float slideOffset) {

float slideX=drawerView.getWidth()*slideOffset;
container.setTranslationX(slideX);
// v.setScaleX(1- (slideOffset / scaleFactor));
container.setScaleX(1- (slideOffset / scaleFactor));
container.setScaleY(1- (slideOffset / scaleFactor));
if (slideOffset>0f) {
Drawable unwrappedDrawable = AppCompatResources.getDrawable(activity, R.drawable.rounded);
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, containerColor);
DrawableCompat.setTint(activity.getResources().getDrawable(R.drawable.rounded),containerColor);
container.setBackgroundResource(R.drawable.rounded);
}
else {
Expand Down

0 comments on commit f14ee9f

Please sign in to comment.