utilitywidgets

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DurationMap map[string]string = map[string]string{
	"1 Hour":   "1h",
	"24 Hours": "24h",
	"7 Days":   "7d",
	"14 Days":  "14d",
	"30 Days":  "30d",
	"200 Days": "200d",
	"1 Year":   "1y",
}

DurationMap maps duration strings to the format required by coinGecko API

View Source
var IntervalMap map[string]string = map[string]string{
	"24 Hours": "24hr",
	"7 Days":   "7d",
	"14 Days":  "14d",
	"30 Days":  "30d",
	"90 Days":  "90d",
	"180 Days": "180d",
	"1 Year":   "1yr",
	"5 Years":  "5yr",
}

IntervalMap maps given interval string to format required by CoinGecko API

Functions

This section is empty.

Types

type AllCurrencyData

type AllCurrencyData struct {
	Data      []SingleCurrency `json:"data"`
	Timestamp uint             `json:"timestamp"`
}

AllCurrencyData holds details of currencies when all are fetched from the API

type ChangeIntervalDurationTable

type ChangeIntervalDurationTable struct {
	*widgets.Table
}

func NewChangeIntervalPage

func NewChangeIntervalPage() *ChangeIntervalDurationTable

NewChangeIntervalPage returns a pointer to an instance of ChangeIntervalDurationTable

func (*ChangeIntervalDurationTable) Draw

func (c *ChangeIntervalDurationTable) Draw(buf *ui.Buffer)

Draw puts the required text into the widget

func (*ChangeIntervalDurationTable) Resize

func (c *ChangeIntervalDurationTable) Resize(termWidth, termHeight int)

type ChangePercentageDurationTable

type ChangePercentageDurationTable struct {
	*widgets.Table
}

func NewChangePercentPage

func NewChangePercentPage() *ChangePercentageDurationTable

NewCurrencyPage creates, initialises and returns a pointer to an instance of CurrencyTable

func (*ChangePercentageDurationTable) Draw

func (c *ChangePercentageDurationTable) Draw(buf *ui.Buffer)

Draw puts the required text into the widget

func (*ChangePercentageDurationTable) Resize

func (c *ChangePercentageDurationTable) Resize(termWidth, termHeight int)

type Currency

type Currency struct {
	Symbol  string
	RateUSD float64
	Type    string
}

Currency holds information of a single currency, it used to populate currencyIDMaps

type CurrencyIDMap

type CurrencyIDMap map[string]Currency

CurrencyIDMap maps a currency Id to it's symbol and price in USD

func NewCurencyIDMap

func NewCurencyIDMap() CurrencyIDMap

NewCurrencyIDMap creates and returns an instance of CurrencyIDMap

func (CurrencyIDMap) Populate

func (c CurrencyIDMap) Populate()

Populate fetches currency rates and populates the map

type CurrencyTable

type CurrencyTable struct {
	*widgets.Table
	IDMap *CurrencyIDMap
}

CurrencyTable is a widget used to display currencyies, symbols and rates

func NewCurrencyPage

func NewCurrencyPage() *CurrencyTable

NewCurrencyPage creates, initialises and returns a pointer to an instance of CurrencyTable

func (*CurrencyTable) Draw

func (c *CurrencyTable) Draw(buf *ui.Buffer)

Draw puts the required text into the widget

func (*CurrencyTable) Get

func (c *CurrencyTable) Get(currencyID string) (string, string, float64)

Get returns the symbol and USD rate for a given currency ID If the given currency ID does not exist in the Map, values for US Dollar are returned

func (*CurrencyTable) Resize

func (c *CurrencyTable) Resize(termWidth, termHeight int)

func (*CurrencyTable) UpdateRows

func (c *CurrencyTable) UpdateRows(allCurrencies bool)

UpdateAll fetches rates of all currencies and updates them as rows in the table

type PortfolioTable

type PortfolioTable struct {
	*widgets.Table
}

func NewPortfolioPage

func NewPortfolioPage() *PortfolioTable

NewPortfolioPage creates, initialises and returns a pointer to an instance of PortfolioTable

func (*PortfolioTable) Draw

func (p *PortfolioTable) Draw(buf *ui.Buffer)

Draw puts the required text into the widget

func (*PortfolioTable) Resize

func (p *PortfolioTable) Resize(termWidth, termHeight int)

func (*PortfolioTable) UpdateRows

func (p *PortfolioTable) UpdateRows(portfolio map[string]float64, currency string, currencyVal float64)

Update Portfolio data

type SingleCurrency

type SingleCurrency struct {
	ID             string `json:"id"`
	Symbol         string `json:"symbol"`
	CurrencySymbol string `json:"currencySymbol"`
	Type           string `json:"type"`
	RateUSD        string `json:"rateUSD"`
}

SingleCurrency holds data of a currency. Used for API fetches

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL