enh
This commit is contained in:
parent
f9fb1c53a7
commit
7a5fc0ff67
5 changed files with 554 additions and 304 deletions
File diff suppressed because one or more lines are too long
|
|
@ -115,7 +115,7 @@ const CartAddressGate: React.FC<CartAddressGateProps> = ({ onDone, onBack }) =>
|
||||||
animationType="slide"
|
animationType="slide"
|
||||||
onRequestClose={() => setMode('none')}
|
onRequestClose={() => setMode('none')}
|
||||||
>
|
>
|
||||||
<View style={tw`flex-1 bg-white`}>
|
<View style={tw`flex-1 bg-white pb-4`}>
|
||||||
<AddressForm
|
<AddressForm
|
||||||
// "Current location" prefills the device coordinates; "another
|
// "Current location" prefills the device coordinates; "another
|
||||||
// location" starts empty so the user picks on the map.
|
// location" starts empty so the user picks on the map.
|
||||||
|
|
|
||||||
|
|
@ -281,48 +281,50 @@ const CheckoutAddressSelector: React.FC = () => {
|
||||||
|
|
||||||
{/* <BottomDialog open={showAddAddress} onClose={() => setShowAddAddress(false)}> */}
|
{/* <BottomDialog open={showAddAddress} onClose={() => setShowAddAddress(false)}> */}
|
||||||
<RawBottomDialog 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
|
const resolved = resolvedRegionRef.current;
|
||||||
onResolvedRegion={(info) => {
|
if (
|
||||||
resolvedRegionRef.current = info;
|
resolved != null &&
|
||||||
}}
|
selectedRegionId != null &&
|
||||||
onSuccess={(addressId) => {
|
resolved.regionId !== selectedRegionId
|
||||||
setShowAddAddress(false);
|
) {
|
||||||
queryClient.invalidateQueries();
|
const targetRegion = (regions ?? []).find((region) => region.id === resolved.regionId);
|
||||||
if (addressId == null) return;
|
if (!targetRegion) {
|
||||||
|
Alert.alert(
|
||||||
const resolved = resolvedRegionRef.current;
|
'Unavailable region',
|
||||||
if (
|
'This address belongs to a region that is not currently available.'
|
||||||
resolved != null &&
|
);
|
||||||
selectedRegionId != null &&
|
return;
|
||||||
resolved.regionId !== selectedRegionId
|
}
|
||||||
) {
|
// The address has been saved; only selecting it is destructive.
|
||||||
const targetRegion = (regions ?? []).find((region) => region.id === resolved.regionId);
|
confirmSwitch(targetRegion.name, () => {
|
||||||
if (!targetRegion) {
|
void (async () => {
|
||||||
Alert.alert(
|
await refreshAddresses();
|
||||||
'Unavailable region',
|
await selectAddress(addressId);
|
||||||
'This address belongs to a region that is not currently available.'
|
router.replace('/(drawer)/(tabs)/home');
|
||||||
);
|
})();
|
||||||
|
});
|
||||||
return;
|
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.
|
// Auto-select the newly added address.
|
||||||
void (async () => {
|
void (async () => {
|
||||||
await refreshAddresses();
|
await refreshAddresses();
|
||||||
await selectAddress(addressId);
|
await selectAddress(addressId);
|
||||||
})();
|
})();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</View>
|
||||||
</RawBottomDialog>
|
</RawBottomDialog>
|
||||||
{/* </BottomDialog> */}
|
{/* </BottomDialog> */}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
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 { Formik } from 'formik';
|
||||||
import * as Yup from 'yup';
|
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 MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
||||||
import { trpc } from '../trpc-client';
|
import { trpc } from '../trpc-client';
|
||||||
import LocationMapStep from './location/LocationMapStep';
|
import LocationMapStep from './location/LocationMapStep';
|
||||||
|
|
@ -492,10 +492,27 @@ const AddressForm: React.FC<AddressFormProps & {
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
|
||||||
<LoadingDialog
|
{/*
|
||||||
open={isSubmitting}
|
The submit loader is an in-tree overlay, NOT a LoadingDialog Modal.
|
||||||
message={isEdit ? "Updating address..." : "Adding address..."}
|
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. */}
|
{/* Region picker: the map opens focused on whichever region is chosen. */}
|
||||||
<BottomDialog open={mapRegionPickerOpen} onClose={closeMapRegionPicker}>
|
<BottomDialog open={mapRegionPickerOpen} onClose={closeMapRegionPicker}>
|
||||||
|
|
|
||||||
|
|
@ -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
|
--- apps/user-ui/src/components/location/neo/NeoAddressFlow.tsx
|
||||||
~ auto-select a sole address only when onClose == null && regionId == null
|
~ 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
|
+ 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.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue