Skip to content

Avoid reusing screen scoped dimens#195

Merged
Goooler merged 1 commit intotrunkfrom
dont-reuse-dimens
May 6, 2026
Merged

Avoid reusing screen scoped dimens#195
Goooler merged 1 commit intotrunkfrom
dont-reuse-dimens

Conversation

@Goooler
Copy link
Copy Markdown
Owner

@Goooler Goooler commented May 6, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces reliance on globally-scoped theme dimension tokens by trimming MihomoDimens down to only the shared/common spacing values, and migrating screen-specific spacing/sizing to local dp constants (or inlined values) within each screen.

Changes:

  • Shrink MihomoDimens/DefaultMihomoDimens to a minimal set of common tokens and remove unused imports.
  • Replace removed mihomoDimens.* usages across Settings, Proxy, Profile, Log, and Home UI with local dp values/constants.
  • Introduce a few screen-local constants (e.g., gridContentPadding, Home layout constants) to keep spacing readable after the theme token removal.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ui/src/main/kotlin/com/github/kr328/clash/ui/theme/Theme.kt Removes many screen-specific dimension tokens from MihomoDimens, keeping only shared/common ones.
ui/settings/src/main/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt Replaces dialog button bar padding from theme dimens with local dp values.
ui/settings/src/main/kotlin/com/github/kr328/clash/settings/ui/EditableTextListScreen.kt Same as above; adds required dp import and uses local padding values.
ui/proxy/src/main/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt Replaces proxy layout sizing/padding tokens with local values and adds gridContentPadding.
ui/profile/src/main/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt Replaces removed middle-margin/divider/trailing-size tokens with local dp values.
ui/profile/src/main/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt Replaces toolbar action progress sizing and horizontal content padding with local dp values.
ui/profile/src/main/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt Replaces toolbar progress sizing and middle-margin spacing with local dp values.
ui/log/src/main/kotlin/com/github/kr328/clash/log/ui/LogcatScreen.kt Replaces log message padding tokens with a local dp value.
ui/home/src/main/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt Replaces home screen spacing tokens with file-local constants for reuse within the screen.
Comments suppressed due to low confidence (1)

ui/profile/src/main/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt:317

  • Several layout values here (e.g., 10.dp padding around the updated-at text and 1.dp divider width) are now raw numbers. To improve readability and make later design adjustments safer, consider introducing named constants local to this screen (similar to what was done in HomeScreen) for these spacing tokens.
      Text(
        text = (currentTime - profile.updatedAt).elapsedIntervalString(context),
        style = MaterialTheme.typography.labelSmall,
        modifier = Modifier.padding(horizontal = 10.dp),
      )

      Box(
        modifier =
          Modifier.width(1.dp).height(itemMinHeight).background(MaterialTheme.colorScheme.outline)
      )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 148 to 150
if (processing) {
CircularProgressIndicator(
modifier = Modifier.size(dimens.itemTrailingComponentSize / 2),
strokeWidth = dimens.toolbarImageActionPadding / 2,
)
CircularProgressIndicator(modifier = Modifier.size(15.dp), strokeWidth = 2.5.dp)
} else {
Comment on lines 201 to 204
IconButton(onClick = onUpdateAll, enabled = !allUpdating) {
if (allUpdating) {
val dimens = mihomoDimens
CircularProgressIndicator(
modifier = Modifier.size(dimens.itemTrailingComponentSize / 2),
strokeWidth = dimens.toolbarImageActionPadding / 2,
)
CircularProgressIndicator(modifier = Modifier.size(15.dp), strokeWidth = 2.5.dp)
} else {
Comment on lines 145 to 161
@@ -158,10 +157,7 @@ private fun ProviderItem(state: ProviderItemState, currentTime: Long, onUpdate:
modifier = Modifier.padding(horizontal = 4.dp),
) {
if (state.updating) {
CircularProgressIndicator(
modifier = Modifier.size(dimens.itemTrailingComponentSize),
strokeWidth = 2.dp,
)
CircularProgressIndicator(modifier = Modifier.size(30.dp), strokeWidth = 2.dp)
} else {
@Goooler Goooler force-pushed the dont-reuse-dimens branch from 67a09d3 to b1d5bc9 Compare May 6, 2026 10:36
@Goooler Goooler enabled auto-merge (squash) May 6, 2026 10:36
@Goooler Goooler merged commit eb02d0e into trunk May 6, 2026
3 checks passed
@Goooler Goooler deleted the dont-reuse-dimens branch May 6, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants