load

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: ISC Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// cryptopower config keys
	HideBalanceConfigKey             = "hide_balance"
	AutoSyncConfigKey                = "autoSync"
	LanguagePreferenceKey            = "app_language"
	DarkModeConfigKey                = "dark_mode"
	FetchProposalConfigKey           = "fetch_proposals"
	SeedBackupNotificationConfigKey  = "seed_backup_notification"
	ProposalNotificationConfigKey    = "proposal_notification_key"
	TransactionNotificationConfigKey = "transaction_notification_key"
	SpendUnmixedFundsKey             = "spend_unmixed_funds"
	KnownDexServersConfigKey         = "known_dex_servers"
	GapLimitConfigKey                = "gap_limit_key"
)
View Source
const MaxInt32 = 1<<(Uint32Size-1) - 1
View Source
const Uint32Size = 32 // 32 or 64 ? shifting 32-bit value by 32 bits will always clear it

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func GetAPIFeeRate added in v1.1.0

func GetAPIFeeRate(w sharedW.Asset) ([]sharedW.FeeEstimate, error)

func MixedAccountNumber added in v1.1.0

func MixedAccountNumber(w sharedW.Asset) int32

func SetAPIFeeRate added in v1.1.0

func SetAPIFeeRate(w sharedW.Asset, feerate string) (int64, error)

SetAPIFeeRate validates the string input its a number before sending it upstream. It returns the string convert to int amount.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type AppConfig added in v1.1.0

type AppConfig struct {
	// contains filtered or unexported fields
}

AppConfig is a helper for reading and storing app-wide config values using a JSON file.

func AppConfigFromFile added in v1.1.0

func AppConfigFromFile(jsonFilePath string) (*AppConfig, error)

AppConfigFromFile attempts to load and parse the JSON file at the specified path, and read the stored config values. If there is no file at the specified path, a new AppConfig instance with default values will be returned.

func (*AppConfig) Update added in v1.1.0

func (cfg *AppConfig) Update(updateFn func(*AppConfigValues)) error

Update provides access to the current app-wide cofiguration values for updating in a concurrent-safe manner. Concurrent reads and updates are prevented when an update operation is on. Returns an error if the updated config values cannot be persisted to the JSON file; and the update is discarded.

func (*AppConfig) Values added in v1.1.0

func (cfg *AppConfig) Values() AppConfigValues

Values returns a read-only copy of the current app-wide cofiguration values.

type AppConfigValues added in v1.1.0

type AppConfigValues struct {
	NetType string `json:"netType"`
}

AppConfigValues are app-wide configuration options with their values.

type AppInfo added in v1.1.0

type AppInfo struct {
	AssetsManager *libwallet.AssetsManager
	// contains filtered or unexported fields
}

TODO: This should ultimately replace Load, acting as the container for all properties and methods that every app page and window relies on. Should probably rename as well.

func StartApp added in v1.1.0

func StartApp(version string, buildDate time.Time, netType string, appCfg *AppConfig, initAssetsManager AssetsManagerInitFn) (*AppInfo, error)

StartApp returns an instance of AppInfo with the startUpTime set to the current time. If netType is empty, the netType to use will be read from the appCfg. If a netType is provided, it'll be used instead of the netType in the appCfg; and in-app network type switching will be disabled.

func (*AppInfo) BuildDate added in v1.1.0

func (app *AppInfo) BuildDate() time.Time

BuildDate returns the app's build date.

func (*AppInfo) CanChangeNetworkType added in v1.1.0

func (app *AppInfo) CanChangeNetworkType() bool

CanChangeNetworkType is true if it is possible to change the network type used by the app.

func (*AppInfo) ChangeAssetsManager added in v1.1.0

func (app *AppInfo) ChangeAssetsManager(newAssetsManager *libwallet.AssetsManager, pageNav app.PageNavigator)

ChangeAssetsManager closes all open pages, shuts down the current AssetsManager, switches to the provided AssetsManager and then restarts the app by displaying the app's first page.

TODO: If *AppInfo.Window is changed to a custom type that implements app.WindowNavigator, this method won't need to take an app.PageNavigator parameter. See the TODO comment on *AppInfo.ReadyForDisplay() and *AppInfo.Window().

func (*AppInfo) ChangeAssetsManagerNetwork added in v1.1.0

func (app *AppInfo) ChangeAssetsManagerNetwork(netType utils.NetworkType) (*libwallet.AssetsManager, error)

ChangeAssetsManagerNetwork changes the network type used by the app to the value provided. A new AssetsManager for the specified network type is initialized and returned, but not used. Call ChangeAssetsManager to use the new AssetsManager.

