Refine UI
This commit is contained in:
parent
eb2fd13518
commit
5984ffc960
8 changed files with 82 additions and 41 deletions
|
|
@ -11,6 +11,7 @@ import androidx.compose.ui.graphics.toArgb
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Color.White,
|
||||
|
|
@ -58,13 +59,11 @@ fun ElementXTheme(
|
|||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
window.statusBarColor = colorScheme.primary.toArgb()
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
||||
}
|
||||
val systemUiController = rememberSystemUiController()
|
||||
SideEffect {
|
||||
systemUiController.setStatusBarColor(
|
||||
color = colorScheme.background
|
||||
)
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
|
|
|
|||
|
|
@ -8,13 +8,22 @@ import androidx.compose.ui.unit.sp
|
|||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
),
|
||||
headlineSmall = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 32.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
|
|
@ -18,28 +19,43 @@ import io.element.android.x.designsystem.AvatarGradientStart
|
|||
import io.element.android.x.designsystem.components.avatar.AvatarData
|
||||
|
||||
@Composable
|
||||
fun Avatar(avatarData: AvatarData) {
|
||||
fun Avatar(avatarData: AvatarData, modifier: Modifier = Modifier) {
|
||||
if (avatarData.model == null) {
|
||||
InitialsAvatar(
|
||||
modifier = Modifier
|
||||
modifier = modifier
|
||||
.size(avatarData.size.dp)
|
||||
.clip(CircleShape),
|
||||
initials = avatarData.initials
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = avatarData.model,
|
||||
onError = {
|
||||
Log.e("TAG", "Error $it\n${it.result}", it.result.throwable)
|
||||
},
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
ImageAvatar(
|
||||
modifier = modifier
|
||||
.size(avatarData.size.dp)
|
||||
.clip(CircleShape)
|
||||
.clip(CircleShape),
|
||||
avatarData = avatarData
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ImageAvatar(
|
||||
avatarData: AvatarData,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
AsyncImage(
|
||||
model = avatarData.model,
|
||||
onError = {
|
||||
Log.e("TAG", "Error $it\n${it.result}", it.result.throwable)
|
||||
},
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = modifier
|
||||
.size(avatarData.size.dp)
|
||||
.clip(CircleShape)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
private fun InitialsAvatar(
|
||||
initials: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue