Skip to content

Commit

Permalink
add unity DTO, mapper, pipeline items
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaconC committed Oct 28, 2024
1 parent 0c295f8 commit 7148100
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 14 deletions.
8 changes: 8 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@ PODS:
- react-native-tcp-socket (6.0.6):
- CocoaAsyncSocket
- React-Core
- react-native-unity (1.0.10):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- react-native-video (5.2.1):
- React-Core
- react-native-video/Video (= 5.2.1)
Expand Down Expand Up @@ -1392,6 +1396,7 @@ DEPENDENCIES:
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- "react-native-skia (from `../node_modules/@shopify/react-native-skia`)"
- react-native-tcp-socket (from `../node_modules/react-native-tcp-socket`)
- "react-native-unity (from `../node_modules/@azesmway/react-native-unity`)"
- react-native-video (from `../node_modules/react-native-video`)
- react-native-webview (from `../node_modules/react-native-webview`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
Expand Down Expand Up @@ -1549,6 +1554,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@shopify/react-native-skia"
react-native-tcp-socket:
:path: "../node_modules/react-native-tcp-socket"
react-native-unity:
:path: "../node_modules/@azesmway/react-native-unity"
react-native-video:
:path: "../node_modules/react-native-video"
react-native-webview:
Expand Down Expand Up @@ -1703,6 +1710,7 @@ SPEC CHECKSUMS:
react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b
react-native-skia: 8c3c1016dfb86ae82d61e08a16c7197ac2b58eed
react-native-tcp-socket: e724380c910c2e704816ec817ed28f1342246ff7
react-native-unity: 1a01286041cff06399765db822dcdf9e1ff71af3
react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253
react-native-webview: a9454e7b9a99dc4c3fc865fd92de3e95d2eb79d2
React-nativeconfig: d7af5bae6da70fa15ce44f045621cf99ed24087c
Expand Down
16 changes: 14 additions & 2 deletions src/entities/activity/lib/types/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export type ActivityItemType =
| 'Video'
| 'Checkbox'
| 'Date'
| 'Time';
| 'Time'
| 'Unity';

export type StabilityTrackerConfig = {
lambdaSlope: number;
Expand Down Expand Up @@ -213,6 +214,10 @@ type RadioConfig = {
}>;
};

type UnityConfig = {
file: string;
};

type PhotoConfig = null;

type VideoConfig = null;
Expand Down Expand Up @@ -241,6 +246,7 @@ export type ActivityItemConfig =
| VideoConfig
| TimeConfig
| FlankerItemSettings
| UnityConfig
| null;

type ActivityItemBase = {
Expand Down Expand Up @@ -273,6 +279,11 @@ interface AbTestActivityItem extends ActivityItemBase {
config: AbTrailsConfig;
}

interface UnityActivityItem extends ActivityItemBase {
inputType: 'Unity';
config: UnityConfig;
}

interface StabilityTrackerActivityItem extends ActivityItemBase {
inputType: 'StabilityTracker';
config: StabilityTrackerConfig;
Expand Down Expand Up @@ -403,7 +414,8 @@ export type ActivityItem =
| DateActivityItem
| PhotoActivityItem
| TimeActivityItem
| VideoActivityItem;
| VideoActivityItem
| UnityActivityItem;

export type ActivityDetails = {
id: string;
Expand Down
25 changes: 25 additions & 0 deletions src/entities/activity/model/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
TextItemDto,
TimeItemDto,
TimeRangeItemDto,
UnityItemDto,
VideoItemDto,
} from '@app/shared/api/services/ActivityItemDto';
import { ActivityDto } from '@app/shared/api/services/IActivityService';
Expand Down Expand Up @@ -104,6 +105,28 @@ function mapToDrawing(dto: DrawingItemDto): ActivityItem {
};
}

function mapToUnity(dto: UnityItemDto): ActivityItem {
return {
id: dto.id,
name: dto.name,
inputType: 'Unity',
config: {
file: dto.config.file,
},
timer: null,
order: dto.order,
question: dto.question,
isSkippable: false,
hasAlert: false,
hasScore: false,
isAbleToMoveBack: false,
hasTextResponse: false,
canBeReset: false,
hasTopNavigation: false,
isHidden: dto.isHidden,
};
}

function mapToAbTest(dto: ABTrailsItemDto): ActivityItem {
const config = dto.config;

Expand Down Expand Up @@ -747,6 +770,8 @@ export function mapToActivity(dto: ActivityDto): ActivityDetails {
return mapToDrawing(item);
case 'time':
return mapToTime(item);
case 'unity':
return mapToUnity(item);
}
}),
hasSummary: dto.scoresAndReports?.showScoreSummary ?? false,
Expand Down
9 changes: 1 addition & 8 deletions src/features/pass-survey/lib/types/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ type StabilityTrackerPayload = {
};

type UnityPayload = {
config: UnityScreenConfig;
deviceType: 'mobile' | 'tablet';
};

type UnityScreenConfig = {
radius: number;
width: number;
height: number;
file: string | null;
};

type SplashPayload = { imageUrl: string };
Expand Down
9 changes: 9 additions & 0 deletions src/features/pass-survey/model/pipelineBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export function buildPipeline(activity: ActivityDetails): PipelineItem[] {
const pipeline: PipelineItem[] = filterHiddenItems(activity.items)
.map((item, index) => {
switch (item.inputType) {
case 'Unity': {
return {
id: item.id,
payload: item.config,
type: item.inputType,
timer: null,
} satisfies PipelineItem;
}

case 'AbTrails': {
return getAbTrailsPipeline(
item.id,
Expand Down
24 changes: 20 additions & 4 deletions src/shared/api/services/ActivityItemDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export type ResponseType =
| 'text'
| 'time'
| 'timeRange'
| 'video';
| 'video'
| 'unity';

type Match = 'any' | 'all';

Expand Down Expand Up @@ -421,6 +422,12 @@ export type AbTrailsConfiguration = AbTrailsItemSettingsDto;

export type AbTrailsAnswerSettings = null;

type UnityAnswerSettings = null;

type UnityConfiguration = {
file: string;
};

type Configuration =
| TextConfiguration
| SingleSelectionRowsConfiguration
Expand All @@ -443,7 +450,8 @@ type Configuration =
| AbTestConfiguration
| StabilityTrackerConfiguration
| FlankerConfiguration
| AbTrailsConfiguration;
| AbTrailsConfiguration
| UnityConfiguration;

type AnswerSettings =
| TextAnswerSettings
Expand All @@ -466,7 +474,8 @@ type AnswerSettings =
| AbTestAnswerSettings
| StabilityTrackerAnswerSettings
| FlankerAnswerSettings
| AbTrailsAnswerSettings;
| AbTrailsAnswerSettings
| UnityAnswerSettings;

type ActivityItemDtoBase = {
id: string;
Expand Down Expand Up @@ -612,6 +621,12 @@ export interface ABTrailsItemDto extends ActivityItemDtoBase {
responseValues: AbTrailsAnswerSettings;
}

export interface UnityItemDto extends ActivityItemDtoBase {
responseType: 'unity';
config: UnityConfiguration;
responseValues: UnityAnswerSettings;
}

export type ActivityItemDto =
| TextItemDto
| ParagraphTextItemDto
Expand All @@ -634,4 +649,5 @@ export type ActivityItemDto =
| ABTrailsItemDto
| StabilityTrackerItemDto
| FlankerItemDto
| TimeItemDto;
| TimeItemDto
| UnityItemDto;

0 comments on commit 7148100

Please sign in to comment.