status-desktop/ui/app/AppMain.qml

259 lines
7.6 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../imports"
2020-06-23 18:59:16 +00:00
import "../shared"
import "../shared/status"
import "./AppLayouts"
import "./AppLayouts/Wallet"
RowLayout {
id: appMain
spacing: 0
2020-05-13 14:40:51 +00:00
Layout.fillHeight: true
Layout.fillWidth: true
ToastMessage {
id: toastMessage
}
// Add SenmdModal here as it is used by the Wallet as well as the Browser
Loader {
id: sendModal
function open() {
this.active = true
this.item.open()
}
function closed() {
// this.sourceComponent = undefined // kill an opened instance
this.active = false
}
sourceComponent: SendModal {
onOpened: {
walletModel.getGasPricePredictions()
}
onClosed: {
sendModal.closed()
}
}
}
Action {
shortcut: "Ctrl+1"
onTriggered: changeAppSection(Constants.chat)
}
Action {
shortcut: "Ctrl+2"
onTriggered: changeAppSection(Constants.browser)
}
Action {
shortcut: "Ctrl+3"
onTriggered: changeAppSection(Constants.wallet)
}
Action {
shortcut: "Ctrl+4, Ctrl+,"
onTriggered: changeAppSection(Constants.profile)
}
function changeAppSection(section) {
let sectionId = -1
switch (section) {
case Constants.chat: sectionId = 0; break;
case Constants.wallet: sectionId = 1; break;
case Constants.browser: sectionId = 2; break;
case Constants.profile: sectionId = 3; break;
case Constants.node: sectionId = 4; break;
case Constants.ui: sectionId = 5; break;
}
if (sectionId === -1) {
throw new Exception ("Unknown section name. Check the Constants to know the available ones")
}
tabBar.setCurrentIndex(sectionId)
}
TabBar {
id: tabBar
2020-06-23 18:59:16 +00:00
width: 78
2020-05-13 14:40:51 +00:00
Layout.maximumWidth: 80
Layout.preferredWidth: 80
Layout.minimumWidth: 80
currentIndex: 0
topPadding: 57
rightPadding: 19
leftPadding: 19
transformOrigin: Item.Top
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
spacing: 5
background: Rectangle {
color: "#00000000"
border.color: Style.current.border
}
StatusIconTabButton {
id: chatBtn
anchors.horizontalCenter: parent.horizontalCenter
icon.name: "message"
anchors.topMargin: 0
Rectangle {
visible: chatsModel.unreadMessagesCount > 0
anchors.top: parent.top
anchors.left: parent.right
anchors.leftMargin: -10
anchors.topMargin: -5
radius: width / 2
color: Style.current.blue
width: chatsModel.unreadMessagesCount < 10 ? 18 : messageCount.width + 10
height: 18
Text {
id: messageCount
font.pixelSize: chatsModel.unreadMessagesCount > 99 ? 10 : 12
color: Style.current.white
anchors.centerIn: parent
2020-12-02 19:28:13 +00:00
text: chatsModel.unreadMessagesCount > 99 ? "99+" : chatsModel.unreadMessagesCount
}
}
}
StatusIconTabButton {
id: walletBtn
anchors.top: chatBtn.top
enabled: isExperimental === "1" || appSettings.walletEnabled
icon.name: "wallet"
}
StatusIconTabButton {
id: browserBtn
anchors.top: walletBtn.top
enabled: isExperimental === "1" || appSettings.browserEnabled
icon.name: "compass"
2020-09-22 15:12:48 +00:00
}
StatusIconTabButton {
id: profileBtn
anchors.top: browserBtn.top
icon.name: "profile"
2020-10-26 20:20:31 +00:00
Rectangle {
id: profileBadge
2020-12-06 22:15:51 +00:00
visible: !profileModel.mnemonic.isBackedUp && sLayout.children[sLayout.currentIndex] !== profileLayoutContainer
anchors.top: parent.top
anchors.left: parent.right
2020-10-26 20:20:31 +00:00
anchors.leftMargin: -10
anchors.topMargin: -5
radius: width / 2
2020-10-26 20:20:31 +00:00
color: Style.current.blue
width: 18
height: 18
Text {
font.pixelSize: 12
color: Style.current.white
anchors.centerIn: parent
text: "1"
}
}
}
StatusIconTabButton {
id: nodeBtn
enabled: isExperimental === "1"
anchors.top: profileBtn.top
icon.name: "node"
}
2020-08-25 09:00:03 +00:00
StatusIconTabButton {
id: uiComponentBtn
enabled: isExperimental === "1"
anchors.top: nodeBtn.top
icon.name: "node"
2020-08-25 09:00:03 +00:00
}
}
StackLayout {
2020-10-26 20:20:31 +00:00
id: sLayout
2020-05-13 14:40:51 +00:00
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
currentIndex: tabBar.currentIndex
onCurrentIndexChanged: {
if (typeof this.children[currentIndex].onActivated === "function") {
this.children[currentIndex].onActivated()
}
if(this.children[currentIndex] === browserLayoutContainer && browserLayoutContainer.active == false){
browserLayoutContainer.active = true;
}
if(this.children[currentIndex] === chatLayoutContainer){
chatLayoutContainer.chatColumn.chatMessages.chatLogView.scrollToBottom(true);
}
2020-11-27 16:21:15 +00:00
if(this.children[currentIndex] === walletLayoutContainer){
walletLayoutContainer.showSigningPhrasePopup();
}
}
ChatLayout {
id: chatLayoutContainer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
}
2020-05-13 18:17:18 +00:00
WalletLayout {
id: walletLayoutContainer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
}
Component {
id: browserLayoutComponent
BrowserLayout { }
}
Loader {
2020-09-22 15:12:48 +00:00
id: browserLayoutContainer
sourceComponent: browserLayoutComponent
active: false
2020-09-22 15:12:48 +00:00
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
// Loaders do not have access to the context, so props need to be set
// Adding a "_" to avoid a binding loop
property var _chatsModel: chatsModel
property var _walletModel: walletModel
property var _utilsModel: utilsModel
property var _web3Provider: web3Provider
2020-09-22 15:12:48 +00:00
}
feat: layouts for the Profile screens Work on this PR started before the build system was updated and at one point I upgraded `nim_status_client.nimble` to use NimScript so the nimble command would stop warning that the old format was being used. In team chat it was discussed that since we're no longer using nimble for package management we could simply delete `nim_status_client.nimble` to avoid confusion, which can be done in another PR. Introduce a BrowserLayout stub so the index will be calcualted correctly re: the active tab. Reorganize ChatLayout and NodeLayout into subdirs `Chat` and `Node`, respectively. Introduce ProfileLayout which uses a "LeftTab" approach similar to that of WalletLayout. There remains quite a bit of styling work to be done in ProfileLayout and its LeftTab. Also, it may be better to start over using a SplitView like the ChatLayout, I'm not really sure. It wasn't clear what should be the default view for the right-pane when Profile is selected in the left-most TabBar. In this PR, it defaults to showing the view corresponding to the ENS usernames button. In the archived Figma for the desktop design, it seemed a picture could be set, e.g. there is a headshot of a woman used in the Profile screen. To that end I explored how to take a square image and clip/mask it so it appears round and I included a larger placeholder image for that purpose. In the new design, and with respect to mobile, it may not be possible to set a profile picture so the code that rounds the image can maybe be dropped.
2020-05-19 19:44:45 +00:00
ProfileLayout {
id: profileLayoutContainer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
}
NodeLayout {
id: nodeLayoutContainer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
}
2020-08-25 09:00:03 +00:00
UIComponents {
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
}
}
}
/*##^##
Designer {
D{i:0;formeditorZoom:0.33000001311302185;height:770;width:1232}
}
##^##*/