Redesign Vote Status (#1970)
* Redesign Vote Status * Revert "Redesign Vote Status" This reverts commit 00295652f8eab9f91c1ef0ec1356e8eff838aaef. * Redesign Vote Status * Refine --------- Co-authored-by: Dude so hot <djohn@fbi.gov>
This commit is contained in:
1 parent
f52b828fe1
commit
d0c150d419
4 files changed
+32
-16
No files matched your search
@@ -130,8 +130,8 @@ object Settings : DataStorePreferences(null) {
|
||||
val displayName = stringOrNullPref("display_name", null)
|
||||
val avatar = stringOrNullPref("avatar", null)
|
||||
val recentDownloadLabel = stringOrNullPref("recent_download_label", null)
|
||||
val showVoteStatus = boolPref("show_vote_status", false)
|
||||
|
||||
var showVoteStatus by boolPref("show_vote_status", false)
|
||||
var downloadScheme by stringOrNullPref("image_scheme", null)
|
||||
var downloadAuthority by stringOrNullPref("image_authority", null)
|
||||
var downloadPath by stringOrNullPref("image_path", null)
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.hippo.ehviewer.client.data
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
enum class VoteStatus(val append: String) {
|
||||
enum class VoteStatus(val display: String) {
|
||||
NONE(""),
|
||||
UP("↑"),
|
||||
DOWN("↓"),
|
||||
UP("+1"),
|
||||
DOWN("-1"),
|
||||
}
|
||||
|
||||
enum class PowerStatus {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hippo.ehviewer.ui.main
|
||||
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
@@ -12,17 +13,21 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.EhTagDatabase
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup
|
||||
import com.hippo.ehviewer.client.data.PowerStatus
|
||||
import com.hippo.ehviewer.client.data.TagNamespace
|
||||
import com.hippo.ehviewer.client.data.VoteStatus
|
||||
import com.hippo.ehviewer.collectAsState
|
||||
import com.hippo.ehviewer.ui.tools.includeFontPadding
|
||||
|
||||
@Composable
|
||||
@@ -37,6 +42,7 @@ fun GalleryTags(
|
||||
val ehTags = EhTagDatabase.takeIf { canTranslate }
|
||||
fun TagNamespace.translate() = ehTags?.getTranslation(tag = value) ?: value
|
||||
fun String.translate(ns: TagNamespace) = ehTags?.getTranslation(prefix = ns.prefix, tag = this) ?: this
|
||||
val showVote by Settings.showVoteStatus.collectAsState()
|
||||
Column(modifier) {
|
||||
tagGroups.forEach { (ns, tags) ->
|
||||
Row {
|
||||
@@ -49,17 +55,27 @@ fun GalleryTags(
|
||||
val translation = text.translate(ns)
|
||||
val tag = ns.value + ":" + text
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
BaseRoundText(
|
||||
text = if (Settings.showVoteStatus) translation + vote.append else translation,
|
||||
weak = power == PowerStatus.WEAK,
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = { onTagClick(tag) },
|
||||
onLongClick = {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onTagLongClick(tag, translation, vote)
|
||||
},
|
||||
),
|
||||
)
|
||||
Box {
|
||||
BaseRoundText(
|
||||
text = translation,
|
||||
weak = power == PowerStatus.WEAK,
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = { onTagClick(tag) },
|
||||
onLongClick = {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onTagLongClick(tag, translation, vote)
|
||||
},
|
||||
),
|
||||
)
|
||||
if (vote != VoteStatus.NONE && showVote) {
|
||||
Text(
|
||||
text = vote.display,
|
||||
modifier = Modifier.align(Alignment.TopEnd).padding(horizontal = 2.dp),
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
style = MaterialTheme.typography.labelSmallEmphasized.copy(fontSize = 10.sp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ fun EhScreen(navigator: DestinationsNavigator) {
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(id = R.string.settings_eh_show_vote_status),
|
||||
value = Settings::showVoteStatus,
|
||||
value = Settings.showVoteStatus::value,
|
||||
)
|
||||
val showComments = Settings::showComments.observed
|
||||
SwitchPreference(
|
||||
|
||||
Reference in new issue
Block a user