Skip to content

Commit b00e8fa

Browse files
committed
View layout customization
1 parent a25c396 commit b00e8fa

45 files changed

Lines changed: 5117 additions & 103 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Packages/com.walletconnect.web3modal/Resources/WalletConnect/Web3Modal/Components/Modal/Modal.uss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.modal--type-mobile {
1414
position: absolute;
15-
max-height: 90%;
15+
max-height: var(--wui-modal-max-height-mobile);
1616
bottom: 0;
1717
left: 0;
1818
right: 0;
@@ -22,7 +22,7 @@
2222

2323
.modal--type-desktop {
2424
align-self: center;
25-
width: 360px;
25+
width: var(--wui-modal-width-desktop);
2626
}
2727

2828
#modal__body {

Packages/com.walletconnect.web3modal/Runtime/Presenters/DeepLinkPresenter.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class DeepLinkPresenter : Presenter<DeepLinkView>
1919
private string _continueInText;
2020
private bool _isLoadingDeepLink;
2121
private Coroutine _loadingCoroutine;
22+
private bool _disposed;
2223

2324
private const string ContinueInTextTemplate = "Continue in {0}";
2425

@@ -129,5 +130,29 @@ private IEnumerator LoadingRoutine()
129130
StopLoadingCoroutine();
130131
}
131132
#endif
133+
134+
protected override void Dispose(bool disposing)
135+
{
136+
if (_disposed)
137+
return;
138+
139+
if (disposing)
140+
{
141+
#if UNITY_IOS || UNITY_ANDROID
142+
if (_isLoadingDeepLink)
143+
{
144+
StopLoadingCoroutine();
145+
}
146+
#endif
147+
148+
_connectionProposal?.Dispose();
149+
150+
View.CopyLinkClicked -= OnCopyLinkClicked;
151+
View.TryAgainLinkClicked -= OnTryAgainLinkClicked;
152+
}
153+
154+
_disposed = true;
155+
base.Dispose(disposing);
156+
}
132157
}
133158
}

Packages/com.walletconnect.web3modal/Runtime/Presenters/ModalHeaderPresenter.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ModalHeaderPresenter : Presenter<ModalHeader>
1414
private readonly Dictionary<ViewType, VisualElement> _leftSlotItems = new();
1515

1616
private Coroutine _snackbarCoroutine;
17+
private bool _disposed;
1718

1819
public ModalHeaderPresenter(RouterController routerController, Modal parent) : base(routerController, parent)
1920
{
@@ -123,5 +124,21 @@ private void ViewChangedHandler(object _, ViewChangedEventArgs args)
123124
? 1
124125
: 0;
125126
}
127+
128+
protected override void Dispose(bool disposing)
129+
{
130+
if (_disposed)
131+
return;
132+
133+
if (disposing)
134+
{
135+
Router.ViewChanged -= ViewChangedHandler;
136+
Web3Modal.NotificationController.Notification -= NotificationHandler;
137+
Web3Modal.ModalController.OpenStateChanged -= ModalOpenStateChangedHandler;
138+
}
139+
140+
_disposed = true;
141+
base.Dispose(disposing);
142+
}
126143
}
127144
}

Packages/com.walletconnect.web3modal/Runtime/Presenters/NetworkSearchPresenter.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public override string Title
2020

2121
private readonly Dictionary<string, CardSelect> _netowrkItems = new();
2222
private string _highlightedChainId;
23+
private bool _disposed;
2324

2425
public NetworkSearchPresenter(RouterController router, VisualElement parent) : base(router, parent)
2526
{
@@ -140,5 +141,19 @@ private void ConfigureItemPaddings(IList<VisualElement> items = null)
140141
item.style.paddingRight = padding;
141142
}
142143
}
144+
145+
protected override void Dispose(bool disposing)
146+
{
147+
if (_disposed)
148+
return;
149+
150+
if (disposing)
151+
{
152+
Web3Modal.NetworkController.ChainChanged += ChainChangedHandler;
153+
}
154+
155+
_disposed = true;
156+
base.Dispose(disposing);
157+
}
143158
}
144159
}

Packages/com.walletconnect.web3modal/Runtime/Presenters/Presenter.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ protected virtual void Dispose(bool disposing)
7979

8080
protected VisualElement Parent { get; }
8181

82+
private bool _disposed;
83+
8284
public override VisualElement ViewVisualElement
8385
{
8486
get => View;
@@ -114,5 +116,20 @@ protected override void OnHideCore()
114116
protected override void OnDisableCore()
115117
{
116118
}
119+
120+
protected override void Dispose(bool disposing)
121+
{
122+
if (_disposed)
123+
return;
124+
125+
if (disposing)
126+
{
127+
if (View != null)
128+
Parent.Remove(View);
129+
}
130+
131+
_disposed = true;
132+
base.Dispose(disposing);
133+
}
117134
}
118135
}

