Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "CheckOut",
"slug": "CheckOut",
"version": "1.2.7",
"version": "1.2.8",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "checkoutattendance",
Expand Down
24 changes: 6 additions & 18 deletions components/TabScreenScrollView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useRef, useCallback, useContext, forwardRef, useImperativeHandle } from 'react';
import { ScrollView, ScrollViewProps, Platform } from 'react-native';
import { useRef, useContext, forwardRef, useImperativeHandle } from 'react';
import { ScrollView, ScrollViewProps } from 'react-native';
import { BottomTabBarHeightContext } from '@react-navigation/bottom-tabs';
import { useFocusEffect } from '@react-navigation/native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Constants from 'expo-constants';
import { useConnectionContext } from '@/contexts/ConnectionContext';
Expand All @@ -27,6 +26,8 @@ const TOP_BAR_HEIGHT = 60;
const CONNECTION_BANNER_HEIGHT = 52;
// VersionUpdateBanner height: padding (14*2) + content height (~24) ≈ 56px
const VERSION_BANNER_HEIGHT = 56;
// Extra breathing room so content doesn't sit flush against the tab bar
const BOTTOM_EXTRA_PADDING = 16;

export const TabScreenScrollView = forwardRef<TabScreenScrollViewRef, TabScreenScrollViewProps>(
function TabScreenScrollView({ children, contentContainerStyle, ...props }, ref) {
Expand All @@ -37,7 +38,6 @@ export const TabScreenScrollView = forwardRef<TabScreenScrollViewRef, TabScreenS
// Only add top padding for native tabs where TopBar is absolute-positioned.
// In Expo Go, TopBar is a flex sibling so no extra padding is needed.
const topInset = isExpoGo ? 0 : insets.top + TOP_BAR_HEIGHT;
const isNativeIOS = !isExpoGo && Platform.OS === 'ios';
const { connectionState } = useConnectionContext();
const { isOutdated, isForcedUpdate } = useVersionCheckContext();
const backgroundColor = useThemeColor({}, 'background');
Expand All @@ -52,6 +52,7 @@ export const TabScreenScrollView = forwardRef<TabScreenScrollViewRef, TabScreenS

const totalBottomPadding =
bottomInset +
BOTTOM_EXTRA_PADDING +
(shouldShowConnectionBanner ? CONNECTION_BANNER_HEIGHT : 0) +
(shouldShowVersionBanner ? VERSION_BANNER_HEIGHT : 0);

Expand All @@ -65,26 +66,13 @@ export const TabScreenScrollView = forwardRef<TabScreenScrollViewRef, TabScreenS
},
}));

// Reset scroll position when tab gains focus to fix iOS content inset issues
useFocusEffect(
useCallback(() => {
if (Platform.OS === 'ios') {
// Small delay to ensure layout is complete
const timeout = setTimeout(() => {
scrollViewRef.current?.scrollTo({ y: 0, animated: false });
}, 0);
return () => clearTimeout(timeout);
}
}, [])
);

return (
<ScrollView
ref={scrollViewRef}
{...props}
style={[{ backgroundColor }, props.style]}
keyboardShouldPersistTaps="handled"
contentInsetAdjustmentBehavior={isNativeIOS ? 'scrollableAxes' : 'never'}
contentInsetAdjustmentBehavior="never"
automaticallyAdjustContentInsets={false}
scrollIndicatorInsets={{ top: topInset, bottom: totalBottomPadding }}
contentContainerStyle={[
Expand Down
Loading