Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chopyourbrain/kontrol
Kontrol - a Kotlin Multiplatform library for creating debug menu.
https://github.com/chopyourbrain/kontrol
Last synced: 5 days ago
JSON representation
Kontrol - a Kotlin Multiplatform library for creating debug menu.
- Host: GitHub
- URL: https://github.com/chopyourbrain/kontrol
- Owner: chopyourbrain
- License: mit
- Created: 2021-09-06T10:31:53.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-29T11:13:28.000Z (5 months ago)
- Last Synced: 2024-08-02T09:27:29.988Z (3 months ago)
- Language: Kotlin
- Homepage:
- Size: 1.01 MB
- Stars: 43
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kotlin-multiplatform - kontrol - A Kotlin Multiplatform library for creating a debugging menu (Libraries / GUI)
- kmp-awesome - Kontrol - Debug menu (Libraries / 🔧 Utils)
README
# Kontrol
![Maven Central](https://img.shields.io/maven-central/v/io.github.chopyourbrain/kontrol)
![badge][badge-android]
![badge][badge-ios]Kontrol - a Kotlin Multiplatform library for creating a debugging menu.
## Setup
### KMM:
Add a dependency to your build.gradle
```kotlin
val commonMain by getting {
dependencies {
implementation("io.github.chopyourbrain:kontrol:$kontrol_version")
}
}```
Android setup:
```kotlin
class App : Application() {override fun onCreate() {
super.onCreate()
kontrolAndroidInstall(applicationContext)
}
}
```iOS setup (inside iosMain):
```kotlin
fun initIOS(navigationController: UINavigationController) {
kontrolIOSInstall(navigationController)
}
```Ktor network inspection setup:
```kotlin
val httpClient = HttpClient(okhttp) {
install(KontrolKtorInterceptor) {
databaseDriverFactory = DatabaseDriverFactory(applicationContext)
}
}
```### Android:
Add dependency to your build.gradle
```kotlin
implementation("io.github.chopyourbrain:kontrol-android:$kontrol_version")
```Add setup to your application:
```kotlin
class App : Application() {override fun onCreate() {
super.onCreate()
kontrolAndroidInstall(applicationContext)
}
}
```Okhttp inspection setup:
```kotlin
val client = OkHttpClient.Builder()
.addInterceptor(KontrolOkhttpInterceptor(DatabaseDriverFactory(applicationContext)))
.build()
```## Using the Library
Inside common code
Create your properties by DSL:
```kotlin
val properties = properties {
group("Network") {
switcher("Enable log", true) {
//Check listener
}
dropDown("Server", listOf("google.com", "amazon.com", "reddit.com"), "google.com") {
//Change listener
}
text("Default error", "Main Exception")
button("Send request") {
//Click listener
}
}
group("App") {
switcher("darkTheme", "Enable dark theme")
dropDown("version", "Version", listOf("1.0", "2.0", "3.0"))
text("Version code", "1.0")
button("Kill application") {
//Click listener
}
}
button("Clear cache") {
//Click listener
}
}
```Implement key-value storage for saving switcher and dropDown state (if nessesary):
```kotlin
val kvStorage = object : KVStorage {
override fun getBoolean(key: String): Boolean? {
return settings.getBooleanOrNull(key)
}override fun getString(key: String): String? {
return settings.getStringOrNull(key)
}override fun setBoolean(key: String, value: Boolean) {
settings[key] = value
}override fun setString(key: String, value: String) {
settings[key] = value
}}
```### Important:
If you want to use KVStorage, create switchers and dropDowns by this:```kotlin
switcher("KEY", "Description")
dropDown("KEY", "Description", listOf("First value", "Second value", "Third value"))
```Then create DebugScreen object and use `show()` for open screen:
```kotlin
val debugScreen = createDebugScreen(properties, kvStorage)
debugScreen.show()
```## SAMPLE
[Click here](https://github.com/chopyourbrain/kontrol/tree/master/sample)## ENJOY!
[badge-android]: http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat
[badge-ios]: http://img.shields.io/badge/platform-ios-CDCDCD.svg?style=flat