Skip to content

Commit 16079a6

Browse files
committed
fix: allow to lock item
1 parent a4b3d29 commit 16079a6

11 files changed

Lines changed: 116 additions & 44 deletions

File tree

app/components/bottomsheet/BottomSheetInfoView.svelte

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { getMapContext } from '~/mapModules/MapModule';
1414
1515
const propsPaint = new Paint();
16-
propsPaint.textSize = 14;
16+
propsPaint.textSize = 13;
1717
propsPaint.setTextAlign(Align.LEFT);
1818
1919
const iconPaint = new Paint();
@@ -55,17 +55,14 @@
5555
let nString;
5656
let nString2;
5757
let nString3;
58-
let userOnRouteData;
5958
6059
const itemsModule = getMapContext().mapModule('items');
6160
itemsModule.on('user_onroute_data', (event: any) => {
6261
if (!item || !ApplicationSettings.getBoolean('draw_onroute_live_data', false)) {
63-
userOnRouteData = null;
6462
nString3 = null;
6563
return;
6664
}
6765
if(event.remainingDistance) {
68-
userOnRouteData = event;
6966
nString3= createNativeAttributedString({
7067
spans: [
7168
{
@@ -91,7 +88,6 @@
9188
])
9289
});
9390
} else {
94-
userOnRouteData = null;
9591
nString3 = null;
9692
}
9793
canvas?.nativeView.invalidate();
@@ -110,6 +106,7 @@
110106
if (!it) {
111107
nString = null;
112108
nString2 = null;
109+
nString3 = null;
113110
return;
114111
}
115112
itemProps = it?.properties;
@@ -294,6 +291,7 @@
294291
canvas.restore();
295292
}
296293
if (nString2) {
294+
propsPaint.textSize = 14;
297295
const staticLayout = new StaticLayout(nString2, propsPaint, w, LayoutAlignment.ALIGN_OPPOSITE, 1, 0, true);
298296
canvas.save();
299297
canvas.translate(paddingLeft, paddingTop + h - props2Bottom);
@@ -308,9 +306,9 @@
308306
canvas.translate(paddingLeft, paddingTop);
309307
staticLayout.draw(canvas);
310308
canvas.restore();
311-
propsPaint.textSize = 14;
309+
312310
}
313-
311+
propsPaint.textSize = 13;
314312
if (item.properties?.['opening_hours']) {
315313
const data = openingHoursText(item);
316314
propsPaint.color = data.color;

app/components/bottomsheet/BottomSheetInner.svelte

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@
3838
import { ALERT_OPTION_MAX_HEIGHT } from '~/utils/constants';
3939
import { VerticalPosition } from '@nativescript-community/ui-popover';
4040
import dayjs from 'dayjs';
41+
import { import {
42+
cityMinZoom,
43+
forestPatternZoom,
44+
rockPatternZoom,
45+
scrubPatternZoom,
46+
screePatternZoom,
47+
contourLinesOpacity,
48+
emphasisDrinkingWater,
49+
emphasisRails,
50+
mapFontScale,
51+
pitchEnabled,
52+
preloading,
53+
projectionModeSpherical,
54+
rotateEnabled,
55+
routesType,
56+
show3DBuildings,
57+
showContourLines,
58+
showRoutes,
59+
showSlopePercentages,
60+
showSubBoundaries,
61+
showPolygonsBorder,
62+
showRoadShields,
63+
showRouteShields,
64+
showItemsLayer,
65+
itemLock
66+
} from '~/stores/mapStore'; } from '~/stores/mapStore';
4167
4268
$: ({ colorError, colorOnSurface, colorOnSurfaceVariant, colorOutlineVariant, colorPrimary, colorWidgetBackground } = $colors);
4369
const PROFILE_HEIGHT = 150;
@@ -275,12 +301,13 @@
275301
function updateRouteItemWithPosition(routeItem: Item, location: GenericMapPos<LatLonKeys>, updateNavigationInstruction = true, updateGraph = true, highlight?: Highlight<Entry>) {
276302
// DEV_LOG && console.log('updateRouteItemWithPosition', !!routeItem?.route, JSON.stringify(location), updateNavigationInstruction, updateGraph, !JSON.stringify(!highlight));
277303
try {
278-
if (routeItem?.route) {
304+
if (routeItem?.route) {
305+
const distanceFromRouteMeters = ApplicationSettings.getNumber('location_distance_from_route', 15);
279306
// const props = routeItem.properties;
280307
const route = routeItem.route;
281308
const positions = packageService.getRouteItemPoses(routeItem);
282309
// DEV_LOG && console.log('updateRouteItemWithPosition', JSON.stringify(location), JSON.stringify(positions));
283-
const onPathIndex = isLocationOnPath(location, positions, false, true, 15);
310+
const onPathIndex = isLocationOnPath(location, positions, false, true, distanceFromRouteMeters);
284311
let remainingDistance: number, remainingTime: number;
285312
// DEV_LOG && console.log('updateRouteItemWithPosition onPathIndex', onPathIndex, JSON.stringify(routeItem.instructions));
286313
if (onPathIndex !== -1 && (graphAvailable || highlight || (routeItem.instructions && updateNavigationInstruction && !graphAvailable))) {
@@ -948,17 +975,26 @@
948975
</BottomSheetInfoView>
949976
<IconButton prop:leftDrawer backgroundColor={colorError} color="white" height="100%" shape="none" text="mdi-trash-can" tooltip={lc('delete')} width={60} on:tap={deleteItem} />
950977

951-
<!-- <stacklayout prop:rightDrawer orientation="horizontal"> -->
978+
<stacklayout prop:rightDrawer orientation="horizontal">
952979
<IconButton
953-
prop:rightDrawer
980+
954981
backgroundColor={new Color(colorPrimary).setAlpha(180).hex}
955982
color="white"
956983
height="100%"
957984
shape="none"
958985
text="mdi-crosshairs-gps"
959986
width={60}
960987
on:tap={zoomToItem} />
961-
<!-- </stacklayout> -->
988+
<IconButton
989+
990+
backgroundColor={new Color(colorPrimary).setAlpha(180).hex}
991+
color="white"
992+
height="100%"
993+
shape="none"
994+
text={$itemLock ? "mdi-lock-off-outline" : "mdi-lock-outline}
995+
width={60}
996+
on:tap={() => $itemLock = !$itemLock} />
997+
</stacklayout>
962998
</swipemenu>
963999

9641000
<scrollview borderBottomWidth={1} borderColor={colorOutlineVariant} borderTopWidth={1} colSpan={2} orientation="horizontal" row={1}>

app/components/directions/DirectionsPanel.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,12 +1286,11 @@
12861286
height={30}
12871287
margin="0 0 0 30"
12881288
on:tap={(event) => openSearchFromItem(event, item)}>
1289-
<label color={buttonsColor} fontSize={15} lineBreak="end" marginLeft={15} maxLines={1} text={item.properties.name} verticalTextAlignment="center" />
1289+
<label color={buttonsColor} fontSize={15} lineBreak="end" marginLeft={15} maxLines={1} text={formatter.getItemName(item)} verticalTextAlignment="center" />
12901290

12911291
<IconButton
12921292
col={1}
12931293
color={buttonsColor}
1294-
isVisible={item.properties.name && item.properties.name.length > 0}
12951294
small={true}
12961295
text="mdi-delete"
12971296
on:tap={() => clearWayPoint(item)} />

app/components/map/Map.svelte

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import { debounce } from '@nativescript/core/utils';
3030
import { Sentry, isSentryEnabled } from '@shared/utils/sentry';
3131
import { navigate } from '@shared/utils/svelte/ui';
32+
import { writable } from 'svelte/store';
3233
import { tryCatch, tryCatchFunction } from '@shared/utils/ui';
3334
import type { Point as GeoJSONPoint } from 'geojson';
3435
import { onDestroy, onMount } from 'svelte';
@@ -78,7 +79,8 @@
7879
showPolygonsBorder,
7980
showRoadShields,
8081
showRouteShields,
81-
showItemsLayer
82+
showItemsLayer,
83+
itemLock
8284
} from '~/stores/mapStore';
8385
import { ALERT_OPTION_MAX_HEIGHT, DEFAULT_TILE_SERVER_AUTO_START, DEFAULT_TILE_SERVER_PORT, SETTINGS_TILE_SERVER_AUTO_START, SETTINGS_TILE_SERVER_PORT } from '~/utils/constants';
8486
import { getBoundsZoomLevel } from '~/utils/geo';
@@ -125,7 +127,7 @@
125127
let steps;
126128
let topTranslationY;
127129
let networkConnected = false;
128-
const itemLoading = false;
130+
const itemLoading = false;
129131
130132
let projection: Projection = new EPSG4326();
131133
const addedLayers: { layer: Layer<any, any>; layerId: LayerType }[] = [];
@@ -810,6 +812,9 @@
810812
forceZoomOut?: boolean;
811813
}) {
812814
try {
815+
if ($itemLock && $selectedItem) {
816+
return;
817+
}
813818
didIgnoreAlreadySelected = false;
814819
if (isFeatureInteresting) {
815820
const isCurrentItem = item === $selectedItem;
@@ -1035,8 +1040,16 @@
10351040
}
10361041
// DEV_LOG && console.log('zoomToItem done ');
10371042
}
1038-
export function unselectItem(updateBottomSheet = true) {
1043+
export function unselectItem(updateBottomSheet = true, forceUnlock = false) {
10391044
// TEST_LOG && console.log('unselectItem', updateBottomSheet, !!$selectedItem);
1045+
1046+
if ($itemLock) {
1047+
if (forceUnlock) {
1048+
$itemLock = false;
1049+
} else {
1050+
return;
1051+
}
1052+
}
10401053
if (!!$selectedItem) {
10411054
// mapContext.mapDecoder.setStyleParameter('selected_id', '');
10421055
setSelectedItem(null);
@@ -1106,7 +1119,7 @@
11061119
$: cartoMap?.getOptions().setRotationGestures($rotateEnabled);
11071120
$: cartoMap?.getOptions().setTiltRange(toNativeMapRange([$pitchEnabled ? 30 : 90, 90]));
11081121
// $: currentLayer && (currentLayer.preloading = $preloading);
1109-
$: bottomSheetStepIndex === 0 && unselectItem();
1122+
$: bottomSheetStepIndex === 0 && unselectItem(true, true);
11101123
$: {
11111124
if (steps?.length) {
11121125
mapContext.focusOffset = { x: 0, y: Utils.layout.toDevicePixels(steps[bottomSheetStepIndex]) / 2 };
@@ -2206,7 +2219,7 @@
22062219
mapContext.innerDecoder.setStyleParameter('editing_id', item.properties.id + '');
22072220
getMapContext().mapModule('items').showItem(item);
22082221
editingItem = item;
2209-
unselectItem();
2222+
unselectItem(true, true);
22102223
22112224
// getMapContext().mapModule('items').hideItem(item);
22122225
}

app/components/settings/Settings.svelte

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script context="module" lang="ts">
1+
<script context="module" lang="ts">
22
import { share } from '@akylas/nativescript-app-utils/share';
33
import { isPermResultAuthorized, request } from '@nativescript-community/perms';
44
import { SDK_VERSION } from '@nativescript-community/sentry';
@@ -133,10 +133,24 @@
133133
key: SETTINGS_NAVIGATION_POSITION_OFFSET,
134134
min: 0,
135135
max: 0.5,
136-
step: 0.1,
136+
step: 0.01,
137137
title: lc('navigation_position_offset'),
138138
type: 'slider',
139139
rightValue: () => ApplicationSettings.getNumber(SETTINGS_NAVIGATION_POSITION_OFFSET, DEFAULT_NAVIGATION_POSITION_OFFSET)
140+
},
141+
{
142+
id: 'setting',
143+
type: 'prompt',
144+
title: lc('offline_routing_pedestrian_max_distance'),
145+
key: 'location_distance_from_route',
146+
valueType: 'number',
147+
default: 15,
148+
textFieldProperties: {
149+
keyboardType: 'number',
150+
autocapitalizationType: 'none',
151+
autocorrect: false
152+
} as TextFieldProperties,
153+
rightValue: () => ApplicationSettings.getNumber('location_distance_from_route', 15)
140154
}
141155
];
142156
case 'general':

app/mapModules/ItemsModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ export default class ItemsModule extends MapModule {
438438
}
439439
async hideItem(item: IItem) {
440440
if (item === mapContext.getSelectedItem()) {
441-
mapContext.unselectItem();
441+
mapContext.unselectItem(true, true);
442442
}
443443
const index = this.currentItems.findIndex((d) => d.id === item.id);
444444
if (index > -1) {
@@ -452,7 +452,7 @@ export default class ItemsModule extends MapModule {
452452
async deleteItem(item: IItem) {
453453
DEV_LOG && console.log('deleteItem', item.id);
454454
if (item === mapContext.getSelectedItem()) {
455-
mapContext.unselectItem();
455+
mapContext.unselectItem(true, true);
456456
}
457457
const index = this.currentItems.findIndex((d) => d.id === item.id);
458458
if (index > -1) {

app/stores/mapStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ export const scrubPatternZoom = settingsStore('scrubPatternZoom', -1);
5959
export const showPolygonsBorder = settingsStore('showPolygonsBorder', true);
6060
export const showRoadShields = settingsStore('showRoadShields', true);
6161
export const showRouteShields = settingsStore('showRouteShields', false);
62-
export const showItemsLayer = settingsStore('showItemsLayer', true);
62+
export const showItemsLayer = settingsStore('showItemsLayer', true);
63+
export const itemLock = writable(false);

dev_assets/styles/inner/shared/route.mss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
line-cap: round;
3131
// line-opacity:linear([view::zoom], (16, 1), (18, 0.4));
3232
// line-opacity: [osmid] = [nuti::selected_osmid] ? linear([view::zoom], (14, 1), (15, 0.3), (17, 0.1)):0.5;
33-
line-width: @route_width +([osmid]=[nuti::selected_osmid] ? 1 : 0);
33+
line-width: @route_width +([osmid]=[nuti::selected_osmid] ? 2 : 0);
3434
// line-offset: @routeOffset * linear([view::zoom], (15, 0), (16, 1), (18, 4));
3535

3636
// line-dasharray: [id] = [nuti::selected_id] ? (0,0) : @biking_route_dasharray;
@@ -41,7 +41,7 @@
4141
// }
4242

4343
[class=bicycle] {
44-
line-width: @biking_route_width +([osmid]=[nuti::selected_osmid] ? 1 : 0);
44+
line-width: @biking_route_width +([osmid]=[nuti::selected_osmid] ? 2 : 0);
4545
line-color: @biking_symbolColor;
4646
[zoom>='nuti::routes_dash_min_zoom'] {
4747
line-dasharray: @biking_route_dasharray;
@@ -53,6 +53,7 @@
5353
[network=2][zoom>=8],
5454
[network=3][zoom>=9]{
5555
shield-name: [ref];
56+
shield-placement-priority: 10-[network];
5657
shield-size: @shield-size;
5758
shield-line-spacing: @shield-line-spacing;
5859
shield-placement: line;

dev_assets/styles/inner/shared/style.mss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131

3232
@shield-size: 8;
3333
@shield-line-spacing: -1.50; // -0.15 em
34-
@shield-size-z18: 12;
35-
@shield-spacing: 260;
36-
@shield-repeat-distance: 200;
34+
@shield-spacing: 160;
35+
@shield-repeat-distance: 100;
3736
@shield-margin: 40;
3837
@shield-clip: false;

0 commit comments

Comments
 (0)