Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format transactions row and details (#582)
* Format transactions row for various tx types * transactions: add mixed transaction type to dropdown selector * transactions: display denomination and mix count for mixed transactions * Support formatting amount with different text sizes and scale * transactions: display mix denomination in transaction row * transactions: show number of days ticket took to vote or revoke * transactions: show vote reward and ticket price price for stake transactions * tx details: add button to view associated ticket * tx detais: fix padding and margins for rows and page sections * tx details: show ticket status, days to vote and vote reward * tx details: add maturity progress bar * Remove redundant seperator function
- Loading branch information
Showing
18 changed files
with
621 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package components | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
|
||
"gioui.org/layout" | ||
"gioui.org/unit" | ||
"github.com/planetdecred/godcr/ui/load" | ||
"github.com/planetdecred/godcr/ui/values" | ||
) | ||
|
||
const defaultScale = .7 | ||
|
||
var ( | ||
doubleOrMoreDecimalPlaces = regexp.MustCompile(`(([0-9]{1,3},*)*\.)\d{2,}`) | ||
oneDecimalPlace = regexp.MustCompile(`(([0-9]{1,3},*)*\.)\d`) | ||
noDecimal = regexp.MustCompile(`([0-9]{1,3},*)+`) | ||
) | ||
|
||
func formatBalance(gtx layout.Context, l *load.Load, amount string, mainTextSize unit.Value, scale float32) D { | ||
|
||
startIndex := 0 | ||
|
||
if doubleOrMoreDecimalPlaces.MatchString(amount) { | ||
decimalIndex := strings.Index(amount, ".") | ||
startIndex = decimalIndex + 3 | ||
} else if oneDecimalPlace.MatchString(amount) { | ||
decimalIndex := strings.Index(amount, ".") | ||
startIndex = decimalIndex + 2 | ||
} else if noDecimal.MatchString(amount) { | ||
loc := noDecimal.FindStringIndex(amount) | ||
startIndex = loc[1] // start scaling from the end | ||
} | ||
|
||
mainText, subText := amount[:startIndex], amount[startIndex:] | ||
|
||
subTextSize := unit.Sp(mainTextSize.V * scale) | ||
|
||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Baseline}.Layout(gtx, | ||
layout.Rigid(func(gtx C) D { | ||
label := l.Theme.Label(mainTextSize, mainText) | ||
label.Color = l.Theme.Color.DeepBlue | ||
return label.Layout(gtx) | ||
}), | ||
layout.Rigid(func(gtx C) D { | ||
label := l.Theme.Label(subTextSize, subText) | ||
label.Color = l.Theme.Color.DeepBlue | ||
return label.Layout(gtx) | ||
}), | ||
) | ||
} | ||
|
||
// LayoutBalance aligns the main and sub DCR balances horizontally, putting the sub | ||
// balance at the baseline of the row. | ||
func LayoutBalance(gtx layout.Context, l *load.Load, amount string) layout.Dimensions { | ||
return formatBalance(gtx, l, amount, values.TextSize20, defaultScale) | ||
} | ||
|
||
func LayoutBalanceSize(gtx layout.Context, l *load.Load, amount string, mainTextSize unit.Value) layout.Dimensions { | ||
return formatBalance(gtx, l, amount, mainTextSize, defaultScale) | ||
} | ||
|
||
func LayoutBalanceSizeScale(gtx layout.Context, l *load.Load, amount string, mainTextSize unit.Value, scale float32) layout.Dimensions { | ||
return formatBalance(gtx, l, amount, mainTextSize, scale) | ||
} |
Oops, something went wrong.