Add ktlint, reformat files

This commit is contained in:
Syer10
2021-04-26 20:16:35 -04:00
parent 3a83037104
commit 91c93b5982
83 changed files with 320 additions and 278 deletions

View File

@@ -1,6 +1,8 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.LintTask
plugins {
kotlin("jvm") version "1.4.32"
@@ -8,6 +10,7 @@ plugins {
kotlin("plugin.serialization") version "1.4.32"
id("org.jetbrains.compose") version "0.4.0-build184"
id("de.fuerstenau.buildconfig") version "1.1.8"
id("org.jmailen.kotlinter") version "3.4.0"
}
group = "ca.gosyer"
@@ -82,6 +85,19 @@ tasks {
test {
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())
}
kotlinter {
experimentalRules = true
disabledRules = arrayOf("experimental:argument-list-wrapping")
}

View File

@@ -1 +1,2 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048m

View File

@@ -27,5 +27,4 @@ object AppScope : Scope by KTP.openRootScope() {
inline fun <reified T> getInstance(): T {
return getInstance(T::class.java)
}
}

View File

@@ -50,5 +50,4 @@ class DataUriStringSource(private val data: String) : Source {
override fun close() {
}
}

View File

@@ -6,7 +6,6 @@
package ca.gosyer.common.io
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okio.BufferedSink

View File

@@ -6,7 +6,6 @@
package ca.gosyer.common.prefs
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
@@ -57,5 +56,4 @@ interface Preference<T> {
* current value and receive preference updates.
*/
fun stateIn(scope: CoroutineScope): StateFlow<T>
}

View File

@@ -57,7 +57,6 @@ interface PreferenceStore {
deserializer: (String) -> T
): Preference<T>
/**
* Returns preference of type [T] for this [key]. The [serializer] must be provided.
*/
@@ -67,7 +66,6 @@ interface PreferenceStore {
serializer: KSerializer<T>,
serializersModule: SerializersModule = EmptySerializersModule
): Preference<T>
}
/**
@@ -77,11 +75,16 @@ inline fun <reified T : Enum<T>> PreferenceStore.getEnum(
key: String,
defaultValue: T
): Preference<T> {
return getObject(key, defaultValue, { it.name }, {
try {
enumValueOf(it)
} catch (e: IllegalArgumentException) {
defaultValue
return getObject(
key,
defaultValue,
{ it.name },
{
try {
enumValueOf(it)
} catch (e: IllegalArgumentException) {
defaultValue
}
}
})
)
}

View File

@@ -95,5 +95,4 @@ internal class JvmPreference<T>(
override fun stateIn(scope: CoroutineScope): StateFlow<T> {
return changes().stateIn(scope, SharingStarted.Eagerly, get())
}
}

View File

@@ -87,7 +87,6 @@ internal class ObjectAdapter<T>(
override fun set(key: String, value: T, editor: ObservableSettings) {
editor.putString(key, serializer(value))
}
}
internal class JsonObjectAdapter<T>(
@@ -103,5 +102,4 @@ internal class JsonObjectAdapter<T>(
override fun set(key: String, value: T, editor: ObservableSettings) {
editor.encodeValue(serializer, key, value, serializersModule)
}
}

View File

@@ -82,5 +82,4 @@ class JvmPreferenceStore(private val preferences: ObservableSettings) : Preferen
val adapter = JsonObjectAdapter(defaultValue, serializer, serializersModule)
return JvmPreference(preferences, key, defaultValue, adapter)
}
}

View File

@@ -13,12 +13,12 @@ import java.util.prefs.Preferences
class PreferenceStoreFactory {
fun create(name: String? = null): PreferenceStore {
val userPreferences: Preferences = Preferences.userRoot()
val jvmPreferences = if (!name.isNullOrBlank()) {
JvmPreferencesSettings(Preferences.userRoot().node(name))
JvmPreferencesSettings(userPreferences.node(name))
} else {
JvmPreferencesSettings(Preferences.userRoot())
JvmPreferencesSettings(userPreferences)
}
return JvmPreferenceStore(jvmPreferences)
}
}

View File

@@ -45,7 +45,7 @@ class ServerService @Inject constructor(
val logger = KotlinLogging.logger("Server")
val runtime = Runtime.getRuntime()
val jarFile = File(userDataDir,"Tachidesk.jar")
val jarFile = File(userDataDir, "Tachidesk.jar")
if (!jarFile.exists()) {
logger.info { "Copying server to resources" }
javaClass.getResourceAsStream("/Tachidesk.jar")?.buffered()?.use { input ->
@@ -59,7 +59,7 @@ class ServerService @Inject constructor(
val javaExeFile = File(javaLibraryPath, "java.exe")
val javaUnixFile = File(javaLibraryPath, "java")
val javaExePath = when {
javaExeFile.exists() ->'"' + javaExeFile.absolutePath + '"'
javaExeFile.exists() -> '"' + javaExeFile.absolutePath + '"'
javaUnixFile.exists() -> '"' + javaUnixFile.absolutePath + '"'
else -> "java"
}
@@ -69,9 +69,11 @@ class ServerService @Inject constructor(
process = runtime.exec("""$javaExePath -jar "${jarFile.absolutePath}"""").also {
reader = it.inputStream.bufferedReader()
}
runtime.addShutdownHook(thread(start = false) {
process?.destroy()
})
runtime.addShutdownHook(
thread(start = false) {
process?.destroy()
}
)
logger.info { "Server started successfully" }
var line: String?
while (reader.readLine().also { line = it } != null) {
@@ -87,7 +89,6 @@ class ServerService @Inject constructor(
logger.info { "Server closed" }
val exitVal = process?.waitFor()
logger.info { "Process exitValue: $exitVal" }
}
}.launchIn(GlobalScope)
}

View File

@@ -29,7 +29,7 @@ import javax.inject.Inject
class CategoryInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getMangaCategories(mangaId: Long) = withContext(Dispatchers.IO) {
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) {
client.submitFormRepeat<HttpResponse>(
serverUrl + categoryModifyRequest(categoryId),
formParameters = Parameters.build {
if (name != null) {
append("name", name)
}
if (isLanding != null) {
append("isLanding", isLanding.toString())
}
formParameters = Parameters.build {
if (name != null) {
append("name", name)
}
if (isLanding != null) {
append("isLanding", isLanding.toString())
}
}
) {
method = HttpMethod.Patch

View File

@@ -20,7 +20,7 @@ import javax.inject.Inject
class ChapterInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getChapters(mangaId: Long) = withContext(Dispatchers.IO) {
client.getRepeat<List<Chapter>>(

View File

@@ -21,7 +21,7 @@ import javax.inject.Inject
class ExtensionInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getExtensionList() = withContext(Dispatchers.IO) {
client.getRepeat<List<Extension>>(

View File

@@ -20,7 +20,7 @@ import javax.inject.Inject
class LibraryInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getLibraryManga() = withContext(Dispatchers.IO) {
client.getRepeat<List<Manga>>(

View File

@@ -18,7 +18,7 @@ import javax.inject.Inject
class MangaInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getManga(mangaId: Long) = withContext(Dispatchers.IO) {
client.getRepeat<Manga>(
@@ -32,5 +32,4 @@ class MangaInteractionHandler @Inject constructor(
serverUrl + mangaThumbnailQuery(mangaId)
)
}
}

View File

@@ -25,7 +25,7 @@ import javax.inject.Inject
class SourceInteractionHandler @Inject constructor(
client: Http,
serverPreferences: ServerPreferences
): BaseInteractionHandler(client, serverPreferences) {
) : BaseInteractionHandler(client, serverPreferences) {
suspend fun getSourceList() = withContext(Dispatchers.IO) {
client.getRepeat<List<Source>>(
@@ -48,7 +48,8 @@ class SourceInteractionHandler @Inject constructor(
}
suspend fun getPopularManga(source: Source, pageNum: Int) = getPopularManga(
source.id, pageNum
source.id,
pageNum
)
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(
source.id, pageNum
source.id,
pageNum
)
// TODO: 2021-03-14
@@ -75,7 +77,9 @@ class SourceInteractionHandler @Inject constructor(
}
suspend fun getSearchResults(source: Source, searchTerm: String, pageNum: Int) = getSearchResults(
source.id, searchTerm, pageNum
source.id,
searchTerm,
pageNum
)
// TODO: 2021-03-14

View File

@@ -56,5 +56,4 @@ class UiPreferences(private val preferenceStore: PreferenceStore) {
fun dateFormat(): Preference<String> {
return preferenceStore.getString("date_format", "")
}
}

View File

@@ -12,9 +12,10 @@ import kotlinx.serialization.Serializable
@Serializable
enum class StartScreen {
Library,
Library,
// Updates,
// History,
Sources,
Extensions
Sources,
Extensions
}

View File

@@ -99,16 +99,20 @@ fun ColorPickerDialog(
val showPresetsState by showPresets.collectAsState()
val currentColorState by currentColor.collectAsState()
Row(Modifier.fillMaxWidth().padding(8.dp)) {
TextButton(onClick = {
showPresets.value = !showPresetsState
}) {
TextButton(
onClick = {
showPresets.value = !showPresetsState
}
) {
Text(if (showPresetsState) "Custom" else "Presets")
}
Spacer(Modifier.weight(1f))
TextButton(onClick = {
onSelected(currentColorState)
it.close()
}) {
TextButton(
onClick = {
onSelected(currentColorState)
it.close()
}
) {
Text("Select")
}
}
@@ -181,7 +185,8 @@ private fun ColorPresetItem(
onClick: () -> Unit
) {
Box(
contentAlignment = Alignment.Center, modifier = Modifier
contentAlignment = Alignment.Center,
modifier = Modifier
.fillMaxWidth()
.padding(4.dp)
.size(48.dp)
@@ -241,13 +246,15 @@ fun ColorPalette(
val saturationGradient = remember(hue, matrixSize) {
Brush.linearGradient(
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) {
Brush.linearGradient(
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 {
Text("") // TODO workaround: without this text, the color picker doesn't render correctly
Row(Modifier.height(IntrinsicSize.Max)) {
Box(Modifier
.aspectRatio(1f)
.weight(1f)
.onSizeChanged {
matrixSize = it
val hsv = selectedColor.toHsv()
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)
Box(
Modifier
.aspectRatio(1f)
.weight(1f)
.onSizeChanged {
matrixSize = it
val hsv = selectedColor.toHsv()
matrixCursor = satValToCoordinates(hsv[1], hsv[2], it)
hueCursor = hueToCoordinate(hue, it)
}
}
)
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))
}
.drawWithContent {
drawRect(brush = valueGradient)
drawRect(brush = saturationGradient, blendMode = BlendMode.Multiply)
drawRect(Color.LightGray, size = size, style = borderStroke)
drawRect(
cursorColor,
topLeft = cursorTopLeft,
size = cursorSize,
drawCircle(
Color.Black,
radius = 8f,
center = matrixCursor,
style = cursorStroke
)
drawCircle(
Color.LightGray,
radius = 12f,
center = matrixCursor,
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)
.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)
}
}
)
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) {
@@ -451,4 +460,3 @@ private val presetColors = listOf(
Color(0xFF607D8B), // BLUE GREY 500
Color(0xFF9E9E9E), // GREY 500
)

View File

@@ -36,8 +36,8 @@ fun Toolbar(
closable: Boolean,
modifier: Modifier = Modifier,
actions: @Composable RowScope.() -> Unit = {},
backgroundColor: Color = MaterialTheme.colors.primary, //CustomColors.current.bars,
contentColor: Color = MaterialTheme.colors.onPrimary, //CustomColors.current.onBars,
backgroundColor: Color = MaterialTheme.colors.primary, // CustomColors.current.bars,
contentColor: Color = MaterialTheme.colors.onPrimary, // CustomColors.current.onBars,
elevation: Dp = AppBarDefaults.TopAppBarElevation,
search: ((String) -> Unit)? = null
) {

View File

@@ -139,9 +139,12 @@ fun EditTextPreference(
preference.value = editText.text
}
) {
OutlinedTextField(editText, onValueChange = {
editText = it
})
OutlinedTextField(
editText,
onValueChange = {
editText = it
}
)
}
}
)
@@ -177,31 +180,37 @@ private fun <T> ChoiceDialog(
onDismissRequest: () -> Unit = {},
onSelected: (T) -> Unit,
title: String,
buttons: @Composable (AppWindow) -> Unit = { }
buttons: @Composable (AppWindow) -> Unit = { }
) {
WindowDialog(onDismissRequest = onDismissRequest, buttons = buttons, title = title, content = {
LazyColumn {
items(items) { (value, text) ->
Row(
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable(
onClick = {
onSelected(value)
it.close()
}),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = value == selected,
onClick = {
onSelected(value)
it.close()
},
)
Text(text = text, modifier = Modifier.padding(start = 24.dp))
WindowDialog(
onDismissRequest = onDismissRequest,
buttons = buttons,
title = title,
content = {
LazyColumn {
items(items) { (value, text) ->
Row(
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable(
onClick = {
onSelected(value)
it.close()
}
),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = value == selected,
onClick = {
onSelected(value)
it.close()
},
)
Text(text = text, modifier = Modifier.padding(start = 24.dp))
}
}
}
}
})
)
}
@Composable

View File

@@ -19,11 +19,13 @@ data class Theme(
val themes = listOf(
// Pure white
Theme(
1, lightColors()
1,
lightColors()
),
// Tachiyomi 0.x default colors
Theme(
2, lightColors(
2,
lightColors(
primary = Color(0xFF2979FF),
primaryVariant = Color(0xFF2979FF),
onPrimary = Color.White,
@@ -34,11 +36,13 @@ val themes = listOf(
),
// Tachiyomi 0.x dark theme
Theme(
3, darkColors()
3,
darkColors()
),
// AMOLED theme
Theme(
4, darkColors(
4,
darkColors(
primary = Color.Black,
onPrimary = Color.White,
background = Color.Black

View File

@@ -142,12 +142,16 @@ private fun CategoryRow(
}
Spacer(modifier = Modifier.weight(1f))
IconButton(onClick = onRename) {
Icon(imageVector = Icons.Default.Edit,
contentDescription = null)
Icon(
imageVector = Icons.Default.Edit,
contentDescription = null
)
}
IconButton(onClick = onDelete) {
Icon(imageVector = Icons.Default.Delete,
contentDescription = null)
Icon(
imageVector = Icons.Default.Delete,
contentDescription = null
)
}
}
}

View File

@@ -123,7 +123,6 @@ fun ExtensionItem(
}
}
}
}
Button(
{

View File

@@ -22,7 +22,7 @@ class ExtensionsMenuViewModel @Inject constructor(
private val extensionHandler: ExtensionInteractionHandler,
serverPreferences: ServerPreferences,
private val extensionPreferences: ExtensionPreferences
): ViewModel() {
) : ViewModel() {
private val logger = KotlinLogging.logger {}
val serverUrl = serverPreferences.server().stateIn(scope)
@@ -33,7 +33,6 @@ class ExtensionsMenuViewModel @Inject constructor(
private val _isLoading = MutableStateFlow(true)
val isLoading = _isLoading.asStateFlow()
init {
scope.launch {
getExtensions()

View File

@@ -50,12 +50,11 @@ fun LibraryScreen(onClickManga: (Long) -> Unit = { openMangaMenu(it) }) {
val displayMode by vm.displayMode.collectAsState()
val isLoading by vm.isLoading.collectAsState()
val serverUrl by vm.serverUrl.collectAsState()
//val sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
// val sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
if (categories.isEmpty()) {
LoadingScreen(isLoading)
} else {
/*ModalBottomSheetLayout(
sheetState = sheetState,
sheetContent = { *//*LibrarySheet()*//* }
@@ -77,7 +76,7 @@ fun LibraryScreen(onClickManga: (Long) -> Unit = { openMangaMenu(it) }) {
}
)*/
LibraryTabs(
visible = true, //vm.showCategoryTabs,
visible = true, // vm.showCategoryTabs,
categories = categories,
selectedPage = selectedCategoryIndex,
onPageChanged = vm::setSelectedPage

View File

@@ -35,7 +35,7 @@ class LibraryScreenViewModel @Inject constructor(
private val categoryHandler: CategoryInteractionHandler,
libraryPreferences: LibraryPreferences,
serverPreferences: ServerPreferences,
): ViewModel() {
) : ViewModel() {
val serverUrl = serverPreferences.server().stateIn(scope)
private val library = Library(MutableStateFlow(emptyList()), mutableMapOf())
@@ -78,7 +78,6 @@ class LibraryScreenViewModel @Inject constructor(
}
}
fun setSelectedPage(page: Int) {
_selectedCategoryIndex.value = page
}
@@ -88,8 +87,6 @@ class LibraryScreenViewModel @Inject constructor(
}
companion object {
val defaultCategory = Category(0, 0, "Default",true)
val defaultCategory = Category(0, 0, "Default", true)
}
}

