Skip to content

Commit 222863f

Browse files
committed
Add minimum width and height for dialogs
1 parent 0ebccb0 commit 222863f

File tree

6 files changed

+52
-15
lines changed

6 files changed

+52
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ Ramen inherits key bindings from underlying UI framework [tview](https://github.
9595
[Hardhat](https://hardhat.org/) / [Ganache](https://trufflesuite.com/ganache/) provides a local Ethereum network for development purpose. Ramen can be used as an user interface for these local networks.
9696
9797
```shell
98-
./ramen -provider local
98+
./ramen --provider local
9999
```
100100
101101
## Troubleshoting
102102
103-
If you come across some problems when using Ramen, at first please check the log file `/tmp/ramen.log` to see if there are any error messages. You can also run Ramen in debug mode with command:
103+
If you come across some problems when using Ramen, please check the log file `/tmp/ramen.log` to see if there are any error messages. You can also run Ramen in debug mode with command:
104104
105105
```shell
106106
ramen --debug
107107
```
108108
109-
If you still can't figure out the problem, please open an issue on [GitHub](https://github.com/dyng/ramen/issues/new)
109+
If you still can't figure out the problem, feel free to open an issue on [GitHub](https://github.com/dyng/ramen/issues/new)
110110

111111
## Special Thanks
112112

internal/service/contract.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func (c *Contract) Call(method string, args ...any) ([]any, error) {
5959
return c.service.provider.CallContract(c.address, c.abi, method, args...)
6060
}
6161

62-
// Transact invokes a non-constant method of this contract. This will make changes to blockchain state and consume ethers.
63-
func (c *Contract) Transact(signer *Signer, method string, args ...any) (common.Hash, error) {
62+
// Send invokes a non-constant method of this contract. This method will sign and send the transaction to the network.
63+
func (c *Contract) Send(signer *Signer, method string, args ...any) (common.Hash, error) {
6464
_, ok := c.abi.Methods[method]
6565
if !ok {
6666
return common.Hash{}, errors.Errorf("Method %s is not found in contract", method)

internal/view/import_abi.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import (
88
"github.com/rivo/tview"
99
)
1010

11+
const (
12+
// importABIDialogMinHeight is the minimum height of the import ABI dialog.
13+
importABIDialogMinHeight = 16
14+
// importABIDialogMinWidth is the minimum width of the import ABI dialog.
15+
importABIDialogMinWidth = 50
16+
)
17+
1118
type ImportABIDialog struct {
1219
*tview.Flex
1320
app *App
@@ -146,8 +153,11 @@ func (d *ImportABIDialog) Draw(screen tcell.Screen) {
146153
func (d *ImportABIDialog) SetCentral(x int, y int, width int, height int) {
147154
dialogWidth := width - width/2
148155
dialogHeight := height - height/2
149-
if dialogHeight < 10 {
150-
dialogHeight = 10
156+
if dialogHeight < importABIDialogMinHeight {
157+
dialogHeight = importABIDialogMinHeight
158+
}
159+
if dialogWidth < importABIDialogMinWidth {
160+
dialogWidth = importABIDialogMinWidth
151161
}
152162
dialogX := x + ((width - dialogWidth) / 2)
153163
dialogY := y + ((height - dialogHeight) / 2)

internal/view/method_call.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import (
1515
"github.com/rivo/tview"
1616
)
1717

18+
const (
19+
// methodCallDialogMinHeight is the minimum height of the method call dialog.
20+
methodCallDialogMinHeight = 16
21+
// methodCallDialogMinWidth is the minimum width of the method call dialog.
22+
methodCallDialogMinWidth = 80
23+
)
24+
1825
type MethodCallDialog struct {
1926
*tview.Flex
2027
app *App
@@ -276,7 +283,7 @@ func (d *MethodCallDialog) callMethod() {
276283
if !method.IsConstant() {
277284
signer = d.app.root.signer.GetSigner()
278285
if signer == nil {
279-
d.app.root.NotifyError(format.FineErrorMessage("Cannot call a non-constant method without a signer. Please signin at first."))
286+
d.app.root.NotifyError(format.FineErrorMessage("Cannot call a non-constant method without a signer. Please signin first."))
280287
return
281288
}
282289
}
@@ -293,8 +300,7 @@ func (d *MethodCallDialog) callMethod() {
293300
if method.IsConstant() {
294301
res, err = d.contract.Call(methodName, args...)
295302
} else {
296-
// FIXME: waiting for transaction executed
297-
hash, e := d.contract.Transact(signer, methodName, args...)
303+
hash, e := d.contract.Send(signer, methodName, args...)
298304
res = []any{fmt.Sprintf("Transaction has been submitted to network.\n\nTxnHash: %s", hash)}
299305
err = e
300306
}
@@ -329,6 +335,12 @@ func (d *MethodCallDialog) SetCentral(x int, y int, width int, height int) {
329335
// self
330336
dialogWidth := width / 2
331337
dialogHeight := height / 2
338+
if dialogHeight < methodCallDialogMinHeight {
339+
dialogHeight = methodCallDialogMinHeight
340+
}
341+
if dialogWidth < methodCallDialogMinWidth {
342+
dialogWidth = methodCallDialogMinWidth
343+
}
332344
dialogX := x + ((width - dialogWidth) / 2)
333345
dialogY := y + ((height - dialogHeight) / 2)
334346
d.Flex.SetRect(dialogX, dialogY, dialogWidth, dialogHeight)

internal/view/notification.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import (
77
"github.com/rivo/tview"
88
)
99

10+
const (
11+
// notificationMinHeight is the minimum height of the notification.
12+
notificationMinHeight = 10
13+
)
14+
1015
type Notification struct {
1116
*tview.TextView
1217
app *App
@@ -97,8 +102,8 @@ func (n *Notification) Draw(screen tcell.Screen) {
97102
func (n *Notification) SetCentral(x int, y int, width int, height int) {
98103
dialogWidth := width - width/3
99104
dialogHeight := height / 4
100-
if dialogHeight < 15 {
101-
dialogHeight = 15
105+
if dialogHeight < notificationMinHeight {
106+
dialogHeight = notificationMinHeight
102107
}
103108
dialogX := x + ((width - dialogWidth) / 2)
104109
dialogY := y + ((height - dialogHeight) / 2)

internal/view/transfer.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import (
1515
"github.com/rivo/tview"
1616
)
1717

18+
const (
19+
// transferDialogMinHeight is the minimum height of the transfer dialog.
20+
transferDialogMinHeight = 10
21+
// transferDialogMinWidth is the minimum width of the transfer dialog.
22+
transferDialogMinWidth = 50
23+
)
24+
1825
type TransferDialog struct {
1926
*tview.Form
2027
app *App
@@ -107,7 +114,7 @@ func (d *TransferDialog) doTransfer() {
107114
if err != nil {
108115
d.app.root.NotifyError(format.FineErrorMessage("Failed to complete transfer", err))
109116
} else {
110-
d.app.root.NotifyInfo(fmt.Sprintf("Transaction has been submitted. TxnHash: %s", hash))
117+
d.app.root.NotifyInfo(fmt.Sprintf("Transaction has been submitted.\n\nTxnHash: %s", hash))
111118
}
112119
}
113120

@@ -151,8 +158,11 @@ func (d *TransferDialog) Draw(screen tcell.Screen) {
151158
func (d *TransferDialog) SetCentral(x int, y int, width int, height int) {
152159
dialogWidth := width - width/2
153160
dialogHeight := style.AvatarSize + 12
154-
if dialogHeight < 10 {
155-
dialogHeight = 10
161+
if dialogHeight < transferDialogMinHeight {
162+
dialogHeight = transferDialogMinHeight
163+
}
164+
if dialogWidth < transferDialogMinWidth {
165+
dialogWidth = transferDialogMinWidth
156166
}
157167
dialogX := x + ((width - dialogWidth) / 2)
158168
dialogY := y + ((height - dialogHeight) / 2)

0 commit comments

Comments
 (0)