(form *tview.Form, frame *tview.Frame, app *tview.Application)
| 21 | } |
| 22 | |
| 23 | func (i *EarnAppConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) { |
| 24 | uuid := "" |
| 25 | isError := false |
| 26 | showingError := false |
| 27 | form.AddInputField("UUID", i.UUID, 50, nil, func(text string) { |
| 28 | uuid = text |
| 29 | }) |
| 30 | form.AddTextView("Attention", "The Claim URL will work only after the container has been started,\nso copy it and keep it in a safe place until you need it", 0, 0, true, false) |
| 31 | form.AddButton("Generate UUID", func() { |
| 32 | uuid = generateEarnAppUUID() |
| 33 | form.GetFormItemByLabel("UUID").(*tview.InputField).SetText(uuid) |
| 34 | }) |
| 35 | form.AddButton("Claim URL", func() { |
| 36 | isError = stringIsEmpty(uuid) |
| 37 | if isError { |
| 38 | if !showingError { |
| 39 | form.AddTextView("Error", "UUID is required", 0, 1, true, true) |
| 40 | showingError = true |
| 41 | } |
| 42 | return |
| 43 | } |
| 44 | modal := tview.NewModal(). |
| 45 | SetText("Claim URL:\nhttps://earnapp.com/r/" + uuid). |
| 46 | AddButtons([]string{"Copy", "Close"}). |
| 47 | SetDoneFunc(func(buttonIndex int, buttonLabel string) { |
| 48 | if buttonLabel == "Copy" { |
| 49 | clipboard.WriteAll("https://earnapp.com/r/" + uuid) |
| 50 | } |
| 51 | app.SetRoot(form, true) |
| 52 | }) |
| 53 | app.SetRoot(modal, true) |
| 54 | }) |
| 55 | form.AddButton("Save", func() { |
| 56 | isError = stringIsEmpty(uuid) |
| 57 | if isError { |
| 58 | if !showingError { |
| 59 | form.AddTextView("Error", "All fields are required", 0, 1, true, true) |
| 60 | showingError = true |
| 61 | } |
| 62 | return |
| 63 | } |
| 64 | i.UUID = uuid |
| 65 | i.Configured = true |
| 66 | returnToMenu(frame, app) |
| 67 | }) |
| 68 | form.AddButton("Cancel", func() { |
| 69 | returnToMenu(frame, app) |
| 70 | }) |
| 71 | form.AddButton("Register", func() { |
| 72 | modal := tview.NewModal(). |
| 73 | SetText("Register on EarnApp\n" + EARNAPP_REFERRAL_LINK). |
| 74 | AddButtons([]string{"Open", "Cancel"}). |
| 75 | SetDoneFunc(func(buttonIndex int, buttonLabel string) { |
| 76 | if buttonLabel == "Open" { |
| 77 | webbrowser.Open(EARNAPP_REFERRAL_LINK) |
| 78 | } |
| 79 | app.SetRoot(form, true) |
| 80 | }) |
nothing calls this directly
no test coverage detected