|
| 1 | +//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3 |
| 2 | + |
| 3 | +<template> |
| 4 | + <GridLayout |
| 5 | + class="app-control-panel" |
| 6 | + width="100%" |
| 7 | + height="100%" |
| 8 | + rows="auto, auto, *" |
| 9 | + columns="*"> |
| 10 | + |
| 11 | + <StackLayout class="panel-header" row="0" col="0" verticalAlignment="top"> |
| 12 | + <Label |
| 13 | + class="panel-header-line" |
| 14 | + /> |
| 15 | + </StackLayout> |
| 16 | + |
| 17 | + <!-- buttons --> |
| 18 | + <GridLayout class="panel-buttons" row="1" col="0" columns="auto, *, auto, auto, auto" verticalAlignment="top"> |
| 19 | + <!-- Quick Access Button --> |
| 20 | + <MDButton |
| 21 | + col="0" |
| 22 | + variant="flat" |
| 23 | + rippleColor="#ffffff" |
| 24 | + class="fa app-control-button" |
| 25 | + :class="{ 'app-control-button--active': isPanelOpen && (activeButton === 'quick' || activeButton === null) }" |
| 26 | + :text="'fa-bars' | fonticon" |
| 27 | + @tap="handleControlButtonTap('quick', $event)" |
| 28 | + @pan="handleControlButtonPan('quick', $event)" |
| 29 | + /> |
| 30 | + |
| 31 | + <!-- Search Button --> |
| 32 | + <MDButton |
| 33 | + col="2" |
| 34 | + variant="flat" |
| 35 | + rippleColor="#ffffff" |
| 36 | + class="fa app-control-button" |
| 37 | + :class="{ 'app-control-button--active': isPanelOpen && activeButton === 'search' }" |
| 38 | + :text="'fa-search' | fonticon" |
| 39 | + @tap="handleControlButtonTap('search', $event)" |
| 40 | + @pan="handleControlButtonPan('search', $event)" |
| 41 | + /> |
| 42 | + |
| 43 | + <!-- Location Button --> |
| 44 | + <MDButton |
| 45 | + col="3" |
| 46 | + variant="flat" |
| 47 | + rippleColor="#ffffff" |
| 48 | + class="fa app-control-button" |
| 49 | + :text="locationButtonIcon | fonticon" |
| 50 | + @tap="onLocate" |
| 51 | + /> |
| 52 | + |
| 53 | + <!-- Layers Button --> |
| 54 | + <MDButton |
| 55 | + col="4" |
| 56 | + variant="flat" |
| 57 | + rippleColor="#ffffff" |
| 58 | + class="fa app-control-button" |
| 59 | + :class="{ 'app-control-button--active': isPanelOpen && activeButton === 'layers' }" |
| 60 | + :text="'fa-layer-group' | fonticon" |
| 61 | + @tap="handleControlButtonTap('layers', $event)" |
| 62 | + @pan="handleControlButtonPan('layers', $event)" |
| 63 | + /> |
| 64 | + |
| 65 | + </GridLayout> |
| 66 | + |
| 67 | + <!-- content --> |
| 68 | + <ScrollView row="2" col="0" :height="maxHeight - 64" verticalAlignment="top"> |
| 69 | + <StackLayout class="panel-body"> |
| 70 | + <QuickAccessView |
| 71 | + v-show="activeButton === 'quick' || activeButton === null" |
| 72 | + /> |
| 73 | + |
| 74 | + <LayersView |
| 75 | + v-show="activeButton === 'layers'" |
| 76 | + /> |
| 77 | + |
| 78 | + <SearchView |
| 79 | + v-show="activeButton === 'search'" |
| 80 | + /> |
| 81 | + </StackLayout> |
| 82 | + </ScrollView> |
| 83 | + </GridLayout> |
| 84 | +</template> |
| 85 | + |
| 86 | +<script> |
| 87 | +import QuickAccessView from "./components/QuickAccessView.vue"; |
| 88 | +import LayersView from "./components/LayersView.vue"; |
| 89 | +import SearchView from "./components/SearchView.vue"; |
| 90 | +import { mapState, mapActions, mapGetters } from 'vuex'; |
| 91 | +import { buttonGestureHandlerMixin } from './button-gesture-handler'; |
| 92 | +
|
| 93 | +export default { |
| 94 | + name: 'AppControlPanel', |
| 95 | +
|
| 96 | + mixins: [buttonGestureHandlerMixin], |
| 97 | +
|
| 98 | + components: { |
| 99 | + QuickAccessView, |
| 100 | + LayersView, |
| 101 | + SearchView, |
| 102 | + }, |
| 103 | +
|
| 104 | + props: { |
| 105 | + maxHeight: { |
| 106 | + type: Number, |
| 107 | + required: true |
| 108 | + } |
| 109 | + }, |
| 110 | +
|
| 111 | + computed: { |
| 112 | + /** |
| 113 | + * Get activeButton from local state or Vuex |
| 114 | + */ |
| 115 | + activeButton: { |
| 116 | + get() { |
| 117 | + return this.$data._activeButton || this.storedActivePanel; |
| 118 | + }, |
| 119 | + set(value) { |
| 120 | + this.$data._activeButton = value; |
| 121 | + } |
| 122 | + }, |
| 123 | +
|
| 124 | + /** |
| 125 | + * Determine location button icon based on follow mode |
| 126 | + */ |
| 127 | + locationButtonIcon() { |
| 128 | + return this.isFollowingUser |
| 129 | + ? 'fa-crosshairs' // Following mode icon |
| 130 | + : 'fa-location-arrow'; // Regular locate icon |
| 131 | + }, |
| 132 | +
|
| 133 | + ...mapState({ |
| 134 | + storedActivePanel: state => state.ui.activePanel, |
| 135 | + isPanelOpen: state => state.ui.panelState.isOpen |
| 136 | + }), |
| 137 | +
|
| 138 | + ...mapGetters('map', ['isFollowingUser']) |
| 139 | + }, |
| 140 | +
|
| 141 | + data() { |
| 142 | + return { |
| 143 | + _activeButton: null, // Internal storage for local changes |
| 144 | + } |
| 145 | + }, |
| 146 | +
|
| 147 | + watch: { |
| 148 | + storedActivePanel(newValue) { |
| 149 | + this._activeButton = newValue; |
| 150 | + } |
| 151 | + }, |
| 152 | +
|
| 153 | + methods: { |
| 154 | + ...mapActions({ |
| 155 | + setActivePanel: 'ui/setActivePanel', |
| 156 | + switchPanel: 'ui/switchPanel' |
| 157 | + }), |
| 158 | +
|
| 159 | + /** |
| 160 | + * Set active button and update panel state |
| 161 | + */ |
| 162 | + setActiveButton(button) { |
| 163 | + // If panel is closed, always open with the selected button |
| 164 | + if (!this.isPanelOpen) { |
| 165 | + this.switchPanel(button); |
| 166 | + return; |
| 167 | + } |
| 168 | +
|
| 169 | + // If clicking the same button again, deactivate it |
| 170 | + if (button === this.activeButton) { |
| 171 | + this.setActivePanel(null); |
| 172 | + return; |
| 173 | + } |
| 174 | +
|
| 175 | + // Use switchPanel action to change active panel |
| 176 | + this.switchPanel(button); |
| 177 | + }, |
| 178 | +
|
| 179 | + /** |
| 180 | + * Handle control button tap with gesture handling |
| 181 | + */ |
| 182 | + handleControlButtonTap(buttonName, event) { |
| 183 | + this.handleButtonTap(event); |
| 184 | +
|
| 185 | + if (this.isCurrentlyPanning()) { |
| 186 | + return; |
| 187 | + } |
| 188 | +
|
| 189 | + const isActive = this.isPanelOpen && |
| 190 | + (buttonName === 'quick' ? |
| 191 | + (this.activeButton === 'quick' || this.activeButton === null) : |
| 192 | + this.activeButton === buttonName); |
| 193 | +
|
| 194 | + const action = isActive ? null : buttonName; |
| 195 | + this.setActiveButton(action); |
| 196 | + }, |
| 197 | +
|
| 198 | + /** |
| 199 | + * Handle control button pan gesture |
| 200 | + */ |
| 201 | + handleControlButtonPan(buttonName, event) { |
| 202 | + this.handleButtonPan(event); |
| 203 | + }, |
| 204 | +
|
| 205 | + /** |
| 206 | + * Handle location button tap |
| 207 | + */ |
| 208 | + async onLocate() { |
| 209 | + await this.$store.dispatch('map/triggerUserLocate'); |
| 210 | + } |
| 211 | + }, |
| 212 | +
|
| 213 | + created() { |
| 214 | + // Initialize active button from store |
| 215 | + this._activeButton = this.storedActivePanel || 'quick'; |
| 216 | + }, |
| 217 | +} |
| 218 | +</script> |
| 219 | + |
| 220 | +<style scoped lang="scss"> |
| 221 | +@import '@/app'; |
| 222 | +
|
| 223 | +.app-control-panel { |
| 224 | + background-color: $base; |
| 225 | + color: $text; |
| 226 | + border-radius: 10 10 0 0; |
| 227 | + border-color: $complementary; |
| 228 | + border-top-width: 1; |
| 229 | +} |
| 230 | +
|
| 231 | +.panel-header { |
| 232 | + height: 14; |
| 233 | + min-height: 14; |
| 234 | +} |
| 235 | +
|
| 236 | +.panel-header-line { |
| 237 | + background-color: $complementary; |
| 238 | + width: 32; |
| 239 | + height: 4; |
| 240 | + margin: 5 0; |
| 241 | + border-radius: 4; |
| 242 | + horizontal-alignment: center; |
| 243 | +} |
| 244 | +
|
| 245 | +.panel-buttons { |
| 246 | + height: 42; // 110 - 46 - 14 - 8 |
| 247 | + min-height: 42; |
| 248 | + margin: 0 10 8 10; |
| 249 | +} |
| 250 | +
|
| 251 | +.app-control-button { |
| 252 | + width: 42; |
| 253 | + min-width: 42; |
| 254 | + max-width: 42; |
| 255 | + height: 42; |
| 256 | + margin: 0 5; |
| 257 | + padding-top: 11; |
| 258 | + font-size: 18; |
| 259 | + border-radius: 10; |
| 260 | + color: rgba(255, 255, 255, 0.7); |
| 261 | + background-color: rgba(255, 255, 255, 0); |
| 262 | + text-align: center; |
| 263 | +
|
| 264 | + &--active { |
| 265 | + background-color: rgba(255, 255, 255, 0.1); |
| 266 | + } |
| 267 | +} |
| 268 | +
|
| 269 | +.panel-body { |
| 270 | + margin: 10; |
| 271 | +} |
| 272 | +
|
| 273 | +</style> |
0 commit comments