Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

aafanasev/kakao-maker

Repository files navigation

Kakao Maker

Auto-generating Kakao screens.

Install

// build.gradle

plugins {
    id "com.aafanasev.kakao-maker" version "<version>"
}

Usage

1. Configure

// build.gradle

kakaoMaker {
    
    // Logger
    debug false
    
    // Output directory
    outputDir file("./src/androidTest/java/com/sample/app/screens")
    
    // Android application id
    applicationId "com.sample.app" 
    
    // Package name of generated screens
    packageName "com.sample.app.screens"
}

2. Use

<!-- activity_main.xml -->

<LinearLayout
    android:id="@+id/root"
    tools:kakaoScreen="MainScreen"
    ...>
    
    <TextView
        android:id="@+id/title"
        ...    
        />
        
    <com.sample.app.CustomSubtitle
            android:id="@+id/sub_title"
            tools:kakaoType="KTextView"
            ...
            />
    
    <include layout="@layout/merge"/>
        
    <include layout="@layout/include"/>
    
    <include layout="@layout/include_screen"/>
    
    <View
        android:id="@+id/dummy"
        tools:kakaoIgnore="true"
        />
        
    <Button
        android:id="@+id/submit"
        ...
        />
    
</LinearLayout>
<!-- merge.xml -->

<merge>
    
    <Button
        android:id="@+id/shared_btn_1"
        ...
        />
        
</merge>
<!-- include.xml -->

<FrameLayout
    ...>
    
    <Button
        android:id="@+id/shared_btn_2"
        ...
        />
        
</FrameLayout>
<!-- include_screen.xml -->

<FrameLayout
    tools:kakaoScreen="SharedScreen"
    ...>
    
    <Button
        android:id="@+id/shared_btn_3"
        ...
        />
        
</FrameLayout>

3. Generate

./gradlew generateKakaoScreens

4. Result

// MainScreen.kt

package com.sample.app.screens

import com.sample.app.R

class MainScreen : Screen<MainScreen>() {
    val root = KView { withId(R.id.root) } 
    val title = KTextView { withId(R.id.title) }
    val subTitle = KTextView { withId(R.id.sub_title) }
    val sharedBtn1 = KButton { withId(R.id.shared_btn_1) }
    val sharedBtn2 = KButton { withId(R.id.shared_btn_2) }
    val sharedScreen = SharedScreen()
    val subTitle = KTextView { withId(R.id.sub_title) }
    val submit = KButton { withId(R.id.submit) }
}
// SharedScreen.kt

package com.sample.app.screens

import com.sample.app.R
class SharedScreen : Screen<SharedScreen>() {
    val sharedBtn3 = KButton { withId(R.id.shared_btn_3) }
}