diff --git a/Logic/State/UserRelatedState.ts b/Logic/State/UserRelatedState.ts index 622d7f3943..68c32351aa 100644 --- a/Logic/State/UserRelatedState.ts +++ b/Logic/State/UserRelatedState.ts @@ -63,9 +63,14 @@ export default class UserRelatedState extends ElementsState { ); if (layoutToUse?.hideFromOverview) { - this.osmConnection - .GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled") - .setData("true"); + this.osmConnection.isLoggedIn.addCallbackAndRunD(loggedIn => { + if(loggedIn){ + this.osmConnection + .GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled") + .setData("true"); + return true; + } + }) } this.installedThemes = new InstalledThemes( diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index 9e21e82af6..f167732162 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -162,7 +162,9 @@ export default class LayerConfig { } this.presets = (json.presets ?? []).map((pr, i) => { - let preciseInput = undefined; + let preciseInput = { + preferredBackground: "photo" + }; if (pr.preciseInput !== undefined) { if (pr.preciseInput === true) { pr.preciseInput = { diff --git a/UI/BigComponents/MoreScreen.ts b/UI/BigComponents/MoreScreen.ts index 719df82c98..606aab1159 100644 --- a/UI/BigComponents/MoreScreen.ts +++ b/UI/BigComponents/MoreScreen.ts @@ -43,52 +43,63 @@ export default class MoreScreen extends Combine { super([ intro, MoreScreen.createOfficialThemesList(state, themeButtonStyle).SetClass(themeListStyle), - MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle).SetClass(themeListStyle), - MoreScreen.createUnofficialThemeList(themeButtonStyle, state)?.SetClass(themeListStyle), + MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle, themeListStyle), + MoreScreen.createUnofficialThemeList(themeButtonStyle, state, themeListStyle), tr.streetcomplete.Clone().SetClass("block text-base mx-10 my-3 mb-10") ]); } - private static createUnofficialThemeList(buttonClass: string, state: UserRelatedState): BaseUIElement { + private static createUnofficialThemeList(buttonClass: string, state: UserRelatedState, themeListClasses): BaseUIElement { return new VariableUiElement(state.installedThemes.map(customThemes => { const els: BaseUIElement[] = [] if (customThemes.length > 0) { - els.push(Translations.t.general.customThemeIntro.Clone()) - const customThemesElement = new Combine( customThemes.map(theme => MoreScreen.createLinkButton(state, theme.layout, theme.definition)?.SetClass(buttonClass)) ) els.push(customThemesElement) } - return els; + return new Combine([ + Translations.t.general.customThemeIntro.Clone(), + new Combine(els).SetClass(themeListClasses) + ]); })); } - - private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string){ - const t= Translations.t.general.morescreen + + private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string, themeListStyle: string) { + const t = Translations.t.general.morescreen + console.log("Hidden themes init...") + const prefix = "mapcomplete-hidden-theme-" + const hiddenTotal = AllKnownLayouts.layoutsList.filter(layout => layout.hideFromOverview).length return new Toggle( - new Combine([ - new Title(t.previouslyHiddenTitle.Clone()), - t.hiddenExplanation, - - new VariableUiElement( state.osmConnection.preferencesHandler.preferences.map(allPreferences => { - const knownThemes = Utils.NoNull( Object.keys(allPreferences).filter(key => key.startsWith("hidden-theme-")) - .map(key => key.substr("hidden-theme-".length, key.length - "-enabled".length)) - .map(theme => AllKnownLayouts.allKnownLayouts.get(theme) )) - return new Combine(knownThemes.map(layout => - MoreScreen.createLinkButton(state, layout ).SetClass(buttonClass) - )) - + const knownThemes = Utils.NoNull(Object.keys(allPreferences) + .filter(key => key.startsWith(prefix)) + .map(key => key.substring(prefix.length, key.length - "-enabled".length)) + .map(theme => { + return AllKnownLayouts.allKnownLayouts.get(theme); + })) + if (knownThemes.length === 0) { + return undefined + } + + const knownLayouts = new Combine(knownThemes.map(layout => + MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass) + )).SetClass(themeListStyle) + + return new Combine([ + new Title(t.previouslyHiddenTitle), + t.hiddenExplanation.Subs({hidden_discovered: ""+knownThemes.length,total_hidden: ""+hiddenTotal}), + knownLayouts + ]) + }) - - )]).SetClass("flex flex-col"), + ).SetClass("flex flex-col"), undefined, state.osmConnection.isLoggedIn ) - + } @@ -100,6 +111,9 @@ export default class MoreScreen extends Combine { console.trace("Layout is undefined") return undefined } + if(layout.hideFromOverview){ + return undefined; + } const button = MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass); if (layout.id === personal.id) { return new VariableUiElement( @@ -154,21 +168,14 @@ export default class MoreScreen extends Combine { }, layout: LayoutConfig, customThemeDefinition: string = undefined ): BaseUIElement { - if (layout - - === - undefined - ) { - return - undefined; + if (layout === undefined) { + return undefined; } if (layout.id === undefined) { console.error("ID is undefined for layout", layout); return undefined; } - if (layout.hideFromOverview) { - return undefined; - } + if (layout.id === state?.layoutToUse?.id) { return undefined; } diff --git a/UI/Input/LocationInput.ts b/UI/Input/LocationInput.ts index 93144ee5ea..8e5474c330 100644 --- a/UI/Input/LocationInput.ts +++ b/UI/Input/LocationInput.ts @@ -16,6 +16,7 @@ import {FixedUiElement} from "../Base/FixedUiElement"; import ShowDataLayer from "../ShowDataLayer/ShowDataLayer"; import BaseUIElement from "../BaseUIElement"; import Toggle from "./Toggle"; +import {start} from "repl"; export default class LocationInput extends InputElement implements MinimapObj { @@ -71,7 +72,6 @@ export default class LocationInput extends InputElement implements MinimapO } else { const self = this; - if (self._snappedPointTags !== undefined) { const layout = State.state.layoutToUse @@ -163,7 +163,14 @@ export default class LocationInput extends InputElement implements MinimapO try { const self = this; const hasMoved = new UIEventSource(false) - this.GetValue().addCallbackAndRunD(_ => { + const startLocation = { ...this._centerLocation.data } + this._centerLocation. addCallbackD(newLocation => { + const f = 100000 + console.log(newLocation.lon, startLocation.lon) + const diff = (Math.abs(newLocation.lon * f - startLocation.lon* f ) + Math.abs(newLocation.lat* f - startLocation.lat* f )) + if(diff < 1){ + return; + } hasMoved.setData(true) return true; }) diff --git a/assets/layers/tree_node/tree_node.json b/assets/layers/tree_node/tree_node.json index a504f74b1c..fed48e7700 100644 --- a/assets/layers/tree_node/tree_node.json +++ b/assets/layers/tree_node/tree_node.json @@ -521,6 +521,9 @@ "en": "A tree of a species with leaves, such as oak or populus.", "it": "Un albero di una specie con foglie larghe come la quercia o il pioppo.", "fr": "Un arbre d'une espèce avec de larges feuilles, comme le chêne ou le peuplier." + }, + "preciseInput": { + "preferredBackground": "photo" } }, { @@ -541,6 +544,9 @@ "it": "Un albero di una specie con aghi come il pino o l’abete.", "ru": "Дерево с хвоей (иглами), например, сосна или ель.", "fr": "Une espèce d’arbre avec des épines comme le pin ou l’épicéa." + }, + "preciseInput": { + "preferredBackground": "photo" } }, { @@ -561,6 +567,9 @@ "it": "Qualora non si sia sicuri se si tratta di un albero latifoglia o aghifoglia.", "fr": "Si vous n'êtes pas sûr(e) de savoir s'il s'agit d'un arbre à feuilles larges ou à aiguilles.", "ru": "Если вы не уверены в том, лиственное это дерево или хвойное." + }, + "preciseInput": { + "preferredBackground": "photo" } } ], diff --git a/langs/en.json b/langs/en.json index b6463cd732..4054cb8ef8 100644 --- a/langs/en.json +++ b/langs/en.json @@ -126,7 +126,7 @@ "streetcomplete": "Another, similar application is StreetComplete.", "createYourOwnTheme": "Create your own MapComplete theme from scratch", "previouslyHiddenTitle": "Previously visited hidden themes", - "hiddenExplanation": "These themes are only visible if you know the link..." + "hiddenExplanation": "These themes are only visible if you know the link. You have discovered {hidden_discovered} out of {total_hidden} hidden themes" }, "sharescreen": { "intro": "

Share this map

Share this map by copying the link below and sending it to friends and family:",