Files
lez-programs/apps/token/qml/Main.qml
T

104 lines
2.9 KiB
QML

import QtQuick
import QtQuick.Layouts
import Logos.Theme
import "pages"
import "state"
Item {
id: root
// Backend replica + account model, bridged from the C++ backend.
readonly property var backend: logos.module("token_ui")
readonly property var accountModel: logos.model("token_ui", "accountModel")
property bool ready: false
// Local-only prototype data. It is seeded from the supplied testnet
// deployment record and never performs a chain read or submits a call.
TokenPrototypeStore {
id: tokenPrototypeStore
}
Connections {
target: logos
function onViewModuleReadyChanged(moduleName, isReady) {
if (moduleName === "token_ui")
root.ready = isReady && root.backend !== null;
}
}
Component.onCompleted: {
root.ready = root.backend !== null && logos.isViewModuleReady("token_ui");
}
// Connectivity banner: shown when a wallet is open but its configured
// sequencer doesn't answer reachability probes (so transactions will fail).
Rectangle {
id: connectionBanner
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
z: 101
readonly property bool show: root.ready && root.backend && root.backend.isWalletOpen && root.backend.sequencerAddr.length > 0 && !root.backend.sequencerReachable
height: show ? 32 : 0
visible: height > 0
clip: true
color: Theme.palette.warning
Behavior on height {
NumberAnimation {
duration: 150
easing.type: Easing.OutCubic
}
}
Text {
anchors.centerIn: parent
width: parent.width - 40
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideMiddle
font.pixelSize: 12
font.weight: Font.Medium
color: Theme.palette.background
text: qsTr("Unable to connect to network")
}
}
// The app is always usable; the wallet is opt-in via the navbar "Connect"
// control. Prototype views render immediately and stay local-only.
NavBar {
id: navbar
anchors.top: connectionBanner.bottom
anchors.left: parent.left
anchors.right: parent.right
z: 100
backend: root.ready ? root.backend : null
accountModel: root.accountModel
}
StackLayout {
anchors.top: navbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
currentIndex: navbar.currentIndex
CreatePage {
Layout.fillWidth: true
Layout.fillHeight: true
store: tokenPrototypeStore
}
ManagePage {
Layout.fillWidth: true
Layout.fillHeight: true
store: tokenPrototypeStore
}
}
}