@magmamath/students-features 0.6.7-rc.1 → 0.6.7-rc.2
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/endOfAssignment/components/Modal/Modal.js +1 -0
- package/dist/commonjs/features/endOfAssignment/components/Modal/Modal.js.map +1 -1
- package/dist/commonjs/index.js +0 -12
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/lib/effector/createControllerEffect.js.map +1 -1
- package/dist/commonjs/lib/helpers/helpers.js.map +1 -1
- package/dist/commonjs/shared/translation/localization/en.json +0 -5
- package/dist/commonjs/shared/translation/localization/gb.json +0 -5
- package/dist/commonjs/shared/translation/localization/sw.json +0 -5
- package/dist/module/features/endOfAssignment/components/Modal/Modal.js +2 -1
- package/dist/module/features/endOfAssignment/components/Modal/Modal.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/effector/createControllerEffect.js.map +1 -1
- package/dist/module/shared/translation/localization/en.json +0 -5
- package/dist/module/shared/translation/localization/gb.json +0 -5
- package/dist/module/shared/translation/localization/sw.json +0 -5
- package/dist/typescript/commonjs/features/endOfAssignment/components/Modal/Modal.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +0 -1
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/effector/createControllerEffect.d.ts +1 -1
- package/dist/typescript/commonjs/lib/effector/createControllerEffect.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/helpers/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +0 -15
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/model.d.ts +0 -10
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/module/features/endOfAssignment/components/Modal/Modal.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +0 -1
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/lib/effector/createControllerEffect.d.ts +1 -1
- package/dist/typescript/module/lib/effector/createControllerEffect.d.ts.map +1 -1
- package/dist/typescript/module/lib/helpers/helpers.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/constants.d.ts +0 -15
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/model.d.ts +0 -10
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/features/endOfAssignment/components/Modal/Modal.tsx +2 -1
- package/src/index.ts +0 -1
- package/src/lib/effector/createControllerEffect.ts +41 -41
- package/src/lib/helpers/helpers.ts +1 -1
- package/src/shared/translation/localization/en.json +0 -5
- package/src/shared/translation/localization/gb.json +0 -5
- package/src/shared/translation/localization/sw.json +0 -5
- package/dist/commonjs/features/gifCelebrations/GifCelebrations.js +0 -62
- package/dist/commonjs/features/gifCelebrations/GifCelebrations.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/assets/confetti.webp +0 -0
- package/dist/commonjs/features/gifCelebrations/assets/gifFallback.gif +0 -0
- package/dist/commonjs/features/gifCelebrations/components/Backdrop.js +0 -44
- package/dist/commonjs/features/gifCelebrations/components/Backdrop.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/components/ContentContainer.js +0 -46
- package/dist/commonjs/features/gifCelebrations/components/ContentContainer.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/components/Gif.js +0 -91
- package/dist/commonjs/features/gifCelebrations/components/Gif.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/components/Progress.js +0 -96
- package/dist/commonjs/features/gifCelebrations/components/Progress.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/constants.js +0 -34
- package/dist/commonjs/features/gifCelebrations/constants.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/helpers.js +0 -114
- package/dist/commonjs/features/gifCelebrations/helpers.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/index.js +0 -20
- package/dist/commonjs/features/gifCelebrations/index.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js +0 -38
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js +0 -150
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrationsApi.js +0 -14
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrationsApi.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/types/model.types.js +0 -6
- package/dist/commonjs/features/gifCelebrations/types/model.types.js.map +0 -1
- package/dist/commonjs/react-app-env.d.js +0 -2
- package/dist/commonjs/react-app-env.d.js.map +0 -1
- package/dist/commonjs/shared/constants.js +0 -9
- package/dist/commonjs/shared/constants.js.map +0 -1
- package/dist/commonjs/types/common.types.js +0 -2
- package/dist/commonjs/types/common.types.js.map +0 -1
- package/dist/module/features/gifCelebrations/GifCelebrations.js +0 -55
- package/dist/module/features/gifCelebrations/GifCelebrations.js.map +0 -1
- package/dist/module/features/gifCelebrations/assets/confetti.webp +0 -0
- package/dist/module/features/gifCelebrations/assets/gifFallback.gif +0 -0
- package/dist/module/features/gifCelebrations/components/Backdrop.js +0 -36
- package/dist/module/features/gifCelebrations/components/Backdrop.js.map +0 -1
- package/dist/module/features/gifCelebrations/components/ContentContainer.js +0 -38
- package/dist/module/features/gifCelebrations/components/ContentContainer.js.map +0 -1
- package/dist/module/features/gifCelebrations/components/Gif.js +0 -83
- package/dist/module/features/gifCelebrations/components/Gif.js.map +0 -1
- package/dist/module/features/gifCelebrations/components/Progress.js +0 -88
- package/dist/module/features/gifCelebrations/components/Progress.js.map +0 -1
- package/dist/module/features/gifCelebrations/constants.js +0 -30
- package/dist/module/features/gifCelebrations/constants.js.map +0 -1
- package/dist/module/features/gifCelebrations/helpers.js +0 -103
- package/dist/module/features/gifCelebrations/helpers.js.map +0 -1
- package/dist/module/features/gifCelebrations/index.js +0 -5
- package/dist/module/features/gifCelebrations/index.js.map +0 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js +0 -33
- package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js.map +0 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js +0 -145
- package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js.map +0 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrationsApi.js +0 -9
- package/dist/module/features/gifCelebrations/model/GifCelebrationsApi.js.map +0 -1
- package/dist/module/features/gifCelebrations/types/model.types.js +0 -4
- package/dist/module/features/gifCelebrations/types/model.types.js.map +0 -1
- package/dist/module/react-app-env.d.js +0 -2
- package/dist/module/react-app-env.d.js.map +0 -1
- package/dist/module/shared/constants.js +0 -5
- package/dist/module/shared/constants.js.map +0 -1
- package/dist/module/types/common.types.js +0 -2
- package/dist/module/types/common.types.js.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/GifCelebrations.d.ts +0 -10
- package/dist/typescript/commonjs/features/gifCelebrations/GifCelebrations.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Backdrop.d.ts +0 -10
- package/dist/typescript/commonjs/features/gifCelebrations/components/Backdrop.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/ContentContainer.d.ts +0 -10
- package/dist/typescript/commonjs/features/gifCelebrations/components/ContentContainer.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts +0 -10
- package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Progress.d.ts +0 -10
- package/dist/typescript/commonjs/features/gifCelebrations/components/Progress.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts +0 -26
- package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts +0 -29
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/index.d.ts +0 -3
- package/dist/typescript/commonjs/features/gifCelebrations/index.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts +0 -19
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts +0 -26
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrationsApi.d.ts +0 -6
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrationsApi.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts +0 -45
- package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts.map +0 -1
- package/dist/typescript/commonjs/shared/constants.d.ts +0 -2
- package/dist/typescript/commonjs/shared/constants.d.ts.map +0 -1
- package/dist/typescript/commonjs/types/common.types.d.ts +0 -5
- package/dist/typescript/commonjs/types/common.types.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/GifCelebrations.d.ts +0 -10
- package/dist/typescript/module/features/gifCelebrations/GifCelebrations.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/components/Backdrop.d.ts +0 -10
- package/dist/typescript/module/features/gifCelebrations/components/Backdrop.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/components/ContentContainer.d.ts +0 -10
- package/dist/typescript/module/features/gifCelebrations/components/ContentContainer.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts +0 -10
- package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/components/Progress.d.ts +0 -10
- package/dist/typescript/module/features/gifCelebrations/components/Progress.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/constants.d.ts +0 -26
- package/dist/typescript/module/features/gifCelebrations/constants.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts +0 -29
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/index.d.ts +0 -3
- package/dist/typescript/module/features/gifCelebrations/index.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts +0 -19
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts +0 -26
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrationsApi.d.ts +0 -6
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrationsApi.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts +0 -45
- package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts.map +0 -1
- package/dist/typescript/module/shared/constants.d.ts +0 -2
- package/dist/typescript/module/shared/constants.d.ts.map +0 -1
- package/dist/typescript/module/types/common.types.d.ts +0 -5
- package/dist/typescript/module/types/common.types.d.ts.map +0 -1
- package/src/features/gifCelebrations/GifCelebrations.tsx +0 -75
- package/src/features/gifCelebrations/assets/confetti.webp +0 -0
- package/src/features/gifCelebrations/assets/gifFallback.gif +0 -0
- package/src/features/gifCelebrations/components/Backdrop.tsx +0 -41
- package/src/features/gifCelebrations/components/ContentContainer.tsx +0 -44
- package/src/features/gifCelebrations/components/Gif.tsx +0 -89
- package/src/features/gifCelebrations/components/Progress.tsx +0 -106
- package/src/features/gifCelebrations/constants.ts +0 -32
- package/src/features/gifCelebrations/helpers.ts +0 -144
- package/src/features/gifCelebrations/index.ts +0 -2
- package/src/features/gifCelebrations/model/GifCelebrations.cache.ts +0 -51
- package/src/features/gifCelebrations/model/GifCelebrations.model.ts +0 -192
- package/src/features/gifCelebrations/model/GifCelebrationsApi.ts +0 -10
- package/src/features/gifCelebrations/types/model.types.ts +0 -53
- package/src/react-app-env.d.ts +0 -6
- package/src/shared/constants.ts +0 -3
- package/src/types/common.types.ts +0 -4
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import { Gif } from './components/Gif'
|
|
3
|
-
import { Progress } from './components/Progress'
|
|
4
|
-
import { ContentContainer } from './components/ContentContainer'
|
|
5
|
-
import { Backdrop } from './components/Backdrop'
|
|
6
|
-
import { Easing, runOnJS, useSharedValue, withSequence, withTiming } from 'react-native-reanimated'
|
|
7
|
-
import { useUnit } from 'effector-react'
|
|
8
|
-
import { ANIMATION_DURATION } from './constants'
|
|
9
|
-
import { GifCelebrationsModel } from './model/GifCelebrations.model'
|
|
10
|
-
import { ProgressValue, TextComponentType } from './types/model.types'
|
|
11
|
-
|
|
12
|
-
type GifCelebrationsProps = {
|
|
13
|
-
model: GifCelebrationsModel
|
|
14
|
-
TextComponent: TextComponentType
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const GifCelebrations = ({ model, TextComponent }: GifCelebrationsProps) => {
|
|
18
|
-
const [problemsAmount, resolvedProblemsAmount, activeGif] = useUnit([
|
|
19
|
-
model.$problemsAmount,
|
|
20
|
-
model.$resolvedProblemsAmount,
|
|
21
|
-
model.$activeGif,
|
|
22
|
-
])
|
|
23
|
-
|
|
24
|
-
const completedPercent =
|
|
25
|
-
resolvedProblemsAmount &&
|
|
26
|
-
problemsAmount &&
|
|
27
|
-
Math.round((resolvedProblemsAmount / problemsAmount) * 100)
|
|
28
|
-
|
|
29
|
-
const progress = useSharedValue<ProgressValue>(0)
|
|
30
|
-
|
|
31
|
-
const stopAnimation = () => {
|
|
32
|
-
model.stop()
|
|
33
|
-
progress.value = 0
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const playAnimation = () => {
|
|
37
|
-
progress.value = withSequence(
|
|
38
|
-
withTiming(1, {
|
|
39
|
-
duration: ANIMATION_DURATION,
|
|
40
|
-
easing: Easing.bezier(0.52, 0.16, 0.26, 0.77),
|
|
41
|
-
}),
|
|
42
|
-
withTiming(
|
|
43
|
-
2,
|
|
44
|
-
{
|
|
45
|
-
duration: ANIMATION_DURATION,
|
|
46
|
-
easing: Easing.bezier(0.71, 0.09, 0.49, 0.89),
|
|
47
|
-
},
|
|
48
|
-
() => runOnJS(stopAnimation)(),
|
|
49
|
-
),
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (activeGif) {
|
|
55
|
-
playAnimation()
|
|
56
|
-
}
|
|
57
|
-
}, [activeGif])
|
|
58
|
-
|
|
59
|
-
if (!activeGif) {
|
|
60
|
-
return null
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Backdrop progress={progress}>
|
|
65
|
-
<ContentContainer progress={progress}>
|
|
66
|
-
<Gif
|
|
67
|
-
gifObject={activeGif}
|
|
68
|
-
getCachePathMethod={model.cache.getCachePathMethod}
|
|
69
|
-
TextComponent={TextComponent}
|
|
70
|
-
/>
|
|
71
|
-
<Progress progress={progress} completedPercent={completedPercent} />
|
|
72
|
-
</ContentContainer>
|
|
73
|
-
</Backdrop>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, useWindowDimensions } from 'react-native'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import Animated, { useAnimatedStyle, interpolateColor, SharedValue } from 'react-native-reanimated'
|
|
4
|
-
import { BACKDROP_COLOR } from '../constants'
|
|
5
|
-
import { ProgressValue } from '../types/model.types'
|
|
6
|
-
|
|
7
|
-
type BackdropProps = {
|
|
8
|
-
children: React.ReactNode
|
|
9
|
-
progress: SharedValue<ProgressValue>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Backdrop = ({ children, progress }: BackdropProps) => {
|
|
13
|
-
const { width, height } = useWindowDimensions()
|
|
14
|
-
|
|
15
|
-
const backdropAnimatedStyle = useAnimatedStyle(
|
|
16
|
-
() => ({
|
|
17
|
-
backgroundColor: interpolateColor(
|
|
18
|
-
progress.value,
|
|
19
|
-
[0, 1, 2],
|
|
20
|
-
[BACKDROP_COLOR.INITIAL, BACKDROP_COLOR.FINAL, BACKDROP_COLOR.INITIAL],
|
|
21
|
-
),
|
|
22
|
-
}),
|
|
23
|
-
[progress],
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Animated.View style={[styles.backdrop, { width, height }, backdropAnimatedStyle]}>
|
|
28
|
-
{children}
|
|
29
|
-
</Animated.View>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const styles = StyleSheet.create({
|
|
34
|
-
backdrop: {
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
zIndex: 10100,
|
|
37
|
-
justifyContent: 'center',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
backgroundColor: 'rgba(51, 51, 51, 0.33);',
|
|
40
|
-
},
|
|
41
|
-
})
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, useWindowDimensions } from 'react-native'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { SPACING } from '@magmamath/react-native-ui'
|
|
4
|
-
import Animated, { useAnimatedStyle, interpolate, SharedValue } from 'react-native-reanimated'
|
|
5
|
-
import { CONTENT_CONTAINER } from '../constants'
|
|
6
|
-
import { ProgressValue } from '../types/model.types'
|
|
7
|
-
|
|
8
|
-
type ContentContainerProps = {
|
|
9
|
-
children: React.ReactNode
|
|
10
|
-
progress: SharedValue<ProgressValue>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const ContentContainer = ({ children, progress }: ContentContainerProps) => {
|
|
14
|
-
const { width } = useWindowDimensions()
|
|
15
|
-
|
|
16
|
-
const RIGHT_POSITION =
|
|
17
|
-
width / 2 + CONTENT_CONTAINER.CONTAINER_WIDTH / 2 + CONTENT_CONTAINER.ROTATION_PADDING
|
|
18
|
-
const LEFT_POSITION = -RIGHT_POSITION - CONTENT_CONTAINER.ROTATION_PADDING
|
|
19
|
-
|
|
20
|
-
const animatedStyles = useAnimatedStyle(
|
|
21
|
-
() => ({
|
|
22
|
-
transform: [
|
|
23
|
-
{
|
|
24
|
-
translateX: interpolate(progress.value, [0, 1, 2], [LEFT_POSITION, 0, RIGHT_POSITION]),
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
rotate: `${interpolate(progress.value, [0, 1, 2], [-CONTENT_CONTAINER.ANGLE, 0, CONTENT_CONTAINER.ANGLE])}deg`,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
}),
|
|
31
|
-
[progress, RIGHT_POSITION, LEFT_POSITION],
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
return <Animated.View style={[styles.container, animatedStyles]}>{children}</Animated.View>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const styles = StyleSheet.create({
|
|
38
|
-
container: {
|
|
39
|
-
width: CONTENT_CONTAINER.CONTAINER_WIDTH,
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
gap: SPACING[800],
|
|
42
|
-
position: 'absolute',
|
|
43
|
-
},
|
|
44
|
-
})
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, View, Image } from 'react-native'
|
|
2
|
-
import React, { useLayoutEffect, useState } from 'react'
|
|
3
|
-
import { BORDER_RADIUS, COLORS, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
-
import { CustomGetCachePathMethod, GifObject, TextComponentType } from '../types/model.types'
|
|
5
|
-
import { MAX_GIF_SIZE, MIN_GIF_SIZE } from '../constants'
|
|
6
|
-
import { useText } from '../../../shared/translation'
|
|
7
|
-
import { constrainDimension, getGifLabel, getImagePath } from '../helpers'
|
|
8
|
-
import gifFallback from '../assets/gifFallback.gif'
|
|
9
|
-
import { IS_WEB } from '../../../shared/constants'
|
|
10
|
-
import { Size } from '../../../types/common.types'
|
|
11
|
-
|
|
12
|
-
type GifProps = {
|
|
13
|
-
gifObject: GifObject
|
|
14
|
-
getCachePathMethod?: CustomGetCachePathMethod //it is used for RN
|
|
15
|
-
TextComponent: TextComponentType
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Gif = ({ gifObject, getCachePathMethod, TextComponent }: GifProps) => {
|
|
19
|
-
const [size, setSize] = useState<Size | null>(null)
|
|
20
|
-
const [pathOrUri, setPathOrUri] = useState('')
|
|
21
|
-
|
|
22
|
-
const t = useText()
|
|
23
|
-
|
|
24
|
-
const gifGroupNumber = Number(gifObject.group.replace('group', ''))
|
|
25
|
-
const gifLabel = getGifLabel(gifGroupNumber)
|
|
26
|
-
|
|
27
|
-
useLayoutEffect(() => {
|
|
28
|
-
const loadImageSize = async () => {
|
|
29
|
-
let localPath
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
localPath = await getImagePath(gifObject.url, getCachePathMethod)
|
|
33
|
-
} catch (error) {
|
|
34
|
-
localPath = IS_WEB ? gifFallback : Image.resolveAssetSource(gifFallback).uri
|
|
35
|
-
console.error('Error fetching image from cache:', error)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Image.getSize(localPath, (width, height) => {
|
|
39
|
-
setSize({
|
|
40
|
-
width: constrainDimension(width, MIN_GIF_SIZE, MAX_GIF_SIZE.WIDTH),
|
|
41
|
-
height: constrainDimension(height, MIN_GIF_SIZE, MAX_GIF_SIZE.HEIGHT),
|
|
42
|
-
})
|
|
43
|
-
setPathOrUri(localPath)
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
loadImageSize()
|
|
48
|
-
}, [gifObject.url])
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<View style={styles.backgroundContainer}>
|
|
52
|
-
<View style={styles.container}>
|
|
53
|
-
{size && pathOrUri && (
|
|
54
|
-
<Image
|
|
55
|
-
alt="Funny celebration animated image"
|
|
56
|
-
source={{
|
|
57
|
-
uri: pathOrUri,
|
|
58
|
-
}}
|
|
59
|
-
width={size.width}
|
|
60
|
-
height={size.height}
|
|
61
|
-
style={[styles.image, { width: size.width, height: size.height }]} //this sizes duplication is needed for compatibility with web and rn
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
<View style={styles.textContainer}>{TextComponent(t(gifLabel))}</View>
|
|
65
|
-
</View>
|
|
66
|
-
</View>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const styles = StyleSheet.create({
|
|
71
|
-
backgroundContainer: {
|
|
72
|
-
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
73
|
-
borderRadius: 23,
|
|
74
|
-
padding: SPACING[200],
|
|
75
|
-
},
|
|
76
|
-
container: {
|
|
77
|
-
padding: SPACING[1600],
|
|
78
|
-
borderRadius: BORDER_RADIUS[400],
|
|
79
|
-
backgroundColor: COLORS.NEUTRAL_1,
|
|
80
|
-
},
|
|
81
|
-
image: {
|
|
82
|
-
borderRadius: BORDER_RADIUS[100],
|
|
83
|
-
},
|
|
84
|
-
textContainer: {
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
bottom: 74,
|
|
87
|
-
alignSelf: 'center',
|
|
88
|
-
},
|
|
89
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, View, Image } from 'react-native'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import {
|
|
4
|
-
BORDER_RADIUS,
|
|
5
|
-
COLORS,
|
|
6
|
-
HeadingVariants,
|
|
7
|
-
IS_WEB,
|
|
8
|
-
SPACING,
|
|
9
|
-
Typography,
|
|
10
|
-
} from '@magmamath/react-native-ui'
|
|
11
|
-
import Animated, { useAnimatedStyle, SharedValue, interpolate } from 'react-native-reanimated'
|
|
12
|
-
import confettiImage from '../assets/confetti.webp'
|
|
13
|
-
import { ProgressValue } from '../types/model.types'
|
|
14
|
-
import { getProgressLineWidth } from '../helpers'
|
|
15
|
-
|
|
16
|
-
type ProgressProps = {
|
|
17
|
-
progress: SharedValue<ProgressValue>
|
|
18
|
-
completedPercent: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const Progress = ({ progress, completedPercent }: ProgressProps) => {
|
|
22
|
-
const progressLineWidth = getProgressLineWidth(completedPercent)
|
|
23
|
-
|
|
24
|
-
const animatedStyles = useAnimatedStyle(
|
|
25
|
-
() => ({
|
|
26
|
-
width: `${interpolate(
|
|
27
|
-
progress.value,
|
|
28
|
-
[0, 1, 2],
|
|
29
|
-
[0, progressLineWidth, progressLineWidth],
|
|
30
|
-
)}%`,
|
|
31
|
-
}),
|
|
32
|
-
[progress, progressLineWidth],
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<View style={styles.backgroundContainer}>
|
|
37
|
-
<View style={styles.container}>
|
|
38
|
-
<View style={styles.progressContainer}>
|
|
39
|
-
<Animated.View style={[styles.progress, animatedStyles]}>
|
|
40
|
-
<Typography variant={HeadingVariants.H1} style={styles.percent}>
|
|
41
|
-
{`${completedPercent}%`}
|
|
42
|
-
</Typography>
|
|
43
|
-
</Animated.View>
|
|
44
|
-
</View>
|
|
45
|
-
<Image
|
|
46
|
-
source={
|
|
47
|
-
IS_WEB
|
|
48
|
-
? {
|
|
49
|
-
uri: confettiImage,
|
|
50
|
-
}
|
|
51
|
-
: require('../assets/confetti.webp')
|
|
52
|
-
}
|
|
53
|
-
style={styles.confetti}
|
|
54
|
-
/>
|
|
55
|
-
</View>
|
|
56
|
-
</View>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const styles = StyleSheet.create({
|
|
61
|
-
backgroundContainer: {
|
|
62
|
-
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
63
|
-
borderRadius: 23,
|
|
64
|
-
padding: SPACING[200],
|
|
65
|
-
width: '100%',
|
|
66
|
-
},
|
|
67
|
-
container: {
|
|
68
|
-
width: '100%',
|
|
69
|
-
height: 116,
|
|
70
|
-
flexDirection: 'row',
|
|
71
|
-
alignItems: 'center',
|
|
72
|
-
borderRadius: BORDER_RADIUS[400],
|
|
73
|
-
backgroundColor: COLORS.NEUTRAL_1,
|
|
74
|
-
paddingLeft: SPACING[400],
|
|
75
|
-
paddingRight: SPACING[200],
|
|
76
|
-
gap: SPACING[100],
|
|
77
|
-
},
|
|
78
|
-
progressContainer: {
|
|
79
|
-
height: 50,
|
|
80
|
-
flexGrow: 1,
|
|
81
|
-
backgroundColor: COLORS.NEUTRAL_5,
|
|
82
|
-
borderRadius: 90,
|
|
83
|
-
overflow: 'hidden',
|
|
84
|
-
},
|
|
85
|
-
progress: {
|
|
86
|
-
position: 'absolute',
|
|
87
|
-
height: '100%',
|
|
88
|
-
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
89
|
-
borderRadius: BORDER_RADIUS[200],
|
|
90
|
-
justifyContent: 'center',
|
|
91
|
-
alignItems: 'flex-end',
|
|
92
|
-
paddingRight: 10.6,
|
|
93
|
-
overflow: 'hidden',
|
|
94
|
-
},
|
|
95
|
-
confetti: {
|
|
96
|
-
width: 75,
|
|
97
|
-
height: 70,
|
|
98
|
-
marginHorizontal: SPACING[200],
|
|
99
|
-
},
|
|
100
|
-
percent: {
|
|
101
|
-
position: 'absolute',
|
|
102
|
-
paddingRight: 10,
|
|
103
|
-
color: COLORS.NEUTRAL_1,
|
|
104
|
-
fontWeight: '700',
|
|
105
|
-
},
|
|
106
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const BACKDROP_COLOR = {
|
|
2
|
-
INITIAL: 'rgba(51, 51, 51, 0)',
|
|
3
|
-
FINAL: 'rgba(51, 51, 51, 0.66)',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const CONTENT_CONTAINER = {
|
|
7
|
-
ANGLE: 5,
|
|
8
|
-
CONTAINER_WIDTH: 769,
|
|
9
|
-
ROTATION_PADDING: 44, // to be sure that the content is not cut off on the edges because of rotate transform
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ANIMATION_DURATION = 1750
|
|
13
|
-
export const MIN_PROBLEMS_TO_SHOW_GIF = 7
|
|
14
|
-
|
|
15
|
-
export const MAX_GIF_SIZE = {
|
|
16
|
-
WIDTH: 480,
|
|
17
|
-
HEIGHT: 300,
|
|
18
|
-
}
|
|
19
|
-
export const MIN_GIF_SIZE = 300
|
|
20
|
-
|
|
21
|
-
export const GROUPS_PERCENTAGES = {
|
|
22
|
-
group1: [15, 20, 25, 30], // Early celebrations
|
|
23
|
-
group2: [33, 40, 45, 50], // Mid celebrations
|
|
24
|
-
group3: [60, 66, 75, 80], // Party
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const MIN_WIDTH_FOR_ONE_DIGIT = 12
|
|
28
|
-
export const MIN_WIDTH_FOR_TWO_DIGITS = 15
|
|
29
|
-
|
|
30
|
-
export const GET_GIFS_TIMEOUT = 5000
|
|
31
|
-
|
|
32
|
-
export const GIFS_FETCHED_KEY = 'gifsFetchedTimestamp'
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { TranslationKeys } from 'src/shared/translation/types'
|
|
2
|
-
import {
|
|
3
|
-
CustomGetCachePathMethod,
|
|
4
|
-
GifsGroups,
|
|
5
|
-
GifsStructure,
|
|
6
|
-
GroupNumber,
|
|
7
|
-
GroupNumberString,
|
|
8
|
-
ProblemsGifsTable,
|
|
9
|
-
} from './types/model.types'
|
|
10
|
-
import { MIN_WIDTH_FOR_ONE_DIGIT, MIN_WIDTH_FOR_TWO_DIGITS } from './constants'
|
|
11
|
-
import { Image } from 'react-native'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Number of problems When we show gif
|
|
15
|
-
* <6 Never
|
|
16
|
-
* 7-12 50% completion
|
|
17
|
-
* 13-18 33%, 66% completion
|
|
18
|
-
* 19-24 25%, 50%, 75 completion
|
|
19
|
-
* 25-30 20%, 40%, 60%, 80% completion
|
|
20
|
-
* .>30 15%, 30%, 45%, 60%, 75% completion
|
|
21
|
-
*
|
|
22
|
-
* We are also going to have different buckets with different gifs. The logic is as follows:
|
|
23
|
-
* Group 1: 15%, 20%, 25%, 30% - Early celebrations
|
|
24
|
-
* Group 2: 33%, 40%, 45%, 50% - Mid celebrations
|
|
25
|
-
* Group 3: 60%, 66%, 75%, 80% - Party
|
|
26
|
-
* or
|
|
27
|
-
* Group 1: <=30% - Early celebrations
|
|
28
|
-
* Group 2: >30% <60% - Mid celebrations
|
|
29
|
-
* Group 3: >=60% - Party
|
|
30
|
-
*/
|
|
31
|
-
export const generateProblemsGifsTable = (
|
|
32
|
-
problemsAmount: number,
|
|
33
|
-
resolvedProblems: number,
|
|
34
|
-
gifs: GifsStructure,
|
|
35
|
-
): ProblemsGifsTable => {
|
|
36
|
-
const percentageMilestones = getPercentageMilestones(problemsAmount)
|
|
37
|
-
|
|
38
|
-
const result: ProblemsGifsTable = {}
|
|
39
|
-
|
|
40
|
-
for (const percentage of percentageMilestones) {
|
|
41
|
-
const problemNumber = Math.ceil(problemsAmount * (percentage / 100))
|
|
42
|
-
|
|
43
|
-
if (problemNumber <= resolvedProblems) continue
|
|
44
|
-
|
|
45
|
-
const groupKey = findGroupForPercentage(percentage)
|
|
46
|
-
const gifsInGroup = gifs[groupKey]
|
|
47
|
-
|
|
48
|
-
if (!gifsInGroup || gifsInGroup.length === 0) continue
|
|
49
|
-
|
|
50
|
-
const unshownGif = gifsInGroup.find((gif) => !gif.isShown)
|
|
51
|
-
|
|
52
|
-
const selectedGif = unshownGif || gifsInGroup[0]
|
|
53
|
-
|
|
54
|
-
if (selectedGif) {
|
|
55
|
-
result[problemNumber] = {
|
|
56
|
-
url: selectedGif.url,
|
|
57
|
-
group: groupKey,
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return result
|
|
63
|
-
}
|
|
64
|
-
const getPercentageMilestones = (problemsAmount: number): number[] => {
|
|
65
|
-
if (problemsAmount <= 12) return [50]
|
|
66
|
-
|
|
67
|
-
if (problemsAmount <= 18) return [33, 66]
|
|
68
|
-
|
|
69
|
-
if (problemsAmount <= 24) return [25, 50, 75]
|
|
70
|
-
|
|
71
|
-
if (problemsAmount <= 30) return [20, 40, 60, 80]
|
|
72
|
-
|
|
73
|
-
return [15, 30, 45, 60, 75]
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const generateGifsStructure = (gifs: GifsGroups): GifsStructure =>
|
|
77
|
-
Object.fromEntries(
|
|
78
|
-
Object.entries(gifs).map(([key, value]) => [
|
|
79
|
-
key,
|
|
80
|
-
value.map((url) => ({
|
|
81
|
-
url,
|
|
82
|
-
isShown: false,
|
|
83
|
-
group: key as GroupNumberString,
|
|
84
|
-
})),
|
|
85
|
-
]),
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
export const getGifLabel = (relatedGroup: GroupNumber): TranslationKeys => {
|
|
89
|
-
if (relatedGroup === 2) {
|
|
90
|
-
return 'gifCelebrations.onTheWay'
|
|
91
|
-
}
|
|
92
|
-
if (relatedGroup === 3) {
|
|
93
|
-
return 'gifCelebrations.almostThere'
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return 'gifCelebrations.greatStart'
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const getProgressLineWidth = (completedPercent: number) => {
|
|
100
|
-
if (completedPercent <= 9) {
|
|
101
|
-
return MIN_WIDTH_FOR_ONE_DIGIT
|
|
102
|
-
}
|
|
103
|
-
if (completedPercent <= 15) {
|
|
104
|
-
return MIN_WIDTH_FOR_TWO_DIGITS
|
|
105
|
-
}
|
|
106
|
-
return completedPercent
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const findGroupForPercentage = (percentage: number) => {
|
|
110
|
-
if (percentage <= 30) {
|
|
111
|
-
return 'group1'
|
|
112
|
-
}
|
|
113
|
-
if (percentage < 60) {
|
|
114
|
-
return 'group2'
|
|
115
|
-
}
|
|
116
|
-
return 'group3'
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export const getImagePath = async (url: string, cacheMethod?: CustomGetCachePathMethod) => {
|
|
120
|
-
if (cacheMethod) {
|
|
121
|
-
const path = await cacheMethod(url)
|
|
122
|
-
if (path) return path
|
|
123
|
-
} else {
|
|
124
|
-
// @ts-ignore - Image.queryCache works only in web
|
|
125
|
-
const isImagesStored = await Image.queryCache([url]).then((images) => !!images[url])
|
|
126
|
-
if (isImagesStored) return url
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
throw new Error('Image not found in cache')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const constrainDimension = (value: number, min: number, max: number) =>
|
|
133
|
-
Math.max(min, Math.min(max, value))
|
|
134
|
-
|
|
135
|
-
export const shouldRefreshGifs = (timestamp: string | null | undefined): boolean => {
|
|
136
|
-
if (!timestamp) return true
|
|
137
|
-
|
|
138
|
-
const REFRESH_INTERVAL_HOURS = 24
|
|
139
|
-
const lastFetchedDate = new Date(timestamp)
|
|
140
|
-
const currentDate = new Date()
|
|
141
|
-
const diffInHours = (currentDate.getTime() - lastFetchedDate.getTime()) / (1000 * 60 * 60)
|
|
142
|
-
|
|
143
|
-
return diffInHours > REFRESH_INTERVAL_HOURS
|
|
144
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createEffect, createEvent, createStore } from 'effector'
|
|
2
|
-
import {
|
|
3
|
-
GifsGroups,
|
|
4
|
-
GifsStructure,
|
|
5
|
-
CustomGetCachePathMethod,
|
|
6
|
-
CustomPrefetchMethod,
|
|
7
|
-
} from '../types/model.types'
|
|
8
|
-
import { generateGifsStructure } from '../helpers'
|
|
9
|
-
import { Image } from 'react-native'
|
|
10
|
-
|
|
11
|
-
type GifCelebrationsCacheProps = {
|
|
12
|
-
customPrefetchMethod?: CustomPrefetchMethod
|
|
13
|
-
customGetCachePathMethod?: CustomGetCachePathMethod
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class GifCelebrationsCache {
|
|
17
|
-
public readonly initialSet = createEvent<GifsGroups>()
|
|
18
|
-
public readonly set = createEvent<GifsStructure>()
|
|
19
|
-
public readonly reset = createEvent()
|
|
20
|
-
|
|
21
|
-
public readonly getCachePathMethod?: CustomGetCachePathMethod
|
|
22
|
-
public readonly prefetchMethod: CustomPrefetchMethod | typeof Image.prefetch
|
|
23
|
-
|
|
24
|
-
public readonly prefetchAllGifs = createEffect<GifsGroups, void>((data) => {
|
|
25
|
-
Object.values(data).forEach((group) => {
|
|
26
|
-
group.forEach((gifUrl) => {
|
|
27
|
-
this.prefetchMethod(gifUrl)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
this.initialSet(data)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
public readonly prefetchGifs = createEffect<string[], void>((gifs) => {
|
|
35
|
-
if (!gifs || gifs.length === 0) return
|
|
36
|
-
|
|
37
|
-
gifs.forEach((gifUrl) => {
|
|
38
|
-
this.prefetchMethod(gifUrl)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
public readonly $gifs = createStore<GifsStructure | null>(null)
|
|
43
|
-
.reset(this.reset)
|
|
44
|
-
.on(this.initialSet, (_, gifs) => generateGifsStructure(gifs))
|
|
45
|
-
.on(this.set, (_, gifs) => gifs)
|
|
46
|
-
|
|
47
|
-
constructor({ customGetCachePathMethod, customPrefetchMethod }: GifCelebrationsCacheProps) {
|
|
48
|
-
this.prefetchMethod = customPrefetchMethod || Image.prefetch
|
|
49
|
-
this.getCachePathMethod = customGetCachePathMethod
|
|
50
|
-
}
|
|
51
|
-
}
|