Skip to content

Commit 233e063

Browse files
committed
Refactor Compose Multiplatform preview dependencies and imports
- Updated `Preview` imports from `org.jetbrains.compose.ui.tooling.preview` to `androidx.compose.ui.tooling.preview` across all modules. - Migrated dependency references from `compose.components.uiToolingPreview` to `compose.preview` in common source sets. - Updated `androidMain` dependencies to use `compose.uiTooling` instead of explicit library versions or incorrect preview aliases. - Enabled `showBackground = true` for several `@Preview` components in the Material theme module.
1 parent dafcef1 commit 233e063

15 files changed

Lines changed: 22 additions & 24 deletions

File tree

sample/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ kotlin {
5353
implementation(compose.material)
5454
implementation(compose.ui)
5555
implementation(compose.components.resources)
56-
implementation(compose.components.uiToolingPreview)
56+
implementation(compose.preview)
5757
implementation("org.jetbrains.androidx.navigation:navigation-compose:2.9.1")
5858
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
5959
}
6060
androidMain.dependencies {
6161
implementation("androidx.activity:activity-compose:1.12.2")
62-
implementation(compose.preview)
62+
implementation(compose.uiTooling)
6363
}
6464
val desktopMain by getting
6565
desktopMain.dependencies {

sample/src/commonMain/kotlin/com/softartdev/shared/material/NoteDetailBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow
2727
import androidx.compose.ui.unit.dp
2828
import com.softartdev.shared.AppState
2929
import com.softartdev.theme.material.PreferableMaterialTheme
30-
import org.jetbrains.compose.ui.tooling.preview.Preview
30+
import androidx.compose.ui.tooling.preview.Preview
3131
import kotlin.experimental.ExperimentalObjCRefinement
3232
import kotlin.native.HiddenFromObjC
3333

sample/src/commonMain/kotlin/com/softartdev/shared/material/SettingsBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import io.github.softartdev.theme_prefs.generated.resources.pref_subtitle_open_g
2525
import io.github.softartdev.theme_prefs.generated.resources.pref_title_source_code
2626
import io.github.softartdev.theme_prefs.generated.resources.switch_to_material_design_3
2727
import org.jetbrains.compose.resources.stringResource
28-
import org.jetbrains.compose.ui.tooling.preview.Preview
28+
import androidx.compose.ui.tooling.preview.Preview
2929
import kotlin.experimental.ExperimentalObjCRefinement
3030
import kotlin.native.HiddenFromObjC
3131

sample/src/commonMain/kotlin/com/softartdev/shared/material3/NoteDetailBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import androidx.compose.ui.text.style.TextOverflow
3030
import androidx.compose.ui.unit.dp
3131
import com.softartdev.shared.AppState
3232
import com.softartdev.theme.material.PreferableMaterialTheme
33-
import org.jetbrains.compose.ui.tooling.preview.Preview
33+
import androidx.compose.ui.tooling.preview.Preview
3434
import kotlin.experimental.ExperimentalObjCRefinement
3535
import kotlin.native.HiddenFromObjC
3636

sample/src/commonMain/kotlin/com/softartdev/shared/material3/SettingsBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import io.github.softartdev.theme_prefs.generated.resources.pref_subtitle_open_g
2525
import io.github.softartdev.theme_prefs.generated.resources.pref_title_source_code
2626
import io.github.softartdev.theme_prefs.generated.resources.switch_to_material_design_3
2727
import org.jetbrains.compose.resources.stringResource
28-
import org.jetbrains.compose.ui.tooling.preview.Preview
28+
import androidx.compose.ui.tooling.preview.Preview
2929
import kotlin.experimental.ExperimentalObjCRefinement
3030
import kotlin.native.HiddenFromObjC
3131

theme/theme-material/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ kotlin {
3636
api(compose.foundation)
3737
api(compose.material)
3838
api(compose.materialIconsExtended)
39-
implementation(compose.components.uiToolingPreview)
39+
implementation(compose.preview)
4040
}
4141
commonTest.dependencies {
4242
implementation(kotlin("test"))
4343
}
4444
androidMain.dependencies {
45-
implementation(compose.preview)
46-
implementation("androidx.compose.ui:ui-tooling:1.10.1")
45+
implementation(compose.uiTooling)
4746
}
4847
}
4948
explicitApi()

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.github.softartdev.theme_prefs.generated.resources.Res
2020
import io.github.softartdev.theme_prefs.generated.resources.choose_theme
2121
import io.github.softartdev.theme_prefs.generated.resources.theme
2222
import org.jetbrains.compose.resources.stringResource
23-
import org.jetbrains.compose.ui.tooling.preview.Preview
23+
import androidx.compose.ui.tooling.preview.Preview
2424

2525
@Composable
2626
public fun ThemePreferencesCategory(): Unit = PreferenceCategory(
@@ -64,13 +64,13 @@ public fun PreferenceItem(
6464
trailing = trailing
6565
)
6666

67-
@Preview
67+
@Preview(showBackground = true)
6868
@Composable
6969
public fun ThemePreferencesCategoryPreview() {
7070
ThemePreferencesCategory()
7171
}
7272

73-
@Preview
73+
@Preview(showBackground = true)
7474
@Composable
7575
public fun ThemePreferenceItemPreview() {
7676
PreferableMaterialTheme { ThemePreferenceItem() }

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import androidx.compose.ui.semantics.Role
1919
import androidx.compose.ui.unit.dp
2020
import com.softartdev.theme.pref.ThemeEnum
2121
import org.jetbrains.compose.resources.stringResource
22-
import org.jetbrains.compose.ui.tooling.preview.Preview
22+
import androidx.compose.ui.tooling.preview.Preview
2323

2424
@Composable
2525
public fun RadioDialogContent(darkThemeState: MutableState<ThemeEnum>) {
@@ -51,7 +51,7 @@ public fun RadioDialogContent(darkThemeState: MutableState<ThemeEnum>) {
5151
}
5252
}
5353

54-
@Preview
54+
@Preview(showBackground = true)
5555
@Composable
5656
private fun RadioDialogContentPreview() {
5757
PreferableMaterialTheme {

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
1616
import io.github.softartdev.theme_prefs.generated.resources.Res
1717
import io.github.softartdev.theme_prefs.generated.resources.settings
1818
import org.jetbrains.compose.resources.stringResource
19-
import org.jetbrains.compose.ui.tooling.preview.Preview
19+
import androidx.compose.ui.tooling.preview.Preview
2020

2121
@Composable
2222
public fun SettingsScaffold(

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/ThemeDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import io.github.softartdev.theme_prefs.generated.resources.cancel
1515
import io.github.softartdev.theme_prefs.generated.resources.choose_theme
1616
import io.github.softartdev.theme_prefs.generated.resources.ok
1717
import org.jetbrains.compose.resources.stringResource
18-
import org.jetbrains.compose.ui.tooling.preview.Preview
18+
import androidx.compose.ui.tooling.preview.Preview
1919

2020
/**
2121
* AlertDialog for selecting a theme.

0 commit comments

Comments
 (0)