MOBILE-3814 collapsible: Add appear on bottom attribute to footer

main
Pau Ferrer Ocaña 2022-03-07 12:04:32 +01:00
parent 1c9f34b469
commit 18696269e0
10 changed files with 20 additions and 10 deletions

View File

@ -33,7 +33,7 @@
</ion-item> </ion-item>
</ion-list> </ion-list>
<div collapsible-footer *ngIf="!showLoading" slot="fixed"> <div collapsible-footer appearOnBottom *ngIf="!showLoading" slot="fixed">
<div class="list-item-limited-width"> <div class="list-item-limited-width">
<ion-button expand="block" (click)="openBook()" class="ion-margin ion-text-wrap"> <ion-button expand="block" (click)="openBook()" class="ion-margin ion-text-wrap">
<span *ngIf="!hasStartedBook">{{ 'core.start' | translate }}</span> <span *ngIf="!hasStartedBook">{{ 'core.start' | translate }}</span>

View File

@ -32,6 +32,6 @@
</core-loading> </core-loading>
<core-course-module-navigation collapsible-footer [hidden]="showLoading" [courseId]="courseId" [currentModuleId]="module.id" <core-course-module-navigation collapsible-footer appearOnBottom [hidden]="showLoading" [courseId]="courseId" [currentModuleId]="module.id"
(completionChanged)="onCompletionChange()"> (completionChanged)="onCompletionChange()">
</core-course-module-navigation> </core-course-module-navigation>

View File

@ -30,7 +30,7 @@
</ion-item> </ion-item>
</ion-list> </ion-list>
<div collapsible-footer *ngIf="!showLoading" slot="fixed"> <div collapsible-footer appearOnBottom *ngIf="!showLoading" slot="fixed">
<div class="list-item-limited-width"> <div class="list-item-limited-width">
<ion-button class="ion-margin ion-text-wrap" expand="block" (click)="openImscp()"> <ion-button class="ion-margin ion-text-wrap" expand="block" (click)="openImscp()">
<span *ngIf="!hasStarted">{{ 'core.start' | translate }}</span> <span *ngIf="!hasStarted">{{ 'core.start' | translate }}</span>

View File

@ -32,5 +32,5 @@
</core-loading> </core-loading>
<core-course-module-navigation collapsible-footer [hidden]="showLoading" [courseId]="courseId" [currentModuleId]="module.id"> <core-course-module-navigation collapsible-footer appearOnBottom [hidden]="showLoading" [courseId]="courseId" [currentModuleId]="module.id">
</core-course-module-navigation> </core-course-module-navigation>

View File

@ -79,7 +79,7 @@
</ion-list> </ion-list>
</ng-container> </ng-container>
<div collapsible-footer *ngIf="!showLoading" slot="fixed"> <div collapsible-footer appearOnBottom *ngIf="!showLoading" slot="fixed">
<div class="list-item-limited-width" *ngIf="mode == 'external'"> <div class="list-item-limited-width" *ngIf="mode == 'external'">
<ion-button expand="block" (click)="open(openFileAction.OPEN)" class="ion-margin ion-text-wrap"> <ion-button expand="block" (click)="open(openFileAction.OPEN)" class="ion-margin ion-text-wrap">
<ng-container *ngIf="isStreamedFile"> <ng-container *ngIf="isStreamedFile">

View File

