-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] ElderInfo 관련 시간설정, 결제 화면, 뷰모델 등 수정 #206 #207
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ import com.konkuk.medicarecall.R | |
| import com.konkuk.medicarecall.ui.common.component.CTAButton | ||
| import com.konkuk.medicarecall.ui.feature.login.info.component.LoginBackButton | ||
| import com.konkuk.medicarecall.ui.feature.login.payment.component.PaymentPriceItem | ||
| import com.konkuk.medicarecall.ui.feature.settings.viewmodel.EldersInfoViewModel | ||
| import com.konkuk.medicarecall.ui.feature.login.payment.viewmodel.PaymentViewModel | ||
| import com.konkuk.medicarecall.ui.theme.MediCareCallTheme | ||
| import com.konkuk.medicarecall.ui.type.CTAButtonType | ||
| import java.text.NumberFormat | ||
|
|
@@ -46,11 +46,14 @@ fun PaymentScreen( | |
| onBack: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| navigateToNaverPay: () -> Unit = {}, | ||
| elderInfoViewModel: EldersInfoViewModel = hiltViewModel(), | ||
| paymentViewModel: PaymentViewModel = hiltViewModel(), | ||
| ) { | ||
| val scrollState = rememberScrollState() | ||
| val elderMap = paymentViewModel.elderMap | ||
| val elders = elderMap.values.toList() | ||
| var isClicked by remember { mutableStateOf(false) } | ||
| val elders = elderInfoViewModel.eldersInfoList.map { it.name } | ||
| val totalAmount = paymentViewModel.getTotalPrice() // Assuming 29,000 is the monthly fee per elder | ||
|
|
||
|
Comment on lines
+52
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isClicked 로컬 상태가 더 이상 갱신되지 않아 결제 UI가 항상 비활성 상태입니다. 지금 구조에서는:
- val elderMap = paymentViewModel.elderMap
- val elders = elderMap.values.toList()
- var isClicked by remember { mutableStateOf(false) }
- val totalAmount = paymentViewModel.getTotalPrice() // Assuming 29,000 is the monthly fee per elder
+ val elderMap = paymentViewModel.elderMap
+ val elders = elderMap.values.toList()
+ val isClicked by paymentViewModel.isPaymentSelected
+ val totalAmount = paymentViewModel.getTotalPrice() // Assuming 29,000 is the monthly fee per elder
@@
- Button(
+ Button(
modifier = modifier
.fillMaxWidth()
.padding(vertical = 18.dp),
- onClick = { paymentViewModel.togglePaymentSelect() },
+ onClick = { paymentViewModel.togglePaymentSelect() },
@@
Spacer(modifier = modifier.weight(1f))
CTAButton(
type = if (isClicked) CTAButtonType.GREEN else CTAButtonType.DISABLED,
text = "결제하기",
onClick = { if (isClicked) navigateToNaverPay() },
)이렇게 바꾸면:
Also applies to: 139-166 🧰 Tools🪛 GitHub Actions: Android CI[error] 55-56: Detekt: Unnecessary long whitespace. [NoMultipleSpaces] 🤖 Prompt for AI Agents |
||
| Column( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
|
|
@@ -124,8 +127,6 @@ fun PaymentScreen( | |
| color = MediCareCallTheme.colors.black, | ||
| ) | ||
| Spacer(modifier = modifier.weight(1f)) | ||
| val totalAmount = | ||
| elders.size * 29000 // Assuming 29,000 is the monthly fee per elder | ||
| val formatted = NumberFormat.getNumberInstance(Locale.KOREA).format(totalAmount) | ||
| val displayText = "₩$formatted/월" | ||
| Text( | ||
|
|
@@ -139,7 +140,7 @@ fun PaymentScreen( | |
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .padding(vertical = 18.dp), | ||
| onClick = { if (isClicked) isClicked = false else isClicked = true }, | ||
| onClick = { paymentViewModel.togglePaymentSelect() }, | ||
| colors = ButtonDefaults.buttonColors( | ||
| containerColor = MediCareCallTheme.colors.bg, | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.konkuk.medicarecall.ui.feature.login.payment.viewmodel | ||
|
|
||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.konkuk.medicarecall.data.repository.ElderIdRepository | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import kotlinx.coroutines.launch | ||
| import javax.inject.Inject | ||
|
|
||
| @HiltViewModel | ||
| class PaymentViewModel @Inject constructor( | ||
| private val elderIdRepository: ElderIdRepository, | ||
| ) : ViewModel() { | ||
|
|
||
| // 결제 대상 어르신 목록 (로컬 DataStore 기준) | ||
| private val _elderMap = mutableStateOf<Map<Int, String>>(emptyMap()) | ||
| val elderMap get() = _elderMap.value | ||
|
|
||
| // 결제 버튼 선택 여부 | ||
| val isPaymentSelected = mutableStateOf(false) | ||
|
|
||
| // 월 요금 (상수) | ||
| private val pricePerElder = 29_000 | ||
|
|
||
| init { | ||
| observeElders() | ||
| } | ||
|
|
||
| // 어르신 목록 Flow → State | ||
| private fun observeElders() { | ||
| viewModelScope.launch { | ||
| elderIdRepository.getElderIds() | ||
| .collect { result -> | ||
| _elderMap.value = result | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 총 결제 금액 | ||
| fun getTotalPrice(): Int { | ||
| return elderMap.size * pricePerElder | ||
| } | ||
|
|
||
| // 네이버페이 선택 토글 | ||
| fun togglePaymentSelect() { | ||
| isPaymentSelected.value = !isPaymentSelected.value | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [versions] | ||
| agp = "8.13.0" | ||
| agp = "8.13.1" | ||
| kotlin = "2.0.21" | ||
| coreKtx = "1.10.1" | ||
| junit = "4.13.2" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용하지 않는 import 제거 필요
파이프라인 오류:
EldersInfoRepositoryimport가 사용되지 않습니다.import com.konkuk.medicarecall.data.repository.ElderIdRepository -import com.konkuk.medicarecall.data.repository.EldersInfoRepository import com.konkuk.medicarecall.data.repository.SetCallRepository📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: Android CI
[error] 9-9: Detekt: Unused import. [NoUnusedImports]
🤖 Prompt for AI Agents