← back to Beverlyhillsvideos App
components/FilmModal.tsx
90 lines
import React from 'react';
import {
Modal,
View,
StyleSheet,
TouchableOpacity,
Text,
SafeAreaView,
Platform,
StatusBar,
} from 'react-native';
import { WebView } from 'react-native-webview';
import { Colors } from '@/constants/Colors';
interface Props {
visible: boolean;
url: string;
title: string;
onClose: () => void;
}
export default function FilmModal({ visible, url, title, onClose }: Props) {
return (
<Modal
visible={visible}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={onClose}
>
<SafeAreaView style={styles.safeArea}>
<View style={styles.header}>
<Text style={styles.title} numberOfLines={1}>
{title}
</Text>
<TouchableOpacity onPress={onClose} style={styles.closeBtn} hitSlop={8}>
<Text style={styles.closeText}>Done</Text>
</TouchableOpacity>
</View>
<WebView
source={{ uri: url }}
style={styles.webview}
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction={false}
javaScriptEnabled
domStorageEnabled
originWhitelist={['https://*', 'http://*']}
contentInsetAdjustmentBehavior="automatic"
/>
</SafeAreaView>
</Modal>
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: Colors.ink,
},
header: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 16,
paddingVertical: 12,
backgroundColor: Colors.ink,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: 'rgba(255,255,255,0.15)',
},
title: {
flex: 1,
color: Colors.cream,
fontSize: 16,
fontWeight: '600',
letterSpacing: 0.3,
marginRight: 12,
},
closeBtn: {
paddingVertical: 4,
paddingHorizontal: 2,
},
closeText: {
color: Colors.gold,
fontSize: 16,
fontWeight: '600',
},
webview: {
flex: 1,
backgroundColor: Colors.ink,
},
});