Skip to content

Commit 09d59fe

Browse files
Tasos Bitsiosd13co
Tasos Bitsios
authored andcommitted
progress
1 parent 1d30a1b commit 09d59fe

File tree

3 files changed

+63
-31
lines changed

3 files changed

+63
-31
lines changed

ui/modals/transaction/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ func (m *ViewModel) Account() *algod.Account {
6666
}
6767

6868
func (m *ViewModel) IsIncentiveProtocol() bool {
69-
return m.State.Status.LastProtocolVersion == "https://github.com/algorandfoundation/specs/tree/236dcc18c9c507d794813ab768e467ea42d1b4d9"
69+
return true // NOCOMMIT
70+
// return m.State.Status.LastProtocolVersion == "https://github.com/algorandfoundation/specs/tree/236dcc18c9c507d794813ab768e467ea42d1b4d9"
7071
}
7172

7273
// Whether the 2A incentive fee should be added

ui/modals/transaction/view.go

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ func (m ViewModel) View() string {
1414
return "No key selected"
1515
}
1616
if m.ATxn == nil || m.Link == nil {
17+
// TODO make sure the link modal actually shows loading
18+
// currently it "hangs" in the previous screen when pressing R until the shortener service responds
1719
return "Loading..."
1820
}
1921

@@ -25,50 +27,76 @@ func (m ViewModel) View() string {
2527
adj = "online"
2628
}
2729

28-
intro := fmt.Sprintf("Sign this transaction to register your account as %s", adj)
29-
render := intro
30-
31-
if !m.ShowLink {
32-
render = lipgloss.JoinVertical(
33-
lipgloss.Center,
34-
render,
35-
style.Green.Render("Scan the QR code with Pera")+" or "+style.Yellow.Render("press S to show a link instead"),
36-
)
37-
}
38-
39-
if m.ShouldAddIncentivesFee() {
40-
render = lipgloss.JoinVertical(
41-
lipgloss.Center,
42-
render,
43-
"",
44-
style.Bold("Note: Transction fee set to 2 ALGO (opting in to rewards)"),
45-
)
46-
}
30+
textHeader := "Sign this transaction to register your account as %s"
31+
textOpenURLInBrowser := "Open this URL in your browser:"
32+
textPeraUserPressSForQr := style.Italics("Pera wallet user? Press S to scan a QR instead.")
33+
text2AFeeWarning := style.Yellow.Render(style.Bold(("⚠ Transaction fee set to 2 ALGO (opting in to rewards)")))
34+
textScanQrOrPressS := style.Green.Render("Scan the QR code with Pera") + " or " + style.Yellow.Render("press S to show a link instead")
35+
textOffline320Note := style.Bold("Note: this will take effect after 320 rounds (~15 min.)\n") + "Please keep your node running during this cooldown period."
4736

48-
if isOffline {
49-
render = lipgloss.JoinVertical(
50-
lipgloss.Center,
51-
render,
52-
"",
53-
style.Bold("Note: this will take effect after 320 rounds (~15 min.)"),
54-
"Please keep your node running during this cooldown period.",
55-
)
56-
}
37+
intro := fmt.Sprintf(textHeader, adj)
38+
render := intro
5739

5840
if m.ShowLink {
5941
link := participation.ToShortLink(*m.Link, m.ShouldAddIncentivesFee())
42+
6043
render = lipgloss.JoinVertical(
6144
lipgloss.Center,
6245
render,
6346
"",
64-
"Open this URL in your browser:",
47+
textOpenURLInBrowser,
6548
"",
6649
style.WithHyperlink(link, link),
67-
"",
6850
)
51+
if m.ShouldAddIncentivesFee() {
52+
render = lipgloss.JoinVertical(
53+
lipgloss.Center,
54+
render,
55+
"",
56+
text2AFeeWarning,
57+
)
58+
}
59+
if isOffline {
60+
render = lipgloss.JoinVertical(
61+
lipgloss.Center,
62+
render,
63+
"",
64+
textOffline320Note,
65+
)
66+
}
67+
if m.IsQREnabled() {
68+
render = lipgloss.JoinVertical(
69+
lipgloss.Center,
70+
render,
71+
"",
72+
textPeraUserPressSForQr,
73+
)
74+
}
75+
6976
} else {
7077
// TODO: Refactor ATxn to Interface
7178
txn, err := m.ATxn.ProduceQRCode()
79+
80+
// TODO responsive vertical spaces? calculate on modal/screen height diff
81+
if m.ShouldAddIncentivesFee() {
82+
render = lipgloss.JoinVertical(
83+
lipgloss.Center,
84+
render,
85+
text2AFeeWarning,
86+
)
87+
}
88+
if isOffline {
89+
render = lipgloss.JoinVertical(
90+
lipgloss.Center,
91+
render,
92+
textOffline320Note,
93+
)
94+
}
95+
render = lipgloss.JoinVertical(
96+
lipgloss.Center,
97+
render,
98+
textScanQrOrPressS,
99+
)
72100
if err != nil {
73101
return "Something went wrong"
74102
}

ui/style/style.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ var (
4444
Bold(true).
4545
Underline(true).
4646
Render
47+
Italics = lipgloss.NewStyle().
48+
Italic(true).
49+
Render
4750
)
4851

4952
func WithHyperlink(text string, url string) string {

0 commit comments

Comments
 (0)