@@ -5,23 +5,35 @@ import android.os.Bundle
55import android.view.View
66import android.widget.ArrayAdapter
77import androidx.appcompat.app.AlertDialog
8+ import androidx.core.os.bundleOf
89import androidx.fragment.app.DialogFragment
910import cz.muni.fi.rpg.R
11+ import cz.muni.fi.rpg.model.domain.character.CharacterId
1012import cz.muni.fi.rpg.model.domain.character.NotEnoughMoney
1113import cz.muni.fi.rpg.model.domain.common.Money
1214import cz.muni.fi.rpg.ui.common.adapters.SpinnerAdapterWithWidthMatchingSelectedItem
15+ import cz.muni.fi.rpg.ui.common.parcelableArgument
1316import cz.muni.fi.rpg.ui.views.TextInput
1417import cz.muni.fi.rpg.viewModels.InventoryViewModel
1518import kotlinx.android.synthetic.main.dialog_transaction.view.*
1619import kotlinx.coroutines.CoroutineScope
1720import kotlinx.coroutines.Dispatchers
1821import kotlinx.coroutines.launch
1922import kotlinx.coroutines.withContext
23+ import org.koin.android.viewmodel.ext.android.viewModel
24+ import org.koin.core.parameter.parametersOf
2025
21- class TransactionDialog (
22- private val viewModel : InventoryViewModel
23- ) : DialogFragment(),
24- CoroutineScope by CoroutineScope (Dispatchers .Default ) {
26+ class TransactionDialog : DialogFragment (), CoroutineScope by CoroutineScope(Dispatchers .Default ) {
27+ companion object {
28+ const val ARGUMENT_CHARACTER_ID = " characterId"
29+
30+ fun newInstance (characterId : CharacterId ) = TransactionDialog ().apply {
31+ arguments = bundleOf(ARGUMENT_CHARACTER_ID to characterId)
32+ }
33+ }
34+
35+ private val characterId: CharacterId by parcelableArgument(ARGUMENT_CHARACTER_ID )
36+ private val viewModel: InventoryViewModel by viewModel { parametersOf(characterId) }
2537
2638 override fun onCreateDialog (savedInstanceState : Bundle ? ): Dialog {
2739 val activity = requireActivity()
0 commit comments