@ -56,9 +56,11 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconT
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicTag
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicTag
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.domain.model.previewUserNewsResources
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import java.time.ZoneId
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatter
@ -73,7 +75,7 @@ import kotlinx.datetime.toJavaInstant
@OptIn ( ExperimentalMaterial3Api :: class )
@OptIn ( ExperimentalMaterial3Api :: class )
@Composable
@Composable
fun NewsResourceCardExpanded (
fun NewsResourceCardExpanded (
newsResource: NewsResource,
userNewsResource: User NewsResource,
isBookmarked : Boolean ,
isBookmarked : Boolean ,
onToggleBookmark : ( ) -> Unit ,
onToggleBookmark : ( ) -> Unit ,
onClick : ( ) -> Unit ,
onClick : ( ) -> Unit ,
@ -91,9 +93,9 @@ fun NewsResourceCardExpanded(
}
}
) {
) {
Column {
Column {
if ( ! n ewsResource. headerImageUrl . isNullOrEmpty ( ) ) {
if ( ! userN ewsResource. headerImageUrl . isNullOrEmpty ( ) ) {
Row {
Row {
NewsResourceHeaderImage ( n ewsResource. headerImageUrl )
NewsResourceHeaderImage ( userN ewsResource. headerImageUrl )
}
}
}
}
Box (
Box (
@ -103,18 +105,18 @@ fun NewsResourceCardExpanded(
Spacer ( modifier = Modifier . height ( 12. dp ) )
Spacer ( modifier = Modifier . height ( 12. dp ) )
Row {
Row {
NewsResourceTitle (
NewsResourceTitle (
n ewsResource. title ,
userN ewsResource. title ,
modifier = Modifier . fillMaxWidth ( ( . 8f ) )
modifier = Modifier . fillMaxWidth ( ( . 8f ) )
)
)
Spacer ( modifier = Modifier . weight ( 1f ) )
Spacer ( modifier = Modifier . weight ( 1f ) )
BookmarkButton ( isBookmarked , onToggleBookmark )
BookmarkButton ( isBookmarked , onToggleBookmark )
}
}
Spacer ( modifier = Modifier . height ( 12. dp ) )
Spacer ( modifier = Modifier . height ( 12. dp ) )
NewsResourceMetaData ( newsResource. publishDate , n ewsResource. type )
NewsResourceMetaData ( userNewsResource. publishDate , userN ewsResource. type )
Spacer ( modifier = Modifier . height ( 12. dp ) )
Spacer ( modifier = Modifier . height ( 12. dp ) )
NewsResourceShortDescription ( n ewsResource. content )
NewsResourceShortDescription ( userN ewsResource. content )
Spacer ( modifier = Modifier . height ( 12. dp ) )
Spacer ( modifier = Modifier . height ( 12. dp ) )
NewsResourceTopics ( n ewsResource. topics )
NewsResourceTopics ( userN ewsResource. topics )
}
}
}
}
}
}
@ -227,7 +229,7 @@ fun NewsResourceShortDescription(
@Composable
@Composable
fun NewsResourceTopics (
fun NewsResourceTopics (
topics : List < Topic> ,
topics : List < Followable Topic> ,
modifier : Modifier = Modifier
modifier : Modifier = Modifier
) {
) {
// Store the ID of the Topic which has its "following" menu expanded, if any.
// Store the ID of the Topic which has its "following" menu expanded, if any.
@ -238,17 +240,17 @@ fun NewsResourceTopics(
modifier = modifier . horizontalScroll ( rememberScrollState ( ) ) , // causes narrow chips
modifier = modifier . horizontalScroll ( rememberScrollState ( ) ) , // causes narrow chips
horizontalArrangement = Arrangement . spacedBy ( 4. dp ) ,
horizontalArrangement = Arrangement . spacedBy ( 4. dp ) ,
) {
) {
for ( t opic in topics ) {
for ( followableT opic in topics ) {
NiaTopicTag (
NiaTopicTag (
expanded = expandedTopicId == topic. id ,
expanded = expandedTopicId == followableTopic. topic. id ,
followed = true , // ToDo: Check if topic is followed
followed = true , // ToDo: Check if topic is followed
onDropdownMenuToggle = { show ->
onDropdownMenuToggle = { show ->
expandedTopicId = if ( show ) topic. id else null
expandedTopicId = if ( show ) followableTopic. topic. id else null
} ,
} ,
onFollowClick = { } , // ToDo
onFollowClick = { } , // ToDo
onUnfollowClick = { } , // ToDo
onUnfollowClick = { } , // ToDo
onBrowseClick = { } , // ToDo
onBrowseClick = { } , // ToDo
text = { Text ( text = topic. name . uppercase ( Locale . getDefault ( ) ) ) }
text = { Text ( text = followableTopic. topic. name . uppercase ( Locale . getDefault ( ) ) ) }
)
)
}
}
}
}
@ -280,7 +282,7 @@ fun ExpandedNewsResourcePreview() {
NiaTheme {
NiaTheme {
Surface {
Surface {
NewsResourceCardExpanded (
NewsResourceCardExpanded (
newsResource = preview NewsResources[ 0 ] ,
userNewsResource = previewUser NewsResources[ 0 ] ,
isBookmarked = true ,
isBookmarked = true ,
onToggleBookmark = { } ,
onToggleBookmark = { } ,
onClick = { }
onClick = { }