enhancement: improved community and user header
This commit is contained in:
parent
54accc8538
commit
e569468fa6
@ -5,7 +5,6 @@ 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.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
@ -39,21 +38,22 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel
|
|||||||
@Composable
|
@Composable
|
||||||
fun CommunityHeader(
|
fun CommunityHeader(
|
||||||
community: CommunityModel,
|
community: CommunityModel,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
autoLoadImages: Boolean = true,
|
autoLoadImages: Boolean = true,
|
||||||
options: List<String> = emptyList(),
|
options: List<String> = emptyList(),
|
||||||
onOptionSelected: ((Int) -> Unit)? = null,
|
onOptionSelected: ((Int) -> Unit)? = null,
|
||||||
onOpenImage: ((String) -> Unit)? = null,
|
onOpenImage: ((String) -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxWidth().aspectRatio(4.5f).padding(Spacing.xs),
|
modifier = modifier.fillMaxWidth().padding(Spacing.s),
|
||||||
) {
|
) {
|
||||||
// banner
|
// banner
|
||||||
val banner = community.banner.orEmpty()
|
val banner = community.banner.orEmpty()
|
||||||
if (banner.isNotEmpty() && autoLoadImages) {
|
if (banner.isNotEmpty() && autoLoadImages) {
|
||||||
CustomImage(
|
CustomImage(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxWidth().aspectRatio(4.5f),
|
||||||
url = banner,
|
url = banner,
|
||||||
contentScale = ContentScale.FillBounds,
|
contentScale = ContentScale.FillWidth,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -99,10 +99,9 @@ fun CommunityHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxWidth().align(Alignment.Center),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(Spacing.m)
|
horizontalArrangement = Arrangement.spacedBy(Spacing.m)
|
||||||
) {
|
) {
|
||||||
@ -155,4 +154,5 @@ fun CommunityHeader(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
@ -47,13 +46,14 @@ import dev.icerock.moko.resources.compose.stringResource
|
|||||||
@Composable
|
@Composable
|
||||||
fun UserHeader(
|
fun UserHeader(
|
||||||
user: UserModel,
|
user: UserModel,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
autoLoadImages: Boolean = true,
|
autoLoadImages: Boolean = true,
|
||||||
options: List<String> = emptyList(),
|
options: List<String> = emptyList(),
|
||||||
onOptionSelected: ((Int) -> Unit)? = null,
|
onOptionSelected: ((Int) -> Unit)? = null,
|
||||||
onOpenImage: ((String) -> Unit)? = null,
|
onOpenImage: ((String) -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.padding(Spacing.xs),
|
modifier = modifier.fillMaxWidth().padding(Spacing.s),
|
||||||
) {
|
) {
|
||||||
// banner
|
// banner
|
||||||
val banner = user.banner.orEmpty()
|
val banner = user.banner.orEmpty()
|
||||||
@ -62,7 +62,7 @@ fun UserHeader(
|
|||||||
modifier = Modifier.fillMaxWidth().aspectRatio(4.5f),
|
modifier = Modifier.fillMaxWidth().aspectRatio(4.5f),
|
||||||
url = banner,
|
url = banner,
|
||||||
quality = FilterQuality.Low,
|
quality = FilterQuality.Low,
|
||||||
contentScale = ContentScale.FillBounds,
|
contentScale = ContentScale.FillWidth,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ fun UserHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxWidth().align(Alignment.Center),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(Spacing.m)
|
horizontalArrangement = Arrangement.spacedBy(Spacing.m)
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user