enh
This commit is contained in:
parent
a09cb936c0
commit
7d33b94c09
3 changed files with 56 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import type { UserAddress } from '@packages/shared'
|
import type { UserAddress } from '@packages/shared'
|
||||||
import { View, Alert } from 'react-native';
|
import { View, Alert, Dimensions } from 'react-native';
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
import { AppContainer, MyText, tw, useMarkDataFetchers, MyFlatList, MyTouchableOpacity, BottomDialog, RawBottomDialog } from 'common-ui';
|
import { AppContainer, MyText, tw, useMarkDataFetchers, MyFlatList, MyTouchableOpacity, BottomDialog, RawBottomDialog } from 'common-ui';
|
||||||
import { trpc } from '@/src/trpc-client';
|
import { trpc } from '@/src/trpc-client';
|
||||||
|
|
@ -243,6 +243,7 @@ export default function Addresses() {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RawBottomDialog open={modalVisible} onClose={() => setModalVisible(false)}>
|
<RawBottomDialog open={modalVisible} onClose={() => setModalVisible(false)}>
|
||||||
|
<View style={[tw`bg-white rounded-t-2xl`, { height: Dimensions.get('window').height * 0.85 }]}>
|
||||||
<AddressForm
|
<AddressForm
|
||||||
onSuccess={handleAddressSubmit}
|
onSuccess={handleAddressSubmit}
|
||||||
initialValues={editingAddress ? {
|
initialValues={editingAddress ? {
|
||||||
|
|
@ -261,6 +262,7 @@ export default function Addresses() {
|
||||||
} : undefined}
|
} : undefined}
|
||||||
isEdit={!!editingAddress}
|
isEdit={!!editingAddress}
|
||||||
/>
|
/>
|
||||||
|
</View>
|
||||||
</RawBottomDialog>
|
</RawBottomDialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, ScrollView, Dimensions } from 'react-native';
|
import { View, ScrollView, KeyboardAvoidingView, Platform } from 'react-native';
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
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 } from 'common-ui';
|
import { tw, MyText, MyTouchableOpacity , Checkbox , MyTextInput , LoadingDialog } from 'common-ui';
|
||||||
import { trpc } from '../trpc-client';
|
import { trpc } from '../trpc-client';
|
||||||
import LocationAttacher from './LocationAttacher';
|
import LocationAttacher from './LocationAttacher';
|
||||||
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
|
|
||||||
import type { AddressFormProps } from '@packages/shared';
|
import type { AddressFormProps } from '@packages/shared';
|
||||||
|
|
||||||
const AddressForm: React.FC<AddressFormProps> = ({ onSuccess, initialValues, isEdit = false }) => {
|
const AddressForm: React.FC<AddressFormProps> = ({ onSuccess, initialValues, isEdit = false }) => {
|
||||||
|
|
@ -56,10 +55,15 @@ const AddressForm: React.FC<AddressFormProps> = ({ onSuccess, initialValues, isE
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KeyboardAwareScrollView
|
<KeyboardAvoidingView
|
||||||
style={[tw`px-4 pt-4 pb-32 bg-white`, {maxHeight: Dimensions.get('window').height * 0.7}]}
|
style={tw`flex-1 bg-white`}
|
||||||
keyboardShouldPersistTaps="always"
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||||
keyboardDismissMode="on-drag"
|
>
|
||||||
|
<ScrollView
|
||||||
|
style={tw`flex-1`}
|
||||||
|
contentContainerStyle={tw`px-4 pt-4 pb-10`}
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
>
|
>
|
||||||
<MyText style={tw`text-xl font-bold mb-4`}>{isEdit ? 'Edit Address' : 'Add Address'}</MyText>
|
<MyText style={tw`text-xl font-bold mb-4`}>{isEdit ? 'Edit Address' : 'Add Address'}</MyText>
|
||||||
|
|
||||||
|
|
@ -248,7 +252,8 @@ const AddressForm: React.FC<AddressFormProps> = ({ onSuccess, initialValues, isE
|
||||||
open={isSubmitting}
|
open={isSubmitting}
|
||||||
message={isEdit ? "Updating address..." : "Adding address..."}
|
message={isEdit ? "Updating address..." : "Adding address..."}
|
||||||
/>
|
/>
|
||||||
</KeyboardAwareScrollView>
|
</ScrollView>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
41
change-log.txt
Normal file
41
change-log.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
2026-10-13 13:54:47 AddressForm keyboard + layout fix (user-ui), re-applied on branch `main`.
|
||||||
|
Note: `main` is the pre-region base; its AddressForm is the older form (region dropdown + Google Maps URL paste).
|
||||||
|
These two fixes are self-contained and do not depend on the region work.
|
||||||
|
1/2 apps/user-ui/src/components/AddressForm.tsx:
|
||||||
|
- import { View, ScrollView, Dimensions } from 'react-native';
|
||||||
|
- import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
|
||||||
|
+ import { View, ScrollView, KeyboardAvoidingView, Platform } from 'react-native';
|
||||||
|
- <KeyboardAwareScrollView
|
||||||
|
- style={[tw`px-4 pt-4 pb-32 bg-white`, {maxHeight: Dimensions.get('window').height * 0.7}]}
|
||||||
|
- keyboardShouldPersistTaps="always"
|
||||||
|
- keyboardDismissMode="on-drag"
|
||||||
|
- >
|
||||||
|
+ <KeyboardAvoidingView
|
||||||
|
+ style={tw`flex-1 bg-white`}
|
||||||
|
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||||
|
+ >
|
||||||
|
+ <ScrollView
|
||||||
|
+ style={tw`flex-1`}
|
||||||
|
+ contentContainerStyle={tw`px-4 pt-4 pb-10`}
|
||||||
|
+ keyboardShouldPersistTaps="handled"
|
||||||
|
+ showsVerticalScrollIndicator={false}
|
||||||
|
+ >
|
||||||
|
...content unchanged...
|
||||||
|
- </KeyboardAwareScrollView>
|
||||||
|
+ </ScrollView>
|
||||||
|
+ </KeyboardAvoidingView>
|
||||||
|
2/2 apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx:
|
||||||
|
- import { View, Alert } from 'react-native';
|
||||||
|
+ import { View, Alert, Dimensions } from 'react-native';
|
||||||
|
- <RawBottomDialog ...><AddressForm .../></RawBottomDialog>
|
||||||
|
+ <RawBottomDialog ...>
|
||||||
|
+ <View style={[tw`bg-white rounded-t-2xl`, { height: Dimensions.get('window').height * 0.85 }]}>
|
||||||
|
+ <AddressForm .../>
|
||||||
|
+ </View>
|
||||||
|
+ </RawBottomDialog>
|
||||||
|
(RawBottomDialog renders children bare, so the form needs a bounded height.)
|
||||||
|
Why: AddressForm was the only form using react-native-keyboard-aware-scroll-view (0.9.5, pre-New-Architecture),
|
||||||
|
which mis-handles the keyboard on iOS (input focused but keyboard missing/off-screen); every other working form uses
|
||||||
|
KeyboardAvoidingView. The old `pb-32` (viewport padding) + hardcoded `maxHeight: 70%` also left a blank band and
|
||||||
|
clipped content.
|
||||||
|
No dependency added. No migration. No tests run.
|
||||||
Loading…
Add table
Reference in a new issue