|
|
|
@ -16,8 +16,15 @@
|
|
|
|
|
|
|
|
|
|
package com.google.samples.apps.nowinandroid.core.ui
|
|
|
|
|
|
|
|
|
|
import android.content.ClipData
|
|
|
|
|
import android.os.Build.VERSION
|
|
|
|
|
import android.os.Build.VERSION_CODES
|
|
|
|
|
import android.view.View
|
|
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
|
|
import androidx.compose.foundation.Image
|
|
|
|
|
import androidx.compose.foundation.draganddrop.dragAndDropSource
|
|
|
|
|
import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
|
|
import androidx.compose.foundation.horizontalScroll
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
@ -45,6 +52,7 @@ import androidx.compose.runtime.remember
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.draganddrop.DragAndDropTransferData
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
|
|
|
import androidx.compose.ui.platform.LocalInspectionMode
|
|
|
|
@ -77,6 +85,7 @@ import java.util.Locale
|
|
|
|
|
* [NewsResource] card used on the following screens: For You, Saved
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalFoundationApi::class)
|
|
|
|
|
@Composable
|
|
|
|
|
fun NewsResourceCardExpanded(
|
|
|
|
|
userNewsResource: UserNewsResource,
|
|
|
|
@ -88,6 +97,19 @@ fun NewsResourceCardExpanded(
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
|
) {
|
|
|
|
|
val clickActionLabel = stringResource(R.string.core_ui_card_tap_action)
|
|
|
|
|
val sharingLabel = stringResource(R.string.core_ui_feed_sharing)
|
|
|
|
|
val sharingContent = stringResource(
|
|
|
|
|
R.string.core_ui_feed_sharing_data,
|
|
|
|
|
userNewsResource.title,
|
|
|
|
|
userNewsResource.url,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val dragAndDropFlags = if (VERSION.SDK_INT >= VERSION_CODES.N) {
|
|
|
|
|
View.DRAG_FLAG_GLOBAL
|
|
|
|
|
} else {
|
|
|
|
|
0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Card(
|
|
|
|
|
onClick = onClick,
|
|
|
|
|
shape = RoundedCornerShape(16.dp),
|
|
|
|
@ -112,7 +134,23 @@ fun NewsResourceCardExpanded(
|
|
|
|
|
Row {
|
|
|
|
|
NewsResourceTitle(
|
|
|
|
|
userNewsResource.title,
|
|
|
|
|
modifier = Modifier.fillMaxWidth((.8f)),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth((.8f))
|
|
|
|
|
.dragAndDropSource {
|
|
|
|
|
detectTapGestures(
|
|
|
|
|
onLongPress = {
|
|
|
|
|
startTransfer(
|
|
|
|
|
DragAndDropTransferData(
|
|
|
|
|
ClipData.newPlainText(
|
|
|
|
|
sharingLabel,
|
|
|
|
|
sharingContent,
|
|
|
|
|
),
|
|
|
|
|
flags = dragAndDropFlags,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
Spacer(modifier = Modifier.weight(1f))
|
|
|
|
|
BookmarkButton(isBookmarked, onToggleBookmark)
|
|
|
|
|