Skip to content

Commit 2354bd2

Browse files
authored
switch to native nav (keybase#25512)
1 parent ad54333 commit 2354bd2

15 files changed

Lines changed: 133 additions & 163 deletions

File tree

‎shared/actions/json/profile.json‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@
3131
"fullname": "string",
3232
"location": "string"
3333
},
34-
"revokeFinish": {
35-
"error?": "string"
36-
},
34+
"revokeFinish": {"error?": "string"},
3735
"finishRevoking": {},
3836
"finishedWithKeyGen": {
3937
"shouldStoreKeyOnServer": "boolean"
4038
},
4139
"generatePgp": {},
42-
"hideStellar": {
43-
"hidden": "boolean"
44-
},
40+
"hideStellar": {"hidden": "boolean"},
4541
"onClickAvatar": {
4642
"username": "string",
4743
"openWebsite?": "boolean"
@@ -56,9 +52,7 @@
5652
"username": "string",
5753
"guiID": "string"
5854
},
59-
"finishBlockUser": {
60-
"error?": "string"
61-
},
55+
"finishBlockUser": {"error?": "string"},
6256
"updateErrorText": {
6357
"errorText": "string",
6458
"errorCode?": "number"

‎shared/chat/conversation/container.tsx‎

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,30 @@ import Error from './error/container'
77
import YouAreReset from './you-are-reset'
88
import Rekey from './rekey/container'
99
import {headerNavigationOptions} from './header-area/container'
10-
import {useFocusEffect, useNavigation} from '@react-navigation/core'
11-
import {tabBarStyle} from '../../router-v2/common'
10+
import {useNavigation} from '@react-navigation/core'
1211
import type {RouteProps} from '../../router-v2/route-params'
12+
import {tabBarStyle} from '../../router-v2/common'
1313

1414
type SwitchProps = RouteProps<'chatConversation'>
1515
const hideTabBarStyle = {display: 'none'}
1616

17-
// due to timing issues if we go between convos we can 'lose track' of focus in / out
18-
// so instead we keep a count and only bring back the tab if we're entirely gone
19-
let focusRefCount = 0
20-
21-
let showDeferId: any = 0
22-
const deferChangeTabOptions = (tabNav, tabBarStyle, defer) => {
23-
if (showDeferId) {
24-
clearTimeout(showDeferId)
25-
}
26-
if (tabNav) {
27-
if (defer) {
28-
showDeferId = setTimeout(() => {
29-
tabNav.setOptions({tabBarStyle})
30-
}, 1)
31-
} else {
32-
tabNav.setOptions({tabBarStyle})
33-
}
34-
}
35-
}
36-
3717
const Conversation = (p: SwitchProps) => {
3818
const navigation = useNavigation()
3919
let tabNav: any = navigation.getParent()
4020
if (tabNav?.getState()?.type !== 'tab') {
4121
tabNav = undefined
4222
}
4323

44-
useFocusEffect(
45-
React.useCallback(() => {
46-
if (!Container.isPhone) {
47-
return
48-
}
49-
++focusRefCount
50-
deferChangeTabOptions(tabNav, hideTabBarStyle, false)
51-
return () => {
52-
--focusRefCount
53-
if (focusRefCount === 0) {
54-
deferChangeTabOptions(tabNav, tabBarStyle, true)
55-
}
56-
}
57-
}, [tabNav])
58-
)
24+
// wait till the animation is over, works but maybe we can fix the resize thing later, its an issue in react-native-screens
25+
React.useEffect(() => {
26+
const unsubscribe = navigation.addListener('transitionEnd' as any, () => {
27+
tabNav?.setOptions({tabBarStyle: hideTabBarStyle})
28+
})
29+
return () => {
30+
unsubscribe()
31+
tabNav?.setOptions({tabBarStyle})
32+
}
33+
}, [navigation, tabNav])
5934

6035
const conversationIDKey = p.route.params?.conversationIDKey ?? Constants.noConversationIDKey
6136
const type = Container.useSelector(state => {
@@ -107,6 +82,7 @@ const Conversation = (p: SwitchProps) => {
10782
Conversation.navigationOptions = ({route}) => ({
10883
...headerNavigationOptions(route),
10984
needsSafe: true,
85+
presentation: undefined,
11086
})
11187

11288
const ConversationMemoed = React.memo(Conversation)

‎shared/chat/conversation/list-area/index.native.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ import {useChatDebugDump} from '../../../constants/chat2/debug'
2222
import {usingFlashList} from './flashlist-config'
2323

2424
const List = usingFlashList ? FlashList : FlatList
25-
const debugWhichList = __DEV__ ? (
26-
<Kb.Text type="HeaderBig" style={{backgroundColor: 'red', left: 0, position: 'absolute', top: 0}}>
27-
{usingFlashList ? 'FLASH' : 'old'}
28-
</Kb.Text>
29-
) : null
3025

3126
// Bookkeep whats animating so it finishes and isn't replaced, if we've animated it we keep the key and use null
3227
const animatingMap = new Map<string, null | React.ReactElement>()
@@ -185,6 +180,12 @@ const ConversationList = React.memo(function ConversationList(p: {
185180
conversationIDKey: Types.ConversationIDKey
186181
requestScrollToBottomRef: React.MutableRefObject<(() => void) | undefined>
187182
}) {
183+
const debugWhichList = __DEV__ ? (
184+
<Kb.Text type="HeaderBig" style={{backgroundColor: 'red', left: 0, position: 'absolute', top: 0}}>
185+
{usingFlashList ? 'FLASH' : 'old'}
186+
</Kb.Text>
187+
) : null
188+
188189
// used to force a rerender when a type changes, aka placeholder resolves
189190
const [extraData, setExtraData] = React.useState(0)
190191

‎shared/chat/inbox/index.native.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ type RowItem = Types.ChatInboxRowItem
2323

2424
const usingFlashList = false
2525
const List = usingFlashList ? FlashList : FlatList
26-
const debugWhichList = __DEV__ ? (
27-
<Kb.Text type="HeaderBig" style={{backgroundColor: 'red', left: 0, position: 'absolute', top: 0}}>
28-
{usingFlashList ? 'FLASH' : 'old'}
29-
</Kb.Text>
30-
) : null
3126

3227
const NoChats = (props: {onNewChat: () => void}) => (
3328
<>
@@ -240,13 +235,21 @@ class Inbox extends React.PureComponent<T.Props, State> {
240235
}
241236

242237
render() {
238+
const debugWhichList = __DEV__ ? (
239+
<Kb.Text type="HeaderBig" style={{backgroundColor: 'red', left: 0, position: 'absolute', top: 0}}>
240+
{usingFlashList ? 'FLASH' : 'old'}
241+
</Kb.Text>
242+
) : null
243+
243244
const noChats = !this.props.neverLoaded && !this.props.isSearching && !this.props.rows.length && (
244245
<NoChats onNewChat={this.props.onNewChat} />
245246
)
246247
const floatingDivider = this.state.showFloating &&
247248
!this.props.isSearching &&
248249
this.props.allowShowFloatingButton && <BigTeamsDivider toggle={this.props.toggleSmallTeamsExpanded} />
249250

251+
const HeadComponent = <ChatInboxHeader headerContext="inbox-header" />
252+
250253
return (
251254
<Kb.ErrorBoundary>
252255
<Kb.Box style={styles.container}>
@@ -300,7 +303,6 @@ const LoadingLine = () => {
300303
</Kb.Box>
301304
) : null
302305
}
303-
const HeadComponent = <ChatInboxHeader headerContext="inbox-header" />
304306

305307
const styles = Styles.styleSheetCreate(
306308
() =>

‎shared/desktop/webpack.config.babel.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ const config = (_, {mode}) => {
6666
test: /\.jpg$/,
6767
...(isDev ? {type: 'asset/resource'} : {use: ['null-loader']}),
6868
},
69+
{
70+
include: path.resolve(
71+
__dirname,
72+
'../node_modules/@react-navigation/native-stack/node_modules/@react-navigation/elements/lib/module/assets'
73+
),
74+
test: /\.(native\.js|gif|png|jpg)$/,
75+
use: ['null-loader'],
76+
},
77+
6978
{
7079
include: path.resolve(__dirname, '../node_modules/@react-navigation/elements/lib/module/assets'),
7180
test: /\.(native\.js|gif|png|jpg)$/,

‎shared/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"@react-navigation/bottom-tabs": "6.5.4",
8383
"@react-navigation/core": "6.4.6",
8484
"@react-navigation/native": "6.1.3",
85-
"@react-navigation/stack": "6.3.12",
85+
"@react-navigation/native-stack": "6.9.10",
8686
"@reduxjs/toolkit": "1.9.2",
8787
"@shopify/flash-list": "1.4.1",
8888
"base64-js": "1.5.1",

shared/patches/@react-navigation+stack+6.3.12.patch renamed to shared/patches/@react-navigation+native-stack+6.9.10.patch

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
diff --git a/node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx b/node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx
2-
index 40f3bc1..1ed566f 100644
3-
--- a/node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx
4-
+++ b/node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx
5-
@@ -6,7 +6,7 @@ import {
1+
diff --git a/node_modules/@react-navigation/native-stack/src/navigators/createNativeStackNavigator.tsx b/node_modules/@react-navigation/native-stack/src/navigators/createNativeStackNavigator.tsx
2+
index 6ad44d2..abbb1c4 100644
3+
--- a/node_modules/@react-navigation/native-stack/src/navigators/createNativeStackNavigator.tsx
4+
+++ b/node_modules/@react-navigation/native-stack/src/navigators/createNativeStackNavigator.tsx
5+
@@ -5,7 +5,7 @@ import {
66
StackActionHelpers,
77
StackActions,
88
StackNavigationState,
@@ -11,10 +11,10 @@ index 40f3bc1..1ed566f 100644
1111
StackRouterOptions,
1212
useNavigationBuilder,
1313
} from '@react-navigation/native';
14-
@@ -20,6 +20,36 @@ import type {
15-
StackNavigationOptions,
14+
@@ -18,6 +18,37 @@ import type {
1615
} from '../types';
17-
import StackView from '../views/Stack/StackView';
16+
import NativeStackView from '../views/NativeStackView';
17+
1818
+import isEqual from 'lodash/isEqual'
1919
+
2020
+const StackRouter = options => {
@@ -45,6 +45,7 @@ index 40f3bc1..1ed566f 100644
4545
+ },
4646
+ }
4747
+}
48-
49-
type Props = DefaultNavigatorOptions<
50-
ParamListBase,
48+
+
49+
function NativeStackNavigator({
50+
id,
51+
initialRouteName,

‎shared/profile/search/bar.tsx‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ import * as Styles from '../../styles'
44
import {appendPeopleBuilder} from '../../actions/typed-routes'
55
import {useDispatch} from 'react-redux'
66

7-
type Props = {
8-
style?: Styles.StylesCrossPlatform
9-
whiteText?: boolean
10-
}
11-
12-
const ProfileSearch = (props: Props) => {
7+
const ProfileSearch = () => {
138
const dispatch = useDispatch()
149
const onSearch = React.useCallback(() => dispatch(appendPeopleBuilder()), [dispatch])
15-
const color = props.whiteText ? Styles.globalColors.white_75 : undefined
1610
return (
17-
<Kb.SearchFilter
18-
hotkey="k"
19-
icon="iconfont-search"
20-
iconColor={color}
21-
onFocus={Styles.isMobile ? undefined : onSearch}
22-
onClick={!Styles.isMobile ? undefined : onSearch}
23-
placeholderColor={color}
24-
placeholderText={`Search${Styles.isMobile ? '' : ' people'}`}
25-
size="full-width"
26-
style={Styles.collapseStyles([Styles.isMobile ? styles.filterMobile : styles.filter, props.style])}
27-
/>
11+
<Kb.Box2 direction="vertical" style={styles.container}>
12+
<Kb.SearchFilter
13+
hotkey="k"
14+
icon="iconfont-search"
15+
onFocus={Styles.isMobile ? undefined : onSearch}
16+
onClick={!Styles.isMobile ? undefined : onSearch}
17+
placeholderText={`Search${Styles.isMobile ? '' : ' people'}`}
18+
size="full-width"
19+
style={styles.filter}
20+
/>
21+
</Kb.Box2>
2822
)
2923
}
3024

3125
const styles = Styles.styleSheetCreate(() => ({
32-
filter: {
33-
marginLeft: Styles.globalMargins.xsmall,
34-
marginRight: Styles.globalMargins.xsmall,
35-
},
36-
filterMobile: {
37-
height: 40,
38-
paddingLeft: 0,
39-
paddingRight: 0,
40-
},
26+
container: Styles.platformStyles({
27+
isElectron: {width: '100%'},
28+
isMobile: {width: 215},
29+
}),
30+
filter: Styles.platformStyles({
31+
isElectron: {
32+
marginLeft: Styles.globalMargins.xsmall,
33+
marginRight: Styles.globalMargins.xsmall,
34+
},
35+
isMobile: {
36+
height: 40,
37+
paddingLeft: 0,
38+
paddingRight: 0,
39+
},
40+
}),
4141
}))
4242

4343
export default ProfileSearch

‎shared/profile/user/index.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ class User extends React.Component<Props, State> {
334334
<HeaderLeftArrow canGoBack={canGoBack} onPress={onPress} tintColor={tintColor} />
335335
</Styles.CanFixOverdrawContext.Provider>
336336
),
337+
headerShown: true,
338+
headerStyle: {backgroundColor: 'transparent'},
337339
headerTitle: () => <ProfileSearch />,
338340
headerTransparent: true,
339341
})

‎shared/router-v2/common.desktop.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import {HeaderLeftArrow} from '../common-adapters/header-hoc'
66
import {TabActions} from '@react-navigation/core'
77
import type {useSubnavTabAction as useSubnavTabActionType} from './common'
88

9-
export const headerDefaultStyle = {
10-
height: 80,
11-
}
9+
export const headerDefaultStyle = {}
1210
export const tabBarStyle = {
1311
get backgroundColor() {
1412
return Styles.globalColors.blueDarkOrGreyDarkest

0 commit comments

Comments
 (0)