| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UIComponents.Scripts.Components; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Wallet |
| | 8 | | { |
| | 9 | | public class WalletCardHUDComponentView : BaseComponentView<WalletCardHUDModel>, IWalletCardHUDComponentView |
| | 10 | | { |
| | 11 | | [SerializeField] internal Button guestButton; |
| | 12 | | [SerializeField] internal Button signedInWalletButton; |
| | 13 | | [SerializeField] internal GameObject ethereumManaBalanceLoading; |
| | 14 | | [SerializeField] internal TMP_Text ethereumManaBalanceText; |
| | 15 | | [SerializeField] internal GameObject polygonManaBalanceLoading; |
| | 16 | | [SerializeField] internal TMP_Text polygonManaBalanceText; |
| | 17 | |
|
| | 18 | | public event Action OnWalletCardClicked; |
| | 19 | |
|
| | 20 | | public override void Awake() |
| | 21 | | { |
| 43 | 22 | | base.Awake(); |
| | 23 | |
|
| 44 | 24 | | guestButton.onClick.AddListener(() => OnWalletCardClicked?.Invoke()); |
| 44 | 25 | | signedInWalletButton.onClick.AddListener(() => OnWalletCardClicked?.Invoke()); |
| 43 | 26 | | } |
| | 27 | |
|
| | 28 | | public override void Dispose() |
| | 29 | | { |
| 57 | 30 | | guestButton.onClick.RemoveAllListeners(); |
| 57 | 31 | | signedInWalletButton.onClick.RemoveAllListeners(); |
| | 32 | |
|
| 57 | 33 | | base.Dispose(); |
| 57 | 34 | | } |
| | 35 | |
|
| | 36 | | public override void RefreshControl() |
| | 37 | | { |
| 0 | 38 | | SetWalletCardAsGuest(model.IsGuest); |
| 0 | 39 | | SetEthereumManaBalance(model.EthereumManaBalance); |
| 0 | 40 | | SetPolygonManaBalance(model.PolygonManaBalance); |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | public void SetWalletCardActive(bool isActive) => |
| 2 | 44 | | gameObject.SetActive(isActive); |
| | 45 | |
|
| | 46 | | public void SetWalletCardAsGuest(bool isGuest) |
| | 47 | | { |
| 2 | 48 | | model.IsGuest = isGuest; |
| 2 | 49 | | guestButton.gameObject.SetActive(isGuest); |
| 2 | 50 | | signedInWalletButton.gameObject.SetActive(!isGuest); |
| 2 | 51 | | } |
| | 52 | |
|
| | 53 | | public void SetEthereumManaLoadingActive(bool isActive) |
| | 54 | | { |
| 2 | 55 | | ethereumManaBalanceText.gameObject.SetActive(!isActive); |
| 2 | 56 | | ethereumManaBalanceLoading.SetActive(isActive); |
| 2 | 57 | | } |
| | 58 | |
|
| | 59 | | public void SetEthereumManaBalance(double balance) |
| | 60 | | { |
| 2 | 61 | | model.EthereumManaBalance = balance; |
| 2 | 62 | | ethereumManaBalanceText.text = WalletUtils.FormatBalanceToString(balance); |
| 2 | 63 | | } |
| | 64 | |
|
| | 65 | | public void SetPolygonManaLoadingActive(bool isActive) |
| | 66 | | { |
| 2 | 67 | | polygonManaBalanceText.gameObject.SetActive(!isActive); |
| 2 | 68 | | polygonManaBalanceLoading.SetActive(isActive); |
| 2 | 69 | | } |
| | 70 | |
|
| | 71 | | public void SetPolygonManaBalance(double balance) |
| | 72 | | { |
| 2 | 73 | | model.PolygonManaBalance = balance; |
| 2 | 74 | | polygonManaBalanceText.text = WalletUtils.FormatBalanceToString(balance); |
| 2 | 75 | | } |
| | 76 | | } |
| | 77 | | } |