1
0

BottomNavTab.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // Debug log the icon value
  28. // Map icon names to Unicode symbols that work on Raspberry Pi
  29. switch(iconValue) {
  30. case "search": return "⌕" // U+2315 - Works better than magnifying glass
  31. case "list_alt": return "☰" // U+2630 - Hamburger menu, widely supported
  32. case "table_chart": return "⚙" // U+2699 - Gear without variant selector
  33. case "play_arrow": return "▶" // U+25B6 - Play without variant selector
  34. case "lightbulb": return "☀" // U+2600 - Sun symbol for LED
  35. default: {
  36. return "□" // U+25A1 - Simple box, universally supported
  37. }
  38. }
  39. }
  40. font.pixelSize: 20
  41. font.family: "sans-serif" // Use system sans-serif font
  42. color: parent.parent.active ? Components.ThemeManager.navIconActive : Components.ThemeManager.navIconInactive
  43. anchors.horizontalCenter: parent.horizontalCenter
  44. Behavior on color {
  45. ColorAnimation { duration: 200 }
  46. }
  47. }
  48. // Label
  49. Label {
  50. text: parent.parent.text
  51. font.pixelSize: 11
  52. font.weight: Font.Medium
  53. color: parent.parent.active ? Components.ThemeManager.navTextActive : Components.ThemeManager.navTextInactive
  54. anchors.horizontalCenter: parent.horizontalCenter
  55. Behavior on color {
  56. ColorAnimation { duration: 200 }
  57. }
  58. }
  59. }
  60. // Touch feedback
  61. Rectangle {
  62. id: touchFeedback
  63. anchors.fill: parent
  64. color: Components.ThemeManager.darkMode ? "#404040" : "#f3f4f6"
  65. opacity: 0
  66. radius: 0
  67. NumberAnimation {
  68. id: touchAnimation
  69. target: touchFeedback
  70. property: "opacity"
  71. from: 0.3
  72. to: 0
  73. duration: 200
  74. easing.type: Easing.OutQuad
  75. }
  76. }
  77. MouseArea {
  78. anchors.fill: parent
  79. onClicked: parent.clicked()
  80. onPressed: {
  81. touchAnimation.stop()
  82. touchFeedback.opacity = 0.3
  83. }
  84. onReleased: {
  85. touchAnimation.start()
  86. }
  87. onCanceled: {
  88. touchAnimation.start()
  89. }
  90. }
  91. }