diff --git a/src/@types/react-navigation.d.ts b/src/@types/react-navigation.d.ts index 0d4ec833..9a0112c6 100644 --- a/src/@types/react-navigation.d.ts +++ b/src/@types/react-navigation.d.ts @@ -151,4 +151,8 @@ declare namespace Nav { fields?: Mastodon.Source['fields'] } } + + type TabMePushStackParamList = { + 'Tab-Me-Push-Root': undefined + } } diff --git a/src/components/Emojis.tsx b/src/components/Emojis.tsx index 2b3ba57c..26afa00f 100644 --- a/src/components/Emojis.tsx +++ b/src/components/Emojis.tsx @@ -86,6 +86,7 @@ export interface Props { start: number end: number }> + maxLength?: number } const ComponentEmojis: React.FC = ({ @@ -93,6 +94,7 @@ const ComponentEmojis: React.FC = ({ value, setValue, selectionRange, + maxLength, children }) => { const { reduceMotionEnabled } = useAccessibility() @@ -125,9 +127,13 @@ const ComponentEmojis: React.FC = ({ const newTextWithSpace = ` ${emojiShortcode}${ whiteSpaceRear ? '' : ' ' }` - setValue([contentFront, newTextWithSpace, contentRear].join('')) + setValue( + [contentFront, newTextWithSpace, contentRear] + .join('') + .slice(0, maxLength) + ) } else { - setValue(`${emojiShortcode} `) + setValue(`${emojiShortcode} `.slice(0, maxLength)) } }, [value, selectionRange.current?.start, selectionRange.current?.end] diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 3aa2f457..795a07b6 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -107,6 +107,7 @@ const Input: React.FC = ({ value={value} setValue={setValue} selectionRange={selectionRange} + maxLength={options?.maxLength} > ({ - headerTitle: t('me.stacks.push.name'), - ...(Platform.OS === 'android' && { - headerCenter: () => ( - - ) - }), - headerLeft: () => navigation.pop(1)} /> - })} + options={{ + stackPresentation: 'modal', + headerShown: false + }} /> () @@ -30,7 +30,7 @@ const TabMeProfile: React.FC {({ route, navigation }) => ( - {({ route, navigation }) => ( - {({ route, navigation }) => ( - & { messageRef: RefObject }> = ({ @@ -112,7 +112,7 @@ const ScreenMeProfileFields: React.FC + {Array.from(Array(4).keys()).map(index => ( @@ -168,4 +168,4 @@ const styles = StyleSheet.create({ } }) -export default ScreenMeProfileFields +export default TabMeProfileFields diff --git a/src/screens/Tabs/Me/Profile/Name.tsx b/src/screens/Tabs/Me/Profile/Name.tsx index 06d1f6d5..cb915af7 100644 --- a/src/screens/Tabs/Me/Profile/Name.tsx +++ b/src/screens/Tabs/Me/Profile/Name.tsx @@ -11,7 +11,7 @@ import { Alert, StyleSheet } from 'react-native' import FlashMessage from 'react-native-flash-message' import { ScrollView } from 'react-native-gesture-handler' -const ScreenMeProfileName: React.FC & { messageRef: RefObject }> = ({ @@ -94,7 +94,7 @@ const ScreenMeProfileName: React.FC + & { messageRef: RefObject }> = ({ @@ -94,7 +94,7 @@ const ScreenMeProfileNote: React.FC + > = ({ navigation }) => { @@ -180,4 +180,4 @@ const ScreenMeProfileRoot: React.FC() const TabMePush: React.FC> = () => { +>> = ({ navigation }) => { const { t } = useTranslation('screenTabs') - const instanceAccount = useSelector( - getInstanceAccount, - (prev, next) => prev?.acct === next?.acct - ) - const instanceUri = useSelector(getInstanceUri) - - const dispatch = useDispatch() - const instancePush = useSelector(getInstancePush) - - const [pushEnabled, setPushEnabled] = useState() - const [pushCanAskAgain, setPushCanAskAgain] = useState() - const checkPush = async () => { - const settings = await Notifications.getPermissionsAsync() - layoutAnimation() - setPushEnabled(settings.granted) - setPushCanAskAgain(settings.canAskAgain) - } - useEffect(() => { - checkPush() - AppState.addEventListener('change', checkPush) - return () => { - AppState.removeEventListener('change', checkPush) - } - }, []) - - useEffect(() => { - dispatch(clearPushLoading()) - }, []) - - const isLoading = instancePush?.global.loading || instancePush?.decode.loading - - const alerts = useMemo(() => { - return instancePush?.alerts - ? (['follow', 'favourite', 'reblog', 'mention', 'poll'] as [ - 'follow', - 'favourite', - 'reblog', - 'mention', - 'poll' - ]).map(alert => ( - - dispatch( - updateInstancePushAlert({ - changed: alert, - alerts: { - ...instancePush?.alerts, - [alert]: { - ...instancePush?.alerts[alert], - value: !instancePush?.alerts[alert].value - } - } - }) - ) - } - /> - )) - : null - }, [pushEnabled, instancePush?.global, instancePush?.alerts, isLoading]) return ( - - {pushEnabled === false ? ( - -