package com.adealink.weparty.module.wallet

import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelStoreOwner
import com.adealink.frame.aab.BaseDynamicModule
import com.adealink.weparty.R
import com.adealink.weparty.module.wallet.data.Currency
import com.adealink.weparty.module.wallet.viewmodel.IWalletViewModel

object WalletModule : BaseDynamicModule<IWalletService>(IWalletService::class),
    IWalletService {

    override val featureName: String
        get() = "wallet"

    override val moduleNameResId: Int
        get() = R.string.module_wallet

    override fun emptyService(): IWalletService {
        return object : IWalletService {

            override fun getService(): IWalletService? {
                return null
            }

            override fun onLogout() {

            }

            override fun init() {
            }

            override fun getBalance(currency: Currency): Double {
                return 0.0
            }

            override fun fetchCurrency() {
            }

            override fun queryAndHandleUnDealPurchases() {
            }

            override fun getWalletViewModel(owner: ViewModelStoreOwner): IWalletViewModel? {
                return null
            }

            override fun showRechargeDialog(
                fm: FragmentManager,
                currency: Currency
            ) {
            }
        }
    }

    override fun init() {
        return getService().init()
    }

    override fun getBalance(currency: Currency): Double {
        return getService().getBalance(currency)
    }

    override fun fetchCurrency() {
        getService().fetchCurrency()
    }

    override fun queryAndHandleUnDealPurchases() {
        getService().queryAndHandleUnDealPurchases()
    }

    override fun getWalletViewModel(owner: ViewModelStoreOwner): IWalletViewModel? {
        return getService().getWalletViewModel(owner)
    }

    override fun showRechargeDialog(
        fm: FragmentManager,
        currency: Currency
    ) {
        getService().showRechargeDialog(fm, currency)
    }

    override fun onLogout() {
        getService().onLogout()
    }
}