diff --git a/ui/modals/transaction/controller.go b/ui/modals/transaction/controller.go index ade062f5..e0e17b72 100644 --- a/ui/modals/transaction/controller.go +++ b/ui/modals/transaction/controller.go @@ -66,7 +66,8 @@ func (m *ViewModel) Account() *algod.Account { } func (m *ViewModel) IsIncentiveProtocol() bool { - return m.State.Status.LastProtocolVersion == "https://github.com/algorandfoundation/specs/tree/236dcc18c9c507d794813ab768e467ea42d1b4d9" + return true // NOCOMMIT + // return m.State.Status.LastProtocolVersion == "https://github.com/algorandfoundation/specs/tree/236dcc18c9c507d794813ab768e467ea42d1b4d9" } // Whether the 2A incentive fee should be added diff --git a/ui/modals/transaction/view.go b/ui/modals/transaction/view.go index 2f771892..f58772ec 100644 --- a/ui/modals/transaction/view.go +++ b/ui/modals/transaction/view.go @@ -14,6 +14,8 @@ func (m ViewModel) View() string { return "No key selected" } if m.ATxn == nil || m.Link == nil { + // TODO make sure the link modal actually shows loading + // currently it "hangs" in the previous screen when pressing R until the shortener service responds return "Loading..." } @@ -25,50 +27,76 @@ func (m ViewModel) View() string { adj = "online" } - intro := fmt.Sprintf("Sign this transaction to register your account as %s", adj) - render := intro - - if !m.ShowLink { - render = lipgloss.JoinVertical( - lipgloss.Center, - render, - style.Green.Render("Scan the QR code with Pera")+" or "+style.Yellow.Render("press S to show a link instead"), - ) - } - - if m.ShouldAddIncentivesFee() { - render = lipgloss.JoinVertical( - lipgloss.Center, - render, - "", - style.Bold("Note: Transction fee set to 2 ALGO (opting in to rewards)"), - ) - } + textHeader := "Sign this transaction to register your account as %s" + textOpenURLInBrowser := "Open this URL in your browser:" + textPeraUserPressSForQr := style.Italics("Pera wallet user? Press S to scan a QR instead.") + text2AFeeWarning := style.Yellow.Render(style.Bold(("⚠ Transaction fee set to 2 ALGO (opting in to rewards)"))) + textScanQrOrPressS := style.Green.Render("Scan the QR code with Pera") + " or " + style.Yellow.Render("press S to show a link instead") + textOffline320Note := style.Bold("Note: this will take effect after 320 rounds (~15 min.)\n") + "Please keep your node running during this cooldown period." - if isOffline { - render = lipgloss.JoinVertical( - lipgloss.Center, - render, - "", - style.Bold("Note: this will take effect after 320 rounds (~15 min.)"), - "Please keep your node running during this cooldown period.", - ) - } + intro := fmt.Sprintf(textHeader, adj) + render := intro if m.ShowLink { link := participation.ToShortLink(*m.Link, m.ShouldAddIncentivesFee()) + render = lipgloss.JoinVertical( lipgloss.Center, render, "", - "Open this URL in your browser:", + textOpenURLInBrowser, "", style.WithHyperlink(link, link), - "", ) + if m.ShouldAddIncentivesFee() { + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + "", + text2AFeeWarning, + ) + } + if isOffline { + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + "", + textOffline320Note, + ) + } + if m.IsQREnabled() { + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + "", + textPeraUserPressSForQr, + ) + } + } else { // TODO: Refactor ATxn to Interface txn, err := m.ATxn.ProduceQRCode() + + // TODO responsive vertical spaces? calculate on modal/screen height diff + if m.ShouldAddIncentivesFee() { + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + text2AFeeWarning, + ) + } + if isOffline { + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + textOffline320Note, + ) + } + render = lipgloss.JoinVertical( + lipgloss.Center, + render, + textScanQrOrPressS, + ) if err != nil { return "Something went wrong" } diff --git a/ui/style/style.go b/ui/style/style.go index a609666b..a6f2fc2f 100644 --- a/ui/style/style.go +++ b/ui/style/style.go @@ -44,6 +44,9 @@ var ( Bold(true). Underline(true). Render + Italics = lipgloss.NewStyle(). + Italic(true). + Render ) func WithHyperlink(text string, url string) string {