@magmamath/students-features 1.2.1-rc.9 → 1.2.2-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/config/dataTestIDs.js +12 -0
- package/dist/commonjs/config/dataTestIDs.js.map +1 -0
- package/dist/commonjs/features/chatbot/components/Chat/Chat.js +2 -0
- package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +2 -0
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js +2 -0
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
- package/dist/commonjs/features/voice/constants.js +3 -13
- package/dist/commonjs/features/voice/constants.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecord.js +5 -19
- package/dist/commonjs/features/voice/recording/components/VoiceRecord.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +20 -71
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js +2 -2
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js +3 -3
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -1
- package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js +0 -5
- package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js.map +1 -1
- package/dist/commonjs/features/voice/types.js +0 -6
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/commonjs/index.js +8 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/config/dataTestIDs.js +9 -0
- package/dist/module/config/dataTestIDs.js.map +1 -0
- package/dist/module/features/chatbot/components/Chat/Chat.js +2 -0
- package/dist/module/features/chatbot/components/Chat/Chat.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +2 -0
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js +2 -0
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
- package/dist/module/features/voice/constants.js +2 -12
- package/dist/module/features/voice/constants.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecord.js +6 -20
- package/dist/module/features/voice/recording/components/VoiceRecord.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js +22 -73
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js +2 -2
- package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js +3 -3
- package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -1
- package/dist/module/features/voice/recording/model/VoiceRecord.model.js +0 -5
- package/dist/module/features/voice/recording/model/VoiceRecord.model.js.map +1 -1
- package/dist/module/features/voice/types.js +1 -5
- package/dist/module/features/voice/types.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/commonjs/config/dataTestIDs.d.ts +7 -0
- package/dist/typescript/commonjs/config/dataTestIDs.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/constants.d.ts +2 -12
- package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts +3 -1
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +1 -2
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts +1 -3
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts +0 -4
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/module/config/dataTestIDs.d.ts +7 -0
- package/dist/typescript/module/config/dataTestIDs.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/constants.d.ts +2 -12
- package/dist/typescript/module/features/voice/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts +3 -1
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +1 -2
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts +1 -3
- package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/types.d.ts +0 -4
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/dataTestIDs.ts +7 -0
- package/src/features/chatbot/components/Chat/Chat.tsx +2 -1
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +2 -0
- package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +2 -0
- package/src/features/voice/constants.ts +2 -13
- package/src/features/voice/recording/components/VoiceRecord.tsx +5 -28
- package/src/features/voice/recording/components/VoiceRecordButton.tsx +30 -99
- package/src/features/voice/recording/components/VoiceRecordDeleteButton.tsx +2 -2
- package/src/features/voice/recording/hooks/useVoiceRecorderAnimation.ts +4 -8
- package/src/features/voice/recording/model/VoiceRecord.model.ts +0 -7
- package/src/features/voice/types.ts +0 -5
- package/src/index.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StyleProp, ViewStyle, StyleSheet } from 'react-native'
|
|
2
2
|
import { VoiceRecordButton } from './VoiceRecordButton'
|
|
3
3
|
import React, { useEffect } from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import { COLORS, SPACING } from '@magmamath/react-native-ui'
|
|
5
5
|
import { VoiceRecordDeleteButton } from './VoiceRecordDeleteButton'
|
|
6
6
|
import { VoiceRecordDivider } from './VoiceRecordDivider'
|
|
7
7
|
import { VoiceRecordTimer } from './VoiceRecordTimer'
|
|
@@ -10,8 +10,6 @@ import { VoiceRecordModel } from '../model/VoiceRecord.model'
|
|
|
10
10
|
import { useVoiceRecorder } from '../hooks/useVoiceRecorder'
|
|
11
11
|
import { useVoiceRecorderAnimation } from '../hooks/useVoiceRecorderAnimation'
|
|
12
12
|
import { useUnit } from 'effector-react'
|
|
13
|
-
import { RecordButtonVariant } from '../../types'
|
|
14
|
-
import { VOICE_RECORD_SHAWODS } from '../../constants'
|
|
15
13
|
|
|
16
14
|
type VoiceRecordProps = {
|
|
17
15
|
style?: StyleProp<ViewStyle>
|
|
@@ -22,8 +20,7 @@ export const VoiceRecord = ({ style, model }: VoiceRecordProps) => {
|
|
|
22
20
|
const { recorderState } = useVoiceRecorder(model)
|
|
23
21
|
const [isExpanded, isDisabled] = useUnit([model.$isExpanded, model.$isButtonDisabled])
|
|
24
22
|
|
|
25
|
-
const
|
|
26
|
-
const { containerAnimatedStyle } = useVoiceRecorderAnimation(isExpanded, recordButtonVariant)
|
|
23
|
+
const { containerAnimatedStyle } = useVoiceRecorderAnimation(isExpanded)
|
|
27
24
|
|
|
28
25
|
useEffect(() => {
|
|
29
26
|
return () => {
|
|
@@ -32,23 +29,12 @@ export const VoiceRecord = ({ style, model }: VoiceRecordProps) => {
|
|
|
32
29
|
}, [model])
|
|
33
30
|
|
|
34
31
|
return (
|
|
35
|
-
<Animated.View
|
|
36
|
-
style={[
|
|
37
|
-
styles.container,
|
|
38
|
-
recordButtonVariant === RecordButtonVariant.ADVANCED && styles.advancedVariantContainer,
|
|
39
|
-
{ boxShadow: VOICE_RECORD_SHAWODS[recordButtonVariant] },
|
|
40
|
-
style,
|
|
41
|
-
containerAnimatedStyle,
|
|
42
|
-
]}
|
|
43
|
-
>
|
|
32
|
+
<Animated.View style={[styles.container, style, containerAnimatedStyle]}>
|
|
44
33
|
<VoiceRecordButton model={model} />
|
|
45
34
|
{isExpanded && (
|
|
46
35
|
<Animated.View entering={FadeIn} exiting={FadeOut} style={styles.expendedContainer}>
|
|
47
36
|
<VoiceRecordTimer
|
|
48
|
-
style={
|
|
49
|
-
styles.timer,
|
|
50
|
-
recordButtonVariant === RecordButtonVariant.ADVANCED && styles.advancedVariantTimer,
|
|
51
|
-
]}
|
|
37
|
+
style={styles.timer}
|
|
52
38
|
model={model}
|
|
53
39
|
recordingFileDurationMs={recorderState.durationMillis}
|
|
54
40
|
/>
|
|
@@ -67,21 +53,12 @@ const styles = StyleSheet.create({
|
|
|
67
53
|
paddingBottom: 6,
|
|
68
54
|
backgroundColor: COLORS.NEUTRAL_3,
|
|
69
55
|
borderRadius: 32,
|
|
70
|
-
|
|
71
|
-
advancedVariantContainer: {
|
|
72
|
-
borderRadius: BORDER_RADIUS[300],
|
|
73
|
-
padding: 0,
|
|
56
|
+
boxShadow: '0 1px 3px 0 rgba(51, 51, 51, 0.10), 0 0 1px 0 rgba(51, 51, 51, 0.40)',
|
|
74
57
|
overflow: 'hidden',
|
|
75
58
|
},
|
|
76
59
|
timer: {
|
|
77
60
|
marginTop: SPACING[400],
|
|
78
61
|
},
|
|
79
|
-
defaultTimer: {
|
|
80
|
-
marginTop: SPACING[300],
|
|
81
|
-
},
|
|
82
|
-
advancedVariantTimer: {
|
|
83
|
-
marginTop: SPACING[150],
|
|
84
|
-
},
|
|
85
62
|
expendedContainer: {
|
|
86
63
|
alignItems: 'center',
|
|
87
64
|
},
|
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
BORDER_RADIUS,
|
|
4
3
|
Button,
|
|
5
4
|
ButtonColor,
|
|
6
5
|
ButtonSize,
|
|
7
6
|
ButtonStyle,
|
|
8
7
|
ButtonVariant,
|
|
9
|
-
CheckIcon,
|
|
10
|
-
COLORS,
|
|
11
8
|
IS_WEB,
|
|
12
|
-
MicrophoneIcon,
|
|
13
9
|
} from '@magmamath/react-native-ui'
|
|
14
|
-
import { Pressable
|
|
10
|
+
import { Pressable } from 'react-native'
|
|
11
|
+
import { MicrophoneIcon, CheckIcon } from '@magmamath/react-native-ui'
|
|
15
12
|
import { VoiceRecordModel } from '../model/VoiceRecord.model'
|
|
16
13
|
import { useUnit } from 'effector-react'
|
|
17
|
-
import {
|
|
14
|
+
import { VoiceRecorderState } from '../../constants'
|
|
18
15
|
import { useText } from '../../../../shared/translation'
|
|
19
|
-
import { RecordButtonVariant } from '../../types'
|
|
20
16
|
|
|
21
17
|
type VoiceRecordButtonProps = {
|
|
18
|
+
style?: ButtonStyle
|
|
22
19
|
model: VoiceRecordModel
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
const
|
|
26
|
-
button: {
|
|
27
|
-
width: 50,
|
|
28
|
-
height: 50,
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const VoiceRecordButton = ({ model }: VoiceRecordButtonProps) => {
|
|
22
|
+
export const VoiceRecordButton = ({ style, model }: VoiceRecordButtonProps) => {
|
|
33
23
|
const t = useText()
|
|
34
24
|
|
|
35
25
|
const availableInputs = useUnit(model.recorderModel.$availableInputs)
|
|
@@ -37,97 +27,38 @@ export const VoiceRecordButton = ({ model }: VoiceRecordButtonProps) => {
|
|
|
37
27
|
const isButtonDisabled = useUnit(model.$isButtonDisabled)
|
|
38
28
|
const isInitializing = useUnit(model.initializeRecording.pending)
|
|
39
29
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
const combinedStyles = useMemo((): ButtonStyle => {
|
|
31
|
+
return {
|
|
32
|
+
button: [{ width: 50, height: 50 }, style?.button],
|
|
33
|
+
container: [style?.container],
|
|
34
|
+
text: [style?.text],
|
|
35
|
+
}
|
|
36
|
+
}, [style])
|
|
43
37
|
|
|
44
38
|
return (
|
|
45
39
|
<Pressable
|
|
46
40
|
onPressIn={(e) => {
|
|
47
|
-
if (
|
|
41
|
+
if (availableInputs.length) return
|
|
48
42
|
e.preventDefault()
|
|
49
43
|
model.notification.warning(t('voice.noMicrophoneFound'))
|
|
50
44
|
}}
|
|
51
|
-
pointerEvents={!
|
|
52
|
-
style={[isButtonDisabled ? styles.disabledCursor : undefined]}
|
|
45
|
+
pointerEvents={!availableInputs.length || isInitializing ? 'box-only' : 'auto'}
|
|
53
46
|
>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
icon={
|
|
70
|
-
isRecording ? (
|
|
71
|
-
<CheckIcon size={25} />
|
|
72
|
-
) : (
|
|
73
|
-
<MicrophoneIcon style={IS_WEB ? { width: 19 } : { minWidth: 23, minHeight: 23 }} />
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
/>
|
|
77
|
-
)}
|
|
47
|
+
<Button
|
|
48
|
+
disabled={isButtonDisabled || !availableInputs.length}
|
|
49
|
+
onPressIn={() => model.recorderButtonHandler()}
|
|
50
|
+
style={combinedStyles}
|
|
51
|
+
size={ButtonSize.LARGE}
|
|
52
|
+
variant={ButtonVariant.SECONDARY}
|
|
53
|
+
colorScheme={ButtonColor.WHITE}
|
|
54
|
+
icon={
|
|
55
|
+
voiceRecordState === VoiceRecorderState.RECORDING ? (
|
|
56
|
+
<CheckIcon size={25} />
|
|
57
|
+
) : (
|
|
58
|
+
<MicrophoneIcon style={IS_WEB ? { width: 19 } : { minWidth: 23, minHeight: 23 }} />
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
/>
|
|
78
62
|
</Pressable>
|
|
79
63
|
)
|
|
80
64
|
}
|
|
81
|
-
|
|
82
|
-
type AdvancedButtonProps = {
|
|
83
|
-
isRecording: boolean
|
|
84
|
-
isIdle: boolean
|
|
85
|
-
disabled: boolean
|
|
86
|
-
onPressIn: () => void
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const AdvancedButton = ({ isRecording, isIdle, disabled, onPressIn }: AdvancedButtonProps) => (
|
|
90
|
-
<Pressable
|
|
91
|
-
style={[styles.advancedButtonContainer, disabled && styles.disabledCursor]}
|
|
92
|
-
onPressIn={onPressIn}
|
|
93
|
-
disabled={disabled}
|
|
94
|
-
>
|
|
95
|
-
<View
|
|
96
|
-
style={[
|
|
97
|
-
styles.advancedIconContainer,
|
|
98
|
-
!isIdle && { borderRadius: 32, backgroundColor: COLORS.PRIMARY_BLUE },
|
|
99
|
-
]}
|
|
100
|
-
>
|
|
101
|
-
{isRecording ? (
|
|
102
|
-
<CheckIcon size={18} color={COLORS.NEUTRAL_1} />
|
|
103
|
-
) : (
|
|
104
|
-
<MicrophoneIcon
|
|
105
|
-
style={{ width: 14, height: 19 }}
|
|
106
|
-
color={disabled ? COLORS.NEUTRAL_5 : isIdle ? COLORS.NEUTRAL_9 : COLORS.NEUTRAL_1}
|
|
107
|
-
/>
|
|
108
|
-
)}
|
|
109
|
-
</View>
|
|
110
|
-
</Pressable>
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
const styles = StyleSheet.create({
|
|
114
|
-
advancedButtonContainer: {
|
|
115
|
-
width: 52,
|
|
116
|
-
height: 52,
|
|
117
|
-
backgroundColor: 'white',
|
|
118
|
-
alignItems: 'center',
|
|
119
|
-
justifyContent: 'center',
|
|
120
|
-
borderRadius: BORDER_RADIUS[300],
|
|
121
|
-
boxShadow: VOICE_RECORD_SHAWODS[RecordButtonVariant.ADVANCED],
|
|
122
|
-
},
|
|
123
|
-
advancedIconContainer: {
|
|
124
|
-
width: 36,
|
|
125
|
-
height: 36,
|
|
126
|
-
borderRadius: BORDER_RADIUS[300],
|
|
127
|
-
justifyContent: 'center',
|
|
128
|
-
alignItems: 'center',
|
|
129
|
-
},
|
|
130
|
-
disabledCursor: {
|
|
131
|
-
cursor: 'not-allowed' as 'auto',
|
|
132
|
-
},
|
|
133
|
-
})
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { useAnimatedStyle, withTiming } from 'react-native-reanimated'
|
|
2
2
|
import { VOICE_RECORDER_CONTAINER_SIZES } from '../../constants'
|
|
3
|
-
import { RecordButtonVariant } from '../../types'
|
|
4
3
|
|
|
5
|
-
export const useVoiceRecorderAnimation = (
|
|
6
|
-
isExpanded: boolean,
|
|
7
|
-
recordButtonVariant: RecordButtonVariant,
|
|
8
|
-
) => {
|
|
4
|
+
export const useVoiceRecorderAnimation = (isExpanded: boolean) => {
|
|
9
5
|
const containerAnimatedStyle = useAnimatedStyle(() => {
|
|
10
6
|
return {
|
|
11
7
|
height: withTiming(
|
|
12
8
|
isExpanded
|
|
13
|
-
? VOICE_RECORDER_CONTAINER_SIZES.EXPANDED
|
|
14
|
-
: VOICE_RECORDER_CONTAINER_SIZES.COLLAPSED
|
|
9
|
+
? VOICE_RECORDER_CONTAINER_SIZES.EXPANDED
|
|
10
|
+
: VOICE_RECORDER_CONTAINER_SIZES.COLLAPSED,
|
|
15
11
|
{
|
|
16
12
|
duration: 280,
|
|
17
13
|
},
|
|
18
14
|
),
|
|
19
15
|
}
|
|
20
|
-
}, [isExpanded
|
|
16
|
+
}, [isExpanded])
|
|
21
17
|
|
|
22
18
|
return { containerAnimatedStyle }
|
|
23
19
|
}
|
|
@@ -4,7 +4,6 @@ import { VoiceRecordsCollection } from './VoiceRecordCollection'
|
|
|
4
4
|
import { UploaderModel } from './Uploader.model'
|
|
5
5
|
import { VoiceRecorderState } from '../../constants'
|
|
6
6
|
import {
|
|
7
|
-
RecordButtonVariant,
|
|
8
7
|
VoiceRecordCollectionItem,
|
|
9
8
|
VoiceRecorderApi,
|
|
10
9
|
VoiceRecordNotificationTypes,
|
|
@@ -59,8 +58,6 @@ export class VoiceRecordModel {
|
|
|
59
58
|
public readonly events: VoiceRecordEvents
|
|
60
59
|
private shouldDiscardRecording = false
|
|
61
60
|
|
|
62
|
-
public recordButtonVariant = RecordButtonVariant.DEFAULT
|
|
63
|
-
|
|
64
61
|
public readonly setCurrentKey = createEvent<string>()
|
|
65
62
|
public readonly setCurrentRecord = createEvent<any>()
|
|
66
63
|
public readonly reset = createEvent()
|
|
@@ -85,10 +82,6 @@ export class VoiceRecordModel {
|
|
|
85
82
|
await this.api.deleteAudioFile(audioFileId)
|
|
86
83
|
})
|
|
87
84
|
|
|
88
|
-
public readonly setRecordButtonVariant = createEffect((variant: RecordButtonVariant) => {
|
|
89
|
-
this.recordButtonVariant = variant
|
|
90
|
-
})
|
|
91
|
-
|
|
92
85
|
public readonly deleteCurrentRecording = attach({
|
|
93
86
|
source: this.$currentKey,
|
|
94
87
|
mapParams: (props: DeleteCurrentRecordingProps | void, currentKey) => ({
|
package/src/index.ts
CHANGED