From 045cd0b92413895a47b7fad8627680c8fb426ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jun 2021 11:01:13 +0200 Subject: [PATCH 1/5] MOBILE-3320 core: Fix animations on core loading --- src/core/components/loading/core-loading.html | 5 +++-- src/core/components/loading/loading.scss | 4 ++++ src/core/components/loading/loading.ts | 6 ++++++ src/core/features/login/pages/sites/sites.html | 2 +- src/core/features/login/pages/sites/sites.ts | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/components/loading/core-loading.html b/src/core/components/loading/core-loading.html index 7f5006545..c5b6d803b 100644 --- a/src/core/components/loading/core-loading.html +++ b/src/core/components/loading/core-loading.html @@ -2,7 +2,8 @@

{{message}}

-
- +
+
diff --git a/src/core/components/loading/loading.scss b/src/core/components/loading/loading.scss index 98f596285..c29e4f9b7 100644 --- a/src/core/components/loading/loading.scss +++ b/src/core/components/loading/loading.scss @@ -43,6 +43,10 @@ flex-direction: column; } + .core-loading-content { + @include core-transition(opacity, 200ms); + } + .core-loading-message { @include margin(10px, 0, 0, 0); } diff --git a/src/core/components/loading/loading.ts b/src/core/components/loading/loading.ts index 7b3f0743d..21aa0b8b5 100644 --- a/src/core/components/loading/loading.ts +++ b/src/core/components/loading/loading.ts @@ -55,6 +55,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit { uniqueId: string; protected element: HTMLElement; // Current element. + loaded = false; // Only comes true once. constructor(element: ElementRef) { this.element = element.nativeElement; @@ -83,6 +84,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit { if (this.hideUntil) { this.element.classList.add('core-loading-loaded'); } + this.loaded = !!this.hideUntil; this.content?.nativeElement.classList.toggle('core-loading-content', !!this.hideUntil); } @@ -94,6 +96,10 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit { */ ngOnChanges(changes: { [name: string]: SimpleChange }): void { if (changes.hideUntil) { + if (!this.loaded) { + this.loaded = !!this.hideUntil; // Only comes true once. + } + if (this.hideUntil) { setTimeout(() => { // Content is loaded so, center the spinner on the content itself. diff --git a/src/core/features/login/pages/sites/sites.html b/src/core/features/login/pages/sites/sites.html index 280e50172..b373216e3 100644 --- a/src/core/features/login/pages/sites/sites.html +++ b/src/core/features/login/pages/sites/sites.html @@ -34,7 +34,7 @@ {{ 'core.login.sitebadgedescription' | translate:{ count: site.badge } }} + [attr.aria-label]="'core.delete' | translate" [@coreSlideInOut]="'fromRight'"> diff --git a/src/core/features/login/pages/sites/sites.ts b/src/core/features/login/pages/sites/sites.ts index 34d4e873a..e74ac1029 100644 --- a/src/core/features/login/pages/sites/sites.ts +++ b/src/core/features/login/pages/sites/sites.ts @@ -22,6 +22,7 @@ import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreNavigator } from '@services/navigator'; import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; import { CoreFilter } from '@features/filter/services/filter'; +import { CoreAnimations } from '@components/animations'; /** * Page that displays a "splash screen" while the app is being initialized. @@ -29,6 +30,7 @@ import { CoreFilter } from '@features/filter/services/filter'; @Component({ selector: 'page-core-login-sites', templateUrl: 'sites.html', + animations: [CoreAnimations.SLIDE_IN_OUT], }) export class CoreLoginSitesPage implements OnInit { From 182d9b5ae21b655087b4fd7435c1e36879180821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jun 2021 11:01:21 +0200 Subject: [PATCH 2/5] MOBILE-3320 settings: Fix dark mode status bar color on iOS --- .../settings/services/settings-helper.ts | 24 +++++++++---------- src/core/services/app.ts | 11 +++++++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/core/features/settings/services/settings-helper.ts b/src/core/features/settings/services/settings-helper.ts index 713407274..cad265dad 100644 --- a/src/core/features/settings/services/settings-helper.ts +++ b/src/core/features/settings/services/settings-helper.ts @@ -63,8 +63,11 @@ export class CoreSettingsHelperProvider { protected syncPromises: { [s: string]: Promise } = {}; protected prefersDark?: MediaQueryList; protected colorSchemes: CoreColorScheme[] = []; + protected currentColorScheme = CoreColorScheme.LIGHT; constructor() { + this.prefersDark = window.matchMedia('(prefers-color-scheme: dark)'); + if (!CoreConstants.CONFIG.forceColorScheme) { // Update color scheme when a user enters or leaves a site, or when the site info is updated. const applySiteScheme = (): void => { @@ -72,7 +75,6 @@ export class CoreSettingsHelperProvider { // Dark mode is disabled, force light mode. this.setColorScheme(CoreColorScheme.LIGHT); } else { - this.prefersDark = window.matchMedia('(prefers-color-scheme: dark)'); // Reset color scheme settings. this.initColorScheme(); } @@ -86,7 +88,12 @@ export class CoreSettingsHelperProvider { // Reset color scheme settings. this.initColorScheme(); }); + } else { + this.initColorScheme(); } + + // Listen for changes to the prefers-color-scheme media query. + this.prefersDark.addEventListener && this.prefersDark.addEventListener('change', this.toggleDarkModeListener.bind(this)); } /** @@ -432,17 +439,10 @@ export class CoreSettingsHelperProvider { * @param colorScheme Name of the color scheme. */ setColorScheme(colorScheme: CoreColorScheme): void { + this.currentColorScheme = colorScheme; if (colorScheme == CoreColorScheme.SYSTEM && this.prefersDark) { - // Listen for changes to the prefers-color-scheme media query. - this.prefersDark.addEventListener && - this.prefersDark.addEventListener('change', this.toggleDarkModeListener); - this.toggleDarkMode(this.prefersDark.matches); } else { - // Stop listening to changes. - this.prefersDark?.removeEventListener && - this.prefersDark?.removeEventListener('change', this.toggleDarkModeListener); - this.toggleDarkMode(colorScheme == CoreColorScheme.DARK); } } @@ -460,11 +460,9 @@ export class CoreSettingsHelperProvider { /** * Listener function to toggle dark mode. - * - * @param e Event object. */ - protected toggleDarkModeListener = (e: MediaQueryListEvent): void => { - document.body.classList.toggle('dark', e.matches); + protected toggleDarkModeListener(): void { + this.setColorScheme(this.currentColorScheme); }; /** diff --git a/src/core/services/app.ts b/src/core/services/app.ts index a44ba3c64..7febb968a 100644 --- a/src/core/services/app.ts +++ b/src/core/services/app.ts @@ -654,10 +654,17 @@ export class CoreAppProvider { const useLightText = CoreColors.isWhiteContrastingBetter(color); const statusBar = StatusBar.instance; - statusBar.backgroundColorByHexString(color); - useLightText ? statusBar.styleLightContent() : statusBar.styleDefault(); this.isIOS() && statusBar.overlaysWebView(false); + + // styleDefault will use white text on iOS when darkmode is on. Force the background to black. + if (this.isIOS() && !useLightText && window.matchMedia('(prefers-color-scheme: dark)').matches) { + statusBar.backgroundColorByHexString('#000000'); + statusBar.styleLightContent(); + } else { + statusBar.backgroundColorByHexString(color); + useLightText ? statusBar.styleLightContent() : statusBar.styleDefault(); + } } /** From 67e6a45b2d1e1c9f21cba492b179cb725bc7c17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jun 2021 15:37:10 +0200 Subject: [PATCH 3/5] MOBILE-3320 style: Fix quiz styles --- .../ddwtos/component/addon-qtype-ddwtos.html | 20 ++++++++++--------- src/addons/qtype/ddwtos/component/ddwtos.scss | 1 + src/theme/components/format-text.scss | 1 - 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/addons/qtype/ddwtos/component/addon-qtype-ddwtos.html b/src/addons/qtype/ddwtos/component/addon-qtype-ddwtos.html index 86b733857..39222c454 100644 --- a/src/addons/qtype/ddwtos/component/addon-qtype-ddwtos.html +++ b/src/addons/qtype/ddwtos/component/addon-qtype-ddwtos.html @@ -1,4 +1,4 @@ -
+
@@ -10,16 +10,18 @@ {{ 'core.question.howtodraganddrop' | translate }} - - +
+ + - - + + -
+
+
diff --git a/src/addons/qtype/ddwtos/component/ddwtos.scss b/src/addons/qtype/ddwtos/component/ddwtos.scss index e5b4ccfb5..bc6bc852b 100644 --- a/src/addons/qtype/ddwtos/component/ddwtos.scss +++ b/src/addons/qtype/ddwtos/component/ddwtos.scss @@ -3,6 +3,7 @@ // Style ddwtos content a bit. Almost all these styles are copied from Moodle. .addon-qtype-ddwtos-container { min-height: 80px; // To display the loading. + position: relative; } core-format-text ::ng-deep, .drags ::ng-deep { diff --git a/src/theme/components/format-text.scss b/src/theme/components/format-text.scss index 9046fa194..423de0eaa 100644 --- a/src/theme/components/format-text.scss +++ b/src/theme/components/format-text.scss @@ -338,7 +338,6 @@ core-rich-text-editor .core-rte-editor { select, input:not([type=checkbox]):not([type=radio]):not([type=hidden]) { height: 30px; - line-height: 30px; display: inline-block; border: 1px solid var(--gray-dark); background: var(--background-contrast); From a21c7597d798ced0930ae8203d94dde820ff6db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jun 2021 16:33:30 +0200 Subject: [PATCH 4/5] MOBILE-3320 survey: Improve radio buttons a11y --- .../survey/components/index/addon-mod-survey-index.html | 7 ++++--- src/addons/mod/survey/components/index/index.scss | 6 ++++++ src/theme/components/format-text.scss | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/addons/mod/survey/components/index/addon-mod-survey-index.html b/src/addons/mod/survey/components/index/addon-mod-survey-index.html index 6f024a1d5..c3f2ea353 100644 --- a/src/addons/mod/survey/components/index/addon-mod-survey-index.html +++ b/src/addons/mod/survey/components/index/addon-mod-survey-index.html @@ -79,7 +79,7 @@ - + @@ -91,9 +91,10 @@ + *ngFor="let option of question.optionsArray; let value=index;" + > - + diff --git a/src/addons/mod/survey/components/index/index.scss b/src/addons/mod/survey/components/index/index.scss index 261e20841..87933f475 100644 --- a/src/addons/mod/survey/components/index/index.scss +++ b/src/addons/mod/survey/components/index/index.scss @@ -17,6 +17,12 @@ .even { background-color: var(--even-background); } + + ion-radio { + height: var(--a11y-min-target-size); + width: var(--a11y-min-target-size); + padding: 12px; + } } :host-context(body.dark) { diff --git a/src/theme/components/format-text.scss b/src/theme/components/format-text.scss index 423de0eaa..06176a466 100644 --- a/src/theme/components/format-text.scss +++ b/src/theme/components/format-text.scss @@ -180,6 +180,11 @@ core-format-text { ion-icon { flex: 1; align-self: center; + /** Fix iOS icon size */ + margin: 0 auto; + position: absolute; + left: 0; + right: 0; } &:hover { From 21d968c84e9a4931e4688e75a4d91da4f8433844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jun 2021 18:51:51 +0200 Subject: [PATCH 5/5] MOBILE-3320 core: Prevent flickering on tab scrolling --- src/core/classes/tabs.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/core/classes/tabs.ts b/src/core/classes/tabs.ts index ddacb08bb..285a47660 100644 --- a/src/core/classes/tabs.ts +++ b/src/core/classes/tabs.ts @@ -61,7 +61,6 @@ export class CoreTabsBaseComponent implements OnInit, Aft numTabsShown = 0; direction = 'ltr'; description = ''; - lastScroll = 0; slidesOpts = { initialSlide: 0, slidesPerView: 3, @@ -89,6 +88,8 @@ export class CoreTabsBaseComponent implements OnInit, Aft protected slidesSwiper: any; // eslint-disable-line @typescript-eslint/no-explicit-any protected slidesSwiperLoaded = false; protected scrollElements: Record = {}; // Scroll elements for each loaded tab. + protected lastScroll = 0; + protected previousLastScroll = 0; tabAction: CoreTabsRoleTab; @@ -164,6 +165,7 @@ export class CoreTabsBaseComponent implements OnInit, Aft this.tabBarElement!.classList.remove('tabs-hidden'); if (scroll === 0) { this.tabBarElement!.style.height = ''; + this.previousLastScroll = this.lastScroll; this.lastScroll = 0; } else if (scroll !== undefined) { this.tabBarElement!.style.height = (this.tabBarHeight - scroll) + 'px'; @@ -253,17 +255,13 @@ export class CoreTabsBaseComponent implements OnInit, Aft return; } - if (!this.tabsShown) { - if (window.innerHeight >= CoreTabsBaseComponent.MAX_HEIGHT_TO_HIDE_TABS) { - // Ensure tabbar is shown. - this.tabsShown = true; - this.tabBarElement?.classList.remove('tabs-hidden'); - this.lastScroll = 0; - this.calculateTabBarHeight(); - } else { - // Don't recalculate. - return; - } + if (window.innerHeight >= CoreTabsBaseComponent.MAX_HEIGHT_TO_HIDE_TABS) { + // Ensure tabbar is shown. + this.applyScroll(true, 0); + this.calculateTabBarHeight(); + } else if (!this.tabsShown) { + // Don't recalculate. + return; } await this.calculateMaxSlides(); @@ -504,7 +502,7 @@ export class CoreTabsBaseComponent implements OnInit, Aft return; } - if (scrollTop == this.lastScroll) { + if (scrollTop == this.lastScroll || scrollTop == this.previousLastScroll) { // Ensure scroll has been modified to avoid flicks. return; } @@ -522,6 +520,7 @@ export class CoreTabsBaseComponent implements OnInit, Aft } // Use lastScroll after moving the tabs to avoid flickering. + this.previousLastScroll = this.lastScroll; this.lastScroll = scrollTop; }