Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @DslMarker annotation class MenuConfigurationPart
- @Suppress("unused")
- fun menuConfig(builder: MenuConfiguration.() -> Unit) = MenuConfiguration(builder)
- @MenuConfigurationPart
- class MenuConfiguration(
- inline val builder: MenuConfiguration.() -> Unit
- )
- {
- lateinit var header: MenuHeader
- lateinit var content: MenuContent
- init
- {
- builder()
- }
- inline fun header(builder: MenuHeader.() -> Unit)
- {
- this.header = MenuHeader().apply(builder)
- }
- inline fun content(builder: MenuContent.() -> Unit)
- {
- this.content = MenuContent().apply(builder)
- }
- override fun equals(other: Any?): Boolean = TODO()
- override fun hashCode(): Int = TODO()
- }
- @MenuConfigurationPart
- class MenuHeader
- {
- lateinit var userEmail: () -> String
- val viewControllers: MutableList<AViewController> = mutableListOf()
- /**
- * [SEPARATOR_SETTING_INVISIBLE] - no separator
- * [SEPARATOR_SETTING_FULL_WIDTH] - full width separator
- * [SEPARATOR_SETTING_MARGINS] - separator with margins
- */
- @SeparatorWidthSetting
- var separatorWidthSetting: Int = SEPARATOR_SETTING_INVISIBLE
- var hasLogout = true
- operator fun AViewController.unaryPlus()
- {
- viewControllers.add(this)
- }
- companion object
- {
- @IntDef(SEPARATOR_SETTING_INVISIBLE, SEPARATOR_SETTING_FULL_WIDTH, SEPARATOR_SETTING_MARGINS)
- @Retention(AnnotationRetention.SOURCE)
- annotation class SeparatorWidthSetting
- const val SEPARATOR_SETTING_INVISIBLE = 0
- const val SEPARATOR_SETTING_FULL_WIDTH = 1
- const val SEPARATOR_SETTING_MARGINS = 2
- }
- }
- @MenuConfigurationPart
- class MenuContent
- {
- val items = mutableListOf<DiverseRecyclerAdapter.RecyclerItem<*, *>>()
- operator fun DiverseRecyclerAdapter.RecyclerItem<*, *>?.unaryPlus()
- {
- this ?: return
- items.add(this)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement