1
0

BottomNavTab.qml 3.4 KB

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