-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
484fb71
commit 36ce54f
Showing
11 changed files
with
504 additions
and
37 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
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
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
79 changes: 79 additions & 0 deletions
79
.../checkin/app/checkin/manager/fragments/ManagerSessionPaymentOptionsBottomSheetFragment.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,79 @@ | ||
package com.checkin.app.checkin.manager.fragments; | ||
|
||
|
||
import android.app.AlertDialog | ||
import android.content.DialogInterface | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.TextView | ||
import androidx.fragment.app.activityViewModels | ||
import androidx.lifecycle.Observer | ||
import butterknife.BindView | ||
import butterknife.OnClick | ||
import com.checkin.app.checkin.R | ||
import com.checkin.app.checkin.data.resource.Resource | ||
import com.checkin.app.checkin.manager.viewmodels.ManagerSessionViewModel | ||
import com.checkin.app.checkin.misc.fragments.BaseBottomSheetFragment | ||
import com.checkin.app.checkin.utility.Utils | ||
|
||
class ManagerSessionPaymentOptionsBottomSheetFragment : BaseBottomSheetFragment() { | ||
override val rootLayout: Int = R.layout.fragment_manager_session_payment_options | ||
|
||
@BindView(R.id.tv_manager_session_payment_amount) | ||
internal lateinit var tvManagerSessionAmount: TextView | ||
|
||
private val viewModel: ManagerSessionViewModel by activityViewModels() | ||
|
||
private val isPromoApplied by lazy { | ||
viewModel.getmIsPromoApplied() | ||
} | ||
|
||
private val isRequestedCheckout by lazy { | ||
viewModel.getmIsRequestedCheckout() | ||
} | ||
|
||
@OnClick(R.id.card_manager_session_payment_bhim, R.id.card_manager_session_payment_card, R.id.card_manager_session_payment_cash) | ||
fun submitButton(v: View) { | ||
when (v.id) { | ||
R.id.card_manager_session_payment_bhim -> viewModel.setPaymentMode(ManagerSessionViewModel.PAYMENT_MODE.UPI) | ||
R.id.card_manager_session_payment_card -> viewModel.setPaymentMode(ManagerSessionViewModel.PAYMENT_MODE.CARD) | ||
R.id.card_manager_session_payment_cash -> viewModel.setPaymentMode(ManagerSessionViewModel.PAYMENT_MODE.CASH) | ||
} | ||
|
||
val builder = AlertDialog.Builder(requireContext()).setTitle("Are you sure you want to close session?") | ||
.setNegativeButton("No") { dialog: DialogInterface, _: Int -> dialog.cancel() } | ||
if (!isPromoApplied || isRequestedCheckout) builder.setPositiveButton("Close session") { _: DialogInterface, _: Int -> | ||
viewModel.putSessionCheckout() | ||
dialog?.dismiss() | ||
dismiss() | ||
} else builder.setPositiveButton("Notify waiter") { dialog: DialogInterface?, _: Int -> | ||
viewModel.requestSessionCheckout() | ||
dialog?.dismiss() | ||
dismiss() | ||
} | ||
if (!isPromoApplied && !isRequestedCheckout) | ||
builder.setNeutralButton("Notify waiter") { dialog: DialogInterface?, i: Int -> | ||
viewModel.requestSessionCheckout() | ||
dialog?.dismiss() | ||
dismiss() | ||
|
||
} | ||
builder.show() | ||
} | ||
|
||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
viewModel.sessionInvoice.observe(viewLifecycleOwner, Observer { resource -> | ||
if (resource == null) return@Observer | ||
if (resource.status === Resource.Status.SUCCESS && resource.data != null) { | ||
val total = resource.data.bill.total | ||
tvManagerSessionAmount.text = Utils.formatCurrencyAmount(context, total) | ||
} | ||
}) | ||
} | ||
|
||
companion object { | ||
fun newInstance() = ManagerSessionPaymentOptionsBottomSheetFragment() | ||
|
||
} | ||
} |
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.