unioil-loyalty-rn-app/app/components/theme.style.js

138 lines
3.6 KiB
JavaScript

import { Platform, Dimensions } from 'react-native';
import { dateFormaterForAndroid } from '../utils/date';
import moment from 'moment';
import { ENV } from './environment';
const platform = Platform.OS;
const app_env = ENV;
const colors = {
primary: "#E74610",
primaryDark: "#d6410f",
accent: "#005598",
accentDark: "#013964",
primaryTransparent: "#1AE74610",
white: "#fff",
white50: "#78ffffff",
black: "#000000",
gray: "#888DA8",
searchText: "#707070",
searchGray: "#AFAFAF",
whitesmoke: "#F5F5F5",
darkerWhite: "#FFEDE6",
darkerGray: "#3b3b3b",
lightGray: "#EAEAEA",
darkGray: "#8E8E93",
black50: "#aa000000",
dim: "#4D000000",
textPrimary: "#4B4B4B",
soda: "#DF4F1B",
midnight: "#384856",
yellow: "#FFCE00",
ratingBorder: "#8E8E93",
pink: "#FFEDE6",
inactive: "rgba(255, 255, 255, 0.4)",
placeHolder: "rgba(0,0,0,.3)",
iqair: [
{main: "#48B74A", opacity: "#8BD38C"},
{main: "#FFC303", opacity: "#FFD95F"},
{main: "#FF9945", opacity: "#FEBF8A"},
{main: "#D2334B", opacity: "#E47F8D"},
{main: "#0188BC", opacity: "#5EB4D5"},
{main: "#4D3068", opacity: "#8F7CA0"},
]
}
const screen = {
w: Dimensions.get('window').width,
h: Dimensions.get('window').height,
tabHeight: 58
}
const card = {
elevation: 0,
radius: 16,
}
const font = "Arial";
const nameFormater = (name) => {
const newName = name.trim()
const firstLetter = newName.slice(0,1).toUpperCase();
const returnName = `${firstLetter}${newName.slice(1, name.lenght)}`.trim();
return returnName;
}
const formatter = {
NAME: function(profile){
if(!profile) return;
const { firstname, middlename, lastname } = profile;
return `${nameFormater(firstname)}${middlename ? " " + nameFormater(middlename) + " " : " " }${nameFormater(lastname)}`
},
CN: function(card){
let range = 4
let indexes = [0, 4, 8, 12]
let res = ""
for(var x=0;x<indexes.length;x++){
res += card.substr(indexes[x], range) + (x < indexes.length - 1 ? " " : "")
}
return res
},
CRNCY: function(amount){
return parseFloat(amount).toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
},
CRNCYNOFIXED: function(amount){
if(!amount) return amount
else return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
},
PMBL: function(number){
//RETURNS MOBILE NUMBER FORMAT API REQUIRED @ FROM 639062447306 TO @ 9062447306
return number.substr(0, 0) + "" + number.substr(2)
},
MBNF: function(number, replace){
var regEx = /^(63|\+63)\d{10}$/
var regExReplace = /^(63|\+63)/
let validMobileNumber = regEx.test(number);
if(!validMobileNumber) {
return number
}
return number.replace(regExReplace, replace)
},
ENCMBL: function(contact){
//RETURNS MOBILE NUMBER WITH HIDDEN PARTS @ 0921****104
let replacement = "****"
let index = 5
return "+" + contact.substr(0, index) + replacement+ contact.substr(index + replacement.length)
},
DT4API: function(dt){
if(platform === 'android') {
const newDate = dateFormaterForAndroid(dt);
return new moment(new Date(newDate)).format("YYYY-MM-DD")
}
return new moment(new Date(dt)).format("YYYY-MM-DD")
},
DTUI: function(dt){
if(platform === 'android') {
const newDate = dateFormaterForAndroid(dt);
return new moment(new Date(newDate)).format("DD MMM YYYY")
}
return new moment(new Date(dt)).format("DD MMM YYYY")
},
CPN: function(mobile) {
let res = ""
res += mobile.substring(5, 0) + " " + mobile.substring(8, 5) + " " + mobile.substring(12, 8)
return res
}
}
export default {
colors,
screen,
font,
card,
formatter,
platform,
app_env
}