Skip to content

Commit 6ae7772

Browse files
chrisbobbegnprice
authored andcommitted
offline notice: Move to always be at top of screen, just below top inset
We want to try making the OfflineNotice a surface that fills the top inset, instead of being a bar that cuts through the middle of an existing surface. Toward that goal, make it so OfflineNotice abuts the top inset, to simplify the diff when it starts actually covering the top inset. In some cases, the OfflineNotice is already where we want it to be. In all cases, take care to make sure the OfflineNotice isn't cut off before it reaches the the extreme left and right of the screen. In ModalNavBar and ModalSearchNavBar, we do so by moving two sets of horizontal padding inward to the view that's styled `styles.contentArea`, and putting the OfflineNotice outside that view: automatic inset padding from a SafeAreaView, and our own added padding of 4px. Having done that, remove an old comment whose explanation would now be wrong about why we have the inner view.
1 parent 07de661 commit 6ae7772

File tree

3 files changed

+27
-46
lines changed

3 files changed

+27
-46
lines changed

src/nav/ChatNavBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export default function ChatNavBar(props: {|
164164
backgroundColor: streamColor,
165165
}}
166166
>
167+
<OfflineNotice />
167168
{/* This SafeAreaView is the app bar:
168169
https://material.io/components/app-bars-top#specs */}
169170
<SafeAreaView
@@ -194,7 +195,6 @@ export default function ChatNavBar(props: {|
194195
textColor={textColor}
195196
/>
196197
</SafeAreaView>
197-
<OfflineNotice />
198198
</>
199199
);
200200
}

src/nav/ModalNavBar.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow strict-local */
22
import React, { useContext, useMemo } from 'react';
33
import type { Node } from 'react';
4-
import { View } from 'react-native';
54
import { SafeAreaView } from 'react-native-safe-area-context';
65

76
import type { LocalizableReactText } from '../types';
@@ -42,37 +41,28 @@ export default function ModalNavBar(props: Props): Node {
4241
{ flex: 1 },
4342
canGoBack ? { marginStart: 20, marginEnd: 8 } : { marginHorizontal: 8 },
4443
],
45-
safeAreaView: {
44+
surface: {
4645
borderColor: 'hsla(0, 0%, 50%, 0.25)',
4746
borderBottomWidth: 1,
4847
backgroundColor,
49-
paddingHorizontal: 4,
5048
},
5149
contentArea: {
52-
// We should really be able to put this in styles.safeAreaView, and
53-
// it should control the height of the "content area" of that view,
54-
// excluding padding. But SafeAreaView seems to take `height` and
55-
// `minHeight` as controlling the height of everything including the
56-
// automatic vertical padding. So, we've added this separate View.
5750
minHeight: NAVBAR_SIZE,
58-
5951
flexDirection: 'row',
6052
alignItems: 'center',
53+
paddingHorizontal: 4,
6154
},
6255
}),
6356
[canGoBack, backgroundColor],
6457
);
6558

6659
return (
67-
<>
68-
<SafeAreaView mode="padding" edges={['top', 'right', 'left']} style={styles.safeAreaView}>
69-
{/* See comment on styles.contentArea.minHeight. */}
70-
<View style={styles.contentArea}>
71-
{canGoBack && <NavBarBackButton />}
72-
<ZulipTextIntl style={styles.text} text={title} numberOfLines={1} ellipsizeMode="tail" />
73-
</View>
74-
</SafeAreaView>
60+
<SafeAreaView mode="padding" edges={['top']} style={styles.surface}>
7561
<OfflineNotice />
76-
</>
62+
<SafeAreaView mode="padding" edges={['right', 'left']} style={styles.contentArea}>
63+
{canGoBack && <NavBarBackButton />}
64+
<ZulipTextIntl style={styles.text} text={title} numberOfLines={1} ellipsizeMode="tail" />
65+
</SafeAreaView>
66+
</SafeAreaView>
7767
);
7868
}

src/nav/ModalSearchNavBar.js

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,38 @@ export default function ModalSearchNavBar(props: Props): Node {
2929

3030
const styles = useMemo(
3131
() => ({
32-
safeAreaView: {
32+
surface: {
3333
borderColor: 'hsla(0, 0%, 50%, 0.25)',
3434
borderBottomWidth: 1,
3535
backgroundColor,
36-
paddingHorizontal: 4,
3736
},
3837
contentArea: {
39-
// We should really be able to put this in styles.safeAreaView, and
40-
// it should control the height of the "content area" of that view,
41-
// excluding padding. But SafeAreaView seems to take `height` and
42-
// `minHeight` as controlling the height of everything including the
43-
// automatic vertical padding. So, we've added this separate View.
4438
minHeight: NAVBAR_SIZE,
45-
4639
flexDirection: 'row',
4740
alignItems: 'center',
41+
paddingHorizontal: 4,
4842
},
4943
}),
5044
[backgroundColor],
5145
);
5246

5347
return (
54-
<>
55-
<SafeAreaView mode="padding" edges={['top', 'right', 'left']} style={styles.safeAreaView}>
56-
{/* See comment on styles.contentArea.minHeight. */}
57-
<View style={styles.contentArea}>
58-
{canGoBack && (
59-
<>
60-
<NavBarBackButton />
61-
<View style={{ width: 20 }} />
62-
</>
63-
)}
64-
<SearchInput
65-
autoFocus={autoFocus}
66-
onChangeText={searchBarOnChange}
67-
onSubmitEditing={searchBarOnSubmit}
68-
placeholder={placeholder}
69-
/>
70-
</View>
71-
</SafeAreaView>
48+
<SafeAreaView mode="padding" edges={['top']} style={styles.surface}>
7249
<OfflineNotice />
73-
</>
50+
<SafeAreaView mode="padding" edges={['right', 'left']} style={styles.contentArea}>
51+
{canGoBack && (
52+
<>
53+
<NavBarBackButton />
54+
<View style={{ width: 20 }} />
55+
</>
56+
)}
57+
<SearchInput
58+
autoFocus={autoFocus}
59+
onChangeText={searchBarOnChange}
60+
onSubmitEditing={searchBarOnSubmit}
61+
placeholder={placeholder}
62+
/>
63+
</SafeAreaView>
64+
</SafeAreaView>
7465
);
7566
}

0 commit comments

Comments
 (0)