MOBILE-3637 core: Unify refresh and sync icons

main
Pau Ferrer Ocaña 2021-02-08 14:50:09 +01:00
parent c98fa810fa
commit d3e8b96946
14 changed files with 75 additions and 66 deletions

View File

@ -40,6 +40,7 @@ import { CoreNavigator } from '@services/navigator';
import { Params } from '@angular/router';
import { Subscription } from 'rxjs';
import { CoreUtils } from '@services/utils/utils';
import { CoreConstants } from '@/core/constants';
/**
* Page that displays the calendar events for a certain day.
@ -85,7 +86,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
loaded = false;
hasOffline = false;
isOnline = false;
syncIcon = 'spinner';
syncIcon = CoreConstants.ICON_LOADING;
isCurrentDay = false;
isPastDay = false;
currentMoment!: moment.Moment;
@ -260,7 +261,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
*/
async fetchData(sync?: boolean): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
this.isOnline = CoreApp.instance.isOnline();
if (sync) {
@ -320,7 +321,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
}
this.loaded = true;
this.syncIcon = 'fas-sync-alt';
this.syncIcon = CoreConstants.ICON_SYNC;
}
/**
@ -450,7 +451,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
* @return Promise resolved when done.
*/
async refreshData(sync?: boolean, afterChange?: boolean): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
const promises: Promise<void>[] = [];

View File

@ -45,6 +45,7 @@ import { CoreUtils } from '@services/utils/utils';
import { AddonCalendarReminderDBRecord } from '../../services/database/calendar';
import { ActivatedRoute } from '@angular/router';
import { CoreScreen } from '@services/screen';
import { CoreConstants } from '@/core/constants';
/**
* Page that displays a single calendar event.
@ -84,7 +85,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
canDelete = false;
hasOffline = false;
isOnline = false;
syncIcon = 'spinner'; // Sync icon.
syncIcon = CoreConstants.ICON_LOADING; // Sync icon.
isSplitViewOn = false;
constructor(
@ -163,7 +164,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
}
this.eventId = eventId;
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
this.fetchEvent();
});
@ -338,7 +339,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
}
this.eventLoaded = true;
this.syncIcon = 'fas-sync-alt';
this.syncIcon = CoreConstants.ICON_SYNC;
}
/**
@ -417,7 +418,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
* @return Promise resolved when done.
*/
async refreshEvent(sync = false, showErrors = false): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
const promises: Promise<void>[] = [];

View File

@ -32,6 +32,7 @@ import { AddonCalendarUpcomingEventsComponent } from '../../components/upcoming-
import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter';
import { CoreNavigator } from '@services/navigator';
import { CoreLocalNotifications } from '@services/local-notifications';
import { CoreConstants } from '@/core/constants';
/**
@ -68,7 +69,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
loaded = false;
hasOffline = false;
isOnline = false;
syncIcon = 'spinner';
syncIcon = CoreConstants.ICON_LOADING;
showCalendar = true;
loadUpcoming = false;
filter: AddonCalendarFilter = {
@ -194,7 +195,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
*/
async fetchData(sync?: boolean, showErrors?: boolean): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
this.isOnline = CoreApp.instance.isOnline();
if (sync) {
@ -254,7 +255,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
}
this.loaded = true;
this.syncIcon = 'fas-sync-alt';
this.syncIcon = CoreConstants.ICON_SYNC;
}
/**
@ -285,7 +286,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
* @return Promise resolved when done.
*/
async refreshData(sync = false, showErrors = false): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
const promises: Promise<void>[] = [];

View File

