Stateful listThumbSize
This commit is contained in:
1 parent
116dbead4b
commit
71ebd99115
7 files changed
+20
-13
No files matched your search
@@ -104,6 +104,7 @@ object Settings : DataStorePreferences(null) {
|
||||
val listMode = intPref("list_mode_2", 0)
|
||||
val detailSize = intPref("detail_size_2", 0)
|
||||
val thumbSizeDp = intPref("thumb_size_", 120)
|
||||
val listThumbSize = intPref("list_tile_size", 40)
|
||||
|
||||
val needSignInFlow: Flow<Boolean>
|
||||
var downloadScheme by stringOrNullPref("image_scheme", null)
|
||||
@@ -150,7 +151,6 @@ object Settings : DataStorePreferences(null) {
|
||||
var defaultFavSlot by intPref("default_favorite_slot", -2)
|
||||
var securityDelay by intPref("require_unlock_delay", 0)
|
||||
var clipboardTextHashCode by intPref("clipboard_text_hash_code", 0)
|
||||
var listThumbSize by intPref("list_tile_size", 40)
|
||||
var searchCategory by intPref("search_pref", EhUtils.ALL_CATEGORY)
|
||||
var requestNewsTimerHour by intPref("request_news_timer_hour", -1)
|
||||
var requestNewsTimerMinute by intPref("request_news_timer_minute", -1)
|
||||
|
||||
@@ -83,7 +83,6 @@ import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.Settings.detailSize
|
||||
import com.hippo.ehviewer.Settings.listThumbSize
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.coil.read
|
||||
@@ -119,7 +118,6 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -719,6 +717,7 @@ class DownloadsScene : SearchBarScene() {
|
||||
binding.start.setOnClickListener(this)
|
||||
binding.stop.setOnClickListener(this)
|
||||
binding.thumb.setMD3Content {
|
||||
val height by collectListThumbSizeAsState()
|
||||
Spacer(modifier = Modifier.height(height).fillMaxWidth())
|
||||
}
|
||||
binding.handle.setOnTouchListener { _, event ->
|
||||
@@ -765,11 +764,10 @@ class DownloadsScene : SearchBarScene() {
|
||||
}
|
||||
}
|
||||
|
||||
private val height = (3 * listThumbSize * 3).pxToDp.dp
|
||||
|
||||
fun bind(info: DownloadInfo, isChecked: Boolean) {
|
||||
binding.root.isChecked = isChecked
|
||||
binding.thumb.setMD3Content {
|
||||
val height by collectListThumbSizeAsState()
|
||||
Card(onClick = ::onClick.partially1(binding.thumb)) {
|
||||
CompanionAsyncThumb(
|
||||
info = info,
|
||||
|
||||
@@ -112,7 +112,6 @@ import com.hippo.ehviewer.util.findActivity
|
||||
import com.hippo.ehviewer.util.mapToLongArray
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import java.time.Instant
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
@@ -301,7 +300,7 @@ fun FavouritesScreen(navigator: NavController) {
|
||||
val listMode by Settings.listMode.collectAsState()
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
if (listMode == 0) {
|
||||
val height = (3 * Settings.listThumbSize * 3).pxToDp.dp
|
||||
val height by collectListThumbSizeAsState()
|
||||
val showPages = Settings.showGalleryPages
|
||||
val columnWidth by collectDetailSizeAsState()
|
||||
FastScrollLazyVerticalGrid(
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import com.hippo.ehviewer.R
|
||||
@@ -42,3 +43,14 @@ fun collectDetailSizeAsState(): State<Dp> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Stable
|
||||
fun collectListThumbSizeAsState(): State<Dp> {
|
||||
val density = LocalDensity.current
|
||||
return Settings.listThumbSize.collectAsState {
|
||||
with(density) {
|
||||
it.toDp() * 9
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,6 @@ import com.ramcosta.composedestinations.annotation.Destination
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import java.io.File
|
||||
import java.time.Instant
|
||||
import java.time.LocalDateTime
|
||||
@@ -842,7 +841,7 @@ fun GalleryListScreen(lub: ListUrlBuilder, navigator: NavController) {
|
||||
}
|
||||
}
|
||||
if (listMode == 0) {
|
||||
val height = (3 * Settings.listThumbSize * 3).pxToDp.dp
|
||||
val height by collectListThumbSizeAsState()
|
||||
val showPages = Settings.showGalleryPages
|
||||
val columnWidth by collectDetailSizeAsState()
|
||||
FastScrollLazyVerticalGrid(
|
||||
|
||||
@@ -41,6 +41,7 @@ import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberDismissState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -63,7 +64,6 @@ import androidx.paging.compose.itemKey
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.Settings.listThumbSize
|
||||
import com.hippo.ehviewer.icons.EhIcons
|
||||
import com.hippo.ehviewer.icons.big.History
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
@@ -78,7 +78,6 @@ import com.hippo.ehviewer.ui.tools.rememberInVM
|
||||
import com.hippo.ehviewer.util.findActivity
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@Destination
|
||||
@@ -120,7 +119,7 @@ fun HistoryScreen(navigator: NavController) {
|
||||
)
|
||||
},
|
||||
) { paddingValues ->
|
||||
val cardHeight = remember { (3 * listThumbSize * 3).pxToDp.dp }
|
||||
val cardHeight by collectListThumbSizeAsState()
|
||||
FastScrollLazyColumn(
|
||||
modifier = Modifier.padding(horizontal = dimensionResource(id = R.dimen.gallery_list_margin_h)),
|
||||
contentPadding = paddingValues,
|
||||
|
||||
@@ -244,7 +244,7 @@ fun EhScreen(navigator: DestinationsNavigator) {
|
||||
minValue = 20,
|
||||
step = 7,
|
||||
title = stringResource(id = R.string.list_tile_thumb_size),
|
||||
value = Settings::listThumbSize,
|
||||
value = Settings.listThumbSize::value,
|
||||
)
|
||||
SimpleMenuPreferenceInt(
|
||||
title = stringResource(id = R.string.settings_eh_detail_size),
|
||||
|
||||
Reference in new issue
Block a user