mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix: Improve ThemeSelector
This commit is contained in:
parent
0fb341ffb9
commit
c994a47d8a
@ -7,14 +7,18 @@ import androidx.compose.foundation.layout.Arrangement
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material.icons.filled.Mic
|
import androidx.compose.material.icons.filled.Mic
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@ -31,68 +35,90 @@ import kotlinx.coroutines.launch
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Preview(
|
fun Preview(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
primaryColor: Color,
|
primaryColor: Color,
|
||||||
textColor: Color,
|
textColor: Color,
|
||||||
onSelect: () -> Unit,
|
onSelect: () -> Unit,
|
||||||
|
isSelected: Boolean = false,
|
||||||
) {
|
) {
|
||||||
Column(
|
Box(
|
||||||
modifier = Modifier
|
modifier = modifier,
|
||||||
.width(100.dp)
|
contentAlignment = Alignment.Center,
|
||||||
.height(200.dp)
|
|
||||||
.clip(shape = RoundedCornerShape(10.dp))
|
|
||||||
.border(width = 1.dp, color = textColor, shape = RoundedCornerShape(10.dp))
|
|
||||||
.background(backgroundColor)
|
|
||||||
.clickable { onSelect() },
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
verticalArrangement = Arrangement.SpaceBetween,
|
|
||||||
) {
|
) {
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(10.dp)
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.width(30.dp)
|
|
||||||
.height(10.dp)
|
|
||||||
.clip(shape = RoundedCornerShape(10.dp))
|
|
||||||
.background(primaryColor)
|
|
||||||
)
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.width(10.dp)
|
|
||||||
.height(10.dp)
|
|
||||||
.clip(shape = RoundedCornerShape(10.dp))
|
|
||||||
.background(primaryColor)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(100.dp)
|
||||||
|
.height(200.dp)
|
||||||
|
.clip(shape = RoundedCornerShape(10.dp))
|
||||||
|
.border(width = 1.dp, color = textColor, shape = RoundedCornerShape(10.dp))
|
||||||
|
.background(backgroundColor)
|
||||||
|
.clickable { onSelect() },
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
verticalArrangement = Arrangement.SpaceBetween,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Row(
|
||||||
Icons.Default.Mic,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
contentDescription = null,
|
|
||||||
tint = primaryColor,
|
|
||||||
)
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(40.dp)
|
.fillMaxWidth()
|
||||||
.height(6.dp)
|
.padding(10.dp)
|
||||||
.clip(shape = RoundedCornerShape(10.dp))
|
) {
|
||||||
.background(primaryColor)
|
Box(
|
||||||
)
|
modifier = Modifier
|
||||||
Box(
|
.width(30.dp)
|
||||||
modifier = Modifier
|
.height(10.dp)
|
||||||
.width(75.dp)
|
.clip(shape = RoundedCornerShape(10.dp))
|
||||||
.height(10.dp)
|
.background(primaryColor)
|
||||||
.clip(shape = RoundedCornerShape(10.dp))
|
)
|
||||||
.background(textColor)
|
Box(
|
||||||
)
|
modifier = Modifier
|
||||||
|
.size(10.dp)
|
||||||
|
.clip(shape = RoundedCornerShape(10.dp))
|
||||||
|
.background(primaryColor)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.Mic,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = primaryColor,
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(40.dp)
|
||||||
|
.height(6.dp)
|
||||||
|
.clip(shape = RoundedCornerShape(10.dp))
|
||||||
|
.background(primaryColor)
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(75.dp)
|
||||||
|
.height(10.dp)
|
||||||
|
.clip(shape = RoundedCornerShape(10.dp))
|
||||||
|
.background(textColor)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Box {}
|
||||||
|
}
|
||||||
|
if (isSelected) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize(),
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.CheckCircle,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(30.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Box {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +139,9 @@ fun ThemeSelector() {
|
|||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
) {
|
) {
|
||||||
Preview(
|
Preview(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.weight(1f),
|
||||||
backgroundColor = Color(0xFFF0F0F0),
|
backgroundColor = Color(0xFFF0F0F0),
|
||||||
primaryColor = Color(0xFFAAAAAA),
|
primaryColor = Color(0xFFAAAAAA),
|
||||||
textColor = Color(0xFFCCCCCC),
|
textColor = Color(0xFFCCCCCC),
|
||||||
@ -122,9 +151,13 @@ fun ThemeSelector() {
|
|||||||
it.setTheme(AppSettings.Theme.LIGHT)
|
it.setTheme(AppSettings.Theme.LIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
isSelected = settings.theme == AppSettings.Theme.LIGHT,
|
||||||
)
|
)
|
||||||
Preview(
|
Preview(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.weight(1f),
|
||||||
backgroundColor = Color(0xFF444444),
|
backgroundColor = Color(0xFF444444),
|
||||||
primaryColor = Color(0xFF888888),
|
primaryColor = Color(0xFF888888),
|
||||||
textColor = Color(0xFF606060),
|
textColor = Color(0xFF606060),
|
||||||
@ -134,7 +167,8 @@ fun ThemeSelector() {
|
|||||||
it.setTheme(AppSettings.Theme.DARK)
|
it.setTheme(AppSettings.Theme.DARK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
isSelected = settings.theme == AppSettings.Theme.DARK,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user