react-native-unit-components
Version:
Unit React Native components
41 lines (37 loc) • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.overFullScreenHeight = exports.VERTICAL_PADDING = exports.TOP_PADDING = exports.RIGHT_PADDING = exports.LEFT_PADDING = exports.BOTTOM_SHEET_OVER_FULLSCREEN_PERCENTAGE_SIZE = exports.BOTTOM_PADDING = void 0;
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
const BOTTOM_SHEET_OVER_FULLSCREEN_PERCENTAGE_SIZE = exports.BOTTOM_SHEET_OVER_FULLSCREEN_PERCENTAGE_SIZE = 0.9;
const windowHeight = _reactNative.Dimensions.get('window').height;
const screenHeight = _reactNative.Dimensions.get('screen').height;
const statusBarHeight = _reactNativeSafeAreaContext.initialWindowMetrics?.insets.top ?? 0;
const isAndroid = _reactNative.Platform.OS === 'android';
const isAndroid15AndAbove = isAndroid && _reactNative.Platform.Version >= 35;
// Android 15+ edge-to-edge detection
const isEdgeToEdgeActive = isAndroid15AndAbove && Math.abs(screenHeight - windowHeight) < 10;
// Calculate overFullScreenHeight based on platform
const calculateOverFullScreenHeight = () => {
if (!isAndroid) {
// iOS: simple percentage of window height
return windowHeight * BOTTOM_SHEET_OVER_FULLSCREEN_PERCENTAGE_SIZE;
}
// Android: adjust for edge-to-edge status
const topMargin = screenHeight * (1 - BOTTOM_SHEET_OVER_FULLSCREEN_PERCENTAGE_SIZE);
if (isEdgeToEdgeActive) {
return screenHeight - topMargin;
} else {
// Edge-to-edge opted out: status bar is outside window, adjust margin
return windowHeight - (topMargin - statusBarHeight);
}
};
const overFullScreenHeight = exports.overFullScreenHeight = calculateOverFullScreenHeight();
const TOP_PADDING = exports.TOP_PADDING = 48;
const BOTTOM_PADDING = exports.BOTTOM_PADDING = 24;
const LEFT_PADDING = exports.LEFT_PADDING = 24;
const RIGHT_PADDING = exports.RIGHT_PADDING = 24;
const VERTICAL_PADDING = exports.VERTICAL_PADDING = TOP_PADDING + BOTTOM_PADDING; // For adjusting injected height
//# sourceMappingURL=UNBottomSheetComponent.constants.js.map