-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix device frame deps * adjust package names * add more example for easier getting started example * update readme * fix demo app path in workflow * fix some deps tree
- Loading branch information
Showing
105 changed files
with
1,034 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# Compose UI Book | ||
|
||
Simple and extensible UI component explorer for Jetpack Compose and Android View | ||
|
||
<p float="middle"> | ||
<img src=".github/art/ss1.png"/> | ||
<img src=".github/art/ss2.png"/> | ||
</p> | ||
|
||
<details> | ||
<summary>You can check the demo video here</summary> | ||
<a href="https://www.youtube.com/watch?v=aB2cBjLuYHA"> | ||
<img src="https://img.youtube.com/vi/aB2cBjLuYHA/0.jpg" /> | ||
</a> | ||
</details> | ||
|
||
## Getting Started | ||
|
||
Usually the UI component explorer is separated from the main app despite you have Android only or KMP project. | ||
So the first thing you should do is to create a module with this `build.gradle.kts` (or `build.gradle` if you're using | ||
Groovy) | ||
|
||
### Setup Module - KMP | ||
|
||
```kotlin | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.multiplatform") | ||
id("org.jetbrains.compose") | ||
id("com.google.devtools.ksp") | ||
} | ||
|
||
// This could be in settings.gradle or root build.gradle | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
jvm("desktop") | ||
android() | ||
|
||
sourceSets { | ||
named("commonMain") { | ||
dependencies { | ||
implementation("io.github.esafirm.uibook:browser-app:x.y.z") | ||
} | ||
} | ||
named("androidMain") { | ||
dependencies { | ||
// This is optional. If you use app compat then include this | ||
implementation("androidx.appcompat:appcompat:1.3.1") | ||
implementation("com.google.android.material:material:1.4.0") | ||
} | ||
} | ||
named("desktopMain") { | ||
dependencies { | ||
// This is mandatory as we current OS is not packaged in POM file | ||
implementation(compose.desktop.currentOs) | ||
} | ||
} | ||
} | ||
} | ||
|
||
android { | ||
// Insert Android related configuration in here | ||
} | ||
|
||
compose.desktop { | ||
// Insert compose desktop related configuration in here | ||
} | ||
|
||
dependencies { | ||
val processorDep = "io.github.esafirm.uibook:annotations-processor:x.y.z" | ||
add("kspAndroid", processorDep) | ||
add("kspDesktop", processorDep) | ||
} | ||
``` | ||
|
||
> :heavy_exclamation_mark: **Info**: Please check the [minimum KMP example](/examples/minimum-kmp) for more complete | ||
> setup. | ||
### Setup Module - Android Only | ||
|
||
```kotlin | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.compose") | ||
id("com.google.devtools.ksp") | ||
kotlin("android") | ||
} | ||
|
||
android { | ||
// Insert Android related configuration in here | ||
} | ||
|
||
dependencies { | ||
implementation("io.github.esafirm.uibook:browser-app:x.y.z") | ||
implementation("androidx.appcompat:appcompat:1.3.1") | ||
implementation("com.google.android.material:material:1.4.0") | ||
|
||
ksp("io.github.esafirm.uibook:annotations-processor:x:y:z") | ||
} | ||
|
||
``` | ||
|
||
> :heavy_exclamation_mark: **Info**: Please check the [minimum android example](/examples/minimum-android) for more | ||
> complete setup. | ||
change `x.y.z` to version in the [release page](https://github.com/esafirm/android-ui-book/releases) | ||
|
||
### Create First Book | ||
|
||
To create book simple create an extension function that extend `BookHost` and give the function `@UIBook` | ||
annotation. | ||
In this case I will create a Kotlin file with name `Catalogue.kt` and then create this function: | ||
|
||
```kotlin | ||
@UIBook(name = "Compose Button") | ||
@Composable | ||
fun BookHost.SimpleCouter() { | ||
val (count, setCount) = remember { mutableStateOf(0) } | ||
Button(onClick = { setCount(count + 1) }) { | ||
Text(text = "Counter $count") | ||
} | ||
} | ||
``` | ||
|
||
That's it now run the new module that you just created. | ||
|
||
### Android View Support | ||
|
||
For Android target, it supports the Android `View`, just add the return type to the function | ||
|
||
```kotlin | ||
@UIBook(name = "Android TextView") | ||
fun BookHost.SimpleTextView(): TextView { | ||
/** | ||
* This will draw text | ||
*/ | ||
return TextView(context).apply { | ||
text = "Hello World" | ||
} | ||
} | ||
``` | ||
|
||
## Advanced | ||
|
||
For now, you can check the [sample module](/sample) for complete features. | ||
|
||
## Development | ||
|
||
To develop the project, you need to use Android Studio Dolphin above. | ||
|
||
It have some strange issue with IntelliJ Idea 2022.3 EAP. | ||
|
||
### Running Sample | ||
|
||
To run the Android sample run this command: | ||
|
||
```bash | ||
./gradlew :sample:installDebug | ||
``` | ||
|
||
To run the Desktop sample run this command: | ||
|
||
```bash | ||
./gradlew :sample:run | ||
``` | ||
|
||
## Support | ||
|
||
<a href='https://ko-fi.com/M4M41RRE0' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi4.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a> | ||
|
||
## License | ||
|
||
Esa @ MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ambda/uibook/browser/AndroidBookConfig.kt → ...a/uibook/browser/app/AndroidBookConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...lin/nolambda/uibook/browser/BrowserApp.kt → ...nolambda/uibook/browser/app/BrowserApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nolambda/uibook/browser/UIBookActivity.kt → ...mbda/uibook/browser/app/UIBookActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mbda/uibook/browser/UIBookListActivity.kt → .../uibook/browser/app/UIBookListActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ser/measurement/MeasurementOverlayView.kt → ...app/measurement/MeasurementOverlayView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/resourceloader/AndroidResourceLoader.kt → ...p/resourceloader/AndroidResourceLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../browser/desktop/DesktopResourceLoader.kt → ...book/browser/app/DesktopResourceLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/nolambda/uibook/browser/desktop/Main.kt → ...otlin/nolambda/uibook/browser/app/Main.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ plugins { | |
} | ||
|
||
android { | ||
namespace = "nolambda.uibook.browser" | ||
namespace = "nolambda.uibook" | ||
} | ||
|
||
kotlin { | ||
|
Oops, something went wrong.