BottomNavTab.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import "." as Components
  4. Rectangle {
  5. property string icon: ""
  6. property string text: ""
  7. property bool active: false
  8. signal clicked()
  9. color: "transparent"
  10. // Active indicator (blue bottom border)
  11. Rectangle {
  12. anchors.bottom: parent.bottom
  13. width: parent.width
  14. height: 3
  15. color: active ? Components.ThemeManager.navIconActive : "transparent"
  16. Behavior on color {
  17. ColorAnimation { duration: 200 }
  18. }
  19. }
  20. Column {
  21. anchors.centerIn: parent
  22. spacing: 4
  23. // Icon (using emoji for cross-platform compatibility)
  24. Text {
  25. property string iconValue: parent.parent.icon
  26. text: {
  27. // Map icon names to Unicode symbols that work on Raspberry Pi
  28. switch(iconValue) {
  29. case "search": return "⌕" // U+2315 - Works better than magnifying glass
  30. case "list_alt": return "☰" // U+2630 - Hamburger menu, widely supported
  31. case "table_chart": return "⚙" // U+2699 - Gear without variant selector
  32. case "play_arrow": return "▶" // U+25B6 - Play without variant selector
  33. case "lightbulb": return "☀" // U+2600 - Sun symbol for LED
  34. default: return "□" // U+25A1 - Simple box, universally supported
  35. }
  36. }
  37. font.pixelSize: 20
  38. font.family: "sans-serif" // Use system sans-serif font
  39. color: parent.parent.active ? Components.ThemeManager.navIconActive : Components.ThemeManager.navIconInactive
  40. anchors.horizontalCenter: parent.horizontalCenter
  41. Behavior on color {
  42. ColorAnimation { duration: 200 }
  43. }
  44. }
  45. // Label
  46. Label {
  47. text: parent.parent.text
  48. font.pixelSize: 11
  49. font.weight: Font.Medium
  50. color: parent.parent.active ? Components.ThemeManager.navTextActive : Components.ThemeManager.navTextInactive
  51. anchors.horizontalCenter: parent.horizontalCenter
  52. Behavior on color {
  53. ColorAnimation { duration: 200 }
  54. }
  55. }
  56. }
  57. // Touch feedback
  58. Rectangle {
  59. id: touchFeedback
  60. anchors.fill: parent
  61. color: Components.ThemeManager.darkMode ? "#404040" : "#f3f4f6"
  62. opacity: 0
  63. radius: 0
  64. NumberAnimation {
  65. id: touchAnimation
  66. target: touchFeedback
  67. property: "opacity"
  68. from: 0.3
  69. to: 0
  70. duration: 200
  71. easing.type: Easing.OutQuad
  72. }
  73. }
  74. MouseArea {
  75. anchors.fill: parent
  76. onClicked: parent.clicked()
  77. onPressed: {
  78. touchAnimation.stop()
  79. touchFeedback.opacity = 0.3
  80. }
  81. onReleased: {
  82. touchAnimation.start()
  83. }
  84. onCanceled: {
  85. touchAnimation.start()
  86. }
  87. }
  88. }