func (*AppInfo) ConvertIconSize added in v1.1.0

func (app *AppInfo) ConvertIconSize(size unit.Dp) unit.Dp

ConvertIconSize returns the appropriate icon size for desktop and mobile, that corresponds to the provided value.

func (*AppInfo) ConvertTextSize added in v1.1.0

func (app *AppInfo) ConvertTextSize(size unit.Sp) unit.Sp

ConvertTextSize returns the appropriate text size for desktop and mobile, that corresponds to the provided value.

func (*AppInfo) CurrentAppWidth added in v1.1.0

func (app *AppInfo) CurrentAppWidth() unit.Dp

CurrentAppWidth returns the current width of the app's window.

func (*AppInfo) IsIOS added in v1.1.2

func (app *AppInfo) IsIOS() bool

func (*AppInfo) IsMobileView added in v1.1.0

func (app *AppInfo) IsMobileView() bool

IsMobileView returns true if the app's window width is less than the mobile view width.

func (*AppInfo) ReadyForDisplay added in v1.1.0

func (app *AppInfo) ReadyForDisplay(window *giouiApp.Window, startPage app.Page)

ReadyForDisplay marks the app as display-ready by storing the window and startPage used by the app.

TODO: Is it possible to create Load here and bring the actual display functionality over from the ui package?

func (*AppInfo) SetCurrentAppWidth added in v1.1.0

func (app *AppInfo) SetCurrentAppWidth(appWidth int, metric unit.Metric)

SetCurrentAppWidth sets the specified value as the app's current width, using the provided device-dependent metric unit conversion.

TODO: If actual display functionality is brought here over from the ui package, setting the app window's current width will be more seamless and this method can be unexported. See the TODO comment on *AppInfo.ReadyForDisplay().

func (*AppInfo) StartPage added in v1.1.0

func (app *AppInfo) StartPage() app.Page

StartPage returns the first page that is displayed when the app is launched. This page would be re-displayed if the app is restarted, e.g. when the network type is changed.

func (*AppInfo) StartupTime added in v1.1.0

func (app *AppInfo) StartupTime() time.Time

StartupTime returns the app's startup time.

func (*AppInfo) Version added in v1.1.0

func (app *AppInfo) Version() string

Version returns the app's version.

func (*AppInfo) Window added in v1.1.0

func (app *AppInfo) Window() *giouiApp.Window

Window returns the gio app window that hosts this app and is used to display different pages and modals.

TODO: Is it possible for Window to be a custom type that has navigation methods?

type AppSettingsChangeHandler

type AppSettingsChangeHandler interface {
	// OnDarkModeChanged is triggered whenever the dark mode setting is changed
	// to enable restyling UI elements where necessary.
	OnDarkModeChanged(bool)
	// OnCurrencyChanged is triggered whenever the currency setting is changed
	// to enable app refresh where necessary especially on the main page.
	OnCurrencyChanged()
	// OnLanguageChanged is triggered whenever the language setting is changed
	// to enable UI language update where necessary especially on page Nav
	OnLanguageChanged()
}

AppSettingsChangeHandler defines a method that can be implemented by pages and modals to watch for real-time changes to the dark mode setting and modify widget appearance accordingly.

type AssetsManagerInitFn added in v1.1.0

type AssetsManagerInitFn func(utils.NetworkType) (*libwallet.AssetsManager, error)

type BTCUSDTBittrex

type BTCUSDTBittrex struct {
	LastTradeRate string
}

type DCRUSDTBittrex

type DCRUSDTBittrex struct {
	LastTradeRate string
}

type KeyEventHandler

type KeyEventHandler interface {
	// KeysToHandle returns an expression that describes a set of key
	// combinations that the implementer of this interface wishes to capture.
	// The HandleKeyPress() method will only be called when any of these key
	// combinations is pressed.
	KeysToHandle() key.Set
	// HandleKeyPress is called when one or more keys are pressed on the current
	// window that match any of the key combinations returned by KeysToHandle().
	HandleKeyPress(*key.Event)
}

KeyEventHandler is implemented by pages and modals that require key event notifications.

type Load

type Load struct {
	*AppInfo

	Theme *cryptomaterial.Theme

	Printer *message.Printer
	Network string

	Toast *notification.Toast

	DarkModeSettingChanged func(bool)
	LanguageSettingChanged func()
	CurrencySettingChanged func()

	// TODO: Kill this property!
	ToggleSync func(sharedW.Asset, NeedUnlockRestore)
}

func (*Load) RefreshTheme

func (l *Load) RefreshTheme(window app.WindowNavigator)

type NeedUnlockRestore

type NeedUnlockRestore func(bool)

Jump to

Keyboard shortcuts

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