Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use GetTransactions method for fetching tickets #567

Merged
merged 27 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e2b99b7
clean up wallet/commands.go
oshorefueled Aug 6, 2021
7ee9ecf
add ticket type and methods to load package
oshorefueled Aug 9, 2021
e85361f
clean up ticket list page
oshorefueled Aug 18, 2021
e9ebe20
resolve inactive button bug on ticket purchase modal
oshorefueled Aug 19, 2021
eac64b2
remove global ticket implementation
oshorefueled Aug 19, 2021
e048abf
cleanup code
oshorefueled Aug 19, 2021
2da1892
use dcrlibwallet staking PR
oshorefueled Aug 25, 2021
fad6722
cleanup fetch ticket code
oshorefueled Aug 27, 2021
cab4922
delete ticket file from load package
oshorefueled Aug 27, 2021
963179a
move tooltip initialization to onResume
oshorefueled Aug 30, 2021
5d44591
Cleanup tickets overview page
beansgum Sep 10, 2021
8e0bec5
Fix only tickets purchase tx showing as 'All' in tickets list page
beansgum Sep 10, 2021
93ba65b
Add shadow to LinearLayout
beansgum Sep 10, 2021
abcf5c6
Add GridLayout
beansgum Sep 10, 2021
61f6336
tickets: fix ticket cards layouts
beansgum Sep 12, 2021
06c6bcf
Fix ticket status tooltip
beansgum Sep 12, 2021
b9c7923
Fix content displayed in ticket age, days to vote and maturity durati…
beansgum Sep 12, 2021
aea8c27
Use transactionItem to populate tickets list values
beansgum Sep 13, 2021
94e2e71
Fix popups and complete tx details not showing on tx overview page
beansgum Sep 13, 2021
9d29e92
Remove tickets activity page and unused util functions
beansgum Sep 13, 2021
26e5aeb
Cleanup ticket purchase modal
beansgum Sep 13, 2021
b3c4349
Resolve requested changes
beansgum Sep 14, 2021
4cc99e7
Show error if selected ticket purchase account has insufficient balance
beansgum Sep 15, 2021
541b3bc
Process ticket purchase in review modal
beansgum Sep 15, 2021
3bb1845
Refresh tickets overview data after successful ticket purchase
beansgum Sep 15, 2021
66442f4
Add tooltip to wallet name
beansgum Sep 15, 2021
acebd08
Use dcrlibwallet master(31878a6)
beansgum Sep 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/PuerkitoBio/goquery v1.6.1
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d
github.com/decred/dcrd/chaincfg v1.5.2 // indirect
github.com/decred/dcrd/chaincfg/chainhash v1.0.3-0.20200921185235-6d75c7ec1199
github.com/decred/dcrd/dcrutil v1.4.0
github.com/decred/dcrd/dcrutil/v2 v2.0.1
github.com/decred/dcrd/dcrutil/v3 v3.0.0
Expand All @@ -21,11 +20,10 @@ require (
github.com/jrick/logrotate v1.0.0
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/planetdecred/dcrlibwallet v1.6.1-0.20210816165030-bb3af17a746a
github.com/planetdecred/dcrlibwallet v1.6.1-rc1.0.20210915175038-31878a61e002
github.com/yeqown/go-qrcode v1.5.1
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 // indirect
golang.org/x/text v0.3.3
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/planetdecred/dcrlibwallet v1.6.1-0.20210816165030-bb3af17a746a h1:loa8rSQsMWs4mGL4wW0Vzvw9kmH7aoO7A/SL4cE+KOM=
github.com/planetdecred/dcrlibwallet v1.6.1-0.20210816165030-bb3af17a746a/go.mod h1:sRwfsPrOEnpGBNL54KS83Dpxx2kp2AzZ0Je5vKRRE4o=
github.com/planetdecred/dcrlibwallet v1.6.1-rc1.0.20210915175038-31878a61e002 h1:W5ZELmwSjtNub4ugEujJtP4XrJ7gnmAacEDnIKNJckE=
github.com/planetdecred/dcrlibwallet v1.6.1-rc1.0.20210915175038-31878a61e002/go.mod h1:sRwfsPrOEnpGBNL54KS83Dpxx2kp2AzZ0Je5vKRRE4o=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
14 changes: 14 additions & 0 deletions ui/decredmaterial/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ func Radius(radius float32) CornerRadius {
}
}

