forked from MapComplete/MapComplete
Huge refactoring of state and initial UI setup
This commit is contained in:
parent
4e43673de5
commit
eff6b5bfad
37 changed files with 5232 additions and 4907 deletions
|
@ -2,7 +2,6 @@ import Combine from "../Base/Combine";
|
|||
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
|
||||
import Translations from "../i18n/Translations";
|
||||
import AttributionPanel from "./AttributionPanel";
|
||||
import State from "../../State";
|
||||
import ContributorCount from "../../Logic/ContributorCount";
|
||||
import Toggle from "../Input/Toggle";
|
||||
import MapControlButton from "../MapControlButton";
|
||||
|
@ -13,16 +12,33 @@ import {UIEventSource} from "../../Logic/UIEventSource";
|
|||
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
||||
import Loc from "../../Models/Loc";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||
import FilteredLayer from "../../Models/FilteredLayer";
|
||||
|
||||
export default class LeftControls extends Combine {
|
||||
|
||||
constructor(state: {featurePipeline: FeaturePipeline, currentBounds: UIEventSource<BBox>, locationControl: UIEventSource<Loc>, overlayToggles: any}) {
|
||||
constructor(state: {
|
||||
layoutToUse: LayoutConfig,
|
||||
featurePipeline: FeaturePipeline,
|
||||
currentBounds: UIEventSource<BBox>,
|
||||
locationControl: UIEventSource<Loc>,
|
||||
overlayToggles: any,
|
||||
featureSwitchEnableExport: UIEventSource<boolean>,
|
||||
featureSwitchExportAsPdf: UIEventSource<boolean>,
|
||||
filteredLayers: UIEventSource<FilteredLayer[]>,
|
||||
featureSwitchFilter: UIEventSource<boolean>,
|
||||
selectedElement: UIEventSource<any>
|
||||
},
|
||||
guiState: {
|
||||
downloadControlIsOpened: UIEventSource<boolean>,
|
||||
filterViewIsOpened: UIEventSource<boolean>,
|
||||
}) {
|
||||
|
||||
const toggledCopyright = new ScrollableFullScreen(
|
||||
() => Translations.t.general.attribution.attributionTitle.Clone(),
|
||||
() =>
|
||||
new AttributionPanel(
|
||||
State.state.layoutToUse,
|
||||
state.layoutToUse,
|
||||
new ContributorCount(state).Contributors
|
||||
),
|
||||
undefined
|
||||
|
@ -38,50 +54,50 @@ export default class LeftControls extends Combine {
|
|||
|
||||
const toggledDownload = new Toggle(
|
||||
new AllDownloads(
|
||||
State.state.downloadControlIsOpened
|
||||
guiState.downloadControlIsOpened
|
||||
).SetClass("block p-1 rounded-full"),
|
||||
new MapControlButton(Svg.download_svg())
|
||||
.onClick(() => State.state.downloadControlIsOpened.setData(true)),
|
||||
State.state.downloadControlIsOpened
|
||||
.onClick(() => guiState.downloadControlIsOpened.setData(true)),
|
||||
guiState.downloadControlIsOpened
|
||||
)
|
||||
|
||||
const downloadButtonn = new Toggle(
|
||||
toggledDownload,
|
||||
undefined,
|
||||
State.state.featureSwitchEnableExport.map(downloadEnabled => downloadEnabled || State.state.featureSwitchExportAsPdf.data,
|
||||
[State.state.featureSwitchExportAsPdf])
|
||||
state.featureSwitchEnableExport.map(downloadEnabled => downloadEnabled || state.featureSwitchExportAsPdf.data,
|
||||
[state.featureSwitchExportAsPdf])
|
||||
);
|
||||
|
||||
const toggledFilter = new Toggle(
|
||||
new ScrollableFullScreen(
|
||||
() => Translations.t.general.layerSelection.title.Clone(),
|
||||
() =>
|
||||
new FilterView(State.state.filteredLayers, state.overlayToggles).SetClass(
|
||||
new FilterView(state.filteredLayers, state.overlayToggles).SetClass(
|
||||
"block p-1 rounded-full"
|
||||
),
|
||||
undefined,
|
||||
State.state.filterIsOpened
|
||||
guiState.filterViewIsOpened
|
||||
),
|
||||
new MapControlButton(Svg.filter_svg())
|
||||
.onClick(() => State.state.filterIsOpened.setData(true)),
|
||||
State.state.filterIsOpened
|
||||
.onClick(() => guiState.filterViewIsOpened.setData(true)),
|
||||
guiState.filterViewIsOpened
|
||||
)
|
||||
|
||||
const filterButton = new Toggle(
|
||||
toggledFilter,
|
||||
undefined,
|
||||
State.state.featureSwitchFilter
|
||||
state.featureSwitchFilter
|
||||
);
|
||||
|
||||
|
||||
State.state.locationControl.addCallback(() => {
|
||||
state.locationControl.addCallback(() => {
|
||||
// Close the layer selection when the map is moved
|
||||
toggledDownload.isEnabled.setData(false);
|
||||
copyrightButton.isEnabled.setData(false);
|
||||
toggledFilter.isEnabled.setData(false);
|
||||
});
|
||||
|
||||
State.state.selectedElement.addCallbackAndRunD((_) => {
|
||||
state.selectedElement.addCallbackAndRunD((_) => {
|
||||
toggledDownload.isEnabled.setData(false);
|
||||
copyrightButton.isEnabled.setData(false);
|
||||
toggledFilter.isEnabled.setData(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue