diff --git a/android/app/src/main/java/com/xmflsct/app/tooot/generated/BasePackageList.java b/android/app/src/main/java/com/xmflsct/app/tooot/generated/BasePackageList.java index 08d117d7..6124677e 100644 --- a/android/app/src/main/java/com/xmflsct/app/tooot/generated/BasePackageList.java +++ b/android/app/src/main/java/com/xmflsct/app/tooot/generated/BasePackageList.java @@ -8,8 +8,8 @@ public class BasePackageList { public List getPackageList() { return Arrays.asList( new expo.modules.application.ApplicationPackage(), - new expo.modules.constants.ConstantsPackage(), new expo.modules.av.AVPackage(), + new expo.modules.constants.ConstantsPackage(), new expo.modules.crypto.CryptoPackage(), new expo.modules.device.DevicePackage(), new expo.modules.errorrecovery.ErrorRecoveryPackage(), @@ -19,17 +19,14 @@ public class BasePackageList { new expo.modules.font.FontLoaderPackage(), new expo.modules.haptics.HapticsPackage(), new expo.modules.imageloader.ImageLoaderPackage(), - new expo.modules.permissions.PermissionsPackage(), new expo.modules.imagepicker.ImagePickerPackage(), new expo.modules.keepawake.KeepAwakePackage(), - new expo.modules.lineargradient.LinearGradientPackage(), new expo.modules.localization.LocalizationPackage(), - new expo.modules.location.LocationPackage(), new expo.modules.notifications.NotificationsPackage(), + new expo.modules.permissions.PermissionsPackage(), new expo.modules.screencapture.ScreenCapturePackage(), new expo.modules.securestore.SecureStorePackage(), new expo.modules.splashscreen.SplashScreenPackage(), - new expo.modules.sqlite.SQLitePackage(), new expo.modules.storereview.StoreReviewPackage(), new expo.modules.updates.UpdatesPackage(), new expo.modules.videothumbnails.VideoThumbnailsPackage(), diff --git a/src/@types/react-navigation.d.ts b/src/@types/react-navigation.d.ts index 9a0112c6..0d4ec833 100644 --- a/src/@types/react-navigation.d.ts +++ b/src/@types/react-navigation.d.ts @@ -151,8 +151,4 @@ declare namespace Nav { fields?: Mastodon.Source['fields'] } } - - type TabMePushStackParamList = { - 'Tab-Me-Push-Root': undefined - } } diff --git a/src/Screens.tsx b/src/Screens.tsx index 0e97e486..5cf8cf5b 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -1,3 +1,4 @@ +import { HeaderCenter, HeaderLeft } from '@components/Header' import { displayMessage, Message, removeMessage } from '@components/Message' import navigationRef from '@helpers/navigationRef' import { useNetInfo } from '@react-native-community/netinfo' @@ -171,18 +172,30 @@ const Screens: React.FC = ({ localCorrupt }) => { ({ stackPresentation: 'transparentModal', stackAnimation: 'fade', - headerShown: false - }} + headerShown: true, + headerHideShadow: true, + headerTopInsetEnabled: false, + headerStyle: { backgroundColor: 'transparent' }, + headerLeft: () => ( + navigation.goBack()} /> + ), + headerTitle: t('screenAnnouncements:heading'), + ...(Platform.OS === 'android' && { + headerCenter: () => ( + + ) + }) + })} /> = ({ localCorrupt }) => { options={{ stackPresentation: 'fullScreenModal', stackAnimation: 'fade', - headerShown: false + ...(Platform.OS === 'android' && { headerShown: false }) }} /> diff --git a/src/screens/Announcements.tsx b/src/screens/Announcements.tsx index 60468a77..4b5dc2ad 100644 --- a/src/screens/Announcements.tsx +++ b/src/screens/Announcements.tsx @@ -1,7 +1,6 @@ import analytics from '@components/analytics' import Button from '@components/Button' import haptics from '@components/haptics' -import { HeaderCenter, HeaderLeft, HeaderRight } from '@components/Header' import { ParseHTML } from '@components/Parse' import RelativeTime from '@components/RelativeTime' import { BlurView } from '@react-native-community/blur' @@ -210,28 +209,6 @@ const ScreenAnnouncements: React.FC = ({ reducedTransparencyFallbackColor={theme.backgroundDefault} > - - navigation.goBack()} - /> - - - {}} - /> - - = ({ diff --git a/src/screens/Tabs/Me.tsx b/src/screens/Tabs/Me.tsx index c512e5e2..73b06e00 100644 --- a/src/screens/Tabs/Me.tsx +++ b/src/screens/Tabs/Me.tsx @@ -109,16 +109,28 @@ const TabMe = React.memo( component={TabMeProfile} options={{ stackPresentation: 'modal', - headerShown: false + ...(Platform.OS === 'android' && { headerShown: false }) }} /> ({ stackPresentation: 'modal', - headerShown: false - }} + headerShown: true, + headerTitle: t('me.stacks.push.name'), + ...(Platform.OS === 'android' && { + headerCenter: () => ( + + ) + }), + headerLeft: () => ( + navigation.goBack()} + /> + ) + })} /> ({ stackPresentation: 'modal', - headerShown: false - }} + headerShown: true, + headerTitle: t('me.stacks.switch.name'), + ...(Platform.OS === 'android' && { + headerCenter: () => ( + + ) + }), + headerLeft: () => ( + navigation.goBack()} + /> + ) + })} /> {sharedScreens(Stack as any)} diff --git a/src/screens/Tabs/Me/Push.tsx b/src/screens/Tabs/Me/Push.tsx index 232bfe06..7f87f9ba 100644 --- a/src/screens/Tabs/Me/Push.tsx +++ b/src/screens/Tabs/Me/Push.tsx @@ -1,42 +1,157 @@ -import { HeaderCenter, HeaderLeft } from '@components/Header' -import { StackScreenProps } from '@react-navigation/stack' -import React from 'react' +import Button from '@components/Button' +import { MenuContainer, MenuRow } from '@components/Menu' +import { updateInstancePush } from '@utils/slices/instances/updatePush' +import { updateInstancePushAlert } from '@utils/slices/instances/updatePushAlert' +import { updateInstancePushDecode } from '@utils/slices/instances/updatePushDecode' +import { + clearPushLoading, + getInstanceAccount, + getInstancePush, + getInstanceUri +} from '@utils/slices/instancesSlice' +import { StyleConstants } from '@utils/styles/constants' +import layoutAnimation from '@utils/styles/layoutAnimation' +import * as Notifications from 'expo-notifications' +import * as WebBrowser from 'expo-web-browser' +import React, { useState, useEffect, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { Platform } from 'react-native' -import { createNativeStackNavigator } from 'react-native-screens/native-stack' -import TabMePushRoot from './Push/Root' +import { AppState, Linking, ScrollView } from 'react-native' +import { useDispatch, useSelector } from 'react-redux' -const Stack = createNativeStackNavigator() - -const TabMePush: React.FC> = ({ navigation }) => { +const TabMePush: React.FC = () => { 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 ( - - ( - - ) - }), - headerLeft: () => ( - navigation.goBack()} - /> - ) - }} - /> - + + {pushEnabled === false ? ( + +