Skip to content

Commit fece93c

Browse files
authored
backport headers fixes (keybase#25708)
1 parent 27acf98 commit fece93c

2 files changed

Lines changed: 54 additions & 47 deletions

File tree

‎shared/fs/nav-header/mobile-header.tsx‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,51 @@ const NavMobileHeader = (props: Props) => {
4444
}, [dispatch, props.path])
4545

4646
return props.path === Constants.defaultPath ? (
47-
<>
48-
<Kb.Box2
49-
direction="vertical"
50-
fullWidth={true}
51-
style={Styles.collapseStyles([styles.headerContainer, getHeightStyle(getBaseHeight(props.path))])}
52-
centerChildren={true}
53-
>
47+
<Kb.SafeAreaViewTop>
48+
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.headerContainer} centerChildren={true}>
5449
<Kb.Text type="BodyBig">Files</Kb.Text>
5550
</Kb.Box2>
5651
<MainBanner />
57-
</>
52+
</Kb.SafeAreaViewTop>
5853
) : (
59-
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.headerContainer}>
60-
{expanded ? (
61-
<Kbfs.FolderViewFilter path={props.path} onCancel={filterDone} />
62-
) : (
63-
<Kb.Box2 direction="horizontal" fullWidth={true} style={styles.expandedTopContainer}>
64-
{props.onBack && (
65-
<Kb.BackButton
66-
badgeNumber={0 /* TODO KBFS-4109 */}
67-
onClick={props.onBack}
68-
style={styles.backButton}
69-
/>
70-
)}
71-
<Kb.Box style={styles.gap} />
72-
<Actions path={props.path} onTriggerFilterMobile={triggerFilterMobile} />
54+
<Kb.SafeAreaViewTop>
55+
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.headerContainer}>
56+
{expanded ? (
57+
<Kbfs.FolderViewFilter path={props.path} onCancel={filterDone} />
58+
) : (
59+
<Kb.Box2 direction="horizontal" fullWidth={true} style={styles.expandedTopContainer}>
60+
{props.onBack && (
61+
<Kb.BackButton
62+
badgeNumber={0 /* TODO KBFS-4109 */}
63+
onClick={props.onBack}
64+
style={styles.backButton}
65+
/>
66+
)}
67+
<Kb.Box style={styles.gap} />
68+
<Actions path={props.path} onTriggerFilterMobile={triggerFilterMobile} />
69+
</Kb.Box2>
70+
)}
71+
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.expandedTitleContainer}>
72+
<Kb.Box2
73+
direction="horizontal"
74+
fullWidth={true}
75+
alignItems="flex-start"
76+
gap="xxtiny"
77+
gapStart={true}
78+
>
79+
<Kbfs.PathStatusIcon path={props.path} showTooltipOnPressMobile={true} />
80+
<Kbfs.Filename path={props.path} selectable={true} type="BodyBig" style={styles.filename} />
81+
</Kb.Box2>
82+
<MaybePublicTag path={props.path} />
7383
</Kb.Box2>
74-
)}
75-
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.expandedTitleContainer}>
76-
<Kb.Box2 direction="horizontal" fullWidth={true} alignItems="flex-start" gap="xxtiny" gapStart={true}>
77-
<Kbfs.PathStatusIcon path={props.path} showTooltipOnPressMobile={true} />
78-
<Kbfs.Filename path={props.path} selectable={true} type="BodyBig" style={styles.filename} />
79-
</Kb.Box2>
80-
<MaybePublicTag path={props.path} />
84+
<MainBanner />
8185
</Kb.Box2>
82-
<MainBanner />
83-
</Kb.Box2>
86+
</Kb.SafeAreaViewTop>
8487
)
8588
}
8689

