Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasos Bitsios committed Jan 22, 2025
1 parent 82922d6 commit ff92d63
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 31 deletions.
3 changes: 2 additions & 1 deletion ui/modals/transaction/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 58 additions & 30 deletions ui/modals/transaction/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}

Expand All @@ -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"
}
Expand Down
3 changes: 3 additions & 0 deletions ui/style/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ var (
Bold(true).
Underline(true).
Render
Italics = lipgloss.NewStyle().
Italic(true).
Render
)

func WithHyperlink(text string, url string) string {
Expand Down

0 comments on commit ff92d63

Please sign in to comment.