Skip to content

Commit

Permalink
feat(ThemeDialog): add option icons
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Feb 10, 2025
1 parent 4aabe9f commit 5554e1d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.aliucord.manager.R
import com.google.accompanist.systemuicontroller.rememberSystemUiController
Expand Down Expand Up @@ -67,4 +68,11 @@ enum class Theme {
LIGHT -> stringResource(R.string.theme_light)
DARK -> stringResource(R.string.theme_dark)
}

@Composable
fun toPainter() = when (this) {
SYSTEM -> painterResource(R.drawable.ic_sync)
LIGHT -> painterResource(R.drawable.ic_light)
DARK -> painterResource(R.drawable.ic_night)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.aliucord.manager.R
import com.aliucord.manager.ui.components.Theme

Expand Down Expand Up @@ -49,9 +50,18 @@ fun ThemeDialog(
.clip(MaterialTheme.shapes.medium)
.padding(horizontal = 6.dp, vertical = 8.dp),
) {
Icon(
painter = theme.toPainter(),
contentDescription = null,
modifier = Modifier
.padding(end = 14.dp)
.size(26.dp),
)

Text(
text = theme.toDisplayName(),
style = MaterialTheme.typography.labelLarge,
style = MaterialTheme.typography.labelLarge
.copy(fontSize = 14.sp)
)

Spacer(Modifier.Companion.weight(1f, true))
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_light.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#e8eaed"
android:pathData="M480,680q-83,0 -141.5,-58.5T280,480q0,-83 58.5,-141.5T480,280q83,0 141.5,58.5T680,480q0,83 -58.5,141.5T480,680ZM80,520q-17,0 -28.5,-11.5T40,480q0,-17 11.5,-28.5T80,440h80q17,0 28.5,11.5T200,480q0,17 -11.5,28.5T160,520L80,520ZM800,520q-17,0 -28.5,-11.5T760,480q0,-17 11.5,-28.5T800,440h80q17,0 28.5,11.5T920,480q0,17 -11.5,28.5T880,520h-80ZM480,200q-17,0 -28.5,-11.5T440,160v-80q0,-17 11.5,-28.5T480,40q17,0 28.5,11.5T520,80v80q0,17 -11.5,28.5T480,200ZM480,920q-17,0 -28.5,-11.5T440,880v-80q0,-17 11.5,-28.5T480,760q17,0 28.5,11.5T520,800v80q0,17 -11.5,28.5T480,920ZM226,282l-43,-42q-12,-11 -11.5,-28t11.5,-29q12,-12 29,-12t28,12l42,43q11,12 11,28t-11,28q-11,12 -27.5,11.5T226,282ZM720,777 L678,734q-11,-12 -11,-28.5t11,-27.5q11,-12 27.5,-11.5T734,678l43,42q12,11 11.5,28T777,777q-12,12 -29,12t-28,-12ZM678,282q-12,-11 -11.5,-27.5T678,226l42,-43q11,-12 28,-11.5t29,11.5q12,12 12,29t-12,28l-43,42q-12,11 -28,11t-28,-11ZM183,777q-12,-12 -12,-29t12,-28l43,-42q12,-11 28.5,-11t27.5,11q12,11 11.5,27.5T282,734l-42,43q-11,12 -28,11.5T183,777Z" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_night.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#e8eaed"
android:pathData="M480,840q-151,0 -255.5,-104.5T120,480q0,-138 90,-239.5T440,122q13,-2 23,3.5t16,14.5q6,9 6.5,21t-7.5,23q-17,26 -25.5,55t-8.5,61q0,90 63,153t153,63q31,0 61.5,-9t54.5,-25q11,-7 22.5,-6.5T819,481q10,5 15.5,15t3.5,24q-14,138 -117.5,229T480,840Z" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_sync.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#e8eaed"
android:pathData="M240,482q0,45 17,87.5t53,78.5l10,10v-58q0,-17 11.5,-28.5T360,560q17,0 28.5,11.5T400,600v160q0,17 -11.5,28.5T360,800L200,800q-17,0 -28.5,-11.5T160,760q0,-17 11.5,-28.5T200,720h70l-16,-14q-52,-46 -73,-105t-21,-119q0,-94 48,-170.5T337,194q14,-8 29.5,-1t20.5,23q5,15 -0.5,30T367,269q-58,32 -92.5,88.5T240,482ZM720,478q0,-45 -17,-87.5T650,312l-10,-10v58q0,17 -11.5,28.5T600,400q-17,0 -28.5,-11.5T560,360v-160q0,-17 11.5,-28.5T600,160h160q17,0 28.5,11.5T800,200q0,17 -11.5,28.5T760,240h-70l16,14q49,49 71.5,106.5T800,478q0,94 -48,170.5T623,766q-14,8 -29.5,1T573,744q-5,-15 0.5,-30t19.5,-23q58,-32 92.5,-88.5T720,478Z" />
</vector>

0 comments on commit 5554e1d

Please sign in to comment.