@tactics/toddle-styleguide 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.tsx +11 -0
- package/index.d.ts +2 -1
- package/index.tsx +2 -0
- package/package.json +1 -1
- package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
- package/src/components/atoms/line/line.component.d.ts +12 -0
- package/src/components/atoms/line/line.component.tsx +23 -0
- package/src/components/atoms/line/line.preview.d.ts +1 -0
- package/src/components/atoms/line/line.preview.tsx +54 -0
- package/src/components/atoms/line/line.styles.d.ts +12 -0
- package/src/components/atoms/line/line.styles.js +10 -0
- package/src/components/atoms/quick-message/__snapshots__/quick-message.test.js.snap +72 -1
- package/src/components/atoms/quick-message/quick-message.component.d.ts +2 -0
- package/src/components/atoms/quick-message/quick-message.component.tsx +3 -1
- package/src/components/atoms/quick-message/quick-message.preview.tsx +10 -1
- package/src/components/atoms/quick-message/quick-message.styles.d.ts +4 -1
- package/src/components/atoms/quick-message/quick-message.styles.js +4 -2
- package/src/components/atoms/quick-message/quick-message.test.js +38 -6
- package/src/components/atoms/text-input/__snapshots__/text-input.test.js.snap +38 -78
- package/src/components/atoms/text-input/text-input.component.tsx +6 -9
- package/src/components/atoms/text-input/text-input.preview.tsx +3 -3
- package/src/components/atoms/text-input/text-input.styles.d.ts +9 -25
- package/src/components/atoms/text-input/text-input.styles.js +7 -13
- package/src/components/molecules/day/__snapshots__/day.test.js.snap +24 -24
- package/src/components/molecules/day/day.component.tsx +17 -4
- package/src/components/molecules/day/day.styles.d.ts +33 -42
- package/src/components/molecules/day/day.styles.js +14 -17
- package/src/components/molecules/failed-to-send/failed-bubble.component.d.ts +2 -2
- package/src/components/molecules/failed-to-send/failed-bubble.component.tsx +39 -22
- package/src/components/molecules/password-input/__snapshots__/password-input.test.js.snap +53 -68
- package/src/components/molecules/password-input/password-input.component.tsx +7 -9
- package/src/components/molecules/password-input/password-input.styles.d.ts +8 -7
- package/src/components/molecules/password-input/password-input.styles.js +6 -6
- package/src/components/molecules/search-input/__snapshots__/search.test.js.snap +30 -31
- package/src/components/molecules/search-input/search.component.d.ts +9 -11
- package/src/components/molecules/search-input/search.component.tsx +19 -30
- package/src/components/molecules/search-input/search.preview.tsx +8 -6
- package/src/components/molecules/search-input/search.styles.d.ts +12 -11
- package/src/components/molecules/search-input/search.styles.js +14 -8
- package/src/components/molecules/search-input/search.test.js +3 -1
- package/src/components/molecules/send-bubble/__snapshots__/send-text-bubble.test.js.snap +12 -32
- package/src/components/molecules/send-bubble/send-text-bubble.component.d.ts +4 -4
- package/src/components/molecules/send-bubble/send-text-bubble.component.tsx +36 -25
- package/src/components/molecules/send-bubble/send-text-bubble.styles.d.ts +4 -7
- package/src/components/molecules/send-bubble/send-text-bubble.styles.js +2 -8
- package/src/components/molecules/timeline/__snapshots__/timeline.test.js.snap +4 -4
- package/src/components/molecules/timeline/timeline.styles.d.ts +1 -1
- package/src/components/molecules/timeline/timeline.styles.js +2 -2
- package/src/components/molecules/timestamp/__snapshots__/timestamp.test.js.snap +2 -1
- package/src/components/molecules/timestamp/timestamp.component.d.ts +2 -1
- package/src/components/molecules/timestamp/timestamp.component.tsx +4 -7
- package/src/components/organisms/child-list-item/__snapshots__/child-list-item.test.js.snap +165 -10
- package/src/components/organisms/child-list-item/child-list-item.component.d.ts +2 -0
- package/src/components/organisms/child-list-item/child-list-item.component.tsx +24 -1
- package/src/components/organisms/child-list-item/child-list-item.preview.tsx +11 -0
- package/src/components/organisms/child-list-item/child-list-item.styles.d.ts +0 -3
- package/src/components/organisms/child-list-item/child-list-item.styles.js +2 -3
- package/src/components/organisms/child-list-item/child-list-item.test.js +9 -4
- package/src/components/organisms/child-list-item/components/child-list-tag.component.d.ts +9 -0
- package/src/components/organisms/child-list-item/components/child-list-tag.component.tsx +28 -0
- package/src/components/organisms/child-list-item/components/child-list-tag.styles.d.ts +13 -0
- package/src/components/organisms/child-list-item/components/child-list-tag.styles.js +16 -0
- package/src/components/organisms/day-select/day-select.preview.tsx +9 -5
- package/src/components/organisms/journal-entry/components/entry-type-indicator/entry-type-indicator.d.ts +9 -0
- package/src/components/organisms/journal-entry/components/entry-type-indicator/entry-type-indicator.styles.d.ts +13 -0
- package/src/components/organisms/journal-entry/components/entry-type-indicator/entry-type-indicator.styles.js +17 -0
- package/src/components/organisms/journal-entry/components/entry-type-indicator/entry-type-indicator.test.js +21 -0
- package/src/components/organisms/journal-entry/components/entry-type-indicator/entry-type-indicator.tsx +97 -0
- package/src/components/organisms/journal-entry/components/index.d.ts +2 -0
- package/src/components/organisms/journal-entry/components/index.ts +2 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/__snapshots__/journal-entry-type.test.js.snap +304 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.d.ts +16 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.tsx +60 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.styles.d.ts +13 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.styles.js +16 -0
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.test.js +48 -0
- package/src/components/organisms/journal-entry/journal-entry.component.d.ts +38 -0
- package/src/components/organisms/journal-entry/journal-entry.component.tsx +139 -0
- package/src/components/organisms/journal-entry/journal-entry.preview.d.ts +1 -0
- package/src/components/organisms/journal-entry/journal-entry.preview.tsx +212 -0
- package/src/components/organisms/journal-entry/journal-entry.styles.d.ts +42 -0
- package/src/components/organisms/journal-entry/journal-entry.styles.js +35 -0
- package/src/components/organisms/my-child-list-item/__snapshots__/my-child-list-item.test.js.snap +143 -399
- package/src/components/organisms/my-child-list-item/my-child-list-item.component.d.ts +5 -7
- package/src/components/organisms/my-child-list-item/my-child-list-item.component.tsx +32 -59
- package/src/components/organisms/my-child-list-item/my-child-list-item.preview.tsx +36 -24
- package/src/components/organisms/my-child-list-item/my-child-list-item.styles.d.ts +15 -11
- package/src/components/organisms/my-child-list-item/my-child-list-item.styles.js +16 -11
- package/src/components/organisms/my-child-list-item/my-child-list-item.test.js +5 -22
- package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +45 -29
- package/src/components/organisms/text-bubble/text-bubble.component.d.ts +8 -6
- package/src/components/organisms/text-bubble/text-bubble.component.tsx +14 -12
- package/src/components/organisms/text-bubble/text-bubble.preview.tsx +14 -19
- package/src/components/organisms/text-bubble/text-bubble.styles.d.ts +14 -3
- package/src/components/organisms/text-bubble/text-bubble.styles.js +6 -0
- package/src/components/organisms/text-bubble/text-bubble.test.js +7 -7
- package/src/components/templates/modal/components/fade-panel.component.tsx +1 -1
- package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.d.ts +4 -0
- package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.tsx +6 -0
- package/src/utilities/toddle-datetime/toddle-datetime.class.d.ts +14 -1
- package/src/utilities/toddle-datetime/toddle-datetime.class.tsx +31 -2
- package/src/utilities/toddle-datetime/toddle-datetime.preview.tsx +114 -84
- package/src/utilities/toddle-datetime/types/{duration-like.type.d.ts → duration.type.d.ts} +2 -0
- package/src/utilities/toddle-datetime/types/{duration-like.type.tsx → duration.type.tsx} +3 -0
- package/src/utilities/toddle-datetime/types/toddle-datetime.type.d.ts +1 -0
- package/src/utilities/toddle-datetime/types/toddle-datetime.type.tsx +8 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, {useContext, useRef} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Platform,
|
|
5
|
+
UIManager,
|
|
6
|
+
useWindowDimensions,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
10
|
+
import {Stylesheet} from './journal-entry.styles';
|
|
11
|
+
import {JournalEntryType} from './components';
|
|
12
|
+
import {ToddleDateTime} from '../../../utilities/toddle-datetime/toddle-datetime.class';
|
|
13
|
+
import {TextBubble} from '../text-bubble/text-bubble.component';
|
|
14
|
+
import {VisualState} from '../../../types/visual-state.enum';
|
|
15
|
+
import {BubbleAlignment} from '../../../types/bubble-alignment.enum';
|
|
16
|
+
import {Line} from '../../atoms/line/line.component';
|
|
17
|
+
import {LoadingIndicator} from '../loading-indicator/loading-indicator.component';
|
|
18
|
+
|
|
19
|
+
interface JournalEntryProps {
|
|
20
|
+
id: string;
|
|
21
|
+
prio: boolean;
|
|
22
|
+
happenedAt: ToddleDateTime;
|
|
23
|
+
type: string;
|
|
24
|
+
text: string;
|
|
25
|
+
visualState: VisualState;
|
|
26
|
+
bubbleAlignment: BubbleAlignment;
|
|
27
|
+
createdAt?: ToddleDateTime;
|
|
28
|
+
timestampLabel?: string;
|
|
29
|
+
sendOrReceived: boolean;
|
|
30
|
+
onFail?: (id: string) => void;
|
|
31
|
+
onEdit?: (id: string) => void;
|
|
32
|
+
onDelete?: (id: string) => void;
|
|
33
|
+
afterAnimationComplete?: () => void;
|
|
34
|
+
loadingNewEntry?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const JournalEntry = ({
|
|
38
|
+
id,
|
|
39
|
+
prio,
|
|
40
|
+
happenedAt,
|
|
41
|
+
type,
|
|
42
|
+
text,
|
|
43
|
+
visualState,
|
|
44
|
+
bubbleAlignment,
|
|
45
|
+
createdAt,
|
|
46
|
+
timestampLabel,
|
|
47
|
+
sendOrReceived,
|
|
48
|
+
onFail,
|
|
49
|
+
onEdit,
|
|
50
|
+
onDelete,
|
|
51
|
+
afterAnimationComplete,
|
|
52
|
+
loadingNewEntry,
|
|
53
|
+
}: JournalEntryProps) => {
|
|
54
|
+
const context = useContext(ThemeCtx);
|
|
55
|
+
const styles = Stylesheet(context, bubbleAlignment, createdAt);
|
|
56
|
+
|
|
57
|
+
const {width} = useWindowDimensions();
|
|
58
|
+
const animatedValue = useRef(
|
|
59
|
+
new Animated.Value(loadingNewEntry ? 0 : 0.5)
|
|
60
|
+
).current;
|
|
61
|
+
|
|
62
|
+
if (Platform.OS === 'android') {
|
|
63
|
+
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (loadingNewEntry) {
|
|
67
|
+
Animated.timing(animatedValue, {
|
|
68
|
+
toValue: 0.5,
|
|
69
|
+
duration: 400,
|
|
70
|
+
useNativeDriver: true,
|
|
71
|
+
}).start(() => {
|
|
72
|
+
if (afterAnimationComplete) {
|
|
73
|
+
afterAnimationComplete();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const deleteJournalEntryHandler = (id: string) => {
|
|
79
|
+
Animated.timing(animatedValue, {
|
|
80
|
+
toValue: -1,
|
|
81
|
+
duration: 400,
|
|
82
|
+
useNativeDriver: true,
|
|
83
|
+
}).start(() => {
|
|
84
|
+
if (onDelete) onDelete(id);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const translateX = animatedValue.interpolate({
|
|
89
|
+
inputRange: [0, 0.5, 1],
|
|
90
|
+
outputRange: [-width, 0, width],
|
|
91
|
+
});
|
|
92
|
+
const opacity = animatedValue.interpolate({
|
|
93
|
+
inputRange: [0, 0.5, 1],
|
|
94
|
+
outputRange: [0, 1, 0],
|
|
95
|
+
});
|
|
96
|
+
return (
|
|
97
|
+
<Animated.View
|
|
98
|
+
style={[
|
|
99
|
+
styles.rootContainer,
|
|
100
|
+
{
|
|
101
|
+
transform: [{translateX: translateX}],
|
|
102
|
+
opacity: opacity,
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
105
|
+
>
|
|
106
|
+
<View style={styles.entryTypeContainer}>
|
|
107
|
+
<JournalEntryType
|
|
108
|
+
prio={prio}
|
|
109
|
+
type={type}
|
|
110
|
+
happenedAt={happenedAt}
|
|
111
|
+
loading={loadingNewEntry}
|
|
112
|
+
send={sendOrReceived}
|
|
113
|
+
/>
|
|
114
|
+
</View>
|
|
115
|
+
{loadingNewEntry ? (
|
|
116
|
+
<View style={{height: 80, justifyContent: 'center'}}>
|
|
117
|
+
<LoadingIndicator color={context.colors.main[5]} />
|
|
118
|
+
</View>
|
|
119
|
+
) : (
|
|
120
|
+
<TextBubble
|
|
121
|
+
id={id}
|
|
122
|
+
text={text}
|
|
123
|
+
visualState={visualState}
|
|
124
|
+
bubbleAlignment={bubbleAlignment}
|
|
125
|
+
timestamp={createdAt}
|
|
126
|
+
timestampLabel={timestampLabel}
|
|
127
|
+
sendOrReceived={sendOrReceived}
|
|
128
|
+
onDelete={deleteJournalEntryHandler}
|
|
129
|
+
onEdit={onEdit}
|
|
130
|
+
onFail={onFail}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
|
|
134
|
+
<View style={styles.horizontalLineContainer}>
|
|
135
|
+
<Line />
|
|
136
|
+
</View>
|
|
137
|
+
</Animated.View>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const JournalEntryPreview: () => JSX.Element;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {FlatList, LayoutAnimation, ListRenderItem, View} from 'react-native';
|
|
2
|
+
|
|
3
|
+
import {JournalEntry} from './journal-entry.component';
|
|
4
|
+
import {ToddleDateTime} from '../../../utilities/toddle-datetime/toddle-datetime.class';
|
|
5
|
+
import {VisualState} from '../../../types/visual-state.enum';
|
|
6
|
+
import {BubbleAlignment} from '../../../types/bubble-alignment.enum';
|
|
7
|
+
import {useRef, useState} from 'react';
|
|
8
|
+
import {PressableIcon} from '../../molecules/pressable-icon/pressable-icon.component';
|
|
9
|
+
import {Icon} from '../../../icons/index';
|
|
10
|
+
|
|
11
|
+
const DATA = [
|
|
12
|
+
{
|
|
13
|
+
picture: '',
|
|
14
|
+
prio: true,
|
|
15
|
+
uuid: '35dc156d-6e59-4628-abf8-cddd9b836875',
|
|
16
|
+
happened_at: 1691394300,
|
|
17
|
+
type: 'GENERAL',
|
|
18
|
+
message: 'We kijken uit naar een leuke dag met Mattis',
|
|
19
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
20
|
+
sender: 'STAFF_MEMBER',
|
|
21
|
+
send: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
picture: '',
|
|
25
|
+
prio: false,
|
|
26
|
+
uuid: 'f776461d-1b74-48be-9b52-5a225b411323',
|
|
27
|
+
happened_at: 1691395200,
|
|
28
|
+
type: 'GENERAL',
|
|
29
|
+
message:
|
|
30
|
+
'Mattis kijkt er ook naar uit! Hij staat al heel het weekend te springen om terug naar de creche te gaan.',
|
|
31
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
32
|
+
sender: 'PARENT',
|
|
33
|
+
send: false,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
picture: '',
|
|
37
|
+
prio: false,
|
|
38
|
+
uuid: 'f451f76e-8573-4130-8c72-28d6a90f164d',
|
|
39
|
+
happened_at: 1691397000,
|
|
40
|
+
type: 'GENERAL',
|
|
41
|
+
message: 'Test bericht met het uur voor Mattis',
|
|
42
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
43
|
+
sender: 'STAFF_MEMBER',
|
|
44
|
+
send: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
picture: '',
|
|
48
|
+
prio: true,
|
|
49
|
+
uuid: 'ee25c811-ff66-439b-8f09-50224e1252e3',
|
|
50
|
+
happened_at: 1691402400,
|
|
51
|
+
type: 'ACTIVITY',
|
|
52
|
+
message: 'Vandaag gaan we knutselen met heel de groep!',
|
|
53
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
54
|
+
sender: 'STAFF_MEMBER',
|
|
55
|
+
send: false,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
picture: '',
|
|
59
|
+
prio: false,
|
|
60
|
+
uuid: '4b858f01-25ae-4a7d-9671-627379494fff',
|
|
61
|
+
happened_at: 1691402400,
|
|
62
|
+
type: 'ACTIVITY',
|
|
63
|
+
message: 'Klaar voor onze schilders schorten aan te doen!',
|
|
64
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
65
|
+
sender: 'STAFF_MEMBER',
|
|
66
|
+
send: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
picture: '',
|
|
70
|
+
prio: false,
|
|
71
|
+
uuid: '3edb8d39-9d12-43dd-929e-98b834f2f325',
|
|
72
|
+
happened_at: 1691409600,
|
|
73
|
+
type: 'NUTRITION',
|
|
74
|
+
message:
|
|
75
|
+
'Onze prachtige kunstwerken zijn aan het drogen, tijd voor een lekkere maaltijd',
|
|
76
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
77
|
+
sender: 'STAFF_MEMBER',
|
|
78
|
+
send: true,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
picture: '',
|
|
82
|
+
prio: false,
|
|
83
|
+
uuid: '6cab5367-d10a-41ec-bb8b-5151df8385f0',
|
|
84
|
+
happened_at: 1691413200,
|
|
85
|
+
type: 'NUTRITION',
|
|
86
|
+
message:
|
|
87
|
+
'Mattis heeft flink zijn buikje vol gegeten. Straks een goed dutje!',
|
|
88
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
89
|
+
sender: 'STAFF_MEMBER',
|
|
90
|
+
send: true,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
picture: '',
|
|
94
|
+
prio: true,
|
|
95
|
+
uuid: '23afaef6-fa4a-43f6-adab-1772b226fb54',
|
|
96
|
+
happened_at: 1691416800,
|
|
97
|
+
type: 'SLEEP',
|
|
98
|
+
message: 'Tijd voor een welverdiend dutje',
|
|
99
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
100
|
+
sender: 'STAFF_MEMBER',
|
|
101
|
+
send: true,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
interface JournalEntry {
|
|
106
|
+
picture: string;
|
|
107
|
+
prio: boolean;
|
|
108
|
+
uuid: string;
|
|
109
|
+
happened_at: number;
|
|
110
|
+
type: string;
|
|
111
|
+
message: string;
|
|
112
|
+
subscription_day: string;
|
|
113
|
+
sender: string;
|
|
114
|
+
loadingNewEntry?: boolean;
|
|
115
|
+
send: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const JournalEntryPreview = () => {
|
|
119
|
+
const [entries, setEntries] = useState(DATA);
|
|
120
|
+
const flatListRef = useRef<FlatList | null>(null);
|
|
121
|
+
|
|
122
|
+
const addJournalEntry = (newEntry: JournalEntry) => {
|
|
123
|
+
setEntries((prevEntries) => [
|
|
124
|
+
...prevEntries,
|
|
125
|
+
{...newEntry, loadingNewEntry: true},
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
setEntries((prevEntries) =>
|
|
130
|
+
prevEntries.map((entry) =>
|
|
131
|
+
entry.uuid === newEntry.uuid
|
|
132
|
+
? {...entry, loadingNewEntry: false}
|
|
133
|
+
: entry
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
}, 3000); // Simulating a delay to demonstrate loading state
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const deleteJournalEntry = (entryId: string) => {
|
|
140
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
141
|
+
const newData = entries.filter((journal) => journal.uuid !== entryId);
|
|
142
|
+
setEntries(newData);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const renderJournalEntryList: ListRenderItem<JournalEntry> = ({item}) => {
|
|
146
|
+
return (
|
|
147
|
+
<JournalEntry
|
|
148
|
+
key={item.uuid}
|
|
149
|
+
id={item.uuid}
|
|
150
|
+
prio={item.prio}
|
|
151
|
+
type={item.type}
|
|
152
|
+
happenedAt={ToddleDateTime.fromSeconds(item.happened_at, {zone: 'utc'})}
|
|
153
|
+
text={item.message}
|
|
154
|
+
visualState={item.prio ? VisualState.WARNING : VisualState.DEFAULT}
|
|
155
|
+
bubbleAlignment={
|
|
156
|
+
item.sender === 'STAFF_MEMBER'
|
|
157
|
+
? BubbleAlignment.SENT
|
|
158
|
+
: BubbleAlignment.RECEIVE
|
|
159
|
+
}
|
|
160
|
+
createdAt={ToddleDateTime.fromSeconds(item.happened_at, {zone: 'utc'})}
|
|
161
|
+
timestampLabel={'ingevuld op'}
|
|
162
|
+
sendOrReceived={item.send}
|
|
163
|
+
onDelete={deleteJournalEntry}
|
|
164
|
+
onEdit={() => console.log('edit entry')}
|
|
165
|
+
onFail={() => console.log('resend')}
|
|
166
|
+
afterAnimationComplete={() => console.log('animation done')}
|
|
167
|
+
loadingNewEntry={item.loadingNewEntry}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<View
|
|
174
|
+
style={{
|
|
175
|
+
flex: 1,
|
|
176
|
+
backgroundColor: 'white',
|
|
177
|
+
justifyContent: 'flex-start',
|
|
178
|
+
alignItems: 'stretch',
|
|
179
|
+
paddingLeft: 16,
|
|
180
|
+
paddingRight: 16,
|
|
181
|
+
paddingTop: 16,
|
|
182
|
+
paddingBottom: 40,
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<View style={{alignItems: 'center', marginBottom: 16}}>
|
|
186
|
+
<PressableIcon
|
|
187
|
+
icon={<Icon key={'1'} style={'regular'} name={'plus-sm'} />}
|
|
188
|
+
onPress={() =>
|
|
189
|
+
addJournalEntry({
|
|
190
|
+
picture: '',
|
|
191
|
+
prio: false,
|
|
192
|
+
uuid: `${Math.random()}-23afaef6-fa4a-43f6-adab-1772b226fb54`,
|
|
193
|
+
happened_at: 1691416800,
|
|
194
|
+
type: 'SLEEP',
|
|
195
|
+
message: 'Tijd voor een welverdiend dutje',
|
|
196
|
+
subscription_day: 'c45cbc3d-7698-4f2d-b892-b634bf016497',
|
|
197
|
+
sender: 'STAFF_MEMBER',
|
|
198
|
+
send: true,
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
/>
|
|
202
|
+
</View>
|
|
203
|
+
<FlatList
|
|
204
|
+
style={{flex: 1}}
|
|
205
|
+
ref={flatListRef}
|
|
206
|
+
data={entries}
|
|
207
|
+
renderItem={renderJournalEntryList}
|
|
208
|
+
keyExtractor={(item) => item.uuid}
|
|
209
|
+
/>
|
|
210
|
+
</View>
|
|
211
|
+
);
|
|
212
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function Stylesheet(
|
|
2
|
+
context: any,
|
|
3
|
+
bubbleAlignment: any,
|
|
4
|
+
createdAt: any
|
|
5
|
+
):
|
|
6
|
+
| StyleSheet.NamedStyles<any>
|
|
7
|
+
| StyleSheet.NamedStyles<{
|
|
8
|
+
rootContainer: {
|
|
9
|
+
borderLeftWidth: number;
|
|
10
|
+
borderLeftColor: any;
|
|
11
|
+
marginLeft: number;
|
|
12
|
+
paddingTop: number;
|
|
13
|
+
};
|
|
14
|
+
entryTypeContainer: {
|
|
15
|
+
position: 'absolute';
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
flexDirection: 'row';
|
|
19
|
+
alignItems: 'center';
|
|
20
|
+
gap: number;
|
|
21
|
+
marginBottom: number;
|
|
22
|
+
};
|
|
23
|
+
horizontalLineContainer: (
|
|
24
|
+
| {
|
|
25
|
+
maxWidth: string;
|
|
26
|
+
width: string;
|
|
27
|
+
alignSelf: string;
|
|
28
|
+
marginTop: number;
|
|
29
|
+
marginBottom: number;
|
|
30
|
+
marginLeft?: undefined;
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
marginLeft: number;
|
|
34
|
+
maxWidth?: undefined;
|
|
35
|
+
width?: undefined;
|
|
36
|
+
alignSelf?: undefined;
|
|
37
|
+
marginTop?: undefined;
|
|
38
|
+
marginBottom?: undefined;
|
|
39
|
+
}
|
|
40
|
+
)[];
|
|
41
|
+
}>;
|
|
42
|
+
import {StyleSheet} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Scale} from '../../../theme/scale/index';
|
|
3
|
+
import {BubbleAlignment} from '../../../types/bubble-alignment.enum';
|
|
4
|
+
|
|
5
|
+
export const Stylesheet = (context, bubbleAlignment, createdAt) =>
|
|
6
|
+
StyleSheet.create({
|
|
7
|
+
rootContainer: {
|
|
8
|
+
borderLeftWidth: 1,
|
|
9
|
+
borderLeftColor: context.colors.ui.xlightgrey,
|
|
10
|
+
marginLeft: Scale.s,
|
|
11
|
+
paddingTop: Scale.m * 2.25,
|
|
12
|
+
},
|
|
13
|
+
entryTypeContainer: {
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
top: 0,
|
|
16
|
+
left: -16,
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
gap: Scale.s,
|
|
20
|
+
marginBottom: Scale.m,
|
|
21
|
+
},
|
|
22
|
+
horizontalLineContainer: [
|
|
23
|
+
{
|
|
24
|
+
maxWidth: '80%',
|
|
25
|
+
width: '100%',
|
|
26
|
+
alignSelf:
|
|
27
|
+
bubbleAlignment === BubbleAlignment.SENT ? 'flex-end' : 'flex-start',
|
|
28
|
+
marginTop: createdAt ? Scale.xxxs : Scale.m,
|
|
29
|
+
marginBottom: Scale.s,
|
|
30
|
+
},
|
|
31
|
+
bubbleAlignment === BubbleAlignment.RECEIVE && {
|
|
32
|
+
marginLeft: Scale.l,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|