Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Use DevicesPreviews annotation #166

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 2 additions & 58 deletions app/src/main/java/ir/composenews/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.google.accompanist.adaptive.calculateDisplayFeatures
import dagger.hilt.android.AndroidEntryPoint
import ir.composenews.designsystem.preview.DevicesPreviews
import ir.composenews.designsystem.theme.ComposeNewsTheme
import ir.composenews.navigation.MainContract
import ir.composenews.permission.enum.PermissionType
Expand Down Expand Up @@ -64,7 +64,7 @@ class MainActivity : ComponentActivity(), PermissionManager by PermissionManager
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Preview(showBackground = true)
@DevicesPreviews()
@Composable
fun ComposeNewsAppPreview() {
ComposeNewsTheme {
Expand All @@ -76,59 +76,3 @@ fun ComposeNewsAppPreview() {
)
}
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Preview(showBackground = true, widthDp = 700, heightDp = 500)
@Composable
fun ComposeNewsAppPreviewTablet() {
ComposeNewsTheme {
ComposeNewsApp(
windowSize = WindowSizeClass.calculateFromSize(DpSize(700.dp, 500.dp)),
displayFeatures = persistentListOf(),
uiState = MainContract.State(),
closeDetailScreen = {},
)
}
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Preview(showBackground = true, widthDp = 500, heightDp = 700)
@Composable
fun ComposeNewsAppPreviewTabletPortrait() {
ComposeNewsTheme {
ComposeNewsApp(
windowSize = WindowSizeClass.calculateFromSize(DpSize(500.dp, 700.dp)),
displayFeatures = persistentListOf(),
uiState = MainContract.State(),
closeDetailScreen = {},
)
}
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Preview(showBackground = true, widthDp = 1100, heightDp = 600)
@Composable
fun ComposeNewsAppPreviewDesktop() {
ComposeNewsTheme {
ComposeNewsApp(
windowSize = WindowSizeClass.calculateFromSize(DpSize(1100.dp, 600.dp)),
displayFeatures = persistentListOf(),
uiState = MainContract.State(),
closeDetailScreen = {},
)
}
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Preview(showBackground = true, widthDp = 600, heightDp = 1100)
@Composable
fun ComposeNewsAppPreviewDesktopPortrait() {
ComposeNewsTheme {
ComposeNewsApp(
windowSize = WindowSizeClass.calculateFromSize(DpSize(600.dp, 1100.dp)),
displayFeatures = persistentListOf(),
uiState = MainContract.State(),
closeDetailScreen = {},
)
}
}
Loading