Skip to content

Commit

Permalink
fix: optimize offline
Browse files Browse the repository at this point in the history
  • Loading branch information
bastyen committed Mar 20, 2024
1 parent 5db51d2 commit 6005119
Show file tree
Hide file tree
Showing 68 changed files with 265 additions and 494 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@types/leaflet.markercluster": "^1.5.4",
"babel-loader": "^9.1.3",
"glob": "^9.3.4",
"stencil-inline-svg": "^1.1.0",
"typescript": "^5.4.2",
"vitepress": "^1.0.0-rc.45"
},
Expand Down
1 change: 1 addition & 0 deletions src/assets/arrow-back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/backpack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/call.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/download_for_offline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filter_list.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/list.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/location_searching.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/mail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/moving.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/offline_pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/open_in_full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/summarize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/timelapse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/translate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions src/components/grw-app/grw-app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Capacitor } from '@capacitor/core';
import { Component, Host, h, Listen, State, Prop, Element, Watch, Event, EventEmitter, Fragment } from '@stencil/core';
import { translate } from 'i18n/i18n';
import state, { reset } from 'store/store';
import { handleTreksFiltersAndSearch } from 'utils/utils';
import { handleTreksFiltersAndSearch, imagesRegExp, revokeObjectURL } from 'utils/utils';
import ArrowBackIcon from '../../assets/arrow-back.svg';

