From ef9c2945577e732d88169b619d0e534db3ef43ca Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Thu, 20 Jan 2022 13:46:01 +0100 Subject: [PATCH] Add Avatar To Account Info --- .../components/settings-view/account-view.js | 88 +++++++++++-------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/qortal-ui-core/src/components/settings-view/account-view.js b/qortal-ui-core/src/components/settings-view/account-view.js index edc567bc..7bf14536 100644 --- a/qortal-ui-core/src/components/settings-view/account-view.js +++ b/qortal-ui-core/src/components/settings-view/account-view.js @@ -1,8 +1,13 @@ -import { LitElement, html, css } from 'lit-element' -import { connect } from 'pwa-helpers' -import { store } from '../../store.js' +import { LitElement, html, css } from 'lit-element'; +import { connect } from 'pwa-helpers'; +import { store } from '../../store.js'; class AccountView extends connect(store)(LitElement) { + static get properties() { + return { + accountInfo: { type: Object } + } + } static get styles() { return css` @@ -21,8 +26,8 @@ class AccountView extends connect(store)(LitElement) { } .img-icon { - font-size: 150px; display: block; + margin-top: 10px; } .content-box { @@ -30,7 +35,6 @@ class AccountView extends connect(store)(LitElement) { padding: 10px 25px; text-align: left; display: inline-block; - /* min-width: 350px; */ } .title { @@ -46,49 +50,61 @@ class AccountView extends connect(store)(LitElement) { display: inline-block; } - .start-chat { - display: inline-flex; - flex-direction: column; - justify-content: center; - align-content: center; - border: none; - border-radius: 20px; - padding-left: 25px; - padding-right: 25px; - color: white; - background: #6a6c75; - width: 50%; - font-size: 17px; - cursor: pointer; - height: 50px; - margin-top: 1rem; - text-transform: uppercase; - text-decoration: none; - transition: all .2s; - position: relative; + #accountName { + margin: 0; + font-size: 24px; + font-weight:500; + display: inline-block; + width:100%; } ` } + constructor() { + super() + this.accountInfo = { names: [], addressInfo: {} }; + } + render() { return html` -
-
- account_circle -
- Address: - ${store.getState().app.selectedAddress.address} -
- Public Key: - ${store.getState().app.selectedAddress.base58PublicKey} -
+
+
+
${this.getAvatar()}
+ + ${this.accountInfo.names.length !== 0 ? this.accountInfo.names[0].name : 'No Registered Name'} + +
+ Address: + ${store.getState().app.selectedAddress.address} +
+ Public Key: + ${store.getState().app.selectedAddress.base58PublicKey}
+
` } stateChanged(state) { - // ... + this.accountInfo = state.app.accountInfo + } + + getAvatar() { + let numberBlocks = (this.accountInfo.addressInfo.blocksMinted + this.accountInfo.addressInfo.blocksMintedAdjustment); + if (Number.isNaN(numberBlocks) || numberBlocks == "" || numberBlocks === null) { + return html`` + } else { + const avatarNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node] + const avatarUrl = avatarNode.protocol + '://' + avatarNode.domain + ':' + avatarNode.port + const url = `${avatarUrl}/arbitrary/THUMBNAIL/${this.accountInfo.names[0].name}/qortal_avatar?apiKey=${this.getApiKey()}` + return html`` + } + } + + getApiKey() { + const apiNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]; + let apiKey = apiNode.apiKey; + return apiKey; } }