import React from "react";
import { View, ScrollView, Platform, KeyboardAvoidingView } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
interface ScreenWrapProps {
children: React.ReactNode;
/** Whether the content should scroll (default: true) */
scrollable?: boolean;
/** Background color class (default: "bg-background") */
bgClass?: string;
/** Additional className for the container */
className?: string;
/** Which edges to apply safe area (default: ['top', 'left', 'right']) */
edges?: ('top' | 'bottom' | 'left' | 'right')[];
/** Whether to add keyboard avoiding behavior (default: false) */
keyboardAvoiding?: boolean;
/** Padding for content area (default: "px-5") */
paddingClass?: string;
/** Whether to apply max-width constraint for web (default: true) */
maxWidth?: boolean;
}
/**
* Consistent screen wrapper that handles:
* - Safe area insets
* - Max-width constraint for web (prevents content from stretching too wide)
* - Consistent padding
* - Optional scrolling
* - Optional keyboard avoiding behavior
*/
export function ScreenWrap({
children,
scrollable = true,
bgClass = "bg-background",
className = "",
edges = ['top', 'left', 'right'],
keyboardAvoiding = false,
paddingClass = "px-5",
maxWidth = true,
}: ScreenWrapProps) {
const content = (
{children}
);
const scrollContent = scrollable ? (
{content}
) : content;
const keyboardContent = keyboardAvoiding ? (
{scrollContent}
) : scrollContent;
return (
{keyboardContent}
);
}
/**
* Simpler wrapper for screens that don't need scrolling
* Just provides safe area and max-width constraint
*/
export function ScreenContainer({
children,
bgClass = "bg-background",
className = "",
edges = ['top', 'left', 'right'],
paddingClass = "px-5",
maxWidth = true,
}: Omit) {
return (
{children}
);
}
export default ScreenWrap;