Rework HBox-based pages and account settings

- Refactor everything about HBox, and adapt all the pages and popups
  that used it

- Replace HTabContainer by HTabbedBox

- Make boxes swippable

- Make esc presses in boxes click the cancel button

- Make all boxes and popups scrollable when needed

- Replace generic apply button icons in popups

- Fix tab focus for error and invite popups

- Rework (still WIP) the account settings page:
  - Use the standard tabbed design of other pages
  - Ditch the horizontal profile layout, hacky and impossible to extend
  - Add real-time coloring for the display name field

- Implement a device list in account settings (Sessions, still WIP)
This commit is contained in:
miruka
2020-06-25 08:32:08 -04:00
parent 72bd78c77e
commit da4a5ab5cd
66 changed files with 1594 additions and 1173 deletions

View File

@@ -12,7 +12,6 @@ import sys
import traceback
from contextlib import suppress
from copy import deepcopy
from dataclasses import asdict
from datetime import datetime, timedelta
from functools import partial
from pathlib import Path
@@ -1261,8 +1260,11 @@ class MatrixClient(nio.AsyncClient):
async def devices_info(self) -> List[Dict[str, Any]]:
"""Get list of devices and their info for our user."""
def get_trust(device_id: str) -> str:
# Returns "verified", "blacklisted", "ignored" or "unset"
def get_type(device_id: str) -> str:
# Return "current", "verified", "blacklisted", "ignored" or "unset"
if device_id == self.device_id:
return "current"
if device_id not in self.olm.device_store[self.user_id]:
return "unset"
@@ -1274,19 +1276,27 @@ class MatrixClient(nio.AsyncClient):
{
"id": device.id,
"display_name": device.display_name or "",
"last_seen_ip": device.last_seen_ip or "",
"last_seen_ip": (device.last_seen_ip or "").strip(" -"),
"last_seen_date": device.last_seen_date or ZeroDate,
"last_seen_country": "",
"trusted": get_trust(device.id) == "verified",
"blacklisted": get_trust(device.id) == "blacklisted",
"type": get_type(device.id),
}
for device in (await self.devices()).devices
]
# Reversed due to sorted(reverse=True) call below
types_order = {
"current": 4,
"unset": 3,
"verified": 2,
"ignored": 1,
"blacklisted": 0,
}
# Sort by type, then by descending date
return sorted(
devices,
# The current device will always be first
key = lambda d: (d["id"] == self.device_id, d["last_seen_date"]),
key = lambda d: (types_order[d["type"]], d["last_seen_date"]),
reverse = True,
)