Add some previews.
This commit is contained in:
parent
3851653d39
commit
0959f652a8
2 changed files with 37 additions and 2 deletions
|
|
@ -20,9 +20,14 @@ import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.libraries.architecture.Async
|
import io.element.android.libraries.architecture.Async
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||||
import io.element.android.libraries.matrix.ui.components.MatrixUserHeader
|
import io.element.android.libraries.matrix.ui.components.MatrixUserHeader
|
||||||
|
import io.element.android.libraries.matrix.ui.components.MatrixUserWithNullProvider
|
||||||
import io.element.android.libraries.matrix.ui.model.MatrixUser
|
import io.element.android.libraries.matrix.ui.model.MatrixUser
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -38,3 +43,22 @@ fun UserPreferences(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
internal fun UserPreferencesLightPreview(@PreviewParameter(MatrixUserWithNullProvider::class) matrixUser: MatrixUser?) =
|
||||||
|
ElementPreviewLight { ContentToPreview(matrixUser) }
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
internal fun UserPreferencesDarkPreview(@PreviewParameter(MatrixUserWithNullProvider::class) matrixUser: MatrixUser?) =
|
||||||
|
ElementPreviewDark { ContentToPreview(matrixUser) }
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ContentToPreview(matrixUser: MatrixUser?) {
|
||||||
|
if (matrixUser == null) {
|
||||||
|
UserPreferences(Async.Uninitialized)
|
||||||
|
} else {
|
||||||
|
UserPreferences(Async.Success(matrixUser))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ open class MatrixUserProvider : PreviewParameterProvider<MatrixUser> {
|
||||||
override val values: Sequence<MatrixUser>
|
override val values: Sequence<MatrixUser>
|
||||||
get() = sequenceOf(
|
get() = sequenceOf(
|
||||||
aMatrixUser(),
|
aMatrixUser(),
|
||||||
MatrixUser(
|
aMatrixUser().copy(
|
||||||
id = UserId("@id_of_alice:server.org"),
|
|
||||||
username = null,
|
username = null,
|
||||||
avatarData = anAvatarData().copy(name = null)
|
avatarData = anAvatarData().copy(name = null)
|
||||||
),
|
),
|
||||||
|
|
@ -38,3 +37,15 @@ fun aMatrixUser() = MatrixUser(
|
||||||
username = "Alice",
|
username = "Alice",
|
||||||
avatarData = anAvatarData()
|
avatarData = anAvatarData()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
open class MatrixUserWithNullProvider : PreviewParameterProvider<MatrixUser?> {
|
||||||
|
override val values: Sequence<MatrixUser?>
|
||||||
|
get() = sequenceOf(
|
||||||
|
aMatrixUser(),
|
||||||
|
aMatrixUser().copy(
|
||||||
|
username = null,
|
||||||
|
avatarData = anAvatarData().copy(name = null)
|
||||||
|
),
|
||||||
|
null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue