BottomNavTab.qml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. default: {
  36. console.log("Unknown icon:", iconValue, "- using default")
  37. return "□" // U+25A1 - Simple box, universally supported
  38. }
  39. }
  40. }
  41. font.pixelSize: 20
  42. font.family: "sans-serif" // Use system sans-serif font
  43. color: parent.parent.active ? Components.ThemeManager.navIconActive : Components.ThemeManager.navIconInactive
  44. anchors.horizontalCenter: parent.horizontalCenter
  45. Behavior on color {
  46. ColorAnimation { duration: 200 }
  47. }
  48. }
  49. // Label
  50. Label {
  51. text: parent.parent.text
  52. font.pixelSize: 11
  53. font.weight: Font.Medium
  54. color: parent.parent.active ? Components.ThemeManager.navTextActive : Components.ThemeManager.navTextInactive
  55. anchors.horizontalCenter: parent.horizontalCenter
  56. Behavior on color {
  57. ColorAnimation { duration: 200 }
  58. }
  59. }
  60. }
  61. // Touch feedback
  62. Rectangle {
  63. id: touchFeedback
  64. anchors.fill: parent
  65. color: Components.ThemeManager.darkMode ? "#404040" : "#f3f4f6"
  66. opacity: 0
  67. radius: 0
  68. NumberAnimation {
  69. id: touchAnimation
  70. target: touchFeedback
  71. property: "opacity"
  72. from: 0.3
  73. to: 0
  74. duration: 200
  75. easing.type: Easing.OutQuad
  76. }
  77. }
  78. MouseArea {
  79. anchors.fill: parent
  80. onClicked: parent.clicked()
  81. onPressed: {
  82. touchAnimation.stop()
  83. touchFeedback.opacity = 0.3
  84. }
  85. onReleased: {
  86. touchAnimation.start()
  87. }
  88. onCanceled: {
  89. touchAnimation.start()
  90. }
  91. }
  92. }