Various fixes, enabled preciseLocation input by default
This commit is contained in:
parent
8fca373437
commit
8ebfb3de51
6 changed files with 71 additions and 41 deletions
|
@ -63,9 +63,14 @@ export default class UserRelatedState extends ElementsState {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (layoutToUse?.hideFromOverview) {
|
if (layoutToUse?.hideFromOverview) {
|
||||||
this.osmConnection
|
this.osmConnection.isLoggedIn.addCallbackAndRunD(loggedIn => {
|
||||||
.GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled")
|
if(loggedIn){
|
||||||
.setData("true");
|
this.osmConnection
|
||||||
|
.GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled")
|
||||||
|
.setData("true");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.installedThemes = new InstalledThemes(
|
this.installedThemes = new InstalledThemes(
|
||||||
|
|
|
@ -162,7 +162,9 @@ export default class LayerConfig {
|
||||||
}
|
}
|
||||||
this.presets = (json.presets ?? []).map((pr, i) => {
|
this.presets = (json.presets ?? []).map((pr, i) => {
|
||||||
|
|
||||||
let preciseInput = undefined;
|
let preciseInput = {
|
||||||
|
preferredBackground: "photo"
|
||||||
|
};
|
||||||
if (pr.preciseInput !== undefined) {
|
if (pr.preciseInput !== undefined) {
|
||||||
if (pr.preciseInput === true) {
|
if (pr.preciseInput === true) {
|
||||||
pr.preciseInput = {
|
pr.preciseInput = {
|
||||||
|
|
|
@ -43,52 +43,63 @@ export default class MoreScreen extends Combine {
|
||||||
super([
|
super([
|
||||||
intro,
|
intro,
|
||||||
MoreScreen.createOfficialThemesList(state, themeButtonStyle).SetClass(themeListStyle),
|
MoreScreen.createOfficialThemesList(state, themeButtonStyle).SetClass(themeListStyle),
|
||||||
MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle).SetClass(themeListStyle),
|
MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle, themeListStyle),
|
||||||
MoreScreen.createUnofficialThemeList(themeButtonStyle, state)?.SetClass(themeListStyle),
|
MoreScreen.createUnofficialThemeList(themeButtonStyle, state, themeListStyle),
|
||||||
tr.streetcomplete.Clone().SetClass("block text-base mx-10 my-3 mb-10")
|
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 => {
|
return new VariableUiElement(state.installedThemes.map(customThemes => {
|
||||||
const els: BaseUIElement[] = []
|
const els: BaseUIElement[] = []
|
||||||
if (customThemes.length > 0) {
|
if (customThemes.length > 0) {
|
||||||
els.push(Translations.t.general.customThemeIntro.Clone())
|
|
||||||
|
|
||||||
const customThemesElement = new Combine(
|
const customThemesElement = new Combine(
|
||||||
customThemes.map(theme => MoreScreen.createLinkButton(state, theme.layout, theme.definition)?.SetClass(buttonClass))
|
customThemes.map(theme => MoreScreen.createLinkButton(state, theme.layout, theme.definition)?.SetClass(buttonClass))
|
||||||
)
|
)
|
||||||
els.push(customThemesElement)
|
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){
|
private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string, themeListStyle: string) {
|
||||||
const t= Translations.t.general.morescreen
|
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(
|
return new Toggle(
|
||||||
new Combine([
|
|
||||||
new Title(t.previouslyHiddenTitle.Clone()),
|
|
||||||
t.hiddenExplanation,
|
|
||||||
|
|
||||||
|
|
||||||
new VariableUiElement(
|
new VariableUiElement(
|
||||||
state.osmConnection.preferencesHandler.preferences.map(allPreferences => {
|
state.osmConnection.preferencesHandler.preferences.map(allPreferences => {
|
||||||
const knownThemes = Utils.NoNull( Object.keys(allPreferences).filter(key => key.startsWith("hidden-theme-"))
|
const knownThemes = Utils.NoNull(Object.keys(allPreferences)
|
||||||
.map(key => key.substr("hidden-theme-".length, key.length - "-enabled".length))
|
.filter(key => key.startsWith(prefix))
|
||||||
.map(theme => AllKnownLayouts.allKnownLayouts.get(theme) ))
|
.map(key => key.substring(prefix.length, key.length - "-enabled".length))
|
||||||
return new Combine(knownThemes.map(layout =>
|
.map(theme => {
|
||||||
MoreScreen.createLinkButton(state, layout ).SetClass(buttonClass)
|
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,
|
undefined,
|
||||||
state.osmConnection.isLoggedIn
|
state.osmConnection.isLoggedIn
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +111,9 @@ export default class MoreScreen extends Combine {
|
||||||
console.trace("Layout is undefined")
|
console.trace("Layout is undefined")
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
if(layout.hideFromOverview){
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
const button = MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass);
|
const button = MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass);
|
||||||
if (layout.id === personal.id) {
|
if (layout.id === personal.id) {
|
||||||
return new VariableUiElement(
|
return new VariableUiElement(
|
||||||
|
@ -154,21 +168,14 @@ export default class MoreScreen extends Combine {
|
||||||
}, layout: LayoutConfig, customThemeDefinition: string = undefined
|
}, layout: LayoutConfig, customThemeDefinition: string = undefined
|
||||||
):
|
):
|
||||||
BaseUIElement {
|
BaseUIElement {
|
||||||
if (layout
|
if (layout === undefined) {
|
||||||
|
return undefined;
|
||||||
===
|
|
||||||
undefined
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
undefined;
|
|
||||||
}
|
}
|
||||||
if (layout.id === undefined) {
|
if (layout.id === undefined) {
|
||||||
console.error("ID is undefined for layout", layout);
|
console.error("ID is undefined for layout", layout);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (layout.hideFromOverview) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (layout.id === state?.layoutToUse?.id) {
|
if (layout.id === state?.layoutToUse?.id) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {FixedUiElement} from "../Base/FixedUiElement";
|
||||||
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer";
|
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer";
|
||||||
import BaseUIElement from "../BaseUIElement";
|
import BaseUIElement from "../BaseUIElement";
|
||||||
import Toggle from "./Toggle";
|
import Toggle from "./Toggle";
|
||||||
|
import {start} from "repl";
|
||||||
|
|
||||||
export default class LocationInput extends InputElement<Loc> implements MinimapObj {
|
export default class LocationInput extends InputElement<Loc> implements MinimapObj {
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
||||||
} else {
|
} else {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
|
||||||
if (self._snappedPointTags !== undefined) {
|
if (self._snappedPointTags !== undefined) {
|
||||||
const layout = State.state.layoutToUse
|
const layout = State.state.layoutToUse
|
||||||
|
|
||||||
|
@ -163,7 +163,14 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
||||||
try {
|
try {
|
||||||
const self = this;
|
const self = this;
|
||||||
const hasMoved = new UIEventSource(false)
|
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)
|
hasMoved.setData(true)
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
|
@ -521,6 +521,9 @@
|
||||||
"en": "A tree of a species with leaves, such as oak or populus.",
|
"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.",
|
"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."
|
"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.",
|
"it": "Un albero di una specie con aghi come il pino o l’abete.",
|
||||||
"ru": "Дерево с хвоей (иглами), например, сосна или ель.",
|
"ru": "Дерево с хвоей (иглами), например, сосна или ель.",
|
||||||
"fr": "Une espèce d’arbre avec des épines comme le pin ou l’épicéa."
|
"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.",
|
"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.",
|
"fr": "Si vous n'êtes pas sûr(e) de savoir s'il s'agit d'un arbre à feuilles larges ou à aiguilles.",
|
||||||
"ru": "Если вы не уверены в том, лиственное это дерево или хвойное."
|
"ru": "Если вы не уверены в том, лиственное это дерево или хвойное."
|
||||||
|
},
|
||||||
|
"preciseInput": {
|
||||||
|
"preferredBackground": "photo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
"streetcomplete": "Another, similar application is <a href='https://play.google.com/store/apps/details?id=de.westnordost.streetcomplete' class='underline hover:text-blue-800' class='underline hover:text-blue-800' target='_blank'>StreetComplete</a>.",
|
"streetcomplete": "Another, similar application is <a href='https://play.google.com/store/apps/details?id=de.westnordost.streetcomplete' class='underline hover:text-blue-800' class='underline hover:text-blue-800' target='_blank'>StreetComplete</a>.",
|
||||||
"createYourOwnTheme": "Create your own MapComplete theme from scratch",
|
"createYourOwnTheme": "Create your own MapComplete theme from scratch",
|
||||||
"previouslyHiddenTitle": "Previously visited hidden themes",
|
"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": {
|
"sharescreen": {
|
||||||
"intro": "<h3>Share this map</h3> Share this map by copying the link below and sending it to friends and family:",
|
"intro": "<h3>Share this map</h3> Share this map by copying the link below and sending it to friends and family:",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue