aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/moments.ts84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/utils/moments.ts b/src/utils/moments.ts
index 9e8cc332..2b924b1b 100644
--- a/src/utils/moments.ts
+++ b/src/utils/moments.ts
@@ -1,4 +1,6 @@
import moment from 'moment';
+import {ImageSourcePropType} from 'react-native';
+import {MOMENT_CATEGORY_BG_COLORS} from '../constants';
/**
* Formats elapsed time from a given time.
@@ -71,3 +73,85 @@ export const getTimeInShorthand = (date_time: string) => {
}
return time;
};
+
+export const getMomentCategoryIconInfo = (category: string) => {
+ let icon: ImageSourcePropType, bgColor: string;
+ switch (category) {
+ case 'Friends':
+ icon = require('../../assets/moment-categories/friends-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[0];
+ break;
+ case 'Adventure':
+ icon = require('../../assets/moment-categories/adventure-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[1];
+ break;
+ case 'Photo Dump':
+ icon = require('../../assets/moment-categories/photo-dump-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[2];
+ break;
+ case 'Food':
+ icon = require('../../assets/moment-categories/food-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[3];
+ break;
+ case 'Music':
+ icon = require('../../assets/moment-categories/music-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[4];
+ break;
+ case 'Art':
+ icon = require('../../assets/moment-categories/art-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[5];
+ break;
+ case 'Sports':
+ icon = require('../../assets/moment-categories/sports-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[6];
+ break;
+ case 'Fashion':
+ icon = require('../../assets/moment-categories/fashion-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[7];
+ break;
+ case 'Travel':
+ icon = require('../../assets/moment-categories/travel-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[8];
+ break;
+ case 'Pets':
+ icon = require('../../assets/moment-categories/pets-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[9];
+ break;
+ case 'Fitness':
+ icon = require('../../assets/moment-categories/fitness-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[10];
+ break;
+ case 'DIY':
+ icon = require('../../assets/moment-categories/diy-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[11];
+ break;
+ case 'Nature':
+ icon = require('../../assets/moment-categories/nature-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[12];
+ break;
+ case 'Early Life':
+ icon = require('../../assets/moment-categories/early-life-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[13];
+ break;
+ case 'Beauty':
+ icon = require('../../assets/moment-categories/beauty-icon.png');
+ bgColor = MOMENT_CATEGORY_BG_COLORS[14];
+ break;
+ default:
+ // All custom categories
+ icon = require('../../assets/moment-categories/custom-icon.png');
+ // A quick deterministic "random" color picker by summing up ascii char codees
+ const charCodeSum = category
+ .split('')
+ .reduce((acc: number, x: string) => acc + x.charCodeAt(0), 0);
+ bgColor =
+ MOMENT_CATEGORY_BG_COLORS[
+ charCodeSum % MOMENT_CATEGORY_BG_COLORS.length
+ ];
+ break;
+ }
+ return {
+ icon,
+ bgColor,
+ };
+};