View File

@@ -70,11 +70,12 @@ private fun LibraryMangaCompactGridItem(
TextStyle(letterSpacing = 0.sp, fontFamily = FontFamily.SansSerif, fontSize = 14.sp)
)
Box(modifier = Modifier.padding(4.dp)
.fillMaxWidth()
.aspectRatio(3f / 4f)
.clip(MaterialTheme.shapes.medium)
.clickable(onClick = onClick)
Box(
modifier = Modifier.padding(4.dp)
.fillMaxWidth()
.aspectRatio(3f / 4f)
.clip(MaterialTheme.shapes.medium)
.clickable(onClick = onClick)
) {
if (cover != null) {
KtorImage(cover, contentScale = ContentScale.Crop)

View File

@@ -58,7 +58,6 @@ import compose.icons.fontawesomeicons.regular.Map
fun MainMenu() {
val vm = viewModel<MainViewModel>()
Surface {
Router<Route>("TopLevel", Route.Library) { backStack ->
Row {
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) {
Color.Transparent
} else {
MaterialTheme.colors.primary.copy(0.30F)
MaterialTheme.colors.primary.copy(0.30F)
},
contentColor = Color.Transparent,
elevation = 0.dp
@@ -160,18 +158,20 @@ sealed class Route {
object Library : Route()
object Sources : Route()
object Extensions : Route()
data class Manga(val mangaId: Long): Route()
data class Manga(val mangaId: Long) : Route()
object Settings : Route()
object SettingsGeneral : Route()
object SettingsAppearance : Route()
object SettingsLibrary : Route()
object SettingsReader : Route()
/*object SettingsDownloads : Route()
object SettingsTracking : Route()*/
object SettingsBrowse : Route()
object SettingsBackup : Route()
object SettingsServer : Route()
/*object SettingsSecurity : Route()
object SettingsParentalControls : Route()*/
object SettingsAdvanced : Route()

View File

@@ -12,6 +12,6 @@ import javax.inject.Inject
class MainViewModel @Inject constructor(
uiPreferences: UiPreferences
): ViewModel() {
) : ViewModel() {
val startScreen = uiPreferences.startScreen().get()
}

View File

@@ -153,9 +153,9 @@ private fun Cover(manga: Manga, serverUrl: String, modifier: Modifier = Modifier
}
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

View File

@@ -91,7 +91,6 @@ class MangaMenuViewModel @Inject constructor(
refreshMangaAsync(it.id).await()
}
}
}
private fun getDateFormat(format: String): DateFormat = when (format) {

View File

@@ -80,7 +80,7 @@ fun SettingsAppearance(navController: BackStack<Route>) {
ChoicePreference(
preference = vm.themeMode,
choices = mapOf(
//ThemeMode.System to R.string.follow_system_settings,
// ThemeMode.System to R.string.follow_system_settings,
ThemeMode.Light to "Light",
ThemeMode.Dark to "Dark"
),
@@ -94,24 +94,29 @@ fun SettingsAppearance(navController: BackStack<Route>) {
)
LazyRow(modifier = Modifier.padding(horizontal = 8.dp)) {
items(themesForCurrentMode) { theme ->
ThemeItem(theme, onClick = {
(if (isLight) vm.lightTheme else vm.darkTheme).value = it.id
activeColors.primaryStateFlow.value = it.colors.primary
activeColors.secondaryStateFlow.value = it.colors.secondary
})
ThemeItem(
theme,
onClick = {
(if (isLight) vm.lightTheme else vm.darkTheme).value = it.id
activeColors.primaryStateFlow.value = it.colors.primary
activeColors.secondaryStateFlow.value = it.colors.secondary
}
)
}
}
}
item {
ColorPreference(
preference = activeColors.primaryStateFlow, title = "Color primary",
preference = activeColors.primaryStateFlow,
title = "Color primary",
subtitle = "Displayed most frequently across your app",
unsetColor = MaterialTheme.colors.primary
)
}
item {
ColorPreference(
preference = activeColors.secondaryStateFlow, title = "Color secondary",
preference = activeColors.secondaryStateFlow,
title = "Color secondary",
subtitle = "Accents select parts of the UI",
unsetColor = MaterialTheme.colors.secondary
)
@@ -132,7 +137,9 @@ private fun ThemeItem(
Color.White.copy(alpha = 0.15f)
}
Surface(
elevation = 4.dp, color = theme.colors.background, shape = borders,
elevation = 4.dp,
color = theme.colors.background,
shape = borders,
modifier = Modifier
.size(100.dp, 160.dp)
.padding(8.dp)
@@ -159,9 +166,10 @@ private fun ThemeItem(
disabledBackgroundColor = theme.colors.primary
)
)
Surface(Modifier
.size(24.dp)
.align(Alignment.BottomEnd),
Surface(
Modifier
.size(24.dp)
.align(Alignment.BottomEnd),
shape = MaterialTheme.shapes.small.copy(CornerSize(percent = 50)),
color = theme.colors.secondary,
elevation = 6.dp,

View File

@@ -23,7 +23,7 @@ import javax.inject.Inject
class SettingsServerViewModel @Inject constructor(
private val serverPreferences: ServerPreferences
): ViewModel() {
) : ViewModel() {
val host = serverPreferences.host().asStateIn(scope)
val serverUrl = serverPreferences.server().asStateIn(scope)
}

View File

@@ -86,7 +86,6 @@ fun SourcesMenu(bundle: Bundle, onMangaClick: (Long) -> Unit) {
}
}
val selectedSource: Source? = selectedSourceTab
BundleScope("Sources") {
if (selectedSource != null) {

View File

@@ -27,7 +27,7 @@ class SourcesMenuViewModel @Inject constructor(
private val sourceHandler: SourceInteractionHandler,
serverPreferences: ServerPreferences,
catalogPreferences: CatalogPreferences
): ViewModel() {
) : ViewModel() {
private val logger = KotlinLogging.logger {}
val serverUrl = serverPreferences.server().stateIn(scope)

View File

@@ -95,7 +95,6 @@ fun SourceCategory(
}
}
@Composable
fun SourceItem(
source: Source,

View File

@@ -95,7 +95,6 @@ private fun MangaTable(
}
}
LazyVerticalGrid(GridCells.Adaptive(160.dp)) {
items(mangas) { manga ->
MangaGridItem(

View File

@@ -28,7 +28,7 @@ class SourceScreenViewModel @Inject constructor(
private val sourceHandler: SourceInteractionHandler,
private val mangaHandler: MangaInteractionHandler,
serverPreferences: ServerPreferences
): ViewModel() {
) : ViewModel() {
private lateinit var source: Source
private lateinit var bundle: Bundle
@@ -99,7 +99,7 @@ class SourceScreenViewModel @Inject constructor(
}
fun setMode(toLatest: Boolean) {
if (isLatest.value != toLatest){
if (isLatest.value != toLatest) {
_isLatest.value = toLatest
bundle.remove(MANGAS_KEY)
bundle.remove(NEXT_PAGE_KEY)

View File

@@ -13,7 +13,7 @@ fun processFile() {
val strTmp = System.getProperty("java.io.tmpdir")
val file = File("$strTmp/TachideskJUI.pid")
//backup deletion
// backup deletion
if (file.exists()) {
file.delete()
}

View File

@@ -4,9 +4,7 @@ import kotlin.test.Test
class ExtensionInteractionTest {
@Test
fun `Install a extension`() {
}
}