Packages/com.walletconnect.web3modal/Runtime/Views/AccountView/AccountView.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class AccountView : VisualElement
1515
public static readonly string NameExplorerButton = $"{Name}__explorer-button";
1616
public static readonly string NameCopyLink = $"{Name}__profile-address-copy-link";
1717
public static readonly string NameButtons = $"{Name}__buttons";
18-
18+
1919
public VisualElement Profile { get; }
2020
public Label ProfileAddress { get; }
2121
public Image ProfileAvatarImage { get; }
@@ -24,19 +24,23 @@ public class AccountView : VisualElement
2424
public Button ExplorerButton { get; }
2525
public IconLink CopyLink { get; }
2626
public VisualElement Buttons { get; }
27-
28-
27+
28+
2929
public new class UxmlFactory : UxmlFactory<AccountView>
3030
{
3131
}
3232

33-
public AccountView()
33+
public AccountView() : this(null)
34+
{
35+
}
36+
37+
public AccountView(string visualTreePath)
3438
{
35-
var asset = Resources.Load<VisualTreeAsset>("WalletConnect/Web3Modal/Views/AccountView/AccountView");
39+
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "WalletConnect/Web3Modal/Views/AccountView/AccountView");
3640
asset.CloneTree(this);
3741

3842
name = Name;
39-
43+
4044
Profile = this.Q<VisualElement>(NameProfile);
4145
ProfileAddress = Profile.Q<Label>(NameProfileAddress);
4246
ProfileAvatarImage = Profile.Q<Image>(NameProfileAvatarImage);
@@ -56,7 +60,7 @@ public void SetBalance(string value)
5660
{
5761
ProfileBalanceValue.text = value.FontWeight500();
5862
}
59-
63+
6064
public void SetBalanceSymbol(string value)
6165
{
6266
ProfileBalanceSymbol.text = value.FontWeight500();

Packages/com.walletconnect.web3modal/Runtime/Views/DeepLinkView/DeepLinkView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ public event Action TryAgainLinkClicked
4343
{
4444
}
4545

46-
public DeepLinkView()
46+
public DeepLinkView() : this(null)
4747
{
48-
var asset = Resources.Load<VisualTreeAsset>("WalletConnect/Web3Modal/Views/DeepLinkView/DeepLinkView");
48+
}
49+
50+
public DeepLinkView(string visualTreePath)
51+
{
52+
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "WalletConnect/Web3Modal/Views/DeepLinkView/DeepLinkView");
4953
asset.CloneTree(this);
5054

5155
name = Name;

Packages/com.walletconnect.web3modal/Runtime/Views/NetworkLoadingView/NetworkLoadingView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ public class NetworkLoadingView : VisualElement
1919
public new class UxmlFactory : UxmlFactory<NetworkLoadingView>
2020
{
2121
}
22+
23+
public NetworkLoadingView() : this(null)
24+
{
25+
}
2226

23-
public NetworkLoadingView()
27+
public NetworkLoadingView(string visualTreePath)
2428
{
25-
var asset = Resources.Load<VisualTreeAsset>("WalletConnect/Web3Modal/Views/NetworkLoadingView/NetworkLoadingView");
29+
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "WalletConnect/Web3Modal/Views/NetworkLoadingView/NetworkLoadingView");
2630
asset.CloneTree(this);
2731

2832
name = Name;

Packages/com.walletconnect.web3modal/Runtime/Views/NetworkSearchView/NetworkSearchView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ public class NetworkSearchView : VisualElement
1616
public new class UxmlFactory : UxmlFactory<NetworkSearchView>
1717
{
1818
}
19+
20+
public NetworkSearchView() : this(null)
21+
{
22+
}
1923

20-
public NetworkSearchView()
24+
public NetworkSearchView(string visualTreePath)
2125
{
22-
var asset = Resources.Load<VisualTreeAsset>("WalletConnect/Web3Modal/Views/NetworkSearchView/NetworkSearchView");
26+
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "WalletConnect/Web3Modal/Views/NetworkSearchView/NetworkSearchView");
2327
asset.CloneTree(this);
2428

2529
name = Name;

Packages/com.walletconnect.web3modal/Runtime/Views/QrCodeView/QrCodeView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ public class QrCodeView : VisualElement
2828
public new class UxmlFactory : UxmlFactory<QrCodeView>
2929
{
3030
}
31+
32+
public QrCodeView() : this(null)
33+
{
34+
}
3135

32-
public QrCodeView()
36+
public QrCodeView(string visualTreePath)
3337
{
34-
var asset = Resources.Load<VisualTreeAsset>("WalletConnect/Web3Modal/Views/QrCodeView/QrCodeView");
38+
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "WalletConnect/Web3Modal/Views/QrCodeView/QrCodeView");
3539
asset.CloneTree(this);
3640

3741
name = Name;

0 commit comments

Comments
 (0)