Skip to content

Commit

Permalink
[MERGE] #15 -> develop
Browse files Browse the repository at this point in the history
[UI/#15] 구매완료뷰 / UI 구현
  • Loading branch information
Marchbreeze authored Jun 15, 2024
2 parents cd385af + 2c137d9 commit 2789139
Show file tree
Hide file tree
Showing 23 changed files with 910 additions and 50 deletions.
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="co.orange.presentation.buy.push.BuyPushActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="co.orange.presentation.buy.finished.BuyFinishedActivity"
android:exported="false"
android:screenOrientation="portrait"/>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.orange.domain.entity.response

data class AddressInfoModel(
val recipient: String,
val zipCode: String,
val address: String,
val phone: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package co.orange.domain.entity.response

import co.orange.domain.enums.OrderStatus

data class BuyDetailModel(
val orderId: String,
val orderStatus: OrderStatus,
val productName: String,
val imgUrl: String,
val originPrice: Int,
val sellerNickname: String,
val addressInfo: List<AddressInfoModel>,
val paymentInfo: List<PaymentInfoModel>,
val discountPrice: Int,
val charge: Int,
val totalPrice: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.orange.domain.entity.response

data class BuyInfoModel(
val productName: String,
val imgUrl: String,
val originPrice: Int,
val addressInfo: List<AddressInfoModel>,
val discountPrice: Int,
val charge: Int,
val totalPrice: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package co.orange.domain.entity.response

data class PaymentInfoModel(
val method: String,
val completedAt: String
)
5 changes: 5 additions & 0 deletions domain/src/main/kotlin/co/orange/domain/enums/OrderStatus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package co.orange.domain.enums

enum class OrderStatus {
ORDER_PLACED, SHIPPING, COMPLETED, CANCELLED
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import co.orange.domain.entity.response.BuyInfoModel
import co.orange.presentation.buy.push.BuyPushActivity
import coil.load
import dagger.hilt.android.AndroidEntryPoint
import kr.genti.core.base.BaseActivity
Expand All @@ -24,7 +26,7 @@ class BuyConfirmActivity : BaseActivity<ActivityBuyConfirmBinding>(R.layout.acti
initTermBtnListener()
initConfirmBtnListener()
getIntentInfo()
setIntentUi()
setIntentUi(viewModel.mockBuyInfo)
}

private fun initExitBtnListener() {
Expand All @@ -33,63 +35,54 @@ class BuyConfirmActivity : BaseActivity<ActivityBuyConfirmBinding>(R.layout.acti

private fun initDeliveryChangeBtnListener() {
// TODO
binding.btnChangeDelivery.setOnSingleClickListener { }
binding.btnChangeDelivery.setOnSingleClickListener { }
}

private fun initTermBtnListener() {
//TODO
binding.btnTermAll.setOnSingleClickListener { }
binding.btnTermFirst.setOnSingleClickListener { }
binding.btnTermSecond.setOnSingleClickListener { }
binding.btnTermThird.setOnSingleClickListener { }
binding.btnTermAll.setOnSingleClickListener { }
binding.btnTermFirst.setOnSingleClickListener { }
binding.btnTermSecond.setOnSingleClickListener { }
binding.btnTermThird.setOnSingleClickListener { }
}

private fun initConfirmBtnListener() {
// TODO
binding.btnConfirmPurchase.setOnSingleClickListener { }
binding.btnConfirmPurchase.setOnSingleClickListener {
// TODO 구매 요청 서버통신 이후
BuyPushActivity.createIntent(this, viewModel.productId).apply {
startActivity(this)
}
}
}

private fun getIntentInfo() {
with(viewModel) {
imageUrl = intent.getStringExtra(EXTRA_PRODUCT_URL).orEmpty()
originPrice = intent.getIntExtra(EXTRA_ORIGIN_PRICE, 0)
salePrice = intent.getIntExtra(EXTRA_SALE_PRICE, 0)
name = intent.getStringExtra(EXTRA_NAME).orEmpty()
}
viewModel.productId = intent.getLongExtra(EXTRA_PRODUCT_ID, -1)
}

private fun setIntentUi() {
private fun setIntentUi(item: BuyInfoModel) {
with(binding) {
tvConfirmProductName.text = viewModel.name
ivConfirmProduct.load(viewModel.imageUrl)
tvConfirmProductPrice.text = viewModel.salePrice.setNumberForm()
tvConfirmPriceMoney.text = viewModel.salePrice.setNumberForm()
// TODO
tvConfirmPriceDiscount.text = "-3,000"
tvConfirmPriceCharge.text = "+350"
tvConfirmPriceTotal.text = "21,350"
tvConfirmProductName.text = item.productName
ivConfirmProduct.load(item.imgUrl)
tvConfirmProductPrice.text = item.originPrice.setNumberForm()
tvConfirmPriceMoney.text = item.originPrice.setNumberForm()
tvConfirmPriceDiscount.text =
getString(R.string.add_minus, item.discountPrice.setNumberForm())
tvConfirmPriceCharge.text =
getString(R.string.add_plus, item.charge.setNumberForm())
tvConfirmPriceTotal.text = item.totalPrice.setNumberForm()
}
}


companion object {
private const val EXTRA_PRODUCT_URL = "EXTRA_PRODUCT_URL"
private const val EXTRA_ORIGIN_PRICE = "EXTRA_ORIGIN_PRICE"
private const val EXTRA_SALE_PRICE = "EXTRA_SALE_PRICE"
private const val EXTRA_NAME = "EXTRA_NAME"
private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID"

@JvmStatic
fun createIntent(
context: Context,
productUrl: String,
originPrice: Int,
salePrice: Int,
name: String
productId: Long
): Intent = Intent(context, BuyConfirmActivity::class.java).apply {
putExtra(EXTRA_PRODUCT_URL, productUrl)
putExtra(EXTRA_ORIGIN_PRICE, originPrice)
putExtra(EXTRA_SALE_PRICE, salePrice)
putExtra(EXTRA_NAME, name)
putExtra(EXTRA_PRODUCT_ID, productId)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package co.orange.presentation.buy.confirm

import androidx.lifecycle.ViewModel
import co.orange.domain.entity.response.AddressInfoModel
import co.orange.domain.entity.response.BuyInfoModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

Expand All @@ -11,9 +13,22 @@ constructor(
// private val feedRepository: FeedRepository,
) : ViewModel() {

var imageUrl: String = ""
var originPrice: Int = 0
var salePrice: Int = 0
var name: String = ""
var productId: Long = -1

val mockBuyInfo = BuyInfoModel(
"상품이름은 한줄로만 보여줄거에야야야야야야",
"https://github.com/Marchbreeze/Marchbreeze/assets/97405341/cd2c0454-92b4-41e7-ae2f-319f83e2426f",
24000,
listOf(
AddressInfoModel(
"김상호",
"04567",
"서울특벌시 성동구 성수이로 137 107동 903호",
"010-3259-0327"
)
),
3000,
350,
21350
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package co.orange.presentation.buy.finished

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import co.orange.domain.entity.response.BuyDetailModel
import co.orange.presentation.main.MainActivity
import coil.load
import dagger.hilt.android.AndroidEntryPoint
import kr.genti.core.base.BaseActivity
import kr.genti.core.extension.breakLines
import kr.genti.core.extension.setNumberForm
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.ActivityBuyFinishedBinding

@AndroidEntryPoint
class BuyFinishedActivity :
BaseActivity<ActivityBuyFinishedBinding>(R.layout.activity_buy_finished) {
private val viewModel by viewModels<BuyFinishedViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initReturnBtnListener()
initDetailBtnListener()
getIntentInfo()
setIntentUi(viewModel.mockBuyInfo)
}

private fun initReturnBtnListener() {
binding.btnHome.setOnSingleClickListener { navigateToHome() }
binding.btnKeepShopping.setOnSingleClickListener { navigateToHome() }
}

private fun navigateToHome() {
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
startActivity(this)
}
}

private fun initDetailBtnListener() {
// TODO
binding.btnShowDetail.setOnSingleClickListener { }
}

private fun getIntentInfo() {
viewModel.productId = intent.getLongExtra(EXTRA_PRODUCT_ID, -1)
}

private fun setIntentUi(item: BuyDetailModel) {
with(binding) {
tvFinishedTransaction.text =
getString(R.string.transaction_id, item.orderId).breakLines()
ivFinishedItem.load(item.imgUrl)
tvFinishedItemName.text = item.productName
tvFinishedItemPrice.text = item.originPrice.setNumberForm()
tvFinishedDeliveryName.text = item.addressInfo[0].recipient
tvFinishedDeliveryAddress.text = getString(
R.string.address_format,
item.addressInfo[0].zipCode,
item.addressInfo[0].address
).breakLines()
tvFinishedDeliveryPhone.text = item.addressInfo[0].phone
tvFinishedTransactionMethod.text = item.paymentInfo[0].method
tvFinishedTransactionDate.text = item.paymentInfo[0].completedAt
tvFinishedPayMoney.text = item.originPrice.setNumberForm()
tvFinishedPayDiscount.text = getString(R.string.add_minus, item.discountPrice.setNumberForm())
tvFinishedPayCharge.text = getString(R.string.add_plus, item.charge.setNumberForm())
tvFinishedPayTotal.text = item.totalPrice.setNumberForm()
}
}


companion object {
private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID"

@JvmStatic
fun createIntent(
context: Context,
productId: Long
): Intent = Intent(context, BuyFinishedActivity::class.java).apply {
putExtra(EXTRA_PRODUCT_ID, productId)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package co.orange.presentation.buy.finished

import androidx.lifecycle.ViewModel
import co.orange.domain.entity.response.AddressInfoModel
import co.orange.domain.entity.response.BuyDetailModel
import co.orange.domain.entity.response.PaymentInfoModel
import co.orange.domain.enums.OrderStatus
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class BuyFinishedViewModel
@Inject
constructor(
// private val feedRepository: FeedRepository,
) : ViewModel() {

var productId: Long = -1

val mockBuyInfo = BuyDetailModel(
"123e4567-e89b-12d3-a456-426614174000",
OrderStatus.ORDER_PLACED,
"상품이름은 한줄로만 보여줄거에야야야야야야",
"https://github.com/Marchbreeze/Marchbreeze/assets/97405341/cd2c0454-92b4-41e7-ae2f-319f83e2426f",
24000,
"등둔",
listOf(
AddressInfoModel(
"김상호",
"04567",
"서울특벌시 성동구 성수이로 137 107동 903호",
"010-3259-0327"
)
),
listOf(
PaymentInfoModel(
"NAVERPAY",
"2024.06.06"
)
),
3000,
350,
21350
)
}
Loading

0 comments on commit 2789139

Please sign in to comment.