-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
404 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
feature/sell/src/main/java/co/orange/sell/confirm/SellConfirmDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package co.orange.sell.confirm | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.WindowManager | ||
import androidx.fragment.app.activityViewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import co.orange.core.R | ||
import co.orange.core.amplitude.AmplitudeManager | ||
import co.orange.core.base.BaseDialog | ||
import co.orange.core.extension.setOnSingleClickListener | ||
import co.orange.core.extension.stringOf | ||
import co.orange.core.extension.toast | ||
import co.orange.core.navigation.NavigationManager | ||
import co.orange.core.state.UiState | ||
import co.orange.sell.databinding.DialogSellConfirmBinding | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
import javax.inject.Inject | ||
import co.orange.sell.R as featureR | ||
|
||
class SellConfirmDialog : | ||
BaseDialog<DialogSellConfirmBinding>(featureR.layout.dialog_sell_confirm) { | ||
@Inject | ||
lateinit var navigationManager: NavigationManager | ||
|
||
private val viewModel by activityViewModels<SellConfirmViewModel>() | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.apply { | ||
setLayout( | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
) | ||
setBackgroundDrawableResource(R.color.transparent) | ||
} | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initReturnBtnListener() | ||
initConfirmBtnListener() | ||
observePatchOrderConfirmState() | ||
} | ||
|
||
private fun initReturnBtnListener() { | ||
binding.btnReturn.setOnSingleClickListener { dismiss() } | ||
} | ||
|
||
private fun initConfirmBtnListener() { | ||
binding.btnConfirm.setOnSingleClickListener { | ||
viewModel.patchOrderConfirmToServer() | ||
} | ||
} | ||
|
||
private fun observePatchOrderConfirmState() { | ||
viewModel.patchOrderConfirmState.flowWithLifecycle(lifecycle).distinctUntilChanged() | ||
.onEach { state -> | ||
when (state) { | ||
is UiState.Success -> { | ||
AmplitudeManager.apply { | ||
plusIntProperty("user_selling_count", 1) | ||
plusIntProperty("user_selling_total", viewModel.totalPrice) | ||
} | ||
toast(stringOf(R.string.sell_order_fix_msg)) | ||
navigationManager.toMainViewWIthClearing(requireContext()) | ||
} | ||
|
||
is UiState.Failure -> toast(stringOf(R.string.error_msg)) | ||
else -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
feature/sell/src/main/java/co/orange/sell/info/SellDeleteDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package co.orange.sell.info | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.WindowManager | ||
import androidx.activity.viewModels | ||
import androidx.fragment.app.activityViewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import co.orange.core.base.BaseDialog | ||
import co.orange.core.extension.setOnSingleClickListener | ||
import co.orange.core.extension.stringOf | ||
import co.orange.core.extension.toast | ||
import co.orange.core.navigation.NavigationManager | ||
import co.orange.core.state.UiState | ||
import co.orange.sell.R | ||
import co.orange.sell.databinding.DialogBankBinding | ||
import co.orange.sell.databinding.DialogSellDeleteBinding | ||
import co.orange.sell.progress.SellProgressViewModel | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class SellDeleteDialog : | ||
BaseDialog<DialogSellDeleteBinding>(R.layout.dialog_sell_delete) { | ||
|
||
private val viewModel by activityViewModels<SellInfoViewModel>() | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.apply { | ||
setLayout( | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
) | ||
setBackgroundDrawableResource(co.orange.core.R.color.transparent) | ||
} | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initDeleteBtnListener() | ||
observeDeleteItemState() | ||
} | ||
|
||
private fun initDeleteBtnListener() { | ||
binding.btnSellDelete.setOnSingleClickListener { | ||
viewModel.deleteSellingItemFromServer() | ||
} | ||
} | ||
|
||
private fun observeDeleteItemState() { | ||
viewModel.deleteItemState | ||
.flowWithLifecycle(lifecycle) | ||
.distinctUntilChanged() | ||
.onEach { state -> | ||
when (state) { | ||
is UiState.Success -> { | ||
toast(stringOf(co.orange.core.R.string.sell_delete_success_toast)) | ||
requireActivity().finish() | ||
dismiss() | ||
} | ||
|
||
is UiState.Failure -> toast(stringOf(co.orange.core.R.string.error_msg)) | ||
else -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.