func TopRadius(radius float32) CornerRadius {
return CornerRadius{
TopLeft: radius,
TopRight: radius,
}
}

func BottomRadius(radius float32) CornerRadius {
return CornerRadius{
BottomRight: radius,
BottomLeft: radius,
}
}

const (
defaultRadius = 14
)
Expand Down
45 changes: 45 additions & 0 deletions ui/decredmaterial/gridlayout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package decredmaterial

import (
"gioui.org/layout"
)

type GridLayout struct {
List *layout.List
HorizontalSpacing layout.Spacing
Alignment layout.Alignment
Direction layout.Direction
RowCount int
}

func (g GridLayout) Layout(gtx layout.Context, num int, el GridElement) layout.Dimensions {
rows := make([]layout.Widget, 0)

currentRow := make([]layout.FlexChild, 0)

appendRow := func(row []layout.FlexChild) {
rows = append(rows, func(gtx C) D {
return layout.Flex{Alignment: g.Alignment, Spacing: g.HorizontalSpacing}.Layout(gtx, row...)
})
currentRow = make([]layout.FlexChild, 0)
}

for i := 0; i < num; i++ {
index := i
currentRow = append(currentRow, layout.Rigid(func(gtx C) D { return el(gtx, index) }))

if len(currentRow) >= g.RowCount {
appendRow(currentRow)
}
}

if len(currentRow) > 0 {
appendRow(currentRow)
}

return g.List.Layout(gtx, len(rows), func(gtx C, index int) D {
return g.Direction.Layout(gtx, func(gtx C) D {
return rows[index](gtx)
})
})
}
66 changes: 38 additions & 28 deletions ui/decredmaterial/linearlayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type LinearLayout struct {
Height int
Orientation layout.Axis
Background color.NRGBA
Shadow *Shadow
Border Border
Margin layout.Inset
Padding layout.Inset
Expand All @@ -38,36 +39,45 @@ func (ll LinearLayout) Layout(gtx C, children ...layout.FlexChild) D {
return ll.Direction.Layout(gtx, func(gtx C) D {
// draw margin
return ll.Margin.Layout(gtx, func(gtx C) D {
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx C) D {
ll.applyDimension(&gtx)
// draw background and clip the background to border radius
tr := float32(gtx.Px(unit.Dp(ll.Border.Radius.TopRight)))
tl := float32(gtx.Px(unit.Dp(ll.Border.Radius.TopLeft)))
br := float32(gtx.Px(unit.Dp(ll.Border.Radius.BottomRight)))
bl := float32(gtx.Px(unit.Dp(ll.Border.Radius.BottomLeft)))
clip.RRect{
Rect: f32.Rectangle{Max: f32.Point{
X: float32(gtx.Constraints.Min.X),
Y: float32(gtx.Constraints.Min.Y),
}},
NW: tl, NE: tr, SE: br, SW: bl,
}.Add(gtx.Ops)
return fill(gtx, ll.Background)
}),
layout.Stacked(func(gtx C) D {
ll.applyDimension(&gtx)
return ll.Border.Layout(gtx, func(gtx C) D {
// draw padding
return ll.Padding.Layout(gtx, func(gtx C) D {
// draw layout direction
return ll.Direction.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: ll.Orientation, Alignment: ll.Alignment, Spacing: ll.Spacing}.Layout(gtx, children...)

wdg := func(gtx C) D {
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx C) D {
ll.applyDimension(&gtx)
// draw background and clip the background to border radius
tr := float32(gtx.Px(unit.Dp(ll.Border.Radius.TopRight)))
tl := float32(gtx.Px(unit.Dp(ll.Border.Radius.TopLeft)))
br := float32(gtx.Px(unit.Dp(ll.Border.Radius.BottomRight)))
bl := float32(gtx.Px(unit.Dp(ll.Border.Radius.BottomLeft)))
clip.RRect{
Rect: f32.Rectangle{Max: f32.Point{
X: float32(gtx.Constraints.Min.X),
Y: float32(gtx.Constraints.Min.Y),
}},
NW: tl, NE: tr, SE: br, SW: bl,
}.Add(gtx.Ops)
return fill(gtx, ll.Background)
}),
layout.Stacked(func(gtx C) D {
ll.applyDimension(&gtx)
return ll.Border.Layout(gtx, func(gtx C) D {
// draw padding
return ll.Padding.Layout(gtx, func(gtx C) D {
// draw layout direction
return ll.Direction.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: ll.Orientation, Alignment: ll.Alignment, Spacing: ll.Spacing}.Layout(gtx, children...)
})
})
})
})
}),
)
}),
)
}

