项目作者: Str3l0k

项目描述 :
Backdrop UI design implementation
高级语言: Kotlin
项目地址: git://github.com/Str3l0k/Backdrop_Android.git
创建时间: 2019-05-12T21:40:44Z
项目社区:https://github.com/Str3l0k/Backdrop_Android

开源协议:Apache License 2.0

下载


Backdrop for Android

This project is an approach to create a template for Backdrop UI design on Android.
Backdrop means that the toolbar moves into the background and the navigation drawer is no longer the main source for navigation.
Instead the card stack element holds the navigation steps and can reveal additional options or configurations in the backdrop element.

Download

Available through jitpack:
https://jitpack.io/#Str3l0k/Backdrop_Android

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add the dependency:

  1. dependencies {
  2. implementation 'com.github.Str3l0k:Backdrop_Android:Tag'
  3. }

Usage

The app module shows a basic how-to-use it for now as demonstration.
It is intended as One-Activity-Application with Fragments for all other means.
Basically use the Activity as base class.

To build an application based on backdrop, the first step is to implement an Activity which
inherits from the Activity provided in the library. It is itself an modified AppCompatActivity.
The second step is to create a base card fragment which will be used as main entry point.

So the basic configuration for an working app is one activity and one Fragment.

MainActivity

  1. class MainActivity : Activity() {
  2. override val baseCardFragment: MainCardBackdropFragment = BaseFragment()
  3. }

BaseFragment

  1. class BaseFragment : MainCardBackdropFragment() {
  2. override val menuButtonState: BackdropToolbarMainButtonState
  3. get() = BackdropToolbarMainButtonState.MENU
  4. override val toolbarItem: BackdropToolbarItem = BackdropToolbarItem(title = "Backdrop",
  5. subtitle = "Demonstration",
  6. primaryAction = R.drawable.ic_add,
  7. moreActionEnabled = true)
  8. override fun onCreateContentView(inflater: LayoutInflater,
  9. container: ViewGroup?,
  10. savedInstanceState: Bundle?): View? {
  11. return inflater.inflate(R.layout.base_card, container, false)
  12. }
  13. override fun onContentViewCreated(view: View?, savedInstanceState: Bundle?) {
  14. // configure content view here
  15. }
  16. }

The main fragment is returned as property in the Activity and currently the only thing that is required to be
implemented when using the Activity class. The fragment needs a ToolbarItem which configures the toolbar titles and
action items. Instead of using the onCreateView and onViewCreated from the Android Fragment class use the onCreateContentView and
onContentViewCreated from the backdrop Fragment to inflate and configure the desired layout.

Preview





TODO

See issues for now.

License

Apache 2.0