From ddce006405bfa5738597d80a2a5f7685501271de Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Thu, 2 Nov 2023 23:33:38 +0900 Subject: [PATCH 01/14] =?UTF-8?q?add:=20=EC=A0=95=EB=B3=B4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=A0=9C=EC=95=88=20v1=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eggeum/android/data/mapper/FileMapper.kt | 4 +- .../eggeum/android/data/mapper/PlaceMapper.kt | 8 +- .../wedemy/eggeum/android/data/model/File.kt | 2 +- .../eggeum/android/data/model/place/Image.kt | 2 +- .../eggeum/android/data/model/place/Info.kt | 28 +- .../eggeum/android/data/model/place/Menu.kt | 2 +- .../android/data/model/place/PlaceResponse.kt | 43 +-- .../data/model/place/UpsertPlaceRequest.kt | 18 +- .../android/data/service/PlaceService.kt | 3 +- .../eggeum/android/domain/model/FileEntity.kt | 2 +- .../android/domain/model/place/ImageEntity.kt | 2 +- .../android/domain/model/place/InfoEntity.kt | 66 ++++- .../android/domain/model/place/MenuEntity.kt | 2 +- .../android/domain/model/place/PlaceEntity.kt | 10 +- .../domain/model/place/UpsertPlaceEntity.kt | 38 ++- .../android/domain/usecase/PlaceUseCase.kt | 11 + update-cafe/build.gradle.kts | 1 + .../updatecafe/ui/InputCafeInfoFragment.kt | 176 ++++++++++- .../ui/UpdateCafeCompleteFragment.kt | 4 +- .../viewmodel/InputCafeInfoViewModel.kt | 101 ++++++- .../res/layout/fragment_input_cafe_info.xml | 278 ++++++++++++++++++ update-cafe/src/main/res/values/strings.xml | 9 + 22 files changed, 696 insertions(+), 114 deletions(-) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt index 94d1af15..f3c47a9b 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt @@ -28,12 +28,12 @@ public fun FileEntity.toModel(): File = public fun Image.toEntity(): ImageEntity = ImageEntity( - files = files.map { it.toEntity() }, + files = files?.map { it.toEntity() }, ) public fun ImageEntity.toModel(): Image = Image( - files = files.map { it.toModel() }, + files = files?.map { it.toModel() }, ) internal fun ProfileImage.toEntity() = diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt index 6a0e3d91..7f0f2a44 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt @@ -45,11 +45,11 @@ internal fun UpsertPlaceEntity.toModel() = UpsertPlaceRequest( address1 = address1, address2 = address2, - image = image.toModel(), + image = image?.toModel(), info = info.toModel(), latitude = latitude, longitude = longitude, - menu = menu.toModel(), + menu = menu?.toModel(), name = name, placeId = placeId, remarks = remarks, @@ -94,12 +94,12 @@ public fun InfoEntity.toModel(): Info = public fun Menu.toEntity(): MenuEntity = MenuEntity( - products = products.map { it.toEntity() }, + products = products?.map { it.toEntity() }, ) public fun MenuEntity.toModel(): Menu = Menu( - products = products.map { it.toModel() }, + products = products?.map { it.toModel() }, ) public fun Product.toEntity(): ProductEntity = diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt index 92e36eee..44115368 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt @@ -25,5 +25,5 @@ public data class File( val uploadFileId: Int, @SerialName("url") - val url: String, + val url: String?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt index 377bfa54..3c0a2a24 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt @@ -20,5 +20,5 @@ import us.wedemy.eggeum.android.data.model.File @Serializable public data class Image( @SerialName("files") - val files: List, + val files: List?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt index 96fad4a3..5d4c28bf 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt @@ -58,44 +58,44 @@ import kotlinx.serialization.Serializable @Serializable public data class Info( @SerialName("areaSize") - val areaSize: String, + val areaSize: String?, @SerialName("blogUri") - val blogUri: String, + val blogUri: String?, @SerialName("businessHours") - val businessHours: List, + val businessHours: List?, @SerialName("existsSmokingArea") - val existsSmokingArea: Boolean, + val existsSmokingArea: Boolean?, @SerialName("existsWifi") - val existsWifi: Boolean, + val existsWifi: Boolean?, @SerialName("instagramUri") - val instagramUri: String, + val instagramUri: String?, @SerialName("meetingRoomCount") - val meetingRoomCount: Int, + val meetingRoomCount: Int?, @SerialName("mobileCharging") - val mobileCharging: String, + val mobileCharging: String?, @SerialName("multiSeatCount") - val multiSeatCount: Int, + val multiSeatCount: Int?, @SerialName("parking") - val parking: String, + val parking: String?, @SerialName("phone") - val phone: String, + val phone: String?, @SerialName("restRoom") - val restRoom: String, + val restRoom: String?, @SerialName("singleSeatCount") - val singleSeatCount: Int, + val singleSeatCount: Int?, @SerialName("websiteUri") - val websiteUri: String, + val websiteUri: String?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt index 1e7a2f95..ce2a0045 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt @@ -19,5 +19,5 @@ import kotlinx.serialization.Serializable @Serializable public data class Menu( @SerialName("products") - val products: List, + val products: List?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt index 35734a72..e17a8ead 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt @@ -10,46 +10,13 @@ package us.wedemy.eggeum.android.data.model.place import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -// @JsonClass(generateAdapter = true) -// public data class PlaceResponse( -// @Json(name = "address1") -// val address1: String, -// -// @Json(name = "address2") -// val address2: String, -// -// @Json(name = "id") -// val id: Int, -// -// @Json(name = "image") -// val image: Image, -// -// @Json(name = "info") -// val info: Info, -// -// @Json(name = "latitude") -// val latitude: Double, -// -// @Json(name = "longitude") -// val longitude: Double, -// -// @Json(name = "menu") -// val menu: Menu, -// -// @Json(name = "name") -// val name: String, -// -// @Json(name = "type") -// val type: String, -// ) - @Serializable public data class PlaceResponse( @SerialName("address1") - val address1: String, + val address1: String?, @SerialName("address2") - val address2: String, + val address2: String?, @SerialName("id") val id: Int, @@ -61,10 +28,10 @@ public data class PlaceResponse( val info: Info, @SerialName("latitude") - val latitude: Double, + val latitude: Double?, @SerialName("longitude") - val longitude: Double, + val longitude: Double?, @SerialName("menu") val menu: Menu, @@ -73,5 +40,5 @@ public data class PlaceResponse( val name: String, @SerialName("type") - val type: String, + val type: String?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt index e9ad6735..8e521a5b 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt @@ -49,35 +49,35 @@ import kotlinx.serialization.Serializable @Serializable public data class UpsertPlaceRequest( @SerialName("address1") - val address1: String, + val address1: String?, @SerialName("address2") - val address2: String, + val address2: String?, @SerialName("image") - val image: Image, + val image: Image?, @SerialName("info") val info: Info, @SerialName("latitude") - val latitude: Double, + val latitude: Double?, @SerialName("longitude") - val longitude: Double, + val longitude: Double?, @SerialName("menu") - val menu: Menu, + val menu: Menu?, @SerialName("name") - val name: String, + val name: String?, @SerialName("placeId") val placeId: Int, @SerialName("remarks") - val remarks: String, + val remarks: String?, @SerialName("type") - val type: String, + val type: String?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt index 08a072e3..3cc005a4 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt @@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.data.service import retrofit2.Response import retrofit2.http.Body import retrofit2.http.GET +import retrofit2.http.POST import retrofit2.http.Path import retrofit2.http.Query import us.wedemy.eggeum.android.data.model.place.PlaceResponse @@ -37,7 +38,7 @@ public interface PlaceService { @Query("type") type: String? = null, ): PlaceListResponse - @GET("app/place/edits") + @POST("app/place/edits") public suspend fun upsertPlace( @Body upsertPlaceRequest: UpsertPlaceRequest, ): Response diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/FileEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/FileEntity.kt index ebdbd80c..c7256938 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/FileEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/FileEntity.kt @@ -9,5 +9,5 @@ package us.wedemy.eggeum.android.domain.model public data class FileEntity( public val uploadFileId: Int, - val url: String, + val url: String?, ) diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt index bc579e3a..6552a0ac 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt @@ -10,5 +10,5 @@ package us.wedemy.eggeum.android.domain.model.place import us.wedemy.eggeum.android.domain.model.FileEntity public data class ImageEntity( - val files: List, + val files: List?, ) diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt index 6287cf0a..7e7be9f7 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt @@ -8,18 +8,54 @@ package us.wedemy.eggeum.android.domain.model.place public data class InfoEntity( - val areaSize: String, - val blogUri: String, - val businessHours: List, - val existsSmokingArea: Boolean, - val existsWifi: Boolean, - val instagramUri: String, - val meetingRoomCount: Int, - val mobileCharging: String, - val multiSeatCount: Int, - val parking: String, - val phone: String, - val restRoom: String, - val singleSeatCount: Int, - val websiteUri: String, -) + val areaSize: String?, + val blogUri: String?, + val businessHours: List?, + val existsSmokingArea: Boolean?, + val existsWifi: Boolean?, + val instagramUri: String?, + val meetingRoomCount: Int?, + val mobileCharging: String?, + val multiSeatCount: Int?, + val parking: String?, + val phone: String?, + val restRoom: String?, + val singleSeatCount: Int?, + val websiteUri: String?, +) { + public companion object { + public fun of( + areaSize: String? = null, + blogUri: String? = null, + businessHours: List? = null, + existsSmokingArea: Boolean? = null, + existsWifi: Boolean? = null, + instagramUri: String? = null, + meetingRoomCount: Int? = null, + mobileCharging: String? = null, + multiSeatCount: Int? = null, + parking: String? = null, + phone: String? = null, + restRoom: String? = null, + singleSeatCount: Int? = null, + websiteUri: String? = null, + ): InfoEntity { + return InfoEntity( + areaSize = areaSize, + blogUri = blogUri, + businessHours = businessHours, + existsSmokingArea = existsSmokingArea, + existsWifi = existsWifi, + instagramUri = instagramUri, + meetingRoomCount = meetingRoomCount, + mobileCharging = mobileCharging, + multiSeatCount = multiSeatCount, + parking = parking, + phone = phone, + restRoom = restRoom, + singleSeatCount = singleSeatCount, + websiteUri = websiteUri, + ) + } + } +} diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt index fd73364f..9ca4aa56 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt @@ -8,5 +8,5 @@ package us.wedemy.eggeum.android.domain.model.place public data class MenuEntity( - val products: List, + val products: List?, ) diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt index d43ae2db..653ca25b 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt @@ -8,14 +8,14 @@ package us.wedemy.eggeum.android.domain.model.place public data class PlaceEntity( - val address1: String, - val address2: String, + val address1: String?, + val address2: String?, val id: Int, val image: ImageEntity, val info: InfoEntity, - val latitude: Double, - val longitude: Double, + val latitude: Double?, + val longitude: Double?, val menu: MenuEntity, val name: String, - val type: String, + val type: String?, ) diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/UpsertPlaceEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/UpsertPlaceEntity.kt index 7e0593e8..f2e36752 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/UpsertPlaceEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/UpsertPlaceEntity.kt @@ -8,15 +8,33 @@ package us.wedemy.eggeum.android.domain.model.place public data class UpsertPlaceEntity( - val address1: String, - val address2: String, - val image: ImageEntity, + val address1: String?, + val address2: String?, + val image: ImageEntity?, val info: InfoEntity, - val latitude: Double, - val longitude: Double, - val menu: MenuEntity, - val name: String, + val latitude: Double?, + val longitude: Double?, + val menu: MenuEntity?, + val name: String?, val placeId: Int, - val remarks: String, - val type: String, -) + val remarks: String?, + val type: String?, +) { + public companion object { + public fun of(info: InfoEntity, placeId: Int, name: String?): UpsertPlaceEntity { + return UpsertPlaceEntity( + address1 = null, + address2 = null, + image = null, + info = info, + latitude = null, + longitude = null, + menu = null, + name = name, + placeId = placeId, + remarks = null, + type = null, + ) + } + } +} diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/PlaceUseCase.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/PlaceUseCase.kt index 05fa3170..206df967 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/PlaceUseCase.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/PlaceUseCase.kt @@ -12,6 +12,7 @@ import javax.inject.Inject import javax.inject.Singleton import kotlinx.coroutines.flow.Flow import us.wedemy.eggeum.android.domain.model.place.PlaceEntity +import us.wedemy.eggeum.android.domain.model.place.UpsertPlaceEntity import us.wedemy.eggeum.android.domain.repository.PlaceRepository import us.wedemy.eggeum.android.domain.util.PlaceApiResponseIsNull import us.wedemy.eggeum.android.domain.util.runSuspendCatching @@ -26,6 +27,16 @@ public class GetPlaceUseCase @Inject constructor( } } +@Singleton +public class UpsertlaceBodyUseCase @Inject constructor( + private val repository: PlaceRepository, +) { + public suspend operator fun invoke(upsertPlaceEntity: UpsertPlaceEntity): Result = + runSuspendCatching { + repository.upsertPlace(upsertPlaceEntity) + } +} + @Singleton public class GetPlaceListUseCase @Inject constructor( private val repository: PlaceRepository, diff --git a/update-cafe/build.gradle.kts b/update-cafe/build.gradle.kts index 9c9ea810..d0490616 100644 --- a/update-cafe/build.gradle.kts +++ b/update-cafe/build.gradle.kts @@ -35,5 +35,6 @@ dependencies { projects.common, projects.designResource, projects.navigator, + projects.domain, ) } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt index ba5a8eee..3436cdd5 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt @@ -10,13 +10,18 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle -import android.util.Log import android.view.View +import android.widget.Toast import androidx.core.widget.doAfterTextChanged import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch +import us.wedemy.eggeum.android.common.extension.repeatOnStarted +import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment +import us.wedemy.eggeum.android.domain.model.place.InfoEntity +import us.wedemy.eggeum.android.domain.model.place.UpsertPlaceEntity import us.wedemy.eggeum.android.updatecafe.databinding.FragmentInputCafeInfoBinding import us.wedemy.eggeum.android.updatecafe.viewmodel.InputCafeInfoViewModel @@ -26,11 +31,41 @@ class InputCafeInfoFragment : BaseFragment() { private val viewModel by viewModels() + private var cafeArea = "" + private var cafeMeetingRoom = "" + private var cafeMultiSeat = "" + private var cafeSingleSeat = "" + private var cafeBusinessHours = "" + private var cafeParking = "" + private var cafeExistsSmokingArea = "" + private var cafeExistsWifi = "" + private var cafeRestRoom = "" + private var cafeMobileCharging = "" + private var cafeInstagramUri = "" + private var cafeWebsiteUri = "" + private var cafeBlogUri = "" + private var cafePhone = "" + + private var cafeName: String = "" + private val guideMessage = "정보를 입력해주세요!" + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + initView() initListener() initObserver() } + private fun initView() { + repeatOnStarted { + launch { + /** + * Intent에서 placeId 가져오기 + */ + viewModel.getPlaceBody(1) + } + } + } + private fun initListener() { with(binding) { tbSelectInputCafeInfo.setNavigationOnClickListener { @@ -38,25 +73,152 @@ class InputCafeInfoFragment : BaseFragment() { requireActivity().finish() } } + /** + * 입력란 별, 검증 + */ tietInputCafeArea.doAfterTextChanged { - Log.d("logcat", "면적: $it") + cafeArea = it.toString() } tietInputCafeMeetingRoom.doAfterTextChanged { - Log.d("logcat", "회의실: $it") + cafeMeetingRoom = it.toString() } tietInputCafeMultiSeat.doAfterTextChanged { - Log.d("logcat", "다인석: $it") + cafeMultiSeat = it.toString() } tietInputCafeSingleSeat.doAfterTextChanged { - Log.d("logcat", "1인석: $it") + cafeSingleSeat = it.toString() } tietInputCafeBusinessHours.doAfterTextChanged { - Log.d("logcat", "영업시간: $it") + cafeBusinessHours = it.toString() + } + tietInputParking.doAfterTextChanged { + cafeParking = it.toString() + } + tietInputExistsSmokingArea.doAfterTextChanged { + cafeExistsSmokingArea = it.toString() + } + tietInputExistsWifi.doAfterTextChanged { + cafeExistsWifi = it.toString() + } + tietInputRestRoom.doAfterTextChanged { + cafeRestRoom = it.toString() + } + tietInputMobileCharging.doAfterTextChanged { + cafeMobileCharging = it.toString() + } + tietInputInstagramUri.doAfterTextChanged { + cafeInstagramUri = it.toString() + } + tietInputWebsiteUri.doAfterTextChanged { + cafeWebsiteUri = it.toString() + } + tietInputBlogUri.doAfterTextChanged { + cafeBlogUri = it.toString() + } + tietInputPhone.doAfterTextChanged { + cafePhone = it.toString() + } + btnNext.setOnClickListener { + val infoEntity = InfoEntity.of( + areaSize = stringOrElseNull(cafeArea), + blogUri = stringOrElseNull(cafeBlogUri), + businessHours = if (cafeBusinessHours != "") cafeBusinessHours.split(" ~ ") else null, + existsSmokingArea = stringToBoolean(cafeExistsSmokingArea), + existsWifi = stringToBoolean(cafeExistsWifi), + instagramUri = stringOrElseNull(cafeInstagramUri), + meetingRoomCount = stringToIntOrElseNull(cafeMeetingRoom), + mobileCharging = stringOrElseNull(cafeMobileCharging), + multiSeatCount = stringToIntOrElseNull(cafeMultiSeat), + parking = stringOrElseNull(cafeParking), + phone = stringOrElseNull(cafePhone), + restRoom = stringOrElseNull(cafeRestRoom), + singleSeatCount = stringToIntOrElseNull(cafeSingleSeat), + websiteUri = stringOrElseNull(cafeWebsiteUri), + ) + + val upsertPlaceEntity = UpsertPlaceEntity.of( + info = infoEntity, + placeId = 1, + name = if (cafeName != "") cafeName else null, + ) + + viewModel.upsertPlaceBody(upsertPlaceEntity = upsertPlaceEntity) } } } + private fun stringToBoolean(str: String): Boolean { + return str == "O" + } + + private fun stringOrElseNull(str: String): String? { + return if (str != "") str + else null + } + + private fun stringToIntOrElseNull(str: String): Int? { + return if (str != "") str.toInt() + else null + } private fun initObserver() { - // TODO + repeatOnStarted { + launch { + viewModel.uiState.collect { uiState -> + with(binding) { + tietInputCafeArea.hint = stringOrElseGuideMessage(uiState.areaSize) + tietInputCafeMeetingRoom.hint = intToStringOrElseGuideMessage(uiState.meetingRoomCount) + tietInputCafeMultiSeat.hint = intToStringOrElseGuideMessage(uiState.multiSeatCount) + tietInputCafeSingleSeat.hint = intToStringOrElseGuideMessage(uiState.singleSeatCount) + tietInputCafeBusinessHours.hint = uiState.businessHours + ?.joinToString(" ~ ", "", "", -1) ?: guideMessage + tietInputParking.hint = stringOrElseGuideMessage(uiState.parking) + tietInputExistsSmokingArea.hint = boolToStringOrElseGuideMessage(uiState.existsSmokingArea) + tietInputExistsWifi.hint = boolToStringOrElseGuideMessage(uiState.existsWifi) + tietInputRestRoom.hint = stringOrElseGuideMessage(uiState.restRoom) + tietInputMobileCharging.hint = stringOrElseGuideMessage(uiState.mobileCharging) + tietInputInstagramUri.hint = stringOrElseGuideMessage(uiState.instagramUri) + tietInputWebsiteUri.hint = stringOrElseGuideMessage(uiState.websiteUri) + tietInputBlogUri.hint = stringOrElseGuideMessage(uiState.blogUri) + tietInputPhone.hint = stringOrElseGuideMessage(uiState.phone) + } + } + } + launch { + viewModel.placeName.collect { + cafeName = it + } + } + launch { + binding.apply { + viewModel.navigateToUpsertEvent.collect { + if (it) { + val action = InputCafeInfoFragmentDirections.actionFragmentInputCafeInfoToFragmentUpdateMenuComplete() + findNavController().safeNavigate(action) + } + } + } + } + launch { + viewModel.showToastEvent.collect { message -> + Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() + } + } + } + } + + private fun stringOrElseGuideMessage(str: String?): String { + return str ?: guideMessage + } + + private fun intToStringOrElseGuideMessage(int: Int?): String { + return int?.toString() ?: guideMessage + } + + private fun boolToStringOrElseGuideMessage(bool: Boolean?): String { + return if (bool == null) guideMessage + else { + if (bool) "O" + else "X" + } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt index 2c7d1179..540758cd 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt @@ -29,6 +29,8 @@ class UpdateCafeCompleteFragment : BaseFragment? = null, + val existsSmokingArea: Boolean? = null, + val existsWifi: Boolean? = null, + val instagramUri: String? = null, + val meetingRoomCount: Int? = null, + val mobileCharging: String? = null, + val multiSeatCount: Int? = null, + val parking: String? = null, + val phone: String? = null, + val restRoom: String? = null, + val singleSeatCount: Int? = null, + val websiteUri: String? = null, +) @HiltViewModel -class InputCafeInfoViewModel @Inject constructor(savedStateHandle: SavedStateHandle) : ViewModel() +class InputCafeInfoViewModel @Inject constructor( + private val getPlaceUseCase: GetPlaceUseCase, + private val upsertlaceBodyUseCase: UpsertlaceBodyUseCase, +) : ViewModel() { + private val _uiState = MutableStateFlow(CafeInfoUiState()) + val uiState = _uiState.asStateFlow() + + private val _placeName = MutableStateFlow("") + val placeName = _placeName.asStateFlow() + + private val _navigateToUpsertEvent = MutableSharedFlow(0) + val navigateToUpsertEvent: SharedFlow = _navigateToUpsertEvent.asSharedFlow() + + private val _showToastEvent = MutableSharedFlow() + val showToastEvent: SharedFlow = _showToastEvent.asSharedFlow() + fun getPlaceBody(placeId: Int) { + viewModelScope.launch { + val result = getPlaceUseCase(placeId) + when { + result.isSuccess && result.getOrNull() != null -> { + val placeBody = result.getOrNull()!! + Timber.d("plcaeBody >>> $placeBody") + _uiState.update { uiState -> + uiState.copy( + areaSize = placeBody.info.areaSize, + blogUri = placeBody.info.blogUri, + businessHours = placeBody.info.businessHours, + existsSmokingArea = placeBody.info.existsSmokingArea, + existsWifi = placeBody.info.existsWifi, + instagramUri = placeBody.info.instagramUri, + meetingRoomCount = placeBody.info.meetingRoomCount, + mobileCharging = placeBody.info.mobileCharging, + multiSeatCount = placeBody.info.multiSeatCount, + parking = placeBody.info.parking, + phone = placeBody.info.phone, + restRoom = placeBody.info.restRoom, + singleSeatCount = placeBody.info.singleSeatCount, + websiteUri = placeBody.info.websiteUri, + ) + } + _placeName.emit(placeBody.name) + } + result.isSuccess && result.getOrNull() == null -> { + Timber.e("Request succeeded but data validation failed.") + } + result.isFailure -> { + val exception = result.exceptionOrNull() + Timber.d(exception) + _showToastEvent.emit(exception?.message ?: "Unknown Error Occured") + } + } + } + } + + fun upsertPlaceBody(upsertPlaceEntity: UpsertPlaceEntity) { + viewModelScope.launch { + val result = upsertlaceBodyUseCase(upsertPlaceEntity) + when { + result.isSuccess -> { + _navigateToUpsertEvent.emit(true) + } + result.isFailure -> { + val exception = result.exceptionOrNull() + Timber.d(exception) + _showToastEvent.emit(exception?.message ?: "Unknown Error Occured") + } + } + } + } +} diff --git a/update-cafe/src/main/res/layout/fragment_input_cafe_info.xml b/update-cafe/src/main/res/layout/fragment_input_cafe_info.xml index 4aee6823..e6dab8f3 100644 --- a/update-cafe/src/main/res/layout/fragment_input_cafe_info.xml +++ b/update-cafe/src/main/res/layout/fragment_input_cafe_info.xml @@ -224,6 +224,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/update-cafe/src/main/res/values/strings.xml b/update-cafe/src/main/res/values/strings.xml index 1688353f..f98124a9 100644 --- a/update-cafe/src/main/res/values/strings.xml +++ b/update-cafe/src/main/res/values/strings.xml @@ -43,6 +43,15 @@ 다인석 1인석 영업시간 + 주차 + 흡연 + 와이파이 + 화장실 + 모바일 충전 + 인스타그램 + 웹사이트 + 블로그 + 휴대폰 메뉴 초콜릿 케이크 가격 From 061f169dd41946d68660f6353511cb13b4688577 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Tue, 7 Nov 2023 20:39:26 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EC=A0=9C=EC=95=88,=20=EB=A9=94=EB=89=B4=20read=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update-cafe/src/main/AndroidManifest.xml | 2 +- .../updatecafe/ui/SelectCafeMenuFragment.kt | 34 ++++- .../updatecafe/ui/adapter/CafeMenuAdapter.kt | 21 ++++ .../adapter/viewholder/CafeMenuViewHolder.kt | 33 +++++ .../updatecafe/ui/item/CafeMenuItem.kt | 13 ++ .../viewmodel/SelectCafeMenuViewModel.kt | 69 +++++++++- .../res/layout/fragment_select_cafe_menu.xml | 2 +- .../src/main/res/layout/item_cafe_menu.xml | 72 ----------- .../main/res/layout/item_update_cafe_menu.xml | 118 ++++++++++++++++++ 9 files changed, 287 insertions(+), 77 deletions(-) create mode 100644 update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt create mode 100644 update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt create mode 100644 update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt delete mode 100644 update-cafe/src/main/res/layout/item_cafe_menu.xml create mode 100644 update-cafe/src/main/res/layout/item_update_cafe_menu.xml diff --git a/update-cafe/src/main/AndroidManifest.xml b/update-cafe/src/main/AndroidManifest.xml index a143aa88..bbf05658 100644 --- a/update-cafe/src/main/AndroidManifest.xml +++ b/update-cafe/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ android:name=".ui.UpdateCafeActivity" android:exported="true" android:theme="@style/Theme.Eggeum.UpdateCafe" - android:windowSoftInputMode="adjustPan"/> + android:windowSoftInputMode="adjustPan" /> \ No newline at end of file diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index 0f2e9c49..f418f3d0 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -14,22 +14,46 @@ import android.view.View import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch +import timber.log.Timber +import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment +import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.viewmodel.SelectCafeMenuViewModel @AndroidEntryPoint class SelectCafeMenuFragment : BaseFragment() { + private val cafeMenuAdapter by lazy { CafeMenuAdapter() } + override fun getViewBinding() = FragmentSelectCafeMenuBinding.inflate(layoutInflater) private val viewModel by viewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + initView() initListener() initObserver() } + private fun initView() { + repeatOnStarted { + launch { + /** + * Intent에서 placeId 가져오기 + */ + viewModel.getCafeMenuList(1) + } + } + with(binding) { + rvCafeMenuList.apply { + setHasFixedSize(true) + adapter = cafeMenuAdapter + } + } + } + private fun initListener() { with(binding) { tbSelectInputCafeMenu.setNavigationOnClickListener { @@ -46,6 +70,14 @@ class SelectCafeMenuFragment : BaseFragment() { } private fun initObserver() { - // TODO + repeatOnStarted { + launch { + viewModel.cafeMenuList.collect { cafeMenuList -> + val cafeMenu = cafeMenuList.uiStateList?.map { it.toMain() }!! + Timber.d("" + cafeMenu) + cafeMenuAdapter.replaceAll(cafeMenu) + } + } + } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt new file mode 100644 index 00000000..3e8740c9 --- /dev/null +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt @@ -0,0 +1,21 @@ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + +package us.wedemy.eggeum.android.updatecafe.ui.adapter + +import android.view.ViewGroup +import us.wedemy.eggeum.android.common.extension.layoutInflater +import us.wedemy.eggeum.android.common.ui.BaseRecyclerViewAdapter +import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding +import us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder.CafeMenuViewHolder +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem + +class CafeMenuAdapter : BaseRecyclerViewAdapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = + CafeMenuViewHolder(ItemUpdateCafeMenuBinding.inflate(parent.context.layoutInflater, parent, false)) +} diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt new file mode 100644 index 00000000..7b54dfe1 --- /dev/null +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt @@ -0,0 +1,33 @@ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + +package us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder + +import java.text.NumberFormat +import java.util.Locale +import us.wedemy.eggeum.android.common.ui.BaseViewHolder +import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem + +class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder(binding) { + + override fun bind(item: CafeMenuItem) { + binding.apply { + tvCafeMenuName.text = item.name + tvCafeMenuPrice.text = formatPrice(item.price) + + imgBtn.setOnClickListener { + // TODO 수정 및 삭제 창 + } + } + } + + private fun formatPrice(price: Int): String { + val format = NumberFormat.getNumberInstance(Locale.KOREA) + return "₩" + format.format(price) + } +} diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt new file mode 100644 index 00000000..27ef3f3f --- /dev/null +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt @@ -0,0 +1,13 @@ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + +package us.wedemy.eggeum.android.updatecafe.ui.item + +data class CafeMenuItem( + val name: String, + val price: Int, +) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt index d51d2ea3..8a14105b 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt @@ -9,10 +9,75 @@ package us.wedemy.eggeum.android.updatecafe.viewmodel -import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch +import timber.log.Timber +import us.wedemy.eggeum.android.domain.usecase.GetPlaceUseCase +import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem + +data class UiState( + val name: String? = null, + val price: Int? = null, +) { + fun toMain(): CafeMenuItem { + return CafeMenuItem( + name = name!!, + price = price!!, + ) + } +} + +data class UiStateList( + val uiStateList: List? = emptyList(), +) @HiltViewModel -class SelectCafeMenuViewModel @Inject constructor(savedStateHandle: SavedStateHandle) : ViewModel() +class SelectCafeMenuViewModel @Inject constructor( + private val getPlaceUseCase: GetPlaceUseCase, + private val upsertlaceBodyUseCase: UpsertlaceBodyUseCase, +) : ViewModel() { + + private val _cafeMenuList = MutableStateFlow(UiStateList()) + val cafeMenuList = _cafeMenuList.asStateFlow() + + private val _showToastEvent = MutableSharedFlow() + val showToastEvent: SharedFlow = _showToastEvent.asSharedFlow() + fun getCafeMenuList(placeId: Int) { + viewModelScope.launch { + val result = getPlaceUseCase(placeId) + when { + result.isSuccess && result.getOrNull() != null -> { + val placeBody = result.getOrNull()!! + Timber.d("plcaeBody >>> $placeBody") + placeBody.menu.products?.let { + val productList = mutableListOf() + it.forEach { product -> + productList.add(UiState(name = product.name, price = product.price)) + } + _cafeMenuList.update { uiStates -> + uiStates.copy(uiStateList = productList) + } + } + } + result.isSuccess && result.getOrNull() == null -> { + Timber.e("Request succeeded but data validation failed.") + } + result.isFailure -> { + val exception = result.exceptionOrNull() + Timber.d(exception) + _showToastEvent.emit(exception?.message ?: "Unknown Error Occured") + } + } + } + } +} diff --git a/update-cafe/src/main/res/layout/fragment_select_cafe_menu.xml b/update-cafe/src/main/res/layout/fragment_select_cafe_menu.xml index 2749d77a..875a4554 100644 --- a/update-cafe/src/main/res/layout/fragment_select_cafe_menu.xml +++ b/update-cafe/src/main/res/layout/fragment_select_cafe_menu.xml @@ -64,7 +64,7 @@ app:layout_constraintBottom_toTopOf="@+id/line_input_cafe_menu" android:layout_marginTop="24dp" android:layout_marginHorizontal="16dp" - tools:listitem="@layout/item_cafe_menu"/> + tools:listitem="@layout/item_update_cafe_menu"/> - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/update-cafe/src/main/res/layout/item_update_cafe_menu.xml b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml new file mode 100644 index 00000000..e7406188 --- /dev/null +++ b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ed97da791e916cb7ce7ba5748c835e8c952c5d1f Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Wed, 15 Nov 2023 23:03:35 +0900 Subject: [PATCH 03/14] =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9A=B0=EC=B8=A1=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=20=EC=8B=9C,=20=EC=84=A0=ED=83=9D=20?= =?UTF-8?q?=EC=B0=BD(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/viewholder/CafeMenuViewHolder.kt | 13 +++++ .../main/res/layout/item_update_cafe_menu.xml | 56 ------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt index 7b54dfe1..3cf88d9d 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt @@ -7,13 +7,22 @@ package us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder +import android.app.Dialog +import android.util.Log +import android.view.KeyEvent +import android.view.MotionEvent +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView import java.text.NumberFormat import java.util.Locale +import us.wedemy.eggeum.android.common.extension.layoutInflater import us.wedemy.eggeum.android.common.ui.BaseViewHolder +import us.wedemy.eggeum.android.updatecafe.databinding.ItemEditBtnBinding import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder(binding) { + private val dialog = Dialog(binding.root.context) override fun bind(item: CafeMenuItem) { binding.apply { @@ -22,6 +31,10 @@ class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Sat, 25 Nov 2023 13:35:39 +0900 Subject: [PATCH 04/14] edit: imageview -> spinner (#147) --- .../adapter/viewholder/CafeMenuViewHolder.kt | 15 +---------- .../main/res/drawable/edit_btn_spinner.xml | 25 +++++++++++++++++++ .../main/res/layout/item_update_cafe_menu.xml | 13 ++++------ update-cafe/src/main/res/values/styles.xml | 12 +++++++++ 4 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 update-cafe/src/main/res/drawable/edit_btn_spinner.xml create mode 100644 update-cafe/src/main/res/values/styles.xml diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt index 3cf88d9d..c5bb8390 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt @@ -7,34 +7,21 @@ package us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder -import android.app.Dialog -import android.util.Log -import android.view.KeyEvent -import android.view.MotionEvent -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView import java.text.NumberFormat import java.util.Locale -import us.wedemy.eggeum.android.common.extension.layoutInflater import us.wedemy.eggeum.android.common.ui.BaseViewHolder -import us.wedemy.eggeum.android.updatecafe.databinding.ItemEditBtnBinding import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder(binding) { - private val dialog = Dialog(binding.root.context) override fun bind(item: CafeMenuItem) { binding.apply { tvCafeMenuName.text = item.name tvCafeMenuPrice.text = formatPrice(item.price) - imgBtn.setOnClickListener { + spinnerBtn.setOnClickListener { // TODO 수정 및 삭제 창 - val btn = ItemEditBtnBinding.inflate(root.context.layoutInflater) - dialog.setContentView(btn.root) - dialog.setCancelable(true) - dialog.show() } } } diff --git a/update-cafe/src/main/res/drawable/edit_btn_spinner.xml b/update-cafe/src/main/res/drawable/edit_btn_spinner.xml new file mode 100644 index 00000000..33994024 --- /dev/null +++ b/update-cafe/src/main/res/drawable/edit_btn_spinner.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/update-cafe/src/main/res/layout/item_update_cafe_menu.xml b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml index 0cdddf74..a07a6c2e 100644 --- a/update-cafe/src/main/res/layout/item_update_cafe_menu.xml +++ b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml @@ -32,21 +32,18 @@ android:textColor="@color/gray_900" android:layout_marginEnd="16dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/img_btn" + app:layout_constraintEnd_toStartOf="@+id/spinner_btn" app:layout_constraintTop_toTopOf="parent" tools:text="₩3,000" /> - + app:layout_constraintTop_toTopOf="parent" /> + + + + \ No newline at end of file From 48d68efb0e011ddca0c08f2c5e5577a9b90dc275 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Mon, 4 Dec 2023 22:37:53 +0900 Subject: [PATCH 05/14] =?UTF-8?q?popupmenu=20=EA=B5=AC=ED=98=84=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../updatecafe/ui/SelectCafeMenuFragment.kt | 11 ++++---- .../adapter/viewholder/CafeMenuViewHolder.kt | 24 ++++++++++++++++-- .../main/res/drawable/edit_btn_spinner.xml | 25 ------------------- .../main/res/layout/item_update_cafe_menu.xml | 8 +++--- update-cafe/src/main/res/menu/edit_menu.xml | 15 +++++++++++ update-cafe/src/main/res/values/styles.xml | 12 --------- 6 files changed, 46 insertions(+), 49 deletions(-) delete mode 100644 update-cafe/src/main/res/drawable/edit_btn_spinner.xml create mode 100644 update-cafe/src/main/res/menu/edit_menu.xml delete mode 100644 update-cafe/src/main/res/values/styles.xml diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index f418f3d0..f77b1521 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -17,7 +17,6 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import timber.log.Timber import us.wedemy.eggeum.android.common.extension.repeatOnStarted -import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding @@ -61,11 +60,11 @@ class SelectCafeMenuFragment : BaseFragment() { requireActivity().finish() } } - - btnInputCafeMenu.setOnClickListener { - val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu() - findNavController().safeNavigate(action) - } + // 드롭다운버튼 선택에 따라 다음 이동 +// btnInputCafeMenu.setOnClickListener { +// val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu() +// findNavController().safeNavigate(action) +// } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt index c5bb8390..7abb9ddb 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt @@ -7,9 +7,11 @@ package us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder +import android.widget.PopupMenu import java.text.NumberFormat import java.util.Locale import us.wedemy.eggeum.android.common.ui.BaseViewHolder +import us.wedemy.eggeum.android.updatecafe.R import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem @@ -20,8 +22,26 @@ class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder { + // 수정 페이지로 이동하려는데, navigator가 fragment 단에 있어서 어떻게 처리해야 할지 고민입니다. + true + } + R.id.menu_edit -> { + // 삭제를 선택하면, 다이얼 로그를 띄워서 확인 누르면, api를 쏘게 하고 싶은데 이것도 마찬가지로 viewmodel 단 메서드를 어떻게 호출시켜야 하는지 고민입니다. + true + } + else -> false + } + } } } } diff --git a/update-cafe/src/main/res/drawable/edit_btn_spinner.xml b/update-cafe/src/main/res/drawable/edit_btn_spinner.xml deleted file mode 100644 index 33994024..00000000 --- a/update-cafe/src/main/res/drawable/edit_btn_spinner.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/update-cafe/src/main/res/layout/item_update_cafe_menu.xml b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml index a07a6c2e..8aa3c46e 100644 --- a/update-cafe/src/main/res/layout/item_update_cafe_menu.xml +++ b/update-cafe/src/main/res/layout/item_update_cafe_menu.xml @@ -32,13 +32,13 @@ android:textColor="@color/gray_900" android:layout_marginEnd="16dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/spinner_btn" + app:layout_constraintEnd_toStartOf="@+id/iv_btn" app:layout_constraintTop_toTopOf="parent" tools:text="₩3,000" /> - + + + + + + + \ No newline at end of file diff --git a/update-cafe/src/main/res/values/styles.xml b/update-cafe/src/main/res/values/styles.xml deleted file mode 100644 index f93598f9..00000000 --- a/update-cafe/src/main/res/values/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file From e05e4bf439352b42f93be71f9b8d125983d1efa4 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Wed, 6 Dec 2023 23:56:35 +0900 Subject: [PATCH 06/14] =?UTF-8?q?Add:=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EA=B8=B0,=20=EC=82=AD=EC=A0=9C=ED=95=98=EA=B8=B0=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=81=B4=EB=A6=AD=20=EA=B5=AC=ED=98=84=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../updatecafe/ui/SelectCafeMenuFragment.kt | 27 ++++++++++++++++++- .../updatecafe/ui/adapter/CafeMenuAdapter.kt | 13 +++++++-- .../adapter/viewholder/CafeMenuViewHolder.kt | 22 ++++++++++++--- .../updatecafe/ui/item/CafeMenuItem.kt | 1 + .../viewmodel/SelectCafeMenuViewModel.kt | 4 ++- 5 files changed, 59 insertions(+), 8 deletions(-) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index f77b1521..1002c387 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle +import android.util.Log import android.view.View import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController @@ -20,11 +21,35 @@ import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem import us.wedemy.eggeum.android.updatecafe.viewmodel.SelectCafeMenuViewModel +interface EditOnClickListener { + fun editBtnClickListener(cafeMenu: CafeMenuItem) +} + +interface DeleteOnClickListener { + fun deleteBtnClickListener(cafeMenu: CafeMenuItem) +} + @AndroidEntryPoint class SelectCafeMenuFragment : BaseFragment() { - private val cafeMenuAdapter by lazy { CafeMenuAdapter() } + private val cafeMenuAdapter by lazy { + CafeMenuAdapter( + object : EditOnClickListener { + override fun editBtnClickListener(cafeMenu: CafeMenuItem) { + // 구현 + Log.d("tlqkf", "수정하기 클릭!!!!") + } + }, + object : DeleteOnClickListener { + override fun deleteBtnClickListener(cafeMenu: CafeMenuItem) { + // 구현 + Log.d("tlqkf", "삭제하기 클릭!!!!") + } + }, + ) + } override fun getViewBinding() = FragmentSelectCafeMenuBinding.inflate(layoutInflater) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt index 3e8740c9..6a4e936c 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/CafeMenuAdapter.kt @@ -11,11 +11,20 @@ import android.view.ViewGroup import us.wedemy.eggeum.android.common.extension.layoutInflater import us.wedemy.eggeum.android.common.ui.BaseRecyclerViewAdapter import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding +import us.wedemy.eggeum.android.updatecafe.ui.DeleteOnClickListener +import us.wedemy.eggeum.android.updatecafe.ui.EditOnClickListener import us.wedemy.eggeum.android.updatecafe.ui.adapter.viewholder.CafeMenuViewHolder import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem -class CafeMenuAdapter : BaseRecyclerViewAdapter() { +class CafeMenuAdapter( + private val editOnClickListener: EditOnClickListener, + private val deleteOnClickListener: DeleteOnClickListener, +) : BaseRecyclerViewAdapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = - CafeMenuViewHolder(ItemUpdateCafeMenuBinding.inflate(parent.context.layoutInflater, parent, false)) + CafeMenuViewHolder( + ItemUpdateCafeMenuBinding.inflate(parent.context.layoutInflater, parent, false), + editOnClickListener, + deleteOnClickListener, + ) } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt index 7abb9ddb..22a98a46 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/adapter/viewholder/CafeMenuViewHolder.kt @@ -13,9 +13,23 @@ import java.util.Locale import us.wedemy.eggeum.android.common.ui.BaseViewHolder import us.wedemy.eggeum.android.updatecafe.R import us.wedemy.eggeum.android.updatecafe.databinding.ItemUpdateCafeMenuBinding +import us.wedemy.eggeum.android.updatecafe.ui.DeleteOnClickListener +import us.wedemy.eggeum.android.updatecafe.ui.EditOnClickListener import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem -class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder(binding) { +class CafeMenuViewHolder( + binding: ItemUpdateCafeMenuBinding, + editOnClickListener: EditOnClickListener, + deleteOnClickListener: DeleteOnClickListener, +) : BaseViewHolder(binding) { + + private val clickOnEditBtn by lazy { + editOnClickListener + } + + private val clickOnDeleteBtn by lazy { + deleteOnClickListener + } override fun bind(item: CafeMenuItem) { binding.apply { @@ -32,11 +46,11 @@ class CafeMenuViewHolder(binding: ItemUpdateCafeMenuBinding) : BaseViewHolder { - // 수정 페이지로 이동하려는데, navigator가 fragment 단에 있어서 어떻게 처리해야 할지 고민입니다. + clickOnEditBtn.editBtnClickListener(cafeMenu = item) true } - R.id.menu_edit -> { - // 삭제를 선택하면, 다이얼 로그를 띄워서 확인 누르면, api를 쏘게 하고 싶은데 이것도 마찬가지로 viewmodel 단 메서드를 어떻게 호출시켜야 하는지 고민입니다. + R.id.menu_delete -> { + clickOnDeleteBtn.deleteBtnClickListener(cafeMenu = item) true } else -> false diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt index 27ef3f3f..6e2b3047 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt @@ -8,6 +8,7 @@ package us.wedemy.eggeum.android.updatecafe.ui.item data class CafeMenuItem( + val placeId: Int, val name: String, val price: Int, ) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt index 8a14105b..a1f5154f 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt @@ -26,11 +26,13 @@ import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem data class UiState( + val id: Int? = null, val name: String? = null, val price: Int? = null, ) { fun toMain(): CafeMenuItem { return CafeMenuItem( + placeId = id!!, name = name!!, price = price!!, ) @@ -62,7 +64,7 @@ class SelectCafeMenuViewModel @Inject constructor( placeBody.menu.products?.let { val productList = mutableListOf() it.forEach { product -> - productList.add(UiState(name = product.name, price = product.price)) + productList.add(UiState(id = placeId, name = product.name, price = product.price)) } _cafeMenuList.update { uiStates -> uiStates.copy(uiStateList = productList) From 0760300773df3761369d784a0e7d02cb665944f4 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Thu, 7 Dec 2023 23:43:29 +0900 Subject: [PATCH 07/14] =?UTF-8?q?Add=20:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=8B=A4=EC=9D=B4=EC=96=BC?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EA=B8=B0=EB=B3=B8=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../updatecafe/ui/SelectCafeMenuFragment.kt | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index 1002c387..7172aa1a 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -9,15 +9,19 @@ package us.wedemy.eggeum.android.updatecafe.ui +import android.content.DialogInterface +import android.content.DialogInterface.OnClickListener import android.os.Bundle -import android.util.Log import android.view.View +import androidx.appcompat.app.AlertDialog +import androidx.core.content.ContextCompat import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import timber.log.Timber import us.wedemy.eggeum.android.common.extension.repeatOnStarted +import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding @@ -38,14 +42,14 @@ class SelectCafeMenuFragment : BaseFragment() { CafeMenuAdapter( object : EditOnClickListener { override fun editBtnClickListener(cafeMenu: CafeMenuItem) { - // 구현 - Log.d("tlqkf", "수정하기 클릭!!!!") + // TODO: cafeMenu 데이터 넘겨주기 + val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu() + findNavController().safeNavigate(action) } }, object : DeleteOnClickListener { override fun deleteBtnClickListener(cafeMenu: CafeMenuItem) { - // 구현 - Log.d("tlqkf", "삭제하기 클릭!!!!") + showEditOrDeleteDialog() } }, ) @@ -61,12 +65,28 @@ class SelectCafeMenuFragment : BaseFragment() { initObserver() } + private fun showEditOrDeleteDialog() { + val dialog = AlertDialog.Builder(requireContext()) + .setMessage("삭제 하시겠어요?") + .setPositiveButton("삭제", object : OnClickListener { + override fun onClick(p0: DialogInterface?, p1: Int) { + // TODO: 삭제 API 호출 + } + }) + .setNegativeButton("취소", null) // 취소 시에는 동작 없음. + .show() + dialog.apply { + getButton(DialogInterface.BUTTON_POSITIVE) + .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.teal_500)) + getButton(DialogInterface.BUTTON_NEGATIVE) + .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.gray_400)) + } + } + private fun initView() { repeatOnStarted { launch { - /** - * Intent에서 placeId 가져오기 - */ + // TODO: 지도에서 placdId 받아와서 인자 넣기 viewModel.getCafeMenuList(1) } } @@ -85,11 +105,9 @@ class SelectCafeMenuFragment : BaseFragment() { requireActivity().finish() } } - // 드롭다운버튼 선택에 따라 다음 이동 -// btnInputCafeMenu.setOnClickListener { -// val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu() -// findNavController().safeNavigate(action) -// } + btnInputCafeMenu.setOnClickListener { + // TODO: 그냥 다음으로 넘어가면, 어떤 동작을 해야 하나? + } } } From 36bfe00f2a96c3e592454208c85d4159afb4f7e1 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Tue, 12 Dec 2023 00:04:05 +0900 Subject: [PATCH 08/14] =?UTF-8?q?Edit:=20=EB=A9=94=EB=89=B4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=ED=99=94=EB=A9=B4=20=EC=9E=AC=EB=A1=9C=EB=94=A9,?= =?UTF-8?q?=20=EB=8B=A4=EC=9D=8C=20=EC=88=98=EC=A0=95=20=EB=B0=98=EC=98=81?= =?UTF-8?q?=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 +- .../android/domain/model/place/ImageEntity.kt | 12 +++- .../android/domain/model/place/MenuEntity.kt | 14 ++++- .../android/domain/model/place/PlaceEntity.kt | 55 ++++++++++++++++-- update-cafe/src/main/AndroidManifest.xml | 7 ++- .../updatecafe/ui/InputCafeMenuFragment.kt | 5 +- .../updatecafe/ui/SelectCafeMenuFragment.kt | 21 ++++++- .../ui/UpdateCafeCompleteFragment.kt | 5 +- .../updatecafe/ui/item/CafeMenuItem.kt | 2 +- .../viewmodel/InputCafeInfoViewModel.kt | 30 +++++----- .../viewmodel/SelectCafeMenuViewModel.kt | 56 +++++++++++++++---- .../main/res/navigation/nav_update_cafe.xml | 24 ++++---- 12 files changed, 176 insertions(+), 59 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 61710f96..9f876cad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,10 +36,10 @@ android:name=".IntroActivity" android:exported="true" android:theme="@style/Theme.Eggeum.Splash"> - + diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt index 6552a0ac..86d399df 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ImageEntity.kt @@ -11,4 +11,14 @@ import us.wedemy.eggeum.android.domain.model.FileEntity public data class ImageEntity( val files: List?, -) +) { + public companion object { + public fun of( + files: List? = null, + ): ImageEntity { + return ImageEntity( + files = files, + ) + } + } +} diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt index 9ca4aa56..e4646b60 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/MenuEntity.kt @@ -8,5 +8,15 @@ package us.wedemy.eggeum.android.domain.model.place public data class MenuEntity( - val products: List?, -) + var products: List?, +) { + public companion object { + public fun of( + products: List? = null, + ): MenuEntity { + return MenuEntity( + products = products, + ) + } + } +} diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt index 653ca25b..d174d138 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt @@ -10,12 +10,55 @@ package us.wedemy.eggeum.android.domain.model.place public data class PlaceEntity( val address1: String?, val address2: String?, - val id: Int, - val image: ImageEntity, - val info: InfoEntity, + val id: Int?, + val image: ImageEntity?, + val info: InfoEntity?, val latitude: Double?, val longitude: Double?, - val menu: MenuEntity, - val name: String, + val menu: MenuEntity?, + val name: String?, val type: String?, -) +) { + public fun toUpsertPlaceEntity(): UpsertPlaceEntity { + return UpsertPlaceEntity( + address1 = address1, + address2 = address2, + placeId = id!!, + image = image, + info = info!!, + latitude = latitude, + longitude = longitude, + menu = menu, + name = name, + remarks = null, + type = type, + ) + } + public companion object { + public fun of( + address1: String? = null, + address2: String? = null, + id: Int? = null, + image: ImageEntity? = null, + info: InfoEntity? = null, + latitude: Double? = null, + longitude: Double? = null, + menu: MenuEntity? = null, + name: String? = null, + type: String? = null, + ): PlaceEntity { + return PlaceEntity( + address1 = address1, + address2 = address2, + id = id, + image = image, + info = info, + latitude = latitude, + longitude = longitude, + menu = menu, + name = name, + type = type, + ) + } + } +} diff --git a/update-cafe/src/main/AndroidManifest.xml b/update-cafe/src/main/AndroidManifest.xml index bbf05658..797dd979 100644 --- a/update-cafe/src/main/AndroidManifest.xml +++ b/update-cafe/src/main/AndroidManifest.xml @@ -11,7 +11,12 @@ android:name=".ui.UpdateCafeActivity" android:exported="true" android:theme="@style/Theme.Eggeum.UpdateCafe" - android:windowSoftInputMode="adjustPan" /> + android:windowSoftInputMode="adjustPan" > + + + + + \ No newline at end of file diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt index 873994a7..964d3836 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt @@ -12,9 +12,7 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle import android.view.View import androidx.fragment.app.viewModels -import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint -import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.databinding.FragmentInputCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.viewmodel.InputCafeMenuViewModel @@ -33,8 +31,7 @@ class InputCafeMenuFragment : BaseFragment() { private fun initListener() { with(binding) { btnUpdateMenuComplete.setOnClickListener { - val action = InputCafeMenuFragmentDirections.actionInputCafeMenuFragmentToUpdateMenuCompleteFragment() - findNavController().safeNavigate(action) + // TODO: 다시 이전 페이지로 돌아가기 } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index 7172aa1a..ee4d989e 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -23,6 +23,7 @@ import timber.log.Timber import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment +import us.wedemy.eggeum.android.domain.model.place.ProductEntity import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem @@ -49,7 +50,7 @@ class SelectCafeMenuFragment : BaseFragment() { }, object : DeleteOnClickListener { override fun deleteBtnClickListener(cafeMenu: CafeMenuItem) { - showEditOrDeleteDialog() + showEditOrDeleteDialog(item = cafeMenu) } }, ) @@ -65,12 +66,23 @@ class SelectCafeMenuFragment : BaseFragment() { initObserver() } - private fun showEditOrDeleteDialog() { + private fun showEditOrDeleteDialog(item: CafeMenuItem) { val dialog = AlertDialog.Builder(requireContext()) .setMessage("삭제 하시겠어요?") .setPositiveButton("삭제", object : OnClickListener { override fun onClick(p0: DialogInterface?, p1: Int) { // TODO: 삭제 API 호출 + val cafeMenuList = viewModel.cafeMenuList.value.uiStateList + val newCafeMenuList = mutableListOf() + cafeMenuList?.forEach { + if (!(it.name == item.name && it.price == item.price)) { + newCafeMenuList.add(it.toEntity()) + } + } + viewModel.placeBody.menu?.products = newCafeMenuList + val newPlaceBody = (viewModel.placeBody.menu?.products as MutableList) + val changedUiState = viewModel.initializeUiState(products = newPlaceBody) + viewModel.uiStateUpdateCafeMenuList(productList = changedUiState) } }) .setNegativeButton("취소", null) // 취소 시에는 동작 없음. @@ -106,7 +118,10 @@ class SelectCafeMenuFragment : BaseFragment() { } } btnInputCafeMenu.setOnClickListener { - // TODO: 그냥 다음으로 넘어가면, 어떤 동작을 해야 하나? + // TODO: 새로운 placeBody -> UpsertPlaceBody -> db update -> 수정 완료 페이지 + viewModel.getUpdateCafeMenu() + val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentUpdateMenuComplete() + findNavController().safeNavigate(action) } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt index 540758cd..787faf47 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeCompleteFragment.kt @@ -11,6 +11,7 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle import android.view.View +import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.databinding.FragmentUpdateCafeCompleteBinding @@ -30,7 +31,9 @@ class UpdateCafeCompleteFragment : BaseFragment>> $placeBody") _uiState.update { uiState -> uiState.copy( - areaSize = placeBody.info.areaSize, - blogUri = placeBody.info.blogUri, - businessHours = placeBody.info.businessHours, - existsSmokingArea = placeBody.info.existsSmokingArea, - existsWifi = placeBody.info.existsWifi, - instagramUri = placeBody.info.instagramUri, - meetingRoomCount = placeBody.info.meetingRoomCount, - mobileCharging = placeBody.info.mobileCharging, - multiSeatCount = placeBody.info.multiSeatCount, - parking = placeBody.info.parking, - phone = placeBody.info.phone, - restRoom = placeBody.info.restRoom, - singleSeatCount = placeBody.info.singleSeatCount, - websiteUri = placeBody.info.websiteUri, + areaSize = placeBody.info?.areaSize, + blogUri = placeBody.info?.blogUri, + businessHours = placeBody.info?.businessHours, + existsSmokingArea = placeBody.info?.existsSmokingArea, + existsWifi = placeBody.info?.existsWifi, + instagramUri = placeBody.info?.instagramUri, + meetingRoomCount = placeBody.info?.meetingRoomCount, + mobileCharging = placeBody.info?.mobileCharging, + multiSeatCount = placeBody.info?.multiSeatCount, + parking = placeBody.info?.parking, + phone = placeBody.info?.phone, + restRoom = placeBody.info?.restRoom, + singleSeatCount = placeBody.info?.singleSeatCount, + websiteUri = placeBody.info?.websiteUri, ) } - _placeName.emit(placeBody.name) + _placeName.emit(placeBody.name!!) } result.isSuccess && result.getOrNull() == null -> { Timber.e("Request succeeded but data validation failed.") diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt index a1f5154f..951b19cf 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt @@ -21,18 +21,24 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import timber.log.Timber +import us.wedemy.eggeum.android.domain.model.place.PlaceEntity +import us.wedemy.eggeum.android.domain.model.place.ProductEntity import us.wedemy.eggeum.android.domain.usecase.GetPlaceUseCase import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem data class UiState( - val id: Int? = null, val name: String? = null, val price: Int? = null, ) { fun toMain(): CafeMenuItem { return CafeMenuItem( - placeId = id!!, + name = name!!, + price = price!!, + ) + } + fun toEntity(): ProductEntity { + return ProductEntity( name = name!!, price = price!!, ) @@ -52,23 +58,21 @@ class SelectCafeMenuViewModel @Inject constructor( private val _cafeMenuList = MutableStateFlow(UiStateList()) val cafeMenuList = _cafeMenuList.asStateFlow() + lateinit var placeBody: PlaceEntity + private val _showToastEvent = MutableSharedFlow() val showToastEvent: SharedFlow = _showToastEvent.asSharedFlow() + fun getCafeMenuList(placeId: Int) { viewModelScope.launch { val result = getPlaceUseCase(placeId) when { result.isSuccess && result.getOrNull() != null -> { - val placeBody = result.getOrNull()!! + placeBody = result.getOrNull()!! Timber.d("plcaeBody >>> $placeBody") - placeBody.menu.products?.let { - val productList = mutableListOf() - it.forEach { product -> - productList.add(UiState(id = placeId, name = product.name, price = product.price)) - } - _cafeMenuList.update { uiStates -> - uiStates.copy(uiStateList = productList) - } + placeBody.menu?.products?.let { + val productList: MutableList = initializeUiState(products = it) + uiStateUpdateCafeMenuList(productList = productList) } } result.isSuccess && result.getOrNull() == null -> { @@ -82,4 +86,34 @@ class SelectCafeMenuViewModel @Inject constructor( } } } + + fun initializeUiState(products: List): MutableList { + val productList = mutableListOf() + products.forEach { product -> + productList.add(UiState(name = product.name, price = product.price)) + } + return productList + } + + fun uiStateUpdateCafeMenuList(productList: MutableList) { + _cafeMenuList.update { uiStates -> + uiStates.copy(uiStateList = productList) + } + } + + fun getUpdateCafeMenu() { + viewModelScope.launch { + val result = upsertlaceBodyUseCase(placeBody.toUpsertPlaceEntity()) + when { + result.isSuccess -> { + // TODO: 메뉴 수정을 완료했어요 fragment + } + result.isFailure -> { + val exception = result.exceptionOrNull() + Timber.d(exception) + _showToastEvent.emit(exception?.message ?: "Unknown Error Occured") + } + } + } + } } diff --git a/update-cafe/src/main/res/navigation/nav_update_cafe.xml b/update-cafe/src/main/res/navigation/nav_update_cafe.xml index 343f2b7a..ef7df4d5 100644 --- a/update-cafe/src/main/res/navigation/nav_update_cafe.xml +++ b/update-cafe/src/main/res/navigation/nav_update_cafe.xml @@ -93,13 +93,19 @@ android:name="us.wedemy.eggeum.android.updatecafe.ui.SelectCafeMenuFragment" android:label="SelectCafeMenuFragment" tools:layout="@layout/fragment_select_cafe_menu"> + + + + + + + + + app:destination="@id/fragment_input_cafe_menu" /> - + Date: Tue, 12 Dec 2023 23:14:23 +0900 Subject: [PATCH 09/14] =?UTF-8?q?Edit:=20=EC=82=AD=EC=A0=9C=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=ED=94=BC=EB=93=9C=EB=B0=B1=20=EB=B0=98=EC=98=81=20?= =?UTF-8?q?&=20=EC=88=98=EC=A0=95=20=EC=8B=9C,=20fragment=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=A0=84=EB=8B=AC(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 8 ++-- .../updatecafe/ui/InputCafeMenuFragment.kt | 11 +++++ .../updatecafe/ui/SelectCafeMenuFragment.kt | 31 +++++++------ .../updatecafe/ui/item/CafeMenuItem.kt | 12 +++++- .../viewmodel/SelectCafeMenuViewModel.kt | 43 ++++--------------- .../res/layout/fragment_input_cafe_menu.xml | 2 +- .../main/res/navigation/nav_update_cafe.xml | 4 +- 7 files changed, 57 insertions(+), 54 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9f876cad..7e8bc1cc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,10 +36,10 @@ android:name=".IntroActivity" android:exported="true" android:theme="@style/Theme.Eggeum.Splash"> - + + + + diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt index 964d3836..205d37d7 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt @@ -12,6 +12,7 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle import android.view.View import androidx.fragment.app.viewModels +import androidx.navigation.fragment.navArgs import dagger.hilt.android.AndroidEntryPoint import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.databinding.FragmentInputCafeMenuBinding @@ -23,11 +24,21 @@ class InputCafeMenuFragment : BaseFragment() { private val viewModel by viewModels() + private val args by navArgs() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { initListener() initObserver() } + override fun onStart() { + super.onStart() + with(binding) { + tietInputCafeName.hint = args.cafeMenuItem.name + tietInputCafePrice.hint = args.cafeMenuItem.price.toString() + } + } + private fun initListener() { with(binding) { btnUpdateMenuComplete.setOnClickListener { diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index ee4d989e..fa042313 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -44,7 +44,12 @@ class SelectCafeMenuFragment : BaseFragment() { object : EditOnClickListener { override fun editBtnClickListener(cafeMenu: CafeMenuItem) { // TODO: cafeMenu 데이터 넘겨주기 - val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu() + val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu( + CafeMenuItem( + name = cafeMenu.name, + price = cafeMenu.price, + ) + ) findNavController().safeNavigate(action) } }, @@ -66,23 +71,29 @@ class SelectCafeMenuFragment : BaseFragment() { initObserver() } + override fun onStart() { + super.onStart() + // TODO: 지도에서 placdId 받아와서 인자 넣기 + viewModel.getCafeMenuList(1) + } + private fun showEditOrDeleteDialog(item: CafeMenuItem) { val dialog = AlertDialog.Builder(requireContext()) .setMessage("삭제 하시겠어요?") .setPositiveButton("삭제", object : OnClickListener { override fun onClick(p0: DialogInterface?, p1: Int) { // TODO: 삭제 API 호출 - val cafeMenuList = viewModel.cafeMenuList.value.uiStateList + val cafeMenuList = viewModel.cafeMenuList.value val newCafeMenuList = mutableListOf() - cafeMenuList?.forEach { + cafeMenuList.forEach { if (!(it.name == item.name && it.price == item.price)) { newCafeMenuList.add(it.toEntity()) } } viewModel.placeBody.menu?.products = newCafeMenuList val newPlaceBody = (viewModel.placeBody.menu?.products as MutableList) - val changedUiState = viewModel.initializeUiState(products = newPlaceBody) - viewModel.uiStateUpdateCafeMenuList(productList = changedUiState) + val changedUiState = viewModel.initializeCafeMenuItem(products = newPlaceBody) + viewModel.updateCafeMenuList(productList = changedUiState) } }) .setNegativeButton("취소", null) // 취소 시에는 동작 없음. @@ -96,12 +107,6 @@ class SelectCafeMenuFragment : BaseFragment() { } private fun initView() { - repeatOnStarted { - launch { - // TODO: 지도에서 placdId 받아와서 인자 넣기 - viewModel.getCafeMenuList(1) - } - } with(binding) { rvCafeMenuList.apply { setHasFixedSize(true) @@ -119,7 +124,7 @@ class SelectCafeMenuFragment : BaseFragment() { } btnInputCafeMenu.setOnClickListener { // TODO: 새로운 placeBody -> UpsertPlaceBody -> db update -> 수정 완료 페이지 - viewModel.getUpdateCafeMenu() + viewModel.updatePlaceBodyUseCase() val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentUpdateMenuComplete() findNavController().safeNavigate(action) } @@ -130,7 +135,7 @@ class SelectCafeMenuFragment : BaseFragment() { repeatOnStarted { launch { viewModel.cafeMenuList.collect { cafeMenuList -> - val cafeMenu = cafeMenuList.uiStateList?.map { it.toMain() }!! + val cafeMenu = cafeMenuList.map { it } Timber.d("" + cafeMenu) cafeMenuAdapter.replaceAll(cafeMenu) } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt index a2be0e63..8c94ab3c 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt @@ -8,7 +8,17 @@ package us.wedemy.eggeum.android.updatecafe.ui.item +import kotlinx.parcelize.Parcelize +import android.os.Parcelable +import us.wedemy.eggeum.android.domain.model.place.ProductEntity + +@Parcelize data class CafeMenuItem( val name: String, val price: Int, -) +): Parcelable { + fun toEntity(): ProductEntity = ProductEntity( + name = name, + price = price, + ) +} \ No newline at end of file diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt index 951b19cf..90671a3a 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt @@ -18,7 +18,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import timber.log.Timber import us.wedemy.eggeum.android.domain.model.place.PlaceEntity @@ -27,35 +26,13 @@ import us.wedemy.eggeum.android.domain.usecase.GetPlaceUseCase import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem -data class UiState( - val name: String? = null, - val price: Int? = null, -) { - fun toMain(): CafeMenuItem { - return CafeMenuItem( - name = name!!, - price = price!!, - ) - } - fun toEntity(): ProductEntity { - return ProductEntity( - name = name!!, - price = price!!, - ) - } -} - -data class UiStateList( - val uiStateList: List? = emptyList(), -) - @HiltViewModel class SelectCafeMenuViewModel @Inject constructor( private val getPlaceUseCase: GetPlaceUseCase, private val upsertlaceBodyUseCase: UpsertlaceBodyUseCase, ) : ViewModel() { - private val _cafeMenuList = MutableStateFlow(UiStateList()) + private val _cafeMenuList = MutableStateFlow(emptyList()) val cafeMenuList = _cafeMenuList.asStateFlow() lateinit var placeBody: PlaceEntity @@ -71,8 +48,8 @@ class SelectCafeMenuViewModel @Inject constructor( placeBody = result.getOrNull()!! Timber.d("plcaeBody >>> $placeBody") placeBody.menu?.products?.let { - val productList: MutableList = initializeUiState(products = it) - uiStateUpdateCafeMenuList(productList = productList) + val productList: MutableList = initializeCafeMenuItem(products = it) + updateCafeMenuList(productList = productList) } } result.isSuccess && result.getOrNull() == null -> { @@ -87,21 +64,19 @@ class SelectCafeMenuViewModel @Inject constructor( } } - fun initializeUiState(products: List): MutableList { - val productList = mutableListOf() + fun initializeCafeMenuItem(products: List): MutableList { + val productList = mutableListOf() products.forEach { product -> - productList.add(UiState(name = product.name, price = product.price)) + productList.add(CafeMenuItem(name = product.name, price = product.price)) } return productList } - fun uiStateUpdateCafeMenuList(productList: MutableList) { - _cafeMenuList.update { uiStates -> - uiStates.copy(uiStateList = productList) - } + fun updateCafeMenuList(productList: MutableList) { + _cafeMenuList.value = productList } - fun getUpdateCafeMenu() { + fun updatePlaceBodyUseCase() { viewModelScope.launch { val result = upsertlaceBodyUseCase(placeBody.toUpsertPlaceEntity()) when { diff --git a/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml b/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml index ac95226f..3c13b053 100644 --- a/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml +++ b/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml @@ -138,7 +138,7 @@ app:layout_constraintStart_toStartOf="parent"> - + Date: Fri, 15 Dec 2023 00:16:26 +0900 Subject: [PATCH 10/14] =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A0=9C=EC=95=88=20api=20=EA=B5=AC=ED=98=84=20#147?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 8 +- .../android/domain/model/place/PlaceEntity.kt | 2 +- .../domain/model/place/ProductEntity.kt | 4 +- update-cafe/src/main/AndroidManifest.xml | 8 +- .../updatecafe/ui/InputCafeInfoFragment.kt | 93 +++++++++++-------- .../updatecafe/ui/InputCafeMenuFragment.kt | 41 +++++++- .../updatecafe/ui/SelectCafeMenuFragment.kt | 53 +++++------ .../updatecafe/ui/UpdateCafeActivity.kt | 5 + .../updatecafe/ui/item/CafeInfoItem.kt | 47 ++++++++++ .../updatecafe/ui/item/CafeMenuItem.kt | 4 +- .../viewmodel/InputCafeInfoViewModel.kt | 38 ++------ .../viewmodel/InputCafeMenuViewModel.kt | 18 ---- ...ewModel.kt => ProposeCafeInfoViewModel.kt} | 36 ++++++- .../res/layout/fragment_input_cafe_menu.xml | 2 +- 14 files changed, 223 insertions(+), 136 deletions(-) create mode 100644 update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeInfoItem.kt delete mode 100644 update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeMenuViewModel.kt rename update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/{SelectCafeMenuViewModel.kt => ProposeCafeInfoViewModel.kt} (71%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7e8bc1cc..61710f96 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,10 +36,10 @@ android:name=".IntroActivity" android:exported="true" android:theme="@style/Theme.Eggeum.Splash"> - - - - + + + + diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt index d174d138..bef0ef17 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt @@ -12,7 +12,7 @@ public data class PlaceEntity( val address2: String?, val id: Int?, val image: ImageEntity?, - val info: InfoEntity?, + var info: InfoEntity?, val latitude: Double?, val longitude: Double?, val menu: MenuEntity?, diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ProductEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ProductEntity.kt index 14b43418..5e2d99de 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ProductEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/ProductEntity.kt @@ -8,6 +8,6 @@ package us.wedemy.eggeum.android.domain.model.place public data class ProductEntity( - val name: String, - val price: Int, + var name: String, + var price: Int, ) diff --git a/update-cafe/src/main/AndroidManifest.xml b/update-cafe/src/main/AndroidManifest.xml index 797dd979..a518df09 100644 --- a/update-cafe/src/main/AndroidManifest.xml +++ b/update-cafe/src/main/AndroidManifest.xml @@ -12,10 +12,10 @@ android:exported="true" android:theme="@style/Theme.Eggeum.UpdateCafe" android:windowSoftInputMode="adjustPan" > - - - - + + + + diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt index 3436cdd5..b6b32a68 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt @@ -21,7 +21,6 @@ import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.domain.model.place.InfoEntity -import us.wedemy.eggeum.android.domain.model.place.UpsertPlaceEntity import us.wedemy.eggeum.android.updatecafe.databinding.FragmentInputCafeInfoBinding import us.wedemy.eggeum.android.updatecafe.viewmodel.InputCafeInfoViewModel @@ -56,14 +55,10 @@ class InputCafeInfoFragment : BaseFragment() { } private fun initView() { - repeatOnStarted { - launch { - /** - * Intent에서 placeId 가져오기 - */ - viewModel.getPlaceBody(1) - } - } + /** + * Intent에서 placeId 가져오기 + */ + viewModel.getPlaceBody(1) } private fun initListener() { @@ -135,19 +130,15 @@ class InputCafeInfoFragment : BaseFragment() { singleSeatCount = stringToIntOrElseNull(cafeSingleSeat), websiteUri = stringOrElseNull(cafeWebsiteUri), ) + viewModel.placeBody.info = infoEntity - val upsertPlaceEntity = UpsertPlaceEntity.of( - info = infoEntity, - placeId = 1, - name = if (cafeName != "") cafeName else null, - ) - - viewModel.upsertPlaceBody(upsertPlaceEntity = upsertPlaceEntity) + viewModel.upsertPlaceBody() } } } - private fun stringToBoolean(str: String): Boolean { - return str == "O" + private fun stringToBoolean(str: String): Boolean? { + return if (str == "") null + else str == "O" } private fun stringOrElseNull(str: String): String? { @@ -163,31 +154,43 @@ class InputCafeInfoFragment : BaseFragment() { private fun initObserver() { repeatOnStarted { launch { - viewModel.uiState.collect { uiState -> + viewModel.cafeInfo.collect { cafeInfo -> with(binding) { - tietInputCafeArea.hint = stringOrElseGuideMessage(uiState.areaSize) - tietInputCafeMeetingRoom.hint = intToStringOrElseGuideMessage(uiState.meetingRoomCount) - tietInputCafeMultiSeat.hint = intToStringOrElseGuideMessage(uiState.multiSeatCount) - tietInputCafeSingleSeat.hint = intToStringOrElseGuideMessage(uiState.singleSeatCount) - tietInputCafeBusinessHours.hint = uiState.businessHours + tietInputCafeArea.hint = stringOrElseGuideMessage(cafeInfo.areaSize) + tietInputCafeMeetingRoom.hint = intToStringOrElseGuideMessage(cafeInfo.meetingRoomCount) + tietInputCafeMultiSeat.hint = intToStringOrElseGuideMessage(cafeInfo.multiSeatCount) + tietInputCafeSingleSeat.hint = intToStringOrElseGuideMessage(cafeInfo.singleSeatCount) + tietInputCafeBusinessHours.hint = cafeInfo.businessHours ?.joinToString(" ~ ", "", "", -1) ?: guideMessage - tietInputParking.hint = stringOrElseGuideMessage(uiState.parking) - tietInputExistsSmokingArea.hint = boolToStringOrElseGuideMessage(uiState.existsSmokingArea) - tietInputExistsWifi.hint = boolToStringOrElseGuideMessage(uiState.existsWifi) - tietInputRestRoom.hint = stringOrElseGuideMessage(uiState.restRoom) - tietInputMobileCharging.hint = stringOrElseGuideMessage(uiState.mobileCharging) - tietInputInstagramUri.hint = stringOrElseGuideMessage(uiState.instagramUri) - tietInputWebsiteUri.hint = stringOrElseGuideMessage(uiState.websiteUri) - tietInputBlogUri.hint = stringOrElseGuideMessage(uiState.blogUri) - tietInputPhone.hint = stringOrElseGuideMessage(uiState.phone) + tietInputParking.hint = stringOrElseGuideMessage(cafeInfo.parking) + tietInputExistsSmokingArea.hint = boolToStringOrElseGuideMessage(cafeInfo.existsSmokingArea) + tietInputExistsWifi.hint = boolToStringOrElseGuideMessage(cafeInfo.existsWifi) + tietInputRestRoom.hint = stringOrElseGuideMessage(cafeInfo.restRoom) + tietInputMobileCharging.hint = stringOrElseGuideMessage(cafeInfo.mobileCharging) + tietInputInstagramUri.hint = stringOrElseGuideMessage(cafeInfo.instagramUri) + tietInputWebsiteUri.hint = stringOrElseGuideMessage(cafeInfo.websiteUri) + tietInputBlogUri.hint = stringOrElseGuideMessage(cafeInfo.blogUri) + tietInputPhone.hint = stringOrElseGuideMessage(cafeInfo.phone) + + cafeArea = stringOrElseDefault(cafeInfo.areaSize) + cafeMeetingRoom = intToStringOrElseDefault(cafeInfo.meetingRoomCount) + cafeMultiSeat = intToStringOrElseDefault(cafeInfo.multiSeatCount) + cafeSingleSeat = intToStringOrElseDefault(cafeInfo.singleSeatCount) + cafeBusinessHours = cafeInfo.businessHours + ?.joinToString(" ~ ", "", "", -1) ?: "" + cafeParking = stringOrElseDefault(cafeInfo.parking) + cafeExistsSmokingArea = boolToStringOrElseDefault(cafeInfo.existsSmokingArea) + cafeExistsWifi = boolToStringOrElseDefault(cafeInfo.existsWifi) + cafeRestRoom = stringOrElseDefault(cafeInfo.restRoom) + cafeMobileCharging = stringOrElseDefault(cafeInfo.mobileCharging) + cafeWebsiteUri = stringOrElseDefault(cafeInfo.websiteUri) + cafeInstagramUri = stringOrElseDefault(cafeInfo.instagramUri) + cafeBlogUri = stringOrElseDefault(cafeInfo.blogUri) + cafePhone = stringOrElseDefault(cafeInfo.phone) } } } - launch { - viewModel.placeName.collect { - cafeName = it - } - } + launch { binding.apply { viewModel.navigateToUpsertEvent.collect { @@ -206,6 +209,20 @@ class InputCafeInfoFragment : BaseFragment() { } } + private fun stringOrElseDefault(str: String?): String { + return str ?: "" + } + + private fun intToStringOrElseDefault(int: Int?): String { + return int?.toString() ?: "" + } + + private fun boolToStringOrElseDefault(bool: Boolean?): String { + return if (bool == null) "" + else if (bool) "O" + else "X" + } + private fun stringOrElseGuideMessage(str: String?): String { return str ?: guideMessage } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt index 205d37d7..43ab9413 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt @@ -11,29 +11,42 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle import android.view.View -import androidx.fragment.app.viewModels +import androidx.core.widget.doAfterTextChanged +import androidx.fragment.app.activityViewModels +import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import dagger.hilt.android.AndroidEntryPoint import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.databinding.FragmentInputCafeMenuBinding -import us.wedemy.eggeum.android.updatecafe.viewmodel.InputCafeMenuViewModel +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem +import us.wedemy.eggeum.android.updatecafe.viewmodel.ProposeCafeInfoViewModel @AndroidEntryPoint class InputCafeMenuFragment : BaseFragment() { override fun getViewBinding() = FragmentInputCafeMenuBinding.inflate(layoutInflater) - private val viewModel by viewModels() + private val viewModel by activityViewModels() private val args by navArgs() + private lateinit var newCafeMenuName: String + private lateinit var newCafeMenuPrice: String + + private val beforeAndAfterCafeMenuItem = mutableMapOf() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + initView() initListener() initObserver() } override fun onStart() { super.onStart() - with(binding) { + beforeAndAfterCafeMenuItem["before"] = CafeMenuItem(name = args.cafeMenuItem.name, price = args.cafeMenuItem.price) + } + + private fun initView() { + binding.apply { tietInputCafeName.hint = args.cafeMenuItem.name tietInputCafePrice.hint = args.cafeMenuItem.price.toString() } @@ -41,8 +54,26 @@ class InputCafeMenuFragment : BaseFragment() { private fun initListener() { with(binding) { + tietInputCafeName.doAfterTextChanged { + newCafeMenuName = it.toString() + } + tietInputCafePrice.doAfterTextChanged { + newCafeMenuPrice = it.toString() + } + btnUpdateMenuComplete.setOnClickListener { - // TODO: 다시 이전 페이지로 돌아가기 + // TODO: 데이터 변경 후, 이전 Fragment에 전달하기 + beforeAndAfterCafeMenuItem["after"] = CafeMenuItem(name = newCafeMenuName, price = newCafeMenuPrice.toInt()) + viewModel.setCafeMenuItemMap(cafeMenuItemMap = beforeAndAfterCafeMenuItem) + + if (!findNavController().navigateUp()) { + requireActivity().finish() + } + } + tbSelectInputCafeMenu.setNavigationOnClickListener { + if (!findNavController().navigateUp()) { + requireActivity().finish() + } } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt index fa042313..9a5a468a 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/SelectCafeMenuFragment.kt @@ -15,11 +15,10 @@ import android.os.Bundle import android.view.View import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat -import androidx.fragment.app.viewModels +import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch -import timber.log.Timber import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment @@ -27,7 +26,7 @@ import us.wedemy.eggeum.android.domain.model.place.ProductEntity import us.wedemy.eggeum.android.updatecafe.ui.adapter.CafeMenuAdapter import us.wedemy.eggeum.android.updatecafe.databinding.FragmentSelectCafeMenuBinding import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem -import us.wedemy.eggeum.android.updatecafe.viewmodel.SelectCafeMenuViewModel +import us.wedemy.eggeum.android.updatecafe.viewmodel.ProposeCafeInfoViewModel interface EditOnClickListener { fun editBtnClickListener(cafeMenu: CafeMenuItem) @@ -43,12 +42,12 @@ class SelectCafeMenuFragment : BaseFragment() { CafeMenuAdapter( object : EditOnClickListener { override fun editBtnClickListener(cafeMenu: CafeMenuItem) { - // TODO: cafeMenu 데이터 넘겨주기 + // TODO: savedInstanceState 방법 알아보기 val action = SelectCafeMenuFragmentDirections.actionFragmentSelectCafeMenuToFragmentInputCafeMenu( CafeMenuItem( name = cafeMenu.name, price = cafeMenu.price, - ) + ), ) findNavController().safeNavigate(action) } @@ -63,7 +62,9 @@ class SelectCafeMenuFragment : BaseFragment() { override fun getViewBinding() = FragmentSelectCafeMenuBinding.inflate(layoutInflater) - private val viewModel by viewModels() + private val viewModel by activityViewModels() + + private var callCount = 0 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { initView() @@ -71,33 +72,27 @@ class SelectCafeMenuFragment : BaseFragment() { initObserver() } - override fun onStart() { - super.onStart() - // TODO: 지도에서 placdId 받아와서 인자 넣기 - viewModel.getCafeMenuList(1) - } - private fun showEditOrDeleteDialog(item: CafeMenuItem) { val dialog = AlertDialog.Builder(requireContext()) .setMessage("삭제 하시겠어요?") .setPositiveButton("삭제", object : OnClickListener { override fun onClick(p0: DialogInterface?, p1: Int) { - // TODO: 삭제 API 호출 + val newCafeMenuList = mutableListOf() val cafeMenuList = viewModel.cafeMenuList.value - val newCafeMenuList = mutableListOf() cafeMenuList.forEach { if (!(it.name == item.name && it.price == item.price)) { - newCafeMenuList.add(it.toEntity()) + newCafeMenuList.add(it) } } - viewModel.placeBody.menu?.products = newCafeMenuList + viewModel.placeBody.menu?.products = newCafeMenuList.map { it.toEntity() } val newPlaceBody = (viewModel.placeBody.menu?.products as MutableList) - val changedUiState = viewModel.initializeCafeMenuItem(products = newPlaceBody) - viewModel.updateCafeMenuList(productList = changedUiState) + val newCafeMenuItemList = viewModel.initializeCafeMenuItem(products = newPlaceBody) + viewModel.updateCafeMenuList(cafeMenuItemList = newCafeMenuItemList) } }) .setNegativeButton("취소", null) // 취소 시에는 동작 없음. .show() + // TODO: 피그마 디자인처럼 다이얼로그 디자인 변경하기 dialog.apply { getButton(DialogInterface.BUTTON_POSITIVE) .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.teal_500)) @@ -107,11 +102,17 @@ class SelectCafeMenuFragment : BaseFragment() { } private fun initView() { - with(binding) { - rvCafeMenuList.apply { - setHasFixedSize(true) - adapter = cafeMenuAdapter - } + // TODO: 지도에서 placdId 받아와서 인자 넣기 + if (callCount == 0) { + viewModel.getCafeMenuList(1) + callCount++ + } else { + viewModel.editCafeMenuItem() + } + + binding.rvCafeMenuList.apply { + setHasFixedSize(true) + adapter = cafeMenuAdapter } } @@ -134,11 +135,7 @@ class SelectCafeMenuFragment : BaseFragment() { private fun initObserver() { repeatOnStarted { launch { - viewModel.cafeMenuList.collect { cafeMenuList -> - val cafeMenu = cafeMenuList.map { it } - Timber.d("" + cafeMenu) - cafeMenuAdapter.replaceAll(cafeMenu) - } + viewModel.cafeMenuList.collect { cafeMenuAdapter.replaceAll(it) } } } } diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeActivity.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeActivity.kt index 91258f63..2a52a4d8 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeActivity.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateCafeActivity.kt @@ -7,6 +7,7 @@ package us.wedemy.eggeum.android.updatecafe.ui +import androidx.activity.viewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @@ -14,10 +15,14 @@ import us.wedemy.eggeum.android.common.ui.BaseActivity import us.wedemy.eggeum.android.navigator.MainNavigator import us.wedemy.eggeum.android.updatecafe.R import us.wedemy.eggeum.android.updatecafe.databinding.ActivityUpdateCafeBinding +import us.wedemy.eggeum.android.updatecafe.viewmodel.ProposeCafeInfoViewModel @AndroidEntryPoint class UpdateCafeActivity : BaseActivity() { override val binding by lazy { ActivityUpdateCafeBinding.inflate(layoutInflater) } + + val viewModel by viewModels() + private val navController get() = supportFragmentManager.findFragmentById(R.id.nav_host_fragment)?.findNavController() diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeInfoItem.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeInfoItem.kt new file mode 100644 index 00000000..253c845e --- /dev/null +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeInfoItem.kt @@ -0,0 +1,47 @@ + +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + +package us.wedemy.eggeum.android.updatecafe.ui.item + +import us.wedemy.eggeum.android.domain.model.place.InfoEntity + +data class CafeInfoItem( + val areaSize: String? = null, + val blogUri: String? = null, + val businessHours: List? = null, + val existsSmokingArea: Boolean? = null, + val existsWifi: Boolean? = null, + val instagramUri: String? = null, + val meetingRoomCount: Int? = null, + val mobileCharging: String? = null, + val multiSeatCount: Int? = null, + val parking: String? = null, + val phone: String? = null, + val restRoom: String? = null, + val singleSeatCount: Int? = null, + val websiteUri: String? = null, +) { + fun toEntity(): InfoEntity { + return InfoEntity( + areaSize = areaSize, + blogUri = blogUri, + businessHours = businessHours, + existsSmokingArea = existsSmokingArea, + existsWifi = existsWifi, + instagramUri = instagramUri, + meetingRoomCount = meetingRoomCount, + mobileCharging = mobileCharging, + multiSeatCount = multiSeatCount, + parking = parking, + phone = phone, + restRoom = restRoom, + singleSeatCount = singleSeatCount, + websiteUri = websiteUri, + ) + } +} diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt index 8c94ab3c..5bf5fd20 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/item/CafeMenuItem.kt @@ -16,9 +16,9 @@ import us.wedemy.eggeum.android.domain.model.place.ProductEntity data class CafeMenuItem( val name: String, val price: Int, -): Parcelable { +) : Parcelable { fun toEntity(): ProductEntity = ProductEntity( name = name, price = price, ) -} \ No newline at end of file +} diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeInfoViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeInfoViewModel.kt index b01a6239..ac455cb2 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeInfoViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeInfoViewModel.kt @@ -21,37 +21,20 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import timber.log.Timber -import us.wedemy.eggeum.android.domain.model.place.UpsertPlaceEntity +import us.wedemy.eggeum.android.domain.model.place.PlaceEntity import us.wedemy.eggeum.android.domain.usecase.GetPlaceUseCase import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase - -data class CafeInfoUiState( - val areaSize: String? = null, - val blogUri: String? = null, - val businessHours: List? = null, - val existsSmokingArea: Boolean? = null, - val existsWifi: Boolean? = null, - val instagramUri: String? = null, - val meetingRoomCount: Int? = null, - val mobileCharging: String? = null, - val multiSeatCount: Int? = null, - val parking: String? = null, - val phone: String? = null, - val restRoom: String? = null, - val singleSeatCount: Int? = null, - val websiteUri: String? = null, -) +import us.wedemy.eggeum.android.updatecafe.ui.item.CafeInfoItem @HiltViewModel class InputCafeInfoViewModel @Inject constructor( private val getPlaceUseCase: GetPlaceUseCase, private val upsertlaceBodyUseCase: UpsertlaceBodyUseCase, ) : ViewModel() { - private val _uiState = MutableStateFlow(CafeInfoUiState()) - val uiState = _uiState.asStateFlow() + private val _cafeInfo = MutableStateFlow(CafeInfoItem()) + val cafeInfo = _cafeInfo.asStateFlow() - private val _placeName = MutableStateFlow("") - val placeName = _placeName.asStateFlow() + lateinit var placeBody: PlaceEntity private val _navigateToUpsertEvent = MutableSharedFlow(0) val navigateToUpsertEvent: SharedFlow = _navigateToUpsertEvent.asSharedFlow() @@ -63,10 +46,10 @@ class InputCafeInfoViewModel @Inject constructor( val result = getPlaceUseCase(placeId) when { result.isSuccess && result.getOrNull() != null -> { - val placeBody = result.getOrNull()!! + placeBody = result.getOrNull()!! Timber.d("plcaeBody >>> $placeBody") - _uiState.update { uiState -> - uiState.copy( + _cafeInfo.update { cafeInfo -> + cafeInfo.copy( areaSize = placeBody.info?.areaSize, blogUri = placeBody.info?.blogUri, businessHours = placeBody.info?.businessHours, @@ -83,7 +66,6 @@ class InputCafeInfoViewModel @Inject constructor( websiteUri = placeBody.info?.websiteUri, ) } - _placeName.emit(placeBody.name!!) } result.isSuccess && result.getOrNull() == null -> { Timber.e("Request succeeded but data validation failed.") @@ -97,9 +79,9 @@ class InputCafeInfoViewModel @Inject constructor( } } - fun upsertPlaceBody(upsertPlaceEntity: UpsertPlaceEntity) { + fun upsertPlaceBody() { viewModelScope.launch { - val result = upsertlaceBodyUseCase(upsertPlaceEntity) + val result = upsertlaceBodyUseCase(placeBody.toUpsertPlaceEntity()) when { result.isSuccess -> { _navigateToUpsertEvent.emit(true) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeMenuViewModel.kt deleted file mode 100644 index b680ff26..00000000 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/InputCafeMenuViewModel.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Designed and developed by Wedemy 2023. - * - * Licensed under the MIT. - * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE - */ - -@file:Suppress("unused") - -package us.wedemy.eggeum.android.updatecafe.viewmodel - -import androidx.lifecycle.SavedStateHandle -import androidx.lifecycle.ViewModel -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class InputCafeMenuViewModel @Inject constructor(savedStateHandle: SavedStateHandle) : ViewModel() diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/ProposeCafeInfoViewModel.kt similarity index 71% rename from update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt rename to update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/ProposeCafeInfoViewModel.kt index 90671a3a..ae5fd5af 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/SelectCafeMenuViewModel.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/viewmodel/ProposeCafeInfoViewModel.kt @@ -27,7 +27,7 @@ import us.wedemy.eggeum.android.domain.usecase.UpsertlaceBodyUseCase import us.wedemy.eggeum.android.updatecafe.ui.item.CafeMenuItem @HiltViewModel -class SelectCafeMenuViewModel @Inject constructor( +class ProposeCafeInfoViewModel @Inject constructor( private val getPlaceUseCase: GetPlaceUseCase, private val upsertlaceBodyUseCase: UpsertlaceBodyUseCase, ) : ViewModel() { @@ -40,6 +40,13 @@ class SelectCafeMenuViewModel @Inject constructor( private val _showToastEvent = MutableSharedFlow() val showToastEvent: SharedFlow = _showToastEvent.asSharedFlow() + private val _cafeMenuItemMap = MutableStateFlow(emptyMap()) + private val cafeMenuItemMap = _cafeMenuItemMap.asStateFlow() + + fun setCafeMenuItemMap(cafeMenuItemMap: MutableMap) { + _cafeMenuItemMap.value = cafeMenuItemMap + } + fun getCafeMenuList(placeId: Int) { viewModelScope.launch { val result = getPlaceUseCase(placeId) @@ -48,8 +55,8 @@ class SelectCafeMenuViewModel @Inject constructor( placeBody = result.getOrNull()!! Timber.d("plcaeBody >>> $placeBody") placeBody.menu?.products?.let { - val productList: MutableList = initializeCafeMenuItem(products = it) - updateCafeMenuList(productList = productList) + val cafeMenuItemList: MutableList = initializeCafeMenuItem(products = it) + updateCafeMenuList(cafeMenuItemList = cafeMenuItemList) } } result.isSuccess && result.getOrNull() == null -> { @@ -72,8 +79,27 @@ class SelectCafeMenuViewModel @Inject constructor( return productList } - fun updateCafeMenuList(productList: MutableList) { - _cafeMenuList.value = productList + fun updateCafeMenuList(cafeMenuItemList: MutableList) { + _cafeMenuList.value = cafeMenuItemList + } + + fun editCafeMenuItem() { + val before = cafeMenuItemMap.value["before"] + val after = cafeMenuItemMap.value["after"] + + placeBody.menu?.products.let { productEntities -> + productEntities?.forEach { + if (it.name == before?.name && it.price == before.price) { + it.name = after?.name!! + it.price = after.price + } + } + } + + placeBody.menu?.products?.let { + val cafeMenuItemList: MutableList = initializeCafeMenuItem(products = it) + updateCafeMenuList(cafeMenuItemList = cafeMenuItemList) + } } fun updatePlaceBodyUseCase() { diff --git a/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml b/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml index 3c13b053..0e6b732f 100644 --- a/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml +++ b/update-cafe/src/main/res/layout/fragment_input_cafe_menu.xml @@ -142,7 +142,7 @@ style="@style/Widget.Eggeum.TextInputEditText.OutlinedBox" android:ellipsize="end" android:hint="@string/input_cafe_menu_price_hint" - android:inputType="text" + android:inputType="number" android:maxLines="1" /> From 4bc44412769a25edba68570bed3135f712be637a Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Sun, 17 Dec 2023 23:36:28 +0900 Subject: [PATCH 11/14] edit: manifest && style check --- app/src/main/AndroidManifest.xml | 8 ++++---- .../eggeum/android/domain/model/place/InfoEntity.kt | 2 +- .../eggeum/android/domain/model/place/PlaceEntity.kt | 2 +- update-cafe/src/main/AndroidManifest.xml | 7 +------ 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 850421e0..c3227279 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,10 +36,10 @@ android:name=".IntroActivity" android:exported="true" android:theme="@style/Theme.Eggeum.Splash"> - - - - + + + + diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt index 93b0fc9e..7e7be9f7 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/InfoEntity.kt @@ -58,4 +58,4 @@ public data class InfoEntity( ) } } -} \ No newline at end of file +} diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt index c4883da4..33b05f22 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/place/PlaceEntity.kt @@ -61,4 +61,4 @@ public data class PlaceEntity( ) } } -} \ No newline at end of file +} diff --git a/update-cafe/src/main/AndroidManifest.xml b/update-cafe/src/main/AndroidManifest.xml index 797dd979..bbf05658 100644 --- a/update-cafe/src/main/AndroidManifest.xml +++ b/update-cafe/src/main/AndroidManifest.xml @@ -11,12 +11,7 @@ android:name=".ui.UpdateCafeActivity" android:exported="true" android:theme="@style/Theme.Eggeum.UpdateCafe" - android:windowSoftInputMode="adjustPan" > - - - - - + android:windowSoftInputMode="adjustPan" /> \ No newline at end of file From 8bd073a665cecf7741407627195bbe726be86d5e Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:03:29 +0900 Subject: [PATCH 12/14] =?UTF-8?q?=EB=88=84=EB=9D=BD=EB=90=9C=20navigation?= =?UTF-8?q?=20animation=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EA=B0=9C?= =?UTF-8?q?=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../updatecafe/ui/InputCafeMenuFragment.kt | 2 ++ .../main/res/navigation/nav_update_cafe.xml | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt index 8505f467..d8d8c55a 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeMenuFragment.kt @@ -60,6 +60,7 @@ class InputCafeMenuFragment : BaseFragment() { tietInputCafeName.doAfterTextChanged { newCafeMenuName = it.toString() } + tietInputCafePrice.doAfterTextChanged { newCafeMenuPrice = it.toString() } @@ -73,6 +74,7 @@ class InputCafeMenuFragment : BaseFragment() { requireActivity().finish() } } + tbSelectInputCafeMenu.setNavigationOnClickListener { if (!findNavController().navigateUp()) { requireActivity().finish() diff --git a/update-cafe/src/main/res/navigation/nav_update_cafe.xml b/update-cafe/src/main/res/navigation/nav_update_cafe.xml index dd924420..f938cb69 100644 --- a/update-cafe/src/main/res/navigation/nav_update_cafe.xml +++ b/update-cafe/src/main/res/navigation/nav_update_cafe.xml @@ -72,6 +72,7 @@ android:name="us.wedemy.eggeum.android.updatecafe.ui.SelectInfoCategoriesFragment" android:label="SelectInfoCategoriesFragment" tools:layout="@layout/fragment_select_info_categories"> + + + + @@ -100,12 +104,23 @@ + + app:destination="@id/fragment_update_menu_complete" + app:enterAnim="@anim/nav_default_enter_anim" + app:exitAnim="@anim/nav_default_exit_anim" + app:popEnterAnim="@anim/nav_default_pop_enter_anim" + app:popExitAnim="@anim/nav_default_pop_exit_anim"/> + + app:destination="@id/fragment_input_cafe_menu" + app:enterAnim="@anim/nav_default_enter_anim" + app:exitAnim="@anim/nav_default_exit_anim" + app:popEnterAnim="@anim/nav_default_pop_enter_anim" + app:popExitAnim="@anim/nav_default_pop_exit_anim"/> + + + + + \ No newline at end of file From 1abef05fb7a51fe534dda04b49bf6846cb5deda8 Mon Sep 17 00:00:00 2001 From: kymjaehong Date: Mon, 18 Dec 2023 21:59:37 +0900 Subject: [PATCH 13/14] =?UTF-8?q?Edit:=20=ED=94=BC=EB=93=9C=EB=B0=B1=20?= =?UTF-8?q?=EC=9D=BC=EB=B6=80=20=EB=B0=98=EC=98=81=20#147?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/updatecafe/ui/InputCafeInfoFragment.kt | 4 ++-- .../updatecafe/ui/UpdateMenuCompleteFragment.kt | 6 ++++++ .../viewmodel/ProposeCafeInfoViewModel.kt | 1 - .../src/main/res/navigation/nav_update_cafe.xml | 6 +++++- update-cafe/src/main/res/values/strings.xml | 13 +++++++------ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt index b6b32a68..21a28327 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/InputCafeInfoFragment.kt @@ -46,7 +46,7 @@ class InputCafeInfoFragment : BaseFragment() { private var cafePhone = "" private var cafeName: String = "" - private val guideMessage = "정보를 입력해주세요!" + private val guideMessage = "정보를 입력해주세요!" // resources.getString(R.string.guide_message) // 에러발생 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { initView() @@ -155,7 +155,7 @@ class InputCafeInfoFragment : BaseFragment() { repeatOnStarted { launch { viewModel.cafeInfo.collect { cafeInfo -> - with(binding) { + binding.apply { tietInputCafeArea.hint = stringOrElseGuideMessage(cafeInfo.areaSize) tietInputCafeMeetingRoom.hint = intToStringOrElseGuideMessage(cafeInfo.meetingRoomCount) tietInputCafeMultiSeat.hint = intToStringOrElseGuideMessage(cafeInfo.multiSeatCount) diff --git a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateMenuCompleteFragment.kt b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateMenuCompleteFragment.kt index ea5d7dec..56eb6395 100644 --- a/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateMenuCompleteFragment.kt +++ b/update-cafe/src/main/kotlin/us/wedemy/eggeum/android/updatecafe/ui/UpdateMenuCompleteFragment.kt @@ -11,7 +11,9 @@ package us.wedemy.eggeum.android.updatecafe.ui import android.os.Bundle import android.view.View +import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint +import us.wedemy.eggeum.android.common.extension.safeNavigate import us.wedemy.eggeum.android.common.ui.BaseFragment import us.wedemy.eggeum.android.updatecafe.databinding.FragmentUpdateMenuCompleteBinding @@ -26,6 +28,10 @@ class UpdateMenuCompleteFragment : BaseFragment { placeBody = result.getOrNull()!! - Timber.d("plcaeBody >>> $placeBody") placeBody.menu?.products?.let { val cafeMenuItemList: MutableList = initializeCafeMenuItem(products = it) updateCafeMenuList(cafeMenuItemList = cafeMenuItemList) diff --git a/update-cafe/src/main/res/navigation/nav_update_cafe.xml b/update-cafe/src/main/res/navigation/nav_update_cafe.xml index dd924420..74ef7660 100644 --- a/update-cafe/src/main/res/navigation/nav_update_cafe.xml +++ b/update-cafe/src/main/res/navigation/nav_update_cafe.xml @@ -122,7 +122,11 @@ android:id="@+id/fragment_update_menu_complete" android:name="us.wedemy.eggeum.android.updatecafe.ui.UpdateMenuCompleteFragment" android:label="UpdateMenuCompleteFragment" - tools:layout="@layout/fragment_update_menu_complete" /> + tools:layout="@layout/fragment_update_menu_complete" > + + 완료 수정하려는 내용을 입력해주세요. 30m - 면적 - 회의실 - 다인석 - 1인석 + 면적(㎡) + 회의실(개) + 다인석(개) + 1인석(개) 영업시간 - 주차 + 주차(O/X) 흡연 - 와이파이 + 와이파이(O/X) 화장실 모바일 충전 인스타그램 @@ -62,4 +62,5 @@ ic_menu_gray400_24 ic_edit_outlined_20 ic_trash_20 + 정보를 입력해주세요! \ No newline at end of file From 1d4f0ecd74e0a894ed25799896d40898f25a5abe Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Tue, 19 Dec 2023 07:17:35 +0900 Subject: [PATCH 14/14] =?UTF-8?q?Edit:=20=EB=A9=94=EB=89=B4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=99=84=EB=A3=8C=20=ED=99=94=EB=A9=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=A0=9C?= =?UTF-8?q?=EC=95=88=20=ED=99=94=EB=A9=B4=EC=9C=BC=EB=A1=9C=20=EB=8F=8C?= =?UTF-8?q?=EC=95=84=EA=B0=80=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=EC=97=90=20=EC=8C=93=EC=97=AC=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=B0=B1=EC=8A=A4=ED=83=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 시스템 백버튼을 눌렀을 때 다시 이전에 수정하는 화면으로 이동되지 않도록 --- app/src/main/AndroidManifest.xml | 18 +++++++++-- .../main/res/navigation/nav_update_cafe.xml | 30 ++++++++++++------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3227279..e90d598d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,14 +32,28 @@ + + + + + + + + + + + + + android:theme="@style/Theme.Eggeum.UpdateCafe"> + + diff --git a/update-cafe/src/main/res/navigation/nav_update_cafe.xml b/update-cafe/src/main/res/navigation/nav_update_cafe.xml index 9a4f46bb..6bc53f6e 100644 --- a/update-cafe/src/main/res/navigation/nav_update_cafe.xml +++ b/update-cafe/src/main/res/navigation/nav_update_cafe.xml @@ -97,13 +97,13 @@ android:label="SelectCafeMenuFragment" tools:layout="@layout/fragment_select_cafe_menu"> - - - - - - - + + + + + + + + app:popExitAnim="@anim/nav_default_pop_exit_anim" /> + app:popExitAnim="@anim/nav_default_pop_exit_anim" /> @@ -139,10 +139,18 @@ android:id="@+id/fragment_update_menu_complete" android:name="us.wedemy.eggeum.android.updatecafe.ui.UpdateMenuCompleteFragment" android:label="UpdateMenuCompleteFragment" - tools:layout="@layout/fragment_update_menu_complete" > + tools:layout="@layout/fragment_update_menu_complete"> + + app:destination="@id/fragment_select_info_categories" + app:enterAnim="@anim/nav_default_enter_anim" + app:exitAnim="@anim/nav_default_exit_anim" + app:popEnterAnim="@anim/nav_default_pop_enter_anim" + app:popExitAnim="@anim/nav_default_pop_exit_anim" + app:popUpTo="@id/fragment_select_info_categories" + app:popUpToInclusive="true" /> +