if ll.Shadow != nil {
return ll.Shadow.Layout(gtx, wdg)
}

return wdg(gtx)
})
})
}
Expand Down
49 changes: 39 additions & 10 deletions ui/decredmaterial/progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,61 @@ import (
)

type ProgressBarStyle struct {
Radius unit.Value
Height unit.Value
Width unit.Value
Radius CornerRadius
Height unit.Value
Width unit.Value
Direction layout.Direction
material.ProgressBarStyle
}

func (t *Theme) ProgressBar(progress int) ProgressBarStyle {
return ProgressBarStyle{ProgressBarStyle: material.ProgressBar(t.Base, float32(progress)/100)}
}

// This achieves a progress bar using linear layouts.
func (p ProgressBarStyle) Layout2(gtx C) D {
if p.Width.V <= 0 {
p.Width = unit.Px(float32(gtx.Constraints.Max.X))
}

return p.Direction.Layout(gtx, func(gtx C) D {
return LinearLayout{
Width: gtx.Px(p.Width),
Height: gtx.Px(p.Height),
Background: p.TrackColor,
Border: Border{Radius: p.Radius},
}.Layout2(gtx, func(gtx C) D {

return LinearLayout{
Width: int(p.Width.V * clamp1(p.Progress)),
Height: gtx.Px(p.Height),
Background: p.Color,
Border: Border{Radius: p.Radius},
}.Layout(gtx)
})
})
}

func (p ProgressBarStyle) Layout(gtx layout.Context) layout.Dimensions {
shader := func(width float32, color color.NRGBA) layout.Dimensions {
maxHeight := p.Height
if p.Height.V <= 0 {
maxHeight = unit.Dp(4)
}

rr := float32(gtx.Px(p.Radius))
if p.Radius.V <= 0 {
rr = float32(gtx.Px(unit.Dp(2)))
}

d := image.Point{X: int(width), Y: gtx.Px(maxHeight)}

height := float32(gtx.Px(maxHeight))
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(width, height)}, rr).Add(gtx.Ops)

tr := float32(gtx.Px(unit.Dp(p.Radius.TopRight)))
tl := float32(gtx.Px(unit.Dp(p.Radius.TopLeft)))
br := float32(gtx.Px(unit.Dp(p.Radius.BottomRight)))
bl := float32(gtx.Px(unit.Dp(p.Radius.BottomLeft)))

clip.RRect{
Rect: f32.Rectangle{Max: f32.Pt(width, height)},
NW: tl, NE: tr, SE: br, SW: bl,
}.Add(gtx.Ops)

paint.ColorOp{Color: color}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)

