Documentation
¶
Index ¶
- Variables
- func CalculateDistance(lat1, lon1, lat2, lon2 float64) float64
- func DeriveDRPCTarget(apiURL string) string
- func DrawIconClose(gtx layout.Context, col color.NRGBA) layout.Dimensions
- func DrawIconMenu(gtx layout.Context, col color.NRGBA) layout.Dimensions
- func DrawIconSearch(gtx layout.Context, col color.NRGBA) layout.Dimensions
- func FetchAllRates(window *app.Window, state *AppState, config AppConfig)
- func FetchAllRatesRPC(window *app.Window, state *AppState, apiURL string)
- func FetchUserLocation() (float64, float64, error)
- func GenerateFakeData(points int, basePrice float64, seed int64) []float64
- func GetCachePath() string
- func GetFormattedDate(lang string, t time.Time) string
- func GetFormattedDateTime(lang string, t time.Time) string
- func GetTranslation(lang, key string) string
- func InitTranslations()
- func LanguageModal(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState) layout.Dimensions
- func LayoutRightPanel(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, ...) layout.Dimensions
- func LayoutSearchBar(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState) layout.Dimensions
- func LayoutUI(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, ...)
- func LayoutVerticalCurrencyBar(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, ...) layout.Dimensions
- func LoadCache(state *AppState)
- func LoadFontCollection() ([]font.FontFace, error)
- func ModalOverlay(gtx layout.Context, window *app.Window, state *AppState, content layout.Widget) layout.Dimensions
- func SaveCache(state *AppState)
- func StartDRPCStream(window *app.Window, state *AppState, apiURL string)
- func UpdateStateWithRate(window *app.Window, state *AppState, rate *pb.RateResponse)
- type ApiCantorResponse
- type AppConfig
- type AppState
- type CachedData
- type CantorEntry
- type CantorInfo
- type CantorItemArgs
- type CantorRowConfig
- type CantorVault
- type ColorPalette
- type ExchangeRates
- type GeoLocationResponse
- type HoverInfo
- type IntroAnim
- type LineChart
- type MarketValueArgs
- type MenuAnim
- type ModalConfig
- type Notification
- type TimeframeButtonArgs
- type UIState
Constants ¶
This section is empty.
Variables ¶
var AppColors = DarkPalette
AppColors is now a pointer that we switch
var DarkPalette = ColorPalette{ Background: color.NRGBA{R: 20, G: 20, B: 20, A: 155}, Text: color.NRGBA{R: 255, G: 255, B: 255, A: 255}, Error: color.NRGBA{R: 225, G: 50, B: 50, A: 255}, Success: color.NRGBA{R: 76, G: 175, B: 80, A: 255}, Title: color.NRGBA{R: 255, G: 184, B: 0, A: 255}, Button: color.NRGBA{R: 100, G: 100, B: 100, A: 165}, Info: color.NRGBA{R: 0, G: 190, B: 255, A: 255}, Warning: color.NRGBA{R: 255, G: 184, B: 0, A: 255}, Primary: color.NRGBA{R: 0, G: 125, B: 255, A: 255}, Secondary: color.NRGBA{R: 110, G: 115, B: 125, A: 255}, Light: color.NRGBA{R: 20, G: 18, B: 25, A: 255}, Dark: color.NRGBA{R: 0, G: 0, B: 0, A: 255}, Accent1: color.NRGBA{R: 255, G: 184, B: 0, A: 255}, Accent2: color.NRGBA{R: 255, G: 184, B: 0, A: 255}, Accent3: color.NRGBA{R: 255, G: 184, B: 0, A: 255}, Accent4: color.NRGBA{R: 20, G: 20, B: 0, A: 255}, Accent1Dark: color.NRGBA{R: 180, G: 130, B: 0, A: 255}, Spread: color.NRGBA{R: 255, G: 200, B: 0, A: 135}, }
var LightPalette = ColorPalette{ Background: color.NRGBA{R: 255, G: 255, B: 255, A: 255}, Text: color.NRGBA{R: 30, G: 30, B: 35, A: 255}, Error: color.NRGBA{R: 200, G: 30, B: 30, A: 255}, Success: color.NRGBA{R: 20, G: 120, B: 50, A: 255}, Title: color.NRGBA{R: 160, G: 110, B: 0, A: 255}, Button: color.NRGBA{R: 235, G: 235, B: 240, A: 255}, Info: color.NRGBA{R: 180, G: 130, B: 0, A: 255}, Warning: color.NRGBA{R: 180, G: 130, B: 0, A: 255}, Primary: color.NRGBA{R: 60, G: 60, B: 70, A: 255}, Secondary: color.NRGBA{R: 100, G: 100, B: 110, A: 255}, Light: color.NRGBA{R: 255, G: 255, B: 255, A: 255}, Dark: color.NRGBA{R: 248, G: 248, B: 250, A: 255}, Accent1: color.NRGBA{R: 210, G: 150, B: 0, A: 255}, Accent2: color.NRGBA{R: 60, G: 60, B: 70, A: 255}, Accent3: color.NRGBA{R: 210, G: 150, B: 0, A: 255}, Accent4: color.NRGBA{R: 248, G: 248, B: 250, A: 255}, Accent1Dark: color.NRGBA{R: 160, G: 110, B: 0, A: 255}, Spread: color.NRGBA{R: 180, G: 130, B: 0, A: 180}, }
Functions ¶
func CalculateDistance ¶
CalculateDistance returns the distance (in km) between two coordinates using the Haversine formula.
func DeriveDRPCTarget ¶
DeriveDRPCTarget parses the given API URL, extracts the host, and appends a default port of 8081 for dRPC connections.
func DrawIconClose ¶
DrawIconClose draws a Material-style close (X) icon.
func DrawIconMenu ¶
DrawIconMenu draws a Material-style hamburger menu icon.
func DrawIconSearch ¶
DrawIconSearch draws a Material-style search icon (magnifying glass).
func FetchAllRates ¶
FetchAllRates initiates the concurrent fetching of exchange rates.
func FetchAllRatesRPC ¶
FetchAllRatesRPC performs a single dRPC call to fetch all rates for the given currency.
func FetchUserLocation ¶
FetchUserLocation attempts to retrieve the user's location. On macOS, it tries to use CoreLocation via a temporary Swift script. Otherwise, it falls back to an IP-based location.
func GenerateFakeData ¶
GenerateFakeData creates a sine-wave like dataset for demo purposes.
func GetFormattedDate ¶
GetFormattedDate returns a date string localized for the given language (e.g. "24 Jan").
func GetFormattedDateTime ¶
GetFormattedDateTime returns a date and time string localized (e.g. "24 Jan 15:30").
func GetTranslation ¶
GetTranslation retrieves the translation for a given language and key. Defaults to English or returns the key if unavailable.
func InitTranslations ¶
func InitTranslations()
InitTranslations loads the translations from the embedded filesystem and initializes the global translations map.
func LanguageModal ¶
func LanguageModal(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState) layout.Dimensions
LanguageModal renders a modal for selecting a language using a modern grid-based card layout.
func LayoutRightPanel ¶
func LayoutRightPanel(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, config AppConfig) layout.Dimensions
LayoutRightPanel lays out the right-side panel of the application.
func LayoutSearchBar ¶
func LayoutSearchBar(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState) layout.Dimensions
LayoutSearchBar renders a search bar component with a text editor and a Locate button, styled and responsive to the current state.
func LayoutUI ¶
func LayoutUI(gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, config AppConfig)
LayoutUI - Main application layout
func LayoutVerticalCurrencyBar ¶
func LayoutVerticalCurrencyBar( gtx layout.Context, window *app.Window, theme *material.Theme, state *AppState, config AppConfig) layout.Dimensions
LayoutVerticalCurrencyBar creates a vertical sidebar for currency selection with a given layout, window, theme, state, and config.
func LoadCache ¶
func LoadCache(state *AppState)
LoadCache loads the application state from a local JSON file.
func LoadFontCollection ¶
LoadFontCollection loads a collection of font faces from predefined font files and returns them.
func ModalOverlay ¶
func ModalOverlay( gtx layout.Context, window *app.Window, state *AppState, content layout.Widget) layout.Dimensions
ModalOverlay displays a centrally aligned modal overlay with optional content and handles dismissal on background click.
func SaveCache ¶
func SaveCache(state *AppState)
SaveCache saves the current application state (cantors and rates) to a local JSON file.
func StartDRPCStream ¶
StartDRPCStream establishes a connection to the dRPC server and processes streaming rate updates in real-time.
func UpdateStateWithRate ¶
func UpdateStateWithRate(window *app.Window, state *AppState, rate *pb.RateResponse)
UpdateStateWithRate safely updates the application state with a new rate and triggers a UI refresh.
Types ¶
type ApiCantorResponse ¶
type ApiCantorResponse struct {
ID int `json:"id"`
DisplayName string `json:"displayName"`
Name string `json:"name"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
ApiCantorResponse for parsing JSON
type AppState ¶
type AppState struct {
Vault *CantorVault
CantorsMu sync.RWMutex
Cantors map[string]*CantorInfo
History *pb.HistoryResponse
ChartAnimStart time.Time // Tracks when the chart data was last updated for animation
LastFrameTime time.Time
IsLoadingStart time.Time
IsLoading atomic.Bool
IsConnected atomic.Bool
Notifications *Notification
UI UIState
}
AppState holds the overall state of the application.
type CachedData ¶
type CachedData struct {
Cantors map[string]*CantorInfo `json:"cantors"`
Rates map[string]*CantorEntry `json:"rates"`
SavedAt time.Time `json:"savedAt"`
}
CachedData represents the cached application state.
type CantorEntry ¶
type CantorEntry struct {
URL string
Rate ExchangeRates
Error string
LoadedAt time.Time
}
CantorEntry represents data fetched from a single cantor.
type CantorInfo ¶
type CantorInfo struct {
ID int
DisplayName string
Address string
Latitude float64
Longitude float64
Button widget.Clickable `json:"-"`
// Long Press Logic
PressStart time.Time `json:"-"`
IsPressing bool `json:"-"`
LongPressTriggered bool `json:"-"`
}
CantorInfo holds information about a cantor.
type CantorItemArgs ¶
type CantorItemArgs struct {
Cantor *CantorInfo
DisplayName string
BuyVal string
SellVal string
SpreadVal string
BuyColor color.NRGBA
SellColor color.NRGBA
Change24h float64
IsSelected bool
IsMobile bool
}
CantorItemArgs holds arguments for rendering a cantor item row.
type CantorRowConfig ¶
CantorRowConfig groups data required to render a single cantor row
type CantorVault ¶
type CantorVault struct {
Mu sync.Mutex
Rates map[string]*CantorEntry
LastEntry *CantorEntry
}
CantorVault stores the entries from all cantors
type ColorPalette ¶
type ColorPalette struct {
Background color.NRGBA
Text color.NRGBA
Error color.NRGBA
Success color.NRGBA
Title color.NRGBA
Button color.NRGBA
Info color.NRGBA
Warning color.NRGBA
Primary color.NRGBA
Secondary color.NRGBA
Light color.NRGBA
Dark color.NRGBA
Accent1 color.NRGBA
Accent2 color.NRGBA
Accent3 color.NRGBA
Accent4 color.NRGBA
Accent1Dark color.NRGBA
Spread color.NRGBA
}
ColorPalette AppColors Colors It defines the color palette used throughout the application.
type ExchangeRates ¶
type ExchangeRates struct {
BuyRate string `json:"buyRate"`
SellRate string `json:"sellRate"`
Change24h float64 `json:"change24h"`
}
ExchangeRates holds the buy and sell rates for a currency.
type GeoLocationResponse ¶
GeoLocationResponse matches the response structure from ip-api.com
type LineChart ¶
type LineChart struct {
Data []float64
Timestamps []int64 // Unix timestamps corresponding to Data points
StartLabel string
Tag any // Tag for pointer events
}
LineChart holds the configuration for a simple line chart.
type MarketValueArgs ¶
type MarketValueArgs struct {
Label string
Value string
Color color.NRGBA
Change float64
IsMobile bool
}
MarketValueArgs holds arguments for rendering a market value display.
type ModalConfig ¶
type ModalConfig struct {
Title string
Options []string
Buttons []widget.Clickable
OnSelect func(string)
}
ModalConfig represents the configuration for a modal UI component.
type Notification ¶
Notification holds information about a notification banner.
type TimeframeButtonArgs ¶
type TimeframeButtonArgs struct {
Window *app.Window
Config AppConfig
Index int
TF string
Text string
}
TimeframeButtonArgs holds arguments for rendering a timeframe selection button.
type UIState ¶
type UIState struct {
ModalOpen string
ModalAnimStart time.Time
LangModalButton widget.Clickable
CurrencyModalButton widget.Clickable
ModalClick widget.Clickable
ModalList widget.List
ModalClose widget.Clickable
MobileMenuOpen bool
MobileMenuBtn widget.Clickable
MobileMenuBackdrop widget.Clickable
BgClick widget.Clickable
IsMobile bool
LayoutTransitionTime time.Time
CurrencyList widget.List
SearchEditor widget.Editor
SearchText string
SearchActive bool
SearchClickable widget.Clickable
FilteredIDs []string
ChartMode string // "BUY" or "SELL"
ChartModeButtons []widget.Clickable // [0] -> Buy, [1] -> Sell
ChartHoverTag int // Unique tag for chart input events
ChartHoverX float32
ChartHoverActive bool
UserLocation struct {
Latitude float64
Longitude float64
Active bool
}
MaxDistance float64
DistanceSlider widget.Float
LocateButton widget.Clickable
StatusClickable widget.Clickable
HoverInfo HoverInfo
NotchState struct {
CurrentAlpha float32
LastContent HoverInfo
LastTime time.Time
LastHoverTime time.Time
HoverStartTime time.Time
}
PulseState struct {
ShowGainer bool // True = Gainer, False = Loser
LastSwitch time.Time // Last switch?
}
TopMovers struct {
GainerID string
LoserID string
LastUpdate time.Time
}
IntroAnim IntroAnim
MenuAnim MenuAnim
SelectedCantor string
SelectedLanguage string
LanguageOptions []string
CurrencyOptions []string
LanguageOptionButtons []widget.Clickable
CurrencyOptionButtons []widget.Clickable
Language string
Currency string
LightMode bool
ThemeButton widget.Clickable
SortMode string // "NAME", "BUY", "SELL", "DIST"
SortButtons []widget.Clickable
Timeframe string // "1D", "7D", "30D"
TimeframeButtons []widget.Clickable
CantorsList widget.List
}
UIState holds UI-specific state and widgets.