-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAppStyles.js
More file actions
335 lines (290 loc) · 7.67 KB
/
Copy pathAppStyles.js
File metadata and controls
335 lines (290 loc) · 7.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
import { StyleSheet, Dimensions, PixelRatio, Platform } from "react-native";
import * as Device from "expo-device";
import * as FileSystem from "expo-file-system";
// styles in app.js
export const styles = StyleSheet.create({
container: {
flex: 1,
},
});
// dimesnions of the mobile
export const dimensions = {
fullHeight: Dimensions.get("window").height,
fullWidth: Dimensions.get("window").width,
fontScale: Dimensions.get("window").fontScale,
};
// get the responsive font size
export const responsiveFontSize = (size) => {
return Math.floor(
PixelRatio.roundToNearestPixel(size / dimensions.fontScale)
);
};
// get the dimensions of the screen
export const UI_dimensions = {
heightMobileUI: 932,
widthMobileUI: 430,
};
// get factor Scale for width and height
export const BaseScale = {
widthScale: dimensions.fullWidth / UI_dimensions.widthMobileUI,
heightScale: dimensions.fullHeight / UI_dimensions.heightMobileUI,
};
// get the responsive width
export const responsiveWidth = (width) => {
return Math.round(
PixelRatio.roundToNearestPixel(width * BaseScale.widthScale)
);
};
// get the responsive height
export const responsiveHeight = (height) => {
return Math.round(
PixelRatio.roundToNearestPixel(height * BaseScale.heightScale)
);
};
// check if it's iphone
export const isIOS = () => {
return Platform.OS === "ios";
};
// detect IOS Version
export const hasNotch = (version) => {
const modelName = Device.modelName;
const ex_notch = [
"iPhone 7",
"iPhone 7 Plus",
"iPhone 8",
"iPhone 8 Plus",
"iPhone SE",
"iPhone 6",
"iPhone 6 Plus",
"iPhone 6s",
"iPhone 6s Plus",
"iPhone 5",
"iPhone 5s",
"iPhone 5c",
"iPhone 4s",
"iPhone 4",
"iPhone 3G",
"iPhone 3GS",
"iPhone 1G",
];
return isIOS() && !ex_notch.includes(modelName);
};
// colors used in the app
export const colors = {
Gold: "#EFCE4A",
White: "#FFFFFF",
WhiteI: "#F9F9F9",
OffWhite: "#F0EEEE",
Black: "#000000",
DarkBlack: "#1E1E1E",
DarkCyan: "#003441",
Cyan: "#55C4E0",
LightSeaGreen: "#1B7B94",
Grey: "#ABAAAA",
GreyI: "#7B7B7B",
GreyII: "#AEAEAE",
SolidGrey: "#D9D9D9",
LightGrey: "#aaa",
DarkGrey: "#606060",
Red: "#e24c4b",
DarkRed: "#910F06",
Green: "#0aa06e",
LightBlue: "#C9D7FE",
BlueI: "#060B73",
BlueII: "#040740",
Yellow: "#fe9800",
Orange: "#ff6a00",
Purple: "#800080",
Pink: "#FFC0CB",
Brown: "#A52A2A",
DarkGreen: "#006400",
NavyRed: "#410000",
NavyYellow: "#412300",
NavyGreen: "#014000",
Violet: "#6200EE",
};
// padding used in the app
export const padding = {
sm: 10,
md: 20,
lg: 30,
xl: 40,
xxl: 60,
xxxl: 80,
xxxxl: 100,
xxxxxl: 120,
xxxxxxl: 140,
};
// margin used in the app
export const margin = {
sm: 10,
md: 20,
lg: 30,
xl: 40,
xxl: 60,
xxxl: 80,
xxxxl: 100,
xxxxxl: 120,
xxxxxxl: 140,
};
// font family used in the app
export const fontFamily = {
CapitalisTypOasis: "CapitalisTypOasis",
MontserratBold: "Montserrat-Bold",
MontserratMedium: "Montserrat-Medium",
MontserratRegular: "Montserrat-Regular",
MontserratSemiBold: "Montserrat-SemiBold",
MontserratBlack: "Montserrat-Black",
MontserratThin: "Montserrat-Thin",
MontserratLight: "Montserrat-Light",
PoppinsRegular: "Poppins-Regular",
PoppinsBold: "Poppins-Bold",
PoppinsMedium: "Poppins-Medium",
PoppinsSemiBold: "Poppins-SemiBold",
PoppinsThin: "Poppins-Thin",
PoppinsLight: "Poppins-Light",
PoppinsExtraLight: "Poppins-Black",
};
// font weight used in the app
export const fontWeight = {
normal: "normal",
thin: "100",
light: "300",
medium: "500",
semiBold: "600",
bold: "700",
extraBold: "800",
black: "900",
};
// convert date
export const formatDate = (inputDate) => {
// get first part of timestamp
inputDate = inputDate.split("T")[0];
// Split the input date string into year, month, and day
const [year, month, day] = inputDate.split("-");
// Create a Date object using the year, month, and day
const dateObject = new Date(year, month - 1, day);
// Array of month names
const monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
// Get the day, month name, and year from the date object
const formattedDay = dateObject.getDate();
const formattedMonth = monthNames[dateObject.getMonth()];
const formattedYear = dateObject.getFullYear();
// Concatenate the formatted day, month name, and year
const formattedDate = `${formattedDay} ${formattedMonth} ${formattedYear}`;
return formattedDate;
};
// format historic date
export const formatHistoricDate = (country, date) => {
const formatDate = `${date} | ${country}`;
return formatDate;
};
// placeholder
export const placeholder = require("./assets/placeholder.png");
export const convertTo12HourFormat = (dateTimeString) => {
const date = new Date(dateTimeString);
// Get day of the week
const days = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
const day = days[date.getDay()];
// Get time in 12-hour format
let hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12; // Handle midnight
// Format minutes
const formattedMinutes = minutes < 10 ? "0" + minutes : minutes;
// Construct the array
const formattedTime = `${hours}:${formattedMinutes} ${ampm}`;
const formattedYMD = `${date.getFullYear()}-${
date.getMonth() + 1
}-${date.getDate()}`;
return [day, formattedTime, formattedYMD];
};
export const removeMinute = (data) => {
let newData = {};
for (let day in data) {
if (data.hasOwnProperty(day)) {
newData[day] = {};
let times = data[day];
for (let time in times) {
if (times.hasOwnProperty(time) && typeof times[time] === "object") {
newData[day][time] = { hour: times[time].hour };
}
}
}
}
return newData;
};
export const mergeSameDays = (schedule) => {
const mergedSchedule = {};
for (const day1 in schedule) {
const from1 = schedule[day1].from.hour;
const to1 = schedule[day1].to.hour;
let mergedKey = day1; // Initialize merged key with current day
for (const day2 in schedule) {
if (
day1 !== day2 &&
schedule[day2].from.hour === from1 &&
schedule[day2].to.hour === to1
) {
mergedKey += ", " + day2;
delete schedule[day2];
}
}
mergedSchedule[mergedKey] = {
from: schedule[day1].from,
to: schedule[day1].to,
};
}
return mergedSchedule;
};
export const createFormData = async (uri) => {
try {
const fileName = uri.split("/").pop(); // Get the file name from the URI
const fileType = fileName.split(".").pop(); // Get the file extension
const formData = new FormData();
// Check if the URI is a remote URL
if (uri.startsWith("http://") || uri.startsWith("https://")) {
// Download the file using FileSystem
const fileUri = FileSystem.cacheDirectory + fileName;
await FileSystem.downloadAsync(uri, fileUri);
uri = fileUri; // Update the URI to the downloaded file URI
}
// Determine the MIME type
const mimeType = fileType === "jpg" ? "image/jpeg" : `image/${fileType}`;
// Create the file object
const file = {
uri: uri,
name: fileName,
type: mimeType,
};
formData.append("image", file);
return formData;
} catch (error) {
console.log("Error creating FormData:", error);
throw error; // Rethrow the error to be caught by the calling function
}
};
export const blurhash = "";