@ -89,7 +89,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
canCreate = false;
hasOffline = false;
isOnline = false;
syncIcon = 'spinner';
syncIcon = CoreConstants.ICON_LOADING;
filter: AddonCalendarFilter = {
filtered: false,
courseId: -1,
@ -251,7 +251,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
this.gotoEvent(this.eventId);
}
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
await this.fetchData(false, true, false);
@ -361,7 +361,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
}
this.eventsLoaded = true;
this.syncIcon = 'fas-sync-alt';
this.syncIcon = CoreConstants.ICON_SYNC;
}
/**
@ -567,7 +567,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
* @return Promise resolved when done.
*/
async refreshEvents(sync?: boolean, showErrors?: boolean): Promise<void> {
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
const promises: Promise<void>[] = [];

View File

@ -49,6 +49,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreIonLoadingElement } from '@classes/ion-loading';
import { ActivatedRoute } from '@angular/router';
import { AddonMessagesConversationInfoComponent } from '../../components/conversation-info/conversation-info';
import { CoreConstants } from '@/core/constants';
/**
* Page that displays a message discussion page.
@ -1352,7 +1353,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
return;
}
this.favouriteIcon = 'spinner';
this.favouriteIcon = CoreConstants.ICON_LOADING;
try {
await AddonMessages.instance.setFavouriteConversation(this.conversation.id, !this.conversation.isfavourite);
@ -1386,7 +1387,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
return;
}
this.muteIcon = 'spinner';
this.muteIcon = CoreConstants.ICON_LOADING;
try {
await AddonMessages.instance.muteConversation(this.conversation.id, !this.conversation.ismuted);
@ -1461,7 +1462,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
try {
await CoreDomUtils.instance.showConfirm(template, undefined, okText);
this.blockIcon = 'spinner';
this.blockIcon = CoreConstants.ICON_LOADING;
const modal = await CoreDomUtils.instance.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1497,7 +1498,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
try {
await CoreDomUtils.instance.showDeleteConfirm(confirmMessage);
this.deleteIcon = 'spinner';
this.deleteIcon = CoreConstants.ICON_LOADING;
try {
try {
@ -1543,7 +1544,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
try {
await CoreDomUtils.instance.showConfirm(template, undefined, okText);
this.blockIcon = 'spinner';
this.blockIcon = CoreConstants.ICON_LOADING;
const modal = await CoreDomUtils.instance.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1582,7 +1583,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
try {
await CoreDomUtils.instance.showConfirm(template, undefined, okText);
this.addRemoveIcon = 'spinner';
this.addRemoveIcon = CoreConstants.ICON_LOADING;
const modal = await CoreDomUtils.instance.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1673,7 +1674,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
try {
await CoreDomUtils.instance.showConfirm(template, undefined, okText);
this.addRemoveIcon = 'spinner';
this.addRemoveIcon = CoreConstants.ICON_LOADING;
const modal = await CoreDomUtils.instance.showModalLoading('core.sending', true);
this.showLoadingModal = true;

View File

@ -20,7 +20,7 @@
[iconAction]="prefetchStatusIcon" [closeOnClick]="false">
</core-context-menu-item>
<core-context-menu-item *ngIf="size" [priority]="400" [content]="'core.clearstoreddata' | translate:{$a: size}"
iconDescription="fas-cube" (action)="removeFiles($event)" iconAction="fas-trash" [closeOnClick]="false">
iconDescription="fas-archive" (action)="removeFiles($event)" iconAction="fas-trash" [closeOnClick]="false">
</core-context-menu-item>
</core-context-menu>
</core-navbar-buttons>

View File

@ -624,8 +624,8 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
}
this.loaded = false;
this.refreshIcon = 'spinner';
this.syncIcon = 'spinner';
this.refreshIcon = CoreConstants.ICON_LOADING;
this.syncIcon = CoreConstants.ICON_LOADING;
try {
await this.validatePassword(<string> password);
@ -643,8 +643,8 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
CoreDomUtils.instance.showErrorModal(error);
} finally {
this.loaded = true;
this.refreshIcon = 'refresh';
this.syncIcon = 'sync';
this.refreshIcon = CoreConstants.ICON_REFRESH;
this.syncIcon = CoreConstants.ICON_SYNC;
CoreDomUtils.instance.triggerFormSubmittedEvent(this.formElement, true, this.siteId);
}

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreConstants } from '@/core/constants';
import { Component } from '@angular/core';
import { NavParams } from '@ionic/angular';
import { PopoverController } from '@singletons';
@ -58,7 +59,7 @@ export class CoreContextMenuPopoverComponent {
event.preventDefault();
event.stopPropagation();
if (item.iconAction == 'spinner') {
if (item.iconAction == CoreConstants.ICON_LOADING) {
return false;
}

View File

@ -77,12 +77,12 @@ export class CoreConstants {
static readonly OUTDATED = 'outdated';
static readonly NOT_DOWNLOADABLE = 'notdownloadable';
// Download / prefetch status icon. @todo
static readonly DOWNLOADED_ICON = 'cloud-done';
static readonly DOWNLOADING_ICON = 'spinner';
static readonly NOT_DOWNLOADED_ICON = 'cloud-download';
static readonly OUTDATED_ICON = 'fas-redo-alt';
static readonly NOT_DOWNLOADABLE_ICON = '';
// Download / prefetch status icon.
static readonly ICON_DOWNLOADED = 'cloud-done';
static readonly ICON_DOWNLOADING = 'spinner';
static readonly ICON_NOT_DOWNLOADED = 'cloud-download';
static readonly ICON_OUTDATED = 'fas-redo-alt';
static readonly ICON_NOT_DOWNLOADABLE = '';
// General download and sync icons.
static readonly ICON_LOADING = 'spinner';

View File

@ -25,6 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreCourseContentsPage } from '../pages/contents/contents';
import { CoreConstants } from '@/core/constants';
/**
* Template class to easily create CoreCourseModuleMainComponent of activities.
@ -70,7 +71,7 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
super.ngOnInit();
this.hasOffline = false;
this.syncIcon = 'spinner';
this.syncIcon = CoreConstants.ICON_LOADING;
this.moduleName = CoreCourse.instance.translateModuleName(this.moduleName || '');
if (this.syncEventName) {
@ -117,16 +118,16 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
return;
}
this.refreshIcon = 'spinner';
this.syncIcon = 'spinner';
this.refreshIcon = CoreConstants.ICON_LOADING;
this.syncIcon = CoreConstants.ICON_LOADING;
try {
await CoreUtils.instance.ignoreErrors(this.invalidateContent());
await this.loadContent(true, sync, showErrors);
} finally {
this.refreshIcon = 'fas-redo';
this.syncIcon = 'fas-sync';
this.refreshIcon = CoreConstants.ICON_REFRESH;
this.syncIcon = CoreConstants.ICON_SYNC;
}
}
@ -138,16 +139,16 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
* @return Resolved when done.
*/
protected async showLoadingAndFetch(sync: boolean = false, showErrors: boolean = false): Promise<void> {
this.refreshIcon = 'spinner';
this.syncIcon = 'spinner';
this.refreshIcon = CoreConstants.ICON_LOADING;
this.syncIcon = CoreConstants.ICON_LOADING;
this.loaded = false;
this.content?.scrollToTop();
try {
await this.loadContent(false, sync, showErrors);
} finally {
this.refreshIcon = 'fas-redo';
this.syncIcon = 'fas-sync';
this.refreshIcon = CoreConstants.ICON_REFRESH;
this.syncIcon = CoreConstants.ICON_REFRESH;
}
}
@ -159,8 +160,8 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
* @return Resolved when done.
*/
protected showLoadingAndRefresh(sync: boolean = false, showErrors: boolean = false): Promise<void> {
this.refreshIcon = 'spinner';
this.syncIcon = 'spinner';
this.refreshIcon = CoreConstants.ICON_LOADING;
this.syncIcon = CoreConstants.ICON_LOADING;
this.loaded = false;
this.content?.scrollToTop();
@ -207,8 +208,8 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
CoreDomUtils.instance.showErrorModalDefault(error, this.fetchContentDefaultError, true);
} finally {
this.loaded = true;
this.refreshIcon = 'fas-redo';
this.syncIcon = 'fas-sync';
this.refreshIcon = CoreConstants.ICON_REFRESH;
this.syncIcon = CoreConstants.ICON_REFRESH;
}
}

