This commit is contained in:
shafi54 2026-11-08 14:22:40 +05:30
parent f9fb1c53a7
commit 7a5fc0ff67
5 changed files with 554 additions and 304 deletions

File diff suppressed because one or more lines are too long

View file

@ -115,7 +115,7 @@ const CartAddressGate: React.FC<CartAddressGateProps> = ({ onDone, onBack }) =>
animationType="slide"
onRequestClose={() => setMode('none')}
>
<View style={tw`flex-1 bg-white`}>
<View style={tw`flex-1 bg-white pb-4`}>
<AddressForm
// "Current location" prefills the device coordinates; "another
// location" starts empty so the user picks on the map.

View file

@ -281,48 +281,50 @@ const CheckoutAddressSelector: React.FC = () => {
{/* <BottomDialog open={showAddAddress} onClose={() => setShowAddAddress(false)}> */}
<RawBottomDialog open={showAddAddress} onClose={() => setShowAddAddress(false)}>
{/* pb-4 keeps the form off the bottom edge of the sheet (16px). */}
<View style={tw`flex-1 bg-white pb-4`}>
<AddressForm
onResolvedRegion={(info) => {
resolvedRegionRef.current = info;
}}
onSuccess={(addressId) => {
setShowAddAddress(false);
queryClient.invalidateQueries();
if (addressId == null) return;
<AddressForm
onResolvedRegion={(info) => {
resolvedRegionRef.current = info;
}}
onSuccess={(addressId) => {
setShowAddAddress(false);
queryClient.invalidateQueries();
if (addressId == null) return;
const resolved = resolvedRegionRef.current;
if (
resolved != null &&
selectedRegionId != null &&
resolved.regionId !== selectedRegionId
) {
const targetRegion = (regions ?? []).find((region) => region.id === resolved.regionId);
if (!targetRegion) {
Alert.alert(
'Unavailable region',
'This address belongs to a region that is not currently available.'
);
const resolved = resolvedRegionRef.current;
if (
resolved != null &&
selectedRegionId != null &&
resolved.regionId !== selectedRegionId
) {
const targetRegion = (regions ?? []).find((region) => region.id === resolved.regionId);
if (!targetRegion) {
Alert.alert(
'Unavailable region',
'This address belongs to a region that is not currently available.'
);
return;
}
// The address has been saved; only selecting it is destructive.
confirmSwitch(targetRegion.name, () => {
void (async () => {
await refreshAddresses();
await selectAddress(addressId);
router.replace('/(drawer)/(tabs)/home');
})();
});
return;
}
// The address has been saved; only selecting it is destructive.
confirmSwitch(targetRegion.name, () => {
void (async () => {
await refreshAddresses();
await selectAddress(addressId);
router.replace('/(drawer)/(tabs)/home');
})();
});
return;
}
// Auto-select the newly added address.
void (async () => {
await refreshAddresses();
await selectAddress(addressId);
})();
}}
/>
// Auto-select the newly added address.
void (async () => {
await refreshAddresses();
await selectAddress(addressId);
})();
}}
/>
</View>
</RawBottomDialog>
{/* </BottomDialog> */}
</>

View file

@ -1,8 +1,8 @@
import React, { useCallback, useEffect, useState } from 'react';
import { View, Modal, ScrollView, KeyboardAvoidingView, Platform, Keyboard } from 'react-native';
import { View, Modal, ScrollView, KeyboardAvoidingView, Platform, Keyboard, StyleSheet, ActivityIndicator } from 'react-native';
import { Formik } from 'formik';
import * as Yup from 'yup';
import { tw, MyText, MyTouchableOpacity , Checkbox , MyTextInput , LoadingDialog , BottomDialog , BottomDropdown } from 'common-ui';
import { tw, MyText, MyTouchableOpacity , Checkbox , MyTextInput , BottomDialog , BottomDropdown } from 'common-ui';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import { trpc } from '../trpc-client';
import LocationMapStep from './location/LocationMapStep';
@ -492,10 +492,27 @@ const AddressForm: React.FC<AddressFormProps & {
)}
</Formik>
<LoadingDialog
open={isSubmitting}
message={isEdit ? "Updating address..." : "Adding address..."}
/>
{/*
The submit loader is an in-tree overlay, NOT a LoadingDialog Modal.
This form is itself rendered inside a Modal (cart/me sheets, the location
flow). Dismissing a nested Modal and then the hosting Modal in quick
succession leaves an invisible native layer that blocks every touch on
iOS (react-native#50152). Keeping the loader inline removes the second
Modal entirely, so closing the sheet can never strand that layer.
*/}
{isSubmitting && (
<View
testID="address-submit-overlay"
style={[StyleSheet.absoluteFill, tw`bg-black bg-opacity-40 justify-center items-center`]}
>
<View style={tw`bg-white rounded-xl p-8 items-center justify-center min-w-50 min-h-37.5 shadow-lg`}>
<ActivityIndicator size="large" color="#3B82F6" style={tw`mb-4`} />
<MyText style={tw`text-base text-gray-500 text-center`}>
{isEdit ? "Updating address..." : "Adding address..."}
</MyText>
</View>
</View>
)}
{/* Region picker: the map opens focused on whichever region is chosen. */}
<BottomDialog open={mapRegionPickerOpen} onClose={closeMapRegionPicker}>

View file

@ -1167,3 +1167,26 @@ no published region, so the switcher always stays open for an explicit pick.
--- apps/user-ui/src/components/location/neo/NeoAddressFlow.tsx
~ auto-select a sole address only when onClose == null && regionId == null
+ keep the gate up when the sole address no longer resolves to a region
[2026-11-08 14:09:38 IST] cart page: 16px bottom padding under the add-address form.
--- apps/user-ui/components/CheckoutAddressSelector.tsx
+ wrap the AddressForm in a white flex-1 view with pb-4 (16px), so the form
no longer sits flush against the bottom edge of the cart's bottom sheet.
--- apps/user-ui/components/CartAddressGate.tsx
+ same 16px bottom padding on the first-address form (the other add-address
surface on the cart page).
[2026-11-08 14:22:10 IST] cart add-address: fix the invisible touch-blocking layer after a successful save.
On iOS a Modal that is dismissed while another Modal is presenting/dismissing can
leave an empty native layer that swallows every touch (react-native#50152). The
address form rendered its submit loader as a nested <Modal> (LoadingDialog) inside
the sheet's Modal, so saving closed the loader and the sheet 350ms apart — the
race that leaves the app unresponsive on the cart page.
--- apps/user-ui/src/components/AddressForm.tsx
- submit <LoadingDialog> (a nested Modal)
+ inline absolute-fill overlay with the same ActivityIndicator + message, inside
the form's KeyboardAvoidingView; no second native modal, so nothing can be left
behind when the host sheet closes.