Skip to content

Commit

Permalink
AccountView → AccountSettingsView
Browse files Browse the repository at this point in the history
  • Loading branch information
skibitsky committed Jan 29, 2025
1 parent dbf8afa commit 6ddf588
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 55 deletions.
19 changes: 19 additions & 0 deletions sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,24 @@ public static void SessionProps()
});
Debug.Log(json);
}

[ConsoleMethod("session", "Prints active session")]
public static void Session()
{
var walletConnect = AppKit.ConnectorController.ActiveConnector as WalletConnectConnector;
var session = walletConnect.SignClient.AddressProvider.DefaultSession;

if (session == null)
{
Debug.Log("No active session found");
return;
}

var json = JsonConvert.SerializeObject(session, new JsonSerializerSettings
{
Formatting = Formatting.Indented
});
Debug.Log(json);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 1.2.0
bundleVersion: 1.3.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#account-view__profile {
#account-settings-view__profile {
display: flex;
flex-direction: column;
align-items: center;
Expand All @@ -7,7 +7,7 @@
margin-top: -12px;
}

#account-view__profile-avatar {
#account-settings-view__profile-avatar {
width: 75px;
height: 75px;
border-radius: 100%;
Expand All @@ -17,12 +17,12 @@
align-items: center;
}

#account-view__profile-avatar-image {
#account-settings-view__profile-avatar-image {
width: 110%;
height: 110%;
}

#account-view__profile-address {
#account-settings-view__profile-address {
margin-top: 10px;
margin-left: 22px;
padding: 0;
Expand All @@ -31,11 +31,11 @@
font-size: var(--ro-font-size-medium-title);
}

#account-view__profile-balance-container {
#account-settings-view__profile-balance-container {
flex-direction: row;
}

#account-view__profile-balance-container > Label {
#account-settings-view__profile-balance-container > Label {
margin-top: 2px;
padding: 0;
-unity-text-align: middle-center;
Expand All @@ -47,27 +47,27 @@
margin-top: 12px;
}

#account-view__profile-address-container {
#account-settings-view__profile-address-container {
display: flex;
flex-direction: row;
}

#account-view__explorer-button-text {
#account-settings-view__explorer-button-text {
margin: 0 6 0 6px;
padding: 0;
-unity-text-align: middle-center;
}

#account-view__explorer-button-icon-left {
#account-settings-view__explorer-button-icon-left {
--unity-image: resource('Reown/AppKit/Icons/icon_medium_compass');
}

#account-view__explorer-button-icon-right {
#account-settings-view__explorer-button-icon-right {
width: 8px;
height: 8px;
--unity-image: resource('Reown/AppKit/Icons/icon_bold_externallink');
}

#account-view__profile-address-copy-link-container {
#account-settings-view__profile-address-copy-link-container {
justify-content: flex-end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<Style src="AccountSettingsView.uss"/>
<ui:VisualElement name="account-settings-view__profile">
<ui:VisualElement name="account-settings-view__profile-avatar">
<ui:Image name="account-settings-view__profile-avatar-image"/>
</ui:VisualElement>
<ui:VisualElement name="account-settings-view__profile-address-container">
<ui:Label name="account-settings-view__profile-address"/>
<ui:VisualElement name="account-settings-view__profile-address-copy-link-container">
<Reown.AppKit.Unity.Components.IconLink name="account-settings-view__profile-address-copy-link"
icon="Reown/AppKit/Icons/icon_bold_copy"
variant="Shade"
/>
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="account-settings-view__profile-balance-container">
<ui:Label name="account-settings-view__profile-balance-value"/>
<ui:Label name="account-settings-view__profile-balance-symbol"/>
</ui:VisualElement>
<ui:VisualElement name="account-explorer-button-container">
<Reown.AppKit.Unity.Components.Button name="account-settings-view__explorer-button" size="Small" variant="Shade">
<ui:Image name="account-settings-view__explorer-button-icon-left"/>
<ui:Label name="account-settings-view__explorer-button-text"
text="&lt;font-weight=600&gt;Block Explorer&lt;/font-weight&gt;" class="text-small"/>
<ui:Image name="account-settings-view__explorer-button-icon-right"/>
</Reown.AppKit.Unity.Components.Button>
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="account-settings-view__buttons"/>
</ui:UXML>

