Skip to content

Commit

Permalink
Update REDME. Update names of views.
Browse files Browse the repository at this point in the history
Signed-off-by: Constantine <[email protected]>
  • Loading branch information
Semper-Viventem committed Feb 10, 2019
1 parent 57fcac7 commit 3f70ac7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ This library makes it easy to implement a [Backdrop](https://material.io/design/

## Download
**JCenter (Recommended):**

*For support library:*
```groovy
dependencies {
implementation 'ru.semper-viventem.backdrop:backdrop:0.1.5'
}
```
*For Android X:*
```groovy
dependencies {
implementation 'ru.semper-viventem.backdrop:backdrop:0.1.5_x'
implementation 'ru.semper-viventem.backdrop:backdrop:0.1.6'
}
```

**JitPack:**
```groovy
repositories {
Expand All @@ -36,34 +29,41 @@ repositories {
}
dependencies {
implementation 'com.github.Semper-Viventem:BackdropView:0.1.5'
implementation 'com.github.Semper-Viventem:BackdropView:0.1.6'
}
```

## How to use it?
You need to add a layout Toolbar, back container and foreground container
You need to add front layout and back layout (with toolbar) to CoordinatorLayout.

Add BackdropBehavior to the Foreground View Container:
Add BackdropBehavior to your front layout:

**XML**
```xml
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<LinearLayout
android:id="@+id/backContainer"

<!-- BackLayout for BackDrop -->
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/backLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<!-- anything -->
</LinearLayout>

<!-- Must contain a Toolbar -->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<!-- For example, NavigationView. Or you can use anything -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/main_menu"/>
</com.google.android.material.appbar.AppBarLayout>

<!-- Add BackdropBehavior to this view -->
<android.support.design.card.MaterialCardView
Expand All @@ -72,7 +72,7 @@ Add BackdropBehavior to the Foreground View Container:
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- anything -->
<!-- Anything -->
</android.support.design.card.MaterialCardView>

</android.support.design.widget.CoordinatorLayout>
Expand All @@ -97,14 +97,16 @@ fun <T : CoordinatorLayout.Behavior<*>> View.findBehavior(): T = layoutParams.ru
val backdropBehavior: BackdropBehavior = foregroundContainer.findBehavior() // find behavior

with(backdropBehavior) {
attachBackContainer(R.id.backContainer) // set back container
attachToolbar(R.id.toolbar) // set toolbar

// Attach your back layout to behavior.
// BackDropBehavior will find the toolbar itself.
attachBackLayout(R.id.backLayout)

// set navigation icons for toolbar
// Set navigation icons for toolbar
setClosedIcon(R.drawable.ic_menu)
setOpenedIcon(R.drawable.ic_close)

// add listener
// Add listener
addOnDropListener(object : BackdropBehavior.OnDropListener {
override fun onDrop(dropState: BackdropBehavior.DropState, fromUser: Boolean) {
// TODO: handle listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MainActivity : AppCompatActivity() {
private const val MENU_TEXT = R.id.menuText
private const val MENU_LIST = R.id.menuList

private const val FRAGMENT_CONTAINER = R.id.foregroundContainer
private const val FRAGMENT_CONTAINER = R.id.frontLayout

private const val DEFAULT_ITEM = MENU_GALLERY
}
Expand All @@ -32,9 +32,9 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

backdropBehavior = foregroundContainer.findBehavior()
backdropBehavior = frontLayout.findBehavior()
with(backdropBehavior) {
attachBackLayout(R.id.backContainer)
attachBackLayout(R.id.backLayout)
}
with(toolbar) {
setTitle(R.string.app_name)
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
tools:context=".ui.MainActivity">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/backContainer"
android:id="@+id/backLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
Expand All @@ -34,7 +34,7 @@
</com.google.android.material.appbar.AppBarLayout>

<FrameLayout
android:id="@+id/foregroundContainer"
android:id="@+id/frontLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_top_radius"
Expand Down

0 comments on commit 3f70ac7

Please sign in to comment.