Skip to content

Commit 5ef7094

Browse files
authored
Merge pull request #42 from funnyzak/feature/latest_screen
2 parents 1a1857d + 2f50463 commit 5ef7094

File tree

5 files changed

+33
-37
lines changed

5 files changed

+33
-37
lines changed

src/navigation/Navigator.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
NavigationState,
1010
PartialState,
1111
DefaultTheme,
12-
Route
12+
Route,
13+
RouteProp
1314
} from '@react-navigation/native'
1415
import { createNativeStackNavigator, NativeStackNavigationOptions } from '@react-navigation/native-stack'
1516
import { createDrawerNavigator } from '@react-navigation/drawer'
@@ -31,6 +32,7 @@ import { EdgeInsets, SafeAreaProvider, useSafeAreaInsets } from 'react-native-sa
3132
import SplashScreen from 'react-native-splash-screen'
3233
import NavigationService from './NavigationService'
3334
import { MainScreenProps, RootStackParamList, ROUTES } from './routes'
35+
import { HeaderButton } from '@src/screens/components'
3436

3537
/**
3638
* dayjs
@@ -177,6 +179,19 @@ const HotDrawerNavigator = (initialRouteName?: string) => {
177179
)
178180
}
179181

182+
const MainBottomHeaderLeft = ({ route }: { route: RouteProp<RootStackParamList> }): ReactNode => {
183+
const { theme } = useTheme()
184+
const focusRouteName = getFocusedRouteNameFromRoute(route) ?? ROUTES.HotDraw
185+
return focusRouteName === ROUTES.HotDraw ? <HeaderButton source={theme.assets.images.icons.header.more} /> : undefined
186+
}
187+
188+
const MainBottomTabHeaderRight = ({ route }: { route: RouteProp<RootStackParamList> }): ReactNode => {
189+
const { theme } = useTheme()
190+
191+
const focusRouteName = getFocusedRouteNameFromRoute(route) ?? ROUTES.HotDraw
192+
return focusRouteName === ROUTES.HotDraw ? <HeaderButton source={theme.assets.images.icons.header.stat} /> : undefined
193+
}
194+
180195
const MainAppNavigator = ({ navigation, route }: MainScreenProps) => {
181196
const insets = useSafeAreaInsets()
182197
const { unread } = useUnRead()
@@ -315,7 +330,7 @@ export const AppNavigationContainer = () => {
315330
}
316331
barStyle={theme.name === 'dark' ? 'light-content' : 'dark-content'}
317332
/>
318-
<StackNavigator.Navigator initialRouteName={!token ? ROUTES.SignIn : ROUTES.Main}>
333+
<StackNavigator.Navigator initialRouteName={!token ? ROUTES.Main : ROUTES.Main}>
319334
<StackNavigator.Screen
320335
name={ROUTES.SignIn}
321336
component={Screens.SignInScreen}
@@ -333,9 +348,11 @@ export const AppNavigationContainer = () => {
333348
component={MainAppNavigator}
334349
options={({ route }) => ({
335350
...defaultScreenOptions(theme),
336-
headerShadowVisible: ![ROUTES.HomeTabs].includes(
351+
headerShadowVisible: ![ROUTES.HotDraw].includes(
337352
getFocusedRouteNameFromRoute(route) ?? (ROUTES.Nodes as any)
338353
),
354+
headerLeft: () => MainBottomHeaderLeft({ route }),
355+
headerRight: () => MainBottomTabHeaderRight({ route }),
339356
headerTitle: getHeaderTitle(route)
340357
})}
341358
initialParams={{

src/screens/components/common/General.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const HeaderButton = ({
101101
source?: ImageSourcePropType
102102
text?: string
103103
textColor?: string
104-
onPress: () => void
104+
onPress?: () => void
105105
}) => {
106106
const { theme } = useTheme()
107107

src/screens/home/LatestTopics.tsx

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
1-
import React, { useState } from 'react'
1+
import { InterestNodesScreenProps as ScreenProps, NODE_TABS } from '@src/navigation'
2+
import { SylCommon, useTheme } from '@src/theme'
3+
import React from 'react'
4+
import { View } from 'react-native'
25
import { connect } from 'react-redux'
3-
import { View, ViewStyle, TouchableOpacity } from 'react-native'
6+
import { FetchTopicCardList } from '../components'
47

5-
import * as Actions from '@src/actions'
6-
import { translate } from '@src/i18n'
7-
import { useTheme, SylCommon } from '@src/theme'
8-
import { IState, ITheme, V2exObject } from '@src/types'
9-
import * as CompS from '../components'
10-
import { Text, Spinner, Placeholder } from '@src/components'
11-
import { LatestScreenProps as ScreenProps, ROUTES } from '@src/navigation'
12-
13-
const LatestTopics = ({ route, navigation, loading }: ScreenProps) => {
8+
const LatestTopics = ({ route, navigation }: ScreenProps) => {
149
const { theme } = useTheme()
1510
return (
16-
<View style={[SylCommon.Layout.fill, SylCommon.View.background(theme)]}>
17-
<Placeholder
18-
displayType="icon"
19-
icon={theme.assets.images.icons.placeholder.construction}
20-
placeholderText={translate(`router.${ROUTES.Latest}`) + translate('label.underConstruction')}
21-
/>
11+
<View style={[SylCommon.Layout.fill, { backgroundColor: theme.colors.background }]}>
12+
<FetchTopicCardList displayStyle="full" nodeName={NODE_TABS.LATEST} />
2213
</View>
2314
)
2415
}
2516

26-
/**
27-
* @description styles settings
28-
*/
29-
const styles = {
30-
container: (theme: ITheme): ViewStyle => ({
31-
flex: 1
32-
})
33-
}
34-
35-
const mapStateToProps = ({ ui: { login } }: { ui: IState.UIState }) => {
36-
const { error, success, loading } = login
37-
return { error, success, loading }
38-
}
39-
40-
export default connect(mapStateToProps)(LatestTopics)
17+
export default connect()(LatestTopics)

src/theme/light/assets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const Assets: IThemeAssets = {
2727
header: {
2828
back: require('@res/images/icons/header/back.png'),
2929
stat: require('@res/images/icons/header/board.png'),
30-
more: require('@res/images/icons/header/more_vert.png'),
30+
moreVert: require('@res/images/icons/header/more_vert.png'),
31+
more: require('@res/images/icons/header/more.png'),
3132
search: require('@res/images/icons/header/search.png'),
3233
star: require('@res/images/icons/header/star.png'),
3334
heart: require('@res/images/icons/header/heart.png'),

src/theme/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export interface IThemeAssets {
212212
back: ImageSourcePropType
213213
stat: ImageSourcePropType
214214
more: ImageSourcePropType
215+
moreVert: ImageSourcePropType
215216
search: ImageSourcePropType
216217
star: ImageSourcePropType
217218
heart: ImageSourcePropType

0 commit comments

Comments
 (0)