New compose UX for usernames/e164
Co-authored-by: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com>
This commit is contained in:
parent
e69826dcc6
commit
a329189489
42 changed files with 19223 additions and 142 deletions
|
@ -12,7 +12,6 @@ import { SearchInput } from '../SearchInput';
|
|||
import type { LocalizerType } from '../../types/Util';
|
||||
import type { ParsedE164Type } from '../../util/libphonenumberInstance';
|
||||
import { parseAndFormatPhoneNumber } from '../../util/libphonenumberInstance';
|
||||
import { missingCaseError } from '../../util/missingCaseError';
|
||||
import { getUsernameFromSearch } from '../../types/Username';
|
||||
import type { UUIDFetchStateType } from '../../util/uuidFetchState';
|
||||
import {
|
||||
|
@ -30,9 +29,9 @@ export type LeftPaneComposePropsType = {
|
|||
uuidFetchState: UUIDFetchStateType;
|
||||
};
|
||||
|
||||
enum TopButton {
|
||||
None,
|
||||
CreateNewGroup,
|
||||
enum TopButtons {
|
||||
None = 'None',
|
||||
Visible = 'Visible',
|
||||
}
|
||||
|
||||
export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsType> {
|
||||
|
@ -146,8 +145,8 @@ export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsTy
|
|||
|
||||
getRowCount(): number {
|
||||
let result = this.composeContacts.length + this.composeGroups.length;
|
||||
if (this.hasTopButton()) {
|
||||
result += 1;
|
||||
if (this.hasTopButtons()) {
|
||||
result += 3;
|
||||
}
|
||||
if (this.hasContactsHeader()) {
|
||||
result += 1;
|
||||
|
@ -167,20 +166,18 @@ export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsTy
|
|||
|
||||
getRow(actualRowIndex: number): undefined | Row {
|
||||
let virtualRowIndex = actualRowIndex;
|
||||
if (this.hasTopButton()) {
|
||||
if (this.hasTopButtons()) {
|
||||
if (virtualRowIndex === 0) {
|
||||
const topButton = this.getTopButton();
|
||||
switch (topButton) {
|
||||
case TopButton.None:
|
||||
break;
|
||||
case TopButton.CreateNewGroup:
|
||||
return { type: RowType.CreateNewGroup };
|
||||
default:
|
||||
throw missingCaseError(topButton);
|
||||
}
|
||||
return { type: RowType.CreateNewGroup };
|
||||
}
|
||||
if (virtualRowIndex === 1) {
|
||||
return { type: RowType.FindByUsername };
|
||||
}
|
||||
if (virtualRowIndex === 2) {
|
||||
return { type: RowType.FindByPhoneNumber };
|
||||
}
|
||||
|
||||
virtualRowIndex -= 1;
|
||||
virtualRowIndex -= 3;
|
||||
}
|
||||
|
||||
if (this.hasContactsHeader()) {
|
||||
|
@ -303,15 +300,15 @@ export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsTy
|
|||
);
|
||||
}
|
||||
|
||||
private getTopButton(): TopButton {
|
||||
private getTopButtons(): TopButtons {
|
||||
if (this.searchTerm) {
|
||||
return TopButton.None;
|
||||
return TopButtons.None;
|
||||
}
|
||||
return TopButton.CreateNewGroup;
|
||||
return TopButtons.Visible;
|
||||
}
|
||||
|
||||
private hasTopButton(): boolean {
|
||||
return this.getTopButton() !== TopButton.None;
|
||||
private hasTopButtons(): boolean {
|
||||
return this.getTopButtons() !== TopButtons.None;
|
||||
}
|
||||
|
||||
private hasContactsHeader(): boolean {
|
||||
|
@ -337,9 +334,9 @@ export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsTy
|
|||
|
||||
let rowCount = 0;
|
||||
|
||||
if (this.hasTopButton()) {
|
||||
if (this.hasTopButtons()) {
|
||||
top = 0;
|
||||
rowCount += 1;
|
||||
rowCount += 3;
|
||||
}
|
||||
if (this.hasContactsHeader()) {
|
||||
contact = rowCount;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue