BottomNavTab.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Rectangle {
  4. property string icon: ""
  5. property string text: ""
  6. property bool active: false
  7. signal clicked()
  8. color: "transparent"
  9. // Active indicator (blue bottom border)
  10. Rectangle {
  11. anchors.bottom: parent.bottom
  12. width: parent.width
  13. height: 3
  14. color: active ? "#2563eb" : "transparent"
  15. Behavior on color {
  16. ColorAnimation { duration: 200 }
  17. }
  18. }
  19. Column {
  20. anchors.centerIn: parent
  21. spacing: 4
  22. // Icon (using emoji for cross-platform compatibility)
  23. Text {
  24. property string iconValue: parent.parent.icon
  25. text: {
  26. // Debug log the icon value
  27. console.log("BottomNavTab icon value:", iconValue)
  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. default: {
  35. console.log("Unknown icon:", iconValue, "- using 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 ? "#2563eb" : "#6b7280"
  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 ? "#2563eb" : "#6b7280"
  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: "#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. }