Skip to content

Commit

Permalink
Make main menu fancier
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpl0itU committed Mar 25, 2024
1 parent 1278d22 commit e9d9d8f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 29 deletions.
6 changes: 3 additions & 3 deletions earnapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type EarnAppConfig struct {
Configured bool
}

func (i *EarnAppConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *EarnAppConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
uuid := ""
isError := false
showingError := false
Expand Down Expand Up @@ -54,10 +54,10 @@ func (i *EarnAppConfig) ConfigureForm(form *tview.Form, list *tview.List, app *t
}
i.UUID = uuid
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://earnapp.com/i/J9XF4PXJ")
Expand Down
6 changes: 3 additions & 3 deletions grass.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type GrassConfig struct {
Configured bool
}

func (i *GrassConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *GrassConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
email := ""
password := ""
isError := false
Expand All @@ -41,10 +41,10 @@ func (i *GrassConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tvi
i.Email = email
i.Password = password
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://app.getgrass.io/register/?referralCode=u154dPm508iVxXy")
Expand Down
6 changes: 3 additions & 3 deletions honeygain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type HoneygainConfig struct {
Configured bool
}

func (i *HoneygainConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *HoneygainConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
email := ""
password := ""
deviceName := ""
Expand Down Expand Up @@ -47,10 +47,10 @@ func (i *HoneygainConfig) ConfigureForm(form *tview.Form, list *tview.List, app
i.Password = password
i.DeviceName = deviceName
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://r.honeygain.me/SAMUEC73")
Expand Down
14 changes: 9 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import (
)

func main() {
app := tview.NewApplication()
app := tview.NewApplication().EnablePaste(true)

list := tview.NewList()

form := tview.NewForm()

frame := tview.NewFrame(list).
AddText("Passive Machine", true, tview.AlignCenter, tview.Styles.PrimaryTextColor).
AddText("Tip: Use the Register button to sign up for the service", true, tview.AlignCenter, tview.Styles.ContrastSecondaryTextColor)

menuItems := []MenuItem{
{"Honeygain", "Earn passive income by sharing your internet connection", &HoneygainConfig{}},
{"EarnApp", "Earn passive income by sharing your internet connection", &EarnAppConfig{}},
Expand All @@ -25,7 +29,7 @@ func main() {
for _, item := range menuItems {
list.AddItem(item.GetName(), item.GetDescription(), 0, func() {
form.Clear(true)
item.Config.ConfigureForm(form, list, app)
item.Config.ConfigureForm(form, frame, app)
app.SetRoot(form, true)
})
}
Expand All @@ -42,7 +46,7 @@ func main() {
}
})
form.AddButton("Return", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
app.SetRoot(form, true)
})
Expand All @@ -61,9 +65,9 @@ func main() {
}
}
form.AddButton("Return", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
app.SetRoot(form, true)
})
app.SetRoot(list, true).Run()
app.SetRoot(frame, true).Run()
}
6 changes: 3 additions & 3 deletions menuItem.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import "github.com/rivo/tview"

type MenuItemConfig interface {
ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application)
ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application)
ConfigureDocker(kind DockerConfigKind, logView *tview.TextView) (string, error)
IsConfigured() bool
}
Expand All @@ -22,6 +22,6 @@ func (i *MenuItem) GetDescription() string {
return i.Description
}

func returnToMenu(list *tview.List, app *tview.Application) {
app.SetRoot(list, true)
func returnToMenu(frame *tview.Frame, app *tview.Application) {
app.SetRoot(frame, true)
}
6 changes: 3 additions & 3 deletions mystnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ type MystConfig struct {
Configured bool
}

func (i *MystConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *MystConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
enabled := i.Configured
form.AddCheckbox("Enable Myst", i.Configured, func(checked bool) {
enabled = checked
})
form.AddButton("Save", func() {
i.Configured = enabled
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://mystnodes.co/?referral_code=ijIy8nJv8xqVoshRmJjKATvoZZYKZ3jhzOY3FWy6")
Expand Down
6 changes: 3 additions & 3 deletions packetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type PacketStreamConfig struct {
Configured bool
}

func (i *PacketStreamConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *PacketStreamConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
cid := ""
isError := false
showingError := false
Expand All @@ -35,10 +35,10 @@ func (i *PacketStreamConfig) ConfigureForm(form *tview.Form, list *tview.List, a
}
i.CID = cid
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://packetstream.io/?psr=4cRE")
Expand Down
6 changes: 3 additions & 3 deletions pawnsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type PawnsAppConfig struct {
Configured bool
}

func (i *PawnsAppConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *PawnsAppConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
email := ""
password := ""
deviceName := ""
Expand Down Expand Up @@ -47,10 +47,10 @@ func (i *PawnsAppConfig) ConfigureForm(form *tview.Form, list *tview.List, app *
i.Password = password
i.DeviceName = deviceName
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://pawns.app/?r=1112060")
Expand Down
6 changes: 3 additions & 3 deletions peer2profit.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Peer2ProfitConfig struct {
Configured bool
}

func (i *Peer2ProfitConfig) ConfigureForm(form *tview.Form, list *tview.List, app *tview.Application) {
func (i *Peer2ProfitConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
email := ""
isError := false
showingError := false
Expand All @@ -35,10 +35,10 @@ func (i *Peer2ProfitConfig) ConfigureForm(form *tview.Form, list *tview.List, ap
}
i.Email = email
i.Configured = true
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Cancel", func() {
returnToMenu(list, app)
returnToMenu(frame, app)
})
form.AddButton("Register", func() {
webbrowser.Open("https://t.me/peer2profit_app_bot?start=1671204644639c8f24d663c")
Expand Down

0 comments on commit e9d9d8f

Please sign in to comment.