From 8f8b7b41b9e9b404425edb5f7f3b8c8a5c6edcc4 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 8 May 2022 00:00:01 +0200 Subject: [PATCH 1/9] Fix Android building fail --- android/app/build.gradle | 1 - fastlane/Fastfile | 2 +- package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0568f271..3cd03925 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -79,7 +79,6 @@ import com.android.build.OutputFile project.ext.react = [ enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes", - cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../cli.js") ] apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../react.gradle") diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 57f13142..7a7cb227 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -123,7 +123,7 @@ private_lane :build_ios do end desc "Build and deploy Android app" -lane :build_android do +private_lane :build_android do sh("echo #{ENV["ANDROID_KEYSTORE"]} | base64 -d | tee #{File.expand_path('..', Dir.pwd)}/android/tooot.jks >/dev/null", log: false) case ENVIRONMENT diff --git a/package.json b/package.json index 4334f04e..3e8a9733 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "android": "react-native run-android", "iphone": "react-native run-ios", "ipad": "react-native run-ios --simulator 'iPad mini (6th generation)'", - "app:build": "bundle exec fastlane build_android", + "app:build": "bundle exec fastlane build", "release": "scripts/release.sh", "clean": "react-native-clean-project", "postinstall": "patch-package" From ed531d7371763964cb251ba0763613cda9791fd5 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 8 May 2022 00:24:15 +0200 Subject: [PATCH 2/9] Add followed by https://github.com/tooot-app/app/issues/272 --- src/i18n/en/screens/tabs.json | 1 + .../Tabs/Shared/Account/Information/Account.tsx | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/i18n/en/screens/tabs.json b/src/i18n/en/screens/tabs.json index 46a28c89..dbc17037 100644 --- a/src/i18n/en/screens/tabs.json +++ b/src/i18n/en/screens/tabs.json @@ -281,6 +281,7 @@ "accessibilityLabel": "Actions for user {{user}}", "accessibilityHint": "You can mute, block, report or share this user" }, + "followed_by": " is following you", "moved": "User moved", "created_at": "Registered on: {{date}}", "summary": { diff --git a/src/screens/Tabs/Shared/Account/Information/Account.tsx b/src/screens/Tabs/Shared/Account/Information/Account.tsx index 467b1ab0..77a03cb3 100644 --- a/src/screens/Tabs/Shared/Account/Information/Account.tsx +++ b/src/screens/Tabs/Shared/Account/Information/Account.tsx @@ -1,5 +1,6 @@ import Icon from '@components/Icon' import CustomText from '@components/Text' +import { useRelationshipQuery } from '@utils/queryHooks/relationship' import { getInstanceAccount, getInstanceUri @@ -7,6 +8,7 @@ import { import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useMemo } from 'react' +import { useTranslation } from 'react-i18next' import { View } from 'react-native' import { useSelector } from 'react-redux' import { PlaceholderLine } from 'rn-placeholder' @@ -20,6 +22,7 @@ const AccountInformationAccount: React.FC = ({ account, localInstance }) => { + const { t } = useTranslation('screenTabs') const { colors } = useTheme() const instanceAccount = useSelector( getInstanceAccount, @@ -27,6 +30,11 @@ const AccountInformationAccount: React.FC = ({ ) const instanceUri = useSelector(getInstanceUri) + const { data: relationship } = useRelationshipQuery({ + id: account!.id, + options: { enabled: account !== undefined } + }) + const movedContent = useMemo(() => { if (account?.moved) { return ( @@ -65,6 +73,11 @@ const AccountInformationAccount: React.FC = ({ @{localInstance ? instanceAccount?.acct : account?.acct} {localInstance ? `@${instanceUri}` : null} + {relationship?.followed_by ? ( + + {t('shared.account.followed_by')} + + ) : null} {movedContent} {account?.locked ? ( Date: Sun, 8 May 2022 12:15:16 +0200 Subject: [PATCH 3/9] Upload GIF using Android keyboard https://github.com/tooot-app/app/issues/261 --- package.json | 1 + src/App.tsx | 1 + src/i18n/en/common.json | 1 + src/i18n/en/screens/compose.json | 8 +++- src/screens/Compose.tsx | 1 - .../Compose/Root/Footer/Attachments.tsx | 18 +++++++-- src/screens/Compose/Root/Header/TextInput.tsx | 40 ++++++++++++++++++- .../Shared/Account/Information/Account.tsx | 2 +- yarn.lock | 5 +++ 9 files changed, 69 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3e8a9733..48e443fc 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "react-native-flash-message": "0.2.1", "react-native-gesture-handler": "2.4.1", "react-native-htmlview": "0.16.0", + "react-native-image-keyboard": "^2.2.0", "react-native-pager-view": "5.4.11", "react-native-reanimated": "2.8.0", "react-native-safe-area-context": "4.2.5", diff --git a/src/App.tsx b/src/App.tsx index 21c6fbf3..e1057e8c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,6 +19,7 @@ import * as SplashScreen from 'expo-splash-screen' import React, { useCallback, useEffect, useState } from 'react' import { AppState, LogBox, Platform } from 'react-native' import { GestureHandlerRootView } from 'react-native-gesture-handler' +import 'react-native-image-keyboard' import { enableFreeze } from 'react-native-screens' import { QueryClientProvider } from 'react-query' import { Provider } from 'react-redux' diff --git a/src/i18n/en/common.json b/src/i18n/en/common.json index 97e95f44..4b3fa57e 100644 --- a/src/i18n/en/common.json +++ b/src/i18n/en/common.json @@ -1,5 +1,6 @@ { "buttons": { + "OK": "OK", "apply": "Apply", "cancel": "Cancel" }, diff --git a/src/i18n/en/screens/compose.json b/src/i18n/en/screens/compose.json index 92e65384..10bae903 100644 --- a/src/i18n/en/screens/compose.json +++ b/src/i18n/en/screens/compose.json @@ -42,7 +42,13 @@ "placeholder": "Spoiler warning message" }, "textInput": { - "placeholder": "What's on your mind" + "placeholder": "What's on your mind", + "keyboardImage": { + "exceedMaximum": { + "title": "Maximum attachments amount reached", + "OK": "$t(common:buttons.OK)" + } + } } }, "footer": { diff --git a/src/screens/Compose.tsx b/src/screens/Compose.tsx index 285b849f..712e31db 100644 --- a/src/screens/Compose.tsx +++ b/src/screens/Compose.tsx @@ -1,4 +1,3 @@ -import apiInstance from '@api/instance' import analytics from '@components/analytics' import { HeaderLeft, HeaderRight } from '@components/Header' import { createNativeStackNavigator } from '@react-navigation/native-stack' diff --git a/src/screens/Compose/Root/Footer/Attachments.tsx b/src/screens/Compose/Root/Footer/Attachments.tsx index 0d77c515..8df70266 100644 --- a/src/screens/Compose/Root/Footer/Attachments.tsx +++ b/src/screens/Compose/Root/Footer/Attachments.tsx @@ -5,6 +5,7 @@ import Icon from '@components/Icon' import CustomText from '@components/Text' import { useActionSheet } from '@expo/react-native-action-sheet' import { useNavigation } from '@react-navigation/native' +import { getInstanceConfigurationStatusMaxAttachments } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import layoutAnimation from '@utils/styles/layoutAnimation' import { useTheme } from '@utils/styles/ThemeManager' @@ -17,8 +18,10 @@ import React, { useRef } from 'react' import { useTranslation } from 'react-i18next' -import { FlatList, Image, Pressable, StyleSheet, View } from 'react-native' +import { FlatList, Pressable, StyleSheet, View } from 'react-native' import { Circle } from 'react-native-animated-spinkit' +import FastImage from 'react-native-fast-image' +import { useSelector } from 'react-redux' import ComposeContext from '../../utils/createContext' import { ExtendedAttachment } from '../../utils/types' import chooseAndUploadAttachment from './addAttachment' @@ -33,9 +36,14 @@ const ComposeAttachments: React.FC = ({ accessibleRefAttachments }) => { const { showActionSheetWithOptions } = useActionSheet() const { composeState, composeDispatch } = useContext(ComposeContext) const { t } = useTranslation('screenCompose') - const { colors, mode } = useTheme() + const { colors } = useTheme() const navigation = useNavigation() + const maxAttachments = useSelector( + getInstanceConfigurationStatusMaxAttachments, + () => true + ) + const flatListRef = useRef(null) const sensitiveOnPress = useCallback(() => { @@ -124,7 +132,7 @@ const ComposeAttachments: React.FC = ({ accessibleRefAttachments }) => { width: calculateWidth(item) }} > - = ({ accessibleRefAttachments }) => { item.local?.uri || item.remote?.url || Math.random().toString() } ListFooterComponent={ - composeState.attachments.uploads.length < 4 ? listFooter : null + composeState.attachments.uploads.length < maxAttachments + ? listFooter + : null } /> diff --git a/src/screens/Compose/Root/Header/TextInput.tsx b/src/screens/Compose/Root/Header/TextInput.tsx index af518beb..d9325197 100644 --- a/src/screens/Compose/Root/Header/TextInput.tsx +++ b/src/screens/Compose/Root/Header/TextInput.tsx @@ -1,17 +1,25 @@ import CustomText from '@components/Text' +import { getInstanceConfigurationStatusMaxAttachments } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' -import { TextInput } from 'react-native' +import { Alert, TextInput } from 'react-native' +import { useSelector } from 'react-redux' import formatText from '../../formatText' import ComposeContext from '../../utils/createContext' +import { uploadAttachment } from '../Footer/addAttachment' const ComposeTextInput: React.FC = () => { const { composeState, composeDispatch } = useContext(ComposeContext) const { t } = useTranslation('screenCompose') const { colors, mode } = useTheme() + const maxAttachments = useSelector( + getInstanceConfigurationStatusMaxAttachments, + () => true + ) + return ( { }} ref={composeState.textInputFocus.refs.text} scrollEnabled={false} + onImageChange={({ nativeEvent }) => { + if (composeState.attachments.uploads.length >= maxAttachments) { + Alert.alert( + t( + 'content.root.header.textInput.keyboardImage.exceedMaximum.title' + ), + undefined, + [ + { + text: t( + 'content.root.header.textInput.keyboardImage.exceedMaximum.OK' + ), + style: 'default' + } + ] + ) + return + } + if (nativeEvent.linkUri) { + uploadAttachment({ + composeDispatch, + imageInfo: { + uri: nativeEvent.linkUri, + type: 'image', + width: 100, + height: 100 + } + }) + } + }} > {composeState.text.formatted} diff --git a/src/screens/Tabs/Shared/Account/Information/Account.tsx b/src/screens/Tabs/Shared/Account/Information/Account.tsx index 77a03cb3..6e4a8cbd 100644 --- a/src/screens/Tabs/Shared/Account/Information/Account.tsx +++ b/src/screens/Tabs/Shared/Account/Information/Account.tsx @@ -31,7 +31,7 @@ const AccountInformationAccount: React.FC = ({ const instanceUri = useSelector(getInstanceUri) const { data: relationship } = useRelationshipQuery({ - id: account!.id, + id: account?.id || '', options: { enabled: account !== undefined } }) diff --git a/yarn.lock b/yarn.lock index 8f67cba6..b9f41f6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6309,6 +6309,11 @@ react-native-htmlview@0.16.0: entities "^1.1.1" htmlparser2-without-node-native "^3.9.2" +react-native-image-keyboard@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/react-native-image-keyboard/-/react-native-image-keyboard-2.2.0.tgz#dc3f90aaaac20a79315015a330e62e85547e0674" + integrity sha512-2JzKCXMBYiIUR6OtGV7F/lEWqwIU/6HS1CGOBulxwYNxoa7m1nZk45hNEZPP8SA5yE2pLNXEQePjc3WGAtXo3w== + react-native-iphone-x-helper@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" From edb332bb26f782f8c591638c1036666f025c68e4 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 8 May 2022 14:27:06 +0200 Subject: [PATCH 4/9] Update Visibility.tsx https://github.com/tooot-app/app/issues/279 --- .../Shared/HeaderShared/Visibility.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/components/Timeline/Shared/HeaderShared/Visibility.tsx b/src/components/Timeline/Shared/HeaderShared/Visibility.tsx index 9d8bb2fb..45639966 100644 --- a/src/components/Timeline/Shared/HeaderShared/Visibility.tsx +++ b/src/components/Timeline/Shared/HeaderShared/Visibility.tsx @@ -15,6 +15,30 @@ const HeaderSharedVisibility = React.memo( const { colors } = useTheme() switch (visibility) { + case 'public': + return ( + + ) + case 'unlisted': + return ( + + ) case 'private': return ( Date: Sun, 8 May 2022 17:56:26 +0200 Subject: [PATCH 5/9] Using format.js https://github.com/tooot-app/app/issues/280 --- package.json | 8 +- src/App.tsx | 41 ++++- src/components/RelativeTime.tsx | 24 --- src/components/Timeline/Default.tsx | 1 + .../Timeline/Shared/HeaderDefault.tsx | 9 +- .../Timeline/Shared/HeaderShared/Created.tsx | 24 ++- src/components/Timeline/Shared/Poll.tsx | 12 +- src/i18n/de/components/relativeTime.json | 20 --- src/i18n/en/components/relativeTime.json | 20 --- src/i18n/ko/components/relativeTime.json | 20 --- src/i18n/vi/components/relativeTime.json | 20 --- src/i18n/zh-Hans/components/relativeTime.json | 20 --- src/i18n/zh-Hant/components/relativeTime.json | 20 --- src/screens/Announcements.tsx | 13 +- src/startup/timezone.ts | 12 ++ tsconfig.json | 3 +- yarn.lock | 159 +++++++++++++++++- 17 files changed, 270 insertions(+), 156 deletions(-) delete mode 100644 src/components/RelativeTime.tsx delete mode 100644 src/i18n/de/components/relativeTime.json delete mode 100644 src/i18n/en/components/relativeTime.json delete mode 100644 src/i18n/ko/components/relativeTime.json delete mode 100644 src/i18n/vi/components/relativeTime.json delete mode 100644 src/i18n/zh-Hans/components/relativeTime.json delete mode 100644 src/i18n/zh-Hant/components/relativeTime.json create mode 100644 src/startup/timezone.ts diff --git a/package.json b/package.json index 48e443fc..7e6d9894 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,12 @@ }, "dependencies": { "@expo/react-native-action-sheet": "3.13.0", + "@formatjs/intl-datetimeformat": "^5.0.2", + "@formatjs/intl-getcanonicallocales": "^1.9.2", + "@formatjs/intl-locale": "^2.4.47", + "@formatjs/intl-numberformat": "^7.4.3", + "@formatjs/intl-pluralrules": "^4.3.3", + "@formatjs/intl-relativetimeformat": "^10.0.1", "@neverdull-agency/expo-unlimited-secure-store": "1.0.10", "@react-native-async-storage/async-storage": "1.17.3", "@react-native-community/blur": "3.6.0", @@ -68,6 +74,7 @@ "react": "17.0.2", "react-dom": "17.0.2", "react-i18next": "11.16.7", + "react-intl": "^5.25.1", "react-native": "0.67.4", "react-native-animated-spinkit": "1.5.2", "react-native-base64": "^0.2.1", @@ -88,7 +95,6 @@ "react-native-tab-view": "3.1.1", "react-query": "3.38.0", "react-redux": "8.0.1", - "react-timeago": "6.2.1", "redux-persist": "6.0.0", "rn-placeholder": "3.0.3", "sentry-expo": "4.1.1", diff --git a/src/App.tsx b/src/App.tsx index e1057e8c..84c4bc99 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,31 @@ import { ActionSheetProvider } from '@expo/react-native-action-sheet' +import '@formatjs/intl-getcanonicallocales/polyfill' +import '@formatjs/intl-locale/polyfill' +import '@formatjs/intl-pluralrules/polyfill' +import '@formatjs/intl-pluralrules/locale-data/de' +import '@formatjs/intl-pluralrules/locale-data/en' +import '@formatjs/intl-pluralrules/locale-data/ko' +import '@formatjs/intl-pluralrules/locale-data/vi' +import '@formatjs/intl-pluralrules/locale-data/zh' +import '@formatjs/intl-numberformat/polyfill' +import '@formatjs/intl-numberformat/locale-data/de' +import '@formatjs/intl-numberformat/locale-data/en' +import '@formatjs/intl-numberformat/locale-data/ko' +import '@formatjs/intl-numberformat/locale-data/vi' +import '@formatjs/intl-numberformat/locale-data/zh' +import '@formatjs/intl-datetimeformat/polyfill' +import '@formatjs/intl-datetimeformat/locale-data/de' +import '@formatjs/intl-datetimeformat/locale-data/en' +import '@formatjs/intl-datetimeformat/locale-data/ko' +import '@formatjs/intl-datetimeformat/locale-data/vi' +import '@formatjs/intl-datetimeformat/locale-data/zh' +import '@formatjs/intl-datetimeformat/add-all-tz' +import '@formatjs/intl-relativetimeformat/polyfill' +import '@formatjs/intl-relativetimeformat/locale-data/de' +import '@formatjs/intl-relativetimeformat/locale-data/en' +import '@formatjs/intl-relativetimeformat/locale-data/ko' +import '@formatjs/intl-relativetimeformat/locale-data/vi' +import '@formatjs/intl-relativetimeformat/locale-data/zh' import queryClient from '@helpers/queryClient' import i18n from '@root/i18n/i18n' import Screens from '@root/Screens' @@ -6,7 +33,9 @@ import audio from '@root/startup/audio' import dev from '@root/startup/dev' import log from '@root/startup/log' import netInfo from '@root/startup/netInfo' +import push from '@root/startup/push' import sentry from '@root/startup/sentry' +import timezone from '@root/startup/timezone' import { persistor, store } from '@root/store' import AccessibilityManager from '@utils/accessibility/AccessibilityManager' import { @@ -24,7 +53,7 @@ import { enableFreeze } from 'react-native-screens' import { QueryClientProvider } from 'react-query' import { Provider } from 'react-redux' import { PersistGate } from 'redux-persist/integration/react' -import push from './startup/push' +import { IntlProvider } from 'react-intl' Platform.select({ android: LogBox.ignoreLogs(['Setting a timer for a long period of time']) @@ -34,6 +63,7 @@ dev() sentry() audio() push() +timezone() enableFreeze(true) const App: React.FC = () => { @@ -92,13 +122,18 @@ const App: React.FC = () => { const language = getSettingsLanguage(store.getState()) if (!language) { store.dispatch(changeLanguage('en')) + i18n.changeLanguage('en') + } else { + i18n.changeLanguage(language) } - i18n.changeLanguage(language) + return ( - + + + diff --git a/src/components/RelativeTime.tsx b/src/components/RelativeTime.tsx deleted file mode 100644 index 378aa878..00000000 --- a/src/components/RelativeTime.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react' -import { useTranslation } from 'react-i18next' -import { Text } from 'react-native' -import TimeAgo from 'react-timeago' -// @ts-ignore -import buildFormatter from 'react-timeago/lib/formatters/buildFormatter' - -export interface Props { - date: string | number -} - -const RelativeTime: React.FC = ({ date }) => { - const { t } = useTranslation('componentRelativeTime') - - return ( - - ) -} - -export default RelativeTime diff --git a/src/components/Timeline/Default.tsx b/src/components/Timeline/Default.tsx index 5a235b34..3605f240 100644 --- a/src/components/Timeline/Default.tsx +++ b/src/components/Timeline/Default.tsx @@ -102,6 +102,7 @@ const TimelineDefault = React.memo( queryKey={disableOnPress ? undefined : queryKey} rootQueryKey={disableOnPress ? undefined : rootQueryKey} status={actualStatus} + highlighted={highlighted} /> diff --git a/src/components/Timeline/Shared/HeaderDefault.tsx b/src/components/Timeline/Shared/HeaderDefault.tsx index 2496c2a2..b4db437b 100644 --- a/src/components/Timeline/Shared/HeaderDefault.tsx +++ b/src/components/Timeline/Shared/HeaderDefault.tsx @@ -18,9 +18,15 @@ export interface Props { queryKey?: QueryKeyTimeline rootQueryKey?: QueryKeyTimeline status: Mastodon.Status + highlighted: boolean } -const TimelineHeaderDefault = ({ queryKey, rootQueryKey, status }: Props) => { +const TimelineHeaderDefault = ({ + queryKey, + rootQueryKey, + status, + highlighted +}: Props) => { const { t } = useTranslation('componentTimeline') const navigation = useNavigation>() const { colors } = useTheme() @@ -40,6 +46,7 @@ const TimelineHeaderDefault = ({ queryKey, rootQueryKey, status }: Props) => { diff --git a/src/components/Timeline/Shared/HeaderShared/Created.tsx b/src/components/Timeline/Shared/HeaderShared/Created.tsx index 816b43f9..cd8eff38 100644 --- a/src/components/Timeline/Shared/HeaderShared/Created.tsx +++ b/src/components/Timeline/Shared/HeaderShared/Created.tsx @@ -1,25 +1,43 @@ import Icon from '@components/Icon' -import RelativeTime from '@components/RelativeTime' import CustomText from '@components/Text' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React from 'react' import { useTranslation } from 'react-i18next' +import { FormattedDate, FormattedRelativeTime, FormattedTime } from 'react-intl' export interface Props { created_at: Mastodon.Status['created_at'] | number edited_at?: Mastodon.Status['edited_at'] + highlighted: boolean } const HeaderSharedCreated = React.memo( - ({ created_at, edited_at }: Props) => { + ({ created_at, edited_at, highlighted }: Props) => { const { t } = useTranslation('componentTimeline') const { colors } = useTheme() + const actualTime = edited_at || created_at + return ( <> - + {highlighted ? ( + <> + + + ) : ( + + )} {edited_at ? ( = ({ ]} + components={[ + + ]} /> ) diff --git a/src/i18n/de/components/relativeTime.json b/src/i18n/de/components/relativeTime.json deleted file mode 100644 index afe2da03..00000000 --- a/src/i18n/de/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": "her", - "suffixFromNow": "", - "seconds": "%d Sekunden", - "minute": "etwa eine Minute", - "minutes": "%d Minuten", - "hour": "etwa eine Stunde", - "hours": "etwa %d Stunden", - "day": "1 Tag", - "days": "%d Tage", - "month": "etwa 1 Monat", - "months": "%d Monate", - "year": "etwa 1 Jahr", - "years": "%d Jahre", - "wordSeparator": "" - } -} \ No newline at end of file diff --git a/src/i18n/en/components/relativeTime.json b/src/i18n/en/components/relativeTime.json deleted file mode 100644 index 2e3a2056..00000000 --- a/src/i18n/en/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": "ago", - "suffixFromNow": "", - "seconds": "%d seconds", - "minute": "about a minute", - "minutes": "%d minutes", - "hour": "about an hour", - "hours": "about %d hours", - "day": "a day", - "days": "%d days", - "month": "about a month", - "months": "%d months", - "year": "about a year", - "years": "%d years", - "wordSeparator": " " - } -} \ No newline at end of file diff --git a/src/i18n/ko/components/relativeTime.json b/src/i18n/ko/components/relativeTime.json deleted file mode 100644 index 4d09558f..00000000 --- a/src/i18n/ko/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": "전", - "suffixFromNow": "", - "seconds": "%d초", - "minute": "약 1분", - "minutes": "%d분", - "hour": "약 1시간", - "hours": "약 %d시간", - "day": "하루", - "days": "%d일", - "month": "약 1달", - "months": "%d달", - "year": "약 1년", - "years": "%d년", - "wordSeparator": "" - } -} \ No newline at end of file diff --git a/src/i18n/vi/components/relativeTime.json b/src/i18n/vi/components/relativeTime.json deleted file mode 100644 index c5fffdb1..00000000 --- a/src/i18n/vi/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": " trước", - "suffixFromNow": "", - "seconds": "%d giây", - "minute": "một phút", - "minutes": "%d phút", - "hour": "một giờ", - "hours": "khoảng %d giờ", - "day": "một ngày", - "days": "%d ngày", - "month": "khoảng một tháng", - "months": "%d tháng", - "year": "khoảng một năm", - "years": "%d năm", - "wordSeparator": "" - } -} \ No newline at end of file diff --git a/src/i18n/zh-Hans/components/relativeTime.json b/src/i18n/zh-Hans/components/relativeTime.json deleted file mode 100644 index e9872070..00000000 --- a/src/i18n/zh-Hans/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": "前", - "suffixFromNow": "", - "seconds": "%d秒", - "minute": "1分钟", - "minutes": "%d分钟", - "hour": "1小时", - "hours": "%d小时", - "day": "1天", - "days": "%d天", - "month": "1个月", - "months": "%d月", - "year": "大约1年", - "years": "%d年", - "wordSeparator": "" - } -} \ No newline at end of file diff --git a/src/i18n/zh-Hant/components/relativeTime.json b/src/i18n/zh-Hant/components/relativeTime.json deleted file mode 100644 index 2f50ef1e..00000000 --- a/src/i18n/zh-Hant/components/relativeTime.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "strings": { - "prefixAgo": "", - "prefixFromNow": "", - "suffixAgo": "前", - "suffixFromNow": "", - "seconds": "%d 秒", - "minute": "約 1 分", - "minutes": "%d 分", - "hour": "約 1 小時", - "hours": "約 %d 小時", - "day": "1 天", - "days": "%d 天", - "month": "約 1 個月", - "months": "%d 個月", - "year": "約 1 年", - "years": "%d 年", - "wordSeparator": "" - } -} \ No newline at end of file diff --git a/src/screens/Announcements.tsx b/src/screens/Announcements.tsx index c9bfe684..b00c12f3 100644 --- a/src/screens/Announcements.tsx +++ b/src/screens/Announcements.tsx @@ -15,6 +15,7 @@ import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useCallback, useEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' +import { FormattedRelativeTime } from 'react-intl' import { Dimensions, Platform, Pressable, StyleSheet, View } from 'react-native' import { Circle } from 'react-native-animated-spinkit' import FastImage from 'react-native-fast-image' @@ -91,7 +92,17 @@ const ScreenAnnouncements: React.FC< > ]} + components={[ + + ]} /> { + log('log', 'Timezone', Localization.timezone) + if ('__setDefaultTimeZone' in Intl.DateTimeFormat) { + // @ts-ignore + Intl.DateTimeFormat.__setDefaultTimeZone(Localization.timezone) + } +} + +export default timezone diff --git a/tsconfig.json b/tsconfig.json index 86fced90..2a2c8a93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "target": "ES6", + "module": "esnext", + "target": "esnext", "allowSyntheticDefaultImports": true, "jsx": "react-native", "lib": ["dom", "esnext"], diff --git a/yarn.lock b/yarn.lock index b9f41f6f..6a11b3ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1467,6 +1467,128 @@ lodash.pick "^4.4.0" lodash.template "^4.5.0" +"@formatjs/ecma402-abstract@1.11.4": + version "1.11.4" + resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz#b962dfc4ae84361f9f08fbce411b4e4340930eda" + integrity sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw== + dependencies: + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/fast-memoize@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz#e6f5aee2e4fd0ca5edba6eba7668e2d855e0fc21" + integrity sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg== + dependencies: + tslib "^2.1.0" + +"@formatjs/icu-messageformat-parser@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz#a54293dd7f098d6a6f6a084ab08b6d54a3e8c12d" + integrity sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/icu-skeleton-parser" "1.3.6" + tslib "^2.1.0" + +"@formatjs/icu-skeleton-parser@1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz#4ce8c0737d6f07b735288177049e97acbf2e8964" + integrity sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + tslib "^2.1.0" + +"@formatjs/intl-datetimeformat@^5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@formatjs/intl-datetimeformat/-/intl-datetimeformat-5.0.2.tgz#11bf5814416c03f544e0b118789fb1497b815566" + integrity sha512-yk7CItBMgtUsub123+iqOfXoqG6JHJIl3Pke7eOYb7QFAPsOZliAJb2i0+Tr1FXWcm1PdWZVHEv6C2l4nEmQdw== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl-displaynames@5.4.3": + version "5.4.3" + resolved "https://registry.yarnpkg.com/@formatjs/intl-displaynames/-/intl-displaynames-5.4.3.tgz#e468586694350c722c7efab1a31fcde68aeaed8b" + integrity sha512-4r12A3mS5dp5hnSaQCWBuBNfi9Amgx2dzhU4lTFfhSxgb5DOAiAbMpg6+7gpWZgl4ahsj3l2r/iHIjdmdXOE2Q== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl-getcanonicallocales@1.9.2", "@formatjs/intl-getcanonicallocales@^1.9.2": + version "1.9.2" + resolved "https://registry.yarnpkg.com/@formatjs/intl-getcanonicallocales/-/intl-getcanonicallocales-1.9.2.tgz#5aab5f6ac2d923933538085eec20a19c393b6ebf" + integrity sha512-69WTStIJI2ikErOU1Il4NQKLVV8f2x6awr7+/dZz0uihuI7uQRcZtI6k/BBt4EtYaEl6w65YjUF93VuE015C0w== + dependencies: + tslib "^2.1.0" + +"@formatjs/intl-listformat@6.5.3": + version "6.5.3" + resolved "https://registry.yarnpkg.com/@formatjs/intl-listformat/-/intl-listformat-6.5.3.tgz#f29da613a8062dc3e4e3d847ba890c3ea745f051" + integrity sha512-ozpz515F/+3CU+HnLi5DYPsLa6JoCfBggBSSg/8nOB5LYSFW9+ZgNQJxJ8tdhKYeODT+4qVHX27EeJLoxLGLNg== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl-locale@^2.4.47": + version "2.4.47" + resolved "https://registry.yarnpkg.com/@formatjs/intl-locale/-/intl-locale-2.4.47.tgz#7bf66960e55e7dfa77fcc7c02ee06aea29f92eb6" + integrity sha512-yEpjx6RgVVG3pPsxb/jydhnq/A02KmjMste5U/wWxscRK0sny8LPIoBwgkOQycRoMRLNlLemJaQB7VbHZJ9OVg== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-getcanonicallocales" "1.9.2" + tslib "^2.1.0" + +"@formatjs/intl-localematcher@0.2.25": + version "0.2.25" + resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz#60892fe1b271ec35ba07a2eb018a2dd7bca6ea3a" + integrity sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA== + dependencies: + tslib "^2.1.0" + +"@formatjs/intl-numberformat@^7.4.3": + version "7.4.3" + resolved "https://registry.yarnpkg.com/@formatjs/intl-numberformat/-/intl-numberformat-7.4.3.tgz#dbf15fb6c8341088f1d526cf24d54f5388b478d1" + integrity sha512-oxhLCw00YO7brwMPqGD+ui5gdeWoMiRhqsRSqwsDSRd03aJ/N3/VZQDoxGIn3IM9bhlPM5W0ckXiXuOMFLszjw== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl-pluralrules@^4.3.3": + version "4.3.3" + resolved "https://registry.yarnpkg.com/@formatjs/intl-pluralrules/-/intl-pluralrules-4.3.3.tgz#9dc5a96175d89c8887f003eacef457a1f3003caf" + integrity sha512-NLZN8gf2qLpCuc0m565IbKLNUarEGOzk0mkdTkE4XTuNCofzoQTurW6lL3fmDlneAoYl2FiTdHa5q4o2vZF50g== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl-relativetimeformat@^10.0.1": + version "10.0.1" + resolved "https://registry.yarnpkg.com/@formatjs/intl-relativetimeformat/-/intl-relativetimeformat-10.0.1.tgz#ed5e3df104a97e3ac6386ea7e5e34adb54ac8e74" + integrity sha512-AABPQtPjFilXegQsnmVHrSlzjFNUffAEk5DgowY6b7WSwDI7g2W6QgW903/lbZ58emhphAbgHdtKeUBXqTiLpw== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/intl-localematcher" "0.2.25" + tslib "^2.1.0" + +"@formatjs/intl@2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@formatjs/intl/-/intl-2.2.1.tgz#6daf4dabed055b17f467f0aa1bc073a626bc9189" + integrity sha512-vgvyUOOrzqVaOFYzTf2d3+ToSkH2JpR7x/4U1RyoHQLmvEaTQvXJ7A2qm1Iy3brGNXC/+/7bUlc3lpH+h/LOJA== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/fast-memoize" "1.2.1" + "@formatjs/icu-messageformat-parser" "2.1.0" + "@formatjs/intl-displaynames" "5.4.3" + "@formatjs/intl-listformat" "6.5.3" + intl-messageformat "9.13.0" + tslib "^2.1.0" + "@hapi/hoek@^9.0.0": version "9.2.1" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.1.tgz#9551142a1980503752536b5050fd99f4a7f13b17" @@ -2175,6 +2297,15 @@ "@types/scheduler" "*" csstype "^3.0.2" +"@types/react@16 || 17 || 18": + version "18.0.9" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.9.tgz#d6712a38bd6cd83469603e7359511126f122e878" + integrity sha512-9bjbg1hJHUm4De19L1cHiW0Jvx3geel6Qczhjd0qY5VKVE2X5+x77YxAepuCwVh4vrgZJdgEJw48zrhRIeF4Nw== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + "@types/scheduler@*": version "0.16.2" resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" @@ -4392,6 +4523,16 @@ internal-slot@^1.0.3: has "^1.0.3" side-channel "^1.0.4" +intl-messageformat@9.13.0: + version "9.13.0" + resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-9.13.0.tgz#97360b73bd82212e4f6005c712a4a16053165468" + integrity sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/fast-memoize" "1.2.1" + "@formatjs/icu-messageformat-parser" "2.1.0" + tslib "^2.1.0" + invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -6228,6 +6369,22 @@ react-i18next@11.16.7: html-escaper "^2.0.2" html-parse-stringify "^3.0.1" +react-intl@^5.25.1: + version "5.25.1" + resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-5.25.1.tgz#68a73aefc485c9bf70062381ae7f6f4791680879" + integrity sha512-pkjdQDvpJROoXLMltkP/5mZb0/XqrqLoPGKUCfbdkP8m6U9xbK40K51Wu+a4aQqTEvEK5lHBk0fWzUV72SJ3Hg== + dependencies: + "@formatjs/ecma402-abstract" "1.11.4" + "@formatjs/icu-messageformat-parser" "2.1.0" + "@formatjs/intl" "2.2.1" + "@formatjs/intl-displaynames" "5.4.3" + "@formatjs/intl-listformat" "6.5.3" + "@types/hoist-non-react-statics" "^3.3.1" + "@types/react" "16 || 17 || 18" + hoist-non-react-statics "^3.3.2" + intl-messageformat "9.13.0" + tslib "^2.1.0" + react-is@^16.13.0, react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -7345,7 +7502,7 @@ ts-interface-checker@^0.1.9: resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== -tslib@2.4.0: +tslib@2.4.0, tslib@^2.1.0: version "2.4.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== From 8c2dcf2e7d1794eea68a7767dd4810d9ffd52b49 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 8 May 2022 22:35:43 +0200 Subject: [PATCH 6/9] Bump up RN and Expo --- .github/workflows/build.yml | 13 +- __tests__/components/Button.js | 96 - __tests__/components/Menu/Header.js | 15 - __tests__/components/Menu/Row.js | 50 - .../Menu/__snapshots__/Header.js.snap | 30 - .../components/Menu/__snapshots__/Row.js.snap | 302 -- .../Timelines/Timeline/Shared/Card.js | 59 - .../Shared/__snapshots__/Card.js.snap | 155 - .../components/__snapshots__/Button.js.snap | 474 --- android/app/build.gradle | 102 +- android/app/src/debug/AndroidManifest.xml | 2 +- .../java/com/tooot/ReactNativeFlipper.java | 3 +- android/app/src/main/AndroidManifest.xml | 2 +- .../com/xmflsct/app/tooot/MainActivity.java | 35 +- .../xmflsct/app/tooot/MainApplication.java | 8 + android/build.gradle | 25 +- android/gradle.properties | 13 +- android/gradle/wrapper/gradle-wrapper.jar | Bin 53639 -> 59536 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/gradlew | 213 +- android/settings.gradle | 6 + ios/Podfile | 17 +- ios/Podfile.lock | 809 ++--- ios/tooot.xcodeproj/project.pbxproj | 12 +- ios/tooot/AppDelegate.m | 103 - ios/tooot/AppDelegate.mm | 126 + ios/tooot/main.m | 2 +- jest.config.js | 31 - jest/async-storage.js | 3 - jest/react-native.js | 6 - jest/react-navigation.js | 14 - package.json | 50 +- patches/expo-av+10.2.1.patch | 81 - patches/expo-file-system+13.2.0.patch | 166 - src/i18n/en/_all.ts | 1 - src/i18n/ko/_all.ts | 1 - src/i18n/vi/_all.ts | 1 - src/i18n/zh-Hans/_all.ts | 1 - tsconfig.json | 3 +- yarn.lock | 2778 ++++++++++++----- 40 files changed, 2828 insertions(+), 2982 deletions(-) delete mode 100644 __tests__/components/Button.js delete mode 100644 __tests__/components/Menu/Header.js delete mode 100644 __tests__/components/Menu/Row.js delete mode 100644 __tests__/components/Menu/__snapshots__/Header.js.snap delete mode 100644 __tests__/components/Menu/__snapshots__/Row.js.snap delete mode 100644 __tests__/components/Timelines/Timeline/Shared/Card.js delete mode 100644 __tests__/components/Timelines/Timeline/Shared/__snapshots__/Card.js.snap delete mode 100644 __tests__/components/__snapshots__/Button.js.snap delete mode 100644 ios/tooot/AppDelegate.m create mode 100644 ios/tooot/AppDelegate.mm delete mode 100644 jest.config.js delete mode 100644 jest/async-storage.js delete mode 100644 jest/react-native.js delete mode 100644 jest/react-navigation.js delete mode 100644 patches/expo-av+10.2.1.patch delete mode 100644 patches/expo-file-system+13.2.0.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d107e31..91fdb20f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,17 +19,22 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - - name: -- Step 3 -- Use Expo action + - name: -- Step 3 -- Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + - name: -- Step 4 -- Use Expo action uses: expo/expo-github-action@v6 with: expo-version: 5.x username: ${{ secrets.EXPO_USERNAME }} token: ${{ secrets.EXPO_TOKEN }} - - name: -- Step 4 -- Install node dependencies + - name: -- Step 5 -- Install node dependencies run: yarn install - - name: -- Step 5 -- Install ruby dependencies + - name: -- Step 6 -- Install ruby dependencies run: bundle install - - name: -- Step 6 -- Run fastlane + - name: -- Step 7 -- Run fastlane env: DEVELOPER_DIR: /Applications/Xcode_13.3.1.app/Contents/Developer ENVIRONMENT: ${{ steps.branch.outputs.branch }} diff --git a/__tests__/components/Button.js b/__tests__/components/Button.js deleted file mode 100644 index 9a2e0b8c..00000000 --- a/__tests__/components/Button.js +++ /dev/null @@ -1,96 +0,0 @@ -import React from 'react' -import { - toBeDisabled, - toHaveStyle, - toHaveTextContent -} from '@testing-library/jest-native' -import { cleanup, fireEvent, render } from '@testing-library/react-native/pure' - -import Button from '@components/Button' - -expect.extend({ toBeDisabled, toHaveStyle, toHaveTextContent }) - -describe('Testing component button', () => { - afterEach(cleanup) - - describe('static button', () => { - it('with text only', () => { - const onPress = jest.fn() - const { getByTestId, toJSON } = render( -