From dd1050d4e6cc25063e279abd5fe7f65124088fa5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 21 Feb 2022 15:44:34 +0100 Subject: [PATCH] MOBILE-3927 swipe: Make swipe-slides fill whole height --- .../calendar/addon-calendar-calendar.html | 192 +++++++++--------- .../components/calendar/calendar.scss | 5 + src/addons/calendar/pages/day/day.html | 142 ++++++------- src/addons/calendar/pages/day/day.scss | 9 +- .../mod/book/pages/contents/contents.html | 16 +- .../mod/book/pages/contents/contents.scss | 7 + .../mod/book/pages/contents/contents.ts | 1 + src/core/components/loading/loading.scss | 4 + .../components/swipe-slides/swipe-slides.scss | 4 +- .../components/swipe-slides/swipe-slides.ts | 34 +++- .../login/pages/site-policy/site-policy.html | 2 +- .../login/pages/site-policy/site-policy.scss | 6 - src/theme/theme.base.scss | 11 + 13 files changed, 235 insertions(+), 198 deletions(-) create mode 100644 src/addons/mod/book/pages/contents/contents.scss diff --git a/src/addons/calendar/components/calendar/addon-calendar-calendar.html b/src/addons/calendar/components/calendar/addon-calendar-calendar.html index 9d072a910..39466f120 100644 --- a/src/addons/calendar/components/calendar/addon-calendar-calendar.html +++ b/src/addons/calendar/components/calendar/addon-calendar-calendar.html @@ -7,102 +7,104 @@ - - - - - - - - - - -

- {{ periodName }} - - -

-
- - - - - -
-
+ +
+ + + + + + + + + +

+ {{ periodName }} + + +

+
+ + + + + +
+
- - - - -
- - - - {{ day.fullname | translate }} - - - - -
-
- - - - - - -

- - {{ day.periodName | translate }} -

- - -

- - -
- -
- - - - - {{ event.timestart * 1000 | coreFormatDate: timeFormat }} - - - - {{ 'addon.calendar.type' + event.formattedType | translate }} - - {{ event.iconTitle }} - - - {{event.name}} -
-
-

- {{ 'core.nummore' | translate:{$a: day.filteredEvents.length - 3} }} + + + + +

+ + + + {{ day.fullname | translate }} + + + + +
+
+ + + + + + +

+ + {{ day.periodName | translate }}

-
- - - - - -
- - - + + +

+ + +
+ +
+ + + + + {{ event.timestart * 1000 | coreFormatDate: timeFormat }} + + + + {{ 'addon.calendar.type' + event.formattedType | translate }} + + {{ event.iconTitle }} + + + {{event.name}} +
+
+

+ {{ 'core.nummore' | translate:{$a: day.filteredEvents.length - 3} }} +

