-
Notifications
You must be signed in to change notification settings - Fork 0
Development
DoSomething iOS is a hybrid React Native app: we use React components to power the View components of some screens, rendered in native UIViewControllers
.
Native components
- Tab Bar, Navigation, Image Picker, Activity/Share View Controllers
- Onboarding Views
- Login / Register Views
- Submit Reportback View
- Settings View
- Campaign Attachments View -- renders URL in
UIWebView
React Native components
- News Feed
- Cause List, Detail
- Reportback Gallery
- Campaign Detail, Action Guides
- Profile
Our LDTAppDelegate
contains a public readonly RCTBridge
property bridge
that all of our React Views (RCTRootView
) are initialized with. Calling the [LDTAppDelegate.bridge.eventDispatcher sendAppEventWithName:body]
allows us to send events from native code and create corresponding listeners (NativeAppEventEmitter
) in React Native.
-
DSOAPI
- subclass ofAFHTTPSessionManager
, handles all of our Objective C networking requests to the DS API and transforms response into relevant Model classes.- Ideally this class will moved out of this repo and into our SlothKit CocoaPod (inspired by Github's Octokit) to share networking code in multiple iOS projects
-
DSOUserManager
- singleton class with auser
property, which stores our logged inDSOUser
(also referred to as Current User in documentation)- Also contains a
campaigns
property - an array ofDSOCampaign
objects loaded fromDSOAPI
. We store these in memory to avoid making extraneous network calls. This may get refactored to store in Core Data to further cut down on network calls (#734). - Calls
DSOAPI
methods on behalf of the Current User with various completion and error handlers, such as logging errors to Crashlytics or dispatching events to React Native.
- Also contains a
-
LDTTabBarController
- OurLDTAppDelegate
root view controller.- Presents modals for Authentication, Reporting Back, and Settings
- Loads the Current User if app starts with a saved API session token
-
LDTReactBridge
- implementsRCTBridgeModule
protocol to export methods that allow React Native to communicate back to our native code.
In our [LDTAppDelegate application:didFinishLaunchingWithOptions:]
, we run React Native from either the local development server or from the offline bundle based on the environment.plist
value for ReactNativeUseOfflineBundle
(pull/#781).
-
When building to device or archiving, make sure your
ReactNativeUseOfflineBundle
is set toYES
in yourenvironment.plist
, otherwise the build fails on device with anpm
not running. -
Alternatively, when developing locally and testing in iOS Simulator,
ReactNativeUseOfflineBundle
must be set toNO
. Testing in Simulator with the value set toYES
will result in a:Unable to execute JS call: __fbBatchedBridge is undefined
error until we fix #920 -- this may be a local setup issue only.
From the root project directory:
- Upgrade the React Native dependency. Example:
npm install --save [email protected]
-
npm update
-- Updatesnode_modules
accordingly (Refs pull#985) -
pod install
-- Updates React Cocoapods
-
We have
NSAllowsArbitraryLoads
set toYES
to allow theLDTNewsArticleViewController
to load any given news article (pull#772) and support iOS8 (dropping iOS8 support would allow us to instead use aSafariWebController
and keepNSAllowsArbitraryLoads
set toNO
for security) -
React Native: Don't render a
ListView
within aView
- it's a gotcha
Our Profile and Campaign view were originally built in native code, but we refactored in React Native for faster view building, and easier dynamic heights (refs pull#687, pull#706)
-
LDTCampaignDetailViewController - used
UICollectionView
-
LDTProfileViewController - used
UITableView
Signups are currently modeled with the DSOSignup
class -- originally was a DSOCampaignSignup
class, before the Phoenix Signups API endpoint existed. (pull#917). We only use the DSOReportback
and DSOSignup
classes in our DSOAPI
POST completion handlers, sending newly created entities to React Native via LDTAppDelegate.bridge.eventDispatcher
.
-
DSOUser.campaignSignups
pull#844 - array storing a User'sDSOCampaignSignup
's. Upon app launch, we'd load the Current User'scampaignSignups
to be able to indicate which Campaigns the Current User has signed up for when viewing a list of Campaigns. The visual indicator in the list of Campaigns has since been removed (see Main Feed below), we now query the Signups API on demand if we need to know the Current User's Signups (currently when either viewing a Campaign or Self Profile) -
InterfaceBuilderView
pull#886 - Helper class for creating aUIView
from a xib with corresponding.h
and.m
files. Was used by the nativeLDTReportbackItemDetailView
-
LDTCampaignListViewController
pull#725 - aka The Main Feed. Was our initial first screen in v1.0.0. Implemented aUICollectionView
, which had 4LDTCampaignCollectionViewCellContainer
cells for 4 different taxonomy terms (aka Interest Groups). ALDTCampaignCollectionViewCellContainer
also contained an innerUICollectionView
that displayed Campaigns and Reportbacks for a given Taxonomy Term and scrolled vertically. The user could swipe left and right to view the different Terms, because the outerUICollectionView
scrolled horizontally.-
LDTReportbackItemDetailSingleViewController
pull#831 - Single view of a Reportback Item the User would be presented with upon selecting an item in the Main Feed Reportback Gallery
-