device.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package mobile
  2. import (
  3. "fyne.io/fyne/v2/driver/mobile"
  4. "fyne.io/fyne/v2/internal/driver/mobile/event/size"
  5. "fyne.io/fyne/v2"
  6. )
  7. type device struct {
  8. safeTop, safeLeft, safeWidth, safeHeight int
  9. }
  10. //lint:file-ignore U1000 Var currentDPI is used in other files, but not here
  11. var (
  12. currentOrientation size.Orientation
  13. currentDPI float32
  14. )
  15. // Declare conformity with Device
  16. var _ fyne.Device = (*device)(nil)
  17. func (*device) Orientation() fyne.DeviceOrientation {
  18. switch currentOrientation {
  19. case size.OrientationLandscape:
  20. return fyne.OrientationHorizontalLeft
  21. default:
  22. return fyne.OrientationVertical
  23. }
  24. }
  25. func (*device) IsMobile() bool {
  26. return true
  27. }
  28. func (*device) IsBrowser() bool {
  29. return false
  30. }
  31. func (*device) HasKeyboard() bool {
  32. return false
  33. }
  34. func (*device) ShowVirtualKeyboard() {
  35. showVirtualKeyboard(mobile.DefaultKeyboard)
  36. }
  37. func (*device) ShowVirtualKeyboardType(keyboard mobile.KeyboardType) {
  38. showVirtualKeyboard(keyboard)
  39. }
  40. func (*device) HideVirtualKeyboard() {
  41. hideVirtualKeyboard()
  42. }