Skip to content

Commit 0348f28

Browse files
committed
allow opting-in to different dev homescreen views from app-config
* allow disabling homescreen views * add an entry for showing recent courses vs course search directly * provide initial params to the course search view from the route
1 parent 8030236 commit 0348f28

File tree

3 files changed

+152
-132
lines changed

3 files changed

+152
-132
lines changed

source/navigation/routes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ const HomeStackScreens = () => {
212212
/>
213213
<Stack.Screen
214214
component={sis.CourseSearchResultsView}
215+
initialParams={{initialFilters: [], initialQuery: ''}}
215216
name="CourseSearchResults"
216217
options={sis.CourseSearchNavigationOptions}
217218
/>

source/views/home/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import {ScrollView, View, StyleSheet} from 'react-native'
33

4-
import {allViews} from '../views'
4+
import {AllViews} from '../views'
55
import {Column} from '@frogpond/layout'
66
import {partitionByIndex} from '../../lib/partition-by-index'
77
import {HomeScreenButton, CELL_MARGIN} from './button'
@@ -25,6 +25,7 @@ const styles = StyleSheet.create({
2525

2626
function HomePage(): JSX.Element {
2727
let navigation = useNavigation()
28+
let allViews = AllViews().filter((v) => !v.disabled ?? true)
2829
let columns = partitionByIndex(allViews)
2930

3031
return (

source/views/views.ts

Lines changed: 149 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as c from '@frogpond/colors'
2-
import {RootViewsParamList} from '../navigation/types'
2+
import {RootViewsParamList, MiscViewParamList} from '../navigation/types'
33

44
import {NavigationKey as menus} from './menus'
55
import {NavigationKey as sis} from './sis'
@@ -8,6 +8,8 @@ import {NavigationKey as streaming} from './streaming'
88
import {NavigationKey as news} from './news'
99
import {NavigationKey as transportation} from './transportation'
1010

11+
import {useCourseSearchRecentsScreen} from '@frogpond/app-config'
12+
1113
const hours: keyof RootViewsParamList = 'BuildingHours'
1214
const directory: keyof RootViewsParamList = 'Directory'
1315
const importantContacts: keyof RootViewsParamList = 'Contacts'
@@ -16,12 +18,14 @@ const studentOrgs: keyof RootViewsParamList = 'StudentOrgs'
1618
const more: keyof RootViewsParamList = 'More'
1719
const printJobs: keyof RootViewsParamList = 'PrintJobs'
1820
const courseSearch: keyof RootViewsParamList = 'CourseSearch'
21+
const courseSearchResults: keyof MiscViewParamList = 'CourseSearchResults'
1922

2023
type CommonView = {
2124
title: string
2225
icon: string
2326
foreground: 'light' | 'dark'
2427
tint: string
28+
disabled?: boolean
2529
}
2630

2731
type NativeView = {
@@ -36,133 +40,147 @@ type WebLinkView = {
3640

3741
export type ViewType = CommonView & (NativeView | WebLinkView)
3842

39-
export const allViews: Array<ViewType> = [
40-
{
41-
type: 'view',
42-
view: menus,
43-
title: 'Menus',
44-
icon: 'bowl',
45-
foreground: 'light',
46-
tint: c.grassToLime[0],
47-
},
48-
{
49-
type: 'view',
50-
view: sis,
51-
title: 'SIS',
52-
icon: 'fingerprint',
53-
foreground: 'light',
54-
tint: c.yellowToGoldDark[0],
55-
},
56-
{
57-
type: 'view',
58-
view: hours,
59-
title: 'Building Hours',
60-
icon: 'clock',
61-
foreground: 'light',
62-
tint: c.lightBlueToBlueDark[0],
63-
},
64-
{
65-
type: 'view',
66-
view: calendar,
67-
title: 'Calendar',
68-
icon: 'calendar',
69-
foreground: 'light',
70-
tint: c.magentaToPurple[0],
71-
},
72-
{
73-
type: 'view',
74-
view: directory,
75-
title: 'Directory',
76-
icon: 'v-card',
77-
foreground: 'light',
78-
tint: c.redToPurple[0],
79-
},
80-
{
81-
type: 'view',
82-
view: streaming,
83-
title: 'Streaming Media',
84-
icon: 'video',
85-
foreground: 'light',
86-
tint: c.lightBlueToBlueLight[0],
87-
},
88-
{
89-
type: 'view',
90-
view: news,
91-
title: 'News',
92-
icon: 'news',
93-
foreground: 'light',
94-
tint: c.purpleToIndigo[0],
95-
},
96-
{
97-
type: 'url',
98-
url: 'https://www.myatlascms.com/map/index.php?id=294',
99-
title: 'Campus Map',
100-
icon: 'map',
101-
foreground: 'light',
102-
tint: c.navyToNavy[0],
103-
},
104-
{
105-
type: 'view',
106-
view: importantContacts,
107-
title: 'Important Contacts',
108-
icon: 'phone',
109-
foreground: 'light',
110-
tint: c.orangeToRed[0],
111-
},
112-
{
113-
type: 'view',
114-
view: transportation,
115-
title: 'Transportation',
116-
icon: 'address',
117-
foreground: 'light',
118-
tint: c.grayToDarkGray[0],
119-
},
120-
{
121-
type: 'view',
122-
view: dictionary,
123-
title: 'Campus Dictionary',
124-
icon: 'open-book',
125-
foreground: 'light',
126-
tint: c.pinkToHotpink[0],
127-
},
128-
{
129-
type: 'view',
130-
view: studentOrgs,
131-
title: 'Student Orgs',
132-
icon: 'globe',
133-
foreground: 'light',
134-
tint: c.darkBlueToIndigo[0],
135-
},
136-
{
137-
type: 'view',
138-
view: more,
139-
title: 'More',
140-
icon: 'link',
141-
foreground: 'light',
142-
tint: c.seafoamToGrass[0],
143-
},
144-
{
145-
type: 'view',
146-
view: printJobs,
147-
title: 'stoPrint',
148-
icon: 'print',
149-
foreground: 'light',
150-
tint: c.tealToSeafoam[0],
151-
},
152-
{
153-
type: 'view',
154-
view: courseSearch,
155-
title: 'Course Catalog',
156-
icon: 'graduation-cap',
157-
foreground: 'light',
158-
tint: c.lavender,
159-
},
160-
{
161-
type: 'url',
162-
url: 'https://oleville.com/',
163-
title: 'Oleville',
164-
icon: 'browser',
165-
foreground: 'dark',
166-
tint: c.yellowToGoldMid[0],
167-
},
168-
]
43+
export const AllViews = (): Array<ViewType> => {
44+
const showRecentCourseSearches = useCourseSearchRecentsScreen()
45+
46+
return [
47+
{
48+
type: 'view',
49+
view: menus,
50+
title: 'Menus',
51+
icon: 'bowl',
52+
foreground: 'light',
53+
tint: c.grassToLime[0],
54+
},
55+
{
56+
type: 'view',
57+
view: sis,
58+
title: 'SIS',
59+
icon: 'fingerprint',
60+
foreground: 'light',
61+
tint: c.yellowToGoldDark[0],
62+
},
63+
{
64+
type: 'view',
65+
view: hours,
66+
title: 'Building Hours',
67+
icon: 'clock',
68+
foreground: 'light',
69+
tint: c.lightBlueToBlueDark[0],
70+
},
71+
{
72+
type: 'view',
73+
view: calendar,
74+
title: 'Calendar',
75+
icon: 'calendar',
76+
foreground: 'light',
77+
tint: c.magentaToPurple[0],
78+
},
79+
{
80+
type: 'view',
81+
view: directory,
82+
title: 'Directory',
83+
icon: 'v-card',
84+
foreground: 'light',
85+
tint: c.redToPurple[0],
86+
},
87+
{
88+
type: 'view',
89+
view: streaming,
90+
title: 'Streaming Media',
91+
icon: 'video',
92+
foreground: 'light',
93+
tint: c.lightBlueToBlueLight[0],
94+
},
95+
{
96+
type: 'view',
97+
view: news,
98+
title: 'News',
99+
icon: 'news',
100+
foreground: 'light',
101+
tint: c.purpleToIndigo[0],
102+
},
103+
{
104+
type: 'url',
105+
url: 'https://www.myatlascms.com/map/index.php?id=294',
106+
title: 'Campus Map',
107+
icon: 'map',
108+
foreground: 'light',
109+
tint: c.navyToNavy[0],
110+
},
111+
{
112+
type: 'view',
113+
view: importantContacts,
114+
title: 'Important Contacts',
115+
icon: 'phone',
116+
foreground: 'light',
117+
tint: c.orangeToRed[0],
118+
},
119+
{
120+
type: 'view',
121+
view: transportation,
122+
title: 'Transportation',
123+
icon: 'address',
124+
foreground: 'light',
125+
tint: c.grayToDarkGray[0],
126+
},
127+
{
128+
type: 'view',
129+
view: dictionary,
130+
title: 'Campus Dictionary',
131+
icon: 'open-book',
132+
foreground: 'light',
133+
tint: c.pinkToHotpink[0],
134+
},
135+
{
136+
type: 'view',
137+
view: studentOrgs,
138+
title: 'Student Orgs',
139+
icon: 'globe',
140+
foreground: 'light',
141+
tint: c.darkBlueToIndigo[0],
142+
},
143+
{
144+
type: 'view',
145+
view: more,
146+
title: 'More',
147+
icon: 'link',
148+
foreground: 'light',
149+
tint: c.seafoamToGrass[0],
150+
},
151+
{
152+
type: 'view',
153+
view: printJobs,
154+
title: 'stoPrint',
155+
icon: 'print',
156+
foreground: 'light',
157+
tint: c.tealToSeafoam[0],
158+
},
159+
{
160+
disabled: !showRecentCourseSearches,
161+
type: 'view',
162+
view: courseSearch,
163+
title: 'Course Catalog',
164+
icon: 'graduation-cap',
165+
foreground: 'light',
166+
tint: c.lavender,
167+
},
168+
{
169+
disabled: showRecentCourseSearches,
170+
type: 'view',
171+
view: courseSearchResults,
172+
title: 'Course Catalog',
173+
icon: 'lab-flask',
174+
foreground: 'light',
175+
tint: c.lavender,
176+
},
177+
{
178+
type: 'url',
179+
url: 'https://oleville.com/',
180+
title: 'Oleville',
181+
icon: 'browser',
182+
foreground: 'dark',
183+
tint: c.yellowToGoldMid[0],
184+
},
185+
]
186+
}

0 commit comments

Comments
 (0)