Skip to content

Commit

Permalink
Merge pull request #358 from apeun-gidaechi/feature/357-chat-detail-m…
Browse files Browse the repository at this point in the history
…essage-copy

Feature/Chat Detail Message Copy
  • Loading branch information
8954sood authored Nov 5, 2024
2 parents 4c53396 + 18bd9c9 commit 7f5d16d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -63,11 +64,13 @@ import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -127,6 +130,7 @@ internal fun ChatDetailScreen(
val scrollState = rememberLazyListState()
val focusRequester by remember { mutableStateOf(FocusRequester()) }
val focusManager = LocalFocusManager.current
val clipboardManager = LocalClipboardManager.current

val context = LocalContext.current
val coroutineScope = rememberCoroutineScope()
Expand Down Expand Up @@ -211,6 +215,9 @@ internal fun ChatDetailScreen(

var nowPage: NowPage by remember { mutableStateOf(NowPage.CHAT) }

var copyMessage by remember { mutableStateOf("") }
var isShowCopyMessageDialog by remember { mutableStateOf(false) }

LaunchedEffect(key1 = sideEffect) {
if (sideEffect == null) {
return@LaunchedEffect
Expand Down Expand Up @@ -376,6 +383,20 @@ internal fun ChatDetailScreen(
)
}

if (isShowCopyMessageDialog) {
ChatDetailCopyDialog(
onDismissRequest = {
isShowCopyMessageDialog = false
copyMessage = ""
},
onClickCopy = {
isShowCopyMessageDialog = false
clipboardManager.setText(AnnotatedString(copyMessage))
copyMessage = ""
},
)
}

AnimatedVisibility(
visible = nowPage == NowPage.CHAT,
enter = fadeIn(),
Expand Down Expand Up @@ -427,6 +448,10 @@ internal fun ChatDetailScreen(
onShowImagePreview = { showImagePreview = it },
onSelectedFileName = { selectedFileName = it },
onSelectedImageBitmap = { selectedImageBitmap = it },
onChatLongClick = {
copyMessage = it
isShowCopyMessageDialog = true
},
)
}

Expand Down Expand Up @@ -866,3 +891,34 @@ internal fun ResendDialog(modifier: Modifier = Modifier, text: String = "재전
}
}
}

@Composable
fun ChatDetailCopyDialog(onDismissRequest: () -> Unit, onClickCopy: () -> Unit) {
Dialog(
onDismissRequest = onDismissRequest,
) {
Surface(
color = SeugiTheme.colors.white,
shape = RoundedCornerShape(16.dp),
) {
Column(
modifier = Modifier.padding(16.dp),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.bounceClick(onClickCopy),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
modifier = Modifier
.padding(vertical = 8.dp),
text = "메세지 복사하기",
color = SeugiTheme.colors.black,
style = SeugiTheme.typography.subtitle2,
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ internal fun ChatDetailChatScreen(
onShowImagePreview: (Boolean) -> Unit,
onSelectedFileName: (String) -> Unit,
onSelectedImageBitmap: (Bitmap?) -> Unit,
onChatLongClick: (text: String) -> Unit,
) {
Box(
modifier = Modifier
Expand Down Expand Up @@ -413,6 +414,9 @@ internal fun ChatDetailChatScreen(
message = item.message,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.message)
},
)
}
is MessageRoomEvent.MessageParent.Other -> {
Expand All @@ -427,6 +431,9 @@ internal fun ChatDetailChatScreen(
message = item.message,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.message)
},
)
}

Expand Down Expand Up @@ -487,6 +494,9 @@ internal fun ChatDetailChatScreen(
message = item.visibleMessage,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.visibleMessage)
},
)
}

Expand All @@ -501,6 +511,9 @@ internal fun ChatDetailChatScreen(
message = item.visibleMessage,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.visibleMessage)
},
)
}

Expand All @@ -515,6 +528,9 @@ internal fun ChatDetailChatScreen(
message = item.visibleMessage,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.visibleMessage)
},
)
}

Expand All @@ -529,6 +545,9 @@ internal fun ChatDetailChatScreen(
message = item.visibleMessage,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.visibleMessage)
},
)
}

Expand All @@ -543,6 +562,9 @@ internal fun ChatDetailChatScreen(
message = item.visibleMessage,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.visibleMessage)
},
)
}

Expand All @@ -557,6 +579,9 @@ internal fun ChatDetailChatScreen(
message = item.message,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.message)
},
)
}

Expand All @@ -571,6 +596,9 @@ internal fun ChatDetailChatScreen(
message = item.message,
createdAt = item.timestamp.toAmShortString(),
count = if (count <= 0) null else count,
onChatLongClick = {
onChatLongClick(item.message)
},
)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ object NetworkModule {
@Provides
@Singleton
fun providesOkhttpClient(): OkHttpClient = OkHttpClient.Builder()
.pingInterval(30, TimeUnit.SECONDS)
.readTimeout(99999, TimeUnit.SECONDS)
.writeTimeout(99999, TimeUnit.SECONDS)
.connectTimeout(99999, TimeUnit.SECONDS)
Expand Down

0 comments on commit 7f5d16d

Please sign in to comment.