forked from MapComplete/MapComplete
Android: add inset spacers (experimental)
This commit is contained in:
parent
7ce320075d
commit
94949e14a6
5 changed files with 61 additions and 1 deletions
|
|
@ -94,6 +94,37 @@ export class AndroidPolyfill {
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets how much padding we should add on top and at the bottom; in pixels
|
||||||
|
*/
|
||||||
|
private static insets: { top: Store<number>, bottom: Store<number> } = undefined
|
||||||
|
|
||||||
|
public static getInsetSizes(): Readonly<{ top: Store<number>, bottom: Store<number> }> {
|
||||||
|
if (AndroidPolyfill.insets) {
|
||||||
|
return AndroidPolyfill.insets
|
||||||
|
}
|
||||||
|
const insets = {
|
||||||
|
top: new UIEventSource(0),
|
||||||
|
bottom: new UIEventSource(0),
|
||||||
|
}
|
||||||
|
AndroidPolyfill.insets = insets
|
||||||
|
|
||||||
|
console.log("Web: requesting inset sizes")
|
||||||
|
DatabridgePluginSingleton.request<{ top: number, bottom: number }>({
|
||||||
|
key: "insets",
|
||||||
|
}).then((result) => {
|
||||||
|
let v = result.value
|
||||||
|
if(typeof v === "string"){
|
||||||
|
v = JSON.parse(v)
|
||||||
|
}
|
||||||
|
console.log("Got inset sizes:", result)
|
||||||
|
insets.bottom.set(v.bottom)
|
||||||
|
insets.top.set(v.top)
|
||||||
|
})
|
||||||
|
|
||||||
|
return insets
|
||||||
|
}
|
||||||
|
|
||||||
public static onBackButton(
|
public static onBackButton(
|
||||||
callback: () => boolean,
|
callback: () => boolean,
|
||||||
options: {
|
options: {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
import { MenuIcon } from "@rgossiaux/svelte-heroicons/solid"
|
import { MenuIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
import AccordionSingle from "./Flowbite/AccordionSingle.svelte"
|
import AccordionSingle from "./Flowbite/AccordionSingle.svelte"
|
||||||
import MenuDrawerIndex from "./BigComponents/MenuDrawerIndex.svelte"
|
import MenuDrawerIndex from "./BigComponents/MenuDrawerIndex.svelte"
|
||||||
|
import InsetSpacer from "./Base/InsetSpacer.svelte"
|
||||||
|
|
||||||
AndroidPolyfill.init().then(() => console.log("Android polyfill setup completed"))
|
AndroidPolyfill.init().then(() => console.log("Android polyfill setup completed"))
|
||||||
const featureSwitches = new OsmConnectionFeatureSwitches()
|
const featureSwitches = new OsmConnectionFeatureSwitches()
|
||||||
|
|
@ -133,6 +134,9 @@
|
||||||
{ returnToIndex: new ImmutableStore(false) }
|
{ returnToIndex: new ImmutableStore(false) }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const topSPace = AndroidPolyfill.getInsetSizes().top
|
||||||
|
const bottom = AndroidPolyfill.getInsetSizes().bottom
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the first search candidate
|
* Opens the first search candidate
|
||||||
*/
|
*/
|
||||||
|
|
@ -155,8 +159,8 @@
|
||||||
<DrawerLeft shown={guistate.pageStates.menu}>
|
<DrawerLeft shown={guistate.pageStates.menu}>
|
||||||
<MenuDrawerIndex onlyLink={true} state={menuDrawerState} />
|
<MenuDrawerIndex onlyLink={true} state={menuDrawerState} />
|
||||||
</DrawerLeft>
|
</DrawerLeft>
|
||||||
|
|
||||||
<div class="flex w-screen flex-col p-2 sm:p-4">
|
<div class="flex w-screen flex-col p-2 sm:p-4">
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().top}/>
|
||||||
<div class="flex w-full justify-between overflow-hidden">
|
<div class="flex w-full justify-between overflow-hidden">
|
||||||
<button on:click={() => guistate.pageStates.menu.set(true)} class="m-0 rounded-full p-2">
|
<button on:click={() => guistate.pageStates.menu.set(true)} class="m-0 rounded-full p-2">
|
||||||
<MenuIcon class="h-6 w-6 cursor-pointer" />
|
<MenuIcon class="h-6 w-6 cursor-pointer" />
|
||||||
|
|
@ -170,6 +174,9 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Inset sizes:
|
||||||
|
{$topSPace} {$bottom}
|
||||||
|
|
||||||
<div class="mt-4 flex overflow-hidden break-words">
|
<div class="mt-4 flex overflow-hidden break-words">
|
||||||
<div class="m-3 hidden flex-none md:block">
|
<div class="m-3 hidden flex-none md:block">
|
||||||
<Logo alt="MapComplete Logo" class="h-12 w-12 sm:h-24 sm:w-24" />
|
<Logo alt="MapComplete Logo" class="h-12 w-12 sm:h-24 sm:w-24" />
|
||||||
|
|
@ -267,6 +274,9 @@
|
||||||
v{Constants.vNumber}
|
v{Constants.vNumber}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().bottom}/>
|
||||||
|
|
||||||
|
|
||||||
<div class="absolute top-0 h-0 w-0" style="margin-left: -10em">
|
<div class="absolute top-0 h-0 w-0" style="margin-left: -10em">
|
||||||
<MenuDrawer onlyLink={false} state={menuDrawerState} />
|
<MenuDrawer onlyLink={false} state={menuDrawerState} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
8
src/UI/Base/InsetSpacer.svelte
Normal file
8
src/UI/Base/InsetSpacer.svelte
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script lang="ts">
|
||||||
|
/**
|
||||||
|
* in pixels
|
||||||
|
*/
|
||||||
|
export let height: Store<number>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div style={"height: "+$height+"px; background: red;"} />
|
||||||
|
|
@ -59,6 +59,7 @@
|
||||||
import { PhotoIcon } from "@babeard/svelte-heroicons/outline"
|
import { PhotoIcon } from "@babeard/svelte-heroicons/outline"
|
||||||
import ImageUploadQueue from "../../Logic/ImageProviders/ImageUploadQueue"
|
import ImageUploadQueue from "../../Logic/ImageProviders/ImageUploadQueue"
|
||||||
import QueuedImagesView from "../Image/QueuedImagesView.svelte"
|
import QueuedImagesView from "../Image/QueuedImagesView.svelte"
|
||||||
|
import InsetSpacer from "../Base/InsetSpacer.svelte"
|
||||||
|
|
||||||
export let state: {
|
export let state: {
|
||||||
favourites: FavouritesFeatureSource
|
favourites: FavouritesFeatureSource
|
||||||
|
|
@ -102,6 +103,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="low-interaction flex h-full flex-col overflow-hidden" class:hidden={!$shown}>
|
<div class="low-interaction flex h-full flex-col overflow-hidden" class:hidden={!$shown}>
|
||||||
|
{#if onlyLink}
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().top} />
|
||||||
|
{/if}
|
||||||
<div class="flex justify-between border-b border-black p-2">
|
<div class="flex justify-between border-b border-black p-2">
|
||||||
<h2>
|
<h2>
|
||||||
<Tr t={t.title} />
|
<Tr t={t.title} />
|
||||||
|
|
@ -330,4 +334,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{#if onlyLink}
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().bottom} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@
|
||||||
import GpsElementHelper from "./BigComponents/GpsElementHelper.svelte"
|
import GpsElementHelper from "./BigComponents/GpsElementHelper.svelte"
|
||||||
import { dragDetection } from "../Utils/dragDetection"
|
import { dragDetection } from "../Utils/dragDetection"
|
||||||
import WelcomeBack from "./BigComponents/WelcomeBack.svelte"
|
import WelcomeBack from "./BigComponents/WelcomeBack.svelte"
|
||||||
|
import InsetSpacer from "./Base/InsetSpacer.svelte"
|
||||||
|
import { AndroidPolyfill } from "../Logic/Web/AndroidPolyfill"
|
||||||
export let state: WithSearchState
|
export let state: WithSearchState
|
||||||
new TitleHandler(state.selectedElement, state)
|
new TitleHandler(state.selectedElement, state)
|
||||||
|
|
||||||
|
|
@ -332,6 +334,7 @@
|
||||||
</If>
|
</If>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().bottom}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DrawerRight shown={state.searchState.showSearchDrawer}>
|
<DrawerRight shown={state.searchState.showSearchDrawer}>
|
||||||
|
|
@ -340,6 +343,7 @@
|
||||||
|
|
||||||
<!-- Top components -->
|
<!-- Top components -->
|
||||||
<div class="z-4 pointer-events-none absolute left-0 top-0 w-full">
|
<div class="z-4 pointer-events-none absolute left-0 top-0 w-full">
|
||||||
|
<InsetSpacer height={AndroidPolyfill.getInsetSizes().top}/>
|
||||||
<div
|
<div
|
||||||
id="top-bar"
|
id="top-bar"
|
||||||
class="bg-black-light-transparent pointer-events-auto flex flex-wrap items-center justify-between px-4 py-1"
|
class="bg-black-light-transparent pointer-events-auto flex flex-wrap items-center justify-between px-4 py-1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue