aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/comments.tsx9
-rw-r--r--src/utils/moments.ts84
2 files changed, 91 insertions, 2 deletions
diff --git a/src/utils/comments.tsx b/src/utils/comments.tsx
index 28879622..504631f5 100644
--- a/src/utils/comments.tsx
+++ b/src/utils/comments.tsx
@@ -82,12 +82,17 @@ export const renderTextWithMentions: React.FC<RenderProps> = ({
export const mentionPartTypes: (
theme: 'blue' | 'white',
component: 'caption' | 'comment',
-) => PartType[] = (theme, component) => {
+ isShowBelowStyle?: boolean,
+) => PartType[] = (theme, component, isShowBelowStyle = false) => {
return [
{
trigger: '@',
renderSuggestions: (props) => (
- <TaggTypeahead component={component} {...props} />
+ <TaggTypeahead
+ component={component}
+ isShowBelowStyle={isShowBelowStyle}
+ {...props}
+ />
),
allowedSpacesCount: 0,
isInsertSpaceAfterMention: true,
diff --git a/src/utils/moments.ts b/src/utils/moments.ts
index 9e8cc332..4aadb4d4 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,
+ };
+};