Skip to content

Commit d15c7f0

Browse files
authored
Merge pull request #6983 from StoDevX/drew/course-search-icon
Add course search icon to navigation header
2 parents fbcbde3 + dc3e01c commit d15c7f0

File tree

3 files changed

+61
-11
lines changed

3 files changed

+61
-11
lines changed

modules/navigation-buttons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export {CloseScreenButton} from './close-screen'
33
export {OpenSettingsButton} from './open-settings'
44
export {FavoriteButton} from './favorite'
55
export {DebugNoticeButton} from './debug'
6+
export {SearchButton} from './search'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as React from 'react'
2+
import {Platform, StyleSheet, Text} from 'react-native'
3+
import Icon from 'react-native-vector-icons/Ionicons'
4+
import {Touchable} from '@frogpond/touchable'
5+
import {useTheme} from '@frogpond/app-theme'
6+
import {commonStyles, rightButtonStyles as styles} from './styles'
7+
8+
type Props = {
9+
onPress: () => void
10+
title?: string
11+
}
12+
13+
export function SearchButton(props: Props): JSX.Element {
14+
let {colors} = useTheme()
15+
16+
return (
17+
<Touchable highlight={false} onPress={props.onPress} style={styles.button}>
18+
{props.title ? (
19+
<Text
20+
style={[
21+
commonStyles.text,
22+
searchStyles.text,
23+
{color: colors.primary},
24+
]}
25+
>
26+
{props.title}
27+
</Text>
28+
) : (
29+
<Icon
30+
name={
31+
Platform.OS === 'ios' ? 'ios-search-outline' : 'md-search-outline'
32+
}
33+
style={styles.icon}
34+
/>
35+
)}
36+
</Touchable>
37+
)
38+
}
39+
40+
const searchStyles = StyleSheet.create({
41+
text: {
42+
...Platform.select({
43+
ios: {
44+
fontWeight: '600',
45+
},
46+
android: {
47+
fontWeight: '400',
48+
},
49+
}),
50+
},
51+
})

source/views/sis/course-search/search.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as c from '@frogpond/colors'
22
import {LoadingView, NoticeView} from '@frogpond/notice'
3+
import {SearchButton} from '@frogpond/navigation-buttons'
34
import {useNavigation} from '@react-navigation/native'
45
import {NativeStackNavigationOptions} from '@react-navigation/native-stack'
56
import {debounce, fromPairs} from 'lodash'
@@ -35,12 +36,15 @@ export const CourseSearchView = (): JSX.Element => {
3536
let [typedQuery, setTypedQuery] = React.useState('')
3637

3738
React.useLayoutEffect(() => {
38-
// TODO: refactor the SIS tabview to not be tabview in order to support search.
39-
// search will not be injected properly embedded inside of a tab navigator and
40-
// calling navigation.getParent() is not a solution because the parent is a tab
41-
// navigator so all top-level tabs here would receive a searchbar. For now we
42-
// can at least rely on the "browse all" button to let us view search.
4339
navigation.setOptions({
40+
headerRight: () => (
41+
<SearchButton
42+
onPress={() =>
43+
navigation.navigate('CourseSearchResults', {initialQuery: ''})
44+
}
45+
title="Browse"
46+
/>
47+
),
4448
headerSearchBarOptions: {
4549
barTintColor: c.quaternarySystemFill,
4650
onChangeText: (event: ChangeTextEvent) => {
@@ -63,10 +67,6 @@ export const CourseSearchView = (): JSX.Element => {
6367
})
6468
}, [showSearchResult, typedQuery])
6569

66-
let browseAll = () => {
67-
navigation.navigate('CourseSearchResults', {initialQuery: ''})
68-
}
69-
7070
let onRecentFilterPress = React.useCallback(
7171
(text: string) => {
7272
let selectedFilterCombo = recentFilters.find(
@@ -120,11 +120,9 @@ export const CourseSearchView = (): JSX.Element => {
120120
title="Recent"
121121
/>
122122
<RecentItemsList
123-
actionLabel="Browse All"
124123
emptyHeader="No recent filter combinations"
125124
emptyText="Your recent filter combinations will appear here."
126125
items={recentFilterDescriptions}
127-
onAction={browseAll}
128126
onItemPress={onRecentFilterPress}
129127
title="Browse"
130128
/>

0 commit comments

Comments
 (0)