Skip to content

Commit

Permalink
Add section in settings to edit TextBadge corner radius
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmvncnt committed Jun 8, 2023
1 parent 180467b commit f9222a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/src/main/java/com/jerboa/db/AppDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.coroutines.launch
import java.util.concurrent.Executors

const val DEFAULT_FONT_SIZE = 16
const val DEFAULT_OP_COMMENT_BADGE_RADIUS = 4
const val UPDATE_APP_CHANGELOG_UNVIEWED = "UPDATE AppSettings SET viewed_changelog = 0"

@Entity
Expand Down Expand Up @@ -74,6 +75,11 @@ data class AppSettings(
defaultValue = "0",
)
val showCollapsedCommentContent: Boolean,
@ColumnInfo(
name = "op_comment_badge_radius",
defaultValue = DEFAULT_OP_COMMENT_BADGE_RADIUS.toString(),
)
val opCommentBadgeRadius: Int
)

@Dao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.jerboa.ThemeMode
import com.jerboa.db.AppSettings
import com.jerboa.db.AppSettingsViewModel
import com.jerboa.db.DEFAULT_FONT_SIZE
import com.jerboa.db.DEFAULT_OP_COMMENT_BADGE_RADIUS
import com.jerboa.ui.components.common.SimpleTopAppBar

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -49,7 +50,10 @@ fun LookAndFeelActivity(
val showBottomNavState = rememberBooleanSettingState(settings?.showBottomNav ?: true)
val showCollapsedCommentContentState =
rememberBooleanSettingState(settings?.showCollapsedCommentContent ?: false)

val opCommentBadgeRadiusState = rememberFloatSettingState(
settings?.opCommentBadgeRadius?.toFloat()
?: DEFAULT_OP_COMMENT_BADGE_RADIUS.toFloat(),
)
val snackbarHostState = remember { SnackbarHostState() }

fun updateAppSettings() {
Expand All @@ -63,6 +67,7 @@ fun LookAndFeelActivity(
postViewMode = postViewModeState.value,
showBottomNav = showBottomNavState.value,
showCollapsedCommentContent = showCollapsedCommentContentState.value,
opCommentBadgeRadius = opCommentBadgeRadiusState.value.toInt(),
),
)
}
Expand Down Expand Up @@ -154,6 +159,20 @@ fun LookAndFeelActivity(
},
onCheckedChange = { updateAppSettings() },
)
SettingsSlider(
valueRange = 0f..20f,
state = opCommentBadgeRadiusState,
icon = {
Icon(
imageVector = Icons.Outlined.FormatSize,
contentDescription = "TODO",
)
},
title = {
Text(text = "OP comment badge radius: ${opCommentBadgeRadiusState.value.toInt()}")
},
onValueChangeFinished = { updateAppSettings() },
)
}
},
)
Expand Down

0 comments on commit f9222a2

Please sign in to comment.