From 53721115152b505ddfe8a5a51215ae23e41a415a Mon Sep 17 00:00:00 2001 From: ows3090 Date: Wed, 27 Dec 2023 02:49:53 +0900 Subject: [PATCH 01/13] =?UTF-8?q?[UI]=20#43=20=EC=A7=80=EB=8F=84=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=97=90=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EB=B0=94=ED=85=80=20=EC=8B=9C=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/modal/GifticonInfoModalSheet.kt | 101 +++++++----------- .../src/main/res/values/strings.xml | 3 + .../java/com/yapp/buddycon/map/MapScreen.kt | 43 +++++++- 3 files changed, 80 insertions(+), 67 deletions(-) diff --git a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt index d989128f..ac356b2e 100644 --- a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt +++ b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt @@ -1,24 +1,16 @@ package com.yapp.buddycon.designsystem.component.modal +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.SheetState import androidx.compose.material3.Text -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable -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.graphics.Color @@ -35,64 +27,51 @@ private val GifticonInfoModalSheetHeight = 167.dp private val GifticonInfoModalSheetRadius = 24.dp private val GifticonInfoModalHorizontalPadding = 15.dp private val GifticonInfoModalItemIconSize = 64.dp -private val GifticonInfoModalDescription = "GifticonInfoModal" +private const val GifticonInfoModalDescription = "GifticonInfoModal" @OptIn(ExperimentalMaterial3Api::class) @Composable -fun GifticonInfoModalSheet( - sheetState: SheetState = rememberModalBottomSheetState(), +fun GifticonInfoModalSheetContent( + modifier: Modifier = Modifier, countOfUsableGifticon: Int, - countOfImminetGifticon: Int, - onDismiss: () -> Unit + countOfImminetGifticon: Int ) { - ModalBottomSheet( - onDismissRequest = onDismiss, - modifier = Modifier + Row( + modifier = modifier + .background(BuddyConTheme.colors.background) .fillMaxWidth() - .height(GifticonInfoModalSheetHeight), - sheetState = sheetState, - shape = RoundedCornerShape( - topStart = GifticonInfoModalSheetRadius, - topEnd = GifticonInfoModalSheetRadius - ), - containerColor = BuddyConTheme.colors.modalColor + .padding(horizontal = GifticonInfoModalHorizontalPadding) + .wrapContentHeight(), + verticalAlignment = Alignment.CenterVertically ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = GifticonInfoModalHorizontalPadding) - .wrapContentHeight(), - verticalAlignment = Alignment.CenterVertically + Column( + modifier = Modifier.weight(1f) ) { - Column( - modifier = Modifier.weight(1f) - ) { + Text( + text = stringResource(R.string.modal_sheet_gifticon), + style = BuddyConTheme.typography.subTitle + ) + Row(verticalAlignment = Alignment.Bottom) { + Text( + text = "${countOfUsableGifticon}개", + style = BuddyConTheme.typography.title01 + ) Text( - text = stringResource(R.string.modal_sheet_gifticon), - style = BuddyConTheme.typography.subTitle + text = String.format( + stringResource(R.string.modal_sheet_imminet_gifticon), + countOfImminetGifticon + ), + modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), + style = BuddyConTheme.typography.body04.copy(color = Pink100) ) - Row(verticalAlignment = Alignment.Bottom) { - Text( - text = "${countOfUsableGifticon}개", - style = BuddyConTheme.typography.title01 - ) - Text( - text = String.format( - stringResource(R.string.modal_sheet_imminet_gifticon), - countOfImminetGifticon - ), - modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), - style = BuddyConTheme.typography.body04.copy(color = Pink100) - ) - } } - Icon( - painter = painterResource(R.drawable.ic_gifticon), - contentDescription = GifticonInfoModalDescription, - modifier = Modifier.size(GifticonInfoModalItemIconSize), - tint = Color.Unspecified - ) } + Icon( + painter = painterResource(R.drawable.ic_gifticon), + contentDescription = GifticonInfoModalDescription, + modifier = Modifier.size(GifticonInfoModalItemIconSize), + tint = Color.Unspecified + ) } } @@ -100,14 +79,10 @@ fun GifticonInfoModalSheet( @Preview @Composable private fun GifticonInfoModalSheetPreview() { - var isShowModal by remember { mutableStateOf(true) } BuddyConTheme { - if (isShowModal) { - GifticonInfoModalSheet( - countOfUsableGifticon = 12, - countOfImminetGifticon = 1, - onDismiss = { isShowModal = false } - ) - } + GifticonInfoModalSheetContent( + countOfUsableGifticon = 12, + countOfImminetGifticon = 1 + ) } } diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index ad564a84..fd43b5cd 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -60,4 +60,7 @@ 사용처 선택 메모 최대 50자 입력 + + 지도 + diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index d352a42c..2ddeb631 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -1,12 +1,47 @@ package com.yapp.buddycon.map -import androidx.compose.foundation.layout.Column -import androidx.compose.material3.Text +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.BottomSheetScaffold +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SheetState +import androidx.compose.material3.SheetValue +import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.yapp.buddycon.designsystem.R +import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification +import com.yapp.buddycon.designsystem.component.modal.GifticonInfoModalSheetContent +import com.yapp.buddycon.designsystem.theme.BuddyConTheme +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MapScreen() { - Column { - Text(text = "Map") + BottomSheetScaffold( + sheetContent = { + GifticonInfoModalSheetContent( + modifier = Modifier.padding(bottom = 11.dp), + countOfUsableGifticon = 12, + countOfImminetGifticon = 1 + ) + }, + scaffoldState = rememberBottomSheetScaffoldState( + bottomSheetState = SheetState( + skipPartiallyExpanded = false, + initialValue = SheetValue.Expanded, + skipHiddenState = true + ) + ), + sheetShape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), + sheetContainerColor = BuddyConTheme.colors.background, + sheetShadowElevation = 33.dp, + topBar = { + TopAppBarWithNotification( + title = stringResource(R.string.map) + ) + } + ) { } } From 9fd8d88e09db03259761e02e64533091116fbcec Mon Sep 17 00:00:00 2001 From: ows3090 Date: Wed, 27 Dec 2023 17:22:08 +0900 Subject: [PATCH 02/13] =?UTF-8?q?[UI]=20#43=20=EC=A7=80=EB=8F=84=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=9D=98=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=ED=83=AD=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/model/type/GifticonCategory.kt | 4 +- feature/map/build.gradle | 1 + .../java/com/yapp/buddycon/map/MapScreen.kt | 53 +++++++++++++++++++ .../java/com/yapp/buddycon/map/MapUiState.kt | 7 +++ .../com/yapp/buddycon/map/MapViewModel.kt | 19 +++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt create mode 100644 feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt diff --git a/domain/src/main/java/com/yapp/buddycon/domain/model/type/GifticonCategory.kt b/domain/src/main/java/com/yapp/buddycon/domain/model/type/GifticonCategory.kt index 5535bbad..fbe12f0b 100644 --- a/domain/src/main/java/com/yapp/buddycon/domain/model/type/GifticonCategory.kt +++ b/domain/src/main/java/com/yapp/buddycon/domain/model/type/GifticonCategory.kt @@ -1,6 +1,7 @@ package com.yapp.buddycon.domain.model.type enum class GifticonCategory(val value: String) { + TOTAL("전체"), STARBUCKS("스타벅스"), TWOSOME("투썸플레이스"), MCDONALD("맥도날드"), @@ -8,6 +9,5 @@ enum class GifticonCategory(val value: String) { GONGCHA("공차"), CU("CU"), GS25("GS25"), - ETC("기타"), - TOTAL("전체") + ETC("기타") } diff --git a/feature/map/build.gradle b/feature/map/build.gradle index 605cd050..6e4bdc4c 100644 --- a/feature/map/build.gradle +++ b/feature/map/build.gradle @@ -37,6 +37,7 @@ android { dependencies { implementation project(":core:designsystem") + implementation project(":domain") implementation libs.androidx.core.ktx implementation libs.androidx.activity.compose diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 2ddeb631..73b36432 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -1,6 +1,13 @@ package com.yapp.buddycon.map +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.BottomSheetScaffold import androidx.compose.material3.ExperimentalMaterial3Api @@ -8,13 +15,19 @@ import androidx.compose.material3.SheetState import androidx.compose.material3.SheetValue import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification +import com.yapp.buddycon.designsystem.component.button.CategoryButton import com.yapp.buddycon.designsystem.component.modal.GifticonInfoModalSheetContent import com.yapp.buddycon.designsystem.theme.BuddyConTheme +import com.yapp.buddycon.designsystem.theme.Paddings +import com.yapp.buddycon.domain.model.type.GifticonCategory @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -42,6 +55,46 @@ fun MapScreen() { title = stringResource(R.string.map) ) } + ) { paddingValues -> + MapContent( + modifier = Modifier + .padding(paddingValues) + .fillMaxSize() + .background(BuddyConTheme.colors.background) + ) + } +} + +@Composable +private fun MapContent( + modifier: Modifier = Modifier, + mapViewModel: MapViewModel = hiltViewModel() +) { + val uiState by mapViewModel.uiState.collectAsStateWithLifecycle() + Column(modifier) { + MapCategoryTab( + category = uiState.category, + onCategoryChange = { mapViewModel.changeCategory(it) } + ) + } +} + +@Composable +private fun MapCategoryTab( + category: GifticonCategory, + onCategoryChange: (GifticonCategory) -> Unit = { } +) { + LazyRow( + modifier = Modifier + .padding(Paddings.xlarge) + .fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(Paddings.small) ) { + items(GifticonCategory.values()) { + CategoryButton( + gifticonCategory = it, + isSelected = it == category + ) + } } } diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt new file mode 100644 index 00000000..f23de3c5 --- /dev/null +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt @@ -0,0 +1,7 @@ +package com.yapp.buddycon.map + +import com.yapp.buddycon.domain.model.type.GifticonCategory + +data class MapUiState( + val category: GifticonCategory = GifticonCategory.TOTAL +) diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt new file mode 100644 index 00000000..91d45287 --- /dev/null +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt @@ -0,0 +1,19 @@ +package com.yapp.buddycon.map + +import androidx.lifecycle.ViewModel +import com.yapp.buddycon.domain.model.type.GifticonCategory +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject + +@HiltViewModel +class MapViewModel @Inject constructor() : ViewModel() { + + private val _uiState = MutableStateFlow(MapUiState()) + val uiState = _uiState.asStateFlow() + + fun changeCategory(category: GifticonCategory) { + _uiState.value = _uiState.value.copy(category = category) + } +} From 85128c9625f1ef20e9832c630af43415c8ae291b Mon Sep 17 00:00:00 2001 From: ows3090 Date: Wed, 27 Dec 2023 17:36:42 +0900 Subject: [PATCH 03/13] =?UTF-8?q?[UI]=20#43=20=EC=8A=A4=EB=82=B5=EB=B0=94?= =?UTF-8?q?=20=EC=9C=84=EC=B9=98=20=EC=A1=B0=EC=A0=95=ED=95=A0=20=EC=88=98?= =?UTF-8?q?=20=EC=9E=88=EB=8F=84=EB=A1=9D=20Modifier=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=85=B8=EC=B6=9C=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/snackbar/BuddyConSnackbar.kt | 10 ++++++---- .../gifticon/register/GifticonRegisterScreen.kt | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/snackbar/BuddyConSnackbar.kt b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/snackbar/BuddyConSnackbar.kt index 4edd799e..ccb74edf 100644 --- a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/snackbar/BuddyConSnackbar.kt +++ b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/snackbar/BuddyConSnackbar.kt @@ -37,14 +37,16 @@ private val SNACKBAR_DISMISS_ICON_DESCRIPTION = "SNACKBAR_DISMISS" @Composable fun BuddyConSnackbar( - snackbarHostState: SnackbarHostState = remember { SnackbarHostState() } + modifier: Modifier = Modifier, + snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }, + contentAlignment: Alignment = Alignment.BottomCenter ) { SnackbarHost( hostState = snackbarHostState ) { snackbarData -> Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.BottomCenter + modifier = modifier.fillMaxSize(), + contentAlignment = contentAlignment ) { Row( modifier = Modifier @@ -88,7 +90,7 @@ fun showBuddyConSnackBar( scope.launch { snackbarHostState.showSnackbar( message = message, - duration = SnackbarDuration.Long + duration = SnackbarDuration.Short ) } } diff --git a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt index 5845ebf6..e689064a 100644 --- a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt +++ b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt @@ -123,7 +123,7 @@ fun GifticonRegisterScreen( ) } }, - snackbarHost = { BuddyConSnackbar(snackbarHostState) } + snackbarHost = { BuddyConSnackbar(snackbarHostState = snackbarHostState) } ) { paddingValues -> GifticonRegisterContent( modifier = Modifier From 10a0cd7321a5e4f48258179592b5077f27852321 Mon Sep 17 00:00:00 2001 From: ows3090 Date: Thu, 28 Dec 2023 03:46:12 +0900 Subject: [PATCH 04/13] =?UTF-8?q?[UI]=20#43=20=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=ED=8C=9D=EC=97=85=20=EB=85=B8=EC=B6=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=81=B4=EB=A6=AD=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 + .../component/button/CategoryButton.kt | 6 ++- .../src/main/res/values/strings.xml | 1 + .../java/com/yapp/buddycon/map/MapScreen.kt | 50 ++++++++++++++++++- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index efb96eae..e02b9e73 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,8 @@ xmlns:tools="http://schemas.android.com/tools"> + + Unit = {} ) { Box( modifier = Modifier @@ -33,7 +35,7 @@ fun CategoryButton( .padding( horizontal = CategoryButtonHorizontalPadding, vertical = CategoryButtonVerticalPadding - ), + ).clickable { onClick() }, contentAlignment = Alignment.Center ) { Text( diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index fd43b5cd..c0e44229 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -62,5 +62,6 @@ 최대 50자 입력 지도 + 위치 정보를 허용했어요! diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 73b36432..489243a1 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -1,5 +1,9 @@ package com.yapp.buddycon.map +import android.Manifest +import android.content.pm.PackageManager +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -13,18 +17,27 @@ import androidx.compose.material3.BottomSheetScaffold import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.SheetState import androidx.compose.material3.SheetValue +import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment 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.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification import com.yapp.buddycon.designsystem.component.button.CategoryButton import com.yapp.buddycon.designsystem.component.modal.GifticonInfoModalSheetContent +import com.yapp.buddycon.designsystem.component.snackbar.BuddyConSnackbar +import com.yapp.buddycon.designsystem.component.snackbar.showBuddyConSnackBar import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.domain.model.type.GifticonCategory @@ -32,6 +45,33 @@ import com.yapp.buddycon.domain.model.type.GifticonCategory @OptIn(ExperimentalMaterial3Api::class) @Composable fun MapScreen() { + val context = LocalContext.current + val coroutineScope = rememberCoroutineScope() + val snackbarHostState = remember { SnackbarHostState() } + val permissions = arrayOf( + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION + ) + + val permissionsLauncher = rememberLauncherForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { permissions -> + val isGranted = permissions.values.all { it } + if (isGranted) { + showBuddyConSnackBar( + message = context.getString(R.string.map_location_permission), + scope = coroutineScope, + snackbarHostState = snackbarHostState + ) + } + } + + LaunchedEffect(Unit) { + if (permissions.any { ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_DENIED }) { + permissionsLauncher.launch(permissions) + } + } + BottomSheetScaffold( sheetContent = { GifticonInfoModalSheetContent( @@ -54,6 +94,13 @@ fun MapScreen() { TopAppBarWithNotification( title = stringResource(R.string.map) ) + }, + snackbarHost = { + BuddyConSnackbar( + modifier = Modifier.padding(top = 128.dp), + snackbarHostState = snackbarHostState, + contentAlignment = Alignment.TopCenter + ) } ) { paddingValues -> MapContent( @@ -93,7 +140,8 @@ private fun MapCategoryTab( items(GifticonCategory.values()) { CategoryButton( gifticonCategory = it, - isSelected = it == category + isSelected = it == category, + onClick = { onCategoryChange(it) } ) } } From ee1d2a3fbdb7624f83c8a4cc5870948c4e87388d Mon Sep 17 00:00:00 2001 From: ows3090 Date: Fri, 29 Dec 2023 03:49:14 +0900 Subject: [PATCH 05/13] =?UTF-8?q?[build]=20#43=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EC=9C=A0=ED=8B=B8=EB=A6=AC=ED=8B=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=ED=95=98=EB=8A=94=20=EC=9C=A0=ED=8B=B8=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/utility/.gitignore | 1 + core/utility/build.gradle | 51 +++++++++++++++++++ core/utility/proguard-rules.pro | 21 ++++++++ core/utility/src/main/AndroidManifest.xml | 4 ++ .../java/com/yapp/buddycon/utility/Density.kt | 11 ++++ settings.gradle | 2 + 6 files changed, 90 insertions(+) create mode 100644 core/utility/.gitignore create mode 100644 core/utility/build.gradle create mode 100644 core/utility/proguard-rules.pro create mode 100644 core/utility/src/main/AndroidManifest.xml create mode 100644 core/utility/src/main/java/com/yapp/buddycon/utility/Density.kt diff --git a/core/utility/.gitignore b/core/utility/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/core/utility/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/utility/build.gradle b/core/utility/build.gradle new file mode 100644 index 00000000..f3828a29 --- /dev/null +++ b/core/utility/build.gradle @@ -0,0 +1,51 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) +} + +android { + namespace 'com.yapp.buddycon.utility' + compileSdk 33 + + defaultConfig { + minSdk 26 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion '1.4.3' + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = '17' + } +} + +dependencies { + implementation libs.timber + implementation libs.androidx.core.ktx + implementation libs.androidx.activity.compose + implementation platform(libs.androidx.compose.bom) + implementation libs.bundles.androidx.compose + testImplementation libs.junit + androidTestImplementation libs.androidx.junit + androidTestImplementation libs.androidx.espresso.core + androidTestImplementation platform(libs.androidx.compose.bom) + androidTestImplementation libs.androidx.compose.ui.test.junit + debugImplementation libs.androidx.compose.ui.tooling + debugImplementation libs.androidx.compose.ui.test.manifest +} \ No newline at end of file diff --git a/core/utility/proguard-rules.pro b/core/utility/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/core/utility/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/core/utility/src/main/AndroidManifest.xml b/core/utility/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/core/utility/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/core/utility/src/main/java/com/yapp/buddycon/utility/Density.kt b/core/utility/src/main/java/com/yapp/buddycon/utility/Density.kt new file mode 100644 index 00000000..bad3d291 --- /dev/null +++ b/core/utility/src/main/java/com/yapp/buddycon/utility/Density.kt @@ -0,0 +1,11 @@ +package com.yapp.buddycon.utility + +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.Dp + +@Composable +fun Float.toDp() = with(LocalDensity.current) { this@toDp.toDp() } + +@Composable +fun Dp.toPx() = with(LocalDensity.current) { this@toPx.toPx() } diff --git a/settings.gradle b/settings.gradle index 60507fb9..b0d6b51d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,6 +11,7 @@ dependencyResolutionManagement { google() mavenCentral() maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' } + maven { url 'https://naver.jfrog.io/artifactory/maven/'} } } rootProject.name = "BuddyCon" @@ -25,3 +26,4 @@ include ':feature:mypage' include ':feature:startup' include ':core:local' include ':core:network' +include ':core:utility' From 39798c6350ff39352563e01e829886d7a3106199 Mon Sep 17 00:00:00 2001 From: ows3090 Date: Fri, 29 Dec 2023 03:49:59 +0900 Subject: [PATCH 06/13] =?UTF-8?q?[UI]=20#43=20Compose=20=EC=9A=A9=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B2=84=20=EB=A7=B5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A7=80=EB=8F=84=20=EB=85=B8=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 10 +- .../buddycon/navigation/BuddyConNavHost.kt | 2 +- feature/map/build.gradle | 3 + .../java/com/yapp/buddycon/map/MapScreen.kt | 113 +++++++++++------- gradle.properties | 1 + gradle/libs.versions.toml | 6 + 7 files changed, 91 insertions(+), 46 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index de595f49..8990d086 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { versionName "1.0" buildConfigField("String", "KAKAO_APP_KEY", properties.getProperty("KAKAO_APP_KEY")) - + resValue("string", "NAVER_CLIENT_ID", properties.getProperty("NAVER_CLIENT_ID")) testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e02b9e73..8a1c93b7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,9 +2,9 @@ - - - + + + + + \ No newline at end of file diff --git a/core/navigation/src/main/java/com/yapp/buddycon/navigation/BuddyConNavHost.kt b/core/navigation/src/main/java/com/yapp/buddycon/navigation/BuddyConNavHost.kt index 316a5b5e..412d828f 100644 --- a/core/navigation/src/main/java/com/yapp/buddycon/navigation/BuddyConNavHost.kt +++ b/core/navigation/src/main/java/com/yapp/buddycon/navigation/BuddyConNavHost.kt @@ -68,7 +68,7 @@ fun BuddyConNavHost( composable(route = StartUpDestination.Login.route) { LoginScreen { - navHostController.navigate(StartUpDestination.SignUp.route) + navHostController.navigate(GifticonDestination.Gifticon.route) } } diff --git a/feature/map/build.gradle b/feature/map/build.gradle index 6e4bdc4c..89fda288 100644 --- a/feature/map/build.gradle +++ b/feature/map/build.gradle @@ -37,8 +37,11 @@ android { dependencies { implementation project(":core:designsystem") + implementation project(":core:utility") implementation project(":domain") + implementation libs.naver.map.compose + implementation libs.timber implementation libs.androidx.core.ktx implementation libs.androidx.activity.compose implementation platform(libs.androidx.compose.bom) diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 489243a1..a45a3bc1 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -5,7 +5,11 @@ import android.content.pm.PackageManager import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.Orientation +import androidx.compose.foundation.gestures.draggable +import androidx.compose.foundation.gestures.rememberDraggableState import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -15,15 +19,14 @@ import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.BottomSheetScaffold import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.SheetState -import androidx.compose.material3.SheetValue import androidx.compose.material3.SnackbarHostState -import androidx.compose.material3.rememberBottomSheetScaffoldState 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.rememberCoroutineScope +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -32,6 +35,8 @@ import androidx.compose.ui.unit.dp import androidx.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.naver.maps.map.compose.ExperimentalNaverMapApi +import com.naver.maps.map.compose.NaverMap import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification import com.yapp.buddycon.designsystem.component.button.CategoryButton @@ -41,52 +46,31 @@ import com.yapp.buddycon.designsystem.component.snackbar.showBuddyConSnackBar import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.domain.model.type.GifticonCategory +import com.yapp.buddycon.utility.toDp @OptIn(ExperimentalMaterial3Api::class) @Composable fun MapScreen() { - val context = LocalContext.current - val coroutineScope = rememberCoroutineScope() val snackbarHostState = remember { SnackbarHostState() } - val permissions = arrayOf( - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION - ) - - val permissionsLauncher = rememberLauncherForActivityResult( - ActivityResultContracts.RequestMultiplePermissions() - ) { permissions -> - val isGranted = permissions.values.all { it } - if (isGranted) { - showBuddyConSnackBar( - message = context.getString(R.string.map_location_permission), - scope = coroutineScope, - snackbarHostState = snackbarHostState - ) - } - } - - LaunchedEffect(Unit) { - if (permissions.any { ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_DENIED }) { - permissionsLauncher.launch(permissions) - } - } + var offsetY by remember { mutableStateOf(111f) } + RequestLocationPermission(snackbarHostState) BottomSheetScaffold( sheetContent = { - GifticonInfoModalSheetContent( - modifier = Modifier.padding(bottom = 11.dp), - countOfUsableGifticon = 12, - countOfImminetGifticon = 1 + MapBottomSheet( + modifier = Modifier + .background(BuddyConTheme.colors.background) + .draggable( + state = rememberDraggableState { delta -> + if (offsetY > 0) { + offsetY -= delta + } + }, + orientation = Orientation.Vertical + ) ) }, - scaffoldState = rememberBottomSheetScaffoldState( - bottomSheetState = SheetState( - skipPartiallyExpanded = false, - initialValue = SheetValue.Expanded, - skipHiddenState = true - ) - ), + sheetPeekHeight = offsetY.toDp(), sheetShape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), sheetContainerColor = BuddyConTheme.colors.background, sheetShadowElevation = 33.dp, @@ -95,9 +79,10 @@ fun MapScreen() { title = stringResource(R.string.map) ) }, + sheetDragHandle = null, snackbarHost = { BuddyConSnackbar( - modifier = Modifier.padding(top = 128.dp), + modifier = Modifier.padding(top = 162.dp), snackbarHostState = snackbarHostState, contentAlignment = Alignment.TopCenter ) @@ -112,6 +97,19 @@ fun MapScreen() { } } +@Composable +private fun MapBottomSheet( + modifier: Modifier = Modifier +) { + Box(modifier) { + GifticonInfoModalSheetContent( + countOfUsableGifticon = 12, + countOfImminetGifticon = 1 + ) + } +} + +@OptIn(ExperimentalNaverMapApi::class) @Composable private fun MapContent( modifier: Modifier = Modifier, @@ -123,6 +121,9 @@ private fun MapContent( category = uiState.category, onCategoryChange = { mapViewModel.changeCategory(it) } ) + NaverMap( + modifier = Modifier.fillMaxSize() + ) } } @@ -133,7 +134,8 @@ private fun MapCategoryTab( ) { LazyRow( modifier = Modifier - .padding(Paddings.xlarge) + .padding(horizontal = Paddings.xlarge) + .padding(top = Paddings.xlarge, bottom = Paddings.large) .fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(Paddings.small) ) { @@ -146,3 +148,32 @@ private fun MapCategoryTab( } } } + +@Composable +private fun RequestLocationPermission(snackbarHostState: SnackbarHostState) { + val context = LocalContext.current + val coroutineScope = rememberCoroutineScope() + val permissions = arrayOf( + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION + ) + + val permissionsLauncher = rememberLauncherForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { permissions -> + val isGranted = permissions.values.all { it } + if (isGranted) { + showBuddyConSnackBar( + message = context.getString(R.string.map_location_permission), + scope = coroutineScope, + snackbarHostState = snackbarHostState + ) + } + } + + LaunchedEffect(Unit) { + if (permissions.any { ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_DENIED }) { + permissionsLauncher.launch(permissions) + } + } +} diff --git a/gradle.properties b/gradle.properties index 3c5031eb..1a982b5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true +android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 81bb6561..efa42bff 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,6 +34,9 @@ coroutine-core = "1.6.4" ## kakao kakao = "2.18.0" +## naver-map +naver-map-compose = "1.3.3" + ## test junit = "4.13.2" androidx-junit = "1.1.5" @@ -93,6 +96,9 @@ coroutine-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-a ## kakao kakao-user = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao" } +## naver-map +naver-map-compose = { group = "io.github.fornewid", name = "naver-map-compose", version.ref = "naver-map-compose" } + ## test junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-junit" } From b73e95ba7af1a5ebcdfef750f2a9a943424f10db Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 31 Dec 2023 23:17:25 +0900 Subject: [PATCH 07/13] =?UTF-8?q?[UI]=20#43=20=EB=93=9C=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=20=EC=98=81=EC=97=AD=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=EC=8B=9C=ED=8A=B8=20=ED=98=95=ED=83=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yapp/buddycon/map/MapScreen.kt | 57 ++++++++++++++----- .../java/com/yapp/buddycon/map/MapUiState.kt | 17 +++++- .../com/yapp/buddycon/map/MapViewModel.kt | 16 ++++++ 3 files changed, 75 insertions(+), 15 deletions(-) diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index a45a3bc1..e108b2a5 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.gestures.rememberDraggableState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -23,12 +24,12 @@ import androidx.compose.material3.SnackbarHostState 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.rememberCoroutineScope -import androidx.compose.runtime.setValue +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -36,6 +37,7 @@ import androidx.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.naver.maps.map.compose.ExperimentalNaverMapApi +import com.naver.maps.map.compose.MapUiSettings import com.naver.maps.map.compose.NaverMap import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification @@ -46,13 +48,21 @@ import com.yapp.buddycon.designsystem.component.snackbar.showBuddyConSnackBar import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.domain.model.type.GifticonCategory -import com.yapp.buddycon.utility.toDp +import com.yapp.buddycon.utility.toPx @OptIn(ExperimentalMaterial3Api::class) @Composable -fun MapScreen() { +fun MapScreen( + mapViewModel: MapViewModel = hiltViewModel() +) { + val context = LocalContext.current + val configuration = LocalConfiguration.current + val density = context.resources.displayMetrics.density + val mapScreenHeightDp = (configuration.screenHeightDp - 244).toFloat() + val mapScreenHeightPx = mapScreenHeightDp.dp.toPx() val snackbarHostState = remember { SnackbarHostState() } - var offsetY by remember { mutableStateOf(111f) } + val mapUiState by mapViewModel.uiState.collectAsStateWithLifecycle() + val heightPx by rememberUpdatedState(mapUiState.heightDp * density) RequestLocationPermission(snackbarHostState) BottomSheetScaffold( @@ -62,24 +72,39 @@ fun MapScreen() { .background(BuddyConTheme.colors.background) .draggable( state = rememberDraggableState { delta -> - if (offsetY > 0) { - offsetY -= delta + if ((heightPx - delta) in 0f..mapScreenHeightPx) { + mapViewModel.changeHeightDp((heightPx - delta) / density) } }, - orientation = Orientation.Vertical + orientation = Orientation.Vertical, + onDragStarted = { + mapViewModel.changeSheetValue(BottomSheetValue.Moving(mapUiState.heightDp)) + }, + onDragStopped = { + mapViewModel.changeSheetValue( + when (mapUiState.heightDp) { + in BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp..(mapScreenHeightDp / 2f - 1) -> { + BottomSheetValue.PartiallyExpanded + } + + in (mapScreenHeightDp / 2f)..mapScreenHeightDp -> BottomSheetValue.Expanded + else -> BottomSheetValue.Collapsed + } + ) + } ) ) }, - sheetPeekHeight = offsetY.toDp(), + sheetPeekHeight = mapUiState.heightDp.dp, sheetShape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), sheetContainerColor = BuddyConTheme.colors.background, sheetShadowElevation = 33.dp, + sheetDragHandle = null, topBar = { TopAppBarWithNotification( title = stringResource(R.string.map) ) }, - sheetDragHandle = null, snackbarHost = { BuddyConSnackbar( modifier = Modifier.padding(top = 162.dp), @@ -87,10 +112,9 @@ fun MapScreen() { contentAlignment = Alignment.TopCenter ) } - ) { paddingValues -> + ) { MapContent( modifier = Modifier - .padding(paddingValues) .fillMaxSize() .background(BuddyConTheme.colors.background) ) @@ -101,7 +125,7 @@ fun MapScreen() { private fun MapBottomSheet( modifier: Modifier = Modifier ) { - Box(modifier) { + Box(modifier.fillMaxHeight()) { GifticonInfoModalSheetContent( countOfUsableGifticon = 12, countOfImminetGifticon = 1 @@ -122,7 +146,12 @@ private fun MapContent( onCategoryChange = { mapViewModel.changeCategory(it) } ) NaverMap( - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), + uiSettings = MapUiSettings( + isZoomControlEnabled = false, + isLogoClickEnabled = false, + isScaleBarEnabled = false + ) ) } } diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt index f23de3c5..73fee67f 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt @@ -3,5 +3,20 @@ package com.yapp.buddycon.map import com.yapp.buddycon.domain.model.type.GifticonCategory data class MapUiState( - val category: GifticonCategory = GifticonCategory.TOTAL + val category: GifticonCategory = GifticonCategory.TOTAL, + val sheetValue: BottomSheetValue = BottomSheetValue.PartiallyExpanded, + val heightDp: Float = 36f ) + +sealed class BottomSheetValue(open val sheetPeekHeightDp: Float) { + + object Collapsed : BottomSheetValue(36f) + + object PartiallyExpanded : BottomSheetValue(111f) + + object Expanded : BottomSheetValue(540f) + + data class Moving( + override val sheetPeekHeightDp: Float + ) : BottomSheetValue(sheetPeekHeightDp) +} diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt index 91d45287..94f275ba 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt @@ -16,4 +16,20 @@ class MapViewModel @Inject constructor() : ViewModel() { fun changeCategory(category: GifticonCategory) { _uiState.value = _uiState.value.copy(category = category) } + + fun changeSheetValue(sheetValue: BottomSheetValue) { + _uiState.value = _uiState.value.copy( + sheetValue = sheetValue, + heightDp = when (sheetValue) { + BottomSheetValue.Collapsed -> BottomSheetValue.Collapsed.sheetPeekHeightDp + BottomSheetValue.PartiallyExpanded -> BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp + BottomSheetValue.Expanded -> BottomSheetValue.Expanded.sheetPeekHeightDp + is BottomSheetValue.Moving -> uiState.value.heightDp + } + ) + } + + fun changeHeightDp(heightDp: Float) { + _uiState.value = _uiState.value.copy(heightDp = heightDp) + } } From 0378b0be240ade5227ed46bae9c9c016af7d54cd Mon Sep 17 00:00:00 2001 From: ows3090 Date: Tue, 2 Jan 2024 00:50:07 +0900 Subject: [PATCH 08/13] =?UTF-8?q?[UI]=20#43=20=EB=B0=94=ED=85=80=EC=8B=9C?= =?UTF-8?q?=ED=8A=B8=20=ED=98=95=ED=83=9C=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=BB=A8=ED=85=90=EC=B8=A0=20=EB=B3=80=EA=B2=BD=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modal/GifticonInfoListModalSheet.kt | 114 +++++++-------- .../component/modal/GifticonInfoModalSheet.kt | 68 +++++---- .../java/com/yapp/buddycon/map/MapScreen.kt | 136 +++++++++++++----- 3 files changed, 189 insertions(+), 129 deletions(-) diff --git a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt index b5e56555..e44a1d02 100644 --- a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt +++ b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt @@ -1,27 +1,24 @@ package com.yapp.buddycon.designsystem.component.modal +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.grid.GridCells -import androidx.compose.foundation.lazy.grid.GridItemSpan import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.SheetState import androidx.compose.material3.Text -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -38,6 +35,7 @@ import coil.compose.AsyncImage import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.tag.DDayTag import com.yapp.buddycon.designsystem.theme.BuddyConTheme +import com.yapp.buddycon.designsystem.theme.Grey40 import com.yapp.buddycon.designsystem.theme.Grey60 import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.designsystem.theme.Pink100 @@ -53,57 +51,50 @@ private val GifticonInfoListModalSheetItemRadius = 8.dp @OptIn(ExperimentalMaterial3Api::class) @Composable fun GifticonInfoListModalSheet( - sheetState: SheetState = rememberModalBottomSheetState(), + modifier: Modifier = Modifier, countOfUsableGifticon: Int, countOfImminetGifticon: Int, - gifticonInfos: List = listOf(), - onDismiss: () -> Unit + gifticonInfos: List = listOf() ) { - ModalBottomSheet( - onDismissRequest = onDismiss, - modifier = Modifier + Column( + modifier = modifier .fillMaxWidth() - .height(GifticonInfoListModalSheetHeight), - sheetState = sheetState, - shape = RoundedCornerShape( - topStart = GifticonInfoListModalSheetRadius, - topEnd = GifticonInfoListModalSheetRadius - ), - containerColor = BuddyConTheme.colors.modalColor + .padding(horizontal = Paddings.xlarge) + .padding(bottom = Paddings.xlarge) ) { + Spacer( + modifier = Modifier + .align(Alignment.CenterHorizontally) + .padding(vertical = Paddings.xlarge) + .size(32.dp, 4.dp) + .background(Grey40, RoundedCornerShape(100.dp)) + ) + Text( + text = stringResource(R.string.modal_sheet_gifticon), + style = BuddyConTheme.typography.subTitle + ) + Row(verticalAlignment = Alignment.Bottom) { + Text( + text = "${countOfUsableGifticon}개", + style = BuddyConTheme.typography.title01 + ) + Text( + text = String.format( + stringResource(R.string.modal_sheet_imminet_gifticon), + countOfImminetGifticon + ), + modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), + style = BuddyConTheme.typography.body04.copy(color = Pink100) + ) + } LazyVerticalGrid( columns = GridCells.Fixed(2), - modifier = Modifier.fillMaxSize(), - contentPadding = PaddingValues( - start = Paddings.xlarge, - end = Paddings.xlarge, - bottom = Paddings.xlarge - ), + modifier = Modifier + .padding(top = Paddings.xlarge) + .fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(Paddings.xlarge), horizontalArrangement = Arrangement.spacedBy(Paddings.medium) ) { - item(span = { GridItemSpan(2) }) { - Column { - Text( - text = stringResource(R.string.modal_sheet_gifticon), - style = BuddyConTheme.typography.subTitle - ) - Row(verticalAlignment = Alignment.Bottom) { - Text( - text = "${countOfUsableGifticon}개", - style = BuddyConTheme.typography.title01 - ) - Text( - text = String.format( - stringResource(R.string.modal_sheet_imminet_gifticon), - countOfImminetGifticon - ), - modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), - style = BuddyConTheme.typography.body04.copy(color = Pink100) - ) - } - } - } items(gifticonInfos) { Column { Box( @@ -156,7 +147,7 @@ fun GifticonInfoListModalSheet( } @OptIn(ExperimentalMaterial3Api::class) -@Preview +@Preview(showBackground = true, backgroundColor = 255) @Composable private fun GifticonInfoListModalSheetPreview() { var isShowModal by remember { mutableStateOf(true) } @@ -168,20 +159,17 @@ private fun GifticonInfoListModalSheetPreview() { }.time.time BuddyConTheme { - if (isShowModal) { - GifticonInfoListModalSheet( - countOfUsableGifticon = 4, - countOfImminetGifticon = 1, - gifticonInfos = List(10) { - GifticonModel( - imageUrl = "https://github.com/Team-BuddyCon/ANDROID_V2/assets/34837583/5ab80674-4ffb-4c91-ab10-3743d8c87e58", - category = GifticonCategory.STARBUCKS, - name = "빙그레)바나나맛우유240", - expirationTime = (today + 1000 * 60 * 60 * 24L * (-1..366).random()) - ) - }, - onDismiss = { isShowModal = false } - ) - } + GifticonInfoListModalSheet( + countOfUsableGifticon = 4, + countOfImminetGifticon = 1, + gifticonInfos = List(10) { + GifticonModel( + imageUrl = "https://github.com/Team-BuddyCon/ANDROID_V2/assets/34837583/5ab80674-4ffb-4c91-ab10-3743d8c87e58", + category = GifticonCategory.STARBUCKS, + name = "빙그레)바나나맛우유240", + expirationTime = (today + 1000 * 60 * 60 * 24L * (-1..366).random()) + ) + } + ) } } diff --git a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt index ac356b2e..4c1f26a1 100644 --- a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt +++ b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoModalSheet.kt @@ -3,10 +3,11 @@ package com.yapp.buddycon.designsystem.component.modal import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.Text @@ -20,6 +21,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.theme.BuddyConTheme +import com.yapp.buddycon.designsystem.theme.Grey40 import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.designsystem.theme.Pink100 @@ -36,42 +38,52 @@ fun GifticonInfoModalSheetContent( countOfUsableGifticon: Int, countOfImminetGifticon: Int ) { - Row( + Column( modifier = modifier .background(BuddyConTheme.colors.background) .fillMaxWidth() - .padding(horizontal = GifticonInfoModalHorizontalPadding) - .wrapContentHeight(), - verticalAlignment = Alignment.CenterVertically + .padding(horizontal = GifticonInfoModalHorizontalPadding), + horizontalAlignment = Alignment.CenterHorizontally ) { - Column( - modifier = Modifier.weight(1f) + Spacer( + modifier = Modifier + .padding(vertical = Paddings.xlarge) + .size(32.dp, 4.dp) + .background(Grey40, RoundedCornerShape(100.dp)) + ) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically ) { - Text( - text = stringResource(R.string.modal_sheet_gifticon), - style = BuddyConTheme.typography.subTitle - ) - Row(verticalAlignment = Alignment.Bottom) { - Text( - text = "${countOfUsableGifticon}개", - style = BuddyConTheme.typography.title01 - ) + Column( + modifier = Modifier.weight(1f) + ) { Text( - text = String.format( - stringResource(R.string.modal_sheet_imminet_gifticon), - countOfImminetGifticon - ), - modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), - style = BuddyConTheme.typography.body04.copy(color = Pink100) + text = stringResource(R.string.modal_sheet_gifticon), + style = BuddyConTheme.typography.subTitle ) + Row(verticalAlignment = Alignment.Bottom) { + Text( + text = "${countOfUsableGifticon}개", + style = BuddyConTheme.typography.title01 + ) + Text( + text = String.format( + stringResource(R.string.modal_sheet_imminet_gifticon), + countOfImminetGifticon + ), + modifier = Modifier.padding(start = Paddings.medium, bottom = Paddings.small), + style = BuddyConTheme.typography.body04.copy(color = Pink100) + ) + } } + Icon( + painter = painterResource(R.drawable.ic_gifticon), + contentDescription = GifticonInfoModalDescription, + modifier = Modifier.size(GifticonInfoModalItemIconSize), + tint = Color.Unspecified + ) } - Icon( - painter = painterResource(R.drawable.ic_gifticon), - contentDescription = GifticonInfoModalDescription, - modifier = Modifier.size(GifticonInfoModalItemIconSize), - tint = Color.Unspecified - ) } } diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index e108b2a5..65de6f0c 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -5,15 +5,14 @@ import android.content.pm.PackageManager import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.background -import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.draggable -import androidx.compose.foundation.gestures.rememberDraggableState +import androidx.compose.foundation.gestures.detectVerticalDragGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items @@ -24,11 +23,14 @@ import androidx.compose.material3.SnackbarHostState 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.rememberCoroutineScope import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -42,27 +44,28 @@ import com.naver.maps.map.compose.NaverMap import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification import com.yapp.buddycon.designsystem.component.button.CategoryButton +import com.yapp.buddycon.designsystem.component.modal.GifticonInfoListModalSheet import com.yapp.buddycon.designsystem.component.modal.GifticonInfoModalSheetContent import com.yapp.buddycon.designsystem.component.snackbar.BuddyConSnackbar import com.yapp.buddycon.designsystem.component.snackbar.showBuddyConSnackBar import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings +import com.yapp.buddycon.domain.model.gifticon.GifticonModel import com.yapp.buddycon.domain.model.type.GifticonCategory import com.yapp.buddycon.utility.toPx +import java.util.Calendar + +private const val MapBarSize = 260f @OptIn(ExperimentalMaterial3Api::class) @Composable fun MapScreen( mapViewModel: MapViewModel = hiltViewModel() ) { - val context = LocalContext.current - val configuration = LocalConfiguration.current - val density = context.resources.displayMetrics.density - val mapScreenHeightDp = (configuration.screenHeightDp - 244).toFloat() - val mapScreenHeightPx = mapScreenHeightDp.dp.toPx() val snackbarHostState = remember { SnackbarHostState() } + val configuration = LocalConfiguration.current + val mapHeightDp = configuration.screenHeightDp - MapBarSize val mapUiState by mapViewModel.uiState.collectAsStateWithLifecycle() - val heightPx by rememberUpdatedState(mapUiState.heightDp * density) RequestLocationPermission(snackbarHostState) BottomSheetScaffold( @@ -70,29 +73,8 @@ fun MapScreen( MapBottomSheet( modifier = Modifier .background(BuddyConTheme.colors.background) - .draggable( - state = rememberDraggableState { delta -> - if ((heightPx - delta) in 0f..mapScreenHeightPx) { - mapViewModel.changeHeightDp((heightPx - delta) / density) - } - }, - orientation = Orientation.Vertical, - onDragStarted = { - mapViewModel.changeSheetValue(BottomSheetValue.Moving(mapUiState.heightDp)) - }, - onDragStopped = { - mapViewModel.changeSheetValue( - when (mapUiState.heightDp) { - in BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp..(mapScreenHeightDp / 2f - 1) -> { - BottomSheetValue.PartiallyExpanded - } - - in (mapScreenHeightDp / 2f)..mapScreenHeightDp -> BottomSheetValue.Expanded - else -> BottomSheetValue.Collapsed - } - ) - } - ) + .height(mapHeightDp.dp), + mapHeightDp = mapHeightDp ) }, sheetPeekHeight = mapUiState.heightDp.dp, @@ -123,13 +105,91 @@ fun MapScreen( @Composable private fun MapBottomSheet( - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + mapViewModel: MapViewModel = hiltViewModel(), + mapHeightDp: Float ) { - Box(modifier.fillMaxHeight()) { - GifticonInfoModalSheetContent( - countOfUsableGifticon = 12, - countOfImminetGifticon = 1 - ) + val context = LocalContext.current + val density = context.resources.displayMetrics.density + val mapHeightPx = mapHeightDp.dp.toPx() + val mapUiState by mapViewModel.uiState.collectAsStateWithLifecycle() + var prevSheetValue: BottomSheetValue by remember { mutableStateOf(BottomSheetValue.Collapsed) } + val heightPx by rememberUpdatedState(mapUiState.heightDp * density) + + Box( + modifier = modifier + .pointerInput(Unit) { + detectVerticalDragGestures( + onDragStart = { + prevSheetValue = mapUiState.sheetValue + mapViewModel.changeSheetValue(BottomSheetValue.Moving(mapUiState.heightDp)) + }, + onDragEnd = { + prevSheetValue = mapUiState.sheetValue + mapViewModel.changeSheetValue( + when (mapUiState.heightDp) { + in BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp..(mapHeightDp / 2f - 1) -> { + BottomSheetValue.PartiallyExpanded + } + + in (mapHeightDp / 2f)..mapHeightDp -> BottomSheetValue.Expanded + else -> BottomSheetValue.Collapsed + } + ) + }, + onVerticalDrag = { change, dragAmount -> + if ((heightPx - dragAmount) in 0f..mapHeightPx) { + mapViewModel.changeHeightDp((heightPx - dragAmount) / density) + } + } + ) + } + ) { + if (mapUiState.sheetValue is BottomSheetValue.Moving) { + MapBottomSheetContent(prevSheetValue) + } else { + MapBottomSheetContent(mapUiState.sheetValue) + } + } +} + +@Composable +private fun MapBottomSheetContent( + sheetValue: BottomSheetValue +) { + val today = Calendar.getInstance().apply { + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.time.time + + when (sheetValue) { + BottomSheetValue.Collapsed, + BottomSheetValue.PartiallyExpanded -> { + GifticonInfoModalSheetContent( + countOfUsableGifticon = 12, + countOfImminetGifticon = 1 + ) + } + + BottomSheetValue.Expanded -> { + GifticonInfoListModalSheet( + modifier = Modifier.fillMaxHeight(), + countOfUsableGifticon = 4, + countOfImminetGifticon = 1, + gifticonInfos = List(10) { + GifticonModel( + imageUrl = "https://github.com/Team-BuddyCon/ANDROID_V2/assets/34837583/5ab80674-4ffb-4c91-ab10-3743d8c87e58", + category = GifticonCategory.STARBUCKS, + name = "빙그레)바나나맛우유240", + expirationTime = (today + 1000 * 60 * 60 * 24L * (-1..366).random()) + ) + } + ) + } + + else -> Unit } } From b113931c9ccb50b3b148a7db3a322dfa267a0fce Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 21 Jan 2024 20:49:05 +0900 Subject: [PATCH 09/13] =?UTF-8?q?[UI]=20#43=20=EA=B8=B0=ED=94=84=ED=8B=B0?= =?UTF-8?q?=EC=BD=98=20=EB=B0=94=ED=85=80=20=EB=AA=A8=EB=8B=AC=EC=B0=BD=20?= =?UTF-8?q?=ED=95=98=EB=8B=A8=20=ED=8C=A8=EB=94=A9=EA=B0=92=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modal/GifticonInfoListModalSheet.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt index e44a1d02..b6050d28 100644 --- a/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt +++ b/core/designsystem/src/main/java/com/yapp/buddycon/designsystem/component/modal/GifticonInfoListModalSheet.kt @@ -13,7 +13,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid -import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.lazy.grid.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -60,7 +60,6 @@ fun GifticonInfoListModalSheet( modifier = modifier .fillMaxWidth() .padding(horizontal = Paddings.xlarge) - .padding(bottom = Paddings.xlarge) ) { Spacer( modifier = Modifier @@ -95,8 +94,10 @@ fun GifticonInfoListModalSheet( verticalArrangement = Arrangement.spacedBy(Paddings.xlarge), horizontalArrangement = Arrangement.spacedBy(Paddings.medium) ) { - items(gifticonInfos) { - Column { + itemsIndexed(gifticonInfos) { index, item -> + Column( + modifier = Modifier.padding(bottom = if (index == gifticonInfos.lastIndex) Paddings.xlarge else 0.dp) + ) { Box( modifier = Modifier .fillMaxWidth() @@ -107,8 +108,8 @@ fun GifticonInfoListModalSheet( shape = RoundedCornerShape(GifticonInfoListModalSheetItemRadius) ) { AsyncImage( - model = it.imageUrl, - contentDescription = it.name, + model = item.imageUrl, + contentDescription = item.name, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds ) @@ -119,24 +120,24 @@ fun GifticonInfoListModalSheet( top = Paddings.medium, start = Paddings.medium ), - dateMillis = it.expirationTime + dateMillis = item.expirationTime ) } Text( - text = it.category.value, + text = item.category.value, modifier = Modifier.padding(top = Paddings.large), style = BuddyConTheme.typography.body03.copy(color = Pink100), overflow = TextOverflow.Ellipsis, maxLines = 1 ) Text( - text = it.name, + text = item.name, style = BuddyConTheme.typography.body04, overflow = TextOverflow.Ellipsis, maxLines = 1 ) Text( - text = "~${it.toExpirationDate()}", + text = "~${item.toExpirationDate()}", modifier = Modifier.padding(top = Paddings.medium), style = BuddyConTheme.typography.body03.copy(color = Grey60) ) From d9a7260ada39790a49d7748f99af5fcd556d146c Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 21 Jan 2024 20:50:09 +0900 Subject: [PATCH 10/13] =?UTF-8?q?[UI]=20#43=20=EC=A7=80=EB=8F=84=20?= =?UTF-8?q?=EB=82=B4=20=EB=B0=94=ED=85=80=20=EC=8B=9C=ED=8A=B8=20=EB=8F=99?= =?UTF-8?q?=EC=9E=91=20=EB=B0=8F=20=EC=83=81=ED=83=9C=20=EB=B3=84=20UI=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yapp/buddycon/map/MapScreen.kt | 121 +++++++----------- .../java/com/yapp/buddycon/map/MapUiState.kt | 19 +-- .../com/yapp/buddycon/map/MapViewModel.kt | 12 +- 3 files changed, 61 insertions(+), 91 deletions(-) diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 65de6f0c..275e9a61 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -9,10 +9,10 @@ import androidx.compose.foundation.gestures.detectVerticalDragGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items @@ -23,11 +23,8 @@ import androidx.compose.material3.SnackbarHostState 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.rememberCoroutineScope -import androidx.compose.runtime.rememberUpdatedState -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.pointer.pointerInput @@ -52,10 +49,10 @@ import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.domain.model.gifticon.GifticonModel import com.yapp.buddycon.domain.model.type.GifticonCategory -import com.yapp.buddycon.utility.toPx import java.util.Calendar -private const val MapBarSize = 260f +// TopAppBarHeight(52) + BottomNavigationBarHeight(72) + MapCategoryTabHeight(60) +private const val MapBarSize = 184f @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -64,16 +61,14 @@ fun MapScreen( ) { val snackbarHostState = remember { SnackbarHostState() } val configuration = LocalConfiguration.current - val mapHeightDp = configuration.screenHeightDp - MapBarSize + val mapHeightDp = configuration.screenHeightDp.toFloat() - MapBarSize val mapUiState by mapViewModel.uiState.collectAsStateWithLifecycle() RequestLocationPermission(snackbarHostState) BottomSheetScaffold( sheetContent = { MapBottomSheet( - modifier = Modifier - .background(BuddyConTheme.colors.background) - .height(mapHeightDp.dp), + mapViewModel = mapViewModel, mapHeightDp = mapHeightDp ) }, @@ -81,7 +76,6 @@ fun MapScreen( sheetShape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), sheetContainerColor = BuddyConTheme.colors.background, sheetShadowElevation = 33.dp, - sheetDragHandle = null, topBar = { TopAppBarWithNotification( title = stringResource(R.string.map) @@ -93,7 +87,8 @@ fun MapScreen( snackbarHostState = snackbarHostState, contentAlignment = Alignment.TopCenter ) - } + }, + sheetDragHandle = null ) { MapContent( modifier = Modifier @@ -111,85 +106,66 @@ private fun MapBottomSheet( ) { val context = LocalContext.current val density = context.resources.displayMetrics.density - val mapHeightPx = mapHeightDp.dp.toPx() val mapUiState by mapViewModel.uiState.collectAsStateWithLifecycle() - var prevSheetValue: BottomSheetValue by remember { mutableStateOf(BottomSheetValue.Collapsed) } - val heightPx by rememberUpdatedState(mapUiState.heightDp * density) + + // 삭제 예정 + val today = Calendar.getInstance().apply { + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.time.time Box( modifier = modifier + .heightIn(min = BottomSheetValue.Collapsed.sheetPeekHeightDp.dp, max = BottomSheetValue.Expanded.sheetPeekHeightDp.dp) + .fillMaxSize() + .background(BuddyConTheme.colors.background) .pointerInput(Unit) { detectVerticalDragGestures( - onDragStart = { - prevSheetValue = mapUiState.sheetValue - mapViewModel.changeSheetValue(BottomSheetValue.Moving(mapUiState.heightDp)) - }, onDragEnd = { - prevSheetValue = mapUiState.sheetValue - mapViewModel.changeSheetValue( - when (mapUiState.heightDp) { - in BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp..(mapHeightDp / 2f - 1) -> { + mapViewModel.onSheetValueChange( + sheetValue = when (mapUiState.heightDp) { + in BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp..(BottomSheetValue.Expanded.sheetPeekHeightDp / 2f - 1) -> { BottomSheetValue.PartiallyExpanded } - in (mapHeightDp / 2f)..mapHeightDp -> BottomSheetValue.Expanded + in (BottomSheetValue.Expanded.sheetPeekHeightDp / 2f)..mapHeightDp -> BottomSheetValue.Expanded else -> BottomSheetValue.Collapsed } ) }, onVerticalDrag = { change, dragAmount -> - if ((heightPx - dragAmount) in 0f..mapHeightPx) { - mapViewModel.changeHeightDp((heightPx - dragAmount) / density) + if (mapUiState.heightDp - (dragAmount / density) in 0f..mapHeightDp) { + mapViewModel.changeBottomSheetOffset(dragAmount / density) } } ) } ) { - if (mapUiState.sheetValue is BottomSheetValue.Moving) { - MapBottomSheetContent(prevSheetValue) - } else { - MapBottomSheetContent(mapUiState.sheetValue) - } - } -} - -@Composable -private fun MapBottomSheetContent( - sheetValue: BottomSheetValue -) { - val today = Calendar.getInstance().apply { - set(Calendar.HOUR_OF_DAY, 0) - set(Calendar.MINUTE, 0) - set(Calendar.SECOND, 0) - set(Calendar.MILLISECOND, 0) - }.time.time - - when (sheetValue) { - BottomSheetValue.Collapsed, - BottomSheetValue.PartiallyExpanded -> { - GifticonInfoModalSheetContent( - countOfUsableGifticon = 12, - countOfImminetGifticon = 1 - ) - } + when (mapUiState.sheetValue) { + BottomSheetValue.Expanded -> { + GifticonInfoListModalSheet( + countOfUsableGifticon = 4, + countOfImminetGifticon = 1, + gifticonInfos = List(5) { + GifticonModel( + imageUrl = "https://github.com/Team-BuddyCon/ANDROID_V2/assets/34837583/5ab80674-4ffb-4c91-ab10-3743d8c87e58", + category = GifticonCategory.STARBUCKS, + name = "빙그레)바나나맛우유240", + expirationTime = (today + 1000 * 60 * 60 * 24L * (-1..366).random()) + ) + } + ) + } - BottomSheetValue.Expanded -> { - GifticonInfoListModalSheet( - modifier = Modifier.fillMaxHeight(), - countOfUsableGifticon = 4, - countOfImminetGifticon = 1, - gifticonInfos = List(10) { - GifticonModel( - imageUrl = "https://github.com/Team-BuddyCon/ANDROID_V2/assets/34837583/5ab80674-4ffb-4c91-ab10-3743d8c87e58", - category = GifticonCategory.STARBUCKS, - name = "빙그레)바나나맛우유240", - expirationTime = (today + 1000 * 60 * 60 * 24L * (-1..366).random()) - ) - } - ) + else -> { + GifticonInfoModalSheetContent( + countOfUsableGifticon = 12, + countOfImminetGifticon = 1 + ) + } } - - else -> Unit } } @@ -203,7 +179,7 @@ private fun MapContent( Column(modifier) { MapCategoryTab( category = uiState.category, - onCategoryChange = { mapViewModel.changeCategory(it) } + onCategoryChange = { mapViewModel.onCategoryChange(it) } ) NaverMap( modifier = Modifier.fillMaxSize(), @@ -223,9 +199,10 @@ private fun MapCategoryTab( ) { LazyRow( modifier = Modifier + .height(60.dp) + .fillMaxWidth() .padding(horizontal = Paddings.xlarge) - .padding(top = Paddings.xlarge, bottom = Paddings.large) - .fillMaxWidth(), + .padding(top = Paddings.xlarge, bottom = Paddings.large), horizontalArrangement = Arrangement.spacedBy(Paddings.small) ) { items(GifticonCategory.values()) { diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt index 73fee67f..2446504e 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapUiState.kt @@ -4,19 +4,12 @@ import com.yapp.buddycon.domain.model.type.GifticonCategory data class MapUiState( val category: GifticonCategory = GifticonCategory.TOTAL, - val sheetValue: BottomSheetValue = BottomSheetValue.PartiallyExpanded, - val heightDp: Float = 36f + val sheetValue: BottomSheetValue = BottomSheetValue.Collapsed, + val heightDp: Float = BottomSheetValue.Collapsed.sheetPeekHeightDp ) -sealed class BottomSheetValue(open val sheetPeekHeightDp: Float) { - - object Collapsed : BottomSheetValue(36f) - - object PartiallyExpanded : BottomSheetValue(111f) - - object Expanded : BottomSheetValue(540f) - - data class Moving( - override val sheetPeekHeightDp: Float - ) : BottomSheetValue(sheetPeekHeightDp) +enum class BottomSheetValue(val sheetPeekHeightDp: Float) { + Collapsed(36f), + PartiallyExpanded(111f), + Expanded(540f) } diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt index 94f275ba..bf1e2a3e 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt @@ -12,24 +12,24 @@ class MapViewModel @Inject constructor() : ViewModel() { private val _uiState = MutableStateFlow(MapUiState()) val uiState = _uiState.asStateFlow() - - fun changeCategory(category: GifticonCategory) { + fun onCategoryChange(category: GifticonCategory) { _uiState.value = _uiState.value.copy(category = category) } - fun changeSheetValue(sheetValue: BottomSheetValue) { + fun onSheetValueChange(sheetValue: BottomSheetValue) { _uiState.value = _uiState.value.copy( sheetValue = sheetValue, heightDp = when (sheetValue) { BottomSheetValue.Collapsed -> BottomSheetValue.Collapsed.sheetPeekHeightDp BottomSheetValue.PartiallyExpanded -> BottomSheetValue.PartiallyExpanded.sheetPeekHeightDp BottomSheetValue.Expanded -> BottomSheetValue.Expanded.sheetPeekHeightDp - is BottomSheetValue.Moving -> uiState.value.heightDp } ) } - fun changeHeightDp(heightDp: Float) { - _uiState.value = _uiState.value.copy(heightDp = heightDp) + fun changeBottomSheetOffset(offsetY: Float) { + _uiState.value = _uiState.value.copy( + heightDp = _uiState.value.heightDp - offsetY + ) } } From 7c7166db27b9537723324126b479e17092cca61c Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 21 Jan 2024 21:13:48 +0900 Subject: [PATCH 11/13] =?UTF-8?q?[UI]=20#43=20=EB=84=A4=EC=9D=B4=EB=B2=84?= =?UTF-8?q?=20=EB=A7=B5=EC=97=90=EC=84=9C=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EB=A7=B5=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/map/build.gradle | 4 ++++ feature/map/src/main/AndroidManifest.xml | 6 +++++- .../main/java/com/yapp/buddycon/map/MapScreen.kt | 14 ++++++-------- gradle/libs.versions.toml | 2 ++ settings.gradle | 3 ++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/feature/map/build.gradle b/feature/map/build.gradle index 89fda288..4a3eb6ef 100644 --- a/feature/map/build.gradle +++ b/feature/map/build.gradle @@ -3,6 +3,9 @@ plugins { alias libs.plugins.kotlin.android } +def Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + android { namespace 'com.yapp.buddycon.map' compileSdk 33 @@ -10,6 +13,7 @@ android { defaultConfig { minSdk 26 + resValue("string", "KAKAO_APP_KEY", properties.getProperty("KAKAO_APP_KEY")) testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" } diff --git a/feature/map/src/main/AndroidManifest.xml b/feature/map/src/main/AndroidManifest.xml index a5918e68..6746d45f 100644 --- a/feature/map/src/main/AndroidManifest.xml +++ b/feature/map/src/main/AndroidManifest.xml @@ -1,4 +1,8 @@ - + + + \ No newline at end of file diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 275e9a61..87fd215b 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -32,12 +32,12 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.viewinterop.AndroidView import androidx.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.naver.maps.map.MapView import com.naver.maps.map.compose.ExperimentalNaverMapApi -import com.naver.maps.map.compose.MapUiSettings -import com.naver.maps.map.compose.NaverMap import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification import com.yapp.buddycon.designsystem.component.button.CategoryButton @@ -181,13 +181,11 @@ private fun MapContent( category = uiState.category, onCategoryChange = { mapViewModel.onCategoryChange(it) } ) - NaverMap( + AndroidView( modifier = Modifier.fillMaxSize(), - uiSettings = MapUiSettings( - isZoomControlEnabled = false, - isLogoClickEnabled = false, - isScaleBarEnabled = false - ) + factory = { context -> + MapView(context) + } ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index efa42bff..8e0fd513 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,6 +33,7 @@ coroutine-core = "1.6.4" ## kakao kakao = "2.18.0" +kakao-map = "2.6.0" ## naver-map naver-map-compose = "1.3.3" @@ -95,6 +96,7 @@ coroutine-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-a ## kakao kakao-user = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao" } +kakao-map = { group = "com.kakao.maps.open", name = "android", version.ref = "kakao-map" } ## naver-map naver-map-compose = { group = "io.github.fornewid", name = "naver-map-compose", version.ref = "naver-map-compose" } diff --git a/settings.gradle b/settings.gradle index b0d6b51d..7a2e33ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,8 @@ dependencyResolutionManagement { google() mavenCentral() maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' } - maven { url 'https://naver.jfrog.io/artifactory/maven/'} + maven { url 'https://naver.jfrog.io/artifactory/maven/' } + maven { url 'https://devrepo.kakao.com/nexus/repository/kakaomap-releases/' } } } rootProject.name = "BuddyCon" From ee1047e9a5d559a72ee28fd7e6da0b06288ab72c Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 21 Jan 2024 21:40:05 +0900 Subject: [PATCH 12/13] =?UTF-8?q?[build]=20#43=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B2=84=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EC=96=B8=ED=8A=B8=20KEY?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 - app/src/main/AndroidManifest.xml | 4 ---- 2 files changed, 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8990d086..01597996 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,6 @@ android { versionName "1.0" buildConfigField("String", "KAKAO_APP_KEY", properties.getProperty("KAKAO_APP_KEY")) - resValue("string", "NAVER_CLIENT_ID", properties.getProperty("NAVER_CLIENT_ID")) testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8a1c93b7..bb20fbf2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -28,10 +28,6 @@ - - \ No newline at end of file From a3b3677bdb34fc9b41c189c9991451b7457c35d5 Mon Sep 17 00:00:00 2001 From: ows3090 Date: Sun, 21 Jan 2024 23:34:25 +0900 Subject: [PATCH 13/13] =?UTF-8?q?[UI]=20#43=20=EC=A0=9C=EB=8C=80=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EC=B9=B4=EC=B9=B4=EC=98=A4=20=EB=A7=B5=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/map/build.gradle | 2 +- .../java/com/yapp/buddycon/map/MapScreen.kt | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/feature/map/build.gradle b/feature/map/build.gradle index 4a3eb6ef..432f80bf 100644 --- a/feature/map/build.gradle +++ b/feature/map/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation project(":core:utility") implementation project(":domain") - implementation libs.naver.map.compose + implementation libs.kakao.map implementation libs.timber implementation libs.androidx.core.ktx implementation libs.androidx.activity.compose diff --git a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt index 87fd215b..661d47f5 100644 --- a/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt +++ b/feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt @@ -36,8 +36,10 @@ import androidx.compose.ui.viewinterop.AndroidView import androidx.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.naver.maps.map.MapView -import com.naver.maps.map.compose.ExperimentalNaverMapApi +import com.kakao.vectormap.KakaoMap +import com.kakao.vectormap.KakaoMapReadyCallback +import com.kakao.vectormap.MapLifeCycleCallback +import com.kakao.vectormap.MapView import com.yapp.buddycon.designsystem.R import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithNotification import com.yapp.buddycon.designsystem.component.button.CategoryButton @@ -49,6 +51,8 @@ import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Paddings import com.yapp.buddycon.domain.model.gifticon.GifticonModel import com.yapp.buddycon.domain.model.type.GifticonCategory +import timber.log.Timber +import java.lang.Exception import java.util.Calendar // TopAppBarHeight(52) + BottomNavigationBarHeight(72) + MapCategoryTabHeight(60) @@ -169,7 +173,6 @@ private fun MapBottomSheet( } } -@OptIn(ExperimentalNaverMapApi::class) @Composable private fun MapContent( modifier: Modifier = Modifier, @@ -185,6 +188,23 @@ private fun MapContent( modifier = Modifier.fillMaxSize(), factory = { context -> MapView(context) + }, + update = { + it.start( + object : MapLifeCycleCallback() { + override fun onMapDestroy() { + } + + override fun onMapError(error: Exception?) { + Timber.e("onMapError ${error?.message}") + } + }, + object : KakaoMapReadyCallback() { + override fun onMapReady(kakaoMap: KakaoMap) { + Timber.d("onMapReady") + } + } + ) } ) }