View File

@ -45,6 +45,7 @@ import {
CoreEventCompletionModuleViewedData,
} from '@singletons/events';
import { CoreNavigator } from '@services/navigator';
import { CoreConstants } from '@/core/constants';
/**
* Page that displays the contents of a course.
@ -71,7 +72,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy {
displayEnableDownload = false;
displayRefresher = false;
prefetchCourseData: CorePrefetchStatusInfo = {
icon: 'spinner',
icon: CoreConstants.ICON_LOADING,
statusTranslatable: 'core.course.downloadcourse',
status: '',
loading: true,
@ -171,7 +172,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy {
// Determine the course prefetch status.
await this.determineCoursePrefetchIcon();
if (this.prefetchCourseData.icon != 'spinner') {
if (this.prefetchCourseData.icon != CoreConstants.ICON_LOADING) {
return;
}

View File

@ -359,7 +359,7 @@ export class CoreCourseHelperProvider {
const siteId = CoreSites.instance.getCurrentSiteId();
data.downloadSucceeded = false;
data.icon = 'spinner';
data.icon = CoreConstants.ICON_DOWNLOADING;
data.statusTranslatable = 'core.downloading';
// Get the sections first if needed.
@ -563,7 +563,7 @@ export class CoreCourseHelperProvider {
done?: () => void,
): Promise<void> {
const initialIcon = instance.prefetchStatusIcon;
instance.prefetchStatusIcon = 'spinner'; // Show spinner since this operation might take a while.
instance.prefetchStatusIcon = CoreConstants.ICON_DOWNLOADING; // Show spinner since this operation might take a while.
try {
// We need to call getDownloadSize, the package might have been updated.
@ -1122,7 +1122,7 @@ export class CoreCourseHelperProvider {
if (prefetch.loading) {
// It seems all courses are being downloaded, show a download button instead.
prefetch.icon = CoreConstants.NOT_DOWNLOADED_ICON;
prefetch.icon = CoreConstants.ICON_NOT_DOWNLOADED;
}
return prefetch;
@ -1188,14 +1188,14 @@ export class CoreCourseHelperProvider {
prefetch: CorePrefetchStatusInfo,
): Promise<void> {
prefetch.loading = true;
prefetch.icon = CoreConstants.DOWNLOADING_ICON;
prefetch.icon = CoreConstants.ICON_DOWNLOADING;
prefetch.badge = '';
try {
await this.confirmAndPrefetchCourses(courses, (progress) => {
prefetch.badge = progress.count + ' / ' + progress.total;
});
prefetch.icon = CoreConstants.OUTDATED_ICON;
prefetch.icon = CoreConstants.ICON_OUTDATED;
} finally {
prefetch.loading = false;
prefetch.badge = '';
@ -1264,19 +1264,19 @@ export class CoreCourseHelperProvider {
*/
getPrefetchStatusIcon(status: string, trustDownload: boolean = false): string {
if (status == CoreConstants.NOT_DOWNLOADED) {
return CoreConstants.NOT_DOWNLOADED_ICON;
return CoreConstants.ICON_NOT_DOWNLOADED;
}
if (status == CoreConstants.OUTDATED || (status == CoreConstants.DOWNLOADED && !trustDownload)) {
return CoreConstants.OUTDATED_ICON;
return CoreConstants.ICON_OUTDATED;
}
if (status == CoreConstants.DOWNLOADED && trustDownload) {
return CoreConstants.DOWNLOADED_ICON;
return CoreConstants.ICON_DOWNLOADED;
}
if (status == CoreConstants.DOWNLOADING) {
return CoreConstants.DOWNLOADING_ICON;
return CoreConstants.ICON_DOWNLOADING;
}
return CoreConstants.DOWNLOADING_ICON;
return CoreConstants.ICON_DOWNLOADING;
}
/**
@ -1335,17 +1335,17 @@ export class CoreCourseHelperProvider {
moduleInfo.status = results[1];
switch (results[1]) {
case CoreConstants.NOT_DOWNLOADED:
moduleInfo.statusIcon = 'fas-cloud-download-alt';
moduleInfo.statusIcon = CoreConstants.ICON_NOT_DOWNLOADED;
break;
case CoreConstants.DOWNLOADING:
moduleInfo.statusIcon = 'spinner';
moduleInfo.statusIcon = CoreConstants.ICON_DOWNLOADING;
break;
case CoreConstants.OUTDATED:
moduleInfo.statusIcon = 'fas-redo';
moduleInfo.statusIcon = CoreConstants.ICON_OUTDATED;
break;
case CoreConstants.DOWNLOADED:
if (!CoreCourseModulePrefetchDelegate.instance.canCheckUpdates()) {
moduleInfo.statusIcon = 'fas-redo';
moduleInfo.statusIcon = CoreConstants.ICON_OUTDATED;
}
break;
default:

View File

@ -45,7 +45,7 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
filter = '';
showFilter = false;
coursesLoaded = false;
downloadAllCoursesIcon = CoreConstants.NOT_DOWNLOADED_ICON;
downloadAllCoursesIcon = CoreConstants.ICON_NOT_DOWNLOADED;
downloadAllCoursesLoading = false;
downloadAllCoursesBadge = '';
downloadAllCoursesEnabled = false;

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreConstants } from '@/core/constants';
/**
* Settings section.
*/
@ -40,7 +42,7 @@ export class CoreSettingsConstants {
{
name: 'synchronization',
path: 'sync',
icon: 'fas-sync-alt',
icon: CoreConstants.ICON_SYNC,
},
// @TODO sharedfiles
{