@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid
|
||||
|
||||
import com.android.build.api.dsl.CommonExtension
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Configure project to enable compose screenshot test.
|
||||
*/
|
||||
internal fun Project.configureAndroidComposeScreenshotTest(
|
||||
commonExtension: CommonExtension<*, *, *, *, *, *>,
|
||||
) {
|
||||
commonExtension.apply {
|
||||
experimentalProperties["android.experimental.enableScreenshotTest"] = true
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.designsystem.component
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun BackgroundDefault() {
|
||||
NiaTheme(disableDynamicTheming = true) {
|
||||
NiaBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun BackgroundDynamic() {
|
||||
NiaTheme(disableDynamicTheming = false) {
|
||||
NiaBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun BackgroundAndroid() {
|
||||
NiaTheme(androidTheme = true) {
|
||||
NiaBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun GradientBackgroundDefault() {
|
||||
NiaTheme(disableDynamicTheming = true) {
|
||||
NiaGradientBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun GradientBackgroundDynamic() {
|
||||
NiaTheme(disableDynamicTheming = false) {
|
||||
NiaGradientBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun GradientBackgroundAndroid() {
|
||||
NiaTheme(androidTheme = true) {
|
||||
NiaGradientBackground(Modifier.size(100.dp), content = {})
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.designsystem.component
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Preview("Top App Bar")
|
||||
@Composable
|
||||
fun NiaTopAppBarPreview() {
|
||||
NiaTheme {
|
||||
NiaTopAppBar(
|
||||
titleRes = android.R.string.untitled,
|
||||
navigationIcon = NiaIcons.Search,
|
||||
navigationIconContentDescription = "Navigation icon",
|
||||
actionIcon = NiaIcons.MoreVert,
|
||||
actionIconContentDescription = "Action icon",
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.designsystem.component
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
|
||||
@ThemePreviews
|
||||
@Composable
|
||||
fun ViewTogglePreviewExpanded() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
NiaViewToggleButton(
|
||||
expanded = true,
|
||||
onExpandedChange = { },
|
||||
compactText = { Text(text = "Compact view") },
|
||||
expandedText = { Text(text = "Expanded view") },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun ViewTogglePreviewCompact() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
NiaViewToggleButton(
|
||||
expanded = false,
|
||||
onExpandedChange = { },
|
||||
compactText = { Text(text = "Compact view") },
|
||||
expandedText = { Text(text = "Expanded view") },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 188 KiB |
After Width: | Height: | Size: 242 KiB |
After Width: | Height: | Size: 68 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 184 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 188 KiB |
After Width: | Height: | Size: 242 KiB |
After Width: | Height: | Size: 68 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 184 KiB |
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.ui
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun InterestsCardPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
InterestsItem(
|
||||
name = "Compose",
|
||||
description = "Description",
|
||||
following = false,
|
||||
topicImageUrl = "",
|
||||
onClick = { },
|
||||
onFollowButtonClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun InterestsCardLongNamePreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
InterestsItem(
|
||||
name = "This is a very very very very long name",
|
||||
description = "Description",
|
||||
following = true,
|
||||
topicImageUrl = "",
|
||||
onClick = { },
|
||||
onFollowButtonClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun InterestsCardLongDescriptionPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
InterestsItem(
|
||||
name = "Compose",
|
||||
description = "This is a very very very very very very very " +
|
||||
"very very very long description",
|
||||
following = false,
|
||||
topicImageUrl = "",
|
||||
onClick = { },
|
||||
onFollowButtonClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun InterestsCardWithEmptyDescriptionPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
InterestsItem(
|
||||
name = "Compose",
|
||||
description = "",
|
||||
following = true,
|
||||
topicImageUrl = "",
|
||||
onClick = { },
|
||||
onFollowButtonClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun InterestsCardSelectedPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
InterestsItem(
|
||||
name = "Compose",
|
||||
description = "",
|
||||
following = true,
|
||||
topicImageUrl = "",
|
||||
onClick = { },
|
||||
onFollowButtonClick = { },
|
||||
isSelected = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.ui
|
||||
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
|
||||
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Devices
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun NewsFeedLoadingPreview() {
|
||||
NiaTheme {
|
||||
LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Adaptive(300.dp)) {
|
||||
newsFeed(
|
||||
feedState = NewsFeedUiState.Loading,
|
||||
onNewsResourcesCheckedChanged = { _, _ -> },
|
||||
onNewsResourceViewed = {},
|
||||
onTopicClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(device = Devices.TABLET)
|
||||
@Composable
|
||||
fun NewsFeedContentPreview(
|
||||
@PreviewParameter(UserNewsResourcePreviewParameterProvider::class)
|
||||
userNewsResources: List<UserNewsResource>,
|
||||
) {
|
||||
NiaTheme {
|
||||
LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Adaptive(300.dp)) {
|
||||
newsFeed(
|
||||
feedState = NewsFeedUiState.Success(userNewsResources),
|
||||
onNewsResourcesCheckedChanged = { _, _ -> },
|
||||
onNewsResourceViewed = {},
|
||||
onTopicClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.ui
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
|
||||
|
||||
@Preview("Bookmark Button")
|
||||
@Composable
|
||||
fun BookmarkButtonPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
BookmarkButton(isBookmarked = false, onClick = { })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview("Bookmark Button Bookmarked")
|
||||
@Composable
|
||||
fun BookmarkButtonBookmarkedPreview() {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
BookmarkButton(isBookmarked = true, onClick = { })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview("NewsResourceCardExpanded")
|
||||
@Composable
|
||||
fun ExpandedNewsResourcePreview(
|
||||
@PreviewParameter(UserNewsResourcePreviewParameterProvider::class)
|
||||
userNewsResources: List<UserNewsResource>,
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalInspectionMode provides true,
|
||||
) {
|
||||
NiaTheme {
|
||||
Surface {
|
||||
NewsResourceCardExpanded(
|
||||
userNewsResource = userNewsResources[0],
|
||||
isBookmarked = true,
|
||||
hasBeenViewed = false,
|
||||
onToggleBookmark = {},
|
||||
onClick = {},
|
||||
onTopicClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 2.7 KiB |
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.feature.bookmarks
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
||||
import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
|
||||
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success
|
||||
import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun LoadingStatePreview() {
|
||||
NiaTheme {
|
||||
LoadingState()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun BookmarksGridPreview(
|
||||
@PreviewParameter(UserNewsResourcePreviewParameterProvider::class)
|
||||
userNewsResources: List<UserNewsResource>,
|
||||
) {
|
||||
NiaTheme {
|
||||
BookmarksGrid(
|
||||
feedState = Success(userNewsResources),
|
||||
removeFromBookmarks = {},
|
||||
onNewsResourceViewed = {},
|
||||
onTopicClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun EmptyStatePreview() {
|
||||
NiaTheme {
|
||||
EmptyState()
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 164 KiB |