Browse Source

Added verified badge to topbar and profile

master
morethanwords 3 years ago
parent
commit
5ba43daf3e
  1. 11
      src/components/chat/topbar.ts
  2. 19
      src/components/generateVerifiedIcon.ts
  3. 8
      src/components/sidebarRight/tabs/sharedMedia.ts
  4. 28
      src/lib/appManagers/appDialogsManager.ts
  5. 16
      src/scss/partials/_chatTopbar.scss
  6. 7
      src/scss/partials/_chatlist.scss
  7. 20
      src/scss/partials/_profile.scss
  8. 7
      src/scss/style.scss

11
src/components/chat/topbar.ts

@ -40,6 +40,7 @@ import replaceContent from "../../helpers/dom/replaceContent";
import { ChatFull } from "../../layer"; import { ChatFull } from "../../layer";
import PopupPickUser from "../popups/pickUser"; import PopupPickUser from "../popups/pickUser";
import PopupPeer from "../popups/peer"; import PopupPeer from "../popups/peer";
import generateVerifiedIcon from "../generateVerifiedIcon";
export default class ChatTopbar { export default class ChatTopbar {
public container: HTMLDivElement; public container: HTMLDivElement;
@ -600,8 +601,14 @@ export default class ChatTopbar {
}).element; }).element;
} }
this.title.textContent = ''; replaceContent(this.title, titleEl);
this.title.append(titleEl);
if(this.chat.type === 'chat') {
const peer = this.appPeersManager.getPeer(this.peerId);
if(peer?.pFlags?.verified) {
this.title.append(generateVerifiedIcon());
}
}
} }
public setMutedState() { public setMutedState() {

19
src/components/generateVerifiedIcon.ts

@ -0,0 +1,19 @@
export default function generateVerifiedIcon() {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
svg.setAttributeNS(null, 'width', '24');
svg.setAttributeNS(null, 'height', '24');
svg.classList.add('verified-icon');
const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
use.setAttributeNS(null, 'href', '#verified-background');
use.classList.add('verified-background');
const use2 = document.createElementNS('http://www.w3.org/2000/svg', 'use');
use2.setAttributeNS(null, 'href', '#verified-check');
use2.classList.add('verified-check');
svg.append(use, use2);
return svg;
}

8
src/components/sidebarRight/tabs/sharedMedia.ts

@ -49,6 +49,7 @@ import { cancelEvent } from "../../../helpers/dom/cancelEvent";
import { attachClickEvent } from "../../../helpers/dom/clickEvent"; import { attachClickEvent } from "../../../helpers/dom/clickEvent";
import replaceContent from "../../../helpers/dom/replaceContent"; import replaceContent from "../../../helpers/dom/replaceContent";
import appAvatarsManager from "../../../lib/appManagers/appAvatarsManager"; import appAvatarsManager from "../../../lib/appManagers/appAvatarsManager";
import generateVerifiedIcon from "../../generateVerifiedIcon";
let setText = (text: string, row: Row) => { let setText = (text: string, row: Row) => {
//fastRaf(() => { //fastRaf(() => {
@ -722,9 +723,14 @@ class PeerProfile {
replaceContent(this.name, new PeerTitle({ replaceContent(this.name, new PeerTitle({
peerId, peerId,
dialog: true dialog: true,
}).element); }).element);
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) {
this.name.append(generateVerifiedIcon());
}
this.setPeerStatus(true); this.setPeerStatus(true);
} }

28
src/lib/appManagers/appDialogsManager.ts

@ -54,6 +54,7 @@ import { MyDocument } from "./appDocsManager";
import { setSendingStatus } from "../../components/sendingStatus"; import { setSendingStatus } from "../../components/sendingStatus";
import SortedList, { SortedElementBase } from "../../helpers/sortedList"; import SortedList, { SortedElementBase } from "../../helpers/sortedList";
import debounce from "../../helpers/schedulers/debounce"; import debounce from "../../helpers/schedulers/debounce";
import generateVerifiedIcon from "../../components/generateVerifiedIcon";
export type DialogDom = { export type DialogDom = {
avatarEl: AvatarElement, avatarEl: AvatarElement,
@ -1608,13 +1609,12 @@ export class AppDialogsManager {
// в других случаях иконка верификации не нужна (а первый - это главные чатлисты) // в других случаях иконка верификации не нужна (а первый - это главные чатлисты)
//if(!container) { //if(!container) {
const peer = appPeersManager.getPeer(peerId);
// for muted icon // for muted icon
titleSpanContainer.classList.add('tgico'); // * эта строка будет актуальна только для !container, но ладно titleSpanContainer.classList.add('tgico'); // * эта строка будет актуальна только для !container, но ладно
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) { if(peer?.pFlags?.verified) {
titleSpanContainer.classList.add('is-verified');
titleSpanContainer.append(generateVerifiedIcon()); titleSpanContainer.append(generateVerifiedIcon());
} }
//} //}
@ -1717,26 +1717,6 @@ export class AppDialogsManager {
} }
} }
export function generateVerifiedIcon() {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
svg.setAttributeNS(null, 'width', '24');
svg.setAttributeNS(null, 'height', '24');
svg.classList.add('verified-icon');
const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
use.setAttributeNS(null, 'href', '#verified-background');
use.classList.add('verified-background');
const use2 = document.createElementNS('http://www.w3.org/2000/svg', 'use');
use2.setAttributeNS(null, 'href', '#verified-check');
use2.classList.add('verified-check');
svg.append(use, use2);
return svg;
}
const appDialogsManager = new AppDialogsManager(); const appDialogsManager = new AppDialogsManager();
MOUNT_CLASS_TO.appDialogsManager = appDialogsManager; MOUNT_CLASS_TO.appDialogsManager = appDialogsManager;
export default appDialogsManager; export default appDialogsManager;

16
src/scss/partials/_chatTopbar.scss

@ -82,24 +82,18 @@
.user-title { .user-title {
cursor: pointer; cursor: pointer;
font-size: 1rem; font-size: 1rem;
line-height: 24px; line-height: 1.5rem;
max-width: calc(100% - 1.5rem); max-width: calc(100% - 1.5rem);
display: flex;
/* @include respond-to(handhelds) { align-items: center;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
} */
span.emoji { span.emoji {
vertical-align: inherit; vertical-align: inherit;
} }
} }
.user-title, .info { .peer-title, .info {
white-space: nowrap; @include text-overflow();
text-overflow: ellipsis;
overflow: hidden;
line-height: var(--line-height); line-height: var(--line-height);
} }

7
src/scss/partials/_chatlist.scss

@ -373,13 +373,6 @@ ul.chatlist {
margin-left: .125rem; margin-left: .125rem;
} }
} */ } */
.verified-icon {
flex: 0 0 auto;
width: 20px;
height: 20px;
margin-left: .125rem;
}
} }
.user-last-message { .user-last-message {

20
src/scss/partials/_profile.scss

@ -258,26 +258,34 @@
&-name { &-name {
text-align: center; text-align: center;
font-size: 20px; font-size: 1.25rem;
line-height: 1.3125; line-height: var(--line-height);
font-weight: 500; font-weight: 500;
text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
word-break: break-word; max-width: 21.25rem;
max-width: 340px;
margin: 0 auto; margin: 0 auto;
color: var(--primary-text-color); color: var(--primary-text-color);
display: flex;
align-items: flex-end;
span.emoji { span.emoji {
vertical-align: inherit; vertical-align: inherit;
min-width: min-content; min-width: min-content;
} }
.peer-title {
@include text-overflow(false);
}
.verified-icon {
margin-bottom: 3px;
}
} }
&-subtitle { &-subtitle {
text-align: center; text-align: center;
color: var(--secondary-text-color); color: var(--secondary-text-color);
font-size: 14px; font-size: .875rem;
margin-bottom: .875rem; margin-bottom: .875rem;
margin-top: 1px; margin-top: 1px;

7
src/scss/style.scss

@ -1410,3 +1410,10 @@ middle-ellipsis-element {
line-height: 1 !important; line-height: 1 !important;
} }
} }
.verified-icon {
flex: 0 0 auto;
width: 1.25rem;
height: 1.25rem;
margin-left: .125rem;
}

Loading…
Cancel
Save