diff --git a/app/build.gradle b/app/build.gradle index f8fc3e4..bdc14f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,6 +24,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + packagingOptions { + exclude 'META-INF/library-core_release.kotlin_module' + } } dependencies { @@ -31,8 +35,8 @@ dependencies { implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation "androidx.legacy:legacy-support-v4:1.0.0" - implementation "com.mikepenz:materialdrawer:6.1.2" - implementation "com.mikepenz:crossfader:1.6.0" // do not update + //implementation "com.mikepenz:materialdrawer:7.0.0-rc05" + //implementation "com.mikepenz:crossfader:1.6.0" // do not update implementation "com.mikepenz:iconics-core:${iconics}" // do not update. >3.1.0 Breaks jelly bean implementation "com.mikepenz:iconics-views:${iconics}" // do not update implementation "com.mikepenz:community-material-typeface:3.5.95.1-kotlin@aar" diff --git a/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt index f26f458..2872733 100644 --- a/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt @@ -2,18 +2,24 @@ package pl.szczodrzynski.navigation import android.annotation.SuppressLint import android.content.Context -import android.graphics.Color -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log +import android.view.Gravity import android.view.View import android.widget.Toast -import android.view.Gravity +import androidx.appcompat.app.AppCompatActivity +import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import kotlinx.android.synthetic.main.sample_nav_view.* import pl.szczodrzynski.navlib.SystemBarsUtil import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_DO_NOT_CHANGE import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_HALF_TRANSPARENT import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_PRIMARY_DARK +import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet +import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.SORT_MODE_ASCENDING +import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.SORT_MODE_DESCENDING +import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.TOGGLE_GROUP_SORTING_ORDER +import pl.szczodrzynski.navlib.bottomsheet.items.PrimaryItem +import pl.szczodrzynski.navlib.bottomsheet.items.SeparatorItem import pl.szczodrzynski.navlib.getColorFromAttr @@ -195,7 +201,55 @@ class MainActivity : AppCompatActivity() { navView.bottomSheet.enableDragToOpen = isChecked } + navView.bottomBar.fabIcon = CommunityMaterial.Icon2.cmd_pencil navView.bottomBar.fabExtendedText = "Compose" navView.bottomBar.fabExtended = false + + + + + + navView.bottomSheet.apply { + this += PrimaryItem(true) + .withId(1) + .withTitle("Compose") + .withIcon(CommunityMaterial.Icon2.cmd_pencil) + .withOnClickListener(View.OnClickListener { + Toast.makeText(this@MainActivity, "Compose message", Toast.LENGTH_SHORT).show() + }) + this += SeparatorItem(false) + this += PrimaryItem(false) + .withId(3) + .withTitle("Synchronise") + .withIcon(CommunityMaterial.Icon2.cmd_sync) + .withOnClickListener(View.OnClickListener { + Toast.makeText(this@MainActivity, "Synchronising...", Toast.LENGTH_SHORT).show() + }) + this += PrimaryItem(false) + .withId(4) + .withTitle("Help") + .withIcon(CommunityMaterial.Icon2.cmd_help) + .withOnClickListener(View.OnClickListener { + Toast.makeText(this@MainActivity, "Want some help?", Toast.LENGTH_SHORT).show() + }) + + toggleGroupTitle = "Sort by" + toggleGroupRemoveItems() + toggleGroupSelectionMode = TOGGLE_GROUP_SORTING_ORDER + toggleGroupAddItem(0, "By date", null, SORT_MODE_DESCENDING) + toggleGroupAddItem(1, "By subject", null, SORT_MODE_ASCENDING) + toggleGroupAddItem(2, "By sender", null, SORT_MODE_ASCENDING) + toggleGroupAddItem(3, "By android", null, SORT_MODE_ASCENDING) + toggleGroupSortingOrderListener = object : NavBottomSheet.OnToggleGroupSortingListener { + override fun onSortingOrder(id: Int, sortMode: Int) { + Toast.makeText( + this@MainActivity, + "Sort mode $id ${if (sortMode == SORT_MODE_ASCENDING) "ascending" else "descending"}", + Toast.LENGTH_SHORT + ).show() + } + } + toggleGroupCheck(1) + } } } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a7f45ef..3b2fcf3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,72 +1,35 @@ - - - - diff --git a/navlib/build.gradle b/navlib/build.gradle index f371c1d..1bd10df 100644 --- a/navlib/build.gradle +++ b/navlib/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation 'com.google.android.material:material:1.1.0-alpha09' implementation "androidx.legacy:legacy-support-v4:1.0.0" - implementation "com.mikepenz:materialdrawer:6.1.2" + implementation "com.mikepenz:materialdrawer:7.0.0-rc05" implementation "com.mikepenz:iconics-core:4.0.1-b01" implementation 'com.mikepenz:community-material-typeface:3.5.95.1-kotlin@aar' @@ -50,4 +50,5 @@ dependencies { implementation "androidx.annotation:annotation:1.1.0" implementation "com.google.android.material:material:${googleMaterial}" implementation "androidx.constraintlayout:constraintlayout:${androidXConstraintLayout}" + implementation 'androidx.gridlayout:gridlayout:1.0.0' } diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/NavBottomBar.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/NavBottomBar.kt index fc5e191..817ad26 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/NavBottomBar.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/NavBottomBar.kt @@ -11,6 +11,7 @@ import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton import com.mikepenz.iconics.IconicsDrawable +import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import com.mikepenz.iconics.utils.colorInt import com.mikepenz.iconics.utils.sizeDp @@ -84,6 +85,15 @@ class NavBottomBar : BottomAppBar { else fabExtendedView?.shrink() } + /** + * Set the FAB's icon. + */ + var fabIcon: IIcon = CommunityMaterial.Icon.cmd_android + set(value) { + field = value + fabView?.setImageDrawable(IconicsDrawable(context, value).colorInt(R.attr.colorFabIcon).sizeDp(24)) + fabExtendedView?.icon = IconicsDrawable(context, value).colorInt(R.attr.colorFabIcon).sizeDp(24) + } /** * Set the ExtendedFAB's text. */ @@ -101,6 +111,8 @@ class NavBottomBar : BottomAppBar { true } + elevation = 0f + navigationIcon = IconicsDrawable(context) .icon(CommunityMaterial.Icon2.cmd_menu) .sizeDp(20) diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt index a87044a..051e22a 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt @@ -3,15 +3,18 @@ package pl.szczodrzynski.navlib import android.annotation.SuppressLint import android.app.Activity import android.content.Context -import android.os.Build import android.util.AttributeSet -import android.view.* +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT -import android.widget.* +import android.widget.FrameLayout +import android.widget.LinearLayout +import android.widget.SeekBar import androidx.coordinatorlayout.widget.CoordinatorLayout -import androidx.core.view.ViewCompat import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton +import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import com.mikepenz.materialdrawer.Drawer import com.mikepenz.materialdrawer.DrawerBuilder import com.mikepenz.materialdrawer.model.DividerDrawerItem @@ -146,8 +149,8 @@ class NavView : FrameLayout { fun addDrawer(activity: Activity) { //if you want to update the items at a later time it is recommended to keep it in a variable - val item1 = PrimaryDrawerItem().withIdentifier(1).withName("Home") - val item2 = SecondaryDrawerItem().withIdentifier(2).withName("Settings") + val item1 = PrimaryDrawerItem().withIdentifier(1).withName("Home").withIcon(CommunityMaterial.Icon.cmd_google_home) + val item2 = SecondaryDrawerItem().withIdentifier(2).withName("Settings").withIcon(CommunityMaterial.Icon2.cmd_settings) drawer = DrawerBuilder(activity) .withDrawerLayout(R.layout.material_drawer_fits_not) @@ -156,7 +159,7 @@ class NavView : FrameLayout { .withTranslucentStatusBar(false) .withTranslucentNavigationBar(false) .withTranslucentNavigationBarProgrammatically(false) - .withToolbar(topBar) + .withToolbar(bottomBar) .withDisplayBelowStatusBar(true) .withActionBarDrawerToggleAnimated(true) .addDrawerItems( @@ -165,9 +168,9 @@ class NavView : FrameLayout { item2, SecondaryDrawerItem().withName("Settings") ) - .withOnDrawerItemClickListener { view, position, drawerItem -> + /*.withOnDrawerItemClickListener { view, position, drawerItem -> true - } + }*/ .build() bottomBar.drawer = drawer diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/NavBottomSheet.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/NavBottomSheet.kt index fc7b2e1..b06a6f6 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/NavBottomSheet.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/NavBottomSheet.kt @@ -4,30 +4,46 @@ import android.app.Activity import android.content.Context import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter +import android.graphics.drawable.Drawable import android.util.AttributeSet import android.view.LayoutInflater import android.view.MotionEvent import android.view.View -import android.view.View.OnClickListener +import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.view.inputmethod.InputMethodManager import android.widget.LinearLayout -import android.widget.Toast +import android.widget.TextView +import androidx.annotation.DrawableRes import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.widget.NestedScrollView import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.button.MaterialButton +import com.google.android.material.button.MaterialButtonToggleGroup +import com.mikepenz.iconics.IconicsDrawable +import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import kotlinx.android.synthetic.main.nav_bottom_sheet.view.* +import com.mikepenz.iconics.utils.paddingDp +import com.mikepenz.iconics.utils.sizeDp import pl.szczodrzynski.navlib.Anim -import pl.szczodrzynski.navlib.bottomsheet.items.EditTextFilledItem +import pl.szczodrzynski.navlib.R import pl.szczodrzynski.navlib.bottomsheet.items.IBottomSheetItem -import pl.szczodrzynski.navlib.bottomsheet.items.PrimaryItem import pl.szczodrzynski.navlib.bottomsheet.items.SeparatorItem -import pl.szczodrzynski.navlib.bottomsheet.listeners.OnItemInputListener -import pl.szczodrzynski.navlib.getColorFromAttr +import pl.szczodrzynski.navlib.elevateSurface +import pl.szczodrzynski.navlib.getDrawableFromRes class NavBottomSheet : CoordinatorLayout { + companion object { + const val TOGGLE_GROUP_SINGLE_SELECTION = 0 + const val TOGGLE_GROUP_MULTIPLE_SELECTION = 1 + const val TOGGLE_GROUP_SORTING_ORDER = 2 + + const val SORT_MODE_ASCENDING = 0 + const val SORT_MODE_DESCENDING = 1 + } + constructor(context: Context) : super(context) { create(null, 0) } @@ -42,12 +58,19 @@ class NavBottomSheet : CoordinatorLayout { private lateinit var scrimView: View private lateinit var bottomSheet: NestedScrollView - private lateinit var bottomSheetContent: LinearLayout - private lateinit var bottomSheetDragBar: View + private lateinit var content: LinearLayout + private lateinit var dragBar: View + private lateinit var toggleGroupContainer: LinearLayout + private lateinit var toggleGroup: MaterialButtonToggleGroup + private lateinit var toggleGroupTitleView: TextView + private lateinit var list: RecyclerView private lateinit var bottomSheetBehavior: BottomSheetBehavior private var bottomSheetVisible = false + val items = ArrayList>() + private val adapter = BottomSheetAdapter(items) + /** * Enable the bottom sheet. * This value is mostly relevant to the [pl.szczodrzynski.navlib.NavBottomBar]. @@ -87,12 +110,16 @@ class NavBottomSheet : CoordinatorLayout { private fun create(attrs: AttributeSet?, defStyle: Int) { val layoutInflater = LayoutInflater.from(context) - layoutInflater.inflate(pl.szczodrzynski.navlib.R.layout.nav_bottom_sheet, this) + layoutInflater.inflate(R.layout.nav_bottom_sheet, this) - scrimView = findViewById(pl.szczodrzynski.navlib.R.id.nv_scrim) - bottomSheet = findViewById(pl.szczodrzynski.navlib.R.id.nv_bottomSheetView) - bottomSheetContent = findViewById(pl.szczodrzynski.navlib.R.id.nv_bottomSheetContent) - bottomSheetDragBar = findViewById(pl.szczodrzynski.navlib.R.id.nv_bottomSheetDragBar) + scrimView = findViewById(R.id.bs_scrim) + bottomSheet = findViewById(R.id.bs_view) + content = findViewById(R.id.bs_content) + dragBar = findViewById(R.id.bs_dragBar) + toggleGroupContainer = findViewById(R.id.bs_toggleGroupContainer) + toggleGroup = findViewById(R.id.bs_toggleGroup) + toggleGroupTitleView = findViewById(R.id.bs_toggleGroupTitle) + list = findViewById(R.id.bs_list) bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet) @@ -116,7 +143,7 @@ class NavBottomSheet : CoordinatorLayout { if (scrimViewEnabled) Anim.fadeOut(scrimView, 300, null) // steal the focus from any EditTexts - bottomSheetDragBar.requestFocus() + dragBar.requestFocus() hideKeyboard() } else if (!bottomSheetVisible) { @@ -127,59 +154,170 @@ class NavBottomSheet : CoordinatorLayout { } }) - bottomSheetContent.background.colorFilter = PorterDuffColorFilter( - getColorFromAttr( - context, - pl.szczodrzynski.navlib.R.attr.colorBackgroundFloating - ), PorterDuff.Mode.SRC_ATOP) + content.background.colorFilter = PorterDuffColorFilter( + elevateSurface(context, dp = 8), + PorterDuff.Mode.SRC_ATOP + ) // steal the focus from any EditTexts - bottomSheetDragBar.requestFocus() + dragBar.requestFocus() - val items = ArrayList>() - - items += EditTextFilledItem(true).apply { - id = 0 - hint = "Search" - helperText = "0 results found" - onItemInputListener = object : OnItemInputListener { - override fun onItemInput(itemId: Int, item: EditTextFilledItem, text: CharSequence) { - item.helperText = "${text.length} results found" - bs_list.adapter?.notifyItemChanged(itemId) - } - } - } - - items += PrimaryItem(true) - .withId(1) - .withTitle("Compose") - .withIcon(CommunityMaterial.Icon2.cmd_pencil) - .withOnClickListener(OnClickListener { - Toast.makeText(context, "Compose message", Toast.LENGTH_SHORT).show() - }) - // TODO add separator item - items += SeparatorItem(true) - items += PrimaryItem(true) - .withId(3) - .withTitle("Synchronise") - .withIcon(CommunityMaterial.Icon2.cmd_sync) - .withOnClickListener(OnClickListener { - Toast.makeText(context, "Synchronising...", Toast.LENGTH_SHORT).show() - }) - items += PrimaryItem(true) - .withId(4) - .withTitle("Help") - .withIcon(CommunityMaterial.Icon2.cmd_help) - .withOnClickListener(OnClickListener { - Toast.makeText(context, "Want some help?", Toast.LENGTH_SHORT).show() - }) - bs_list.apply { + list.apply { setHasFixedSize(true) layoutManager = LinearLayoutManager(context) - adapter = BottomSheetAdapter(items) + adapter = this@NavBottomSheet.adapter + } + + toggleGroup.addOnButtonCheckedListener(toggleGroupCheckedListener) + } + + /* _____ _ _ _ + |_ _| | ___ | | | | + | | | |_ ___ _ __ ___ ___ ( _ ) __| | __ _| |_ __ _ + | | | __/ _ \ '_ ` _ \/ __| / _ \/\ / _` |/ _` | __/ _` | + _| |_| || __/ | | | | \__ \ | (_> < | (_| | (_| | || (_| | + |_____|\__\___|_| |_| |_|___/ \___/\/ \__,_|\__,_|\__\__,*/ + + operator fun plusAssign(item: IBottomSheetItem<*>) { + appendItem(item) + } + fun appendItem(item: IBottomSheetItem<*>) { + items += item + adapter.notifyItemInserted(items.size - 1) + } + fun prependItem(item: IBottomSheetItem<*>) { + items.add(0, item) + adapter.notifyItemInserted(0) + } + fun addItemAt(index: Int, item: IBottomSheetItem<*>) { + items.add(index, item) + adapter.notifyItemInserted(index) + } + fun removeItemAt(index: Int) { + items.removeAt(index) + adapter.notifyItemRemoved(index) + } + fun removeAllItems() { + items.clear() + adapter.notifyDataSetChanged() + } + fun removeAllStatic() { + items.filter { it.isContextual } + adapter.notifyDataSetChanged() + } + fun removeAllContextual() { + items.filter { !it.isContextual } + adapter.notifyDataSetChanged() + } + fun removeSeparators() { + items.filterNot { it is SeparatorItem } + adapter.notifyDataSetChanged() + } + + var toggleGroupTitle + get() = toggleGroupTitleView.text.toString() + set(value) { toggleGroupTitleView.text = value } + var toggleGroupSelectionMode: Int = TOGGLE_GROUP_SORTING_ORDER + set(value) { + field = value + toggleGroup.isSingleSelection = value != TOGGLE_GROUP_MULTIPLE_SELECTION + } + + private fun toggleGroupGetIconicsDrawable(context: Context, icon: IIcon?): Drawable? { + if (icon == null) + return null + return IconicsDrawable(context, icon).sizeDp(24).paddingDp(4) + } + + fun toggleGroupAddItem(id: Int, text: String, @DrawableRes icon: Int, defaultSortOrder: Int = SORT_MODE_ASCENDING) { + toggleGroupAddItem(id, text, context.getDrawableFromRes(icon), defaultSortOrder) + } + fun toggleGroupAddItem(id: Int, text: String, icon: IIcon, defaultSortOrder: Int = SORT_MODE_ASCENDING) { + toggleGroupAddItem(id, text, toggleGroupGetIconicsDrawable(context, icon), defaultSortOrder) + } + fun toggleGroupAddItem(id: Int, text: String, icon: Drawable?, defaultSortOrder: Int = SORT_MODE_ASCENDING) { + if (id < 0) + throw IllegalArgumentException("ID cannot be less than 0") + toggleGroup.addView(MaterialButton(context, null, R.attr.materialButtonOutlinedStyle).apply { + this.id = id + 1 + this.tag = defaultSortOrder + this.text = text + this.icon = icon + }, WRAP_CONTENT, WRAP_CONTENT) + } + fun toggleGroupCheck(id: Int) { + toggleGroup.check(id) + } + fun toggleGroupRemoveItems() { + toggleGroup.removeAllViews() + } + + private val toggleGroupCheckedListener = MaterialButtonToggleGroup.OnButtonCheckedListener { group, checkedId, isChecked -> + if (group.checkedButtonId == View.NO_ID) { + group.check(checkedId) + return@OnButtonCheckedListener + } + /* TAG bit order + * bit 0 = default sorting mode + * bit 1 = is checked + * bit 2 = current sorting mode + */ + if (toggleGroupSelectionMode == TOGGLE_GROUP_SORTING_ORDER) { + val button = group.findViewById(checkedId) + var tag = button.tag as Int + var sortingMode: Int? = null + if (isChecked) { + sortingMode = if (tag and 0b010 == 1 shl 1) { + /* the view is checked and clicked once again */ + if (tag and 0b100 == SORT_MODE_ASCENDING shl 2) SORT_MODE_DESCENDING else SORT_MODE_ASCENDING + } else { + /* the view is first clicked so use the default sorting mode */ + if (tag and 0b001 == SORT_MODE_ASCENDING) SORT_MODE_ASCENDING else SORT_MODE_DESCENDING + } + tag = tag and 0b001 /* retain only default sorting mode */ + tag = tag or 0b010 /* set as checked */ + tag = tag or (sortingMode shl 2) /* set new sorting mode */ + } + else { + tag = tag and 0b001 /* retain only default sorting mode */ + } + button.tag = tag + button.icon = toggleGroupGetIconicsDrawable(context, when (sortingMode) { + SORT_MODE_ASCENDING -> CommunityMaterial.Icon2.cmd_sort_ascending + SORT_MODE_DESCENDING -> CommunityMaterial.Icon2.cmd_sort_descending + else -> null + }) + if (sortingMode != null) { + toggleGroupSortingOrderListener?.onSortingOrder(checkedId, sortingMode) + } + } + else if (toggleGroup.isSingleSelection && isChecked) { + toggleGroupSingleSelectionListener?.onSingleSelection(checkedId - 1) + } + else { + toggleGroupMultipleSelectionListener?.onMultipleSelection(checkedId - 1, isChecked) } } + interface OnToggleGroupChangeListener { + fun onSingleSelection(id: Int) + } + var toggleGroupSingleSelectionListener: OnToggleGroupChangeListener? = null + + interface OnToggleGroupCheckedListener { + fun onMultipleSelection(id: Int, checked: Boolean) + } + var toggleGroupMultipleSelectionListener: OnToggleGroupCheckedListener? = null + + interface OnToggleGroupSortingListener { + fun onSortingOrder(id: Int, sortMode: Int) + } + var toggleGroupSortingOrderListener: OnToggleGroupSortingListener? = null + + + + + fun dispatchBottomBarEvent(event: MotionEvent) { val location = IntArray(2) bottomSheet.getLocationOnScreen(location) @@ -188,9 +326,9 @@ class NavBottomSheet : CoordinatorLayout { } fun setContentPadding(left: Int, top: Int, right: Int, bottom: Int) { - bottomSheetContent.setPadding(left, top, right, bottom) + content.setPadding(left, top, right, bottom) } - fun getContentView() = bottomSheetContent + fun getContentView() = content var isOpen get() = bottomSheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/items/PrimaryItem.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/items/PrimaryItem.kt index 1a9818d..8bb314c 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/items/PrimaryItem.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/bottomsheet/items/PrimaryItem.kt @@ -12,6 +12,8 @@ import com.mikepenz.iconics.typeface.library.community.material.CommunityMateria import com.mikepenz.iconics.utils.sizeDp import com.mikepenz.materialize.holder.ImageHolder import pl.szczodrzynski.navlib.R +import pl.szczodrzynski.navlib.colorAttr +import pl.szczodrzynski.navlib.getColorFromAttr data class PrimaryItem(override val isContextual: Boolean = true) : IBottomSheetItem { @@ -37,9 +39,11 @@ data class PrimaryItem(override val isContextual: Boolean = true) : IBottomSheet override fun bindViewHolder(viewHolder: ViewHolder) { viewHolder.root.setOnClickListener(onClickListener) viewHolder.text.text = title + viewHolder.text.setTextColor(getColorFromAttr(viewHolder.text.context, R.attr.material_drawer_primary_text)) viewHolder.text.setCompoundDrawables( IconicsDrawable(viewHolder.text.context) .icon(iconicsIcon?:CommunityMaterial.Icon.cmd_android) + .colorAttr(viewHolder.text.context, R.attr.material_drawer_primary_icon) .sizeDp(20), null, null, diff --git a/navlib/src/main/res/layout/nav_bottom_sheet.xml b/navlib/src/main/res/layout/nav_bottom_sheet.xml index b7562cf..b2ce5da 100644 --- a/navlib/src/main/res/layout/nav_bottom_sheet.xml +++ b/navlib/src/main/res/layout/nav_bottom_sheet.xml @@ -10,7 +10,7 @@ tools:targetApi="lollipop"> - - + android:visibility="gone"> -