diff --git a/app/app.tsx b/app/app.tsx index 9a7bd5833..97dc9d621 100644 --- a/app/app.tsx +++ b/app/app.tsx @@ -5,6 +5,7 @@ import { translate } from "./i18n" import * as React from "react" import { Alert, AppRegistry, Linking, YellowBox } from "react-native" +import { enableScreens } from "react-native-screens" import { mapping, light as lightTheme } from '@eva-design/eva' import { ApplicationProvider, IconRegistry } from 'react-native-ui-kitten' import RNExitApp from 'react-native-exit-app' @@ -21,6 +22,8 @@ import { LoadingScreen } from "./components/loading-screen" import { SaveToBookmarkScreen } from "./screens/save-to-bookmark-screen" import { StorybookUIRoot } from "../storybook" +enableScreens() + /** * Ignore some yellowbox warnings. Some of these are for deprecated functions * that we haven't gotten around to replacing yet. diff --git a/app/i18n/en.json b/app/i18n/en.json index e7de2ae7a..3a3919f2e 100644 --- a/app/i18n/en.json +++ b/app/i18n/en.json @@ -65,7 +65,6 @@ }, "readerScreen": { "emptyLabel": "No content", - "featuredLabel": "Today", "followingLabel": "Your following list" }, "receiveScreen": { diff --git a/app/i18n/zh-Hant-HK.json b/app/i18n/zh-Hant-HK.json index 66a98237e..e469ecaba 100644 --- a/app/i18n/zh-Hant-HK.json +++ b/app/i18n/zh-Hant-HK.json @@ -64,7 +64,6 @@ }, "readerScreen": { "emptyLabel": "沒有內容", - "featuredLabel": "今日", "followingLabel": "你的追蹤列表" }, "receiveScreen": { diff --git a/app/models/reader-store/reader-store.ts b/app/models/reader-store/reader-store.ts index d61ab947d..7f5b530d5 100644 --- a/app/models/reader-store/reader-store.ts +++ b/app/models/reader-store/reader-store.ts @@ -28,8 +28,6 @@ export const ReaderStoreModel = types .props({ contents: types.map(types.late(() => ContentModel)), creators: types.map(types.late(() => CreatorModel)), - featuredList: ContentList, - featuredListLastFetchedDate: types.optional(types.Date, () => new Date(0)), followedList: ContentList, bookmarkList: ContentList, followingCreators: types.array(types.safeReference(CreatorModel)), @@ -38,8 +36,6 @@ export const ReaderStoreModel = types .volatile(() => ({ isFetchingCreatorList: false, hasFetchedCreatorList: false, - isFetchingFeaturedList: false, - hasFetchedFeaturedList: false, isFetchingFollowedList: false, hasFetchedFollowedList: false, followedListLastFetchedDate: new Date(), @@ -50,20 +46,8 @@ export const ReaderStoreModel = types hasFetchedBookmarkList: false, })) .extend(withEnvironment) - .views(self => ({ - getHasSeenFeaturedListToday() { - const past = self.featuredListLastFetchedDate - const now = new Date() - return past.getFullYear() === now.getFullYear() && - past.getMonth() === now.getMonth() && - past.getDate() === now.getDate() - }, - })) .actions(self => ({ clearAllLists: () => { - self.featuredList.replace([]) - self.hasFetchedFeaturedList = false - self.featuredListLastFetchedDate = new Date(0) self.followedList.replace([]) self.hasFetchedFollowedList = false self.hasReachedEndOfFollowedList = false @@ -152,25 +136,6 @@ export const ReaderStoreModel = types self.hasFetchedCreatorList = true } }), - fetchFeaturedList: flow(function * () { - self.isFetchingFeaturedList = true - try { - const result: ContentListResult = yield self.env.likerLandAPI.fetchReaderFeatured() - switch (result.kind) { - case "ok": - self.featuredList.replace([]) - result.data.forEach((data) => { - self.featuredList.push(self.parseContentResult(data)) - }) - } - } catch (error) { - logError(error.message) - } finally { - self.isFetchingFeaturedList = false - self.hasFetchedFeaturedList = true - self.featuredListLastFetchedDate = new Date() - } - }), fetchFollowingList: flow(function * () { self.isFetchingFollowedList = true try { diff --git a/app/models/root-store/setup-root-store.ts b/app/models/root-store/setup-root-store.ts index 693761bdd..b389d7602 100644 --- a/app/models/root-store/setup-root-store.ts +++ b/app/models/root-store/setup-root-store.ts @@ -97,8 +97,6 @@ export async function setupRootStore() { readerStore: { contents, creators, - featuredListLastFetchedDate, - featuredList, // Never cache followedList, // Never cache bookmarkList, }, @@ -108,7 +106,6 @@ export async function setupRootStore() { }) => { const toBePersistedContentURLs = new Set([].concat( bookmarkList, - featuredList, followedList.slice(0, 20) )) const [toBePersistedContents, restContents] = partition( @@ -134,7 +131,6 @@ export async function setupRootStore() { readerStore: { contents: snContents, creators: snCreators, - featuredListLastFetchedDate, bookmarkList, }, statisticsRewardedStore: diff --git a/app/navigation/app-navigator.tsx b/app/navigation/app-navigator.tsx index 409467a83..4b66e5eaa 100644 --- a/app/navigation/app-navigator.tsx +++ b/app/navigation/app-navigator.tsx @@ -4,7 +4,6 @@ import { createBottomTabNavigator, } from "react-navigation" -import { ReaderNavigator } from "./reader-navigator" import { SettingsNavigator } from "./settings-navigator" import { TransferNavigator } from "./transfer-navigator" import { StakingDelegationNavigator } from "./staking-delegation-navigator" @@ -17,13 +16,14 @@ import { BookmarkScreen } from "../screens/bookmark-screen" import { ContentViewScreen } from "../screens/content-view-screen" import { CrispSupportScreen } from "../screens/crisp-support-screen" import { QrcodeScannerScreen } from "../screens/qrcode-scanner-screen" +import { ReaderScreen } from "../screens/reader-screen" import { ReceiveScreen } from "../screens/receive-screen" import { StakingRewardsWithdrawScreen } from "../screens/staking-rewards-withdraw-screen" import { color } from "../theme" const MainTabs = createBottomTabNavigator({ - Reader: ReaderNavigator, + Reader: ReaderScreen, Bookmark: BookmarkScreen, Settings: SettingsNavigator, }, { diff --git a/app/navigation/reader-navigator.tsx b/app/navigation/reader-navigator.tsx deleted file mode 100644 index 8312e90a9..000000000 --- a/app/navigation/reader-navigator.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import * as React from "react" -import { ViewStyle } from "react-native" -import { - createMaterialTopTabNavigator, - NavigationScreenProps, - NavigationRoute, - NavigationParams, - SafeAreaView, -} from "react-navigation" -import { TabBar, Tab } from "react-native-ui-kitten" -import { Icon, IconTypes } from "../components/icon" - -import { ReaderScreen } from "../screens/reader-screen" -import { color } from "../theme" - -interface ReaderTabBarProps extends NavigationScreenProps<{}> {} - -const TAB_BAR_CONTAINER: ViewStyle = { - backgroundColor: color.primary, -} -const TAB_BAR: ViewStyle = { - height: 40, - backgroundColor: TAB_BAR_CONTAINER.backgroundColor, -} -const TAB_BAR_INDICATOR: ViewStyle = { - backgroundColor: color.palette.likeCyan -} - -class ReaderTabBar extends React.Component { - _onBarSelect = (selectedIndex: number) => { - const { navigation } = this.props - navigation.navigate(navigation.state.routes[selectedIndex].routeName) - } - - render() { - const { navigation } = this.props - return ( - - - {navigation.state.routes.map(this._renderTab)} - - - ) - } - - _renderTab = (route: NavigationRoute, selectedIndex: number) => { - return ( - - ) - } - - _renderIcon = (index: number) => () => { - const { navigation } = this.props - const isSelected = navigation.state.index === index - const { routeName } = navigation.state.routes[index] - let name: IconTypes - switch (routeName) { - case "Featured": - name = "reader-featured" - break - case "Following": - name = "reader-following" - break - } - const fill = isSelected ? color.palette.likeCyan : color.palette.white - return ( - - ) - } -} - -export const ReaderNavigator = createMaterialTopTabNavigator({ - Featured: ReaderScreen, - Following: ReaderScreen, -}, { - swipeEnabled: false, - tabBarOptions: { - style: { - backgroundColor: color.primary, - }, - indicatorStyle: { - backgroundColor: color.palette.likeCyan, - }, - }, - tabBarComponent: ReaderTabBar, -}) diff --git a/app/screens/reader-screen/reader-screen.style.ts b/app/screens/reader-screen/reader-screen.style.ts new file mode 100644 index 000000000..201079ab0 --- /dev/null +++ b/app/screens/reader-screen/reader-screen.style.ts @@ -0,0 +1,17 @@ +import { + StyleSheet, + ViewStyle, +} from "react-native" + +import { color } from "../../theme" + +export const ReaderScreenStyle = StyleSheet.create({ + List: { + backgroundColor: color.palette.white, + } as ViewStyle, + Root: { + flex: 1, + alignItems: "stretch", + backgroundColor: color.primary, + } as ViewStyle, +}) diff --git a/app/screens/reader-screen/reader-screen.tsx b/app/screens/reader-screen/reader-screen.tsx index 75392154e..ab6171d9d 100644 --- a/app/screens/reader-screen/reader-screen.tsx +++ b/app/screens/reader-screen/reader-screen.tsx @@ -1,25 +1,16 @@ import * as React from "react" -import { ViewStyle } from "react-native" -import { reaction } from "mobx" import { inject, observer } from "mobx-react" import { ReaderScreenProps as Props } from "./reader-screen.props" +import { ReaderScreenStyle as Style } from "./reader-screen.style" import { Screen } from "../../components/screen" import { ContentList } from "../../components/content-list" import { Content } from "../../models/content" -import { color } from "../../theme" - import { logAnalyticsEvent } from "../../utils/analytics" -const FULL: ViewStyle = { flex: 1 } -const CONTAINER: ViewStyle = { - ...FULL, - alignItems: "stretch", -} - @inject("readerStore") @observer export class ReaderScreen extends React.Component { @@ -29,24 +20,6 @@ export class ReaderScreen extends React.Component { this.list.current.props.onRefresh() this.props.readerStore.fetchCreatorList() this.props.readerStore.fetchBookmarkList() - - // Automatically switch to following list if the user has followees - if (this.props.navigation.state.routeName === "Featured") { - reaction( - () => this.props.readerStore.hasFetchedCreatorList, - (hasFetchedCreatorList, r) => { - if (hasFetchedCreatorList) { - r.dispose() - if ( - this.props.readerStore.followingCreators.length > 0 && - this.props.navigation.state.routeName === "Featured" - ) { - this.props.navigation.navigate("Following") - } - } - } - ) - } } private onPressContentItem = (url: string) => { @@ -80,10 +53,8 @@ export class ReaderScreen extends React.Component { render() { return ( {this.renderList()} @@ -91,52 +62,25 @@ export class ReaderScreen extends React.Component { } private renderList = () => { - const { - featuredList, - followedList, - hasFetchedCreatorList, - hasFetchedFeaturedList, - hasFetchedFollowedList, - } = this.props.readerStore - switch (this.props.navigation.state.routeName) { - case "Featured": - return ( - - ) - - case "Following": - return ( - - ) - } - return null + return ( + + ) } } diff --git a/app/services/api/likerland-api.ts b/app/services/api/likerland-api.ts index 83ae4a646..5de13a946 100644 --- a/app/services/api/likerland-api.ts +++ b/app/services/api/likerland-api.ts @@ -98,25 +98,6 @@ export class LikerLandAPI { } } - /** - * Fetch a list of the reader suggestion - */ - async fetchReaderFeatured(): Promise { - const response: ApiResponse = await this.apisauce.get("/reader/works/suggest") - - if (!response.ok) { - const problem = getGeneralApiProblem(response) - if (problem) return problem - } - - try { - const data: Types.Content[] = response.data.list - return { kind: "ok", data } - } catch { - return { kind: "bad-data" } - } - } - /** * Fetch a list of content from followed authors */ diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ccf8ce476..d1e21b816 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -292,6 +292,8 @@ PODS: - React - RNLocalize (1.1.4): - React + - RNScreens (2.7.0): + - React - RNSentry (1.1.0): - React - Sentry (~> 4.4.0) @@ -351,6 +353,7 @@ DEPENDENCIES: - RNIap (from `../node_modules/react-native-iap`) - RNKeychain (from `../node_modules/react-native-keychain`) - RNLocalize (from `../node_modules/react-native-localize`) + - RNScreens (from `../node_modules/react-native-screens`) - "RNSentry (from `../node_modules/@sentry/react-native`)" - RNSVG (from `../node_modules/react-native-svg`) - yoga (from `../node_modules/react-native/ReactCommon/yoga`) @@ -472,6 +475,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-keychain" RNLocalize: :path: "../node_modules/react-native-localize" + RNScreens: + :path: "../node_modules/react-native-screens" RNSentry: :path: "../node_modules/@sentry/react-native" RNSVG: @@ -548,6 +553,7 @@ SPEC CHECKSUMS: RNIap: e75200c18ed318479a52db633dc2db2facce77ea RNKeychain: c658833a9cb2cbcba6423bdd6e16cce59e27da0e RNLocalize: 62a949d2ec5bee0eb8f39a80a48f01e2f4f67080 + RNScreens: cf198f915f8a2bf163de94ca9f5bfc8d326c3706 RNSentry: 932ac1c8b2f581b1c8be5812f88ff556c99e7fb7 RNSVG: 7e16ddfc6e00d5aa69c9eb83e699bcce5dcb85d4 SDWebImage: 7edb9c3ea661e77a66661f7f044de8c1b55d1120 diff --git a/package.json b/package.json index e7d1c747d..e62232b13 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "react-native-localize": "^1.0.0", "react-native-qrcode-svg": "^5.2.0", "react-native-randombytes": "^3.5.3", + "react-native-screens": "^2.7.0", "react-native-share-extension": "git+https://github.com/likecoin/react-native-share-extension#244989a267e4d1beb41779228ad905e5211f6bf7", "react-native-snap-carousel": "^3.9.0", "react-native-splash-screen": "3.1.1", diff --git a/yarn.lock b/yarn.lock index c3a20084b..03395b96e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9908,6 +9908,11 @@ react-native-safe-area-view@^0.14.9: dependencies: debounce "^1.2.0" +react-native-screens@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.7.0.tgz#2d3cf3c39a665e9ca1c774264fccdb90e7944047" + integrity sha512-n/23IBOkrTKCfuUd6tFeRkn3lB2QZ3cmvoubRscR0JU/Zl4/ZyKmwnFmUv1/Fr+2GH/H8UTX59kEKDYYg3dMgA== + "react-native-share-extension@git+https://github.com/likecoin/react-native-share-extension#244989a267e4d1beb41779228ad905e5211f6bf7": version "2.0.0" resolved "git+https://github.com/likecoin/react-native-share-extension#244989a267e4d1beb41779228ad905e5211f6bf7"