From 2af96ffed4ff87a199da1109cd30d64334d4f873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:41:02 +0900 Subject: [PATCH 01/15] :memo: :: Add formateLongStockPrice To formatStockPrice Package --- .../java/com/jusiCool/presentation/utill/formatStockPrice.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt b/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt index ee239502..ea2bbd8f 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt @@ -2,4 +2,6 @@ package com.jusiCool.presentation.utill fun Int.formatStockPrice(): String = "%,d".format(this) -fun String.formatStockPrice(): String = this.toInt().formatStockPrice() \ No newline at end of file +fun String.formatStockPrice(): String = this.toInt().formatStockPrice() + +fun Long.formatLongStockPrice(): String = "%,d".format(this) \ No newline at end of file From 98df172a7a2b3445692d62964effabb1f602348e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:41:43 +0900 Subject: [PATCH 02/15] :memo: :: Add .gitkeep File --- .../java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep new file mode 100644 index 00000000..e69de29b From ea403a66e276b9100608d3051a5010dfb899caa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:42:05 +0900 Subject: [PATCH 03/15] :sparkles: :: Create StockBuyScreen --- .../stockBuy/screen/StockBuyScreen.kt | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt new file mode 100644 index 00000000..1642cc10 --- /dev/null +++ b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt @@ -0,0 +1,162 @@ +package com.jusiCool.presentation.stockBuy.screen + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import com.example.design_system.component.button.ButtonState +import com.example.design_system.component.button.JDSButton +import com.example.design_system.component.modifier.clickableSingle.clickableSingle +import com.example.design_system.component.textfield.JDSTextField +import com.example.design_system.component.topbar.JDSArrowTopBar +import com.example.design_system.icon_image.icon.LeftArrowIcon +import com.example.design_system.icon_image.icon.RightArrowIcon +import com.example.design_system.icon_image.image.CostImage +import com.example.design_system.theme.JDSTypography +import com.example.design_system.theme.color.JDSColor +import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData +import com.jusiCool.presentation.main.component.MyAccountData +import com.jusiCool.presentation.main.screen.tempMyAccountData +import com.jusiCool.presentation.utill.formatStockPrice + +const val stockBuyingRoute = "stockBuyingRoute" + +fun NavController.navigationToStockBuying() { + this.navigate(stockBuyingRoute) +} + +fun NavGraphBuilder.stockBuyingRoute( + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, +) { + composable(stockBuyingRoute) { + StockBuyingRoute( + navigateToStockDetail = navigateToStockDetail, + navigateToOrderHistory = navigateToOrderHistory + ) + } +} + +@Composable +fun StockBuyingRoute( + modifier: Modifier = Modifier, + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, +) { + StockBuyingScreen( + modifier = modifier, + myAccountData = tempMyAccountData, + entireStocksData = EntireStocksData(0, "", 10000, 8160, 0,7.9f), + navigateToStockDetail = navigateToStockDetail, + navigateToOrderHistory = navigateToOrderHistory + ) +} + +@Composable +internal fun StockBuyingScreen( + modifier: Modifier = Modifier, + myAccountData: MyAccountData, + entireStocksData: EntireStocksData, + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, +) { + val (stockTextState, setStockTextState) = remember { mutableStateOf("") } + val (isBuyingSuccessful, setIsBuyingSuccessful) = remember { mutableStateOf(false) } + + Column( + modifier = modifier + .fillMaxSize() + .background(color = JDSColor.WHITE), + horizontalAlignment = Alignment.CenterHorizontally + ) { + JDSArrowTopBar( + startIcon = { LeftArrowIcon(modifier = Modifier.clickableSingle { navigateToStockDetail() }) }, + betweenText = "주식 구매" + ) + + if (!isBuyingSuccessful) { + Spacer(modifier = Modifier.height(40.dp)) + + JDSTextField( + modifier = Modifier.padding(horizontal = 24.dp), + textState = stockTextState, + placeHolder = "최대 N주 구매 가능", + label = "몇 주 구매할까요?", + helperText = "보유 포인트 ${myAccountData.point.formatStockPrice()} P", + placerHolderShare = true, + onTextChange = setStockTextState + ) + + Spacer(modifier = Modifier.weight(1f)) + + JDSButton( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp, vertical = 32.dp), + state = if (stockTextState.isEmpty()) ButtonState.Disable else ButtonState.Enable, + text = "구매 하기", + onClick = { setIsBuyingSuccessful(true) } + ) + } else { + Column( + modifier = modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Spacer(modifier = Modifier.height(120.dp)) + + CostImage(modifier = Modifier.size(177.dp)) + + Text( + text = "${entireStocksData.stockName} ${stockTextState.formatStockPrice()}주\n" + + " ${(stockTextState.toInt() * entireStocksData.myStockPrice).formatStockPrice()}P 구매 성공", + style = JDSTypography.subTitle, + color = JDSColor.Black + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Row( + modifier = Modifier.clickableSingle { navigateToOrderHistory() }, + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = "구매 내역 보러가기", + style = JDSTypography.label, + color = JDSColor.GRAY600 + ) + + RightArrowIcon() + } + } + } + } +} + +@Preview +@Composable +fun StockBuyingScreenPreview() { + StockBuyingScreen( + myAccountData = tempMyAccountData, + entireStocksData = EntireStocksData(0, "", 10000, 8160, 0,7.9f), + navigateToStockDetail = {}, + navigateToOrderHistory = {} + ) +} \ No newline at end of file From 2af4f2f3ae34dc8180490836ed3c2af441b94f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:43:25 +0900 Subject: [PATCH 04/15] :sparkles: :: Create StockReservationBuyScreen --- .../screen/StockReservationBuyScreen.kt | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt new file mode 100644 index 00000000..0592908e --- /dev/null +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -0,0 +1,258 @@ +package com.jusiCool.presentation.stockReservationBuy.screen + +import androidx.activity.ComponentActivity +import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.mutableLongStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusManager +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import com.example.design_system.component.button.ButtonState +import com.example.design_system.component.button.JDSButton +import com.example.design_system.component.modifier.clickableSingle.clickableSingle +import com.example.design_system.component.textfield.JDSTextField +import com.example.design_system.component.topbar.JDSArrowTopBar +import com.example.design_system.icon_image.icon.LeftArrowIcon +import com.example.design_system.icon_image.icon.RightArrowIcon +import com.example.design_system.icon_image.image.CostImage +import com.example.design_system.theme.JDSTypography +import com.example.design_system.theme.JusiCoolAndroidTheme +import com.example.design_system.theme.color.JDSColor +import com.jusiCool.domain.model.stock.request.BuyStockRequestModel +import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData +import com.jusiCool.presentation.main.component.MyAccountData +import com.jusiCool.presentation.main.screen.tempMyAccountData +import com.jusiCool.presentation.stockReservationBuy.viewmodel.StockReservationBuyViewModel +import com.jusiCool.presentation.utill.formatLongStockPrice +import com.jusiCool.presentation.utill.formatStockPrice + +const val stockReservationBuyingRoute = "stockReservationBuyingRoute" + +fun NavController.navigationToStockReservationBuying(stockId: Long) { + this.navigate("$stockReservationBuyingRoute/$stockId") +} + +fun NavGraphBuilder.stockReservationBuyingRoute( + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, +) { + composable("$stockReservationBuyingRoute}/{id}") { backStackEntry -> + val id = backStackEntry.arguments?.getString("id")?.toLongOrNull() + if(id != null) { + StockReservationBuyingRoute( + id = id, + navigateToStockDetail = navigateToStockDetail, + navigateToOrderHistory = navigateToOrderHistory + ) + } + } +} + +@Composable +internal fun StockReservationBuyingRoute( + modifier: Modifier = Modifier, + viewModel: StockReservationBuyViewModel = hiltViewModel(LocalContext.current as ComponentActivity), + id: Long, + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, +) { + val focusManager = LocalFocusManager.current + + StockReservationBuyingScreen( + modifier = modifier, + id = id, + myAccountData = tempMyAccountData, + entireStocksData = EntireStocksData(0, "", 10000, 8160, 6, 4.9f), + navigateToStockDetail = navigateToStockDetail, + navigateToOrderHistory = navigateToOrderHistory, + focusManager = focusManager, + postStock = viewModel.postStock.longValue, + postReserveStock = viewModel.postReserveStock.longValue, + postBuyStock = {num, goal_price -> + viewModel.postBuyStock( + stockId = id, + num = num, + goal_price = goal_price + ) + viewModel.postStock.longValue = 0 + viewModel.postReserveStock.longValue = 0 + } + ) +} + +@Composable +internal fun StockReservationBuyingScreen( + modifier: Modifier = Modifier, + id: Long, + myAccountData: MyAccountData, + entireStocksData: EntireStocksData, + postBuyStock: (num: Long, goal_price: Long) -> Unit, + navigateToStockDetail: () -> Unit, + navigateToOrderHistory: () -> Unit, + focusManager: FocusManager, + postStock: Long, + postReserveStock: Long +) { + val (stockReservationTextState, setStockReservationTextState) = remember { mutableLongStateOf(postStock) } + val (stockTextState, setStockTextState) = remember { mutableLongStateOf(postReserveStock) } + val (pager, setPager) = remember { mutableStateOf(1) } + + CompositionLocalProvider(LocalFocusManager provides focusManager) { + JusiCoolAndroidTheme { colors, _ -> + Column( + modifier = modifier + .fillMaxSize() + .background(color = colors.WHITE) + .pointerInput(Unit) { + detectTapGestures { + focusManager.clearFocus() + } + }, + horizontalAlignment = Alignment.CenterHorizontally + ) { + JDSArrowTopBar( + startIcon = { + LeftArrowIcon(modifier = Modifier.clickableSingle { + if (pager == 2) setPager(1) + else navigateToStockDetail() + }) + }, + betweenText = "주식 구매" + ) + + when (pager) { + 1 -> { + Spacer(modifier = Modifier.height(40.dp)) + + JDSTextField( + modifier = Modifier.padding(horizontal = 24.dp), + textState = stockReservationTextState.toString(), + placeHolder = "예약 금액을 달성했을 때 주식을 구매해요", + label = "예약 금액을 입력하세요", + helperText = "지금 주식 가격: ${entireStocksData.myStockPrice.formatStockPrice()} P", + onTextChange = { setStockReservationTextState(it.toLongOrNull() ?: 0) } + ) + + Spacer(modifier = Modifier.weight(1f)) + + JDSButton( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp, vertical = 32.dp), + state = if (stockReservationTextState == 0L) ButtonState.Disable else ButtonState.Enable, + text = "다음", + onClick = { setPager(2) } + ) + } + + 2 -> { + Spacer(modifier = Modifier.height(40.dp)) + + JDSTextField( + modifier = Modifier.padding(horizontal = 24.dp), + textState = stockTextState.toString(), + placeHolder = "최대 N주 구매 가능", + label = "몇 주 구매할까요?", + helperText = "보유 포인트 ${myAccountData.point.formatStockPrice()} P", + placerHolderShare = true, + onTextChange = { setStockTextState(it.toLongOrNull() ?: 0) } + ) + + Spacer(modifier = Modifier.weight(1f)) + + JDSButton( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp, vertical = 32.dp), + state = if (stockTextState == 0L) ButtonState.Disable else ButtonState.Enable, + text = "구매 하기", + onClick = { + postBuyStock( + stockTextState, + stockReservationTextState + ) + setPager(3) + } + ) + } + + 3 -> { + Column( + modifier = modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Spacer(modifier = Modifier.height(120.dp)) + + CostImage(modifier = Modifier.size(177.dp)) + + Text( + text = "${entireStocksData.stockName} ${stockTextState.formatLongStockPrice()}주\n" + + "${(stockTextState.toInt() * stockReservationTextState.toInt()).formatStockPrice()}P 구매 예약 성공", + style = JDSTypography.subTitle, + color = JDSColor.Black, + textAlign = TextAlign.Center + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Row( + modifier = Modifier.clickableSingle { navigateToOrderHistory() }, + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = "구매 내역 보러가기", + style = JDSTypography.label, + color = JDSColor.GRAY600 + ) + + RightArrowIcon() + } + } + } + } + } + } + } +} + + +@Preview +@Composable +fun StockReservationBuyingScreenPreview() { + StockReservationBuyingScreen( + id = 0, + myAccountData = tempMyAccountData, + entireStocksData = EntireStocksData(0, "", 10000, 8160, 23, 9.3f), + navigateToStockDetail = {}, + navigateToOrderHistory = {}, + focusManager = LocalFocusManager.current, + postStock = 0, + postReserveStock = 0, + postBuyStock = {_, _ ->} + ) +} \ No newline at end of file From f4c0618c98fc0bd872a8557f665fd1b587280ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:44:53 +0900 Subject: [PATCH 05/15] :truck: :: Changed Package Naming --- .../stockReservationBuy/screen/StockReservationBuyScreen.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index 0592908e..d5aca4ad 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -42,7 +42,6 @@ import com.example.design_system.icon_image.image.CostImage import com.example.design_system.theme.JDSTypography import com.example.design_system.theme.JusiCoolAndroidTheme import com.example.design_system.theme.color.JDSColor -import com.jusiCool.domain.model.stock.request.BuyStockRequestModel import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData import com.jusiCool.presentation.main.component.MyAccountData import com.jusiCool.presentation.main.screen.tempMyAccountData From c87ed55f43dbcbb05ffbd22062d374c8c663ac5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:45:20 +0900 Subject: [PATCH 06/15] :sparkles: :: Create StockReservationBuyViewModel --- .../viewmodel/StockReservationBuyViewModel.kt | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt new file mode 100644 index 00000000..77d7ed07 --- /dev/null +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt @@ -0,0 +1,53 @@ +package com.jusiCool.presentation.stockReservationBuy.viewmodel + +import androidx.compose.runtime.mutableLongStateOf +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.jusiCool.domain.model.stock.request.BuyStockRequestModel +import com.jusiCool.domain.usecase.stock.BuyStockReserveUseCase +import com.jusiCool.domain.usecase.stock.BuyStockUseCase +import com.jusiCool.presentation.utill.Event +import com.jusiCool.presentation.utill.errorHandling +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class StockReservationBuyViewModel @Inject constructor( + private val buyStockReserveUseCase: BuyStockReserveUseCase +) : ViewModel() { + + private val _buyStockReserveResponse = MutableStateFlow>(Event.Loading) + val buyStockReserveResponse = _buyStockReserveResponse.asStateFlow() + + var postStock = mutableLongStateOf(0) + private set + + var postReserveStock = mutableLongStateOf(0) + private set + + fun postBuyStock( + stockId: Long, + num: Long, + goal_price: Long, + ) = viewModelScope.launch { + buyStockReserveUseCase( + stockId = stockId, + body = BuyStockRequestModel( + num = num, + goal_price = goal_price + ) + ).onSuccess { + it.catch { remoteError -> + _buyStockReserveResponse.value = remoteError.errorHandling() + }.collect { + _buyStockReserveResponse.value = Event.Success() + } + }.onFailure { error -> + _buyStockReserveResponse.value = error.errorHandling() + } + } +} \ No newline at end of file From 88f4f2bbd28938d66249c3654199edad6b609fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 13:46:16 +0900 Subject: [PATCH 07/15] :fire: :: Fire Unused Import And Fix Typo Error --- .../stockReservationBuy/screen/StockReservationBuyScreen.kt | 2 +- .../viewmodel/StockReservationBuyViewModel.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index d5aca4ad..692f927d 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -1,6 +1,6 @@ package com.jusiCool.presentation.stockReservationBuy.screen -import androidx.activity.ComponentActivity +import androidx.activity.ComponentActivity import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt index 77d7ed07..83cb2383 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt @@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.jusiCool.domain.model.stock.request.BuyStockRequestModel import com.jusiCool.domain.usecase.stock.BuyStockReserveUseCase -import com.jusiCool.domain.usecase.stock.BuyStockUseCase import com.jusiCool.presentation.utill.Event import com.jusiCool.presentation.utill.errorHandling import dagger.hilt.android.lifecycle.HiltViewModel From 103acc06be988fef151c4f67e6ecc2f0312fa06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Fri, 12 Jul 2024 14:33:44 +0900 Subject: [PATCH 08/15] :truck: :: File And Package Changed --- .../JusiCool_Android_NavHost.kt | 2 +- .../stockBuy/screen/StockBuyScreen.kt | 162 ------------------ .../screen/StockBuyingScreen.kt | 2 +- .../presentation/stockBuy/viewModel/.gitkeep | 0 .../stockBuying/viewModel/.gitkeep | 0 5 files changed, 2 insertions(+), 164 deletions(-) delete mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt rename presentation/src/main/java/com/jusiCool/presentation/{stockBuying => stockBuy}/screen/StockBuyingScreen.kt (99%) delete mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep delete mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockBuying/viewModel/.gitkeep diff --git a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt index a0de53fb..fab9de71 100644 --- a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt +++ b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt @@ -35,7 +35,7 @@ import com.jusiCool.presentation.search.screen.searchRoute import com.jusiCool.presentation.splash.screen.splashRoute import com.jusiCool.presentation.stockDetail.screen.navigateToStockDetail import com.jusiCool.presentation.stockDetail.screen.stockDetailRoute -import com.jusiCool.presentation.stockBuying.screen.stockBuyingRoute +import com.jusiCool.presentation.stockBuy.screen.stockBuyingRoute import com.jusiCool.presentation.stockReservationBuying.screen.stockReservationBuyingRoute import com.jusiCool.presentation.stockReservationSelling.screen.stockReservationSellingRoute import com.jusiCool.presentation.stockSelling.screen.stockSellingRoute diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt deleted file mode 100644 index 1642cc10..00000000 --- a/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyScreen.kt +++ /dev/null @@ -1,162 +0,0 @@ -package com.jusiCool.presentation.stockBuy.screen - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import com.example.design_system.component.button.ButtonState -import com.example.design_system.component.button.JDSButton -import com.example.design_system.component.modifier.clickableSingle.clickableSingle -import com.example.design_system.component.textfield.JDSTextField -import com.example.design_system.component.topbar.JDSArrowTopBar -import com.example.design_system.icon_image.icon.LeftArrowIcon -import com.example.design_system.icon_image.icon.RightArrowIcon -import com.example.design_system.icon_image.image.CostImage -import com.example.design_system.theme.JDSTypography -import com.example.design_system.theme.color.JDSColor -import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData -import com.jusiCool.presentation.main.component.MyAccountData -import com.jusiCool.presentation.main.screen.tempMyAccountData -import com.jusiCool.presentation.utill.formatStockPrice - -const val stockBuyingRoute = "stockBuyingRoute" - -fun NavController.navigationToStockBuying() { - this.navigate(stockBuyingRoute) -} - -fun NavGraphBuilder.stockBuyingRoute( - navigateToStockDetail: () -> Unit, - navigateToOrderHistory: () -> Unit, -) { - composable(stockBuyingRoute) { - StockBuyingRoute( - navigateToStockDetail = navigateToStockDetail, - navigateToOrderHistory = navigateToOrderHistory - ) - } -} - -@Composable -fun StockBuyingRoute( - modifier: Modifier = Modifier, - navigateToStockDetail: () -> Unit, - navigateToOrderHistory: () -> Unit, -) { - StockBuyingScreen( - modifier = modifier, - myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(0, "", 10000, 8160, 0,7.9f), - navigateToStockDetail = navigateToStockDetail, - navigateToOrderHistory = navigateToOrderHistory - ) -} - -@Composable -internal fun StockBuyingScreen( - modifier: Modifier = Modifier, - myAccountData: MyAccountData, - entireStocksData: EntireStocksData, - navigateToStockDetail: () -> Unit, - navigateToOrderHistory: () -> Unit, -) { - val (stockTextState, setStockTextState) = remember { mutableStateOf("") } - val (isBuyingSuccessful, setIsBuyingSuccessful) = remember { mutableStateOf(false) } - - Column( - modifier = modifier - .fillMaxSize() - .background(color = JDSColor.WHITE), - horizontalAlignment = Alignment.CenterHorizontally - ) { - JDSArrowTopBar( - startIcon = { LeftArrowIcon(modifier = Modifier.clickableSingle { navigateToStockDetail() }) }, - betweenText = "주식 구매" - ) - - if (!isBuyingSuccessful) { - Spacer(modifier = Modifier.height(40.dp)) - - JDSTextField( - modifier = Modifier.padding(horizontal = 24.dp), - textState = stockTextState, - placeHolder = "최대 N주 구매 가능", - label = "몇 주 구매할까요?", - helperText = "보유 포인트 ${myAccountData.point.formatStockPrice()} P", - placerHolderShare = true, - onTextChange = setStockTextState - ) - - Spacer(modifier = Modifier.weight(1f)) - - JDSButton( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 32.dp), - state = if (stockTextState.isEmpty()) ButtonState.Disable else ButtonState.Enable, - text = "구매 하기", - onClick = { setIsBuyingSuccessful(true) } - ) - } else { - Column( - modifier = modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Spacer(modifier = Modifier.height(120.dp)) - - CostImage(modifier = Modifier.size(177.dp)) - - Text( - text = "${entireStocksData.stockName} ${stockTextState.formatStockPrice()}주\n" + - " ${(stockTextState.toInt() * entireStocksData.myStockPrice).formatStockPrice()}P 구매 성공", - style = JDSTypography.subTitle, - color = JDSColor.Black - ) - - Spacer(modifier = Modifier.height(16.dp)) - - Row( - modifier = Modifier.clickableSingle { navigateToOrderHistory() }, - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "구매 내역 보러가기", - style = JDSTypography.label, - color = JDSColor.GRAY600 - ) - - RightArrowIcon() - } - } - } - } -} - -@Preview -@Composable -fun StockBuyingScreenPreview() { - StockBuyingScreen( - myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(0, "", 10000, 8160, 0,7.9f), - navigateToStockDetail = {}, - navigateToOrderHistory = {} - ) -} \ No newline at end of file diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuying/screen/StockBuyingScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyingScreen.kt similarity index 99% rename from presentation/src/main/java/com/jusiCool/presentation/stockBuying/screen/StockBuyingScreen.kt rename to presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyingScreen.kt index e94edd48..2082c3b9 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockBuying/screen/StockBuyingScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/screen/StockBuyingScreen.kt @@ -1,4 +1,4 @@ -package com.jusiCool.presentation.stockBuying.screen +package com.jusiCool.presentation.stockBuy.screen import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep b/presentation/src/main/java/com/jusiCool/presentation/stockBuy/viewModel/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockBuying/viewModel/.gitkeep b/presentation/src/main/java/com/jusiCool/presentation/stockBuying/viewModel/.gitkeep deleted file mode 100644 index e69de29b..00000000 From 4d4542768e742b9a23773ec985a5e52eff23615d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Sun, 14 Jul 2024 00:39:37 +0900 Subject: [PATCH 09/15] :fire: :: Fire Unused Package --- .../screen/StockReservationBuying.kt | 208 ------------------ 1 file changed, 208 deletions(-) delete mode 100644 presentation/src/main/java/com/jusiCool/presentation/stockReservationBuying/screen/StockReservationBuying.kt diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuying/screen/StockReservationBuying.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuying/screen/StockReservationBuying.kt deleted file mode 100644 index 58f07267..00000000 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuying/screen/StockReservationBuying.kt +++ /dev/null @@ -1,208 +0,0 @@ -package com.jusiCool.presentation.stockReservationBuying.screen - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import com.example.design_system.component.button.ButtonState -import com.example.design_system.component.button.JDSButton -import com.example.design_system.component.modifier.clickableSingle.clickableSingle -import com.example.design_system.component.textfield.JDSTextField -import com.example.design_system.component.topbar.JDSArrowTopBar -import com.example.design_system.icon_image.icon.LeftArrowIcon -import com.example.design_system.icon_image.icon.RightArrowIcon -import com.example.design_system.icon_image.image.CostImage -import com.example.design_system.theme.JDSTypography -import com.example.design_system.theme.color.JDSColor -import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData -import com.jusiCool.presentation.main.component.MyAccountData -import com.jusiCool.presentation.main.screen.tempMyAccountData -import com.jusiCool.presentation.utill.formatStockPrice - -const val stockReservationBuyingRoute = "stockReservationBuyingRoute" - -fun NavController.navigationToStockReservationBuying(id: Long) { - this.navigate("$stockReservationBuyingRoute/$id") -} - -fun NavGraphBuilder.stockReservationBuyingRoute( - navigateToStockDetail: (Long) -> Unit, - navigateToOrderHistory: () -> Unit, -) { - composable("$stockReservationBuyingRoute/{id}") { backStackEntry -> - val id = backStackEntry.arguments?.getString("id")?.toLongOrNull() - if (id != null) { - StockReservationBuyingRoute( - id = id, - navigateToStockDetail = navigateToStockDetail, - navigateToOrderHistory = navigateToOrderHistory - ) - } - } -} - -@Composable -internal fun StockReservationBuyingRoute( - modifier: Modifier = Modifier, - id: Long, - navigateToStockDetail: (Long) -> Unit, - navigateToOrderHistory: () -> Unit, -) { - StockReservationBuyingScreen( - modifier = modifier, - id = id, - myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(id = 1L, "마이크로소프트", 1231, 10000, 8160, 7.9f), - navigateToStockDetail = navigateToStockDetail, - navigateToOrderHistory = navigateToOrderHistory - ) -} - -@Composable -internal fun StockReservationBuyingScreen( - modifier: Modifier = Modifier, - id: Long, - myAccountData: MyAccountData, - entireStocksData: EntireStocksData, - navigateToStockDetail: (Long) -> Unit, - navigateToOrderHistory: () -> Unit, -) { - val (stockReservationTextState, setStockReservationTextState) = remember { mutableStateOf("") } - val (stockTextState, setStockTextState) = remember { mutableStateOf("") } - val (pager, setPager) = remember { mutableIntStateOf(1) } - - Column( - modifier = modifier - .fillMaxSize() - .background(color = JDSColor.WHITE), - horizontalAlignment = Alignment.CenterHorizontally - ) { - JDSArrowTopBar( - startIcon = { - LeftArrowIcon(modifier = Modifier.clickableSingle { - if (pager == 2) setPager(1) - else navigateToStockDetail(id) - }) - }, - betweenText = "주식 구매" - ) - - when (pager) { - 1 -> { - Spacer(modifier = Modifier.height(40.dp)) - - JDSTextField( - modifier = Modifier.padding(horizontal = 24.dp), - textState = stockReservationTextState, - placeHolder = "예약 금액을 달성했을 때 주식을 구매해요", - label = "예약 금액을 입력하세요", - helperText = "지금 주식 가격: ${entireStocksData.myStockPrice.formatStockPrice()} P", - onTextChange = setStockReservationTextState - ) - - Spacer(modifier = Modifier.weight(1f)) - - JDSButton( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 32.dp), - state = if (stockReservationTextState.isEmpty()) ButtonState.Disable else ButtonState.Enable, - text = "다음", - onClick = { setPager(2) } - ) - } - - 2 -> { - Spacer(modifier = Modifier.height(40.dp)) - - JDSTextField( - modifier = Modifier.padding(horizontal = 24.dp), - textState = stockTextState, - placeHolder = "최대 N주 구매 가능", - label = "몇 주 구매할까요?", - helperText = "보유 포인트 ${myAccountData.point.formatStockPrice()} P", - placerHolderShare = true, - onTextChange = setStockTextState - ) - - Spacer(modifier = Modifier.weight(1f)) - - JDSButton( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 32.dp), - state = if (stockTextState.isEmpty()) ButtonState.Disable else ButtonState.Enable, - text = "구매 하기", - onClick = { setPager(3) } - ) - } - - 3 -> { - Column( - modifier = modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Spacer(modifier = Modifier.height(120.dp)) - - CostImage(modifier = Modifier.size(177.dp)) - - Text( - text = "${entireStocksData.stockName} ${stockTextState.formatStockPrice()}주\n" + - "${(stockTextState.toInt() * stockReservationTextState.toInt()).formatStockPrice()}P 구매 예약 성공", - style = JDSTypography.subTitle, - color = JDSColor.Black, - textAlign = TextAlign.Center - ) - - Spacer(modifier = Modifier.height(16.dp)) - - Row( - modifier = Modifier.clickableSingle { navigateToOrderHistory() }, - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "구매 내역 보러가기", - style = JDSTypography.label, - color = JDSColor.GRAY600 - ) - - RightArrowIcon() - } - } - } - } - } -} - - -@Preview -@Composable -fun StockReservationBuyingScreenPreview() { - StockReservationBuyingScreen( - myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(id = 1L, "마이크로소프트", 1231, 10000, 8160, 7.9f), - navigateToStockDetail = {}, - navigateToOrderHistory = {}, - id = 1L - ) -} \ No newline at end of file From 67773e9f3bb929b802ebfaeaa10d713db697981b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Sun, 14 Jul 2024 00:40:14 +0900 Subject: [PATCH 10/15] :memo: :: Changed Naming(Delete -ing) --- .../JusiCool_Android_NavHost.kt | 4 +-- .../screen/StockReservationBuyScreen.kt | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt index fab9de71..74cb3764 100644 --- a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt +++ b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt @@ -36,7 +36,7 @@ import com.jusiCool.presentation.splash.screen.splashRoute import com.jusiCool.presentation.stockDetail.screen.navigateToStockDetail import com.jusiCool.presentation.stockDetail.screen.stockDetailRoute import com.jusiCool.presentation.stockBuy.screen.stockBuyingRoute -import com.jusiCool.presentation.stockReservationBuying.screen.stockReservationBuyingRoute +import com.jusiCool.presentation.stockReservationBuy.screen.stockReservationBuyRoute import com.jusiCool.presentation.stockReservationSelling.screen.stockReservationSellingRoute import com.jusiCool.presentation.stockSelling.screen.stockSellingRoute @@ -106,7 +106,7 @@ fun JusiCool_Android_NavHost( navigateToOrderHistory = navController::navigateToOrderHistory, ) - stockReservationBuyingRoute( + stockReservationBuyRoute( navigateToStockDetail = navController::navigateToStockDetail, navigateToOrderHistory = navController::navigateToOrderHistory, ) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index 692f927d..21af2092 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -49,20 +49,20 @@ import com.jusiCool.presentation.stockReservationBuy.viewmodel.StockReservationB import com.jusiCool.presentation.utill.formatLongStockPrice import com.jusiCool.presentation.utill.formatStockPrice -const val stockReservationBuyingRoute = "stockReservationBuyingRoute" +const val stockReservationBuyRoute = "stockReservationBuyRoute" -fun NavController.navigationToStockReservationBuying(stockId: Long) { - this.navigate("$stockReservationBuyingRoute/$stockId") +fun NavController.navigationToStockReservationBuy(id: Long) { + this.navigate("${stockReservationBuyRoute}/${id}") } -fun NavGraphBuilder.stockReservationBuyingRoute( - navigateToStockDetail: () -> Unit, +fun NavGraphBuilder.stockReservationBuyRoute( + navigateToStockDetail: (Long) -> Unit, navigateToOrderHistory: () -> Unit, ) { - composable("$stockReservationBuyingRoute}/{id}") { backStackEntry -> + composable("$stockReservationBuyRoute}/{id}") { backStackEntry -> val id = backStackEntry.arguments?.getString("id")?.toLongOrNull() if(id != null) { - StockReservationBuyingRoute( + StockReservationBuyRoute( id = id, navigateToStockDetail = navigateToStockDetail, navigateToOrderHistory = navigateToOrderHistory @@ -72,16 +72,16 @@ fun NavGraphBuilder.stockReservationBuyingRoute( } @Composable -internal fun StockReservationBuyingRoute( +internal fun StockReservationBuyRoute( modifier: Modifier = Modifier, viewModel: StockReservationBuyViewModel = hiltViewModel(LocalContext.current as ComponentActivity), id: Long, - navigateToStockDetail: () -> Unit, + navigateToStockDetail: (Long) -> Unit, navigateToOrderHistory: () -> Unit, ) { val focusManager = LocalFocusManager.current - StockReservationBuyingScreen( + StockReservationBuyScreen( modifier = modifier, id = id, myAccountData = tempMyAccountData, @@ -104,13 +104,13 @@ internal fun StockReservationBuyingRoute( } @Composable -internal fun StockReservationBuyingScreen( +internal fun StockReservationBuyScreen( modifier: Modifier = Modifier, id: Long, myAccountData: MyAccountData, entireStocksData: EntireStocksData, postBuyStock: (num: Long, goal_price: Long) -> Unit, - navigateToStockDetail: () -> Unit, + navigateToStockDetail: (Long) -> Unit, navigateToOrderHistory: () -> Unit, focusManager: FocusManager, postStock: Long, @@ -137,7 +137,7 @@ internal fun StockReservationBuyingScreen( startIcon = { LeftArrowIcon(modifier = Modifier.clickableSingle { if (pager == 2) setPager(1) - else navigateToStockDetail() + else navigateToStockDetail(id) }) }, betweenText = "주식 구매" @@ -243,7 +243,7 @@ internal fun StockReservationBuyingScreen( @Preview @Composable fun StockReservationBuyingScreenPreview() { - StockReservationBuyingScreen( + StockReservationBuyScreen( id = 0, myAccountData = tempMyAccountData, entireStocksData = EntireStocksData(0, "", 10000, 8160, 23, 9.3f), From 7249b2923476ae62afc6ca13c896d98d608811ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Sun, 14 Jul 2024 00:41:55 +0900 Subject: [PATCH 11/15] :recycle: :: Changed Changed Type Way --- .../stockReservationBuy/screen/StockReservationBuyScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index 21af2092..842aa734 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -153,7 +153,7 @@ internal fun StockReservationBuyScreen( placeHolder = "예약 금액을 달성했을 때 주식을 구매해요", label = "예약 금액을 입력하세요", helperText = "지금 주식 가격: ${entireStocksData.myStockPrice.formatStockPrice()} P", - onTextChange = { setStockReservationTextState(it.toLongOrNull() ?: 0) } + onTextChange = { setStockReservationTextState(it.toLong()) } ) Spacer(modifier = Modifier.weight(1f)) @@ -178,7 +178,7 @@ internal fun StockReservationBuyScreen( label = "몇 주 구매할까요?", helperText = "보유 포인트 ${myAccountData.point.formatStockPrice()} P", placerHolderShare = true, - onTextChange = { setStockTextState(it.toLongOrNull() ?: 0) } + onTextChange = { setStockTextState(it.toLong()) } ) Spacer(modifier = Modifier.weight(1f)) From 3b87c9253f9048d39eb49d535e47c2ad9db9537f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Sun, 14 Jul 2024 00:44:03 +0900 Subject: [PATCH 12/15] :recycle: :: Fire Unused Code And Apply(Add .toInt) --- .../stockReservationBuy/screen/StockReservationBuyScreen.kt | 3 +-- .../java/com/jusiCool/presentation/utill/formatStockPrice.kt | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index 842aa734..9c08a736 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -46,7 +46,6 @@ import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData import com.jusiCool.presentation.main.component.MyAccountData import com.jusiCool.presentation.main.screen.tempMyAccountData import com.jusiCool.presentation.stockReservationBuy.viewmodel.StockReservationBuyViewModel -import com.jusiCool.presentation.utill.formatLongStockPrice import com.jusiCool.presentation.utill.formatStockPrice const val stockReservationBuyRoute = "stockReservationBuyRoute" @@ -209,7 +208,7 @@ internal fun StockReservationBuyScreen( CostImage(modifier = Modifier.size(177.dp)) Text( - text = "${entireStocksData.stockName} ${stockTextState.formatLongStockPrice()}주\n" + + text = "${entireStocksData.stockName} ${stockTextState.toInt().formatStockPrice()}주\n" + "${(stockTextState.toInt() * stockReservationTextState.toInt()).formatStockPrice()}P 구매 예약 성공", style = JDSTypography.subTitle, color = JDSColor.Black, diff --git a/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt b/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt index ea2bbd8f..ee239502 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/utill/formatStockPrice.kt @@ -2,6 +2,4 @@ package com.jusiCool.presentation.utill fun Int.formatStockPrice(): String = "%,d".format(this) -fun String.formatStockPrice(): String = this.toInt().formatStockPrice() - -fun Long.formatLongStockPrice(): String = "%,d".format(this) \ No newline at end of file +fun String.formatStockPrice(): String = this.toInt().formatStockPrice() \ No newline at end of file From 7c65e1c56bddcef4b5179c2bcee9309418498597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Wed, 17 Jul 2024 08:11:03 +0900 Subject: [PATCH 13/15] :memo: :: Get Id Type Long -> String --- .../screen/StockReservationBuyScreen.kt | 24 +++++++++---------- .../viewmodel/StockReservationBuyViewModel.kt | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index 9c08a736..b3c18c79 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -42,7 +42,7 @@ import com.example.design_system.icon_image.image.CostImage import com.example.design_system.theme.JDSTypography import com.example.design_system.theme.JusiCoolAndroidTheme import com.example.design_system.theme.color.JDSColor -import com.jusiCool.presentation.checkEntireStock.component.EntireStocksData +import com.jusiCool.presentation.main.component.EntireStocksData import com.jusiCool.presentation.main.component.MyAccountData import com.jusiCool.presentation.main.screen.tempMyAccountData import com.jusiCool.presentation.stockReservationBuy.viewmodel.StockReservationBuyViewModel @@ -50,23 +50,21 @@ import com.jusiCool.presentation.utill.formatStockPrice const val stockReservationBuyRoute = "stockReservationBuyRoute" -fun NavController.navigationToStockReservationBuy(id: Long) { +fun NavController.navigationToStockReservationBuy(id: String) { this.navigate("${stockReservationBuyRoute}/${id}") } fun NavGraphBuilder.stockReservationBuyRoute( - navigateToStockDetail: (Long) -> Unit, + navigateToStockDetail: (String) -> Unit, navigateToOrderHistory: () -> Unit, ) { composable("$stockReservationBuyRoute}/{id}") { backStackEntry -> - val id = backStackEntry.arguments?.getString("id")?.toLongOrNull() - if(id != null) { + val id = backStackEntry.arguments?.getString("id") ?: "" StockReservationBuyRoute( id = id, navigateToStockDetail = navigateToStockDetail, navigateToOrderHistory = navigateToOrderHistory ) - } } } @@ -74,8 +72,8 @@ fun NavGraphBuilder.stockReservationBuyRoute( internal fun StockReservationBuyRoute( modifier: Modifier = Modifier, viewModel: StockReservationBuyViewModel = hiltViewModel(LocalContext.current as ComponentActivity), - id: Long, - navigateToStockDetail: (Long) -> Unit, + id: String, + navigateToStockDetail: (String) -> Unit, navigateToOrderHistory: () -> Unit, ) { val focusManager = LocalFocusManager.current @@ -84,7 +82,7 @@ internal fun StockReservationBuyRoute( modifier = modifier, id = id, myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(0, "", 10000, 8160, 6, 4.9f), + entireStocksData = EntireStocksData("", "", 10000, 8160, 6, 4.9f), navigateToStockDetail = navigateToStockDetail, navigateToOrderHistory = navigateToOrderHistory, focusManager = focusManager, @@ -105,11 +103,11 @@ internal fun StockReservationBuyRoute( @Composable internal fun StockReservationBuyScreen( modifier: Modifier = Modifier, - id: Long, + id: String, myAccountData: MyAccountData, entireStocksData: EntireStocksData, postBuyStock: (num: Long, goal_price: Long) -> Unit, - navigateToStockDetail: (Long) -> Unit, + navigateToStockDetail: (String) -> Unit, navigateToOrderHistory: () -> Unit, focusManager: FocusManager, postStock: Long, @@ -243,9 +241,9 @@ internal fun StockReservationBuyScreen( @Composable fun StockReservationBuyingScreenPreview() { StockReservationBuyScreen( - id = 0, + id = "", myAccountData = tempMyAccountData, - entireStocksData = EntireStocksData(0, "", 10000, 8160, 23, 9.3f), + entireStocksData = EntireStocksData("", "", 10000, 8160, 23, 9.3f), navigateToStockDetail = {}, navigateToOrderHistory = {}, focusManager = LocalFocusManager.current, diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt index 83cb2383..5bb20d3f 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/viewmodel/StockReservationBuyViewModel.kt @@ -29,7 +29,7 @@ class StockReservationBuyViewModel @Inject constructor( private set fun postBuyStock( - stockId: Long, + stockId: String, num: Long, goal_price: Long, ) = viewModelScope.launch { From d126a28bfb70dc13f29d2875ba61231d61684211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Wed, 17 Jul 2024 08:11:38 +0900 Subject: [PATCH 14/15] :truck: :: Locate To File To Presentation --- .../com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt | 2 +- .../jusiCool/presentation/stockSell/screen/StockSellScreen.kt | 4 ++-- .../presentation/stockSell/viewModel/StockSellViewModel.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt index 24dde096..08573069 100644 --- a/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt +++ b/app/src/main/java/com/jusiCool/jusicool_android/JusiCool_Android_NavHost.kt @@ -39,7 +39,7 @@ import com.jusiCool.presentation.stockDetail.screen.stockDetailRoute import com.jusiCool.presentation.stockBuy.screen.stockBuyingRoute import com.jusiCool.presentation.stockReservationBuy.screen.stockReservationBuyRoute import com.jusiCool.presentation.stockReservationSelling.screen.stockReservationSellingRoute -import com.jusiCool.presentation.stockReservationBuying.screen.stockSell.screen.stockSellingRoute +import com.jusiCool.presentation.stockSell.screen.stockSellingRoute @Composable fun JusiCool_Android_NavHost( diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockSell/screen/StockSellScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockSell/screen/StockSellScreen.kt index 2cf97b8e..c337585a 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockSell/screen/StockSellScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockSell/screen/StockSellScreen.kt @@ -1,4 +1,4 @@ -package com.jusiCool.presentation.stockReservationBuying.screen.stockSell.screen +package com.jusiCool.presentation.stockSell.screen import androidx.activity.ComponentActivity import androidx.compose.foundation.background @@ -38,7 +38,7 @@ import com.example.design_system.theme.color.JDSColor import com.jusiCool.domain.model.user.response.GetMyStockModel import com.jusiCool.presentation.main.component.EntireStocksData import com.jusiCool.presentation.main.viewModel.MainViewModel -import com.jusiCool.presentation.stockReservationBuying.screen.stockSell.viewModel.StockSellViewModel +import com.jusiCool.presentation.stockSell.viewModel.StockSellViewModel import com.jusiCool.presentation.utill.formatStockPrice const val stockSellingRoute = "stockSellingRoute" diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockSell/viewModel/StockSellViewModel.kt b/presentation/src/main/java/com/jusiCool/presentation/stockSell/viewModel/StockSellViewModel.kt index 41446cad..95262a08 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockSell/viewModel/StockSellViewModel.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockSell/viewModel/StockSellViewModel.kt @@ -1,4 +1,4 @@ -package com.jusiCool.presentation.stockReservationBuying.screen.stockSell.viewModel +package com.jusiCool.presentation.stockSell.viewModel import androidx.compose.runtime.mutableLongStateOf import androidx.lifecycle.ViewModel From 335b1d8c583b781913452d4da584937bd1b6b448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AA=85=ED=9B=88?= Date: Wed, 17 Jul 2024 08:30:53 +0900 Subject: [PATCH 15/15] :green_heart: :: Fix Ci Error --- .../stockReservationBuy/screen/StockReservationBuyScreen.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt index b3c18c79..5d297c7e 100644 --- a/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt +++ b/presentation/src/main/java/com/jusiCool/presentation/stockReservationBuy/screen/StockReservationBuyScreen.kt @@ -59,12 +59,14 @@ fun NavGraphBuilder.stockReservationBuyRoute( navigateToOrderHistory: () -> Unit, ) { composable("$stockReservationBuyRoute}/{id}") { backStackEntry -> - val id = backStackEntry.arguments?.getString("id") ?: "" + val id = backStackEntry.arguments?.getString("id") + if (id != null) { StockReservationBuyRoute( id = id, navigateToStockDetail = navigateToStockDetail, navigateToOrderHistory = navigateToOrderHistory ) + } } }