From 7da65f383cbb3e6a0db19b3697bc07d9be92e988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 8 Apr 2022 13:27:13 +0200 Subject: [PATCH 1/4] MOBILE-3833 style: Fix margin on chip with non slotted icons --- src/theme/theme.base.scss | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index 32100b047..fe26a3881 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -1054,8 +1054,15 @@ ion-button.chip { ion-icon { font-size: 16px; min-width: 16px; + @include margin(0, 8px, 0, 0); } + ion-label { + white-space: normal !important; + } +} + +ion-button.chip { ion-icon[slot=start] { @include margin(0, 8px, 0, 0); } @@ -1063,10 +1070,6 @@ ion-button.chip { ion-icon[slot=end] { @include margin(0, 0, 0, 8px); } - - ion-label { - white-space: normal !important; - } } ion-chip { From c5b8b4fb1998fd0bcb63e6dfe876f1f1fcc6d1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 8 Apr 2022 14:11:52 +0200 Subject: [PATCH 2/4] MOBILE-3833 assignment: Add collapsible footer action buttons --- .../index/addon-mod-assign-index.html | 3 - .../addon-mod-assign-submission.html | 159 ++++++++++-------- .../components/submission/submission.ts | 3 +- src/core/classes/tabs.ts | 3 + 4 files changed, 90 insertions(+), 78 deletions(-) diff --git a/src/addons/mod/assign/components/index/addon-mod-assign-index.html b/src/addons/mod/assign/components/index/addon-mod-assign-index.html index 5aa7a97af..599a85136 100644 --- a/src/addons/mod/assign/components/index/addon-mod-assign-index.html +++ b/src/addons/mod/assign/components/index/addon-mod-assign-index.html @@ -134,6 +134,3 @@ [moduleId]="module.id"> - - - diff --git a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html index 42dde1d55..753b18636 100644 --- a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html @@ -37,7 +37,7 @@ - + @@ -139,79 +139,6 @@ [submission]="userSubmission" [plugin]="plugin"> - - - -
- - - {{ 'addon.mod_assign.editsubmission' | translate }} - - - - - {{ 'addon.mod_assign.addsubmission' | translate }} - - - {{ 'addon.mod_assign.beginassignment' | translate }} - - - - - - {{ 'addon.mod_assign.addnewattemptfromprevious' | translate }} - - - {{ 'addon.mod_assign.addnewattempt' | translate }} - - - - - {{ 'addon.mod_assign.editsubmission' | translate }} - -
-
-

{{ 'addon.mod_assign.erroreditpluginsnotsupported' | translate }}

-

{{ name }}

-
-
-

{{ 'addon.mod_assign.cannoteditduetostatementsubmission' | translate }}

-
-
-
- - - - - - - - - - - - - - - {{ 'addon.mod_assign.submitassignment' | translate }} - -

{{ 'addon.mod_assign.submitassignment_help' | translate }}

-
-
- - - -

- {{ 'addon.mod_assign.cannotsubmitduetostatementsubmission' | translate }} -

-
-
-
- @@ -236,6 +163,90 @@ + + +
+
+ + + + + {{ 'addon.mod_assign.editsubmission' | translate }} + + + + + {{ 'addon.mod_assign.addsubmission' | translate }} + + + {{ 'addon.mod_assign.beginassignment' | translate }} + + + + + + {{ 'addon.mod_assign.addnewattemptfromprevious' | translate }} + + + {{ 'addon.mod_assign.addnewattempt' | translate }} + + + + + {{ 'addon.mod_assign.editsubmission' | translate }} + + + + + +

{{ 'addon.mod_assign.erroreditpluginsnotsupported' | translate }}

+

{{ name }}

+
+ +

{{ 'addon.mod_assign.cannoteditduetostatementsubmission' | translate }}

+
+
+
+ +
+ + + + + + + + + + + + + + + {{ 'addon.mod_assign.submitassignment' | translate }} + +

{{ 'addon.mod_assign.submitassignment_help' | translate }}

+
+
+ + + +

+ {{ 'addon.mod_assign.cannotsubmitduetostatementsubmission' | translate }} +

+
+
+
+
+ + +
diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index 3699d2c59..f3c2f3840 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -184,7 +184,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } /** - * Component being initialized. + * @inheritdoc */ ngOnInit(): void { this.isSubmittedForGrading = !!this.submitId; @@ -1195,6 +1195,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can * @param tab The tab that was selected. */ tabSelected(tab: CoreTabComponent): void { + this.selectedTab = tab.id; // Block sync when selecting grade tab, unblock when leaving it. this.setGradeSyncBlocked(tab.id === 'grade'); } diff --git a/src/core/classes/tabs.ts b/src/core/classes/tabs.ts index 61f006286..166711854 100644 --- a/src/core/classes/tabs.ts +++ b/src/core/classes/tabs.ts @@ -482,6 +482,9 @@ export class CoreTabsBaseComponent implements OnInit, Aft */ async selectTab(tabId: string, e?: Event): Promise { const index = this.tabs.findIndex((tab) => tabId == tab.id); + if (index < 0) { + return; + } return this.selectByIndex(index, e); } From 72c516b88c29d9b08c63b8a13e544dc17856ad19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 8 Apr 2022 10:39:14 +0200 Subject: [PATCH 3/4] MOBILE-3833 settings: Warn user to restart app on language change --- scripts/langindex.json | 2 + src/core/features/settings/lang.json | 6 +- .../settings/pages/general/general.ts | 67 ++++++++++++++++--- src/theme/theme.base.scss | 28 ++++++++ 4 files changed, 93 insertions(+), 10 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index bca4fe470..b245d6a4e 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -2167,6 +2167,8 @@ "core.settings.cannotsyncloggedout": "local_moodlemobileapp", "core.settings.cannotsyncoffline": "local_moodlemobileapp", "core.settings.cannotsyncwithoutwifi": "local_moodlemobileapp", + "core.settings.changelanguage": "local_moodlemobileapp", + "core.settings.changelanguagealert": "local_moodlemobileapp", "core.settings.colorscheme": "local_moodlemobileapp", "core.settings.colorscheme-dark": "local_moodlemobileapp", "core.settings.colorscheme-light": "local_moodlemobileapp", diff --git a/src/core/features/settings/lang.json b/src/core/features/settings/lang.json index 29c25bbff..42114fcd0 100644 --- a/src/core/features/settings/lang.json +++ b/src/core/features/settings/lang.json @@ -6,11 +6,13 @@ "cannotsyncloggedout": "This site cannot be synchronised because you've logged out. Please try again when you're logged in the site again.", "cannotsyncoffline": "Cannot synchronise offline.", "cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.", - "colorscheme": "Color Scheme", + "changelanguage": "Change to {{$a}}", + "changelanguagealert": "Changing the language will restart the app.", "colorscheme-dark": "Dark", "colorscheme-light": "Light", - "colorscheme-system": "System default", "colorscheme-system-notice": "System default mode will depend on your device support.", + "colorscheme-system": "System default", + "colorscheme": "Color Scheme", "compilationinfo": "Compilation info", "copyinfo": "Copy device info on the clipboard", "cordovadevicemodel": "Cordova device model", diff --git a/src/core/features/settings/pages/general/general.ts b/src/core/features/settings/pages/general/general.ts index e8ef89874..a1487f255 100644 --- a/src/core/features/settings/pages/general/general.ts +++ b/src/core/features/settings/pages/general/general.ts @@ -22,9 +22,10 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push import { CoreSettingsHelper, CoreColorScheme, CoreZoomLevel } from '../../services/settings-helper'; import { CoreApp } from '@services/app'; import { CoreIframeUtils } from '@services/utils/iframe'; -import { Diagnostic } from '@singletons'; +import { Diagnostic, Translate } from '@singletons'; import { CoreSites } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; +import { AlertButton } from '@ionic/angular'; /** * Page that displays the general settings. @@ -110,14 +111,64 @@ export class CoreSettingsGeneralPage { /** * Called when a new language is selected. */ - languageChanged(): void { - CoreLang.changeCurrentLanguage(this.selectedLanguage).finally(async () => { - // Invalidate cache for all sites to get the content in the right language. - const sites = await CoreSites.getSitesInstances(); - await CoreUtils.ignoreErrors(Promise.all(sites.map((site) => site.invalidateWsCache()))); + async languageChanged(): Promise { + const previousLanguage = await CoreLang.getCurrentLanguage(); + if (this.selectedLanguage === previousLanguage) { + // Prevent opening again. - CoreEvents.trigger(CoreEvents.LANGUAGE_CHANGED, this.selectedLanguage); - }); + return; + } + + const previousLanguageCancel = Translate.instant('core.cancel'); + + try { + await CoreLang.changeCurrentLanguage(this.selectedLanguage); + } finally { + const langName = this.languages.find((lang) => lang.code == this.selectedLanguage)?.name; + + const buttons: AlertButton[] = [ + { + text: previousLanguageCancel, + role: 'cancel', + handler: (): void => { + clearTimeout(timeout); + this.selectedLanguage = previousLanguage; + CoreLang.changeCurrentLanguage(this.selectedLanguage); + }, + }, + { + text: Translate.instant('core.settings.changelanguage', { $a: langName }), + cssClass: 'timed-button', + handler: (): void => { + clearTimeout(timeout); + this.applyLanguageAndRestart(); + }, + }, + ]; + + const alert = await CoreDomUtils.showAlertWithOptions( + { + message: Translate.instant('core.settings.changelanguagealert'), + buttons, + }, + ); + const timeout = window.setTimeout(async () => { + await alert.dismiss(); + this.applyLanguageAndRestart(); + }, 10000); + } + } + + /** + * Apply language changes and restart the app. + */ + protected async applyLanguageAndRestart(): Promise { + // Invalidate cache for all sites to get the content in the right language. + const sites = await CoreSites.getSitesInstances(); + await CoreUtils.ignoreErrors(Promise.all(sites.map((site) => site.invalidateWsCache()))); + + CoreEvents.trigger(CoreEvents.LANGUAGE_CHANGED, this.selectedLanguage); + window.location.reload(); } /** diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index fe26a3881..bfca7c48e 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -461,6 +461,34 @@ ion-alert.core-nohead { } } +@keyframes scaleFrom0 { + from { + /* More performant than animating `width` */ + transform: scaleX(0); + } +} + +ion-alert .alert-button.timed-button{ + position: relative; + + &::before { + content: ''; + position: absolute; + width: 100%; + left: 0; + right: 0; + bottom: 0; + top: 0; + background-color: var(--primary-tint); + animation: scaleFrom0 10s forwards linear; + transform-origin: left; + @include rtl() { + transform-origin: right; + } + z-index: -1; + } +} + ion-alert { --border-radius: var(--huge-radius); From 6af21412842dbf98c591f90b823292a594cd49ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 8 Apr 2022 16:17:47 +0200 Subject: [PATCH 4/4] MOBILE-3833 siteplugins: Use new icon function --- .../classes/handlers/module-handler.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/features/siteplugins/classes/handlers/module-handler.ts b/src/core/features/siteplugins/classes/handlers/module-handler.ts index e501e91c6..57b415309 100644 --- a/src/core/features/siteplugins/classes/handlers/module-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/module-handler.ts @@ -63,18 +63,18 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp /** * @inheritdoc */ - getData( + async getData( module: CoreCourseModuleData, courseId: number, sectionId?: number, forCoursePage?: boolean, - ): CoreCourseModuleHandlerData { + ): Promise { if (this.shouldOnlyDisplayDescription(module, forCoursePage)) { const title = module.description; module.description = ''; return { - icon: this.getIconSrc(), + icon: await CoreCourse.getModuleIconSrc(module.modname, this.handlerSchema.displaydata?.icon), title: title || '', a11yTitle: '', class: this.handlerSchema.displaydata?.class, @@ -85,7 +85,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp const showDowloadButton = this.handlerSchema.downloadbutton; const handlerData: CoreCourseModuleHandlerData = { title: module.name, - icon: this.getIconSrc(), + icon: await CoreCourse.getModuleIconSrc(module.modname, this.handlerSchema.displaydata?.icon), class: this.handlerSchema.displaydata?.class, showDownloadButton: showDowloadButton !== undefined ? showDowloadButton : hasOffline, }; @@ -198,13 +198,6 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp } } - /** - * @inheritdoc - */ - getIconSrc(): string | undefined { - return this.handlerSchema.displaydata?.icon; - } - /** * @inheritdoc */