|
| 1 | +package startpage |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "github.com/rivo/tview" |
| 6 | +) |
| 7 | + |
| 8 | +const E3Logo = ` ________ __ ______ |
| 9 | +/ | / | / \ |
| 10 | +$$$$$$$$/ ______ $$/ ______ ______ _______ /$$$$$$ | |
| 11 | +$$ |__ / \ / | / \ / \ / \ $$ ___$$ | |
| 12 | +$$ | /$$$$$$ |$$ |/$$$$$$ |/$$$$$$ |$$$$$$$ | / $$< |
| 13 | +$$$$$/ $$ | $$/ $$ |$$ | $$ |$$ | $$ |$$ | $$ | _$$$$$ | |
| 14 | +$$ |_____ $$ | $$ |$$ \__$$ |$$ \__$$ |$$ | $$ | / \__$$ | |
| 15 | +$$ |$$ | $$ |$$ $$ |$$ $$/ $$ | $$ | $$ $$/ |
| 16 | +$$$$$$$$/ $$/ $$/ $$$$$$$ | $$$$$$/ $$/ $$/ $$$$$$/ |
| 17 | + / \__$$ | |
| 18 | + $$ $$/ |
| 19 | + $$$$$$/ ` |
| 20 | + |
| 21 | +func Body(clock *tview.TextView, datadir string) (*tview.Flex, *BodyView) { |
| 22 | + netInf := tview.NewTextView().SetDynamicColors(true).SetText("network info...") |
| 23 | + view := &BodyView{ |
| 24 | + Logo: tview.NewTextView().SetText(E3Logo).SetDynamicColors(true), |
| 25 | + Network: NetworkDropdown(netInf), |
| 26 | + NetworkInfo: netInf, |
| 27 | + Execution: tview.NewTextView().SetDynamicColors(true).SetText("exec/stop"), |
| 28 | + Status: tview.NewTextView().SetDynamicColors(true).SetText("status..."), |
| 29 | + Clock: clock, |
| 30 | + Datadir: tview.NewTextView().SetDynamicColors(true).SetTextAlign(tview.AlignRight). |
| 31 | + SetText(fmt.Sprintf("datadir: %s", datadir)), |
| 32 | + } |
| 33 | + |
| 34 | + topPanel := tview.NewFlex(). |
| 35 | + AddItem(view.Logo, 0, 1, false). |
| 36 | + AddItem(tview.NewFlex().SetDirection(tview.FlexRow). |
| 37 | + AddItem(view.Clock, 1, 1, false). |
| 38 | + AddItem(view.Datadir, 0, 5, false), 0, 1, false) |
| 39 | + //topPanel.GetItem(1).(*tview.Flex).GetItem(1).(*tview.TextView).Box.SetBorder(true) |
| 40 | + networkWidget := tview.NewFlex().SetDirection(tview.FlexRow). |
| 41 | + AddItem(view.Network, 0, 1, false). |
| 42 | + AddItem(view.NetworkInfo, 0, 1, false) |
| 43 | + flex := tview.NewFlex().SetDirection(tview.FlexRow). |
| 44 | + AddItem(topPanel, |
| 45 | + 15, 1, false). |
| 46 | + AddItem(tview.NewFlex(). |
| 47 | + AddItem(networkWidget, 0, 1, false). |
| 48 | + AddItem(view.Status, 0, 1, false). |
| 49 | + AddItem(view.Execution, 0, 1, false), |
| 50 | + 0, 1, false) |
| 51 | + flex.Box.SetBorder(true) |
| 52 | + return flex, view |
| 53 | +} |
| 54 | + |
| 55 | +type BodyView struct { |
| 56 | + Logo *tview.TextView |
| 57 | + Network *tview.DropDown |
| 58 | + NetworkInfo *tview.TextView |
| 59 | + Datadir *tview.TextView |
| 60 | + Execution *tview.TextView |
| 61 | + Clock *tview.TextView |
| 62 | + Status *tview.TextView |
| 63 | +} |
| 64 | + |
| 65 | +var Networks = []string{"mainnet", "hoodi", "sepolia"} |
| 66 | +var Network = "mainnet" |
| 67 | + |
| 68 | +func NetworkDropdown(netInf *tview.TextView) *tview.DropDown { |
| 69 | + dd := tview.NewDropDown().SetLabel("choose network: "). |
| 70 | + SetOptions(Networks, func(text string, index int) { |
| 71 | + Network = Networks[index] |
| 72 | + netInf.SetText(Network) |
| 73 | + }).SetCurrentOption(0) |
| 74 | + return dd |
| 75 | +} |
0 commit comments