Rework Preview for a better rendering in the IDE.

This commit is contained in:
Benoit Marty 2023-01-27 10:19:17 +01:00 committed by Benoit Marty
parent e3fed8b4f5
commit 9d32b05fbb
32 changed files with 452 additions and 73 deletions

View file

@ -14,8 +14,6 @@
* limitations under the License.
*/
@file:OptIn(ExperimentalMaterial3Api::class)
package io.element.android.features.login.changeserver
import androidx.compose.foundation.background
@ -52,6 +50,8 @@ import io.element.android.features.login.error.changeServerError
import io.element.android.libraries.architecture.Async
import io.element.android.libraries.designsystem.components.VectorIcon
import io.element.android.libraries.designsystem.components.form.textFieldState
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.theme.ElementTheme
import io.element.android.libraries.designsystem.theme.components.ElementButton
import io.element.android.libraries.designsystem.theme.components.ElementCircularProgressIndicator
@ -109,6 +109,7 @@ fun ChangeServerView(
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
color = ElementTheme.colors.primary,
)
Text(
text = "A server is a home for all your data.\n" +
@ -119,7 +120,7 @@ fun ChangeServerView(
.padding(top = 16.dp),
textAlign = TextAlign.Center,
fontSize = 16.sp,
color = ElementTheme.colors.secondary
color = ElementTheme.colors.secondary,
)
var homeserverFieldState by textFieldState(stateValue = state.homeserver)
ElementOutlinedTextField(
@ -177,9 +178,16 @@ fun ChangeServerView(
}
}
@Composable
@Preview
fun ChangeServerContentPreview() {
@Composable
fun ChangeServerViewLightPreview() = ElementPreviewLight { ContentToPreview() }
@Preview
@Composable
fun ChangeServerViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
@Composable
private fun ContentToPreview() {
ChangeServerView(
state = ChangeServerState(homeserver = "matrix.org"),
)

View file

@ -14,8 +14,6 @@
* limitations under the License.
*/
@file:OptIn(ExperimentalMaterial3Api::class)
package io.element.android.features.login.root
import androidx.compose.foundation.layout.Box
@ -55,6 +53,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.element.android.features.login.error.loginError
import io.element.android.libraries.designsystem.components.form.textFieldState
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.theme.ElementTheme
import io.element.android.libraries.designsystem.theme.components.ElementButton
import io.element.android.libraries.designsystem.theme.components.ElementCircularProgressIndicator
@ -99,6 +99,7 @@ fun LoginRootScreen(
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
color = ElementTheme.colors.primary,
)
// Form
Column(
@ -219,9 +220,16 @@ fun LoginRootScreen(
}
}
@Composable
@Preview
fun LoginContentPreview() {
@Composable
fun LoginRootScreenLightPreview() = ElementPreviewLight { ContentToPreview() }
@Preview
@Composable
fun LoginRootScreenDarkPreview() = ElementPreviewDark { ContentToPreview() }
@Composable
private fun ContentToPreview() {
LoginRootScreen(
state = LoginRootState(
homeserver = "matrix.org",