|
|
@@ -1,48 +1,60 @@
|
|
|
package com.adealink.weparty.profile.me.comp
|
|
|
|
|
|
import androidx.lifecycle.LifecycleOwner
|
|
|
+import com.adealink.frame.base.fastLazy
|
|
|
import com.adealink.frame.mvvm.view.ViewComponent
|
|
|
-import com.adealink.frame.mvvm.viewmodel.viewModels
|
|
|
-import com.adealink.weparty.module.profile.ProfileModule
|
|
|
-import com.adealink.weparty.module.profile.data.UserInfo
|
|
|
+import com.adealink.frame.util.onClick
|
|
|
+import com.adealink.weparty.module.wallet.WalletModule
|
|
|
+import com.adealink.weparty.module.wallet.data.Currency
|
|
|
import com.adealink.weparty.profile.databinding.LayoutMeWalletBinding
|
|
|
-import com.adealink.weparty.profile.viewmodel.ProfileViewModel
|
|
|
-import com.adealink.weparty.profile.viewmodel.ProfileViewModelFactory
|
|
|
|
|
|
class MeWalletComp(
|
|
|
lifecycleOwner: LifecycleOwner,
|
|
|
val binding: LayoutMeWalletBinding
|
|
|
) : ViewComponent(lifecycleOwner) {
|
|
|
-
|
|
|
- private val profileViewModel by viewModels<ProfileViewModel>(
|
|
|
- ownerProducer = { viewModelStoreOwner },
|
|
|
- factoryProducer = { ProfileViewModelFactory() }
|
|
|
- )
|
|
|
+ private val walletViewModel by fastLazy { WalletModule.getWalletViewModel(requireActivity()) }
|
|
|
|
|
|
override fun onCreate() {
|
|
|
super.onCreate()
|
|
|
initView()
|
|
|
observeViewModel()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
loadData()
|
|
|
}
|
|
|
|
|
|
private fun initView() {
|
|
|
+ binding.clCoin.onClick {
|
|
|
+ goWallet(Currency.COIN)
|
|
|
+ }
|
|
|
+ binding.clDiamond.onClick {
|
|
|
+ goWallet(Currency.DIAMOND)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun observeViewModel() {
|
|
|
- profileViewModel.userInfoLD.observe(viewLifecycleOwner) { user ->
|
|
|
- updateHeader(user)
|
|
|
+ walletViewModel?.coinLD?.observe(viewLifecycleOwner) {
|
|
|
+
|
|
|
+ }
|
|
|
+ walletViewModel?.diamondLD?.observe(viewLifecycleOwner) {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private fun loadData() {
|
|
|
- updateHeader(ProfileModule.getMyUserInfo())
|
|
|
+ walletViewModel?.refreshWalletData()
|
|
|
}
|
|
|
|
|
|
- private fun updateHeader(userInfo: UserInfo?) {
|
|
|
- }
|
|
|
+ private fun goWallet(currency: Currency) {
|
|
|
+ when (currency) {
|
|
|
+ Currency.COIN -> {
|
|
|
|
|
|
- private fun goWallet() {
|
|
|
+ }
|
|
|
|
|
|
+ Currency.DIAMOND -> {
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|