import React from 'react' import { View } from 'react-native' import MaterialIcons from '@expo/vector-icons/MaterialIcons' import { usePathname, useRouter } from 'expo-router' import { tw, MyText, MyTouchableOpacity, StorageServiceCasual } from 'common-ui' import constants from '@/src/constants' interface LoginWallProps { /** Headline shown above the message. */ title?: string /** Supporting copy. */ message?: string /** When provided, a "Go Back" action is rendered under the Log In button. */ onBack?: () => void } /** * Inline login gate. Renders a "please log in" prompt instead of redirecting, so * the screen the user came from stays in the navigation stack and Back works * normally (a push-based redirect would bounce them back into the wall). */ const LoginWall: React.FC = ({ title = 'Please log in', message = 'Log in to continue.', onBack, }) => { const router = useRouter() const pathname = usePathname() const handleLogIn = async () => { try { // Remember where the user was, so login returns them to this page. await StorageServiceCasual.setItem( constants.AUTH_REDIRECT_KEY, JSON.stringify({ targetUrl: pathname, queryParams: {}, timestamp: Date.now() }) ) } catch { // ignore storage failure — still navigate to login } router.push('/(auth)/login') } return ( {title} {message} Log In {onBack && ( Go Back )} ) } export default LoginWall