pull/2064/head
lihenggui 2 years ago
parent 31a84c4ef3
commit 2c98afa365

@ -1,4 +1,20 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import androidx.compose.ui.window.ComposeUIViewController
import com.google.samples.apps.niacatalog.ui.NiaCatalog
fun MainViewController() = ComposeUIViewController { NiaCatalog() }
fun mainViewController() = ComposeUIViewController { NiaCatalog() }

@ -35,9 +35,8 @@ import kotlinx.browser.document
* limitations under the License.
*/
@OptIn(ExperimentalComposeUiApi::class)
fun main () {
fun main() {
ComposeViewport(document.body!!) {
NiaCatalog()
}

@ -1,3 +1,18 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

@ -21,12 +21,12 @@ import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
@Component
abstract class ApplicationComponent (
abstract class ApplicationComponent(
@get:Provides val context: Context,
): PlatformComponent
) : PlatformComponent
interface ApplicationComponentProvider {
val component: ApplicationComponent
}
val Context.applicationComponent get() = (applicationContext as ApplicationComponentProvider).component
val Context.applicationComponent get() = (applicationContext as ApplicationComponentProvider).component

@ -23,4 +23,4 @@ import me.tatarka.inject.annotations.Provides
interface PlatformComponent {
@Provides
fun providePlatformContext(context: Context): PlatformContext = context
}
}

@ -22,9 +22,9 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
* Multipreview annotation that represents various device sizes. Add this annotation to a composable
* to render various devices.
*/
//@Preview(name = "phone", device = "spec:shape=Normal,width=360,height=640,unit=dp,dpi=480")
//@Preview(name = "landscape", device = "spec:shape=Normal,width=640,height=360,unit=dp,dpi=480")
//@Preview(name = "foldable", device = "spec:shape=Normal,width=673,height=841,unit=dp,dpi=480")
//@Preview(name = "tablet", device = "spec:shape=Normal,width=1280,height=800,unit=dp,dpi=480")
// @Preview(name = "phone", device = "spec:shape=Normal,width=360,height=640,unit=dp,dpi=480")
// @Preview(name = "landscape", device = "spec:shape=Normal,width=640,height=360,unit=dp,dpi=480")
// @Preview(name = "foldable", device = "spec:shape=Normal,width=673,height=841,unit=dp,dpi=480")
// @Preview(name = "tablet", device = "spec:shape=Normal,width=1280,height=800,unit=dp,dpi=480")
@Preview
annotation class DevicePreviews

@ -122,7 +122,7 @@ private fun NewsFeedLoadingPreview() {
}
@Preview
//@Preview(device = Devices.TABLET)
// @Preview(device = Devices.TABLET)
@Composable
private fun NewsFeedContentPreview(
@PreviewParameter(UserNewsResourcePreviewParameterProvider::class)

@ -53,10 +53,7 @@ import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.unit.dp
import coil3.ImageLoader
import coil3.PlatformContext
import coil3.compose.AsyncImagePainter
import coil3.compose.rememberAsyncImagePainter
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconToggleButton
@ -183,9 +180,9 @@ fun NewsResourceHeaderImage(
.fillMaxWidth()
.height(180.dp),
contentScale = ContentScale.Crop,
painter =
painter = imagePainter,
// if (isError.not() && !isLocalInspection) {
imagePainter,
// imagePainter,
// } else {
// painterResource(drawable.core_designsystem_ic_placeholder_default)
// },
@ -312,7 +309,7 @@ fun NewsResourceTopics(
}
}
//@Preview("Bookmark Button")
// @Preview("Bookmark Button")
@Preview
@Composable
private fun BookmarkButtonPreview() {
@ -323,7 +320,7 @@ private fun BookmarkButtonPreview() {
}
}
//@Preview("Bookmark Button Bookmarked")
// @Preview("Bookmark Button Bookmarked")
@Preview
@Composable
private fun BookmarkButtonBookmarkedPreview() {
@ -335,7 +332,7 @@ private fun BookmarkButtonBookmarkedPreview() {
}
@Preview
//@Preview("NewsResourceCardExpanded")
// @Preview("NewsResourceCardExpanded")
@Composable
private fun ExpandedNewsResourcePreview(
@PreviewParameter(UserNewsResourcePreviewParameterProvider::class)

Loading…
Cancel
Save