Skip to content

Reorganize all app files#1537

Draft
hawkrives wants to merge 13 commits into
masterfrom
reorg
Draft

Reorganize all app files#1537
hawkrives wants to merge 13 commits into
masterfrom
reorg

Conversation

@hawkrives

Copy link
Copy Markdown
Member

This was originally a proof of concept that got a bit out of hand… and actually worked.

  • Moves components/ up under source/
  • Makes a source/init/ folder for "initialization files" – think bugsnag, GA, etc
  • Dynamically loads homescreen buttons and screen navigation keys from the files

And then, the big change is that it changes what a "view" is.

We currently kinda abuse the notion of a "view" – we call the thing that is produced by tapping a homescreen button a view, but we have nowhere for the detail views (or the views housed under the tab bars) to live, so they just kinda wander around.

This branch introduces the concept of a "module," which is a discrete … view. Each tab in a tabbed view is a module (OtherModesTransitView, StudentJobPostingsView), as is each top-level view (those that are more than just a tab switcher, at least) – BonAppMenuView, CalendarEventsListView, BusLineView, for example.

These "modules" are then composed into an actual "view", which is somehow presented by the app (usually by the homescreen buttons, but also by the toolbar buttons.)

Here's an example "view":

// @flow
import * as c from '../components/colors'
import type {HomescreenViewType, AppNavigationType} from '../app/types'
import {DictionaryView, DictionaryDetailView} from '../modules/dictionary'
export const navigation: AppNavigationType = {
DictionaryView: {screen: DictionaryView},
DictionaryDetailView: {screen: DictionaryDetailView},
}
export const view: HomescreenViewType = {
type: 'view',
view: 'DictionaryView',
title: 'Campus Dictionary',
icon: 'open-book',
tint: c.olive,
gradient: c.yellowToGoldLight,
}

Every view must export two named exports: navigation and view.

navigation is used by the navigation system to allow links and buttons to work, and the keys there must be globally unique. All exported "navigation" exports are joined together into one giant object to create the current navigation.js.

view is used by the homescreen to render the buttons. (There's also a new type of view, hidden, which facilitates the toolbar buttons.)

I think that this new organization method really shines in its consistency across all of our views – the "view" is now responsible for creating the tabs, and the content of each tab has to be created in a "module" and imported into the view.


This PR is not intended to be merged anytime soon. I just wanted to open it so it didn't languish in GitHub purgatory. (… actually, looking it over again, it needs some cleanup even beyond the merge conflicts. Some of the restructuring I did for the modules resulted in some code duplication, so I haven't found the right balance of "module separation" yet.)

I'd be interested to hear your thoughts, either here or in person, @elijahverdoorn.

@drewvolz

Copy link
Copy Markdown
Member

@hawkrives I am a big fan of this reorg 👍

@drewvolz

Copy link
Copy Markdown
Member

@hawkrives if you need help cleaning up merge conflicts, let me know

@hawkrives hawkrives marked this pull request as draft April 14, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants