Skip to content

Commit

Permalink
Refactor AnkrSDK examples: UI refactoring finished (#107)
Browse files Browse the repository at this point in the history
* refactor wc scenes wip

* test scene adjusted to scale for both portrait and landscape mode

* demo root scene buttons adjusted

* ugui tools removed

* ConnectionController adjusted

* can send request inversed logic bug bug

* logical inversion

* wc2 replaced to 2c where needed

* demo screen update

* method name bugfix for updateChain

* logging improvement for test cases

* rinkeby changed to goerli

* nft contract examples refactoring wip

* comment contracts

* Wallet connect 2 docs (#106)

* migration to 0.6.0 breaking changes migration guide

* migration from wc1 to wc2 doc

* docs update

* Update migration-from-wc1-to-wc2.md

* Update migration-from-wc1-to-wc2.md

* hex extension usage fix

* minor comment fix

* Remove wc2 in a single commit (#108)

* hex extension usage fix

* minor comment fix

* wallet connect 2 single commit removal

* all related active flags renamed to isActive
  • Loading branch information
Antivortex authored Mar 16, 2023
1 parent fc4bceb commit 4ccf74a
Show file tree
Hide file tree
Showing 175 changed files with 1,327 additions and 5,898 deletions.
3 changes: 1 addition & 2 deletions Assets/AnkrSDK/Examples/AnkrSDK.Examples.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"WalletConnectSharp.Core",
"WalletConnectSharp.Unity",
"WalletConnectSharp.VersionShared",
"Unity.TextMeshPro",
"AnkrSDK.WalletConnect2"
"Unity.TextMeshPro"
]
}
7 changes: 7 additions & 0 deletions Assets/AnkrSDK/Examples/Base/IUseCaseUIController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace AnkrSDK.Base
{
public interface IUseCaseUIController
{
void SetUseCaseButtonsActive(bool isActive);
}
}
3 changes: 3 additions & 0 deletions Assets/AnkrSDK/Examples/Base/IUseCaseUIController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions Assets/AnkrSDK/Examples/Base/UseCase.cs

This file was deleted.

12 changes: 12 additions & 0 deletions Assets/AnkrSDK/Examples/Base/UseCaseBodyUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

namespace AnkrSDK.Base
{
public abstract class UseCaseBodyUI : MonoBehaviour
{
public virtual void SetUseCaseBodyActive(bool isActive)
{
gameObject.SetActive(isActive);
}
}
}
22 changes: 11 additions & 11 deletions Assets/AnkrSDK/Examples/Base/UseCaseUI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using UnityEngine;
using UnityEngine.UI;

Expand All @@ -7,18 +6,20 @@ namespace AnkrSDK.Base
public class UseCaseUI : MonoBehaviour
{
[SerializeField] private Button _selectButton;

[SerializeField] private Button _backButton;

[SerializeField] private UseCase _useCase;
[SerializeField] private UseCaseBodyUI _useCase;

public Button SelectButton => _selectButton;

public Button BackButton => _backButton;
public UseCaseBodyUI UseCase => _useCase;

public UseCase UseCase => _useCase;
private IUseCaseUIController _uiController;

public event Action<bool> OnButtonClickedEvent;
public void Setup(IUseCaseUIController uiController)
{
_uiController = uiController;
}

private void Awake()
{
Expand All @@ -44,15 +45,14 @@ private void UnsubscribeButtonLinks()

private void OnBackButtonClicked()
{
OnButtonClickedEvent?.Invoke(true);
UseCase.DeActivateUseCase();
UseCase.SetUseCaseBodyActive(false);
_uiController.SetUseCaseButtonsActive(true);
}

private void OnSelectButtonClicked()
{
UseCase.ActivateUseCase();

OnButtonClickedEvent?.Invoke(false);
UseCase.SetUseCaseBodyActive(true);
_uiController.SetUseCaseButtonsActive(false);
}
}
}
31 changes: 5 additions & 26 deletions Assets/AnkrSDK/Examples/Base/UseCaseUIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,21 @@

namespace AnkrSDK.Base
{
public class UseCaseUIHandler : MonoBehaviour
public class UseCaseUIHandler : MonoBehaviour, IUseCaseUIController
{
[SerializeField] private List<UseCaseUI> _useCaseUIs;

private void Awake()
{
SubscribeToEvents();
}

private void OnDestroy()
{
UnsubscribeToEvents();
}

private void SubscribeToEvents()
{
foreach (var useCaseUI in _useCaseUIs)
foreach (var useCaseUi in _useCaseUIs)
{
useCaseUI.OnButtonClickedEvent += SetButtonsActive;
}
}

private void UnsubscribeToEvents()
{
foreach (var useCaseUI in _useCaseUIs)
{
useCaseUI.OnButtonClickedEvent -= SetButtonsActive;
useCaseUi.Setup(this);
}
}

private void SetButtonsActive(bool isActive)
public void SetUseCaseButtonsActive(bool isActive)
{
foreach (var useCaseUI in _useCaseUIs)
{
useCaseUI.SelectButton.gameObject.SetActive(isActive);
}
_useCaseUIs.ForEach(item => item.SelectButton.gameObject.SetActive(isActive));
}
}
}
Loading

0 comments on commit 4ccf74a

Please sign in to comment.