@magmamath/students-features 0.6.13 → 0.6.14-rc.1
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/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +67 -15
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js +150 -41
- package/dist/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/InputButton.js +97 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/InputButton.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js +156 -0
- package/dist/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +7 -4
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/commonjs/features/chatbot/constants.js +4 -0
- package/dist/commonjs/features/chatbot/constants.js.map +1 -1
- package/dist/commonjs/features/problemSelector/components/ProblemSelectorButton.js +1 -1
- package/dist/commonjs/features/problemSelector/components/ProblemSelectorButton.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/ca.json +1 -1
- package/dist/commonjs/shared/translation/localization/en.json +2 -2
- package/dist/commonjs/shared/translation/localization/gb.json +1 -1
- package/dist/commonjs/shared/translation/localization/sct.json +1 -1
- package/dist/commonjs/shared/translation/localization/sw.json +1 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +67 -15
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js +149 -41
- package/dist/module/features/chatbot/components/Alternatives/HelpRequestOption.js.map +1 -1
- package/dist/module/features/chatbot/components/Alternatives/InputButton.js +89 -0
- package/dist/module/features/chatbot/components/Alternatives/InputButton.js.map +1 -0
- package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js +149 -0
- package/dist/module/features/chatbot/components/Alternatives/InputWithHintRow.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +7 -4
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/module/features/chatbot/constants.js +4 -0
- package/dist/module/features/chatbot/constants.js.map +1 -1
- package/dist/module/features/problemSelector/components/ProblemSelectorButton.js +1 -1
- package/dist/module/features/problemSelector/components/ProblemSelectorButton.js.map +1 -1
- package/dist/module/shared/translation/localization/ca.json +1 -1
- package/dist/module/shared/translation/localization/en.json +2 -2
- package/dist/module/shared/translation/localization/gb.json +1 -1
- package/dist/module/shared/translation/localization/sct.json +1 -1
- package/dist/module/shared/translation/localization/sw.json +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +5 -2
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputButton.d.ts +10 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +11 -0
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +4 -0
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +5 -4
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts +5 -2
- package/dist/typescript/module/features/chatbot/components/Alternatives/HelpRequestOption.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputButton.d.ts +10 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputButton.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts +11 -0
- package/dist/typescript/module/features/chatbot/components/Alternatives/InputWithHintRow.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/constants.d.ts +4 -0
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +5 -4
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +89 -14
- package/src/features/chatbot/components/Alternatives/HelpRequestOption.tsx +160 -37
- package/src/features/chatbot/components/Alternatives/InputButton.tsx +90 -0
- package/src/features/chatbot/components/Alternatives/InputWithHintRow.tsx +158 -0
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +6 -2
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +1 -1
- package/src/features/chatbot/constants.ts +4 -0
- package/src/features/chatbot/types/api.types.ts +6 -4
- package/src/features/problemSelector/components/ProblemSelectorButton.tsx +1 -1
- package/src/shared/translation/localization/ca.json +1 -1
- package/src/shared/translation/localization/en.json +2 -2
- package/src/shared/translation/localization/gb.json +1 -1
- package/src/shared/translation/localization/sct.json +1 -1
- package/src/shared/translation/localization/sw.json +1 -1
|
@@ -1,58 +1,182 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { Animated, Pressable, StyleSheet } from 'react-native'
|
|
3
|
-
import { COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
-
|
|
1
|
+
// import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
// import { Animated, Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
// import { ArrowUpIcon, COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
+
//
|
|
5
|
+
// type HelpRequestOptionProps = {
|
|
6
|
+
// onPress: () => void
|
|
7
|
+
// message: string
|
|
8
|
+
// disabled: boolean
|
|
9
|
+
// hoverColor?: string
|
|
10
|
+
// }
|
|
11
|
+
//
|
|
12
|
+
// export const HelpRequestOption = ({
|
|
13
|
+
// onPress,
|
|
14
|
+
// message,
|
|
15
|
+
// disabled = false,
|
|
16
|
+
// hoverColor = COLORS.PRIMARY_BLUE,
|
|
17
|
+
// }: HelpRequestOptionProps) => {
|
|
18
|
+
// const [isHovered, setIsHovered] = useState(false)
|
|
19
|
+
// const hoverAnim = useRef(new Animated.Value(0)).current
|
|
20
|
+
//
|
|
21
|
+
// const backgroundColor = hoverAnim.interpolate({
|
|
22
|
+
// inputRange: [0, 1],
|
|
23
|
+
// outputRange: [COLORS.NEUTRAL_1, hoverColor],
|
|
24
|
+
// })
|
|
25
|
+
// const textColor = hoverAnim.interpolate({
|
|
26
|
+
// inputRange: [0, 1],
|
|
27
|
+
// outputRange: [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1],
|
|
28
|
+
// })
|
|
29
|
+
//
|
|
30
|
+
// useEffect(() => {
|
|
31
|
+
// Animated.timing(hoverAnim, {
|
|
32
|
+
// toValue: isHovered ? 1 : 0,
|
|
33
|
+
// duration: 200,
|
|
34
|
+
// useNativeDriver: false,
|
|
35
|
+
// }).start()
|
|
36
|
+
// }, [isHovered, hoverAnim])
|
|
37
|
+
//
|
|
38
|
+
// return (
|
|
39
|
+
// <Pressable
|
|
40
|
+
// onHoverIn={() => setIsHovered(true)}
|
|
41
|
+
// onHoverOut={() => setIsHovered(false)}
|
|
42
|
+
// onPress={onPress}
|
|
43
|
+
// style={styles.button}
|
|
44
|
+
// disabled={disabled}
|
|
45
|
+
// accessibilityState={{ disabled }}
|
|
46
|
+
// accessibilityRole="button"
|
|
47
|
+
// >
|
|
48
|
+
// <Animated.View
|
|
49
|
+
// style={[styles.textWrapper, { backgroundColor, borderColor: isHovered ? backgroundColor: COLORS.PRIMARY_BLUE }]}
|
|
50
|
+
// >
|
|
51
|
+
// <Animated.Text numberOfLines={1} style={[styles.text, { color: textColor }]}>
|
|
52
|
+
// I need a hint
|
|
53
|
+
// </Animated.Text>
|
|
54
|
+
// <ArrowUpIcon color={isHovered ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_10} />
|
|
55
|
+
// </Animated.View>
|
|
56
|
+
// </Pressable>
|
|
57
|
+
// )
|
|
58
|
+
// }
|
|
59
|
+
//
|
|
60
|
+
// const styles = StyleSheet.create({
|
|
61
|
+
// button: {
|
|
62
|
+
// flexDirection: 'row',
|
|
63
|
+
// alignItems: 'flex-end',
|
|
64
|
+
// justifyContent: 'space-between',
|
|
65
|
+
// width: '100%',
|
|
66
|
+
// },
|
|
67
|
+
// text: {
|
|
68
|
+
// fontSize: 18,
|
|
69
|
+
// fontWeight: 400,
|
|
70
|
+
// fontFamily: FONT_FAMILY.buenosAires,
|
|
71
|
+
// color: COLORS.NEUTRAL_10,
|
|
72
|
+
// },
|
|
73
|
+
// textWrapper: {
|
|
74
|
+
// flex: 1,
|
|
75
|
+
// flexDirection: 'row',
|
|
76
|
+
// alignItems: 'center',
|
|
77
|
+
// justifyContent: 'space-between',
|
|
78
|
+
// maxWidth: 163,
|
|
79
|
+
// paddingHorizontal: SPACING[400],
|
|
80
|
+
// paddingVertical: SPACING[200],
|
|
81
|
+
// borderWidth: 1,
|
|
82
|
+
// borderRadius: 48,
|
|
83
|
+
// elevation: 3,
|
|
84
|
+
// shadowColor: '#333',
|
|
85
|
+
// shadowOffset: { width: 0, height: 1 },
|
|
86
|
+
// shadowOpacity: 0.25,
|
|
87
|
+
// shadowRadius: 3,
|
|
88
|
+
// backgroundColor: COLORS.NEUTRAL_1,
|
|
89
|
+
// borderColor: COLORS.PRIMARY_BLUE,
|
|
90
|
+
// },
|
|
91
|
+
// })
|
|
92
|
+
|
|
93
|
+
import React from 'react'
|
|
94
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
95
|
+
import Animated, {
|
|
96
|
+
useSharedValue,
|
|
97
|
+
withTiming,
|
|
98
|
+
useAnimatedStyle,
|
|
99
|
+
interpolateColor,
|
|
100
|
+
SharedValue,
|
|
101
|
+
} from 'react-native-reanimated'
|
|
102
|
+
import { ArrowUpIcon, COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
103
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
104
|
+
import { MESSAGE_COLORS_MAP } from '../../constants'
|
|
5
105
|
|
|
6
106
|
type HelpRequestOptionProps = {
|
|
7
107
|
onPress: () => void
|
|
8
108
|
message: string
|
|
9
109
|
disabled: boolean
|
|
10
|
-
|
|
110
|
+
colorScheme?: ColorScheme
|
|
111
|
+
visibleSv?: SharedValue<number>
|
|
11
112
|
}
|
|
12
113
|
|
|
13
114
|
export const HelpRequestOption = ({
|
|
14
115
|
onPress,
|
|
15
116
|
message,
|
|
16
117
|
disabled = false,
|
|
17
|
-
|
|
118
|
+
colorScheme = ColorScheme.Blue,
|
|
119
|
+
visibleSv,
|
|
18
120
|
}: HelpRequestOptionProps) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
121
|
+
const hoverSv = useSharedValue(0)
|
|
122
|
+
|
|
123
|
+
const onHoverIn = () => {
|
|
124
|
+
if (!disabled) hoverSv.value = withTiming(1, { duration: 200 })
|
|
125
|
+
}
|
|
126
|
+
const onHoverOut = () => {
|
|
127
|
+
if (!disabled) hoverSv.value = withTiming(0, { duration: 200 })
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const animatedWrapperStyle = useAnimatedStyle(() => {
|
|
131
|
+
const backgroundColor = interpolateColor(
|
|
132
|
+
hoverSv.value,
|
|
133
|
+
[0, 1],
|
|
134
|
+
[COLORS.NEUTRAL_1, MESSAGE_COLORS_MAP[colorScheme].sent.background],
|
|
135
|
+
)
|
|
136
|
+
const borderColor = interpolateColor(
|
|
137
|
+
hoverSv.value,
|
|
138
|
+
[0, 1],
|
|
139
|
+
[
|
|
140
|
+
MESSAGE_COLORS_MAP[colorScheme].sent.border,
|
|
141
|
+
MESSAGE_COLORS_MAP[colorScheme].sent.border,
|
|
142
|
+
],
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
backgroundColor: disabled ? COLORS.NEUTRAL_2 : backgroundColor,
|
|
147
|
+
borderColor: disabled ? COLORS.NEUTRAL_5 : borderColor,
|
|
148
|
+
}
|
|
149
|
+
}, [hoverSv, disabled, colorScheme])
|
|
21
150
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
const textColor = hoverAnim.interpolate({
|
|
27
|
-
inputRange: [0, 1],
|
|
28
|
-
outputRange: [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1],
|
|
29
|
-
})
|
|
151
|
+
const animatedTextStyle = useAnimatedStyle(() => {
|
|
152
|
+
const color = interpolateColor(hoverSv.value, [0, 1], [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1])
|
|
153
|
+
return { color: disabled ? COLORS.NEUTRAL_5 : color }
|
|
154
|
+
}, [hoverSv, disabled])
|
|
30
155
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}).start()
|
|
37
|
-
}, [isHovered, hoverAnim])
|
|
156
|
+
const animatedVisibilityStyle = useAnimatedStyle(() => {
|
|
157
|
+
return {
|
|
158
|
+
opacity: visibleSv ? visibleSv.value : 1,
|
|
159
|
+
}
|
|
160
|
+
}, [visibleSv])
|
|
38
161
|
|
|
39
162
|
return (
|
|
40
163
|
<Pressable
|
|
41
|
-
onHoverIn={
|
|
42
|
-
onHoverOut={
|
|
164
|
+
onHoverIn={onHoverIn}
|
|
165
|
+
onHoverOut={onHoverOut}
|
|
43
166
|
onPress={onPress}
|
|
44
|
-
style={styles.button}
|
|
167
|
+
style={[styles.button, { cursor: disabled ? 'auto' : 'pointer' }]}
|
|
45
168
|
disabled={disabled}
|
|
46
169
|
accessibilityState={{ disabled }}
|
|
47
170
|
accessibilityRole="button"
|
|
48
171
|
>
|
|
49
|
-
<Animated.View
|
|
50
|
-
style={[styles.
|
|
51
|
-
>
|
|
52
|
-
<Animated.Text numberOfLines={1} style={[styles.text, { color: textColor }]}>
|
|
172
|
+
<Animated.View style={[styles.textWrapper, animatedWrapperStyle, animatedVisibilityStyle]}>
|
|
173
|
+
<Animated.Text numberOfLines={1} style={[styles.text, animatedTextStyle]}>
|
|
53
174
|
{message}
|
|
54
175
|
</Animated.Text>
|
|
55
|
-
|
|
176
|
+
|
|
177
|
+
<Animated.Text style={animatedTextStyle}>
|
|
178
|
+
<ArrowUpIcon color={'currentColor'} size={16} />
|
|
179
|
+
</Animated.Text>
|
|
56
180
|
</Animated.View>
|
|
57
181
|
</Pressable>
|
|
58
182
|
)
|
|
@@ -61,13 +185,11 @@ export const HelpRequestOption = ({
|
|
|
61
185
|
const styles = StyleSheet.create({
|
|
62
186
|
button: {
|
|
63
187
|
flexDirection: 'row',
|
|
64
|
-
|
|
65
|
-
justifyContent: 'space-between',
|
|
66
|
-
width: '100%',
|
|
188
|
+
justifyContent: 'flex-end',
|
|
67
189
|
},
|
|
68
190
|
text: {
|
|
69
|
-
fontSize:
|
|
70
|
-
fontWeight: 400,
|
|
191
|
+
fontSize: 18,
|
|
192
|
+
fontWeight: '400',
|
|
71
193
|
fontFamily: FONT_FAMILY.buenosAires,
|
|
72
194
|
color: COLORS.NEUTRAL_10,
|
|
73
195
|
},
|
|
@@ -76,7 +198,7 @@ const styles = StyleSheet.create({
|
|
|
76
198
|
flexDirection: 'row',
|
|
77
199
|
alignItems: 'center',
|
|
78
200
|
justifyContent: 'space-between',
|
|
79
|
-
|
|
201
|
+
width: 163,
|
|
80
202
|
paddingHorizontal: SPACING[400],
|
|
81
203
|
paddingVertical: SPACING[200],
|
|
82
204
|
borderWidth: 1,
|
|
@@ -87,5 +209,6 @@ const styles = StyleSheet.create({
|
|
|
87
209
|
shadowOpacity: 0.25,
|
|
88
210
|
shadowRadius: 3,
|
|
89
211
|
backgroundColor: COLORS.NEUTRAL_1,
|
|
212
|
+
borderColor: COLORS.PRIMARY_BLUE,
|
|
90
213
|
},
|
|
91
214
|
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
interpolateColor,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
import { ArrowUpIcon, COLORS, FONT_FAMILY } from '@magmamath/react-native-ui'
|
|
10
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
11
|
+
import { MESSAGE_COLORS_MAP } from '../../constants'
|
|
12
|
+
|
|
13
|
+
type HelpRequestOptionProps = {
|
|
14
|
+
onPress: () => void
|
|
15
|
+
disabled: boolean
|
|
16
|
+
colorScheme?: ColorScheme
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const InputButton = ({
|
|
20
|
+
onPress,
|
|
21
|
+
disabled = false,
|
|
22
|
+
colorScheme = ColorScheme.Blue,
|
|
23
|
+
}: HelpRequestOptionProps) => {
|
|
24
|
+
const hoverSv = useSharedValue(0)
|
|
25
|
+
|
|
26
|
+
const onHoverIn = () => {
|
|
27
|
+
if (!disabled) hoverSv.value = withTiming(1, { duration: 200 })
|
|
28
|
+
}
|
|
29
|
+
const onHoverOut = () => {
|
|
30
|
+
if (!disabled) hoverSv.value = withTiming(0, { duration: 200 })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const animatedWrapperStyle = useAnimatedStyle(() => {
|
|
34
|
+
const backgroundColor = interpolateColor(hoverSv.value, [0, 1], [COLORS.NEUTRAL_1, MESSAGE_COLORS_MAP[colorScheme].sent.border])
|
|
35
|
+
const color = interpolateColor(hoverSv.value, [0, 1], [COLORS.NEUTRAL_10, COLORS.NEUTRAL_1])
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
backgroundColor: disabled ? COLORS.NEUTRAL_2 : backgroundColor,
|
|
39
|
+
borderColor: disabled ? COLORS.NEUTRAL_5 : MESSAGE_COLORS_MAP[colorScheme].sent.border,
|
|
40
|
+
color: disabled ? COLORS.NEUTRAL_5 : color,
|
|
41
|
+
}
|
|
42
|
+
}, [hoverSv, disabled])
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Pressable
|
|
46
|
+
onHoverIn={onHoverIn}
|
|
47
|
+
onHoverOut={onHoverOut}
|
|
48
|
+
onPress={onPress}
|
|
49
|
+
style={[styles.button, disabled && { cursor: 'auto' }]}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
accessibilityState={{ disabled }}
|
|
52
|
+
accessibilityRole="button"
|
|
53
|
+
>
|
|
54
|
+
<Animated.Text style={[styles.textWrapper, animatedWrapperStyle]}>
|
|
55
|
+
<ArrowUpIcon color={'currentColor'} size={16} />
|
|
56
|
+
</Animated.Text>
|
|
57
|
+
</Pressable>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
button: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
justifyContent: 'flex-end',
|
|
65
|
+
},
|
|
66
|
+
text: {
|
|
67
|
+
fontSize: 18,
|
|
68
|
+
fontWeight: '400',
|
|
69
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
70
|
+
color: COLORS.NEUTRAL_10,
|
|
71
|
+
backgroundColor: 'purple',
|
|
72
|
+
},
|
|
73
|
+
textWrapper: {
|
|
74
|
+
flex: 1,
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
justifyContent: 'space-between',
|
|
78
|
+
paddingHorizontal: 13,
|
|
79
|
+
paddingVertical: 12,
|
|
80
|
+
borderWidth: 1,
|
|
81
|
+
borderRadius: 48,
|
|
82
|
+
elevation: 3,
|
|
83
|
+
shadowColor: '#333',
|
|
84
|
+
shadowOffset: { width: 0, height: 1 },
|
|
85
|
+
shadowOpacity: 0.25,
|
|
86
|
+
shadowRadius: 3,
|
|
87
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
88
|
+
borderColor: COLORS.PRIMARY_BLUE,
|
|
89
|
+
},
|
|
90
|
+
})
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Platform, StyleSheet, TextInput, View } from 'react-native'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
useAnimatedReaction,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
import { COLORS, FONT_FAMILY, SPACING } from '@magmamath/react-native-ui'
|
|
10
|
+
import { HelpRequestOption } from './HelpRequestOption'
|
|
11
|
+
import { InputButton } from './InputButton'
|
|
12
|
+
import { ColorScheme } from '@magmamath/students-features'
|
|
13
|
+
|
|
14
|
+
const COMPACT_WIDTH = 134
|
|
15
|
+
|
|
16
|
+
type InputWithHintRowProps = {
|
|
17
|
+
onPress: () => void
|
|
18
|
+
message: string
|
|
19
|
+
disabled: boolean
|
|
20
|
+
colorScheme?: ColorScheme
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const InputWithHintRow = ({
|
|
24
|
+
onPress,
|
|
25
|
+
message,
|
|
26
|
+
disabled,
|
|
27
|
+
colorScheme,
|
|
28
|
+
}: InputWithHintRowProps) => {
|
|
29
|
+
const [value, setValue] = useState('')
|
|
30
|
+
|
|
31
|
+
const widthSv = useSharedValue(COMPACT_WIDTH)
|
|
32
|
+
const arrowOpacitySv = useSharedValue(1)
|
|
33
|
+
const hintVisibleSv = useSharedValue(1)
|
|
34
|
+
const valueLengthSv = useSharedValue(0)
|
|
35
|
+
|
|
36
|
+
const shouldDisable = value.trim().length > 0
|
|
37
|
+
|
|
38
|
+
const animatedInputStyle = useAnimatedStyle(
|
|
39
|
+
() => ({
|
|
40
|
+
width: widthSv.value,
|
|
41
|
+
}),
|
|
42
|
+
[widthSv],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const handleChangeText = (text: string) => {
|
|
46
|
+
setValue(text)
|
|
47
|
+
valueLengthSv.value = text.trim().length
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
useAnimatedReaction(
|
|
51
|
+
() => valueLengthSv.value,
|
|
52
|
+
(currentLength) => {
|
|
53
|
+
if (currentLength > 0) {
|
|
54
|
+
widthSv.value = withTiming(305, { duration: 200 })
|
|
55
|
+
arrowOpacitySv.value = withTiming(0, { duration: 200 })
|
|
56
|
+
hintVisibleSv.value = withTiming(0, { duration: 200 })
|
|
57
|
+
} else {
|
|
58
|
+
widthSv.value = withTiming(COMPACT_WIDTH, { duration: 200 })
|
|
59
|
+
arrowOpacitySv.value = withTiming(1, { duration: 200 })
|
|
60
|
+
hintVisibleSv.value = withTiming(1, { duration: 200 })
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[valueLengthSv],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
// const handleFocus = () => {
|
|
67
|
+
// widthSv.value = withTiming(305, { duration: 200 }) // expand full width (container limits it)
|
|
68
|
+
// arrowOpacitySv.value = withTiming(0, { duration: 200 })
|
|
69
|
+
// hintVisibleSv.value = withTiming(0, { duration: 200 })
|
|
70
|
+
//
|
|
71
|
+
// // setIsFocused(true)
|
|
72
|
+
// }
|
|
73
|
+
//
|
|
74
|
+
// const handleBlur = () => {
|
|
75
|
+
// if (value.trim().length > 0) return
|
|
76
|
+
// widthSv.value = withTiming(COMPACT_WIDTH, { duration: 200 })
|
|
77
|
+
// arrowOpacitySv.value = withTiming(1, { duration: 200 })
|
|
78
|
+
// hintVisibleSv.value = withTiming(1, { duration: 200 })
|
|
79
|
+
// // setIsFocused(false)
|
|
80
|
+
// }
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View style={styles.container}>
|
|
84
|
+
<Animated.View style={[styles.inputWrapper, animatedInputStyle]}>
|
|
85
|
+
<TextInput
|
|
86
|
+
style={styles.input}
|
|
87
|
+
placeholder="Type..."
|
|
88
|
+
placeholderTextColor={COLORS.NEUTRAL_6}
|
|
89
|
+
value={value}
|
|
90
|
+
onChangeText={handleChangeText}
|
|
91
|
+
// onFocus={handleFocus}
|
|
92
|
+
// onBlur={handleBlur}
|
|
93
|
+
/>
|
|
94
|
+
<Animated.View style={[styles.arrowWrapper]}>
|
|
95
|
+
<InputButton
|
|
96
|
+
onPress={() => {
|
|
97
|
+
console.log('Pressed')
|
|
98
|
+
}}
|
|
99
|
+
disabled={value.trim().length < 1 || disabled}
|
|
100
|
+
colorScheme={colorScheme}
|
|
101
|
+
/>
|
|
102
|
+
</Animated.View>
|
|
103
|
+
</Animated.View>
|
|
104
|
+
|
|
105
|
+
<HelpRequestOption
|
|
106
|
+
visibleSv={hintVisibleSv}
|
|
107
|
+
disabled={disabled || shouldDisable}
|
|
108
|
+
onPress={onPress}
|
|
109
|
+
message={message}
|
|
110
|
+
colorScheme={colorScheme}
|
|
111
|
+
/>
|
|
112
|
+
</View>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const styles = StyleSheet.create({
|
|
117
|
+
container: {
|
|
118
|
+
position: 'relative',
|
|
119
|
+
width: '100%',
|
|
120
|
+
alignItems: 'flex-end',
|
|
121
|
+
height: 52,
|
|
122
|
+
justifyContent: 'center',
|
|
123
|
+
},
|
|
124
|
+
inputWrapper: {
|
|
125
|
+
position: 'absolute',
|
|
126
|
+
zIndex: 1,
|
|
127
|
+
right: SPACING[200],
|
|
128
|
+
left: 0,
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
borderWidth: 1,
|
|
132
|
+
borderColor: COLORS.NEUTRAL_5,
|
|
133
|
+
borderRadius: 200,
|
|
134
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
135
|
+
paddingHorizontal: SPACING[100],
|
|
136
|
+
paddingVertical: SPACING[100],
|
|
137
|
+
overflow: 'hidden',
|
|
138
|
+
elevation: 3,
|
|
139
|
+
shadowColor: '#333',
|
|
140
|
+
shadowOffset: { width: 0, height: 1 },
|
|
141
|
+
shadowOpacity: 0.25,
|
|
142
|
+
shadowRadius: 3,
|
|
143
|
+
},
|
|
144
|
+
input: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
fontSize: 16,
|
|
147
|
+
minWidth: 60,
|
|
148
|
+
minHeight: 22,
|
|
149
|
+
fontWeight: '400',
|
|
150
|
+
fontFamily: FONT_FAMILY.buenosAires,
|
|
151
|
+
...(Platform.OS === 'web' && { outlineStyle: 'none' }),
|
|
152
|
+
paddingHorizontal: SPACING[100],
|
|
153
|
+
paddingVertical: SPACING[200],
|
|
154
|
+
},
|
|
155
|
+
arrowWrapper: {
|
|
156
|
+
marginLeft: SPACING[200],
|
|
157
|
+
},
|
|
158
|
+
})
|
|
@@ -6,6 +6,7 @@ import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
|
|
|
6
6
|
import { ThreeDotsLoader } from '../ThreeDotsLoader/ThreeDotsLoader'
|
|
7
7
|
import { CONTROLS_COLORS_MAP } from '../../constants'
|
|
8
8
|
import { ColorScheme } from '../../types/style.types'
|
|
9
|
+
import { LavaIconInGlasses } from '@magmamath/students-features'
|
|
9
10
|
|
|
10
11
|
type MessageLoaderProps = {
|
|
11
12
|
colorScheme?: ColorScheme
|
|
@@ -14,7 +15,7 @@ type MessageLoaderProps = {
|
|
|
14
15
|
export const MessageLoader = ({ colorScheme = ColorScheme.Blue }: MessageLoaderProps) => (
|
|
15
16
|
<View style={styles.container}>
|
|
16
17
|
<View style={styles.icon}>
|
|
17
|
-
<
|
|
18
|
+
<LavaIconInGlasses width={60} height={80} />
|
|
18
19
|
</View>
|
|
19
20
|
<View style={styles.loader}>
|
|
20
21
|
<ThreeDotsLoader backgroundColor={CONTROLS_COLORS_MAP[colorScheme].background} />
|
|
@@ -27,10 +28,13 @@ const styles = StyleSheet.create({
|
|
|
27
28
|
flexDirection: 'row',
|
|
28
29
|
width: 327,
|
|
29
30
|
alignItems: 'flex-end',
|
|
31
|
+
paddingLeft:70
|
|
30
32
|
},
|
|
31
33
|
icon: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
zIndex:1,
|
|
32
36
|
alignSelf: 'flex-end',
|
|
33
|
-
|
|
37
|
+
left: 0
|
|
34
38
|
},
|
|
35
39
|
loader: {
|
|
36
40
|
flex: 1,
|
|
@@ -44,20 +44,24 @@ export const MESSAGE_COLORS_MAP = {
|
|
|
44
44
|
[ColorScheme.Blue]: {
|
|
45
45
|
[MessageVariant.RECEIVED]: {
|
|
46
46
|
background: COLORS.NEUTRAL_3,
|
|
47
|
+
border: COLORS.NEUTRAL_3,
|
|
47
48
|
icon: ButtonColor.BLUE,
|
|
48
49
|
},
|
|
49
50
|
[MessageVariant.SENT]: {
|
|
50
51
|
background: COLORS.PRIMARY_BLUE,
|
|
52
|
+
border: COLORS.PRIMARY_BLUE,
|
|
51
53
|
icon: ButtonColor.BLUE,
|
|
52
54
|
},
|
|
53
55
|
},
|
|
54
56
|
[ColorScheme.Yellow]: {
|
|
55
57
|
[MessageVariant.RECEIVED]: {
|
|
56
58
|
background: COLORS.NEUTRAL_3,
|
|
59
|
+
border: COLORS.NEUTRAL_3,
|
|
57
60
|
icon: ButtonColor.YELLOW,
|
|
58
61
|
},
|
|
59
62
|
[MessageVariant.SENT]: {
|
|
60
63
|
background: COLORS.PRIMARY_YELLOW,
|
|
64
|
+
border: COLORS.PRIMARY_YELLOW,
|
|
61
65
|
icon: ButtonColor.YELLOW,
|
|
62
66
|
},
|
|
63
67
|
},
|
|
@@ -5,12 +5,14 @@ export type GetAlternativesPayload = {
|
|
|
5
5
|
assignmentClassGrade: number
|
|
6
6
|
} | null
|
|
7
7
|
|
|
8
|
+
export type AlternativesOptions = {
|
|
9
|
+
default: ChatAnswer[]
|
|
10
|
+
hints: ChatAnswer[]
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export type GetAlternativesResponse = {
|
|
9
14
|
chatAccess?: boolean
|
|
10
|
-
options:
|
|
11
|
-
default: ChatAnswer[]
|
|
12
|
-
hints: ChatAnswer[]
|
|
13
|
-
}
|
|
15
|
+
options: AlternativesOptions
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export type PostMessagePayload = {
|
|
@@ -38,7 +38,7 @@ export const ProblemSelectorButton = ({
|
|
|
38
38
|
disabled={locked}
|
|
39
39
|
icon={
|
|
40
40
|
locked ? (
|
|
41
|
-
<LockIcon color={customColorScheme[ButtonStates.DISABLED]?.color} size=
|
|
41
|
+
<LockIcon color={customColorScheme[ButtonStates.DISABLED]?.color} size={25} />
|
|
42
42
|
) : (
|
|
43
43
|
<Typography
|
|
44
44
|
variant="h3"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Give me another hint",
|
|
16
|
-
"giveHint": "
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"time.yearAgo": "year ago",
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
|
-
"anotherHint": "
|
|
16
|
-
"giveHint": "
|
|
15
|
+
"anotherHint": "I need a hint",
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Give me another hint",
|
|
16
|
-
"giveHint": "
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"time.yearsAgo": "years ago",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Give me another hint",
|
|
16
|
-
"giveHint": "
|
|
16
|
+
"giveHint": "I need a hint",
|
|
17
17
|
"answerAgain": "Answer again to get another hint!",
|
|
18
18
|
"errorMessage": "Something went wrong! Try again",
|
|
19
19
|
"howCanIHelp": "Hi! Do you want help?",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"time.yearsAgo": "år sedan",
|
|
14
14
|
"chat": {
|
|
15
15
|
"anotherHint": "Ge mig en ledtråd",
|
|
16
|
-
"giveHint": "Ge
|
|
16
|
+
"giveHint": "Ge ledtråd",
|
|
17
17
|
"answerAgain": "Svara igen för att få en till ledtråd!",
|
|
18
18
|
"errorMessage": "Något gick snett! Försök igen",
|
|
19
19
|
"howCanIHelp": "Hej! Hur kan jag hjälpa dig?",
|