diff --git a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/component/detail/PlaceBottomSheet.kt b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/component/detail/PlaceBottomSheet.kt index e847642e..a5024faf 100644 --- a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/component/detail/PlaceBottomSheet.kt +++ b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/component/detail/PlaceBottomSheet.kt @@ -15,6 +15,7 @@ import androidx.compose.runtime.Stable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.easyhz.noffice.core.design_system.R @@ -32,6 +33,7 @@ import com.easyhz.noffice.core.design_system.theme.White internal fun PlaceBottomSheetTopBar( modifier: Modifier = Modifier, placeUrl: String, + onClickUrl: () -> Unit, onClickBack: () -> Unit, ) { Box( @@ -64,13 +66,15 @@ internal fun PlaceBottomSheetTopBar( modifier = Modifier .align(Alignment.Center) .widthIn(max = 300.dp) + .noRippleClickable { onClickUrl() } ) { Text( text = placeUrl, style = SemiBold14, color = Grey700, maxLines = 1, - overflow = TextOverflow.Ellipsis + overflow = TextOverflow.Ellipsis, + textDecoration = TextDecoration.Underline ) } } diff --git a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailIntent.kt b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailIntent.kt index 4514ff8d..42396fb2 100644 --- a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailIntent.kt +++ b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailIntent.kt @@ -10,5 +10,6 @@ sealed class DetailIntent: UiIntent() { data class LoadWebView(val isLoading: Boolean): DetailIntent() data object ClickOpenBrowser: DetailIntent() data object ClickWebViewBack: DetailIntent() + data object CopyUrl: DetailIntent() data class UpdateCanGoBack(val canGoBack: Boolean): DetailIntent() } \ No newline at end of file diff --git a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailSideEffect.kt b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailSideEffect.kt index 933334e3..3ec77a88 100644 --- a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailSideEffect.kt +++ b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/contract/detail/DetailSideEffect.kt @@ -5,5 +5,6 @@ import com.easyhz.noffice.core.common.base.UiSideEffect sealed class DetailSideEffect: UiSideEffect() { data object NavigateToUp: DetailSideEffect() data class OpenBrowser(val url: String): DetailSideEffect() + data class CopyUrl(val url: String): DetailSideEffect() data object NavigateToUpInWebView: DetailSideEffect() } \ No newline at end of file diff --git a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailScreen.kt b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailScreen.kt index 6bd1a457..4ac0daa1 100644 --- a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailScreen.kt +++ b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailScreen.kt @@ -23,14 +23,14 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -70,8 +70,10 @@ fun AnnouncementDetailScreen( ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() val scrollState = rememberScrollState() + val clipBoardManager = LocalClipboardManager.current val context = LocalContext.current val webView = remember { WebView(context) } + LaunchedEffect(Unit) { viewModel.postIntent(DetailIntent.InitScreen(id, title)) } @@ -161,6 +163,7 @@ fun AnnouncementDetailScreen( dragHandle = { PlaceBottomSheetTopBar( placeUrl = uiState.detail.placeUrl, + onClickUrl = { viewModel.postIntent(DetailIntent.CopyUrl) } ) { viewModel.postIntent(DetailIntent.ClickWebViewBack) } @@ -209,6 +212,9 @@ fun AnnouncementDetailScreen( val intent = Intent(Intent.ACTION_VIEW, Uri.parse(sideEffect.url)) context.startActivity(intent) } + is DetailSideEffect.CopyUrl -> { + clipBoardManager.setText(AnnotatedString(sideEffect.url)) + } is DetailSideEffect.NavigateToUpInWebView -> { webView.goBack() } diff --git a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailViewModel.kt b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailViewModel.kt index 15140847..3fc424ce 100644 --- a/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailViewModel.kt +++ b/feature/announcement/src/main/java/com/easyhz/noffice/feature/announcement/screen/detail/AnnouncementDetailViewModel.kt @@ -27,6 +27,7 @@ class AnnouncementDetailViewModel @Inject constructor( is DetailIntent.LoadWebView -> { onLoadWebView(intent.isLoading) } is DetailIntent.ClickOpenBrowser -> { onClickOpenBrowser() } is DetailIntent.ClickWebViewBack -> { onClickWebViewBack() } + is DetailIntent.CopyUrl -> { onCopyUrl() } is DetailIntent.UpdateCanGoBack -> { updateCanGoBack(intent.canGoBack) } } } @@ -62,6 +63,9 @@ class AnnouncementDetailViewModel @Inject constructor( postSideEffect { DetailSideEffect.OpenBrowser(currentState.detail.placeUrl) } } + private fun onCopyUrl() { + postSideEffect { DetailSideEffect.CopyUrl(currentState.detail.placeUrl) } + } private fun onClickWebViewBack() { if (currentState.canGoBack) { postSideEffect { DetailSideEffect.NavigateToUpInWebView }