This file was deleted.

13 changes: 11 additions & 2 deletions src/Reown.AppKit.Unity/Runtime/AppKitCore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Threading.Tasks;
using Reown.AppKit.Unity.Components;
using Reown.AppKit.Unity.Profile;
using Reown.AppKit.Unity.Utils;
using Reown.Sign.Models;
using Reown.Sign.Unity;
Expand Down Expand Up @@ -67,9 +69,16 @@ await Task.WhenAll(

protected override void OpenModalCore(ViewType viewType = ViewType.None)
{
if (viewType == ViewType.None)
if (viewType is ViewType.None or ViewType.Account)
{
ModalController.Open(IsAccountConnected ? ViewType.Account : ViewType.Connect);
if (!IsAccountConnected)
{
ModalController.Open(ViewType.Connect);
return;
}

var isConnectedToReownWallet = ConnectorController.ActiveConnector is ProfileConnector;
ModalController.Open(isConnectedToReownWallet ? ViewType.AccountPortfolio : ViewType.AccountSettings);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Reown.AppKit.Unity/Runtime/Chain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static class Chains
public static readonly Chain Optimism = new(
Namespaces.Evm,
References.Optimism,
"Optimism",
"OP Mainnet",
new Currency("Ether", "ETH", 18),
new BlockExplorer("Optimistic Etherscan", "https://optimistic.etherscan.io"),
"https://mainnet.optimism.io",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public enum ViewType
NetworkSearch,
NetworkLoading,
Siwe,
WebWallet
WebWallet,
AccountSettings,
AccountPortfolio
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void RegisterDefaultModalViews()
RegisterModalView(ViewType.QrCode, new QrCodePresenter(this, RootVisualElement));
RegisterModalView(ViewType.Wallet, new WalletPresenter(this, RootVisualElement));
RegisterModalView(ViewType.WalletSearch, new WalletSearchPresenter(this, RootVisualElement));
RegisterModalView(ViewType.Account, new AccountPresenter(this, RootVisualElement));
RegisterModalView(ViewType.AccountSettings, new AccountSettingsPresenter(this, RootVisualElement));
RegisterModalView(ViewType.NetworkSearch, new NetworkSearchPresenter(this, RootVisualElement));
RegisterModalView(ViewType.NetworkLoading, new NetworkLoadingPresenter(this, RootVisualElement));
RegisterModalView(ViewType.WebWallet, new WebWalletPresenter(this, RootVisualElement));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Reown.AppKit.Unity
{
public class AccountPresenter : Presenter<AccountView>
public class AccountSettingsPresenter : Presenter<AccountSettingsView>
{
public override bool HeaderBorder
{
Expand All @@ -28,7 +28,7 @@ public override bool HeaderBorder

private ProfileConnector _profileConnector;

public AccountPresenter(RouterController router, VisualElement parent) : base(router, parent)
public AccountSettingsPresenter(RouterController router, VisualElement parent) : base(router, parent)
{
View.ExplorerButton.Clicked += OnBlockExplorerButtonClick;
View.CopyLink.Clicked += OnCopyAddressButtonClick;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Reown.AppKit.Unity.Components
{
public class AccountView : VisualElement
public class AccountSettingsView : VisualElement
{
public const string Name = "account-view";
public const string Name = "account-settings-view";
public static readonly string NameProfile = $"{Name}__profile";
public static readonly string NameProfileAddress = $"{Name}__profile-address";
public static readonly string NameProfileAvatarImage = $"{Name}__profile-avatar-image";
Expand All @@ -26,17 +26,17 @@ public class AccountView : VisualElement
public VisualElement Buttons { get; }


public new class UxmlFactory : UxmlFactory<AccountView>
public new class UxmlFactory : UxmlFactory<AccountSettingsView>
{
}

public AccountView() : this(null)
public AccountSettingsView() : this(null)
{
}

public AccountView(string visualTreePath)
public AccountSettingsView(string visualTreePath)
{
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "Reown/AppKit/Views/AccountView/AccountView");
var asset = Resources.Load<VisualTreeAsset>(visualTreePath ?? "Reown/AppKit/Views/AccountSettingsView/AccountSettingsView");
asset.CloneTree(this);

name = Name;
Expand Down

0 comments on commit 6ddf588

Please sign in to comment.