react-native-my-survey-sdk 2.2.1 → 2.2.3
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/package.json
CHANGED
|
@@ -28,8 +28,15 @@ import { XeboMultiNPSView } from './XeboMultiNPSView';
|
|
|
28
28
|
import { XeboRatingView } from './XeboRatingView';
|
|
29
29
|
import { XeboMultiRatingView } from './XeboMultiRatingView';
|
|
30
30
|
|
|
31
|
-
// '
|
|
32
|
-
|
|
31
|
+
// 'window' excludes the Android navigation bar; 'screen' includes it.
|
|
32
|
+
// Using window height so sheets are sized relative to the usable area.
|
|
33
|
+
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
|
34
|
+
|
|
35
|
+
// Android navigation bar height = difference between screen and window.
|
|
36
|
+
// Used as bottomInset so content isn't hidden behind the nav bar.
|
|
37
|
+
const _androidNavBar = Platform.OS === 'android'
|
|
38
|
+
? Math.max(0, Dimensions.get('screen').height - Dimensions.get('window').height)
|
|
39
|
+
: 0;
|
|
33
40
|
|
|
34
41
|
function computeSheetHeight(question: XeboQuestion | null, screen: ModalScreen): number {
|
|
35
42
|
if (screen === 'thankYou') return SCREEN_HEIGHT * 0.32;
|
|
@@ -68,8 +75,8 @@ type ModalScreen = 'intro' | 'question' | 'thankYou';
|
|
|
68
75
|
|
|
69
76
|
export const XeboSurveyModal: React.FC = () => {
|
|
70
77
|
const theme = getTheme();
|
|
71
|
-
//
|
|
72
|
-
const bottomInset = Platform.OS === 'ios' ? 34 : 16;
|
|
78
|
+
// Bottom inset: iOS home indicator (34) or Android nav bar height (min 16)
|
|
79
|
+
const bottomInset = Platform.OS === 'ios' ? 34 : Math.max(16, _androidNavBar);
|
|
73
80
|
|
|
74
81
|
const [visible, setVisible] = useState(false);
|
|
75
82
|
const [survey, setSurvey] = useState<XeboSurvey | null>(null);
|
|
@@ -149,28 +156,28 @@ export const XeboSurveyModal: React.FC = () => {
|
|
|
149
156
|
const lastRealIndex = questions.findIndex(q => q.id === 'thank_you_auto') - 1;
|
|
150
157
|
const isLast = questionIndex === lastRealIndex;
|
|
151
158
|
|
|
152
|
-
// key
|
|
159
|
+
// key must be passed directly (not via spread) — forces unmount/remount on question change,
|
|
153
160
|
// resetting all component state (selected score, text, etc.)
|
|
154
|
-
const commonProps = {
|
|
161
|
+
const commonProps = { question, isLastQuestion: isLast, onAnswer: handleAnswer };
|
|
155
162
|
|
|
156
163
|
switch (question.type) {
|
|
157
164
|
case XeboQuestionType.singleChoice:
|
|
158
|
-
return <XeboSingleChoiceView {...commonProps} />;
|
|
165
|
+
return <XeboSingleChoiceView key={question.id} {...commonProps} />;
|
|
159
166
|
case XeboQuestionType.multipleChoice:
|
|
160
|
-
return <XeboMultipleChoiceView {...commonProps} />;
|
|
167
|
+
return <XeboMultipleChoiceView key={question.id} {...commonProps} />;
|
|
161
168
|
case XeboQuestionType.dropdown:
|
|
162
|
-
return <XeboDropdownView {...commonProps} />;
|
|
169
|
+
return <XeboDropdownView key={question.id} {...commonProps} />;
|
|
163
170
|
case XeboQuestionType.singleTextBox:
|
|
164
171
|
case XeboQuestionType.multipleTextBox:
|
|
165
|
-
return <XeboTextBoxView {...commonProps} />;
|
|
172
|
+
return <XeboTextBoxView key={question.id} {...commonProps} />;
|
|
166
173
|
case XeboQuestionType.nps:
|
|
167
|
-
return <XeboNPSView {...commonProps} />;
|
|
174
|
+
return <XeboNPSView key={question.id} {...commonProps} />;
|
|
168
175
|
case XeboQuestionType.multiNps:
|
|
169
|
-
return <XeboMultiNPSView {...commonProps} />;
|
|
176
|
+
return <XeboMultiNPSView key={question.id} {...commonProps} />;
|
|
170
177
|
case XeboQuestionType.rating:
|
|
171
|
-
return <XeboRatingView {...commonProps} />;
|
|
178
|
+
return <XeboRatingView key={question.id} {...commonProps} />;
|
|
172
179
|
case XeboQuestionType.multiRating:
|
|
173
|
-
return <XeboMultiRatingView {...commonProps} />;
|
|
180
|
+
return <XeboMultiRatingView key={question.id} {...commonProps} />;
|
|
174
181
|
default:
|
|
175
182
|
return null;
|
|
176
183
|
}
|