+
+
+ + + +
+
+
+
+
+
diff --git a/src/addons/calendar/components/calendar/calendar.scss b/src/addons/calendar/components/calendar/calendar.scss index 35cd3ccbd..7a358700e 100644 --- a/src/addons/calendar/components/calendar/calendar.scss +++ b/src/addons/calendar/components/calendar/calendar.scss @@ -3,6 +3,11 @@ :host { --addon-calendar-blank-day-background-color: var(--light); + .core-swipe-slides-container ion-grid { + flex: none; + width: 100%; + } + .addon-calendar-navigation { padding-top: 5px; padding-left: 10px; diff --git a/src/addons/calendar/pages/day/day.html b/src/addons/calendar/pages/day/day.html index 62939f984..d245f7258 100644 --- a/src/addons/calendar/pages/day/day.html +++ b/src/addons/calendar/pages/day/day.html @@ -27,78 +27,80 @@ - - - - - - - - - - -

{{ periodName }}

-
- - - - - -
-
+ +
+ + + + + + + + + +

{{ periodName }}

+
+ + + + + +
+
- - - - - - - - {{ 'core.hasdatatosync' | translate:{$a: 'core.day' | translate} }} - - - - - - - - - - - - - - - - {{ 'addon.calendar.type' + event.formattedType | translate }} - {{ event.iconTitle }} - -

- -

-

-
- - - {{ 'core.notsent' | translate }} - - - - {{ 'core.deletedoffline' | translate }} - + + + + + + + + {{ 'core.hasdatatosync' | translate:{$a: 'core.day' | translate} }} -
-
-
-
-
+ + + + + + + + + + + + + + + {{ 'addon.calendar.type' + event.formattedType | translate }} + {{ event.iconTitle }} + +

+ +

+

+
+ + + {{ 'core.notsent' | translate }} + + + + {{ 'core.deletedoffline' | translate }} + +
+
+
+ + + +
diff --git a/src/addons/calendar/pages/day/day.scss b/src/addons/calendar/pages/day/day.scss index d3fdad33c..145eccfb8 100644 --- a/src/addons/calendar/pages/day/day.scss +++ b/src/addons/calendar/pages/day/day.scss @@ -1,4 +1,9 @@ :host { + .core-swipe-slides-container ion-grid { + flex: none; + width: 100%; + } + .addon-calendar-period { flex-grow: 3; h3 { @@ -6,8 +11,4 @@ font-size: 1.2rem; } } - - core-swipe-slides { - --swipe-slides-min-height: calc(100% - 52px); - } } diff --git a/src/addons/mod/book/pages/contents/contents.html b/src/addons/mod/book/pages/contents/contents.html index f5a6d6f4a..6e6334aab 100644 --- a/src/addons/mod/book/pages/contents/contents.html +++ b/src/addons/mod/book/pages/contents/contents.html @@ -21,16 +21,16 @@ - + +
- - - - - - + + + + + + -
diff --git a/src/addons/mod/book/pages/contents/contents.scss b/src/addons/mod/book/pages/contents/contents.scss new file mode 100644 index 000000000..de654bcac --- /dev/null +++ b/src/addons/mod/book/pages/contents/contents.scss @@ -0,0 +1,7 @@ +:host { + .core-swipe-slides-container { + ion-card, core-navigation-bar { + flex: none; + } + } +} diff --git a/src/addons/mod/book/pages/contents/contents.ts b/src/addons/mod/book/pages/contents/contents.ts index 0f2444198..36af98196 100644 --- a/src/addons/mod/book/pages/contents/contents.ts +++ b/src/addons/mod/book/pages/contents/contents.ts @@ -47,6 +47,7 @@ import { @Component({ selector: 'page-addon-mod-book-contents', templateUrl: 'contents.html', + styleUrls: ['contents.scss'], }) export class AddonModBookContentsPage implements OnInit, OnDestroy { diff --git a/src/core/components/loading/loading.scss b/src/core/components/loading/loading.scss index 6f439e64e..bd77cefd5 100644 --- a/src/core/components/loading/loading.scss +++ b/src/core/components/loading/loading.scss @@ -71,6 +71,10 @@ } } + &.core-loading-full-height .core-loading-content { + height: 100%; + } + &.safe-area-padding:not(.core-loading-inline) .core-loading-content, &.safe-area-padding-horizontal:not(.core-loading-inline) .core-loading-content { @include safe-area-padding-horizontal(0px, 0px); diff --git a/src/core/components/swipe-slides/swipe-slides.scss b/src/core/components/swipe-slides/swipe-slides.scss index 71cf2f9f6..90b467e57 100644 --- a/src/core/components/swipe-slides/swipe-slides.scss +++ b/src/core/components/swipe-slides/swipe-slides.scss @@ -1,8 +1,6 @@ :host { - --swipe-slides-min-height: auto; - ion-slides { - min-height: var(--swipe-slides-min-height); + height: 100%; } ion-slide { diff --git a/src/core/components/swipe-slides/swipe-slides.ts b/src/core/components/swipe-slides/swipe-slides.ts index 139393670..a169714e4 100644 --- a/src/core/components/swipe-slides/swipe-slides.ts +++ b/src/core/components/swipe-slides/swipe-slides.ts @@ -181,17 +181,8 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe this.onWillChange.emit(currentItemData); - if (this.options.scrollOnChange !== 'top') { - return; - } - - // Scroll top. This can be improved in the future to keep the scroll for each slide. - const scrollElement = await this.content?.getScrollElement(); - - if (!scrollElement || CoreDomUtils.isElementOutsideOfScreen(scrollElement, this.hostElement, VerticalPoint.TOP)) { - // Scroll to top. - this.hostElement.scrollIntoView({ behavior: 'smooth' }); - } + // Apply scroll on change. In some devices it's too soon to do it, that's why it's done again in DidChange. + await this.applyScrollOnChange(); } /** @@ -204,6 +195,27 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe } this.onDidChange.emit(currentItemData); + + await this.applyScrollOnChange(); + } + + /** + * Treat scroll on change. + * + * @return Promise resolved when done. + */ + protected async applyScrollOnChange(): Promise { + if (this.options.scrollOnChange !== 'top') { + return; + } + + // Scroll top. This can be improved in the future to keep the scroll for each slide. + const scrollElement = await this.content?.getScrollElement(); + + if (!scrollElement || CoreDomUtils.isElementOutsideOfScreen(scrollElement, this.hostElement, VerticalPoint.TOP)) { + // Scroll to top. + this.hostElement.scrollIntoView({ behavior: 'smooth' }); + } } /** diff --git a/src/core/features/login/pages/site-policy/site-policy.html b/src/core/features/login/pages/site-policy/site-policy.html index 05a67d683..af2cd7267 100644 --- a/src/core/features/login/pages/site-policy/site-policy.html +++ b/src/core/features/login/pages/site-policy/site-policy.html @@ -10,7 +10,7 @@ - + diff --git a/src/core/features/login/pages/site-policy/site-policy.scss b/src/core/features/login/pages/site-policy/site-policy.scss index f54f35631..fa7bca312 100644 --- a/src/core/features/login/pages/site-policy/site-policy.scss +++ b/src/core/features/login/pages/site-policy/site-policy.scss @@ -18,9 +18,3 @@ } } } - -:host core-loading ::ng-deep { - .core-loading-content { - height: 100%; - } -} diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index c0d3691c8..ff9231e33 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -1581,3 +1581,14 @@ ion-app.md .collapsible-title h1 { body.core-iframe-fullscreen ion-content { --offset-top: 0px !important; } + +// To make core-swipe-slides fill the remaining height. +.core-swipe-slides-container { + display: flex; + flex-direction: column; + height: 100%; + + core-swipe-slides { + flex-grow: 1; + } +}