@@ -3,15 +3,27 @@ import { RNConfig } from "@/lib/common/config";
33import { Logger } from "@/lib/common/logger" ;
44import { filterSurveys , getLanguageCode , getStyling } from "@/lib/common/utils" ;
55import { SurveyStore } from "@/lib/survey/store" ;
6+ import type { TOverlay } from "@/types/common" ;
67import { type TUserState , ZJsRNWebViewOnMessageData } from "@/types/config" ;
78import type { TSurvey , SurveyContainerProps } from "@/types/survey" ;
8- import React , { type JSX , useEffect , useRef , useState } from "react" ;
9+ import React , { type JSX , useEffect , useMemo , useRef , useState } from "react" ;
910import { KeyboardAvoidingView , Modal , View , StyleSheet } from "react-native" ;
1011import { WebView , type WebViewMessageEvent } from "react-native-webview" ;
1112
1213const logger = Logger . getInstance ( ) ;
1314logger . configure ( { logLevel : "debug" } ) ;
1415
16+ const getOverlayBackgroundColor = ( overlay : TOverlay ) : string => {
17+ switch ( overlay ) {
18+ case "dark" :
19+ return "rgba(51, 65, 85, 0.8)" ;
20+ case "light" :
21+ return "rgba(148, 163, 184, 0.5)" ;
22+ case "none" :
23+ return "transparent" ;
24+ }
25+ } ;
26+
1527const surveyStore = SurveyStore . getInstance ( ) ;
1628
1729interface SurveyWebViewProps {
@@ -85,6 +97,15 @@ export function SurveyWebView(
8597 setShowSurvey ( true ) ;
8698 } , [ props . survey . delay , isSurveyRunning , props . survey . name ] ) ;
8799
100+ const overlay = appConfig
101+ ? ( props . survey . projectOverwrites ?. overlay ?? appConfig . get ( ) . environment . data . project . overlay )
102+ : "none" ;
103+
104+ const modalContainerStyle = useMemo (
105+ ( ) => [ styles . modalContainer , { backgroundColor : getOverlayBackgroundColor ( overlay ) } ] ,
106+ [ overlay ]
107+ ) ;
108+
88109 if ( ! appConfig ) {
89110 return ;
90111 }
@@ -114,8 +135,6 @@ export function SurveyWebView(
114135 const clickOutside =
115136 props . survey . projectOverwrites ?. clickOutsideClose ??
116137 project . clickOutsideClose ;
117- const darkOverlay =
118- props . survey . projectOverwrites ?. darkOverlay ?? project . darkOverlay ;
119138
120139 return (
121140 < Modal
@@ -127,7 +146,7 @@ export function SurveyWebView(
127146 setIsSurveyRunning ( false ) ;
128147 } }
129148 >
130- < View style = { styles . modalContainer } >
149+ < View style = { modalContainerStyle } >
131150 < KeyboardAvoidingView
132151 behavior = "padding"
133152 style = { styles . keyboardAvoidingView }
@@ -145,9 +164,8 @@ export function SurveyWebView(
145164 languageCode,
146165 placement : surveyPlacement ,
147166 appUrl : appConfig . get ( ) . appUrl ,
148- clickOutside :
149- surveyPlacement === "center" ? clickOutside : true ,
150- darkOverlay,
167+ clickOutside,
168+ overlay,
151169 getSetIsResponseSendingFinished : (
152170 _f : ( value : boolean ) => void
153171 ) => undefined ,
@@ -269,7 +287,6 @@ export function SurveyWebView(
269287const styles = StyleSheet . create ( {
270288 modalContainer : {
271289 flex : 1 ,
272- backgroundColor : "rgba(0, 0, 0, 0.5)" ,
273290 } ,
274291 keyboardAvoidingView : {
275292 flex : 1 ,
0 commit comments