MOBILE-3320 utils: Add helper methods and classes
parent
25edf4a3aa
commit
2c01a3c4aa
|
@ -38,10 +38,18 @@ export class CoreConstants {
|
|||
/* eslint-disable max-len */
|
||||
|
||||
static readonly SECONDS_YEAR = 31536000;
|
||||
static readonly SECONDS_MONTH = 2592000;
|
||||
static readonly SECONDS_WEEK = 604800;
|
||||
static readonly SECONDS_DAY = 86400;
|
||||
static readonly SECONDS_HOUR = 3600;
|
||||
static readonly SECONDS_MINUTE = 60;
|
||||
static readonly MILLISECONDS_YEAR = 31536000000;
|
||||
static readonly MILLISECONDS_MONTH = 2592000000;
|
||||
static readonly MILLISECONDS_WEEK = 604800000;
|
||||
static readonly MILLISECONDS_DAY = 86400000;
|
||||
static readonly MILLISECONDS_HOUR = 3600000;
|
||||
static readonly MILLISECONDS_MINUTE = 60000;
|
||||
static readonly MILLISECONDS_SECOND = 1000;
|
||||
static readonly WIFI_DOWNLOAD_THRESHOLD = 104857600; // 100MB.
|
||||
static readonly DOWNLOAD_THRESHOLD = 10485760; // 10MB.
|
||||
static readonly MINIMUM_FREE_SPACE = 10485760; // 10MB.
|
||||
|
@ -131,7 +139,7 @@ export class CoreConstants {
|
|||
|
||||
}
|
||||
|
||||
type EnvironmentConfig = {
|
||||
export interface EnvironmentConfig {
|
||||
app_id: string;
|
||||
appname: string;
|
||||
versioncode: number;
|
||||
|
@ -167,7 +175,7 @@ type EnvironmentConfig = {
|
|||
forceOpenLinksIn: 'app' | 'browser';
|
||||
};
|
||||
|
||||
type EnvironmentBuild = {
|
||||
export interface EnvironmentBuild {
|
||||
version: string;
|
||||
isProduction: boolean;
|
||||
isTesting: boolean;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* Singleton with helper functions for math operations.
|
||||
*/
|
||||
export class CoreMath {
|
||||
|
||||
/**
|
||||
* Clamp a value between a minimum and a maximum.
|
||||
*
|
||||
* @param value Original value.
|
||||
* @param min Minimum value.
|
||||
* @param max Maximum value.
|
||||
* @return Clamped value.
|
||||
*/
|
||||
static clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,17 @@ export type CoreObjectWithoutEmpty<T> = {
|
|||
*/
|
||||
export class CoreObject {
|
||||
|
||||
/**
|
||||
* Check if two objects have the same shape and the same leaf values.
|
||||
*
|
||||
* @param a First object.
|
||||
* @param b Second object.
|
||||
* @return Whether objects are equal.
|
||||
*/
|
||||
static deepEquals(a: unknown, b: unknown): boolean {
|
||||
return JSON.stringify(a) === JSON.stringify(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given object is empty.
|
||||
*
|
||||
|
|
|
@ -161,3 +161,12 @@ $screen-breakpoints: (
|
|||
) !default;
|
||||
|
||||
$breakpoint-tablet: map-get($screen-breakpoints, tablet), !default;
|
||||
|
||||
/*
|
||||
* Z-indexes.
|
||||
*
|
||||
* https://github.com/ionic-team/ionic-framework/blob/master/core/src/themes/ionic.globals.scss
|
||||
*/
|
||||
|
||||
$z-index-overlay: 1001;
|
||||
$z-index-overlay-wrapper: 10;
|
||||
|
|
|
@ -37,6 +37,14 @@
|
|||
flex-direction: row;
|
||||
}
|
||||
|
||||
.margin-bottom-sm { margin-bottom: 8px; }
|
||||
.margin-bottom-md { margin-bottom: 12px; }
|
||||
|
||||
.font-bold { font-weight: bold; }
|
||||
.font-italic { font-style: italic; }
|
||||
.font-lg { font-size: 1.7rem; }
|
||||
.font-sm { font-size: 1.2rem; }
|
||||
|
||||
// Correctly inherit ion-text-wrap onto labels.
|
||||
ion-item.ion-text-wrap ion-label {
|
||||
white-space: normal !important;
|
||||
|
|
Loading…
Reference in New Issue