-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
260 additions
and
177 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
25 changes: 25 additions & 0 deletions
25
...main/kotlin/com/eblan/socialworkreviewer/core/designsystem/component/ProgressIndicator.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,25 @@ | ||
package com.eblan.socialworkreviewer.core.designsystem.component | ||
|
||
import androidx.compose.material3.LinearProgressIndicator | ||
import androidx.compose.material3.ProgressIndicatorDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.StrokeCap | ||
|
||
@Composable | ||
fun SwrLinearProgressIndicator( | ||
progress: () -> Float, | ||
modifier: Modifier = Modifier, | ||
color: Color = ProgressIndicatorDefaults.linearColor, | ||
trackColor: Color = ProgressIndicatorDefaults.linearTrackColor, | ||
strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap, | ||
) { | ||
LinearProgressIndicator( | ||
progress = progress, | ||
modifier = modifier, | ||
color = color, | ||
trackColor = trackColor, | ||
strokeCap = strokeCap, | ||
) | ||
} |
34 changes: 34 additions & 0 deletions
34
...system/src/main/kotlin/com/eblan/socialworkreviewer/core/designsystem/component/TopBar.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,34 @@ | ||
package com.eblan.socialworkreviewer.core.designsystem.component | ||
|
||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.TopAppBarColors | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.TopAppBarScrollBehavior | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun SwrLargeTopAppBar( | ||
title: @Composable () -> Unit, | ||
modifier: Modifier = Modifier, | ||
navigationIcon: @Composable () -> Unit = {}, | ||
actions: @Composable (RowScope.() -> Unit) = {}, | ||
windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, | ||
colors: TopAppBarColors = TopAppBarDefaults.largeTopAppBarColors(), | ||
scrollBehavior: TopAppBarScrollBehavior? = null, | ||
) { | ||
LargeTopAppBar( | ||
title = title, | ||
modifier = modifier, | ||
navigationIcon = navigationIcon, | ||
actions = actions, | ||
windowInsets = windowInsets, | ||
colors = colors, | ||
scrollBehavior = scrollBehavior, | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
...kotlin/com/eblan/socialworkreviewer/core/designsystem/ProgressIndicatorScreenshotTests.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,33 @@ | ||
package com.eblan.socialworkreviewer.core.designsystem | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import com.eblan.socialworkreviewer.core.designsystem.component.SwrLinearProgressIndicator | ||
import com.eblan.socialworkreviewer.core.screenshottesting.util.captureMultiTheme | ||
import dagger.hilt.android.testing.HiltTestApplication | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
import org.robolectric.annotation.GraphicsMode | ||
import org.robolectric.annotation.LooperMode | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
@Config(application = HiltTestApplication::class, qualifiers = "480dpi") | ||
@LooperMode(LooperMode.Mode.PAUSED) | ||
class ProgressIndicatorScreenshotTests { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
|
||
@Test | ||
fun progressIndicator_multipleThemes() { | ||
composeTestRule.captureMultiTheme("ProgressIndicator") { | ||
SwrLinearProgressIndicator( | ||
progress = { 0.5f }, | ||
) | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...rc/test/kotlin/com/eblan/socialworkreviewer/core/designsystem/TopAppBarScreenshotTests.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,83 @@ | ||
package com.eblan.socialworkreviewer.core.designsystem | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.platform.LocalInspectionMode | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onRoot | ||
import com.eblan.socialworkreviewer.core.designsystem.component.SwrLargeTopAppBar | ||
import com.eblan.socialworkreviewer.core.designsystem.theme.LocalGradientColors | ||
import com.eblan.socialworkreviewer.core.screenshottesting.util.DefaultRoborazziOptions | ||
import com.eblan.socialworkreviewer.core.screenshottesting.util.captureMultiTheme | ||
import com.github.takahirom.roborazzi.captureRoboImage | ||
import dagger.hilt.android.testing.HiltTestApplication | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
import org.robolectric.annotation.GraphicsMode | ||
import org.robolectric.annotation.LooperMode | ||
import androidx.compose.ui.test.DeviceConfigurationOverride | ||
import androidx.compose.ui.test.FontScale | ||
import com.eblan.socialworkreviewer.core.designsystem.theme.SwrTheme | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@RunWith(RobolectricTestRunner::class) | ||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
@Config(application = HiltTestApplication::class, qualifiers = "480dpi") | ||
@LooperMode(LooperMode.Mode.PAUSED) | ||
class TopAppBarScreenshotTests { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
|
||
@Test | ||
fun largeTopAppBar_multipleThemes() { | ||
composeTestRule.captureMultiTheme("LargeTopAppBar") { | ||
SwrLargeTopAppBarExample() | ||
} | ||
} | ||
|
||
@Test | ||
fun largeTopAppBar_hugeFont() { | ||
composeTestRule.setContent { | ||
CompositionLocalProvider( | ||
LocalInspectionMode provides true, | ||
) { | ||
DeviceConfigurationOverride( | ||
DeviceConfigurationOverride.FontScale(2f), | ||
) { | ||
SwrTheme { | ||
SwrLargeTopAppBarExample() | ||
} | ||
} | ||
} | ||
} | ||
composeTestRule.onRoot().captureRoboImage( | ||
"src/test/screenshots/TopAppBar/TopAppBar_fontScale2.png", | ||
roborazziOptions = DefaultRoborazziOptions, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun SwrLargeTopAppBarExample() { | ||
SwrLargeTopAppBar( | ||
title = { | ||
Text( | ||
text = "Large Top App Bar", | ||
style = MaterialTheme.typography.headlineSmall.copy( | ||
brush = Brush.linearGradient( | ||
colors = LocalGradientColors.current.topBarTitleColorsDefault, | ||
), | ||
), | ||
) | ||
}, | ||
) | ||
} | ||
} |
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
Oops, something went wrong.