aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/assets/qml/views/wallet.qml
blob: 59dbae848a61a10dd201dbc0cb36154a2cb67ed9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import QtQuick 2.0
import QtQuick.Controls 1.0;
import QtQuick.Layouts 1.0;
import QtQuick.Dialogs 1.0;
import QtQuick.Window 2.1;
import QtQuick.Controls.Styles 1.1
import Ethereum 1.0

Rectangle {
    id: root
    property var title: "Wallet"
    property var iconSource: "../facet.png"
    property var menuItem

    objectName: "walletView"
    anchors.fill: parent

        Label {
            objectName: "balanceLabel"
            visible: false
        onTextChanged: {
        balance.text = text
        menuItem.secondaryTitle = text
        }
        }

    function onReady() {
        setBalance()
    }

    function setBalance() {
        balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.coinbase()))
        if(menuItem)
            menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.coinbase()))
    }

    ListModel {
        id: denomModel
        ListElement { text: "Wei" ;     zeros: "" }
        ListElement { text: "Ada" ;     zeros: "000" }
        ListElement { text: "Babbage" ; zeros: "000000" }
        ListElement { text: "Shannon" ; zeros: "000000000" }
        ListElement { text: "Szabo" ;   zeros: "000000000000" }
        ListElement { text: "Finney" ;  zeros: "000000000000000" }
        ListElement { text: "Ether" ;   zeros: "000000000000000000" }
        ListElement { text: "Einstein" ;zeros: "000000000000000000000" }
        ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" }
    }

    ColumnLayout {
        spacing: 10
        y: 40
        anchors.fill: parent

        Text {
            id: balance
            font.pixelSize: 24
            anchors {
                horizontalCenter: parent.horizontalCenter
                top: parent.top
                topMargin: 20
            }
        }

        Rectangle {
            id: newTxPane
            color: "#ececec"
            border.color: "#cccccc"
            border.width: 1
            anchors {
                top: balance.bottom
                topMargin: 10
                left: parent.left
                leftMargin: 5
                right: parent.right
                rightMargin: 5
            }
            height: 100

            RowLayout {
                id: amountFields
                spacing: 10
                anchors {
                    top: parent.top
                    topMargin: 20
                    left: parent.left
                    leftMargin: 20
                }

                Text {
                    text: "Ξ  "
                }

                // There's something off with the row layout where textfields won't listen to the width setting
                Rectangle {
                    width: 50
                    height: 20
                    TextField {
                        id: txValue
                        width: parent.width
                        placeholderText: "0.00"
                    }
                }

                ComboBox {
                    id: valueDenom
                    currentIndex: 5
                    model: denomModel
                }

            }

            RowLayout {
                id: toFields
                spacing: 10
                anchors {
                    top: amountFields.bottom
                    topMargin: 5
                    left: parent.left
                    leftMargin: 20
                }

                Text {
                    text: "To"
                }

                Rectangle {
                    width: 200
                    height: 20
                    TextField {
                        id: txTo
                        width: parent.width
                        placeholderText: "Address or name"
                    }
                }

                Button {
                    text: "Send"
                    onClicked: {
                        var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros;
                        var gasPrice = "10000000000000"
                        var res = eth.transact({from: eth.coinbase(), to: txTo.text, value: value, gas: "500", gasPrice: gasPrice})
                    }
                }
            }
        }

        Rectangle {
            anchors {
                left: parent.left
                right: parent.right
                top: newTxPane.bottom
                topMargin: 10
                bottom: parent.bottom
            }
            TableView {
                id: txTableView
                anchors.fill : parent
                TableViewColumn{ role: "num" ; title: "#" ; width: 30 }
                TableViewColumn{ role: "from" ; title: "From" ; width: 340 }
                TableViewColumn{ role: "to" ; title: "To" ; width: 340 }
                TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }

                model: ListModel {
                    id: txModel
                    Component.onCompleted: {
                    }

                    function addTxs(messages) {
                        /*
                        setBalance()

                        for(var i = 0; i < messages.length; i++) {
                            var message = messages.get(i);
                            var to = eth.lookupName(message.to);
                            var from;
                            if(message.from.length == 0) {
                                from = "- MINED -";
                            } else {
                                from = eth.lookupName(message.from);
                            }
                            txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)})
                        }
                        */
                    }
                }
            }
        }

    }
}