enh
This commit is contained in:
parent
3347b0f6f1
commit
7e2cca0e34
9 changed files with 153 additions and 102 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import type { UserAddress } from '@packages/shared'
|
||||
import { View, Alert, Dimensions } from 'react-native';
|
||||
import { View, Alert, Dimensions, Keyboard } from 'react-native';
|
||||
import { useRouter } from 'expo-router';
|
||||
import { AppContainer, MyText, tw, useMarkDataFetchers, MyFlatList, MyTouchableOpacity, BottomDialog, RawBottomDialog } from 'common-ui';
|
||||
import { trpc } from '@/src/trpc-client';
|
||||
|
|
@ -91,6 +91,23 @@ export default function Addresses() {
|
|||
const [editingAddress, setEditingAddress] = useState<Address | null>(null);
|
||||
// Reason a delete was refused (only address / still the default / open order) — shown in a bottom sheet.
|
||||
const [deleteError, setDeleteError] = useState<string | null>(null);
|
||||
// Size the address sheet to the form when the keyboard is closed; keep the
|
||||
// full 85% while editing so the scrollable area stays usable.
|
||||
const [formContentHeight, setFormContentHeight] = useState<number | null>(null);
|
||||
const [keyboardVisible, setKeyboardVisible] = useState(false);
|
||||
useEffect(() => {
|
||||
const show = Keyboard.addListener('keyboardDidShow', () => setKeyboardVisible(true));
|
||||
const hide = Keyboard.addListener('keyboardDidHide', () => setKeyboardVisible(false));
|
||||
return () => {
|
||||
show.remove();
|
||||
hide.remove();
|
||||
};
|
||||
}, []);
|
||||
const windowHeight = Dimensions.get('window').height;
|
||||
const maxSheetHeight = windowHeight * 0.85;
|
||||
const sheetHeight = keyboardVisible
|
||||
? maxSheetHeight
|
||||
: Math.min(maxSheetHeight, formContentHeight ?? maxSheetHeight);
|
||||
|
||||
const { data, isLoading, error, refetch } = trpc.user.address.getUserAddresses.useQuery();
|
||||
|
||||
|
|
@ -268,8 +285,9 @@ export default function Addresses() {
|
|||
/>
|
||||
|
||||
<RawBottomDialog open={modalVisible} onClose={() => setModalVisible(false)}>
|
||||
<View style={[tw`bg-white rounded-t-2xl`, { height: Dimensions.get('window').height * 0.85 }]}>
|
||||
<View style={[tw`bg-white rounded-t-2xl`, { height: sheetHeight }]}>
|
||||
<AddressForm
|
||||
onContentHeightChange={setFormContentHeight}
|
||||
onSuccess={handleAddressSubmit}
|
||||
initialValues={editingAddress ? {
|
||||
id: editingAddress.id,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import { View, ScrollView, Alert, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform } from "react-native";
|
||||
import { View, ScrollView, Alert, TextInput, ActivityIndicator } from "react-native";
|
||||
import { Image } from 'expo-image';
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { AppContainer, MyText, tw, MyTouchableOpacity, theme, BottomDialog } from "common-ui";
|
||||
|
|
@ -387,9 +387,8 @@ export default function OrderDetails() {
|
|||
|
||||
{/* Cancel Order Dialog */}
|
||||
<BottomDialog open={cancelDialogOpen} onClose={() => setCancelDialogOpen(false)}>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<MyText style={tw`text-xl font-bold text-gray-900`}>Cancel Order</MyText>
|
||||
<MyTouchableOpacity onPress={() => setCancelDialogOpen(false)}>
|
||||
<MaterialIcons name="close" size={24} color="#9CA3AF" />
|
||||
|
|
@ -428,7 +427,6 @@ export default function OrderDetails() {
|
|||
)}
|
||||
</MyTouchableOpacity>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</BottomDialog>
|
||||
|
||||
{/* Raise Complaint Dialog */}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from 'react';
|
||||
import { View, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform, Alert } from 'react-native';
|
||||
import { View, TextInput, ActivityIndicator, Alert } from 'react-native';
|
||||
import { MaterialIcons } from '@expo/vector-icons'
|
||||
import { MyText, ImageUploaderNeo, tw, MyTouchableOpacity, type ImageUploaderNeoItem, type ImageUploaderNeoPayload } from 'common-ui'
|
||||
import { trpc } from '@/src/trpc-client'
|
||||
|
|
@ -76,9 +76,8 @@ export default function ComplaintForm({ open, onClose, orderId }: ComplaintFormP
|
|||
if (!open) return null;
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<MyText style={tw`text-xl font-bold text-gray-900`}>Raise Complaint</MyText>
|
||||
<MyTouchableOpacity testID="complaint-close" onPress={onClose}>
|
||||
<MaterialIcons name="close" size={24} color="#9CA3AF" />
|
||||
|
|
@ -118,6 +117,5 @@ export default function ComplaintForm({ open, onClose, orderId }: ComplaintFormP
|
|||
)}
|
||||
</MyTouchableOpacity>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from 'react';
|
||||
import { View, Alert, KeyboardAvoidingView, Platform, TextInput, ActivityIndicator } from 'react-native';
|
||||
import { View, Alert, TextInput, ActivityIndicator } from 'react-native';
|
||||
import { MaterialIcons, Ionicons } from '@expo/vector-icons';
|
||||
import { tw, MyText, MyTouchableOpacity, BottomDialog } from 'common-ui';
|
||||
import { trpc } from '@/src/trpc-client';
|
||||
|
|
@ -80,7 +80,8 @@ const OrderMenu: React.FC<OrderMenuProps> = ({ orderId, postActionHandler }) =>
|
|||
</MyTouchableOpacity>
|
||||
|
||||
{/* Menu Dialog */}
|
||||
<BottomDialog open={open} onClose={() => setOpen(false)}>
|
||||
{open && (
|
||||
<BottomDialog open onClose={() => setOpen(false)}>
|
||||
<View style={tw`pb-8 pt-2 px-4`}>
|
||||
{/* Handle */}
|
||||
<View style={tw`items-center mb-6`}>
|
||||
|
|
@ -132,7 +133,10 @@ const OrderMenu: React.FC<OrderMenuProps> = ({ orderId, postActionHandler }) =>
|
|||
<MyTouchableOpacity
|
||||
testID="order-menu-raise-complaint"
|
||||
style={tw`flex-row items-center p-4 bg-white border border-gray-100 rounded-xl shadow-sm`}
|
||||
onPress={() => setComplaintDialogOpen(true)}
|
||||
onPress={() => {
|
||||
setOpen(false);
|
||||
setComplaintDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
<View style={tw`w-10 h-10 rounded-full bg-yellow-50 items-center justify-center mr-4`}>
|
||||
<MaterialIcons name="report-problem" size={20} color="#D97706" />
|
||||
|
|
@ -164,11 +168,12 @@ const OrderMenu: React.FC<OrderMenuProps> = ({ orderId, postActionHandler }) =>
|
|||
</View>
|
||||
</View>
|
||||
</BottomDialog>
|
||||
)}
|
||||
|
||||
{/* Edit Notes Dialog */}
|
||||
<BottomDialog open={editNotesDialogOpen} onClose={() => setEditNotesDialogOpen(false)}>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
||||
<View style={tw`p-6`}>
|
||||
{editNotesDialogOpen && (
|
||||
<BottomDialog open onClose={() => setEditNotesDialogOpen(false)}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<MyText style={tw`text-xl font-bold text-gray-900`}>Edit Instructions</MyText>
|
||||
<MyTouchableOpacity onPress={() => setEditNotesDialogOpen(false)}>
|
||||
|
|
@ -201,13 +206,13 @@ const OrderMenu: React.FC<OrderMenuProps> = ({ orderId, postActionHandler }) =>
|
|||
)}
|
||||
</MyTouchableOpacity>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</BottomDialog>
|
||||
)}
|
||||
|
||||
{/* Cancel Order Dialog */}
|
||||
<BottomDialog open={cancelDialogOpen} onClose={() => setCancelDialogOpen(false)}>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
||||
<View style={tw`p-6`}>
|
||||
{cancelDialogOpen && (
|
||||
<BottomDialog open onClose={() => setCancelDialogOpen(false)}>
|
||||
<View style={tw`p-6`}>
|
||||
<View style={tw`flex-row justify-between items-center mb-4`}>
|
||||
<MyText style={tw`text-xl font-bold text-gray-900`}>Cancel Order</MyText>
|
||||
<MyTouchableOpacity onPress={() => setCancelDialogOpen(false)}>
|
||||
|
|
@ -247,17 +252,19 @@ const OrderMenu: React.FC<OrderMenuProps> = ({ orderId, postActionHandler }) =>
|
|||
)}
|
||||
</MyTouchableOpacity>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</BottomDialog>
|
||||
)}
|
||||
|
||||
{/* Raise Complaint Dialog */}
|
||||
<BottomDialog open={complaintDialogOpen} onClose={handleComplaintClose}>
|
||||
{complaintDialogOpen && (
|
||||
<BottomDialog open onClose={handleComplaintClose}>
|
||||
<ComplaintForm
|
||||
open={complaintDialogOpen}
|
||||
open
|
||||
onClose={handleComplaintClose}
|
||||
orderId={orderId}
|
||||
/>
|
||||
</BottomDialog>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,12 +16,16 @@ type ResolvedRegion = { regionId: number; boundId: number | null };
|
|||
// Where the delivery coordinates came from, so the heading can say so.
|
||||
type LocationSource = 'device' | 'map';
|
||||
|
||||
const AddressForm: React.FC<AddressFormProps> = ({
|
||||
const AddressForm: React.FC<AddressFormProps & {
|
||||
/** Reported so a bottom sheet can size itself to the form when idle. */
|
||||
onContentHeightChange?: (height: number) => void;
|
||||
}> = ({
|
||||
onSuccess,
|
||||
initialValues,
|
||||
isEdit = false,
|
||||
draftMode = false,
|
||||
onResolvedRegion,
|
||||
onContentHeightChange,
|
||||
}) => {
|
||||
const { regionId: browsingRegionId, boundId: browsingBoundId } = useRegion();
|
||||
const deviceCoords = useLocationStore((state) => state.coords);
|
||||
|
|
@ -42,6 +46,17 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|||
const [locationSource, setLocationSource] = useState<LocationSource | null>(
|
||||
initialValues?.latitude != null && initialValues?.longitude != null ? 'device' : null
|
||||
);
|
||||
// Bottom sheets size to content when idle, but need the extra scroll room only
|
||||
// while the keyboard is up.
|
||||
const [keyboardVisible, setKeyboardVisible] = useState(false);
|
||||
useEffect(() => {
|
||||
const show = Keyboard.addListener('keyboardDidShow', () => setKeyboardVisible(true));
|
||||
const hide = Keyboard.addListener('keyboardDidHide', () => setKeyboardVisible(false));
|
||||
return () => {
|
||||
show.remove();
|
||||
hide.remove();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
|
|
@ -74,8 +89,8 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|||
setMapRegionPickerOpen(false);
|
||||
}, []);
|
||||
|
||||
// "Select in Map" (City selector and region picker): no region named, so open
|
||||
// the map straight away on the first region's bound.
|
||||
// "Select in Map" in the region picker: no region named, so open the map
|
||||
// straight away on the first region's bound.
|
||||
const openMapForFirstRegion = useCallback(() => {
|
||||
const firstRegion = regions[0] ?? null;
|
||||
setMapRegionPickerOpen(false);
|
||||
|
|
@ -215,7 +230,11 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|||
>
|
||||
<ScrollView
|
||||
style={tw`flex-1`}
|
||||
contentContainerStyle={tw`px-4 pt-4 pb-10`}
|
||||
contentContainerStyle={[
|
||||
tw`px-4 pt-4`,
|
||||
{ paddingBottom: keyboardVisible ? 96 : 40 },
|
||||
]}
|
||||
onContentSizeChange={(_width, height) => onContentHeightChange?.(height)}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
|
|
@ -337,15 +356,8 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|||
label="Select Town"
|
||||
placeholder="Select town"
|
||||
value={resolvedRegion?.regionId ?? ''}
|
||||
options={[
|
||||
...regions.map((region) => ({ label: region.name, value: region.id })),
|
||||
{ label: 'Select in Map', value: 'map' },
|
||||
]}
|
||||
options={regions.map((region) => ({ label: region.name, value: region.id }))}
|
||||
onValueChange={(value) => {
|
||||
if (value === 'map') {
|
||||
openMapForFirstRegion();
|
||||
return;
|
||||
}
|
||||
void handleCityChange(Number(value));
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -103,12 +103,6 @@ function openMapViaChooser(screen: any, regionId = 1) {
|
|||
fireEvent.press(screen.getByTestId(`address-map-region-${regionId}`))
|
||||
}
|
||||
|
||||
/** Open the map through the City picker's "Select in Map" option. */
|
||||
function openMapViaCity(screen: any) {
|
||||
fireEvent.press(screen.getByTestId('address-city'))
|
||||
fireEvent.press(screen.getByTestId('address-city-option-map'))
|
||||
}
|
||||
|
||||
function sendMapMessage(screen: any, payload: string) {
|
||||
fireEvent(screen.getByTestId('webview'), 'message', { nativeEvent: { data: payload } })
|
||||
}
|
||||
|
|
@ -207,16 +201,17 @@ describe('AddressForm', () => {
|
|||
expect(getByText('Attach a location to add address')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('ADDRF-10: opening the city picker lists the regions, "Select in Map" and no empty message', async () => {
|
||||
it('ADDRF-10: opening the city picker lists only the regions', async () => {
|
||||
denyLocation()
|
||||
const { getByTestId, getByText, queryByText } = renderForm()
|
||||
const { getByTestId, queryByTestId, queryByText } = renderForm()
|
||||
await flush()
|
||||
|
||||
fireEvent.press(getByTestId('address-city'))
|
||||
|
||||
expect(getByTestId('address-city-option-1')).toBeTruthy()
|
||||
expect(getByTestId('address-city-option-2')).toBeTruthy()
|
||||
expect(getByText('Select in Map')).toBeTruthy()
|
||||
expect(queryByTestId('address-city-option-map')).toBeNull()
|
||||
expect(queryByText('Select in Map')).toBeNull()
|
||||
expect(queryByText('No towns available')).toBeNull()
|
||||
})
|
||||
|
||||
|
|
@ -278,18 +273,6 @@ describe('AddressForm', () => {
|
|||
)
|
||||
})
|
||||
|
||||
it('ADDRF-14: "Select in Map" from the city picker opens the map at the first region centre', async () => {
|
||||
denyLocation()
|
||||
setProcedure('common.listRegions', { data: [REGION_1_CENTER, REGION_2_CENTER] })
|
||||
const { getByTestId } = renderForm()
|
||||
await flush()
|
||||
|
||||
openMapViaCity({ getByTestId } as any)
|
||||
|
||||
const webview = getByTestId('webview')
|
||||
expect(webview.props.source.uri).toBe(`${MAP_BASE}?lat=11&lng=22`)
|
||||
})
|
||||
|
||||
it('ADDRF-15: the location chooser opens the region picker and marks the current region', async () => {
|
||||
denyLocation()
|
||||
seedRegion(REGION_1, 7)
|
||||
|
|
@ -668,7 +651,7 @@ describe('AddressForm', () => {
|
|||
const { getByTestId } = renderForm()
|
||||
await flush()
|
||||
|
||||
openMapViaCity({ getByTestId } as any)
|
||||
openMapViaChooser({ getByTestId } as any)
|
||||
|
||||
const uri = getByTestId('webview').props.source.uri
|
||||
expect(uri).toContain('?lat=11')
|
||||
|
|
@ -680,7 +663,8 @@ describe('AddressForm', () => {
|
|||
const { getByTestId } = renderForm()
|
||||
await flush()
|
||||
|
||||
openMapViaCity({ getByTestId } as any)
|
||||
fireEvent.press(getByTestId('address-attach-location'))
|
||||
fireEvent.press(getByTestId('address-map-region-select-in-map'))
|
||||
|
||||
expect(getByTestId('webview').props.source.uri).toBe(MAP_BASE)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -304,12 +304,6 @@ export function AddressForm({ onSuccess, initialValues, isEdit = false, onResolv
|
|||
data-testid="address-city"
|
||||
value={resolvedRegion?.regionId ?? ''}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === 'map') {
|
||||
const firstRegion = regions[0] ?? null
|
||||
setMapCenter(firstRegion?.center ?? null)
|
||||
setMapOpen(true)
|
||||
return
|
||||
}
|
||||
void handleCityChange(Number(e.target.value))
|
||||
}}
|
||||
className="w-full rounded-lg border border-gray-200 bg-gray-50 p-3 text-base outline-none"
|
||||
|
|
@ -320,7 +314,6 @@ export function AddressForm({ onSuccess, initialValues, isEdit = false, onResolv
|
|||
{region.name}
|
||||
</option>
|
||||
))}
|
||||
<option value="map" data-testid="address-city-option-map">Select in Map</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -8595,3 +8595,43 @@ around a wait for either screen, then the dashboard is required.
|
|||
and then dropped to the login screen, skipping the conditional login. Fixed by
|
||||
attempting the login subflow on both sides of a wait for either screen.
|
||||
Left in place for inspection: slot 2118 and staff devslothook (id 10).
|
||||
|
||||
[2026-10-21 17:59:28 IST] apps/user-ui/src/components/AddressForm.tsx: increase the ScrollView bottom
|
||||
content padding (pb-10 -> pb-24) so the form can scroll far enough for the
|
||||
"Add Address"/"Update Address" submit button and its inline error to clear the
|
||||
iOS keyboard/home indicator inside the My Addresses RawBottomDialog.
|
||||
Typecheck: user-ui clean. Not mirrored to web-ui: the web Add Address form is
|
||||
not inside this native keyboard-driven RawBottomDialog (no soft keyboard).
|
||||
|
||||
[2026-10-21 18:01:40 IST] apps/user-ui address sheet: stop the fixed 85% empty height.
|
||||
- AddressForm: track keyboard visibility, paddingBottom 40 (closed) / 96 (open),
|
||||
and report its natural content height via onContentHeightChange.
|
||||
- My Addresses: sheet height = content height when the keyboard is closed (capped
|
||||
at 85%), 85% while the keyboard is open so editing still has room.
|
||||
Typecheck: user-ui clean. Web counterpart not applicable (no native keyboard /
|
||||
this sheet).
|
||||
|
||||
[2026-10-21 18:03:21 IST] Hide "Select in Map" from the City dropdown (user-ui + web-ui),
|
||||
keeping the separate map picker/location controls. Update ADDRF-10 and drop the
|
||||
city-picker map test ADDRF-14 (the chooser map test ADDRF-17 still covers it).
|
||||
Run: user-ui typecheck clean; address-form tests 36/36 (ADDRF-14 removed,
|
||||
ADDRF-10 updated, ADDRF-36/37 now use the chooser map). web-ui typecheck clean.
|
||||
|
||||
[2026-10-21 18:38:57 IST] iOS BottomDialog keyboard lift.
|
||||
- packages/ui/src/components/dialog.tsx: move the KeyboardAvoidingView outside the
|
||||
absolute dialog (backdrop absolutely fills, KAV flex-end anchors the sheet) and
|
||||
size the sheet to content up to 85%, so padding behavior actually lifts it.
|
||||
- Remove nested KeyboardAvoidingView wrappers from OrderMenu (edit notes, cancel),
|
||||
ComplaintForm, and the My Orders cancel dialog; the shared BottomDialog owns it.
|
||||
Verified: user-ui typecheck clean; order-menu 10/10; address-form + cart 146/146.
|
||||
Web-ui not affected (no shared BottomDialog).
|
||||
|
||||
[2026-10-21 18:48:27 IST] iOS My Orders: order menu opens only once.
|
||||
- BottomDialog: move the backdrop inside the KeyboardAvoidingView (drop
|
||||
pointerEvents=box-none) so outside taps reliably reach the backdrop and no
|
||||
invisible touch layer is left.
|
||||
- OrderMenu: mount each BottomDialog only while its open flag is true, so closed
|
||||
dialogs cannot leave a hidden native Modal over the order card.
|
||||
- Also: raise-complaint now closes the menu (instead of stacking a second Modal on
|
||||
top), and BottomDialog backdrop sits inside the KeyboardAvoidingView so outside
|
||||
taps reliably dismiss. Verified: user-ui typecheck clean; order-menu 10/10.
|
||||
|
|
|
|||
|
|
@ -34,35 +34,36 @@ export const BottomDialog: React.FC<DialogProps> = ({ open, onClose, children, e
|
|||
animationType="none"
|
||||
onRequestClose={enableDismiss ? onClose : undefined}
|
||||
>
|
||||
{enableDismiss ? (
|
||||
<TouchableOpacity style={styles.backdrop} activeOpacity={1} onPress={onClose} />
|
||||
) : (
|
||||
<View style={[styles.backdrop, styles.disabledBackdrop]} />
|
||||
)}
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.dialog,
|
||||
{
|
||||
transform: [{ translateY: slideAnim }],
|
||||
},
|
||||
]}
|
||||
>
|
||||
<View style={styles.handle} />
|
||||
<View style={styles.root}>
|
||||
<KeyboardAvoidingView
|
||||
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
||||
style={styles.keyboardAvoidingContainer}
|
||||
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : 0}
|
||||
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||
style={styles.keyboardAvoider}
|
||||
>
|
||||
<ScrollView
|
||||
style={styles.scrollContainer}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={true}
|
||||
{enableDismiss ? (
|
||||
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={onClose} />
|
||||
) : (
|
||||
<View style={[StyleSheet.absoluteFill, styles.disabledBackdrop]} />
|
||||
)}
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.dialog,
|
||||
{
|
||||
transform: [{ translateY: slideAnim }],
|
||||
},
|
||||
]}
|
||||
>
|
||||
{children}
|
||||
</ScrollView>
|
||||
<View style={styles.handle} />
|
||||
<ScrollView
|
||||
style={styles.scrollContainer}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={true}
|
||||
>
|
||||
{children}
|
||||
</ScrollView>
|
||||
</Animated.View>
|
||||
</KeyboardAvoidingView>
|
||||
</Animated.View>
|
||||
</View>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
@ -122,18 +123,16 @@ export const RawBottomDialog: React.FC<DialogProps> = ({ open, onClose, children
|
|||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
backdrop: {
|
||||
root: {
|
||||
flex: 1,
|
||||
backgroundColor: 'rgba(0,0,0,0.3)',
|
||||
justifyContent: 'flex-end',
|
||||
},
|
||||
disabledBackdrop: {
|
||||
pointerEvents: 'none',
|
||||
backgroundColor: 'rgba(0,0,0,0.3)',
|
||||
},
|
||||
dialog: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
width: '100%',
|
||||
backgroundColor: '#fff',
|
||||
borderTopLeftRadius: 18,
|
||||
borderTopRightRadius: 18,
|
||||
|
|
@ -155,16 +154,18 @@ const styles = StyleSheet.create({
|
|||
marginTop: 12,
|
||||
marginBottom: 8,
|
||||
},
|
||||
keyboardAvoidingContainer: {
|
||||
keyboardAvoider: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
justifyContent: 'flex-end',
|
||||
},
|
||||
scrollContainer: {
|
||||
flex: 1,
|
||||
flexGrow: 0,
|
||||
flexShrink: 1,
|
||||
width: '100%',
|
||||
},
|
||||
scrollContent: {
|
||||
flexGrow: 1,
|
||||
flexGrow: 0,
|
||||
paddingBottom: Platform.OS === 'ios' ? 40 : 20, // Extra padding for iOS keyboard
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue