|
@@ -1,6 +1,59 @@
|
|
|
|
|
+import {
|
|
|
|
|
+ Platform
|
|
|
|
|
+} from "react-native";
|
|
|
|
|
+
|
|
|
export const uuid = () => {
|
|
export const uuid = () => {
|
|
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
|
const r = Math.random() * 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8);
|
|
const r = Math.random() * 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8);
|
|
|
return v.toString(16);
|
|
return v.toString(16);
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+const ANDROID_FONT_FIX = {
|
|
|
|
|
+ "100": "Thin",
|
|
|
|
|
+ "200": "ExtraLight",
|
|
|
|
|
+ "300": "Light",
|
|
|
|
|
+ "400": "Regular",
|
|
|
|
|
+ "500": "Medium",
|
|
|
|
|
+ "600": "SemiBold",
|
|
|
|
|
+ "700": "Bold",
|
|
|
|
|
+ "800": "ExtraBold",
|
|
|
|
|
+ "900": "Black"
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+export const androidTypographyFixer = (defaultPaletteData: NCoreUIKit.Palette): NCoreUIKit.Palette => {
|
|
|
|
|
+ if(defaultPaletteData.isNeedAndroidTypographyFixer && Platform.OS === "android") {
|
|
|
|
|
+ const spacious = defaultPaletteData.typography.spacious;
|
|
|
|
|
+ const compact = defaultPaletteData.typography.compact;
|
|
|
|
|
+
|
|
|
|
|
+ (Object.keys(spacious) as Array<keyof typeof spacious>).forEach((key) => {
|
|
|
|
|
+ spacious[key] = {
|
|
|
|
|
+ ...spacious[key],
|
|
|
|
|
+ fontWeight: "normal",
|
|
|
|
|
+ fontFamily: spacious[key].fontFamily.indexOf("-") === -1
|
|
|
|
|
+ ? `${spacious[key].fontFamily}-${ANDROID_FONT_FIX[spacious[key].fontWeight as keyof typeof ANDROID_FONT_FIX]}`
|
|
|
|
|
+ : spacious[key].fontFamily
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ (Object.keys(compact) as Array<keyof typeof compact>).forEach((key) => {
|
|
|
|
|
+ compact[key] = {
|
|
|
|
|
+ ...compact[key],
|
|
|
|
|
+ fontWeight: "normal",
|
|
|
|
|
+ fontFamily: compact[key].fontFamily.indexOf("-") === -1
|
|
|
|
|
+ ? `${compact[key].fontFamily}-${ANDROID_FONT_FIX[compact[key].fontWeight as keyof typeof ANDROID_FONT_FIX]}`
|
|
|
|
|
+ : compact[key].fontFamily
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...defaultPaletteData,
|
|
|
|
|
+ typography: {
|
|
|
|
|
+ spacious: spacious,
|
|
|
|
|
+ compact: compact
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return defaultPaletteData;
|
|
|
|
|
+ }
|
|
|
|
|
+};
|