Skip to content

Commit

Permalink
bumped version up to 1.4.0. implemented menu class.
Browse files Browse the repository at this point in the history
  • Loading branch information
st235 committed Apr 3, 2021
1 parent 10eb471 commit 565233a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,22 @@ Firstly, you should declare your view in xml file
app:layout_constraintStart_toStartOf="parent" />
```

Then you should add menu items to your navigation component
Then you should add menu items to your navigation menu
To access menu call `bottomBar.menu` on your navigation view

```kotlin
val bottomBar: ExpandableBottomBar = findViewById(R.id.expandable_bottom_bar)

bottomBar.addItems(
MenuItemDescriptor.Builder(context = this)
.addItem(R.id.icon_home, R.drawable.ic_bug, R.string.text, Color.GRAY)
.addItem(R.id.icon_go, R.drawable.ic_gift, R.string.text2, 0xFFFF77A9)
.addItem(R.id.icon_left, R.drawable.ic_one, R.string.text3, 0xFF58A5F0)
.addItem(R.id.icon_right, R.drawable.ic_two, R.string.text4, 0xFFBE9C91)
.build()
val menu = bottomBar.menu

menu.add(
MenuItemDescriptor.Builder(
this,
R.id.icon_home,
R.drawable.ic_home,
R.string.text,
Color.GRAY
)
.build()
)

bottomBar.onItemSelectedListener = { view, menuItem ->
Expand Down Expand Up @@ -185,7 +189,8 @@ Then you should reference this xml file at the view attributes
/**
* Returns notification object
*/
val notification = bottomBar.getMenuItemFor(i.itemId).notification() // itemId is R.id.action_id
val menu = bottomBar.menu
val notification = menu.findItemById(i.itemId).notification() // itemId is R.id.action_id

notification.show() // shows simple dot-notification
notification.show("string literal") // shows notification with counter. Counter could not exceed the 4 symbols length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.graphics.ColorUtils
import github.com.st235.expandablebottombar.R
import github.com.st235.lib_expandablebottombar.ExpandableBottomBar
import github.com.st235.lib_expandablebottombar.Notification
import kotlinx.android.synthetic.main.activity_xml_declared.*

class NotificationBadgeActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package github.com.st235.expandablebottombar.screens

import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import android.view.ViewAnimationUtils
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android.useAndroidX=true

GROUP=com.github.st235

VERSION_CODE=42
VERSION_NAME=1.3.2
VERSION_CODE=45
VERSION_NAME=1.4.0

POM_DESCRIPTION=A new way to improve navigation in your app.
POM_URL=https://github.com/st235/ExpandableBottomBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,33 @@ interface Menu: Iterable<MenuItem> {
* Programmatically select item
*
* @param id - identifier of menu item, which should be selected
* @throws IllegalArgumentException when menu item cannot be found
*/
@Throws(IllegalArgumentException::class)
fun select(@IdRes id: Int)

fun deselect()

/**
* Removes the given menu item
*
* @param id - identifier of menu item, which should be selected
* @throws IllegalArgumentException when menu item cannot be found
*/
@Throws(IllegalArgumentException::class)
fun remove(@IdRes id: Int)

/**
* Removes all menu items
*/
fun removeAll()

/**
* Returns menu item for the given id value
*
* @throws NullPointerException when id doesn't exists
* @throws IllegalArgumentException when menu item cannot be found
*/
@Throws(IllegalArgumentException::class)
fun findItemById(@IdRes id: Int): MenuItem

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ internal class MenuImpl(
itemsLookup[item.id]?.setAccessibleWith(prev = prev, next = next)
}
}
}
}

0 comments on commit 565233a

Please sign in to comment.