mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-12 07:42:03 +01:00
Add ktlint, reformat files
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import org.jetbrains.compose.compose
|
import org.jetbrains.compose.compose
|
||||||
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
|
||||||
|
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||||
|
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.4.32"
|
kotlin("jvm") version "1.4.32"
|
||||||
@@ -8,6 +10,7 @@ plugins {
|
|||||||
kotlin("plugin.serialization") version "1.4.32"
|
kotlin("plugin.serialization") version "1.4.32"
|
||||||
id("org.jetbrains.compose") version "0.4.0-build184"
|
id("org.jetbrains.compose") version "0.4.0-build184"
|
||||||
id("de.fuerstenau.buildconfig") version "1.1.8"
|
id("de.fuerstenau.buildconfig") version "1.1.8"
|
||||||
|
id("org.jmailen.kotlinter") version "3.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ca.gosyer"
|
group = "ca.gosyer"
|
||||||
@@ -82,6 +85,19 @@ tasks {
|
|||||||
test {
|
test {
|
||||||
useJUnit()
|
useJUnit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withType<LintTask> {
|
||||||
|
source(files("src"))
|
||||||
|
reports.set(mapOf(
|
||||||
|
"plain" to file("build/lint-report.txt"),
|
||||||
|
"json" to file("build/lint-report.json")
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<FormatTask> {
|
||||||
|
source(files("src"))
|
||||||
|
report.set(file("build/format-report.txt"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,3 +140,8 @@ buildConfig {
|
|||||||
|
|
||||||
buildConfigField("boolean", "DEBUG", project.hasProperty("debugApp").toString())
|
buildConfigField("boolean", "DEBUG", project.hasProperty("debugApp").toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlinter {
|
||||||
|
experimentalRules = true
|
||||||
|
disabledRules = arrayOf("experimental:argument-list-wrapping")
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
org.gradle.jvmargs=-Xmx2048m
|
||||||
@@ -27,5 +27,4 @@ object AppScope : Scope by KTP.openRootScope() {
|
|||||||
inline fun <reified T> getInstance(): T {
|
inline fun <reified T> getInstance(): T {
|
||||||
return getInstance(T::class.java)
|
return getInstance(T::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -50,5 +50,4 @@ class DataUriStringSource(private val data: String) : Source {
|
|||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.common.io
|
package ca.gosyer.common.io
|
||||||
|
|
||||||
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import okio.BufferedSink
|
import okio.BufferedSink
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.common.prefs
|
package ca.gosyer.common.prefs
|
||||||
|
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
@@ -57,5 +56,4 @@ interface Preference<T> {
|
|||||||
* current value and receive preference updates.
|
* current value and receive preference updates.
|
||||||
*/
|
*/
|
||||||
fun stateIn(scope: CoroutineScope): StateFlow<T>
|
fun stateIn(scope: CoroutineScope): StateFlow<T>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,6 @@ interface PreferenceStore {
|
|||||||
deserializer: (String) -> T
|
deserializer: (String) -> T
|
||||||
): Preference<T>
|
): Preference<T>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns preference of type [T] for this [key]. The [serializer] must be provided.
|
* Returns preference of type [T] for this [key]. The [serializer] must be provided.
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +66,6 @@ interface PreferenceStore {
|
|||||||
serializer: KSerializer<T>,
|
serializer: KSerializer<T>,
|
||||||
serializersModule: SerializersModule = EmptySerializersModule
|
serializersModule: SerializersModule = EmptySerializersModule
|
||||||
): Preference<T>
|
): Preference<T>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,11 +75,16 @@ inline fun <reified T : Enum<T>> PreferenceStore.getEnum(
|
|||||||
key: String,
|
key: String,
|
||||||
defaultValue: T
|
defaultValue: T
|
||||||
): Preference<T> {
|
): Preference<T> {
|
||||||
return getObject(key, defaultValue, { it.name }, {
|
return getObject(
|
||||||
try {
|
key,
|
||||||
enumValueOf(it)
|
defaultValue,
|
||||||
} catch (e: IllegalArgumentException) {
|
{ it.name },
|
||||||
defaultValue
|
{
|
||||||
|
try {
|
||||||
|
enumValueOf(it)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
defaultValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,5 +95,4 @@ internal class JvmPreference<T>(
|
|||||||
override fun stateIn(scope: CoroutineScope): StateFlow<T> {
|
override fun stateIn(scope: CoroutineScope): StateFlow<T> {
|
||||||
return changes().stateIn(scope, SharingStarted.Eagerly, get())
|
return changes().stateIn(scope, SharingStarted.Eagerly, get())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,6 @@ internal class ObjectAdapter<T>(
|
|||||||
override fun set(key: String, value: T, editor: ObservableSettings) {
|
override fun set(key: String, value: T, editor: ObservableSettings) {
|
||||||
editor.putString(key, serializer(value))
|
editor.putString(key, serializer(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class JsonObjectAdapter<T>(
|
internal class JsonObjectAdapter<T>(
|
||||||
@@ -103,5 +102,4 @@ internal class JsonObjectAdapter<T>(
|
|||||||
override fun set(key: String, value: T, editor: ObservableSettings) {
|
override fun set(key: String, value: T, editor: ObservableSettings) {
|
||||||
editor.encodeValue(serializer, key, value, serializersModule)
|
editor.encodeValue(serializer, key, value, serializersModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -82,5 +82,4 @@ class JvmPreferenceStore(private val preferences: ObservableSettings) : Preferen
|
|||||||
val adapter = JsonObjectAdapter(defaultValue, serializer, serializersModule)
|
val adapter = JsonObjectAdapter(defaultValue, serializer, serializersModule)
|
||||||
return JvmPreference(preferences, key, defaultValue, adapter)
|
return JvmPreference(preferences, key, defaultValue, adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,12 +13,12 @@ import java.util.prefs.Preferences
|
|||||||
class PreferenceStoreFactory {
|
class PreferenceStoreFactory {
|
||||||
|
|
||||||
fun create(name: String? = null): PreferenceStore {
|
fun create(name: String? = null): PreferenceStore {
|
||||||
|
val userPreferences: Preferences = Preferences.userRoot()
|
||||||
val jvmPreferences = if (!name.isNullOrBlank()) {
|
val jvmPreferences = if (!name.isNullOrBlank()) {
|
||||||
JvmPreferencesSettings(Preferences.userRoot().node(name))
|
JvmPreferencesSettings(userPreferences.node(name))
|
||||||
} else {
|
} else {
|
||||||
JvmPreferencesSettings(Preferences.userRoot())
|
JvmPreferencesSettings(userPreferences)
|
||||||
}
|
}
|
||||||
return JvmPreferenceStore(jvmPreferences)
|
return JvmPreferenceStore(jvmPreferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class ServerService @Inject constructor(
|
|||||||
val logger = KotlinLogging.logger("Server")
|
val logger = KotlinLogging.logger("Server")
|
||||||
val runtime = Runtime.getRuntime()
|
val runtime = Runtime.getRuntime()
|
||||||
|
|
||||||
val jarFile = File(userDataDir,"Tachidesk.jar")
|
val jarFile = File(userDataDir, "Tachidesk.jar")
|
||||||
if (!jarFile.exists()) {
|
if (!jarFile.exists()) {
|
||||||
logger.info { "Copying server to resources" }
|
logger.info { "Copying server to resources" }
|
||||||
javaClass.getResourceAsStream("/Tachidesk.jar")?.buffered()?.use { input ->
|
javaClass.getResourceAsStream("/Tachidesk.jar")?.buffered()?.use { input ->
|
||||||
@@ -59,7 +59,7 @@ class ServerService @Inject constructor(
|
|||||||
val javaExeFile = File(javaLibraryPath, "java.exe")
|
val javaExeFile = File(javaLibraryPath, "java.exe")
|
||||||
val javaUnixFile = File(javaLibraryPath, "java")
|
val javaUnixFile = File(javaLibraryPath, "java")
|
||||||
val javaExePath = when {
|
val javaExePath = when {
|
||||||
javaExeFile.exists() ->'"' + javaExeFile.absolutePath + '"'
|
javaExeFile.exists() -> '"' + javaExeFile.absolutePath + '"'
|
||||||
javaUnixFile.exists() -> '"' + javaUnixFile.absolutePath + '"'
|
javaUnixFile.exists() -> '"' + javaUnixFile.absolutePath + '"'
|
||||||
else -> "java"
|
else -> "java"
|
||||||
}
|
}
|
||||||
@@ -69,9 +69,11 @@ class ServerService @Inject constructor(
|
|||||||
process = runtime.exec("""$javaExePath -jar "${jarFile.absolutePath}"""").also {
|
process = runtime.exec("""$javaExePath -jar "${jarFile.absolutePath}"""").also {
|
||||||
reader = it.inputStream.bufferedReader()
|
reader = it.inputStream.bufferedReader()
|
||||||
}
|
}
|
||||||
runtime.addShutdownHook(thread(start = false) {
|
runtime.addShutdownHook(
|
||||||
process?.destroy()
|
thread(start = false) {
|
||||||
})
|
process?.destroy()
|
||||||
|
}
|
||||||
|
)
|
||||||
logger.info { "Server started successfully" }
|
logger.info { "Server started successfully" }
|
||||||
var line: String?
|
var line: String?
|
||||||
while (reader.readLine().also { line = it } != null) {
|
while (reader.readLine().also { line = it } != null) {
|
||||||
@@ -87,7 +89,6 @@ class ServerService @Inject constructor(
|
|||||||
logger.info { "Server closed" }
|
logger.info { "Server closed" }
|
||||||
val exitVal = process?.waitFor()
|
val exitVal = process?.waitFor()
|
||||||
logger.info { "Process exitValue: $exitVal" }
|
logger.info { "Process exitValue: $exitVal" }
|
||||||
|
|
||||||
}
|
}
|
||||||
}.launchIn(GlobalScope)
|
}.launchIn(GlobalScope)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import javax.inject.Inject
|
|||||||
class CategoryInteractionHandler @Inject constructor(
|
class CategoryInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getMangaCategories(mangaId: Long) = withContext(Dispatchers.IO) {
|
suspend fun getMangaCategories(mangaId: Long) = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<List<Category>>(
|
client.getRepeat<List<Category>>(
|
||||||
@@ -75,13 +75,13 @@ class CategoryInteractionHandler @Inject constructor(
|
|||||||
suspend fun modifyCategory(categoryId: Long, name: String? = null, isLanding: Boolean? = null) = withContext(Dispatchers.IO) {
|
suspend fun modifyCategory(categoryId: Long, name: String? = null, isLanding: Boolean? = null) = withContext(Dispatchers.IO) {
|
||||||
client.submitFormRepeat<HttpResponse>(
|
client.submitFormRepeat<HttpResponse>(
|
||||||
serverUrl + categoryModifyRequest(categoryId),
|
serverUrl + categoryModifyRequest(categoryId),
|
||||||
formParameters = Parameters.build {
|
formParameters = Parameters.build {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
append("name", name)
|
append("name", name)
|
||||||
}
|
}
|
||||||
if (isLanding != null) {
|
if (isLanding != null) {
|
||||||
append("isLanding", isLanding.toString())
|
append("isLanding", isLanding.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
method = HttpMethod.Patch
|
method = HttpMethod.Patch
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import javax.inject.Inject
|
|||||||
class ChapterInteractionHandler @Inject constructor(
|
class ChapterInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getChapters(mangaId: Long) = withContext(Dispatchers.IO) {
|
suspend fun getChapters(mangaId: Long) = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<List<Chapter>>(
|
client.getRepeat<List<Chapter>>(
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import javax.inject.Inject
|
|||||||
class ExtensionInteractionHandler @Inject constructor(
|
class ExtensionInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getExtensionList() = withContext(Dispatchers.IO) {
|
suspend fun getExtensionList() = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<List<Extension>>(
|
client.getRepeat<List<Extension>>(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import javax.inject.Inject
|
|||||||
class LibraryInteractionHandler @Inject constructor(
|
class LibraryInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getLibraryManga() = withContext(Dispatchers.IO) {
|
suspend fun getLibraryManga() = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<List<Manga>>(
|
client.getRepeat<List<Manga>>(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import javax.inject.Inject
|
|||||||
class MangaInteractionHandler @Inject constructor(
|
class MangaInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getManga(mangaId: Long) = withContext(Dispatchers.IO) {
|
suspend fun getManga(mangaId: Long) = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<Manga>(
|
client.getRepeat<Manga>(
|
||||||
@@ -32,5 +32,4 @@ class MangaInteractionHandler @Inject constructor(
|
|||||||
serverUrl + mangaThumbnailQuery(mangaId)
|
serverUrl + mangaThumbnailQuery(mangaId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ import javax.inject.Inject
|
|||||||
class SourceInteractionHandler @Inject constructor(
|
class SourceInteractionHandler @Inject constructor(
|
||||||
client: Http,
|
client: Http,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): BaseInteractionHandler(client, serverPreferences) {
|
) : BaseInteractionHandler(client, serverPreferences) {
|
||||||
|
|
||||||
suspend fun getSourceList() = withContext(Dispatchers.IO) {
|
suspend fun getSourceList() = withContext(Dispatchers.IO) {
|
||||||
client.getRepeat<List<Source>>(
|
client.getRepeat<List<Source>>(
|
||||||
@@ -48,7 +48,8 @@ class SourceInteractionHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getPopularManga(source: Source, pageNum: Int) = getPopularManga(
|
suspend fun getPopularManga(source: Source, pageNum: Int) = getPopularManga(
|
||||||
source.id, pageNum
|
source.id,
|
||||||
|
pageNum
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun getLatestManga(sourceId: Long, pageNum: Int) = withContext(Dispatchers.IO) {
|
suspend fun getLatestManga(sourceId: Long, pageNum: Int) = withContext(Dispatchers.IO) {
|
||||||
@@ -58,7 +59,8 @@ class SourceInteractionHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getLatestManga(source: Source, pageNum: Int) = getLatestManga(
|
suspend fun getLatestManga(source: Source, pageNum: Int) = getLatestManga(
|
||||||
source.id, pageNum
|
source.id,
|
||||||
|
pageNum
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: 2021-03-14
|
// TODO: 2021-03-14
|
||||||
@@ -75,7 +77,9 @@ class SourceInteractionHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getSearchResults(source: Source, searchTerm: String, pageNum: Int) = getSearchResults(
|
suspend fun getSearchResults(source: Source, searchTerm: String, pageNum: Int) = getSearchResults(
|
||||||
source.id, searchTerm, pageNum
|
source.id,
|
||||||
|
searchTerm,
|
||||||
|
pageNum
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: 2021-03-14
|
// TODO: 2021-03-14
|
||||||
|
|||||||
@@ -56,5 +56,4 @@ class UiPreferences(private val preferenceStore: PreferenceStore) {
|
|||||||
fun dateFormat(): Preference<String> {
|
fun dateFormat(): Preference<String> {
|
||||||
return preferenceStore.getString("date_format", "")
|
return preferenceStore.getString("date_format", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,10 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
enum class StartScreen {
|
enum class StartScreen {
|
||||||
Library,
|
Library,
|
||||||
|
|
||||||
// Updates,
|
// Updates,
|
||||||
// History,
|
// History,
|
||||||
Sources,
|
Sources,
|
||||||
Extensions
|
Extensions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,16 +99,20 @@ fun ColorPickerDialog(
|
|||||||
val showPresetsState by showPresets.collectAsState()
|
val showPresetsState by showPresets.collectAsState()
|
||||||
val currentColorState by currentColor.collectAsState()
|
val currentColorState by currentColor.collectAsState()
|
||||||
Row(Modifier.fillMaxWidth().padding(8.dp)) {
|
Row(Modifier.fillMaxWidth().padding(8.dp)) {
|
||||||
TextButton(onClick = {
|
TextButton(
|
||||||
showPresets.value = !showPresetsState
|
onClick = {
|
||||||
}) {
|
showPresets.value = !showPresetsState
|
||||||
|
}
|
||||||
|
) {
|
||||||
Text(if (showPresetsState) "Custom" else "Presets")
|
Text(if (showPresetsState) "Custom" else "Presets")
|
||||||
}
|
}
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
TextButton(onClick = {
|
TextButton(
|
||||||
onSelected(currentColorState)
|
onClick = {
|
||||||
it.close()
|
onSelected(currentColorState)
|
||||||
}) {
|
it.close()
|
||||||
|
}
|
||||||
|
) {
|
||||||
Text("Select")
|
Text("Select")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +185,8 @@ private fun ColorPresetItem(
|
|||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.Center, modifier = Modifier
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
.size(48.dp)
|
.size(48.dp)
|
||||||
@@ -241,13 +246,15 @@ fun ColorPalette(
|
|||||||
val saturationGradient = remember(hue, matrixSize) {
|
val saturationGradient = remember(hue, matrixSize) {
|
||||||
Brush.linearGradient(
|
Brush.linearGradient(
|
||||||
colors = listOf(Color.White, hueToColor(hue)),
|
colors = listOf(Color.White, hueToColor(hue)),
|
||||||
start = Offset(0f, 0f), end = Offset(matrixSize.width.toFloat(), 0f)
|
start = Offset(0f, 0f),
|
||||||
|
end = Offset(matrixSize.width.toFloat(), 0f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val valueGradient = remember(matrixSize) {
|
val valueGradient = remember(matrixSize) {
|
||||||
Brush.linearGradient(
|
Brush.linearGradient(
|
||||||
colors = listOf(Color.White, Color.Black),
|
colors = listOf(Color.White, Color.Black),
|
||||||
start = Offset(0f, 0f), end = Offset(0f, matrixSize.height.toFloat())
|
start = Offset(0f, 0f),
|
||||||
|
end = Offset(0f, matrixSize.height.toFloat())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,80 +277,82 @@ fun ColorPalette(
|
|||||||
Column {
|
Column {
|
||||||
Text("") // TODO workaround: without this text, the color picker doesn't render correctly
|
Text("") // TODO workaround: without this text, the color picker doesn't render correctly
|
||||||
Row(Modifier.height(IntrinsicSize.Max)) {
|
Row(Modifier.height(IntrinsicSize.Max)) {
|
||||||
Box(Modifier
|
Box(
|
||||||
.aspectRatio(1f)
|
Modifier
|
||||||
.weight(1f)
|
.aspectRatio(1f)
|
||||||
.onSizeChanged {
|
.weight(1f)
|
||||||
matrixSize = it
|
.onSizeChanged {
|
||||||
val hsv = selectedColor.toHsv()
|
matrixSize = it
|
||||||
matrixCursor = satValToCoordinates(hsv[1], hsv[2], it)
|
val hsv = selectedColor.toHsv()
|
||||||
hueCursor = hueToCoordinate(hue, it)
|
matrixCursor = satValToCoordinates(hsv[1], hsv[2], it)
|
||||||
}
|
hueCursor = hueToCoordinate(hue, it)
|
||||||
.drawWithContent {
|
|
||||||
drawRect(brush = valueGradient)
|
|
||||||
drawRect(brush = saturationGradient, blendMode = BlendMode.Multiply)
|
|
||||||
drawRect(Color.LightGray, size = size, style = borderStroke)
|
|
||||||
drawCircle(
|
|
||||||
Color.Black,
|
|
||||||
radius = 8f,
|
|
||||||
center = matrixCursor,
|
|
||||||
style = cursorStroke
|
|
||||||
)
|
|
||||||
drawCircle(
|
|
||||||
Color.LightGray,
|
|
||||||
radius = 12f,
|
|
||||||
center = matrixCursor,
|
|
||||||
style = cursorStroke
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.pointerInput(Unit) {
|
|
||||||
detectMove { offset ->
|
|
||||||
val safeOffset = offset.copy(
|
|
||||||
x = offset.x.coerceIn(0f, matrixSize.width.toFloat()),
|
|
||||||
y = offset.y.coerceIn(0f, matrixSize.height.toFloat())
|
|
||||||
)
|
|
||||||
matrixCursor = safeOffset
|
|
||||||
val newColor = matrixCoordinatesToColor(hue, safeOffset, matrixSize)
|
|
||||||
setSelectedColor(newColor)
|
|
||||||
}
|
}
|
||||||
}
|
.drawWithContent {
|
||||||
)
|
drawRect(brush = valueGradient)
|
||||||
Box(Modifier
|
drawRect(brush = saturationGradient, blendMode = BlendMode.Multiply)
|
||||||
.fillMaxHeight()
|
|
||||||
.requiredWidth(48.dp)
|
|
||||||
.padding(start = 8.dp)
|
|
||||||
.drawWithCache {
|
|
||||||
var h = 360f
|
|
||||||
val colors = MutableList(size.height.toInt()) {
|
|
||||||
hueToColor(h).also {
|
|
||||||
h -= 360f / size.height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val cursorSize = Size(size.width, 10f)
|
|
||||||
val cursorTopLeft = Offset(0f, hueCursor - (cursorSize.height / 2))
|
|
||||||
onDrawBehind {
|
|
||||||
colors.forEachIndexed { i, color ->
|
|
||||||
val pos = i.toFloat()
|
|
||||||
drawLine(color, Offset(0f, pos), Offset(size.width, pos))
|
|
||||||
}
|
|
||||||
drawRect(Color.LightGray, size = size, style = borderStroke)
|
drawRect(Color.LightGray, size = size, style = borderStroke)
|
||||||
drawRect(
|
drawCircle(
|
||||||
cursorColor,
|
Color.Black,
|
||||||
topLeft = cursorTopLeft,
|
radius = 8f,
|
||||||
size = cursorSize,
|
center = matrixCursor,
|
||||||
|
style = cursorStroke
|
||||||
|
)
|
||||||
|
drawCircle(
|
||||||
|
Color.LightGray,
|
||||||
|
radius = 12f,
|
||||||
|
center = matrixCursor,
|
||||||
style = cursorStroke
|
style = cursorStroke
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
.pointerInput(Unit) {
|
||||||
.pointerInput(Unit) {
|
detectMove { offset ->
|
||||||
detectMove { offset ->
|
val safeOffset = offset.copy(
|
||||||
val safeY = offset.y.coerceIn(0f, matrixSize.height.toFloat())
|
x = offset.x.coerceIn(0f, matrixSize.width.toFloat()),
|
||||||
hueCursor = safeY
|
y = offset.y.coerceIn(0f, matrixSize.height.toFloat())
|
||||||
hue = hueCoordinatesToHue(safeY, matrixSize)
|
)
|
||||||
val newColor = matrixCoordinatesToColor(hue, matrixCursor, matrixSize)
|
matrixCursor = safeOffset
|
||||||
setSelectedColor(newColor)
|
val newColor = matrixCoordinatesToColor(hue, safeOffset, matrixSize)
|
||||||
|
setSelectedColor(newColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.requiredWidth(48.dp)
|
||||||
|
.padding(start = 8.dp)
|
||||||
|
.drawWithCache {
|
||||||
|
var h = 360f
|
||||||
|
val colors = MutableList(size.height.toInt()) {
|
||||||
|
hueToColor(h).also {
|
||||||
|
h -= 360f / size.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val cursorSize = Size(size.width, 10f)
|
||||||
|
val cursorTopLeft = Offset(0f, hueCursor - (cursorSize.height / 2))
|
||||||
|
onDrawBehind {
|
||||||
|
colors.forEachIndexed { i, color ->
|
||||||
|
val pos = i.toFloat()
|
||||||
|
drawLine(color, Offset(0f, pos), Offset(size.width, pos))
|
||||||
|
}
|
||||||
|
drawRect(Color.LightGray, size = size, style = borderStroke)
|
||||||
|
drawRect(
|
||||||
|
cursorColor,
|
||||||
|
topLeft = cursorTopLeft,
|
||||||
|
size = cursorSize,
|
||||||
|
style = cursorStroke
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pointerInput(Unit) {
|
||||||
|
detectMove { offset ->
|
||||||
|
val safeY = offset.y.coerceIn(0f, matrixSize.height.toFloat())
|
||||||
|
hueCursor = safeY
|
||||||
|
hue = hueCoordinatesToHue(safeY, matrixSize)
|
||||||
|
val newColor = matrixCoordinatesToColor(hue, matrixCursor, matrixSize)
|
||||||
|
setSelectedColor(newColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row(Modifier.padding(top = 8.dp), verticalAlignment = Alignment.Bottom) {
|
Row(Modifier.padding(top = 8.dp), verticalAlignment = Alignment.Bottom) {
|
||||||
@@ -451,4 +460,3 @@ private val presetColors = listOf(
|
|||||||
Color(0xFF607D8B), // BLUE GREY 500
|
Color(0xFF607D8B), // BLUE GREY 500
|
||||||
Color(0xFF9E9E9E), // GREY 500
|
Color(0xFF9E9E9E), // GREY 500
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ fun Toolbar(
|
|||||||
closable: Boolean,
|
closable: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
actions: @Composable RowScope.() -> Unit = {},
|
actions: @Composable RowScope.() -> Unit = {},
|
||||||
backgroundColor: Color = MaterialTheme.colors.primary, //CustomColors.current.bars,
|
backgroundColor: Color = MaterialTheme.colors.primary, // CustomColors.current.bars,
|
||||||
contentColor: Color = MaterialTheme.colors.onPrimary, //CustomColors.current.onBars,
|
contentColor: Color = MaterialTheme.colors.onPrimary, // CustomColors.current.onBars,
|
||||||
elevation: Dp = AppBarDefaults.TopAppBarElevation,
|
elevation: Dp = AppBarDefaults.TopAppBarElevation,
|
||||||
search: ((String) -> Unit)? = null
|
search: ((String) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -139,9 +139,12 @@ fun EditTextPreference(
|
|||||||
preference.value = editText.text
|
preference.value = editText.text
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(editText, onValueChange = {
|
OutlinedTextField(
|
||||||
editText = it
|
editText,
|
||||||
})
|
onValueChange = {
|
||||||
|
editText = it
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -177,31 +180,37 @@ private fun <T> ChoiceDialog(
|
|||||||
onDismissRequest: () -> Unit = {},
|
onDismissRequest: () -> Unit = {},
|
||||||
onSelected: (T) -> Unit,
|
onSelected: (T) -> Unit,
|
||||||
title: String,
|
title: String,
|
||||||
buttons: @Composable (AppWindow) -> Unit = { }
|
buttons: @Composable (AppWindow) -> Unit = { }
|
||||||
) {
|
) {
|
||||||
WindowDialog(onDismissRequest = onDismissRequest, buttons = buttons, title = title, content = {
|
WindowDialog(
|
||||||
LazyColumn {
|
onDismissRequest = onDismissRequest,
|
||||||
items(items) { (value, text) ->
|
buttons = buttons,
|
||||||
Row(
|
title = title,
|
||||||
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable(
|
content = {
|
||||||
onClick = {
|
LazyColumn {
|
||||||
onSelected(value)
|
items(items) { (value, text) ->
|
||||||
it.close()
|
Row(
|
||||||
}),
|
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
onClick = {
|
||||||
) {
|
onSelected(value)
|
||||||
RadioButton(
|
it.close()
|
||||||
selected = value == selected,
|
}
|
||||||
onClick = {
|
),
|
||||||
onSelected(value)
|
verticalAlignment = Alignment.CenterVertically
|
||||||
it.close()
|
) {
|
||||||
},
|
RadioButton(
|
||||||
)
|
selected = value == selected,
|
||||||
Text(text = text, modifier = Modifier.padding(start = 24.dp))
|
onClick = {
|
||||||
|
onSelected(value)
|
||||||
|
it.close()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
Text(text = text, modifier = Modifier.padding(start = 24.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -19,11 +19,13 @@ data class Theme(
|
|||||||
val themes = listOf(
|
val themes = listOf(
|
||||||
// Pure white
|
// Pure white
|
||||||
Theme(
|
Theme(
|
||||||
1, lightColors()
|
1,
|
||||||
|
lightColors()
|
||||||
),
|
),
|
||||||
// Tachiyomi 0.x default colors
|
// Tachiyomi 0.x default colors
|
||||||
Theme(
|
Theme(
|
||||||
2, lightColors(
|
2,
|
||||||
|
lightColors(
|
||||||
primary = Color(0xFF2979FF),
|
primary = Color(0xFF2979FF),
|
||||||
primaryVariant = Color(0xFF2979FF),
|
primaryVariant = Color(0xFF2979FF),
|
||||||
onPrimary = Color.White,
|
onPrimary = Color.White,
|
||||||
@@ -34,11 +36,13 @@ val themes = listOf(
|
|||||||
),
|
),
|
||||||
// Tachiyomi 0.x dark theme
|
// Tachiyomi 0.x dark theme
|
||||||
Theme(
|
Theme(
|
||||||
3, darkColors()
|
3,
|
||||||
|
darkColors()
|
||||||
),
|
),
|
||||||
// AMOLED theme
|
// AMOLED theme
|
||||||
Theme(
|
Theme(
|
||||||
4, darkColors(
|
4,
|
||||||
|
darkColors(
|
||||||
primary = Color.Black,
|
primary = Color.Black,
|
||||||
onPrimary = Color.White,
|
onPrimary = Color.White,
|
||||||
background = Color.Black
|
background = Color.Black
|
||||||
|
|||||||
@@ -142,12 +142,16 @@ private fun CategoryRow(
|
|||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
IconButton(onClick = onRename) {
|
IconButton(onClick = onRename) {
|
||||||
Icon(imageVector = Icons.Default.Edit,
|
Icon(
|
||||||
contentDescription = null)
|
imageVector = Icons.Default.Edit,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
IconButton(onClick = onDelete) {
|
IconButton(onClick = onDelete) {
|
||||||
Icon(imageVector = Icons.Default.Delete,
|
Icon(
|
||||||
contentDescription = null)
|
imageVector = Icons.Default.Delete,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ fun ExtensionItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ExtensionsMenuViewModel @Inject constructor(
|
|||||||
private val extensionHandler: ExtensionInteractionHandler,
|
private val extensionHandler: ExtensionInteractionHandler,
|
||||||
serverPreferences: ServerPreferences,
|
serverPreferences: ServerPreferences,
|
||||||
private val extensionPreferences: ExtensionPreferences
|
private val extensionPreferences: ExtensionPreferences
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
val serverUrl = serverPreferences.server().stateIn(scope)
|
val serverUrl = serverPreferences.server().stateIn(scope)
|
||||||
@@ -33,7 +33,6 @@ class ExtensionsMenuViewModel @Inject constructor(
|
|||||||
private val _isLoading = MutableStateFlow(true)
|
private val _isLoading = MutableStateFlow(true)
|
||||||
val isLoading = _isLoading.asStateFlow()
|
val isLoading = _isLoading.asStateFlow()
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
getExtensions()
|
getExtensions()
|
||||||
|
|||||||
@@ -50,12 +50,11 @@ fun LibraryScreen(onClickManga: (Long) -> Unit = { openMangaMenu(it) }) {
|
|||||||
val displayMode by vm.displayMode.collectAsState()
|
val displayMode by vm.displayMode.collectAsState()
|
||||||
val isLoading by vm.isLoading.collectAsState()
|
val isLoading by vm.isLoading.collectAsState()
|
||||||
val serverUrl by vm.serverUrl.collectAsState()
|
val serverUrl by vm.serverUrl.collectAsState()
|
||||||
//val sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
|
// val sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
|
||||||
|
|
||||||
if (categories.isEmpty()) {
|
if (categories.isEmpty()) {
|
||||||
LoadingScreen(isLoading)
|
LoadingScreen(isLoading)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*ModalBottomSheetLayout(
|
/*ModalBottomSheetLayout(
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
sheetContent = { *//*LibrarySheet()*//* }
|
sheetContent = { *//*LibrarySheet()*//* }
|
||||||
@@ -77,7 +76,7 @@ fun LibraryScreen(onClickManga: (Long) -> Unit = { openMangaMenu(it) }) {
|
|||||||
}
|
}
|
||||||
)*/
|
)*/
|
||||||
LibraryTabs(
|
LibraryTabs(
|
||||||
visible = true, //vm.showCategoryTabs,
|
visible = true, // vm.showCategoryTabs,
|
||||||
categories = categories,
|
categories = categories,
|
||||||
selectedPage = selectedCategoryIndex,
|
selectedPage = selectedCategoryIndex,
|
||||||
onPageChanged = vm::setSelectedPage
|
onPageChanged = vm::setSelectedPage
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
private val categoryHandler: CategoryInteractionHandler,
|
private val categoryHandler: CategoryInteractionHandler,
|
||||||
libraryPreferences: LibraryPreferences,
|
libraryPreferences: LibraryPreferences,
|
||||||
serverPreferences: ServerPreferences,
|
serverPreferences: ServerPreferences,
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
val serverUrl = serverPreferences.server().stateIn(scope)
|
val serverUrl = serverPreferences.server().stateIn(scope)
|
||||||
|
|
||||||
private val library = Library(MutableStateFlow(emptyList()), mutableMapOf())
|
private val library = Library(MutableStateFlow(emptyList()), mutableMapOf())
|
||||||
@@ -78,7 +78,6 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setSelectedPage(page: Int) {
|
fun setSelectedPage(page: Int) {
|
||||||
_selectedCategoryIndex.value = page
|
_selectedCategoryIndex.value = page
|
||||||
}
|
}
|
||||||
@@ -88,8 +87,6 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val defaultCategory = Category(0, 0, "Default",true)
|
val defaultCategory = Category(0, 0, "Default", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,11 +70,12 @@ private fun LibraryMangaCompactGridItem(
|
|||||||
TextStyle(letterSpacing = 0.sp, fontFamily = FontFamily.SansSerif, fontSize = 14.sp)
|
TextStyle(letterSpacing = 0.sp, fontFamily = FontFamily.SansSerif, fontSize = 14.sp)
|
||||||
)
|
)
|
||||||
|
|
||||||
Box(modifier = Modifier.padding(4.dp)
|
Box(
|
||||||
.fillMaxWidth()
|
modifier = Modifier.padding(4.dp)
|
||||||
.aspectRatio(3f / 4f)
|
.fillMaxWidth()
|
||||||
.clip(MaterialTheme.shapes.medium)
|
.aspectRatio(3f / 4f)
|
||||||
.clickable(onClick = onClick)
|
.clip(MaterialTheme.shapes.medium)
|
||||||
|
.clickable(onClick = onClick)
|
||||||
) {
|
) {
|
||||||
if (cover != null) {
|
if (cover != null) {
|
||||||
KtorImage(cover, contentScale = ContentScale.Crop)
|
KtorImage(cover, contentScale = ContentScale.Crop)
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import compose.icons.fontawesomeicons.regular.Map
|
|||||||
fun MainMenu() {
|
fun MainMenu() {
|
||||||
val vm = viewModel<MainViewModel>()
|
val vm = viewModel<MainViewModel>()
|
||||||
Surface {
|
Surface {
|
||||||
|
|
||||||
Router<Route>("TopLevel", Route.Library) { backStack ->
|
Router<Route>("TopLevel", Route.Library) { backStack ->
|
||||||
Row {
|
Row {
|
||||||
Surface(elevation = 2.dp) {
|
Surface(elevation = 2.dp) {
|
||||||
@@ -124,7 +123,6 @@ fun MainMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +133,7 @@ fun MainMenuItem(menu: TopLevelMenus, selected: Boolean, onClick: (Route) -> Uni
|
|||||||
backgroundColor = if (!selected) {
|
backgroundColor = if (!selected) {
|
||||||
Color.Transparent
|
Color.Transparent
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colors.primary.copy(0.30F)
|
MaterialTheme.colors.primary.copy(0.30F)
|
||||||
},
|
},
|
||||||
contentColor = Color.Transparent,
|
contentColor = Color.Transparent,
|
||||||
elevation = 0.dp
|
elevation = 0.dp
|
||||||
@@ -160,18 +158,20 @@ sealed class Route {
|
|||||||
object Library : Route()
|
object Library : Route()
|
||||||
object Sources : Route()
|
object Sources : Route()
|
||||||
object Extensions : Route()
|
object Extensions : Route()
|
||||||
data class Manga(val mangaId: Long): Route()
|
data class Manga(val mangaId: Long) : Route()
|
||||||
|
|
||||||
object Settings : Route()
|
object Settings : Route()
|
||||||
object SettingsGeneral : Route()
|
object SettingsGeneral : Route()
|
||||||
object SettingsAppearance : Route()
|
object SettingsAppearance : Route()
|
||||||
object SettingsLibrary : Route()
|
object SettingsLibrary : Route()
|
||||||
object SettingsReader : Route()
|
object SettingsReader : Route()
|
||||||
|
|
||||||
/*object SettingsDownloads : Route()
|
/*object SettingsDownloads : Route()
|
||||||
object SettingsTracking : Route()*/
|
object SettingsTracking : Route()*/
|
||||||
object SettingsBrowse : Route()
|
object SettingsBrowse : Route()
|
||||||
object SettingsBackup : Route()
|
object SettingsBackup : Route()
|
||||||
object SettingsServer : Route()
|
object SettingsServer : Route()
|
||||||
|
|
||||||
/*object SettingsSecurity : Route()
|
/*object SettingsSecurity : Route()
|
||||||
object SettingsParentalControls : Route()*/
|
object SettingsParentalControls : Route()*/
|
||||||
object SettingsAdvanced : Route()
|
object SettingsAdvanced : Route()
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class MainViewModel @Inject constructor(
|
class MainViewModel @Inject constructor(
|
||||||
uiPreferences: UiPreferences
|
uiPreferences: UiPreferences
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
val startScreen = uiPreferences.startScreen().get()
|
val startScreen = uiPreferences.startScreen().get()
|
||||||
}
|
}
|
||||||
@@ -153,9 +153,9 @@ private fun Cover(manga: Manga, serverUrl: String, modifier: Modifier = Modifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
sealed class MangaMenu {
|
sealed class MangaMenu {
|
||||||
data class MangaMenuManga(val manga: Manga): MangaMenu()
|
data class MangaMenuManga(val manga: Manga) : MangaMenu()
|
||||||
|
|
||||||
data class MangaMenuChapter(val chapter: Chapter): MangaMenu()
|
data class MangaMenuChapter(val chapter: Chapter) : MangaMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ class MangaMenuViewModel @Inject constructor(
|
|||||||
refreshMangaAsync(it.id).await()
|
refreshMangaAsync(it.id).await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDateFormat(format: String): DateFormat = when (format) {
|
private fun getDateFormat(format: String): DateFormat = when (format) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ fun SettingsAppearance(navController: BackStack<Route>) {
|
|||||||
ChoicePreference(
|
ChoicePreference(
|
||||||
preference = vm.themeMode,
|
preference = vm.themeMode,
|
||||||
choices = mapOf(
|
choices = mapOf(
|
||||||
//ThemeMode.System to R.string.follow_system_settings,
|
// ThemeMode.System to R.string.follow_system_settings,
|
||||||
ThemeMode.Light to "Light",
|
ThemeMode.Light to "Light",
|
||||||
ThemeMode.Dark to "Dark"
|
ThemeMode.Dark to "Dark"
|
||||||
),
|
),
|
||||||
@@ -94,24 +94,29 @@ fun SettingsAppearance(navController: BackStack<Route>) {
|
|||||||
)
|
)
|
||||||
LazyRow(modifier = Modifier.padding(horizontal = 8.dp)) {
|
LazyRow(modifier = Modifier.padding(horizontal = 8.dp)) {
|
||||||
items(themesForCurrentMode) { theme ->
|
items(themesForCurrentMode) { theme ->
|
||||||
ThemeItem(theme, onClick = {
|
ThemeItem(
|
||||||
(if (isLight) vm.lightTheme else vm.darkTheme).value = it.id
|
theme,
|
||||||
activeColors.primaryStateFlow.value = it.colors.primary
|
onClick = {
|
||||||
activeColors.secondaryStateFlow.value = it.colors.secondary
|
(if (isLight) vm.lightTheme else vm.darkTheme).value = it.id
|
||||||
})
|
activeColors.primaryStateFlow.value = it.colors.primary
|
||||||
|
activeColors.secondaryStateFlow.value = it.colors.secondary
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
ColorPreference(
|
ColorPreference(
|
||||||
preference = activeColors.primaryStateFlow, title = "Color primary",
|
preference = activeColors.primaryStateFlow,
|
||||||
|
title = "Color primary",
|
||||||
subtitle = "Displayed most frequently across your app",
|
subtitle = "Displayed most frequently across your app",
|
||||||
unsetColor = MaterialTheme.colors.primary
|
unsetColor = MaterialTheme.colors.primary
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
ColorPreference(
|
ColorPreference(
|
||||||
preference = activeColors.secondaryStateFlow, title = "Color secondary",
|
preference = activeColors.secondaryStateFlow,
|
||||||
|
title = "Color secondary",
|
||||||
subtitle = "Accents select parts of the UI",
|
subtitle = "Accents select parts of the UI",
|
||||||
unsetColor = MaterialTheme.colors.secondary
|
unsetColor = MaterialTheme.colors.secondary
|
||||||
)
|
)
|
||||||
@@ -132,7 +137,9 @@ private fun ThemeItem(
|
|||||||
Color.White.copy(alpha = 0.15f)
|
Color.White.copy(alpha = 0.15f)
|
||||||
}
|
}
|
||||||
Surface(
|
Surface(
|
||||||
elevation = 4.dp, color = theme.colors.background, shape = borders,
|
elevation = 4.dp,
|
||||||
|
color = theme.colors.background,
|
||||||
|
shape = borders,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(100.dp, 160.dp)
|
.size(100.dp, 160.dp)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
@@ -159,9 +166,10 @@ private fun ThemeItem(
|
|||||||
disabledBackgroundColor = theme.colors.primary
|
disabledBackgroundColor = theme.colors.primary
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
Surface(Modifier
|
Surface(
|
||||||
.size(24.dp)
|
Modifier
|
||||||
.align(Alignment.BottomEnd),
|
.size(24.dp)
|
||||||
|
.align(Alignment.BottomEnd),
|
||||||
shape = MaterialTheme.shapes.small.copy(CornerSize(percent = 50)),
|
shape = MaterialTheme.shapes.small.copy(CornerSize(percent = 50)),
|
||||||
color = theme.colors.secondary,
|
color = theme.colors.secondary,
|
||||||
elevation = 6.dp,
|
elevation = 6.dp,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class SettingsServerViewModel @Inject constructor(
|
class SettingsServerViewModel @Inject constructor(
|
||||||
private val serverPreferences: ServerPreferences
|
private val serverPreferences: ServerPreferences
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
val host = serverPreferences.host().asStateIn(scope)
|
val host = serverPreferences.host().asStateIn(scope)
|
||||||
val serverUrl = serverPreferences.server().asStateIn(scope)
|
val serverUrl = serverPreferences.server().asStateIn(scope)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ fun SourcesMenu(bundle: Bundle, onMangaClick: (Long) -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val selectedSource: Source? = selectedSourceTab
|
val selectedSource: Source? = selectedSourceTab
|
||||||
BundleScope("Sources") {
|
BundleScope("Sources") {
|
||||||
if (selectedSource != null) {
|
if (selectedSource != null) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class SourcesMenuViewModel @Inject constructor(
|
|||||||
private val sourceHandler: SourceInteractionHandler,
|
private val sourceHandler: SourceInteractionHandler,
|
||||||
serverPreferences: ServerPreferences,
|
serverPreferences: ServerPreferences,
|
||||||
catalogPreferences: CatalogPreferences
|
catalogPreferences: CatalogPreferences
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
val serverUrl = serverPreferences.server().stateIn(scope)
|
val serverUrl = serverPreferences.server().stateIn(scope)
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ fun SourceCategory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SourceItem(
|
fun SourceItem(
|
||||||
source: Source,
|
source: Source,
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ private fun MangaTable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LazyVerticalGrid(GridCells.Adaptive(160.dp)) {
|
LazyVerticalGrid(GridCells.Adaptive(160.dp)) {
|
||||||
items(mangas) { manga ->
|
items(mangas) { manga ->
|
||||||
MangaGridItem(
|
MangaGridItem(
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class SourceScreenViewModel @Inject constructor(
|
|||||||
private val sourceHandler: SourceInteractionHandler,
|
private val sourceHandler: SourceInteractionHandler,
|
||||||
private val mangaHandler: MangaInteractionHandler,
|
private val mangaHandler: MangaInteractionHandler,
|
||||||
serverPreferences: ServerPreferences
|
serverPreferences: ServerPreferences
|
||||||
): ViewModel() {
|
) : ViewModel() {
|
||||||
private lateinit var source: Source
|
private lateinit var source: Source
|
||||||
private lateinit var bundle: Bundle
|
private lateinit var bundle: Bundle
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ class SourceScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setMode(toLatest: Boolean) {
|
fun setMode(toLatest: Boolean) {
|
||||||
if (isLatest.value != toLatest){
|
if (isLatest.value != toLatest) {
|
||||||
_isLatest.value = toLatest
|
_isLatest.value = toLatest
|
||||||
bundle.remove(MANGAS_KEY)
|
bundle.remove(MANGAS_KEY)
|
||||||
bundle.remove(NEXT_PAGE_KEY)
|
bundle.remove(NEXT_PAGE_KEY)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ fun processFile() {
|
|||||||
val strTmp = System.getProperty("java.io.tmpdir")
|
val strTmp = System.getProperty("java.io.tmpdir")
|
||||||
val file = File("$strTmp/TachideskJUI.pid")
|
val file = File("$strTmp/TachideskJUI.pid")
|
||||||
|
|
||||||
//backup deletion
|
// backup deletion
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.delete()
|
file.delete()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import kotlin.test.Test
|
|||||||
|
|
||||||
class ExtensionInteractionTest {
|
class ExtensionInteractionTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Install a extension`() {
|
fun `Install a extension`() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user