@ -37,7 +37,7 @@
</ion-item> </ion-item>
</ion-list> </ion-list>
<div collapsible-footer *ngIf="!showLoading" slot="fixed"> <div collapsible-footer appearOnBottom *ngIf="!showLoading" slot="fixed">
<div class="list-item-limited-width" *ngIf="url && !shouldIframe && (!shouldEmbed || !isOther)"> <div class="list-item-limited-width" *ngIf="url && !shouldIframe && (!shouldEmbed || !isOther)">
<ion-button expand="block" (click)="go()" class="ion-margin ion-text-wrap"> <ion-button expand="block" (click)="go()" class="ion-margin ion-text-wrap">
<ion-icon name="fas-link" slot="start" aria-hidden="true"></ion-icon> <ion-icon name="fas-link" slot="start" aria-hidden="true"></ion-icon>

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Directive, ElementRef, OnDestroy, OnInit } from '@angular/core'; import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { ScrollDetail } from '@ionic/core'; import { ScrollDetail } from '@ionic/core';
import { IonContent } from '@ionic/angular'; import { IonContent } from '@ionic/angular';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
@ -34,6 +34,8 @@ import { CoreEventLoadingChangedData, CoreEventObserver, CoreEvents } from '@sin
}) })
export class CoreCollapsibleFooterDirective implements OnInit, OnDestroy { export class CoreCollapsibleFooterDirective implements OnInit, OnDestroy {
@Input() appearOnBottom = false;
protected element: HTMLElement; protected element: HTMLElement;
protected initialHeight = 0; protected initialHeight = 0;
protected initialPaddingBottom = '0px'; protected initialPaddingBottom = '0px';
@ -127,7 +129,7 @@ export class CoreCollapsibleFooterDirective implements OnInit, OnDestroy {
*/ */
protected onScroll(scrollDetail: ScrollDetail, scrollElement: HTMLElement): void { protected onScroll(scrollDetail: ScrollDetail, scrollElement: HTMLElement): void {
const maxScroll = scrollElement.scrollHeight - scrollElement.offsetHeight; const maxScroll = scrollElement.scrollHeight - scrollElement.offsetHeight;
if (scrollDetail.scrollTop <= 0 || scrollDetail.scrollTop >= maxScroll) { if (scrollDetail.scrollTop <= 0 || (this.appearOnBottom && scrollDetail.scrollTop >= maxScroll)) {
// Reset. // Reset.
this.setBarHeight(this.initialHeight); this.setBarHeight(this.initialHeight);
} else { } else {
@ -181,6 +183,9 @@ export class CoreCollapsibleFooterDirective implements OnInit, OnDestroy {
this.listenScrollEvents(); this.listenScrollEvents();
// Only if not present or explicitly falsy it will be false.
this.appearOnBottom = !CoreUtils.isFalseOrZero(this.appearOnBottom);
// Recalculate the height if a parent core-loading displays the content. // Recalculate the height if a parent core-loading displays the content.
this.loadingChangedListener = this.loadingChangedListener =
CoreEvents.on(CoreEvents.CORE_LOADING_CHANGED, async (data: CoreEventLoadingChangedData) => { CoreEvents.on(CoreEvents.CORE_LOADING_CHANGED, async (data: CoreEventLoadingChangedData) => {

View File

@ -45,6 +45,6 @@
<core-course-unsupported-module *ngIf="unsupported" [module]="module"></core-course-unsupported-module> <core-course-unsupported-module *ngIf="unsupported" [module]="module"></core-course-unsupported-module>
</core-loading> </core-loading>
<core-course-module-navigation collapsible-footer [hidden]="!loaded" [courseId]="courseId" [currentModuleId]="module.id"> <core-course-module-navigation collapsible-footer appearOnBottom [hidden]="!loaded" [courseId]="courseId" [currentModuleId]="module.id">
</core-course-module-navigation> </core-course-module-navigation>
</ion-content> </ion-content>

View File

@ -14,5 +14,6 @@
(onLoadingContent)="contentLoading()"> (onLoadingContent)="contentLoading()">
</core-site-plugins-plugin-content> </core-site-plugins-plugin-content>
<core-course-module-navigation collapsible-footer *ngIf="module" [courseId]="courseId" [currentModuleId]="module.id"> <core-course-module-navigation collapsible-footer [appearOnBottom]="collapsibleFooterAppearOnBottom" *ngIf="module" [courseId]="courseId"
[currentModuleId]="module.id">
</core-course-module-navigation> </core-course-module-navigation>

View File

@ -85,6 +85,8 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
*/ */
size?: string; size?: string;
collapsibleFooterAppearOnBottom = true;
displayOpenInBrowser = true; displayOpenInBrowser = true;
displayDescription = true; displayDescription = true;
displayRefresh = true; displayRefresh = true;
@ -133,6 +135,8 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
this.displaySize = !CoreUtils.isFalseOrZero(handlerSchema.displaysize); this.displaySize = !CoreUtils.isFalseOrZero(handlerSchema.displaysize);
this.displayGrades = CoreUtils.isTrueOrOne(handlerSchema.displaygrades); // False by default. this.displayGrades = CoreUtils.isTrueOrOne(handlerSchema.displaygrades); // False by default.
this.ptrEnabled = !CoreUtils.isFalseOrZero(handlerSchema.ptrenabled); this.ptrEnabled = !CoreUtils.isFalseOrZero(handlerSchema.ptrenabled);
this.collapsibleFooterAppearOnBottom = !CoreUtils.isFalseOrZero(handlerSchema.isresource);
} }
// Get the data for the context menu. // Get the data for the context menu.