8790
const getBaseHeight = (path: Types.Path) => {
8891
return (
89-
Styles.statusBarHeight +
9092
44 +
9193
(path === Constants.defaultPath
9294
? Styles.headerExtraHeight
@@ -110,8 +112,6 @@ export const useHeaderHeight = (path: Types.Path) => {
110112
}
111113
}
112114

113-
const getHeightStyle = (height: number) => ({height, maxHeight: height, minHeight: height})
114-
115115
const styles = Styles.styleSheetCreate(
116116
() =>
117117
({
@@ -155,7 +155,7 @@ const styles = Styles.styleSheetCreate(
155155
borderBottomColor: Styles.globalColors.black_10,
156156
borderBottomWidth: 1,
157157
borderStyle: 'solid',
158-
paddingTop: Styles.isAndroid ? undefined : Styles.statusBarHeight,
158+
minHeight: 44,
159159
},
160160
} as const)
161161
)

‎shared/profile/user/index.tsx‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,16 @@ type ChunkType = Array<
319319
| {type: 'noFriends'; text: string}
320320
| {type: 'loading'; text: string}
321321
>
322-
class User extends React.Component<Props, State> {
322+
323+
// TODO move container and get rid of this simple wrapper
324+
const UserWrap = (p: Props) => {
325+
const insets = Kb.useSafeAreaInsets()
326+
return <User {...p} insetTop={insets.top} />
327+
}
328+
329+
type Props2 = Props & {insetTop: number}
330+
331+
class User extends React.Component<Props2, State> {
323332
static navigationOptions = {
324333
headerLeft: ({
325334
canGoBack,
@@ -340,7 +349,7 @@ class User extends React.Component<Props, State> {
340349
headerTransparent: true,
341350
}
342351

343-
constructor(props: Props) {
352+
constructor(props: Props2) {
344353
super(props)
345354
this.state = {
346355
selectedTab: usernameSelectedTab[props.username] || 'followers',
@@ -455,6 +464,11 @@ class User extends React.Component<Props, State> {
455464
}
456465
}
457466

467+
const containerStyle = {
468+
paddingTop:
469+
(Styles.isAndroid ? 56 : Styles.isTablet ? 80 : Styles.isIOS ? 46 : 80) + this.props.insetTop,
470+
}
471+
458472
return (
459473
<Kb.Reloadable
460474
reloadOnMount={true}
@@ -467,7 +481,7 @@ class User extends React.Component<Props, State> {
467481
direction="vertical"
468482
fullWidth={true}
469483
fullHeight={true}
470-
style={Styles.collapseStyles([styles.container, colorTypeToStyle(this.props.backgroundColorType)])}
484+
style={Styles.collapseStyles([containerStyle, colorTypeToStyle(this.props.backgroundColorType)])}
471485
>
472486
<Kb.Box2 direction="vertical" style={styles.innerContainer}>
473487
{!Styles.isMobile && <Measure onMeasured={this._onMeasured} />}
@@ -498,18 +512,12 @@ class User extends React.Component<Props, State> {
498512
)
499513
}
500514
}
515+
UserWrap.navigationOptions = User.navigationOptions
501516

502517
// don't bother to keep this in the store
503518
const usernameSelectedTab = {}
504519

505520
const avatarSize = 128
506-
const headerHeight = Styles.isAndroid
507-
? 56
508-
: Styles.isTablet
509-
? 80
510-
: Styles.isIOS
511-
? Styles.statusBarHeight + 46
512-
: 80
513521

514522
export const styles = Styles.styleSheetCreate(() => ({
515523
addIdentityButton: {
@@ -542,7 +550,6 @@ export const styles = Styles.styleSheetCreate(() => ({
542550
isElectron: {paddingTop: Styles.globalMargins.tiny},
543551
isMobile: {paddingBottom: Styles.globalMargins.small},
544552
}),
545-
container: {paddingTop: headerHeight},
546553
followTab: Styles.platformStyles({
547554
common: {
548555
alignItems: 'center',
@@ -657,4 +664,4 @@ export const styles = Styles.styleSheetCreate(() => ({
657664
typedBackgroundRed: {backgroundColor: Styles.globalColors.red},
658665
}))
659666

660-
export default User
667+
export default UserWrap

0 commit comments

Comments
 (0)