@Component({
tag: 'grw-app',
Expand Down Expand Up @@ -279,6 +281,13 @@ export class GrwApp {

handleBackButton() {
if (window.history.state && window.history.state.isInitialHistoryWithDetails) {
if (state.currentTrek.offline && !Capacitor.isNativePlatform()) {
revokeObjectURL(state.currentPois, imagesRegExp, ['url']);
revokeObjectURL(state.trekTouristicEvents, imagesRegExp, ['url']);
revokeObjectURL(state.trekTouristicContents, imagesRegExp, ['url']);
revokeObjectURL(state.currentInformationDesks, imagesRegExp);
revokeObjectURL(state.currentTrek, imagesRegExp, ['url']);
}
this.onDetailsClose();
const url = new URL(window.location.toString());
url.searchParams.delete('trek');
Expand Down Expand Up @@ -561,10 +570,7 @@ export class GrwApp {
) : (
<div class="grw-arrow-back-container">
<button onClick={() => this.handleBackButton()} class="grw-arrow-back-icon">
{/* @ts-ignore */}
<span translate={false} part="icon" class="material-symbols material-symbols-outlined icon">
arrow_back
</span>
<span part="icon" class="icon" innerHTML={ArrowBackIcon}></span>
</button>
</div>
)}
Expand Down
8 changes: 0 additions & 8 deletions src/components/grw-common-button/grw-common-button.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
.material-symbols {
font-family: 'Material Symbols Outlined';
}

.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

.common-button {
user-select: none;
cursor: pointer;
Expand Down
7 changes: 3 additions & 4 deletions src/components/grw-common-button/grw-common-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, Host, Prop, h } from '@stencil/core';
import RefreshIcon from '../../assets/refresh.svg';
import FilterListIcon from '../../assets/filter_list.svg';

@Component({
tag: 'grw-common-button',
Expand All @@ -20,10 +22,7 @@ export class GrwCommonButton {
}}
>
<button part="common-button" class="common-button" onClick={() => this.action()}>
{/* @ts-ignore */}
<span part="common-button-icon" class="material-symbols material-symbols-outlined icon" translate={false}>
{this.icon}
</span>
<span part="common-button-icon" class="icon" innerHTML={this.icon === 'refresh' ? RefreshIcon : FilterListIcon}></span>
<span part="common-button-label" class="label">
{this.name}
</span>
Expand Down
10 changes: 1 addition & 9 deletions src/components/grw-extended-fab/grw-extended-fab.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
.material-symbols {
font-family: 'Material Symbols Outlined';
}

.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

.map-visibility-button {
cursor: pointer;
user-select: none;
Expand All @@ -28,7 +20,7 @@
box-shadow: var(--elevation-4);
}
.icon {
font-size: 24px;
display: flex;
margin-right: 8px;
color: var(--fab-color);
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/grw-extended-fab/grw-extended-fab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Component, Host, Prop, h } from '@stencil/core';
import SummarizeIcon from '../../assets/summarize.svg';
import MapIcon from '../../assets/map.svg';
import ListIcon from '../../assets/list.svg';

@Component({
tag: 'grw-extended-fab',
Expand All @@ -14,17 +17,15 @@ export class GrwExtendedFab {
@Prop() fontFamily = 'Roboto';

render() {
const icon = this.icon();
return (
<Host
style={{
'--font-family': this.fontFamily,
}}
>
<button part="map-visibility-button" class="map-visibility-button" onClick={() => this.action()} style={{ display: this.display }}>
{/* @ts-ignore */}
<span part="map-visibility-button-icon" class="material-symbols material-symbols-outlined icon" translate={false}>
{this.icon()}
</span>
<span part="map-visibility-button-icon" class="icon" innerHTML={icon === 'Summarize' ? SummarizeIcon : icon === 'map' ? MapIcon : ListIcon}></span>
<span part="map-visibility-button-label" class="label">
{this.name()}
</span>
Expand Down
10 changes: 1 addition & 9 deletions src/components/grw-filter/grw-filter.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
@import '~choices.js/public/assets/styles/base.min.css';
@import '~choices.js/public/assets/styles/choices.min.css';

.material-symbols {
font-family: 'Material Symbols Outlined';
}

.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

.filter-name {
margin-left: 8px;
color: var(--color-on-surface);
Expand Down Expand Up @@ -107,7 +99,7 @@
color: var(--color-on-secondary-container);
background-color: var(--color-secondary-container);
.icon {
font-size: 24px;
display: flex;
margin-right: 8px;
color: var(--color-on-secondary-container);
}
Expand Down
17 changes: 10 additions & 7 deletions src/components/grw-filter/grw-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
handleTouristicEventsFiltersAndSearch,
} from 'utils/utils';
import 'choices.js/public/assets/scripts/choices.min.js';
import CheckIcon from '../../assets/check.svg';

@Component({
tag: 'grw-filter',
Expand Down Expand Up @@ -128,20 +129,22 @@ export class GrwFilter {
'--font-family': this.fontFamily,
}}
>
<div part="filter-name" class="filter-name display-large">{this.filterName}</div>
<div part="filter-name" class="filter-name display-large">
{this.filterName}
</div>
<div part="filter-button-container" class="filter-button-container">
{state[this.filterType].length > 9 ? (
<select part="filter-select" multiple ref={el => (this.choicesRef = el)}></select>
) : (
state[this.filterType]
.filter(currentFilter => !currentFilter.hasOwnProperty('filter') || (currentFilter.hasOwnProperty('filter') && currentFilter.filter))
.map(currentFilter => (
<button part="filter-button" class={currentFilter.selected ? 'filter-button selected-filter-button' : 'filter-button'} onClick={event => this.handleFilter(event, currentFilter)}>
{/* @ts-ignore */}
{currentFilter.selected && (<span part="selected-filter-icon" class="material-symbols material-symbols-outlined icon" translate={false}>
check
</span>
)}
<button
part="filter-button"
class={currentFilter.selected ? 'filter-button selected-filter-button' : 'filter-button'}
onClick={event => this.handleFilter(event, currentFilter)}
>
{currentFilter.selected && <span part="selected-filter-icon" class="icon" innerHTML={CheckIcon}></span>}
<span part="filter-label" class="filter-label">
{currentFilter[this.filterNameProperty]}
</span>
Expand Down
11 changes: 2 additions & 9 deletions src/components/grw-information-desk/grw-information-desk.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
.material-symbols {
font-family: 'Material Symbols Outlined';
}

.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

:host {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -66,6 +58,7 @@
display: flex;
align-items: center;
.icon {
display: flex;
font-size: 16px;
margin-right: 8px;
}
Expand Down Expand Up @@ -95,6 +88,6 @@
box-shadow: var(--elevation-2);
}
.icon {
font-size: 18px;
display: flex;
}
}
Loading

0 comments on commit 6005119

Please sign in to comment.