From b45db2cdf3eb63214342fc9390604db66c9078f8 Mon Sep 17 00:00:00 2001 From: Sehwan Yun <39579912+l5x5l@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:07:00 +0900 Subject: [PATCH] [Fix] #67 qa bottom sheet (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] 닉네임 로직 수정 - isError 확인 * [fix] 공유하기 토스트 추가 - 토스트 추가 * [fix] 공유, 수정, 삭제 버튼 노출 * [fix] 메모 입력 버그 수정 * [chore] 코딩 컨벤션 반영 * [FIX] #67-링크 추가 화면에서 포킷목록 조회 bottomSheet에서 포킷목록이 많을 경우 화면을 꽉 채우는 문제 수정 * [FIX] #67-bottomSheet의 구분을 위한 그림자 추가 * [FIX] #67-홈 화면에서 bottomSheet의 배경 색상 수정 * [FIX] #67-라미인드 화면 배경 색상 조정 * [FIX] #67-리마인드 화면에서 "오늘 이 링크는 어때요?"에 표시되는 link UI의 카테고리 표시 부분 임시 숨김처리 수행 * [FIX] #67-검색 화면에서 공유 기능 누락 추가 --------- Co-authored-by: jiwon2724 --- .../template/bottomsheet/PokitBottomSheet.kt | 62 ++++++++++++------- .../template/bottomsheet/Preview.kt | 44 +++++++------ .../com/strayalpaca/addlink/AddLinkScreen.kt | 31 +++++++--- .../strayalpaca/addlink/AddLinkViewModel.kt | 4 +- .../java/pokitmons/pokit/home/HomeScreen.kt | 3 +- .../pokitmons/pokit/home/pokit/PokitScreen.kt | 6 ++ .../pokit/home/pokit/UnclassifiedScreen.kt | 14 +++++ .../pokit/home/remind/RemindScreen.kt | 11 +++- .../pokit/home/remind/TodayLinkCard.kt | 28 +++++---- .../pokit/nickname/InputNicknameScreen.kt | 8 +-- .../pokitdetail/PokitDetailScreen.kt | 16 +++++ .../pokitmons/pokit/search/SearchScreen.kt | 29 ++++++++- 12 files changed, 180 insertions(+), 76 deletions(-) diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt index 427b2860..dbd9e606 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility import androidx.compose.foundation.layout.width @@ -14,6 +15,7 @@ import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.Surface import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -22,6 +24,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color @@ -34,9 +37,10 @@ import pokitmons.pokit.core.ui.theme.PokitTheme fun PokitBottomSheet( onHideBottomSheet: () -> Unit, show: Boolean = false, + skipPartiallyExpanded: Boolean = true, content: @Composable (ColumnScope.() -> Unit), ) { - val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) + val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = skipPartiallyExpanded) var visibility by remember { mutableStateOf(show) } val scope = rememberCoroutineScope() @@ -63,31 +67,45 @@ fun PokitBottomSheet( }, sheetState = bottomSheetState, scrimColor = Color.Transparent, - shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), - containerColor = PokitTheme.colors.backgroundBase, - dragHandle = { - Column { - Spacer(modifier = Modifier.height(8.dp)) + containerColor = Color.Transparent, + dragHandle = null + ) { + Spacer(modifier = Modifier.height(8.dp).background(Color.Transparent)) - Box( - Modifier - .clip(RoundedCornerShape(4.dp)) - .width(36.dp) - .height(4.dp) - .background(color = PokitTheme.colors.iconTertiary) - ) + Surface( + shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), + color = PokitTheme.colors.backgroundBase, + shadowElevation = 20.dp + ) { + Column( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Spacer(modifier = Modifier.height(8.dp)) + + Box( + Modifier + .clip(RoundedCornerShape(4.dp)) + .width(36.dp) + .height(4.dp) + .background(color = PokitTheme.colors.iconTertiary) + ) + + Spacer(modifier = Modifier.height(12.dp)) + } - Spacer(modifier = Modifier.height(12.dp)) + content() + + Spacer( + Modifier.windowInsetsBottomHeight( + WindowInsets.navigationBarsIgnoringVisibility + ) + ) } } - ) { - content() - - Spacer( - Modifier.windowInsetsBottomHeight( - WindowInsets.navigationBarsIgnoringVisibility - ) - ) } } } diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/Preview.kt index 624e4e2c..b66f5e21 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/Preview.kt @@ -3,7 +3,6 @@ package pokitmons.pokit.core.ui.components.template.bottomsheet import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Button import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -27,36 +26,35 @@ private fun PokitSwitchRadioPreview() { Surface(modifier = Modifier.fillMaxSize()) { Surface( modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background + color = PokitTheme.colors.backgroundBase ) { Button(onClick = { showBottomSheet = true }) { Text(text = "Click!") } } - if (showBottomSheet) { - PokitBottomSheet( - onHideBottomSheet = { showBottomSheet = false } - ) { - PokitBottomSheetItem( - text = "즐겨찾기", - resourceId = R.drawable.icon_24_star_1, - data = "즐겨찾기", - onClick = { } - ) + PokitBottomSheet( + onHideBottomSheet = { showBottomSheet = false }, + show = showBottomSheet + ) { + PokitBottomSheetItem( + text = "즐겨찾기", + resourceId = R.drawable.icon_24_star_1, + data = "즐겨찾기", + onClick = { } + ) - HorizontalDivider( - thickness = 1.dp, - color = PokitTheme.colors.borderTertiary - ) + HorizontalDivider( + thickness = 1.dp, + color = PokitTheme.colors.borderTertiary + ) - PokitBottomSheetItem( - text = "공유하기", - resourceId = R.drawable.icon_24_share, - data = "공유하기", - onClick = { showBottomSheet = false } - ) - } + PokitBottomSheetItem( + text = "공유하기", + resourceId = R.drawable.icon_24_share, + data = "공유하기", + onClick = { showBottomSheet = false } + ) } } } diff --git a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt index 0c4bd205..f08baec8 100644 --- a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt +++ b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt @@ -89,7 +89,8 @@ fun AddLinkScreenContainer( PokitBottomSheet( onHideBottomSheet = viewModel::hideSelectPokitBottomSheet, - show = state.step == ScreenStep.POKIT_SELECT + show = state.step == ScreenStep.POKIT_SELECT, + skipPartiallyExpanded = false ) { val lazyColumnListState = rememberLazyListState() val startPaging = remember { @@ -272,17 +273,31 @@ fun AddLinkScreen( text = memo, hintText = stringResource(id = R.string.placeholder_memo), onChangeText = inputMemo, - enable = enable + enable = enable, + isError = memo.length >= 100 ) Spacer(modifier = Modifier.height(4.dp)) - Text( - modifier = Modifier.fillMaxWidth(), - text = "${memo.length}/100", - style = PokitTheme.typography.detail1.copy(color = PokitTheme.colors.textTertiary), - textAlign = TextAlign.End - ) + Row(verticalAlignment = Alignment.CenterVertically) { + if (memo.length >= 100) { + Text( + color = PokitTheme.colors.error, + text = "최대 100자까지 입력 가능합니다.", + style = PokitTheme.typography.detail1 + ) + } + + Spacer(modifier = Modifier.weight(1f)) + + Text( + color = if (memo.length >= 100) PokitTheme.colors.error else PokitTheme.colors.textTertiary, + modifier = Modifier.weight(1f), + text = "${memo.length}/100", + style = PokitTheme.typography.detail1, + textAlign = TextAlign.End + ) + } Spacer(modifier = Modifier.height(24.dp)) diff --git a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt index 3ef65cd4..84b04a4e 100644 --- a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt +++ b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkViewModel.kt @@ -177,7 +177,9 @@ class AddLinkViewModel @Inject constructor( } fun inputMemo(memo: String) { - _memo.update { memo } + if (memo.length <= 100) { + _memo.update { memo } + } } fun showSelectPokitBottomSheet() = intent { diff --git a/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt index 4757dcb8..86c878a0 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/HomeScreen.kt @@ -82,7 +82,8 @@ fun HomeScreen( onDismissRequest = { showBottomSheet = false }, - sheetState = sheetState + sheetState = sheetState, + containerColor = PokitTheme.colors.backgroundBase ) { Row( modifier = Modifier diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt index 5af92453..da716fc9 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt @@ -1,5 +1,7 @@ package pokitmons.pokit.home.pokit +import android.content.Context +import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,6 +17,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import coil.compose.rememberAsyncImagePainter @@ -47,6 +50,8 @@ fun PokitScreen( val pokitOptionBottomSheetType by viewModel.pokitOptionBottomSheetType.collectAsState() val currentDetailSelectedCategory by viewModel.currentDetailSelectedCategory.collectAsState() + val context: Context = LocalContext.current + PokitBottomSheet( onHideBottomSheet = viewModel::hidePokitDetailRemoveBottomSheet, show = pokitOptionBottomSheetType != null @@ -54,6 +59,7 @@ fun PokitScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( + onClickShare = { Toast.makeText(context, "준비중입니다.", Toast.LENGTH_SHORT).show() }, onClickModify = remember { { viewModel.hidePokitDetailRemoveBottomSheet() diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt index 6a780f86..011e44cc 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt @@ -1,5 +1,8 @@ package pokitmons.pokit.home.pokit +import android.content.Context +import android.content.Intent +import android.widget.Toast import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn @@ -9,6 +12,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -33,6 +37,8 @@ fun UnclassifiedScreen( val currentSelectedLink by viewModel.currentSelectedLink.collectAsState() val currentDetailShowLink by viewModel.currentDetailShowLink.collectAsState() + val context: Context = LocalContext.current + currentDetailShowLink?.let { link -> LinkDetailBottomSheet( title = link.title, @@ -45,6 +51,13 @@ fun UnclassifiedScreen( dateString = link.dateString, onHideBottomSheet = viewModel::hideDetailLinkBottomSheet, show = true, + onClickShareLink = { + val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, link.url) + } + context.startActivity(Intent.createChooser(intent, "Pokit")) + }, onClickBookmark = viewModel::toggleBookmark ) } @@ -56,6 +69,7 @@ fun UnclassifiedScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( + onClickShare = { Toast.makeText(context, "준비중입니다.", Toast.LENGTH_SHORT).show() }, onClickModify = remember { { viewModel.hideLinkOptionBottomSheet() diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt index 6b900077..bcc902c0 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt @@ -1,5 +1,8 @@ package pokitmons.pokit.home.remind +import android.content.Context +import android.widget.Toast +import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -17,6 +20,7 @@ import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -32,6 +36,7 @@ import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBotto import pokitmons.pokit.core.ui.components.template.pokkiempty.EmptyPokki import pokitmons.pokit.core.ui.components.template.pokkierror.ErrorPokki import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent +import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.core.ui.R.string as coreString @Composable @@ -54,6 +59,8 @@ fun RemindScreen( val pokitOptionBottomSheetType by viewModel.pokitOptionBottomSheetType.collectAsState() val currentSelectedLink by viewModel.currentSelectedLink.collectAsState() + val context: Context = LocalContext.current + val showTotalEmpty by remember { derivedStateOf { todayContentsState == NetworkState.IDLE && @@ -70,6 +77,7 @@ fun RemindScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( + onClickShare = { Toast.makeText(context, "준비중입니다.", Toast.LENGTH_SHORT).show() }, onClickModify = remember { { viewModel.hideLinkOptionBottomSheet() @@ -124,6 +132,7 @@ fun RemindScreen( } else { Column( modifier = modifier + .background(PokitTheme.colors.backgroundBase) .padding(20.dp) .fillMaxHeight() .verticalScroll(rememberScrollState()) @@ -154,7 +163,7 @@ fun RemindScreen( title = todayContent.title, sub = todayContent.createdAt, painter = rememberAsyncImagePainter(todayContent.thumbNail), - badgeText = todayContent.data, + badgeText = null, domain = todayContent.domain, onClick = { viewModel.showDetailLinkBottomSheet(remindResult = todayContent) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/TodayLinkCard.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/TodayLinkCard.kt index 888f971b..6cd3309a 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/TodayLinkCard.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/TodayLinkCard.kt @@ -36,7 +36,7 @@ fun ToadyLinkCard( title: String, sub: String, painter: Painter, - badgeText: String, + badgeText: String?, domain: String, onClick: () -> Unit, onClickKebab: () -> Unit, @@ -70,19 +70,21 @@ fun ToadyLinkCard( .align(Alignment.BottomStart) .padding(12.dp) ) { - Text( - style = PokitTheme.typography.label4, - text = badgeText, - color = PokitTheme.colors.textTertiary, - modifier = Modifier - .height(16.dp) - .width(34.dp) - .clip(RoundedCornerShape(4.dp)) - .background(PokitTheme.colors.backgroundPrimary) - .padding(horizontal = 4.dp, vertical = 2.dp) - ) + badgeText?.let { + Text( + style = PokitTheme.typography.label4, + text = badgeText, + color = PokitTheme.colors.textTertiary, + modifier = Modifier + .height(16.dp) + .width(34.dp) + .clip(RoundedCornerShape(4.dp)) + .background(PokitTheme.colors.backgroundPrimary) + .padding(horizontal = 4.dp, vertical = 2.dp) + ) - Spacer(modifier = Modifier.height(4.dp)) + Spacer(modifier = Modifier.height(4.dp)) + } Row( modifier = Modifier.fillMaxWidth(), diff --git a/feature/login/src/main/java/pokitmons/pokit/nickname/InputNicknameScreen.kt b/feature/login/src/main/java/pokitmons/pokit/nickname/InputNicknameScreen.kt index ce096374..f3173f75 100644 --- a/feature/login/src/main/java/pokitmons/pokit/nickname/InputNicknameScreen.kt +++ b/feature/login/src/main/java/pokitmons/pokit/nickname/InputNicknameScreen.kt @@ -67,11 +67,11 @@ fun InputNicknameScreen( maxLength = NICKNAME_MAX_LENGTH, sub = when { inputNicknameState.isDuplicate -> stringResource(id = Login.string.nickname_already_in_use) - inputNicknameState.isRegex -> stringResource(id = Login.string.input_restriction_message) - inputNicknameState.nickname.length < NICKNAME_MAX_LENGTH -> stringResource(id = Login.string.input_max_length) + !inputNicknameState.isRegex -> stringResource(id = Login.string.input_restriction_message) + inputNicknameState.nickname.length >= NICKNAME_MAX_LENGTH -> stringResource(id = Login.string.input_max_length) else -> "" }, - isError = inputNicknameState.nickname.length > NICKNAME_MAX_LENGTH || inputNicknameState.isDuplicate || inputNicknameState.isRegex, + isError = inputNicknameState.isRegex || inputNicknameState.isDuplicate || inputNicknameState.nickname.length >= NICKNAME_MAX_LENGTH, hintText = stringResource(id = Login.string.input_nickname_hint), onChangeText = { text -> Log.d("!! : ", text) @@ -79,9 +79,7 @@ fun InputNicknameScreen( viewModel.apply { inputText(text) if (checkNicknameRegex(text)) { - Log.d("!! : ", "else call") checkDuplicateNickname(text) - } else { } } } diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index eef10b24..1dd8c7df 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -1,5 +1,8 @@ package com.strayalpaca.pokitdetail +import android.content.Context +import android.content.Intent +import android.widget.Toast import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -17,6 +20,7 @@ import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import coil.compose.rememberAsyncImagePainter @@ -215,6 +219,7 @@ fun PokitDetailScreen( } if (state.currentLink != null) { + val context: Context = LocalContext.current LinkDetailBottomSheet( title = state.currentLink.title, memo = state.currentLink.memo, @@ -226,6 +231,13 @@ fun PokitDetailScreen( dateString = state.currentLink.dateString, onHideBottomSheet = hideLinkDetailBottomSheet, show = state.linkDetailBottomSheetVisible, + onClickShareLink = { + val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, state.currentLink.url) + } + context.startActivity(Intent.createChooser(intent, "Pokit")) + }, onClickBookmark = onClickBookmark ) } @@ -282,9 +294,11 @@ fun PokitDetailScreen( onHideBottomSheet = hideLinkModifyBottomSheet, show = state.linkBottomSheetType != null ) { + val context: Context = LocalContext.current when (state.linkBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( + onClickShare = { Toast.makeText(context, "준비중입니다.", Toast.LENGTH_SHORT).show() }, onClickModify = remember { { state.currentLink?.let { link -> @@ -319,7 +333,9 @@ fun PokitDetailScreen( ) { when (state.pokitBottomSheetType) { BottomSheetType.MODIFY -> { + val context: Context = LocalContext.current ModifyBottomSheetContent( + onClickShare = { Toast.makeText(context, "준비중입니다.", Toast.LENGTH_SHORT).show() }, onClickModify = remember { { hidePokitModifyBottomSheet() diff --git a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt index 8063935c..e084ec67 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt @@ -1,5 +1,7 @@ package pokitmons.pokit.search +import android.content.Context +import android.content.Intent import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -10,6 +12,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import coil.compose.rememberAsyncImagePainter @@ -48,6 +51,8 @@ fun SearchScreenContainer( val pokitList by viewModel.pokitList.collectAsState() val pokitPagingState by viewModel.pokitPagingState.collectAsState() + val context: Context = LocalContext.current + state.currentLink?.let { link -> LinkDetailBottomSheet( title = link.title, @@ -60,6 +65,13 @@ fun SearchScreenContainer( dateString = link.dateString, onHideBottomSheet = viewModel::hideLinkDetailBottomSheet, show = state.showLinkDetailBottomSheet, + onClickShareLink = { + val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, state.currentLink?.url) + } + context.startActivity(Intent.createChooser(intent, "Pokit")) + }, onClickModifyLink = { viewModel.hideLinkDetailBottomSheet() onNavigateToLinkModify(link.id) @@ -103,6 +115,15 @@ fun SearchScreenContainer( viewModel.showLinkRemoveBottomSheet(link) } } + }, + onClickShare = remember { + { + val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, state.currentLink?.url) + } + context.startActivity(Intent.createChooser(intent, "Pokit")) + } } ) } @@ -211,7 +232,9 @@ fun SearchScreen( } (linkPagingState == SimplePagingState.FAILURE_INIT) -> { ErrorPokki( - modifier = Modifier.fillMaxWidth().weight(1f), + modifier = Modifier + .fillMaxWidth() + .weight(1f), title = stringResource(id = coreString.title_error), sub = stringResource(id = coreString.sub_error), onClickRetry = onClickSearch @@ -219,7 +242,9 @@ fun SearchScreen( } (linkList.isEmpty()) -> { EmptyPokki( - modifier = Modifier.fillMaxWidth().weight(1f), + modifier = Modifier + .fillMaxWidth() + .weight(1f), title = stringResource(id = coreString.title_empty_search), sub = stringResource(id = coreString.sub_empty_search) )