lez-programs/apps/amm/qml/NavBar.qml
r4bbit 2b3ecadfaa
feat(amm): wire the AMM app to the LEZ wallet module
Turns the dummy-data AMM UI into a real client of the on-chain LEZ wallet.
Adds a hand-written ui_qml C++ backend (src/AmmUi*) over the core
logos_execution_zone module: create/open a local wallet, create and list
public/private accounts, and a navbar Connect / Connected + account-selector
+ Disconnect flow. Onboarding is password-only (no path picking) with a
per-app wallet at ~/.lee/amm-wallet (override: AMM_WALLET_HOME_DIR);
standalone gets its own wallet, Basecamp shares accounts via adopt-on-start.

Requires Nix with flakes; macOS also needs `sandbox = false` (the default).
The logos_execution_zone input is pinned to a module rev whose LEZ (lssa)
already includes the macOS Metal-build fix, so no `--override-input` is
needed — plain `nix run .` works:

    cd apps/amm
    nix run .

- create_new now returns the new wallet's BIP39 mnemonic (not an int status);
  the app currently discards it, so the wallet can't yet be recovered. Surfacing
  it in onboarding (+ restore_storage) is a follow-up.
- The wallet password is currently a no-op upstream (storage.rs: "TODO: use
  password for storage encryption"); storage.json is plaintext. So Disconnect
  is a UI-level lock and reconnect does not (cannot yet) re-prompt for it.
- wallet-ffi requires explicit config/storage paths; a *_default() FFI would
  let the app drop its path handling.
- Bundled network config: connects to whatever WalletConfig::default() points
  at; real testnet endpoints still TBD.
2026-07-02 18:38:00 +02:00

106 lines
3.1 KiB
QML

import QtQuick 2.15
import QtQuick.Layouts 1.15
import Logos.Theme
import "components/wallet"
// Self-contained navigation bar — styling is independent of any view's theme.
// Use currentIndex to read the active tab; tabChanged(index) fires on selection.
Item {
id: root
property int currentIndex: 0
readonly property var tabs: ["Trade", "Liquidity"]
// Wallet wiring, passed down from Main.qml.
property var backend: null
property var accountModel: null
// Address of the account currently selected in the header control.
readonly property string selectedAddress: accountControl.selectedAddress
signal tabChanged(int index)
implicitHeight: 56
Rectangle {
anchors.fill: parent
color: Theme.palette.background
// Bottom separator
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 1
color: Theme.palette.borderSecondary
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 20
anchors.rightMargin: 20
spacing: 4
// App identity
Text {
text: "Logos AMM"
color: Theme.palette.text
font.pixelSize: 17
font.weight: Font.Bold
}
Item { Layout.fillWidth: true }
// Tab pills
Row {
spacing: 4
Repeater {
model: root.tabs
delegate: Rectangle {
readonly property bool active: root.currentIndex === index
height: 36
width: tabLabel.implicitWidth + 28
radius: 18
color: active ? Theme.palette.backgroundSecondary : "transparent"
Behavior on color { ColorAnimation { duration: 150 } }
Text {
id: tabLabel
anchors.centerIn: parent
text: modelData
color: active ? Theme.palette.text : Theme.palette.textSecondary
font.pixelSize: 14
font.weight: active ? Font.Medium : Font.Normal
Behavior on color { ColorAnimation { duration: 150 } }
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
root.currentIndex = index
root.tabChanged(index)
}
}
}
}
}
// Wallet / account control on the far right.
AccountControl {
id: accountControl
Layout.leftMargin: 12
backend: root.backend
accountModel: root.accountModel
}
}
}
}