{"id":13428487,"url":"https://github.com/afollestad/material-cab","last_synced_at":"2025-03-16T01:32:38.912Z","repository":{"id":31491952,"uuid":"35056138","full_name":"afollestad/material-cab","owner":"afollestad","description":"🚕 An Android \u0026 Kotlin library for placing and manipulating Contextual Action Bars in your UI.","archived":true,"fork":false,"pushed_at":"2021-02-21T05:11:57.000Z","size":5063,"stargazers_count":979,"open_issues_count":5,"forks_count":103,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-24T17:47:51.298Z","etag":null,"topics":["android","cab","contextual-actionbar","kotlin","material-design","ui","ux"],"latest_commit_sha":null,"homepage":"https://af.codes","language":"Kotlin","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afollestad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"afollestad","ko_fi":"afollestad"}},"created_at":"2015-05-04T19:57:22.000Z","updated_at":"2024-10-25T16:14:36.000Z","dependencies_parsed_at":"2022-08-26T07:41:41.071Z","dependency_job_id":null,"html_url":"https://github.com/afollestad/material-cab","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fmaterial-cab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fmaterial-cab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fmaterial-cab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fmaterial-cab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afollestad","download_url":"https://codeload.github.com/afollestad/material-cab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814901,"owners_count":20352037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cab","contextual-actionbar","kotlin","material-design","ui","ux"],"created_at":"2024-07-31T01:00:58.420Z","updated_at":"2025-03-16T01:32:38.455Z","avatar_url":"https://github.com/afollestad.png","language":"Kotlin","funding_links":["https://github.com/sponsors/afollestad","https://ko-fi.com/afollestad"],"categories":["Java","Libraries","Toolbar"],"sub_categories":[],"readme":"# Material Contextual Action Bar\n\n[ ![Maven Central](https://img.shields.io/maven-central/v/com.afollestad/material-cab?style=flat\u0026label=Maven+Central) ](https://repo1.maven.org/maven2/com/afollestad/material-cab)\n[![Android CI](https://github.com/afollestad/material-cab/workflows/Android%20CI/badge.svg)](https://github.com/afollestad/material-cab/actions?query=workflow%3A%22Android+CI%22)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\n\u003cimg src=\"https://raw.githubusercontent.com/afollestad/material-cab/master/art/newshowcase.png\" width=\"250px\" /\u003e\n\nMaterial CAB allows you to implement a customizable and flexible contextual action bar in your app.\nThe traditional stock CAB on Android is limited to being placed at the top of your Activity,\nand the navigation drawer cannot go over it. This library lets you choose its exact location,\nand a toolbar is used, allowing views to be be placed over and under it.\n\n## Table of Contents\n\n1. [Gradle Dependency](#gradle-dependency)\n2. [Getting Started](#getting-started)\n3. [Destroying the CAB](#destroying-the-cab)\n\n---\n\n## Gradle Dependency\n\n[ ![Maven Central](https://img.shields.io/maven-central/v/com.afollestad/material-cab?style=flat\u0026label=Maven+Central) ](https://repo1.maven.org/maven2/com/afollestad/material-cab)\n\nAdd Material CAB to your module's `build.gradle` dependencies block:\n\n```Gradle\ndependencies {\n\n  implementation 'com.afollestad:material-cab:2.0.1'\n}\n```\n\n---\n\n## Getting Started\n\nThis library attaches to your `Activity` by taking the place of a `ViewStub` in your Activity layout.\nFor an example, this is similar to the main layout of the sample project:\n\n```xml\n\u003cLinearLayout\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"match_parent\"\n  android:orientation=\"vertical\"\u003e\n\n  \u003cFrameLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\u003e\n\n    \u003candroidx.appcompat.widget.Toolbar\n      android:id=\"@+id/main_toolbar\"\n      ... /\u003e\n\n    \u003cViewStub\n      android:id=\"@+id/cab_stub\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"?actionBarSize\" /\u003e\n\n  \u003c/FrameLayout\u003e\n\n  \u003candroidx.recyclerview.widget.RecyclerView\n    android:id=\"@+id/list\"\n    ... /\u003e\n\n\u003c/LinearLayout\u003e\n```\n\nYou create/attach a Material CAB in an Activity like this:\n\n```kotlin\nclass MyActivity : AppCompatActivity() {\n  private var cab: AttachedCab? = null\n  \n  override fun onCreate(savedInstanceState: Bundle?) {\n    super.onCreate(savedInstanceState)\n    \n    // createCab is an extension on Activity/Fragment\n    cab = createCab(R.id.cab_stub) {\n        title(R.string.some_title)\n        menu(R.menu.some_menu)\n        slideDown()\n    }\n  }\n}\n```\n\n`R.id.cab_stub` references the `ViewStub`, which is replaced with the CAB toolbar.\n\nIn addition, you can also pass the ID of a `ViewGroup` (such as a `FrameLayout`). The CAB will\nget appended as a child to that view group.\n\n---\n\n## Configuration\n\nYou can configure various properties about your CAB during attachment:\n\n```kotlin\nval attachedCab = createCab(R.id.cab_stub) {\n    title(R.string.some_title)\n    title(literal = \"Some Title\")\n    subtitle(R.string.some_subtitle)\n    subtitle(literal = \"Some Subtitle\")\n    \n    titleColor(R.color.white)\n    titleColor(literal = Color.WHITE)\n    subtitleColor(R.color.white)\n    subtitleColor(literal = Color.WHITE)\n    \n    popupTheme(R.style.ThemeOverlay_AppCompat_Light)\n    \n    contentInsetStart(R.dimen.mcab_default_content_inset)\n    contentInsetStart(literal = 52)\n    \n    backgroundColor(R.color.dark_gray)\n    backgroundColor(literal = Color.DARK_GRAY)\n    \n    closeDrawable(R.drawable.close_icon)\n    \n    menu(R.menu.cab_menu_items)\n\n    onCreate { cab, menu -\u003e\n      ...\n    }\n    onSelection { item -\u003e\n      ...\n      true // allow selection?\n    }\n    onDestroy { cab -\u003e\n      ...\n      true // allow destruction?\n    }\n    \n    animateOnCreate { view, animator -\u003e \n      // Animate the view with its animator.\n      // See the source of fadeIn(Long) or slideDown(Long) for an example.\n    }\n    \n    animateOnDestroy { view, animator -\u003e\n      // Animate the view with its animator.\n      // See the source of fadeIn(Long) or slideDown(Long) for an example.\n    }\n    \n    // Sets animateOnCreate and animateOnDestroy to fade the CAB. Duration is optional, 250 is default.\n    fadeIn(durationMs = 250)\n    \n    // Sets animateOnCreate and animateOnDestroy to slide the CAB up/down. Duration is optional, 250 is default.\n    slideDown(durationMs = 250)\n}\n```\n\n---\n\n## Destroying the CAB\n\nThe navigation icon in your CAB toolbar (far left button) will trigger this method, but you\ncan manually call it whenever you'd like as well:\n\n\n```kotlin\nval cab: AttachedCab? = // ...\n\nval isDestroyed = cab.isDestroyed() // true if null or destroyed\nval isActive = cab.isActive() // true if not destroyed\n\ncab.destroy()\n```\n\nThis will invoke the onDestroy callback. If the callback returns true, the CAB is destroyed.\nIf the CAB replaced a ViewStub, it's hidden (`GONE`), otherwise it's removed from the layout.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafollestad%2Fmaterial-cab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafollestad%2Fmaterial-cab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafollestad%2Fmaterial-cab/lists"}