Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

가게 등록 기능 마무리 #300

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -13,9 +12,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Text
Expand All @@ -24,12 +21,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -57,9 +51,10 @@ fun FinalCheckStoreScreen(

FinalCheckStoreScreenImpl(
state = state,
goToFinishScreen = {
navigateToFinishScreen = {
viewModel.registerStore()
}
},
onBackPressed = onBackPressed
)

HandleSideEffects(viewModel, navigateToFinishScreen)
Expand All @@ -69,7 +64,7 @@ fun FinalCheckStoreScreen(
@Composable
fun FinalCheckStoreScreenImpl(
modifier: Modifier = Modifier,
goToFinishScreen: () -> Unit = {},
navigateToFinishScreen: () -> Unit = {},
onBackPressed: () -> Unit = {},
state: FinalCheckStoreScreenState = FinalCheckStoreScreenState()
) {
Expand Down Expand Up @@ -125,7 +120,7 @@ fun FinalCheckStoreScreenImpl(
item {
NameTextField(
textString = stringResource(id = R.string.category),
outputString = state.storeCategory.toString(),
outputString = state.storeCategoryString,
paddingTopValue = 32.dp
)
}
Expand Down Expand Up @@ -235,7 +230,7 @@ fun FinalCheckStoreScreenImpl(

item {
Button(
onClick = goToFinishScreen,
onClick = navigateToFinishScreen,
colors = ButtonDefaults.buttonColors(ColorPrimary),
shape = RectangleShape,
modifier = Modifier
Expand Down Expand Up @@ -312,8 +307,7 @@ private fun HandleSideEffects(viewModel: FinalCheckStoreScreenViewModel, navigat
viewModel.collectSideEffect { sideEffect ->
when (sideEffect) {
is FinalCheckStoreScreenSideEffect.GoToFinishScreen -> navigateToFinishScreen()
is FinalCheckStoreScreenSideEffect.GoToFinishScreen -> ToastUtil.getInstance().makeShort(R.string.insert_store_null_store_phone_number)
else -> {}
is FinalCheckStoreScreenSideEffect.FailRegisterStore -> ToastUtil.getInstance().makeShort(R.string.insert_store_fail_register_store)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package `in`.koreatech.business.feature.insertstore.finalcheckstore

import `in`.koreatech.business.feature.insertstore.selectcategory.SelectCategoryScreenSideEffect

sealed class FinalCheckStoreScreenSideEffect {
object GoToFinishScreen: FinalCheckStoreScreenSideEffect()
object FailRegisterStore: FinalCheckStoreScreenSideEffect()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package `in`.koreatech.business.feature.insertstore.finalcheckstore

import android.net.Uri
import android.os.Parcelable
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.operatingTime.OperatingTimeState
import kotlinx.parcelize.Parcelize
Expand All @@ -9,6 +8,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class FinalCheckStoreScreenState(
val storeCategory: Int = -1,
val storeCategoryString: String ="",
val storeName: String = "",
val storeAddress: String = "",
val storeImage: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.chargemap.compose.numberpicker.Hours
import dagger.hilt.android.lifecycle.HiltViewModel
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreenState
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.operatingTime.OperatingTimeState
import `in`.koreatech.koin.domain.model.owner.insertstore.OperatingTime
import `in`.koreatech.koin.domain.model.store.StoreCategories
import `in`.koreatech.koin.domain.usecase.business.store.RegisterStoreUseCase
import `in`.koreatech.koin.domain.usecase.store.GetStoreCategoriesUseCase
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch
Expand All @@ -24,7 +25,8 @@ import javax.inject.Inject
@HiltViewModel
class FinalCheckStoreScreenViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val registerStoreUseCase : RegisterStoreUseCase
private val registerStoreUseCase : RegisterStoreUseCase,
private val getStoreCategoriesUseCase: GetStoreCategoriesUseCase
): ViewModel(), ContainerHost<FinalCheckStoreScreenState, FinalCheckStoreScreenSideEffect> {
override val container: Container<FinalCheckStoreScreenState, FinalCheckStoreScreenSideEffect> =
container(FinalCheckStoreScreenState(), savedStateHandle = savedStateHandle) {
Expand Down Expand Up @@ -63,6 +65,7 @@ class FinalCheckStoreScreenViewModel @Inject constructor(
operatingTimeList = storeInfo.operatingTimeList
)
}
getCategory()
}
}

Expand Down Expand Up @@ -92,6 +95,19 @@ class FinalCheckStoreScreenViewModel @Inject constructor(
}
}

private fun getCategory() {
intent {
viewModelScope.launch {
val categories = getStoreCategoriesUseCase()
reduce {
state.copy(
storeCategoryString = categories[state.storeCategory - 1].name
)
}
}
}
}

fun registerStore() {
intent {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package `in`.koreatech.business.feature.insertstore.finishregisterstore

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import `in`.koreatech.koin.core.R
import `in`.koreatech.business.ui.theme.Blue1
import `in`.koreatech.business.ui.theme.ColorPrimary

@Composable
fun FinishRegisterScreen(
modifier: Modifier = Modifier,
goToMainScreen: () -> Unit,
onBackPressed: () -> Unit
) {
Column(
modifier = modifier.fillMaxSize()
) {
Box(
modifier = modifier
.padding(top = 56.dp, start = 10.dp , bottom = 18.dp)
.width(40.dp)
.height(40.dp)
.clickable { onBackPressed }

) {
Image(
painter = painterResource(R.drawable.ic_arrow_left),
contentDescription = "backArrow",
modifier = modifier
.width(40.dp)
.height(40.dp)
.clickable { }
)
}

Image(
painter = painterResource(id = R.drawable.ic_finish_check),
contentDescription = "finish_mark",
alignment = Alignment.Center,
modifier = modifier
.fillMaxWidth()
.padding(top = 103.dp, bottom = 30.dp)
.height(55.dp)
.width(55.dp)
)

Text(
text = stringResource(R.string.insert_store_finish),
fontSize = 24.sp,
color = ColorPrimary,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 46.dp)
.padding(bottom = 16.dp)
)

Text(
text = stringResource(R.string.insert_store_finish_guide),
fontSize = 16.sp,
color = Blue1,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 46.dp)
.padding(bottom = 51.dp)
)

Button(
onClick = goToMainScreen,
colors = ButtonDefaults.buttonColors(ColorPrimary),
shape = RectangleShape,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 33.dp)
.height(44.dp)
) {
Text(
text = stringResource(id = R.string.go_to_main_screen),
fontSize = 15.sp,
fontWeight = FontWeight.Bold,
color = Color.White
)
}
}
}


@Preview
@Composable
fun PreviewStartInsertScreen(){
FinishRegisterScreen(
modifier = Modifier,
goToMainScreen = {} ,
onBackPressed = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import `in`.koreatech.business.feature.insertstore.finalcheckstore.FinalCheckStoreScreen
import `in`.koreatech.business.feature.insertstore.finalcheckstore.FinalCheckStoreScreenImpl
import `in`.koreatech.business.feature.insertstore.finishregisterstore.FinishRegisterScreen
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreen
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreenState
import `in`.koreatech.business.feature.insertstore.insertdetailinfo.InsertDetailInfoScreenViewModel
Expand Down Expand Up @@ -131,7 +132,22 @@ fun InsertStoreNavigator(
onBackPressed = {
navController.navigateUp()
},
navigateToFinishScreen = {}
navigateToFinishScreen = {
navController.navigate(InsertStoreRoute.FINISH_SCREEN.name)
}
)
}

composable(
route = InsertStoreRoute.FINISH_SCREEN.name,
) {
FinishRegisterScreen(
goToMainScreen = {

},
onBackPressed = {
navController.navigateUp()
}
)
}
}
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/res/drawable/ic_finish_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="55dp"
android:height="55dp"
android:viewportWidth="55"
android:viewportHeight="55">
<path
android:pathData="M27.5,27.5m-26,0a26,26 0,1 1,52 0a26,26 0,1 1,-52 0"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#F7941E"/>
<path
android:pathData="M14.781,26.813L23.719,35.75L40.219,19.25"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#F7941E"
android:strokeLineCap="round"/>
</vector>
5 changes: 5 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="day_off">휴일</string>
<string name="store_open_time">개점시간</string>
<string name="store_close_time">폐점시간</string>
<string name="go_to_main_screen">메인 화면 바로가기</string>

<!--left drawer menu -->
<string name="home">홈</string>
Expand Down Expand Up @@ -126,4 +127,8 @@

<string name="insert_store_check_store_info">4. 가게 정보 확인</string>
<string name="insert_store_check_info">입력하신 정보가 맞습니까?</string>
<string name="insert_store_fail_register_store">가게를 등록하는데 실패하였습니다.</string>

<string name="insert_store_finish">가게 등록 완료</string>
<string name="insert_store_finish_guide">가게 등록이 완료되었습니다.\n업체 정보 수정은 내 상점에서 가능합니다.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UploadImageLocalDataSource @Inject constructor(
ExifInterface.ORIENTATION_ROTATE_90 -> bitmap?.rotateBitmap(90f)
ExifInterface.ORIENTATION_ROTATE_180 -> bitmap?.rotateBitmap(180f)
ExifInterface.ORIENTATION_ROTATE_270 -> bitmap?.rotateBitmap(270f)
else -> bitmap?.rotateBitmap(90f)
else -> bitmap
}
if(rotatedBitmap != null){
imageBitmap = rotatedBitmap
Expand Down