feat: json layout saving
This commit is contained in:
parent
1a738a4c9c
commit
b2479abb09
5 changed files with 25 additions and 6 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import org.jetbrains.compose.ExperimentalComposeLibrary
|
import org.jetbrains.compose.ExperimentalComposeLibrary
|
||||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
@ -23,6 +22,7 @@ dependencies {
|
||||||
implementation(compose.materialIconsExtended)
|
implementation(compose.materialIconsExtended)
|
||||||
implementation(compose.material3)
|
implementation(compose.material3)
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.6.4")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.6.4")
|
||||||
|
implementation("com.google.code.gson:gson:2.10")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package xyz.atnrch.wrench.components.filemanager.bottom
|
package xyz.atnrch.wrench.components
|
||||||
|
|
||||||
import androidx.compose.foundation.shape.CornerSize
|
import androidx.compose.foundation.shape.CornerSize
|
||||||
import androidx.compose.material.BottomAppBar
|
import androidx.compose.material.BottomAppBar
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.window.WindowState
|
import androidx.compose.ui.window.WindowState
|
||||||
|
import xyz.atnrch.wrench.components.filemanager.bottom.BottomRowNew
|
||||||
import xyz.atnrch.wrench.ui.UIColors
|
import xyz.atnrch.wrench.ui.UIColors
|
||||||
import xyz.atnrch.wrench.watcher.Watcher
|
import xyz.atnrch.wrench.watcher.Watcher
|
||||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
import xyz.atnrch.wrench.watcher.WatcherManager
|
|
@ -1,4 +0,0 @@
|
||||||
package xyz.atnrch.wrench.config
|
|
||||||
|
|
||||||
class WrenchConfig {
|
|
||||||
}
|
|
22
src/main/kotlin/xyz/atnrch/wrench/json/JsonConfig.kt
Normal file
22
src/main/kotlin/xyz/atnrch/wrench/json/JsonConfig.kt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.atnrch.wrench.json
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileReader
|
||||||
|
import java.io.FileWriter
|
||||||
|
|
||||||
|
class JsonConfig {
|
||||||
|
private val gson: Gson = Gson().newBuilder().serializeNulls().setPrettyPrinting().create()
|
||||||
|
private val file = File("layout.json")
|
||||||
|
private val watcherEntryType = object : TypeToken<List<WatcherEntry>>() {}.type
|
||||||
|
|
||||||
|
fun writeLayout(list: List<WatcherEntry>) {
|
||||||
|
gson.toJson(list, FileWriter(file))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun readLayout() {
|
||||||
|
gson.fromJson<List<WatcherEntry>>(FileReader(file), watcherEntryType)
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue