@magmamath/students-features 0.6.6-rc.9 → 0.6.6
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/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +5 -3
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +3 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/commonjs/features/feedback/model/comments.js +5 -3
- package/dist/commonjs/features/feedback/model/comments.js.map +1 -1
- package/dist/commonjs/features/feedback/model/model.js +7 -9
- package/dist/commonjs/features/feedback/model/model.js.map +1 -1
- package/dist/commonjs/index.js +0 -12
- package/dist/commonjs/index.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/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +5 -3
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +3 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/module/features/feedback/model/comments.js +5 -3
- package/dist/module/features/feedback/model/comments.js.map +1 -1
- package/dist/module/features/feedback/model/model.js +7 -9
- package/dist/module/features/feedback/model/model.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.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/chatbot/components/ChatMessage/ChatMessage.d.ts +2 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.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/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/chatbot/components/ChatMessage/ChatMessage.d.ts +2 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.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/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/chatbot/components/ChatMessage/ChatMessage.tsx +2 -1
- package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +7 -4
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +4 -2
- package/src/features/feedback/model/comments.ts +7 -7
- package/src/features/feedback/model/model.ts +6 -6
- package/src/index.ts +0 -1
- 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 -65
- 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 -32
- package/dist/commonjs/features/gifCelebrations/constants.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/helpers.js +0 -111
- 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 -37
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js.map +0 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js +0 -121
- 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/module/features/gifCelebrations/GifCelebrations.js +0 -58
- 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 -28
- package/dist/module/features/gifCelebrations/constants.js.map +0 -1
- package/dist/module/features/gifCelebrations/helpers.js +0 -101
- 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 -32
- package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js.map +0 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js +0 -116
- 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/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 -24
- package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts +0 -28
- 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 -24
- 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 -39
- 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/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 -24
- package/dist/typescript/module/features/gifCelebrations/constants.d.ts.map +0 -1
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts +0 -28
- 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 -24
- 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 -39
- 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/src/features/gifCelebrations/GifCelebrations.tsx +0 -77
- 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 -93
- package/src/features/gifCelebrations/components/Progress.tsx +0 -106
- package/src/features/gifCelebrations/constants.ts +0 -28
- package/src/features/gifCelebrations/helpers.ts +0 -123
- package/src/features/gifCelebrations/index.ts +0 -2
- package/src/features/gifCelebrations/model/GifCelebrations.cache.ts +0 -49
- package/src/features/gifCelebrations/model/GifCelebrations.model.ts +0 -163
- package/src/features/gifCelebrations/model/GifCelebrationsApi.ts +0 -10
- package/src/features/gifCelebrations/types/model.types.ts +0 -47
- package/src/react-app-env.d.ts +0 -6
- package/src/shared/constants.ts +0 -3
package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GifCelebrations.cache.d.ts","sourceRoot":"","sources":["../../../../../../src/features/gifCelebrations/model/GifCelebrations.cache.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,KAAK,yBAAyB,GAAG;IAC/B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;CACpD,CAAA;AAED,qBAAa,oBAAoB;IAC/B,SAAgB,UAAU,+CAA4B;IACtD,SAAgB,GAAG,kDAA+B;IAClD,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,kBAAkB,CAAC,EAAE,wBAAwB,CAAA;IAC7D,SAAgB,cAAc,EAAE,oBAAoB,GAAG,OAAO,KAAK,CAAC,QAAQ,CAAA;IAE5E,SAAgB,eAAe,qDAQ7B;IAEF,SAAgB,YAAY,mDAI1B;IAEF,SAAgB,KAAK,yDAGa;gBAEtB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,EAAE,yBAAyB;CAI1F"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Store } from 'effector';
|
|
2
|
-
import { GifCelebrationsApi } from './GifCelebrationsApi';
|
|
3
|
-
import { GifCelebrationsModelProps, GifObject, ProblemsPercentageTable } from '../types/model.types';
|
|
4
|
-
import { GifCelebrationsCache } from './GifCelebrations.cache';
|
|
5
|
-
export declare class GifCelebrationsModel {
|
|
6
|
-
readonly api: GifCelebrationsApi;
|
|
7
|
-
readonly cache: GifCelebrationsCache;
|
|
8
|
-
readonly $totalProblems: Store<number>;
|
|
9
|
-
readonly $resolvedProblems: Store<number>;
|
|
10
|
-
readonly play: import("effector").EventCallable<void>;
|
|
11
|
-
readonly stop: import("effector").EventCallable<void>;
|
|
12
|
-
readonly resetGifTriggerable: import("effector").EventCallable<void>;
|
|
13
|
-
readonly setGifTriggerable: import("effector").EventCallable<boolean>;
|
|
14
|
-
readonly $isGifTriggerable: import("effector").StoreWritable<boolean>;
|
|
15
|
-
readonly resetPercentageTable: import("effector").EventCallable<void>;
|
|
16
|
-
readonly $problemsPercentageTable: import("effector").StoreWritable<ProblemsPercentageTable | null>;
|
|
17
|
-
readonly setActiveGif: import("effector").EventCallable<GifObject>;
|
|
18
|
-
readonly $activeGif: import("effector").StoreWritable<GifObject | null>;
|
|
19
|
-
readonly initialize: import("effector").EventCallable<void>;
|
|
20
|
-
constructor({ api, totalProblems, resolvedProblems, customGetCachePathMethod, customPrefetchMethod, }: GifCelebrationsModelProps);
|
|
21
|
-
private setupEventHandlers;
|
|
22
|
-
private readonly handleGifSelection;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=GifCelebrations.model.d.ts.map
|
package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GifCelebrations.model.d.ts","sourceRoot":"","sources":["../../../../../../src/features/gifCelebrations/model/GifCelebrations.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,EAAE,MAAM,UAAU,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EACL,yBAAyB,EACzB,SAAS,EAET,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAU9D,qBAAa,oBAAoB;IAC/B,SAAgB,GAAG,EAAE,kBAAkB,CAAA;IACvC,SAAgB,KAAK,EAAE,oBAAoB,CAAA;IAE3C,SAAgB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7C,SAAgB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAEhD,SAAgB,IAAI,yCAAgB;IACpC,SAAgB,IAAI,yCAAgB;IAEpC,SAAgB,mBAAmB,yCAAgB;IACnD,SAAgB,iBAAiB,4CAAyB;IAC1D,SAAgB,iBAAiB,4CAM9B;IAEH,SAAgB,oBAAoB,yCAAgB;IACpD,SAAgB,wBAAwB,mEAEN;IAElC,SAAgB,YAAY,8CAA2B;IACvD,SAAgB,UAAU,qDAGe;IAEzC,SAAgB,UAAU,yCAAgB;gBAE9B,EACV,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,GACrB,EAAE,yBAAyB;IAU5B,OAAO,CAAC,kBAAkB;IAoD1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CA0ClC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GifCelebrationApiRequests } from '../types/model.types';
|
|
2
|
-
export declare class GifCelebrationsApi {
|
|
3
|
-
readonly getGifsFx: import("./../../../lib/effector/createControllerEffect").ControlledEffect<unknown, import("../types/model.types").GifResponse>;
|
|
4
|
-
constructor(api: GifCelebrationApiRequests);
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=GifCelebrationsApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GifCelebrationsApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/gifCelebrations/model/GifCelebrationsApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAEhE,qBAAa,kBAAkB;IAC7B,SAAgB,SAAS,iIAAA;gBAEb,GAAG,EAAE,yBAAyB;CAG3C"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Store } from 'effector';
|
|
2
|
-
export type CustomGetCachePathMethod = (uri: string) => Promise<string | null>;
|
|
3
|
-
export type CustomPrefetchMethod = (gifs: string[] | string) => Promise<unknown>;
|
|
4
|
-
export type GroupNumber = number;
|
|
5
|
-
export type GifCelebrationApiRequests = {
|
|
6
|
-
getGifs: () => Promise<GifResponse>;
|
|
7
|
-
};
|
|
8
|
-
export type GifCelebrationsModelProps = {
|
|
9
|
-
api: GifCelebrationApiRequests;
|
|
10
|
-
totalProblems: Store<number>;
|
|
11
|
-
resolvedProblems: Store<number>;
|
|
12
|
-
customPrefetchMethod?: CustomPrefetchMethod;
|
|
13
|
-
customGetCachePathMethod?: CustomGetCachePathMethod;
|
|
14
|
-
};
|
|
15
|
-
export type GifsGroup = string[];
|
|
16
|
-
export type GifsGroups = Record<`group${GroupNumber}`, GifsGroup>;
|
|
17
|
-
export type GifObject = {
|
|
18
|
-
url: string;
|
|
19
|
-
isShown: boolean;
|
|
20
|
-
group: `group${GroupNumber}`;
|
|
21
|
-
};
|
|
22
|
-
export type GifsStructure = Record<`group${GroupNumber}`, GifObject[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Usually, the response contains 3 groups of gifs:
|
|
25
|
-
* - group1: early celebrations
|
|
26
|
-
* - group2: mid celebrations
|
|
27
|
-
* - group3: party
|
|
28
|
-
*/
|
|
29
|
-
export type GifResponse = {
|
|
30
|
-
data: GifsGroups;
|
|
31
|
-
ok: boolean;
|
|
32
|
-
};
|
|
33
|
-
export type GifsPayload = {
|
|
34
|
-
group: number;
|
|
35
|
-
};
|
|
36
|
-
export type ProblemsPercentageTable = Record<number, number>;
|
|
37
|
-
export type ProgressValue = 0 | 1 | 2;
|
|
38
|
-
export type TextComponentType = (text: string) => React.ReactNode;
|
|
39
|
-
//# sourceMappingURL=model.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/gifCelebrations/types/model.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,MAAM,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AAC9E,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAEhF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,yBAAyB,CAAA;IAC9B,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAChC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,WAAW,EAAE,EAAE,SAAS,CAAC,CAAA;AAEjE,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,QAAQ,WAAW,EAAE,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;AACtE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,EAAE,EAAE,OAAO,CAAA;CACZ,CAAA;AACD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAErC,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/shared/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,SAAwB,CAAA"}
|
|
@@ -1,77 +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 [totalProblems, resolvedProblems, activeGif] = useUnit([
|
|
19
|
-
model.$totalProblems,
|
|
20
|
-
model.$resolvedProblems,
|
|
21
|
-
model.$activeGif,
|
|
22
|
-
])
|
|
23
|
-
|
|
24
|
-
const completedPercent =
|
|
25
|
-
resolvedProblems && totalProblems && Math.round((resolvedProblems / totalProblems) * 100)
|
|
26
|
-
|
|
27
|
-
const progress = useSharedValue<ProgressValue>(0)
|
|
28
|
-
|
|
29
|
-
const stopAnimation = () => {
|
|
30
|
-
model.stop()
|
|
31
|
-
progress.value = 0
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const playAnimation = () => {
|
|
35
|
-
progress.value = withSequence(
|
|
36
|
-
withTiming(1, {
|
|
37
|
-
duration: ANIMATION_DURATION,
|
|
38
|
-
easing: Easing.bezier(0.52, 0.16, 0.26, 0.77),
|
|
39
|
-
}),
|
|
40
|
-
withTiming(
|
|
41
|
-
2,
|
|
42
|
-
{
|
|
43
|
-
duration: ANIMATION_DURATION,
|
|
44
|
-
easing: Easing.bezier(0.71, 0.09, 0.49, 0.89),
|
|
45
|
-
},
|
|
46
|
-
() => runOnJS(stopAnimation)(),
|
|
47
|
-
),
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
model.initialize()
|
|
53
|
-
}, [])
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (activeGif) {
|
|
57
|
-
playAnimation()
|
|
58
|
-
}
|
|
59
|
-
}, [activeGif])
|
|
60
|
-
|
|
61
|
-
if (!activeGif) {
|
|
62
|
-
return null
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Backdrop progress={progress}>
|
|
67
|
-
<ContentContainer progress={progress}>
|
|
68
|
-
<Gif
|
|
69
|
-
gifObject={activeGif}
|
|
70
|
-
getCachePathMethod={model.cache.getCachePathMethod}
|
|
71
|
-
TextComponent={TextComponent}
|
|
72
|
-
/>
|
|
73
|
-
<Progress progress={progress} completedPercent={completedPercent} />
|
|
74
|
-
</ContentContainer>
|
|
75
|
-
</Backdrop>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
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,93 +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
|
-
|
|
11
|
-
type GifProps = {
|
|
12
|
-
gifObject: GifObject
|
|
13
|
-
getCachePathMethod?: CustomGetCachePathMethod //it is used for RN
|
|
14
|
-
TextComponent: TextComponentType
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Size = {
|
|
18
|
-
width: number
|
|
19
|
-
height: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const Gif = ({ gifObject, getCachePathMethod, TextComponent }: GifProps) => {
|
|
23
|
-
const [size, setSize] = useState<Size | null>(null)
|
|
24
|
-
const [pathOrUri, setPathOrUri] = useState<string>('')
|
|
25
|
-
|
|
26
|
-
const t = useText()
|
|
27
|
-
|
|
28
|
-
const gifGroupNumber = Number(gifObject.group.replace('group', ''))
|
|
29
|
-
const gifLabel = getGifLabel(gifGroupNumber)
|
|
30
|
-
|
|
31
|
-
useLayoutEffect(() => {
|
|
32
|
-
const loadImageSize = async () => {
|
|
33
|
-
let localPath
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
localPath = await getImagePath(gifObject.url, getCachePathMethod)
|
|
37
|
-
} catch (error) {
|
|
38
|
-
localPath = IS_WEB ? gifFallback : Image.resolveAssetSource(gifFallback).uri
|
|
39
|
-
console.error('Error fetching image from cache:', error)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
Image.getSize(localPath, (width, height) => {
|
|
43
|
-
setSize({
|
|
44
|
-
width: constrainDimension(width, MIN_GIF_SIZE, MAX_GIF_SIZE.WIDTH),
|
|
45
|
-
height: constrainDimension(height, MIN_GIF_SIZE, MAX_GIF_SIZE.HEIGHT),
|
|
46
|
-
})
|
|
47
|
-
setPathOrUri(localPath)
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
loadImageSize()
|
|
52
|
-
}, [gifObject.url])
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<View style={styles.backgroundContainer}>
|
|
56
|
-
<View style={styles.container}>
|
|
57
|
-
{size && pathOrUri && (
|
|
58
|
-
<Image
|
|
59
|
-
alt="Funny celebration animated image"
|
|
60
|
-
source={{
|
|
61
|
-
uri: pathOrUri,
|
|
62
|
-
}}
|
|
63
|
-
width={size.width}
|
|
64
|
-
height={size.height}
|
|
65
|
-
style={[styles.image, { width: size.width, height: size.height }]} //this sizes duplication is needed for compatibility with web and rn
|
|
66
|
-
/>
|
|
67
|
-
)}
|
|
68
|
-
<View style={styles.textContainer}>{TextComponent(t(gifLabel))}</View>
|
|
69
|
-
</View>
|
|
70
|
-
</View>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const styles = StyleSheet.create({
|
|
75
|
-
backgroundContainer: {
|
|
76
|
-
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
77
|
-
borderRadius: 23,
|
|
78
|
-
padding: SPACING[200],
|
|
79
|
-
},
|
|
80
|
-
container: {
|
|
81
|
-
padding: SPACING[1600],
|
|
82
|
-
borderRadius: BORDER_RADIUS[400],
|
|
83
|
-
backgroundColor: COLORS.NEUTRAL_1,
|
|
84
|
-
},
|
|
85
|
-
image: {
|
|
86
|
-
borderRadius: BORDER_RADIUS[100],
|
|
87
|
-
},
|
|
88
|
-
textContainer: {
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
bottom: 74,
|
|
91
|
-
alignSelf: 'center',
|
|
92
|
-
},
|
|
93
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, View, Image, Platform } 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,28 +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
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { TranslationKeys } from 'src/shared/translation/types'
|
|
2
|
-
import {
|
|
3
|
-
CustomGetCachePathMethod,
|
|
4
|
-
GifsGroups,
|
|
5
|
-
GifsStructure,
|
|
6
|
-
GroupNumber,
|
|
7
|
-
ProblemsPercentageTable,
|
|
8
|
-
} from './types/model.types'
|
|
9
|
-
import { MIN_WIDTH_FOR_ONE_DIGIT, MIN_WIDTH_FOR_TWO_DIGITS } from './constants'
|
|
10
|
-
import { Image } from 'react-native'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Number of problems When we show gif
|
|
14
|
-
* <6 Never
|
|
15
|
-
* 7-12 50% completion
|
|
16
|
-
* 13-18 33%, 66% completion
|
|
17
|
-
* 19-24 25%, 50%, 75 completion
|
|
18
|
-
* 25-30 20%, 40%, 60%, 80% completion
|
|
19
|
-
* .>30 15%, 30%, 45%, 60%, 75% completion
|
|
20
|
-
*
|
|
21
|
-
* We are also going to have different buckets with different gifs. The logic is as follows:
|
|
22
|
-
* Group 1: 15%, 20%, 25%, 30% - Early celebrations
|
|
23
|
-
* Group 2: 33%, 40%, 45%, 50% - Mid celebrations
|
|
24
|
-
* Group 3: 60%, 66%, 75%, 80% - Party
|
|
25
|
-
* or
|
|
26
|
-
* Group 1: <=30% - Early celebrations
|
|
27
|
-
* Group 2: >30% <60% - Mid celebrations
|
|
28
|
-
* Group 3: >=60% - Party
|
|
29
|
-
*/
|
|
30
|
-
export const calculatePercentageTable = (totalProblems: number): ProblemsPercentageTable => {
|
|
31
|
-
if (totalProblems <= 12) return { 50: Math.ceil(totalProblems * 0.5) }
|
|
32
|
-
|
|
33
|
-
if (totalProblems <= 18) {
|
|
34
|
-
return {
|
|
35
|
-
33: Math.ceil(totalProblems * 0.33),
|
|
36
|
-
66: Math.ceil(totalProblems * 0.66),
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (totalProblems <= 24) {
|
|
41
|
-
return {
|
|
42
|
-
25: Math.ceil(totalProblems * 0.25),
|
|
43
|
-
50: Math.ceil(totalProblems * 0.5),
|
|
44
|
-
75: Math.ceil(totalProblems * 0.75),
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (totalProblems <= 30) {
|
|
49
|
-
return {
|
|
50
|
-
20: Math.ceil(totalProblems * 0.2),
|
|
51
|
-
40: Math.ceil(totalProblems * 0.4),
|
|
52
|
-
60: Math.ceil(totalProblems * 0.6),
|
|
53
|
-
80: Math.ceil(totalProblems * 0.8),
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
15: Math.ceil(totalProblems * 0.15),
|
|
59
|
-
30: Math.ceil(totalProblems * 0.3),
|
|
60
|
-
45: Math.ceil(totalProblems * 0.45),
|
|
61
|
-
60: Math.ceil(totalProblems * 0.6),
|
|
62
|
-
75: Math.ceil(totalProblems * 0.75),
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const generateGifsStructure = (gifs: GifsGroups): GifsStructure =>
|
|
67
|
-
Object.fromEntries(
|
|
68
|
-
Object.entries(gifs).map(([key, value]) => [
|
|
69
|
-
key,
|
|
70
|
-
value.map((url) => ({
|
|
71
|
-
url,
|
|
72
|
-
isShown: false,
|
|
73
|
-
group: key as `group${GroupNumber}`,
|
|
74
|
-
})),
|
|
75
|
-
]),
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
export const getGifLabel = (relatedGroup: GroupNumber): TranslationKeys => {
|
|
79
|
-
if (relatedGroup === 2) {
|
|
80
|
-
return 'gifCelebrations.onTheWay'
|
|
81
|
-
}
|
|
82
|
-
if (relatedGroup === 3) {
|
|
83
|
-
return 'gifCelebrations.almostThere'
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return 'gifCelebrations.greatStart'
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const getProgressLineWidth = (completedPercent: number) => {
|
|
90
|
-
if (completedPercent <= 9) {
|
|
91
|
-
return MIN_WIDTH_FOR_ONE_DIGIT
|
|
92
|
-
}
|
|
93
|
-
if (completedPercent <= 15) {
|
|
94
|
-
return MIN_WIDTH_FOR_TWO_DIGITS
|
|
95
|
-
}
|
|
96
|
-
return completedPercent
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const findGroupForPercentage = (percentage: number) => {
|
|
100
|
-
if (percentage <= 30) {
|
|
101
|
-
return 'group1'
|
|
102
|
-
}
|
|
103
|
-
if (percentage < 60) {
|
|
104
|
-
return 'group2'
|
|
105
|
-
}
|
|
106
|
-
return 'group3'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const getImagePath = async (url: string, cacheMethod?: CustomGetCachePathMethod) => {
|
|
110
|
-
if (cacheMethod) {
|
|
111
|
-
const path = await cacheMethod(url)
|
|
112
|
-
if (path) return path
|
|
113
|
-
} else {
|
|
114
|
-
// @ts-ignore - Image.queryCache works only in web
|
|
115
|
-
const isImagesStored = await Image.queryCache([url]).then((images) => !!images[url])
|
|
116
|
-
if (isImagesStored) return url
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
throw new Error('Image not found in cache')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export const constrainDimension = (value: number, min: number, max: number) =>
|
|
123
|
-
Math.max(min, Math.min(max, value))
|
|
@@ -1,49 +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
|
-
gifs.forEach((gifUrl) => {
|
|
36
|
-
this.prefetchMethod(gifUrl)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
public readonly $gifs = createStore<GifsStructure | null>(null)
|
|
41
|
-
.reset(this.reset)
|
|
42
|
-
.on(this.initialSet, (_, gifs) => generateGifsStructure(gifs))
|
|
43
|
-
.on(this.set, (_, gifs) => gifs)
|
|
44
|
-
|
|
45
|
-
constructor({ customGetCachePathMethod, customPrefetchMethod }: GifCelebrationsCacheProps) {
|
|
46
|
-
this.prefetchMethod = customPrefetchMethod || Image.prefetch
|
|
47
|
-
this.getCachePathMethod = customGetCachePathMethod
|
|
48
|
-
}
|
|
49
|
-
}
|