-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
102 changes: 102 additions & 0 deletions
102
sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.github.takahirom.preview.tests | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Devices | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.Wallpapers | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewNormal() { | ||
MaterialTheme { | ||
Card( | ||
Modifier | ||
.width(180.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(8.dp), | ||
text = "Generate Preview Test Sample" | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview( | ||
uiMode = Configuration.UI_MODE_NIGHT_YES | ||
) | ||
@Composable | ||
fun PreviewDarkMode() { | ||
val isSystemInDarkTheme = isSystemInDarkTheme() | ||
MaterialTheme( | ||
colorScheme = if (isSystemInDarkTheme) { | ||
darkColorScheme() | ||
} else { | ||
lightColorScheme() | ||
} | ||
) { | ||
Card( | ||
Modifier | ||
.width(180.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(8.dp), | ||
text = "Generate Preview Test Sample" | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview( | ||
name = "Preview Name", | ||
// These properties are not supported by Roborazzi yet. | ||
group = "Preview Group", | ||
apiLevel = 30, | ||
widthDp = 320, | ||
heightDp = 640, | ||
locale = "ja-rJP", | ||
fontScale = 1.5f, | ||
) | ||
@Composable | ||
fun PreviewWithProperties1() { | ||
Card( | ||
Modifier | ||
.width(100.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(8.dp), | ||
text = "Hello, World!" | ||
) | ||
} | ||
} | ||
|
||
@Preview( | ||
showSystemUi = true, | ||
showBackground = true, | ||
backgroundColor = 0xFF0000FF, | ||
uiMode = Configuration.UI_MODE_NIGHT_YES, | ||
device = Devices.NEXUS_5, | ||
wallpaper = Wallpapers.GREEN_DOMINATED_EXAMPLE, | ||
) | ||
@Composable | ||
fun PreviewWithProperties2() { | ||
Card( | ||
Modifier | ||
.width(100.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(8.dp), | ||
text = "Hello, World!" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters