Skip to content

Commit 986c3db

Browse files
committed
feat: enhance View component with SafeArea support and update generate function
- Integrated SafeAreaView and StatusBar into the View component for improved UI layout and safety on different devices. - Updated the generate function to ensure reactNativeOptions defaults to an empty object, enhancing robustness in configuration handling. All tests pass successfully.
1 parent 9b735ca commit 986c3db

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

packages/react-native/scripts/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function generate({
133133

134134
let options = '';
135135
let optionsVar = '';
136-
const reactNativeOptions = main.reactNative;
136+
const reactNativeOptions = main.reactNative ?? {};
137137

138138
if (liteMode) {
139139
reactNativeOptions.liteMode = true;

packages/react-native/src/View.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import dedent from 'dedent';
1111
import { patchChannelForRN } from './patchChannelForRN';
1212
import deepmerge from 'deepmerge';
1313
import { useEffect, useMemo, useReducer, useState } from 'react';
14+
import { StatusBar } from 'react-native';
15+
import { SafeAreaView, SafeAreaProvider } from 'react-native-safe-area-context';
16+
1417
import {
1518
ActivityIndicator,
1619
Linking,
@@ -245,7 +248,7 @@ export class View {
245248
hasStoryWrapper: storyViewWrapper = true,
246249
} = params;
247250

248-
const onDeviceUI = this._options.liteMode ? false : params.onDeviceUI ?? true;
251+
const onDeviceUI = this._options.liteMode ? false : (params.onDeviceUI ?? true);
249252

250253
const getFullUI = (enabled: boolean): SBUI => {
251254
if (enabled) {
@@ -493,7 +496,22 @@ export class View {
493496
);
494497
} else {
495498
return (
496-
<StoryView useWrapper={storyViewWrapper} storyBackgroundColor={storyBackgroundColor} />
499+
<SafeAreaProvider>
500+
<SafeAreaView style={{ flex: 1 }}>
501+
<StatusBar hidden />
502+
<RNView
503+
style={{ flex: 1 }}
504+
accessibilityLabel={story?.id}
505+
testID={story?.id}
506+
accessible
507+
>
508+
<StoryView
509+
useWrapper={storyViewWrapper}
510+
storyBackgroundColor={storyBackgroundColor}
511+
/>
512+
</RNView>
513+
</SafeAreaView>
514+
</SafeAreaProvider>
497515
);
498516
}
499517
};

0 commit comments

Comments
 (0)