preferences.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package fyne
  2. // Preferences describes the ways that an app can save and load user preferences
  3. type Preferences interface {
  4. // Bool looks up a boolean value for the key
  5. Bool(key string) bool
  6. // BoolWithFallback looks up a boolean value and returns the given fallback if not found
  7. BoolWithFallback(key string, fallback bool) bool
  8. // SetBool saves a boolean value for the given key
  9. SetBool(key string, value bool)
  10. // Float looks up a float64 value for the key
  11. Float(key string) float64
  12. // FloatWithFallback looks up a float64 value and returns the given fallback if not found
  13. FloatWithFallback(key string, fallback float64) float64
  14. // SetFloat saves a float64 value for the given key
  15. SetFloat(key string, value float64)
  16. // Int looks up an integer value for the key
  17. Int(key string) int
  18. // IntWithFallback looks up an integer value and returns the given fallback if not found
  19. IntWithFallback(key string, fallback int) int
  20. // SetInt saves an integer value for the given key
  21. SetInt(key string, value int)
  22. // String looks up a string value for the key
  23. String(key string) string
  24. // StringWithFallback looks up a string value and returns the given fallback if not found
  25. StringWithFallback(key, fallback string) string
  26. // SetString saves a string value for the given key
  27. SetString(key string, value string)
  28. // RemoveValue removes a value for the given key (not currently supported on iOS)
  29. RemoveValue(key string)
  30. // AddChangeListener allows code to be notified when some preferences change. This will fire on any update.
  31. AddChangeListener(func())
  32. // ChangeListeners returns a list of the known change listeners for this preference set.
  33. //
  34. // Since: 2.3
  35. ChangeListeners() []func()
  36. }