Expand Down
2 changes: 1 addition & 1 deletion ui/decredmaterial/shadow.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *Shadow) Layout(gtx C, w layout.Widget) D {
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx C) D {
s.layout(gtx)
surface := clip.UniformRRect(f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)}, float32(gtx.Px(values.MarginPadding5)))
surface := clip.UniformRRect(f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)}, float32(gtx.Px(values.MarginPadding4)))
paint.FillShape(gtx.Ops, s.surface, surface.Op(gtx.Ops))
return D{Size: gtx.Constraints.Min}
}),
Expand Down
27 changes: 27 additions & 0 deletions ui/decredmaterial/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Theme struct {
Base *material.Theme
Color struct {
Primary color.NRGBA
Primary50 color.NRGBA
Secondary color.NRGBA
Text color.NRGBA
Hint color.NRGBA
Expand All @@ -56,6 +57,10 @@ type Theme struct {
DeepBlue color.NRGBA
LightBlue color.NRGBA
LightBlue2 color.NRGBA
LightBlue3 color.NRGBA
LightBlue4 color.NRGBA
LightBlue5 color.NRGBA
LightBlue6 color.NRGBA
BlueProgressTint color.NRGBA
LightGray color.NRGBA
InactiveGray color.NRGBA
Expand All @@ -65,11 +70,15 @@ type Theme struct {
Gray3 color.NRGBA
Orange color.NRGBA
Orange2 color.NRGBA
Orange3 color.NRGBA
Gray4 color.NRGBA
Gray5 color.NRGBA
Gray6 color.NRGBA
Green50 color.NRGBA
Green500 color.NRGBA
Turquoise100 color.NRGBA
Turquoise300 color.NRGBA
Turquoise700 color.NRGBA
Turquoise800 color.NRGBA
Yellow color.NRGBA
}
Expand Down Expand Up @@ -99,6 +108,7 @@ func (t *Theme) setColorMode(darkMode bool) {
if darkMode {
t.DarkMode = true
t.Color.Primary = rgb(0x57B6FF)
t.Color.Primary50 = rgb(0xE3F2FF)
t.Color.Text = argb(0x99FFFFFF)
t.Color.Hint = rgb(0x8997A5)
t.Color.InvText = rgb(0xffffff)
Expand All @@ -124,15 +134,24 @@ func (t *Theme) setColorMode(darkMode bool) {
t.Color.Background = argb(0x22444444)
t.Color.LightBlue = rgb(0xe4f6ff)
t.Color.LightBlue2 = rgb(0x75D8FF)
t.Color.LightBlue3 = rgb(0xBCE8FF)
t.Color.LightBlue4 = rgb(0xBBDEFF)
t.Color.LightBlue5 = rgb(0x70CBFF)
t.Color.LightBlue6 = rgb(0x4B91D8)
t.Color.BlueProgressTint = rgb(0x73d7ff)
t.Color.Orange = rgb(0xD34A21)
t.Color.Orange2 = rgb(0xF8E8E7)
t.Color.Orange3 = rgb(0xF8CABC)
t.Color.Turquoise100 = rgb(0xB6EED7)
t.Color.Turquoise300 = rgb(0x2DD8A3)
t.Color.Turquoise700 = rgb(0x00A05F)
t.Color.Turquoise800 = rgb(0x008F52)
t.Color.Yellow = rgb(0xffc84e)
t.TextSize = unit.Sp(16)
} else {
t.DarkMode = false
t.Color.Primary = keyblue
t.Color.Primary50 = rgb(0xE3F2FF)
t.Color.Text = darkblue
t.Color.Hint = rgb(0x8997A5)
t.Color.InvText = rgb(0xffffff)
Expand All @@ -158,9 +177,17 @@ func (t *Theme) setColorMode(darkMode bool) {
t.Color.Background = argb(0x22444444)
t.Color.LightBlue = rgb(0xe4f6ff)
t.Color.LightBlue2 = rgb(0x75D8FF)
t.Color.LightBlue3 = rgb(0xBCE8FF)
t.Color.LightBlue4 = rgb(0xBBDEFF)
t.Color.LightBlue5 = rgb(0x70CBFF)
t.Color.LightBlue6 = rgb(0x4B91D8)
t.Color.BlueProgressTint = rgb(0x73d7ff)
t.Color.Orange = rgb(0xD34A21)
t.Color.Orange2 = rgb(0xF8E8E7)
t.Color.Orange3 = rgb(0xF8CABC)
t.Color.Turquoise100 = rgb(0xB6EED7)
t.Color.Turquoise300 = rgb(0x2DD8A3)
t.Color.Turquoise700 = rgb(0x00A05F)
t.Color.Turquoise800 = rgb(0x008F52)
t.Color.Yellow = rgb(0xffc84e)
t.TextSize = unit.Sp(16)
Expand Down
Loading