Skip to content

Commit 4356045

Browse files
chrisbobbegnprice
authored andcommitted
offline notice [nfc]: Put <OfflineNotice />s into nearby *NavBar components
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. With that goal in mind, move our `<OfflineNotice />`s closer to the UI code responsible for handling the top inset. But without making any functional changes yet: in ChatScreen, for example, the `<OfflineNotice />` goes from being the next element down from `<ChatNavBar />`, to being the last element *in* ChatNavBar, in a way that ensures the visual layout doesn't change. And likewise everywhere else an `<OfflineNotice />` was just below a `<ModalNavBar />` or a `<ModalSearchNavBar />`. We'll start changing the layout next.
1 parent 033c210 commit 4356045

File tree

6 files changed

+34
-31
lines changed

6 files changed

+34
-31
lines changed

src/chat/ChatScreen.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type { AppNavigationProp } from '../nav/AppNavigator';
99
import { ThemeContext, createStyleSheet } from '../styles';
1010
import type { Narrow, EditMessage } from '../types';
1111
import KeyboardAvoider from '../common/KeyboardAvoider';
12-
import OfflineNotice from '../common/OfflineNotice';
1312
import ChatNavBar from '../nav/ChatNavBar';
1413
import MessageList from '../webview/MessageList';
1514
import NoMessages from '../message/NoMessages';
@@ -199,7 +198,6 @@ export default function ChatScreen(props: Props): Node {
199198
return (
200199
<KeyboardAvoider style={[componentStyles.screen, { backgroundColor }]} behavior="padding">
201200
<ChatNavBar narrow={narrow} editMessage={editMessage} />
202-
<OfflineNotice />
203201
<UnreadNotice narrow={narrow} />
204202
{(() => {
205203
if (!isNarrowValid) {

src/common/Screen.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { EditingEvent } from 'react-native/Libraries/Components/TextInput/T
1010
import styles, { createStyleSheet, ThemeContext } from '../styles';
1111
import type { LocalizableText, LocalizableReactText } from '../types';
1212
import KeyboardAvoider from './KeyboardAvoider';
13-
import OfflineNotice from './OfflineNotice';
1413
import LoadingBanner from './LoadingBanner';
1514
import ModalNavBar from '../nav/ModalNavBar';
1615
import ModalSearchNavBar from '../nav/ModalSearchNavBar';
@@ -112,7 +111,6 @@ export default function Screen(props: Props): Node {
112111
) : (
113112
<ModalNavBar canGoBack={canGoBack} title={title} />
114113
)}
115-
<OfflineNotice />
116114
{shouldShowLoadingBanner && <LoadingBanner />}
117115
<KeyboardAvoider
118116
behavior="padding"

src/nav/ChatNavBar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { doNarrow } from '../actions';
2121
import { isNarrowValid as getIsNarrowValid } from '../selectors';
2222
import NavButton from './NavButton';
2323
import { useNavigation } from '../react-navigation';
24+
import OfflineNotice from '../common/OfflineNotice';
2425

2526
function ExtraNavButtonStream(props: {| +color: string, +narrow: Narrow |}): Node {
2627
const { color, narrow } = props;
@@ -191,6 +192,7 @@ export default function ChatNavBar(props: {|
191192
textColor={textColor}
192193
/>
193194
</SafeAreaView>
195+
<OfflineNotice />
194196
</>
195197
);
196198
}

src/nav/ModalNavBar.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { LocalizableReactText } from '../types';
88
import globalStyles, { ThemeContext, NAVBAR_SIZE } from '../styles';
99
import ZulipTextIntl from '../common/ZulipTextIntl';
1010
import NavBarBackButton from './NavBarBackButton';
11+
import OfflineNotice from '../common/OfflineNotice';
1112

1213
type Props = $ReadOnly<{|
1314
canGoBack: boolean,
@@ -63,12 +64,15 @@ export default function ModalNavBar(props: Props): Node {
6364
);
6465

6566
return (
66-
<SafeAreaView mode="padding" edges={['top', 'right', 'left']} style={styles.safeAreaView}>
67-
{/* See comment on styles.contentArea.minHeight. */}
68-
<View style={styles.contentArea}>
69-
{canGoBack && <NavBarBackButton />}
70-
<ZulipTextIntl style={styles.text} text={title} numberOfLines={1} ellipsizeMode="tail" />
71-
</View>
72-
</SafeAreaView>
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>
75+
<OfflineNotice />
76+
</>
7377
);
7478
}

src/nav/ModalSearchNavBar.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ThemeContext, NAVBAR_SIZE } from '../styles';
99
import SearchInput from '../common/SearchInput';
1010
import NavBarBackButton from './NavBarBackButton';
1111
import type { LocalizableText } from '../types';
12+
import OfflineNotice from '../common/OfflineNotice';
1213

1314
type Props = $ReadOnly<{|
1415
autoFocus: boolean,
@@ -50,22 +51,25 @@ export default function ModalSearchNavBar(props: Props): Node {
5051
);
5152

5253
return (
53-
<SafeAreaView mode="padding" edges={['top', 'right', 'left']} style={styles.safeAreaView}>
54-
{/* See comment on styles.contentArea.minHeight. */}
55-
<View style={styles.contentArea}>
56-
{canGoBack && (
57-
<>
58-
<NavBarBackButton />
59-
<View style={{ width: 20 }} />
60-
</>
61-
)}
62-
<SearchInput
63-
autoFocus={autoFocus}
64-
onChangeText={searchBarOnChange}
65-
onSubmitEditing={searchBarOnSubmit}
66-
placeholder={placeholder}
67-
/>
68-
</View>
69-
</SafeAreaView>
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>
72+
<OfflineNotice />
73+
</>
7074
);
7175
}

src/streams/SubscriptionsScreen.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { caseInsensitiveCompareFunc } from '../utils/misc';
2121
import StreamItem from './StreamItem';
2222
import ModalNavBar from '../nav/ModalNavBar';
2323
import NestedNavRow from '../common/NestedNavRow';
24-
import OfflineNotice from '../common/OfflineNotice';
2524

2625
const styles = createStyleSheet({
2726
container: {
@@ -74,8 +73,6 @@ export default function SubscriptionsScreen(props: Props): Node {
7473
<View style={styles.container}>
7574
{/* Consumes the top inset. */}
7675
<ModalNavBar canGoBack={false} title="Streams" />
77-
<OfflineNotice />
78-
7976
<LoadingBanner />
8077
{subscriptions.length === 0 ? (
8178
<SearchEmptyState text="No streams found" />

0 commit comments

Comments
 (0)