├── .watchmanconfig ├── .gitattributes ├── src ├── shared │ ├── style │ │ ├── index.ts │ │ └── color.ts │ ├── buttons │ │ └── Button.tsx │ └── i18n.ts ├── images │ └── logo_vote.png ├── state │ ├── index.ts │ ├── selectors.ts │ ├── __tests__ │ │ └── api.test.ts │ ├── types.ts │ ├── reducer.ts │ ├── hooks.ts │ ├── actions.ts │ ├── context.tsx │ └── api.ts ├── __mocks__ │ ├── i18next.ts │ └── react-native-screens.ts ├── screens │ ├── types.ts │ ├── PollingLocations │ │ ├── Row.tsx │ │ └── index.tsx │ ├── Screens.tsx │ ├── Home.tsx │ └── Location │ │ └── index.tsx ├── App.tsx └── __tests__ │ └── setupTests.js ├── app.json ├── ios ├── logo_vote.png ├── Vote │ ├── Images.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-40.png │ │ │ ├── Icon-58.png │ │ │ ├── Icon-60.png │ │ │ ├── Icon-87.png │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── main.m │ ├── Info.plist │ ├── AppDelegate.m │ └── LaunchScreen.storyboard ├── Vote.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Podfile ├── VoteTests │ ├── Info.plist │ └── VoteTests.m ├── Vote-tvOSTests │ └── Info.plist ├── Vote-tvOS │ └── Info.plist ├── Vote.xcodeproj │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── Vote.xcscheme │ │ │ └── Vote-tvOS.xcscheme │ └── project.pbxproj └── Podfile.lock ├── readme-images ├── ios.jpg └── android.jpg ├── android ├── app │ ├── debug.keystore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vote │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ └── AndroidManifest.xml │ │ └── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── vote │ │ │ └── ReactNativeFlipper.java │ ├── proguard-rules.pro │ ├── build_defs.bzl │ ├── _BUCK │ └── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── settings.gradle ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── .buckconfig ├── metro.config.js ├── .prettierrc.js ├── index.js ├── babel.config.js ├── jest.config.js ├── tsconfig.json ├── .gitignore ├── LICENSE ├── README.md ├── .eslintrc.js └── package.json /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /src/shared/style/index.ts: -------------------------------------------------------------------------------- 1 | export * from './color' 2 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Vote", 3 | "displayName": "Vote" 4 | } -------------------------------------------------------------------------------- /ios/logo_vote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/ios/logo_vote.png -------------------------------------------------------------------------------- /readme-images/ios.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/readme-images/ios.jpg -------------------------------------------------------------------------------- /android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/debug.keystore -------------------------------------------------------------------------------- /readme-images/android.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/readme-images/android.jpg -------------------------------------------------------------------------------- /src/images/logo_vote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/src/images/logo_vote.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Vote 3 | 4 | -------------------------------------------------------------------------------- /src/state/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api' 2 | export { CivicInfoProvider } from './context' 3 | export * from './hooks' 4 | -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-58.png -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-60.png -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/ios/Vote/Images.xcassets/AppIcon.appiconset/Icon-87.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steam/vote-react-native/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Vote' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /ios/Vote/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /metro.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transformer: { 3 | getTransformOptions: async () => ({ 4 | transform: { 5 | experimentalImportSupport: false, 6 | inlineRequires: false, 7 | }, 8 | }), 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /ios/Vote/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/__mocks__/i18next.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-var-requires */ 2 | const { use } = require('i18next') 3 | const i18next: any = jest.genMockFromModule('i18next') 4 | i18next.t = (i: string) => i 5 | i18next.use = use 6 | module.exports = i18next 7 | -------------------------------------------------------------------------------- /src/__mocks__/react-native-screens.ts: -------------------------------------------------------------------------------- 1 | jest.mock('react-native-screens', () => { 2 | const RealComponent = jest.requireActual('react-native-screens') 3 | RealComponent.enableScreens = jest.fn() 4 | RealComponent.screensEnabled = jest.fn() 5 | return RealComponent 6 | }) 7 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSpacing: true, 4 | jsxBracketSameLine: false, 5 | jsxSingleQuote: false, 6 | proseWrap: 'always', 7 | singleQuote: true, 8 | trailingComma: 'all', 9 | useTabs: false, 10 | semi: false, 11 | printWidth: 90, 12 | } 13 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import 'react-native-gesture-handler' 2 | import { AppRegistry } from 'react-native' 3 | import { App } from './src/App' 4 | import { name as appName } from './app.json' 5 | import { enableScreens } from 'react-native-screens' 6 | enableScreens() 7 | 8 | AppRegistry.registerComponent(appName, () => App) 9 | -------------------------------------------------------------------------------- /ios/Vote.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Vote.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/shared/style/color.ts: -------------------------------------------------------------------------------- 1 | const colors = { 2 | primary: '#17b890', 3 | primaryMedium: '#9DC5BB', 4 | primaryLight: '#DEE5E5', 5 | pin: '#f0452b', 6 | uiLight: '#ffffff', 7 | uiMedium: '#888888', 8 | uiMediumAlpha80: 'rgba(52, 52, 52, 0.8)', 9 | uiDark: '#000000', 10 | } 11 | 12 | export { colors } 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | sourceMaps: true, 3 | presets: [ 4 | 'module:metro-react-native-babel-preset', 5 | [ 6 | '@babel/preset-env', 7 | { 8 | targets: { 9 | node: 'current', 10 | }, 11 | }, 12 | ], 13 | '@babel/preset-typescript', 14 | ], 15 | } 16 | -------------------------------------------------------------------------------- /src/state/selectors.ts: -------------------------------------------------------------------------------- 1 | import { PollingLocation, State } from './types' 2 | 3 | const selectors = (state: State) => { 4 | const location = (name: string): PollingLocation | undefined => { 5 | return state.pollingLocations.find(l => l.address?.locationName === name) 6 | } 7 | return { location } 8 | } 9 | 10 | export { selectors } 11 | -------------------------------------------------------------------------------- /src/screens/types.ts: -------------------------------------------------------------------------------- 1 | enum Route { 2 | HOME = 'HOME', 3 | LOCATION = 'LOCATION', 4 | POLLING_LOCATIONS = 'POLLING_LOCATIONS', 5 | } 6 | 7 | type ScreenNavigatorParamList = { 8 | [Route.HOME]: undefined 9 | [Route.LOCATION]: { name?: string } 10 | [Route.POLLING_LOCATIONS]: { address: string } 11 | } 12 | export { Route, ScreenNavigatorParamList } 13 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/vote/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.vote; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "Vote"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC } from 'react' 2 | import { NavigationContainer } from '@react-navigation/native' 3 | import { Screens } from './screens/Screens' 4 | import { initializeI18N } from './shared/i18n' 5 | 6 | initializeI18N() 7 | 8 | declare const global: { HermesInternal: null | {} } 9 | 10 | const App: FC = () => { 11 | return ( 12 | 13 | 14 | 15 | ) 16 | } 17 | 18 | export { App } 19 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /src/state/__tests__/api.test.ts: -------------------------------------------------------------------------------- 1 | import { loadPollingPlaces } from '../api' 2 | import { enableFetchMocks } from 'jest-fetch-mock' 3 | enableFetchMocks() 4 | import fetchMock from 'jest-fetch-mock' 5 | 6 | beforeEach(() => { 7 | fetchMock.resetMocks() 8 | }) 9 | 10 | test('getPollingLocations', async () => { 11 | const dispatch = jest.fn() 12 | fetchMock.mockResponseOnce(JSON.stringify({ getPollingLocations: ['1', '2'] })) 13 | await loadPollingPlaces(dispatch, '123 E. Voter Ave. Denver, CO 80238') 14 | expect(dispatch).toBeCalledTimes(2) 15 | }) 16 | -------------------------------------------------------------------------------- /src/state/types.ts: -------------------------------------------------------------------------------- 1 | interface PollingLocation { 2 | address?: Address 3 | latitude?: number 4 | longitude?: number 5 | pollingHours?: string 6 | sources?: Source[] 7 | } 8 | 9 | interface Address { 10 | locationName?: string 11 | line1?: string 12 | city?: string 13 | state?: string 14 | zip?: string 15 | } 16 | 17 | interface Source { 18 | name?: string 19 | official?: boolean 20 | } 21 | 22 | interface State { 23 | error: Error | undefined 24 | pollingLocations: PollingLocation[] 25 | status: 'loading' | 'finished' | 'error' 26 | } 27 | 28 | export { State, PollingLocation } 29 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'Vote' do 7 | # React Native Maps dependencies 8 | rn_maps_path = '../node_modules/react-native-maps' 9 | pod 'react-native-google-maps', :path => rn_maps_path 10 | pod 'GoogleMaps' 11 | pod 'Google-Maps-iOS-Utils' 12 | 13 | config = use_native_modules! 14 | 15 | use_react_native!(:path => config["reactNativePath"]) 16 | 17 | use_flipper! 18 | post_install do |installer| 19 | flipper_post_install(installer) 20 | end 21 | end -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-var-requires 2 | const path = require('path') 3 | const spec = { 4 | preset: 'react-native', 5 | displayName: 'spec', 6 | rootDir: path.join(__dirname, ''), 7 | transform: { 8 | '^.+\\.js$': '/node_modules/react-native/jest/preprocessor.js', 9 | }, 10 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', 11 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 12 | setupFilesAfterEnv: ['/src/__tests__/setupTests.js'], 13 | testPathIgnorePatterns: ['/node_modules/'], 14 | transformIgnorePatterns: [], 15 | } 16 | 17 | const test = spec 18 | 19 | module.exports = test 20 | -------------------------------------------------------------------------------- /android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /src/state/reducer.ts: -------------------------------------------------------------------------------- 1 | import { State } from './types' 2 | import { Actions, ActionTypes } from './actions' 3 | 4 | const reducer = (state: State, action: Actions): State => { 5 | switch (action.type) { 6 | case ActionTypes.FailLoadingPollingLocations: { 7 | return { ...state, error: action.payload.error, status: 'error' } 8 | } 9 | case ActionTypes.FinishLoadingPollingLocations: { 10 | return { 11 | ...state, 12 | pollingLocations: action.payload.pollingLocations, 13 | status: 'finished', 14 | } 15 | } 16 | case ActionTypes.StartLoadingPollingLocations: { 17 | return { ...state, status: 'loading' } 18 | } 19 | } 20 | return state 21 | } 22 | 23 | export { reducer } 24 | -------------------------------------------------------------------------------- /ios/VoteTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/Vote-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/shared/buttons/Button.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC } from 'react' 2 | import { Pressable, StyleSheet, Text } from 'react-native' 3 | import { colors } from '../style' 4 | 5 | interface Props { 6 | onPress: () => void 7 | title: string 8 | } 9 | 10 | const Button: FC = ({ onPress, title }) => { 11 | return ( 12 | [ 15 | { 16 | backgroundColor: pressed ? colors.primaryMedium : colors.primary, 17 | }, 18 | styles.button, 19 | ]} 20 | > 21 | {title} 22 | 23 | ) 24 | } 25 | 26 | const styles = StyleSheet.create({ 27 | button: { borderRadius: 30, marginBottom: 20, marginTop: 35, padding: 10 }, 28 | buttonText: { color: colors.uiLight, fontSize: 25, textAlign: 'center' }, 29 | }) 30 | 31 | export { Button } 32 | -------------------------------------------------------------------------------- /src/state/hooks.ts: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react' 2 | import { ActionTypes } from './actions' 3 | import { CivicInfoContext, CivicInfoDispatchContext } from './context' 4 | import { selectors } from './selectors' 5 | 6 | const useCivicInfoState = () => { 7 | const state = useContext(CivicInfoContext) 8 | 9 | if (state === undefined) { 10 | throw new Error('useCivicInfoState must be used within a CivicInfoProvider') 11 | } 12 | 13 | return { ...state, selectors: selectors(state) } 14 | } 15 | 16 | const useCivicInfoDispatch = () => { 17 | const dispatch = useContext(CivicInfoDispatchContext) 18 | 19 | if (dispatch === undefined) { 20 | throw new Error('useCivicInfoDispatch must be used within a CivicInfoProvider') 21 | } 22 | 23 | return { 24 | dispatch, 25 | actions: { 26 | ...ActionTypes, 27 | }, 28 | } 29 | } 30 | 31 | export { useCivicInfoDispatch, useCivicInfoState } 32 | -------------------------------------------------------------------------------- /src/state/actions.ts: -------------------------------------------------------------------------------- 1 | import { PollingLocation } from './types' 2 | 3 | enum ActionTypes { 4 | FailLoadingPollingLocations = 'app/Vote/FailLoadingPollingLocations', 5 | FinishLoadingPollingLocations = 'app/Vote/FinishLoadingPollingLocations', 6 | StartLoadingPollingLocations = 'app/Vote/StartLoadingPollingLocations', 7 | } 8 | 9 | interface FailLoadingPollingLocations { 10 | type: ActionTypes.FailLoadingPollingLocations 11 | payload: { 12 | error: Error 13 | } 14 | } 15 | 16 | interface FinishLoadingPollingLocations { 17 | type: ActionTypes.FinishLoadingPollingLocations 18 | payload: { 19 | pollingLocations: PollingLocation[] 20 | } 21 | } 22 | 23 | interface StartLoadingPollingLocations { 24 | type: ActionTypes.StartLoadingPollingLocations 25 | payload: { 26 | address: string 27 | } 28 | } 29 | 30 | type Actions = 31 | | StartLoadingPollingLocations 32 | | FinishLoadingPollingLocations 33 | | FailLoadingPollingLocations 34 | 35 | export { Actions, ActionTypes } 36 | -------------------------------------------------------------------------------- /src/__tests__/setupTests.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-empty-function */ 2 | /* eslint-disable @typescript-eslint/no-var-requires */ 3 | import '@testing-library/jest-native/extend-expect' 4 | 5 | import fetchMock from 'jest-fetch-mock' 6 | 7 | fetchMock.enableMocks() 8 | 9 | jest.mock('react-native-localize', () => { 10 | return { 11 | getLocales: () => { 12 | return [{ languageCode: 'en' }] 13 | }, 14 | } 15 | }) 16 | 17 | import 'react-native-gesture-handler/jestSetup' 18 | 19 | jest.mock('react-native-reanimated', () => { 20 | const Reanimated = require('react-native-reanimated/mock') 21 | 22 | // The mock for `call` immediately calls the callback which is incorrect 23 | // So we override it with a no-op 24 | Reanimated.default.call = () => {} 25 | 26 | return Reanimated 27 | }) 28 | 29 | // Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing 30 | jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper') 31 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "alwaysStrict": true, 5 | "declaration": false, 6 | "esModuleInterop": true, 7 | "jsx": "react", 8 | "keyofStringsOnly": true, 9 | "lib": ["es2017", "dom"], 10 | "module": "commonjs", 11 | "moduleResolution": "node", 12 | "noImplicitAny": true, 13 | "noImplicitReturns": true, 14 | "noImplicitThis": true, 15 | "outDir": "dist", 16 | "resolveJsonModule": true, 17 | "sourceMap": true, 18 | "strict": true, 19 | "strictFunctionTypes": true, 20 | "strictNullChecks": true, 21 | "strictPropertyInitialization": true, 22 | "target": "es2019", 23 | "types": [ 24 | "node", 25 | "./node_modules/@types/jest", 26 | "./node_modules/@testing-library/jest-native/extend-expect" 27 | ], 28 | "typeRoots": ["node_modules/@types"] 29 | }, 30 | "awesomeTypescriptLoaderOptions": { 31 | "useCache": true 32 | }, 33 | "exclude": ["node_modules", "dist", "webpack", "jest"] 34 | } 35 | -------------------------------------------------------------------------------- /src/shared/i18n.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-empty-function */ 2 | import i18next, { LanguageDetectorModule } from 'i18next' 3 | import { initReactI18next } from 'react-i18next' 4 | import * as RNLocalize from 'react-native-localize' 5 | 6 | const languageDetector: LanguageDetectorModule = { 7 | type: 'languageDetector', 8 | detect: () => RNLocalize.getLocales()[0].languageCode, 9 | init: () => {}, 10 | cacheUserLanguage: () => {}, 11 | } 12 | 13 | const en = { 14 | addressPlaceholder: 'e.g. 123 Voter Way, Your City State, Zip', 15 | findPollingLocaions: 'Find my polling locations', 16 | getDirections: 'Get Directions', 17 | hours: 'Hours', 18 | pollingLocations: 'Polling Locations', 19 | source: 'Source', 20 | } 21 | 22 | const initializeI18N = () => { 23 | i18next 24 | .use(languageDetector) 25 | .use(initReactI18next) 26 | .init({ 27 | fallbackLng: 'en', 28 | debug: false, 29 | resources: { 30 | en: { 31 | translation: { ...en }, 32 | }, 33 | }, 34 | }) 35 | } 36 | 37 | export { en, initializeI18N } 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # Visual Studio Code 33 | # 34 | .vscode/ 35 | 36 | # node.js 37 | # 38 | node_modules/ 39 | npm-debug.log 40 | yarn-error.log 41 | 42 | # BUCK 43 | buck-out/ 44 | \.buckd/ 45 | *.keystore 46 | !debug.keystore 47 | 48 | # fastlane 49 | # 50 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 51 | # screenshots whenever they are needed. 52 | # For more information about the recommended setup visit: 53 | # https://docs.fastlane.tools/best-practices/source-control/ 54 | 55 | */fastlane/report.xml 56 | */fastlane/Preview.html 57 | */fastlane/screenshots 58 | 59 | # Bundle artifact 60 | *.jsbundle 61 | 62 | # CocoaPods 63 | /ios/Pods/ 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sean Dougherty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/state/context.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, Dispatch, FC, ReactNode, useReducer } from 'react' 2 | import { State } from './types' 3 | import { Actions } from './actions' 4 | import { reducer } from './reducer' 5 | 6 | interface CivicInfoProviderProps { 7 | initialState?: State 8 | children: ReactNode 9 | } 10 | 11 | const getInitialState = (): State => ({ 12 | error: undefined, 13 | status: 'finished', 14 | pollingLocations: [], 15 | }) 16 | 17 | const CivicInfoContext = createContext(undefined) 18 | const CivicInfoDispatchContext = createContext | undefined>(undefined) 19 | 20 | const CivicInfoProvider: FC = ({ 21 | initialState = getInitialState(), 22 | ...rest 23 | }) => { 24 | const [state, dispatch] = useReducer(reducer, initialState) 25 | 26 | return ( 27 | 28 | 29 | {rest.children} 30 | 31 | 32 | ) 33 | } 34 | 35 | export { CivicInfoProvider, CivicInfoContext, CivicInfoDispatchContext } 36 | -------------------------------------------------------------------------------- /src/state/api.ts: -------------------------------------------------------------------------------- 1 | import { Actions, ActionTypes } from './actions' 2 | import { Dispatch } from 'react' 3 | 4 | // this would not normally be inline here :) 5 | const apiKey = 'AIzaSyChE0fr3l0LbtaR_IdeRg4EMOz9Pez4YR0' 6 | const baseUrl = 'https://civicinfo.googleapis.com/civicinfo/v2/' 7 | const voterInfoUrl = `${baseUrl}voterinfo?key=${apiKey}` 8 | 9 | const loadPollingPlaces = async (dispatch: Dispatch, address: string) => { 10 | dispatch({ type: ActionTypes.StartLoadingPollingLocations, payload: { address } }) 11 | try { 12 | const voterInfo = await fetch(`${voterInfoUrl}&address=${address}`, { 13 | method: 'GET', 14 | headers: { 15 | Accept: 'application/json', 16 | 'Content-Type': 'application/json', 17 | }, 18 | }) 19 | const json = await voterInfo.json() 20 | const pollingLocations = json.pollingLocations ?? [] 21 | dispatch({ 22 | type: ActionTypes.FinishLoadingPollingLocations, 23 | payload: { pollingLocations }, 24 | }) 25 | } catch (error) { 26 | dispatch({ type: ActionTypes.FailLoadingPollingLocations, payload: { error } }) 27 | } 28 | } 29 | 30 | export { loadPollingPlaces } 31 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | playServicesVersion = "17.0.0" 10 | androidMapsUtilsVersion = "2.0.3" 11 | } 12 | repositories { 13 | google() 14 | jcenter() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:3.5.3") 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | 35 | google() 36 | jcenter() 37 | maven { url 'https://www.jitpack.io' } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ios/Vote/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "Icon-40.png", 5 | "idiom" : "iphone", 6 | "scale" : "2x", 7 | "size" : "20x20" 8 | }, 9 | { 10 | "filename" : "Icon-60.png", 11 | "idiom" : "iphone", 12 | "scale" : "3x", 13 | "size" : "20x20" 14 | }, 15 | { 16 | "filename" : "Icon-58.png", 17 | "idiom" : "iphone", 18 | "scale" : "2x", 19 | "size" : "29x29" 20 | }, 21 | { 22 | "filename" : "Icon-87.png", 23 | "idiom" : "iphone", 24 | "scale" : "3x", 25 | "size" : "29x29" 26 | }, 27 | { 28 | "idiom" : "iphone", 29 | "scale" : "2x", 30 | "size" : "40x40" 31 | }, 32 | { 33 | "idiom" : "iphone", 34 | "scale" : "3x", 35 | "size" : "40x40" 36 | }, 37 | { 38 | "idiom" : "iphone", 39 | "scale" : "2x", 40 | "size" : "60x60" 41 | }, 42 | { 43 | "idiom" : "iphone", 44 | "scale" : "3x", 45 | "size" : "60x60" 46 | }, 47 | { 48 | "idiom" : "ios-marketing", 49 | "scale" : "1x", 50 | "size" : "1024x1024" 51 | } 52 | ], 53 | "info" : { 54 | "author" : "xcode", 55 | "version" : 1 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.54.0 29 | -------------------------------------------------------------------------------- /android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.vote", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.vote", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /src/screens/PollingLocations/Row.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC } from 'react' 2 | import { StyleSheet, Text, TouchableHighlight, View } from 'react-native' 3 | import { PollingLocation } from '../../state/types' 4 | import Icon from 'react-native-vector-icons/EvilIcons' 5 | import { colors } from '../../shared/style' 6 | 7 | interface Props { 8 | onPress: () => void 9 | location: PollingLocation 10 | } 11 | 12 | const Row: FC = ({ location, onPress }) => { 13 | return ( 14 | 19 | 20 | 21 | {location.address?.locationName} 22 | {location.address?.line1} 23 | {`${location.address?.city}, ${location.address?.state}, ${location.address?.zip}`} 26 | 27 | 28 | 29 | 30 | 31 | 32 | ) 33 | } 34 | 35 | const styles = StyleSheet.create({ 36 | address: { color: colors.uiMedium, fontSize: 15 }, 37 | icon: { alignSelf: 'center' }, 38 | row: { 39 | backgroundColor: colors.uiLight, 40 | flexDirection: 'row', 41 | justifyContent: 'space-between', 42 | marginVertical: 5, 43 | paddingVertical: 10, 44 | }, 45 | text: { alignSelf: 'flex-start' }, 46 | title: { fontSize: 20 }, 47 | }) 48 | 49 | export { Row } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vote 2 | 3 | ![img](https://github.com/steam/vote-react-native/blob/master/src/images/logo_vote.png) 4 | 5 | A simple React Native application for figuring out where to vote using the 6 | [Google Civic Information API](https://developers.google.com/civic-information). 7 | 8 | ## Highlights 9 | 10 | The Vote app uses the 11 | [Google Civic Information API](https://developers.google.com/civic-information) to lookup 12 | polling locations for the entered address. Most results come from the 13 | [Voting Information Project](https://www.votinginfoproject.org/). 14 | 15 | All 1st party code is written in Typescript using functional components and react hooks. 16 | Application state utilizes a modified React Context pattern inspired by Kent C. Dodds' 17 | blog post 18 | [How to use React Context effectively](https://kentcdodds.com/blog/how-to-use-react-context-effectively). 19 | 20 | ![img](https://github.com/steam/vote-react-native/blob/master/readme-images/ios.jpg) 21 | ![img](https://github.com/steam/vote-react-native/blob/master/readme-images/android.jpg) 22 | 23 | ## Major 3rd Party Libraries 24 | 25 | - Navigation - [React Navigation](https://reactnavigation.org/) 26 | - Translations - [React i18next](https://react.i18next.com/) 27 | - Maps - [React Native Maps](https://github.com/react-native-maps/react-native-maps) 28 | 29 | ## Next up 30 | 31 | - A bunch more jest testing 32 | - end to end acceptance testing with [Detox](https://github.com/wix/Detox) 33 | - CI/CD using [Github Actions](https://docs.github.com/en/free-pro-team@latest/actions) 34 | 35 | ## 📄 License 36 | 37 | Vote is MIT licensed, as found in the [LICENSE][l] file. 38 | 39 | [l]: https://github.com/steam/vote-react-native/blob/master/LICENSE 40 | -------------------------------------------------------------------------------- /ios/Vote-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/screens/Screens.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC } from 'react' 2 | import { createNativeStackNavigator } from 'react-native-screens/native-stack' 3 | import { Home } from './Home' 4 | import { LocationsScreen } from './PollingLocations' 5 | import { Route, ScreenNavigatorParamList } from './types' 6 | import { CivicInfoProvider } from '../state' 7 | import { LocationScreen } from './Location' 8 | import { colors } from '../shared/style' 9 | import { en } from '../shared/i18n' 10 | import { useTranslation } from 'react-i18next' 11 | 12 | const Stack = createNativeStackNavigator() 13 | 14 | const Screens: FC = () => { 15 | const { t } = useTranslation() 16 | return ( 17 | 18 | 19 | 28 | 40 | 45 | 46 | 47 | ) 48 | } 49 | 50 | export { Screens } 51 | -------------------------------------------------------------------------------- /ios/Vote/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Vote 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UIAppFonts 43 | 44 | EvilIcons.ttf 45 | 46 | UILaunchStoryboardName 47 | LaunchScreen 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UIViewControllerBasedStatusBarAppearance 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ios/VoteTests/VoteTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface VoteTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation VoteTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: [ 4 | '@react-native-community', 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/eslint-recommended', 7 | 'plugin:@typescript-eslint/recommended', 8 | 'eslint-config-prettier', 9 | 'eslint-config-prettier/@typescript-eslint', 10 | 'plugin:react/recommended', 11 | ], 12 | parser: '@typescript-eslint/parser', 13 | plugins: [ 14 | '@typescript-eslint/eslint-plugin', 15 | 'react-hooks', 16 | 'eslint-plugin-react-native', 17 | 'sort-destructure-keys', 18 | ], 19 | parserOptions: { 20 | ecmaVersion: 2019, 21 | sourceType: 'module', 22 | ecmaFeatures: { 23 | jsx: true, 24 | }, 25 | project: './tsconfig.json', 26 | }, 27 | rules: { 28 | '@typescript-eslint/no-use-before-define': 0, 29 | semi: 0, 30 | 'react-native/no-single-element-style-arrays': 2, 31 | 'react-native/sort-styles': 2, 32 | 'react-native/no-unused-styles': 2, 33 | 'no-case-declarations': 0, 34 | 'prefer-const': 2, 35 | 'no-undef': 0, 36 | 'no-console': 1, 37 | 'react/jsx-sort-props': [ 38 | 1, 39 | { 40 | ignoreCase: true, 41 | }, 42 | ], 43 | 'react/prop-types': 0, 44 | 'react-hooks/rules-of-hooks': 2, 45 | 'react-hooks/exhaustive-deps': 1, 46 | '@typescript-eslint/strict-boolean-expressions': 1, 47 | '@typescript-eslint/camelcase': 0, 48 | '@typescript-eslint/no-explicit-any': 0, 49 | '@typescript-eslint/explicit-function-return-type': 0, 50 | '@typescript-eslint/explicit-module-boundary-types': 0, 51 | '@typescript-eslint/explicit-member-accessibility': [ 52 | 2, 53 | { 54 | overrides: { 55 | constructors: 'off', 56 | }, 57 | }, 58 | ], 59 | complexity: [1, 10], 60 | 'max-nested-callbacks': [1, 3], 61 | 'max-depth': [1, 3], 62 | 'sort-imports': [2, { ignoreCase: true, ignoreDeclarationSort: true }], 63 | 'sort-destructure-keys/sort-destructure-keys': [2, { caseSensitive: false }], 64 | }, 65 | } 66 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Vote", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx" 11 | }, 12 | "dependencies": { 13 | "@react-native-community/masked-view": "^0.1.10", 14 | "@react-navigation/native": "5.7.3", 15 | "@react-navigation/stack": "5.9.0", 16 | "i18next": "^19.8.3", 17 | "react": "16.13.1", 18 | "react-i18next": "^11.7.3", 19 | "react-native": "0.63.3", 20 | "react-native-gesture-handler": "1.8.0", 21 | "react-native-localize": "^1.4.2", 22 | "react-native-maps": "0.27.1", 23 | "react-native-reanimated": "^1.8.1", 24 | "react-native-safe-area-context": "^3.1.8", 25 | "react-native-screens": "2.10.1", 26 | "react-native-vector-icons": "^7.1.0" 27 | }, 28 | "devDependencies": { 29 | "@babel/core": "^7.8.4", 30 | "@babel/preset-env": "^7.12.1", 31 | "@babel/preset-typescript": "^7.12.1", 32 | "@babel/runtime": "^7.8.4", 33 | "@react-native-community/eslint-config": "^1.1.0", 34 | "@testing-library/jest-native": "^3.4.3", 35 | "@testing-library/react-hooks": "^3.4.2", 36 | "@testing-library/react-native": "^7.1.0", 37 | "@types/jest": "^25.2.3", 38 | "@types/react-native": "^0.63.2", 39 | "@types/react-native-maps": "^0.24.0", 40 | "@types/react-native-vector-icons": "^6.4.6", 41 | "@types/react-test-renderer": "^16.9.2", 42 | "@typescript-eslint/eslint-plugin": "^2.27.0", 43 | "@typescript-eslint/parser": "^2.27.0", 44 | "babel-jest": "^25.1.0", 45 | "eslint": "^6.5.1", 46 | "eslint-plugin-sort-destructure-keys": "^1.3.5", 47 | "jest": "^25.1.0", 48 | "jest-fetch-mock": "^3.0.3", 49 | "metro-react-native-babel-preset": "^0.59.0", 50 | "react-test-renderer": "16.13.1", 51 | "typescript": "^3.8.3" 52 | }, 53 | "jest": { 54 | "preset": "react-native", 55 | "moduleFileExtensions": [ 56 | "ts", 57 | "tsx", 58 | "js", 59 | "jsx", 60 | "json", 61 | "node" 62 | ] 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ios/Vote/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import 3 | 4 | #import 5 | #import 6 | #import 7 | 8 | #ifdef FB_SONARKIT_ENABLED 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | 16 | static void InitializeFlipper(UIApplication *application) { 17 | FlipperClient *client = [FlipperClient sharedClient]; 18 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 19 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 20 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 21 | [client addPlugin:[FlipperKitReactPlugin new]]; 22 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 23 | [client start]; 24 | } 25 | #endif 26 | 27 | @implementation AppDelegate 28 | 29 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 30 | { 31 | #ifdef FB_SONARKIT_ENABLED 32 | InitializeFlipper(application); 33 | #endif 34 | 35 | [GMSServices provideAPIKey:@"AIzaSyD9mA83rADVUdyeodS0eolK-PLp9Vb6C5I"]; 36 | 37 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 38 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 39 | moduleName:@"Vote" 40 | initialProperties:nil]; 41 | 42 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 43 | 44 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 45 | UIViewController *rootViewController = [UIViewController new]; 46 | rootViewController.view = rootView; 47 | self.window.rootViewController = rootViewController; 48 | [self.window makeKeyAndVisible]; 49 | return YES; 50 | } 51 | 52 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 53 | { 54 | #if DEBUG 55 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 56 | #else 57 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 58 | #endif 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /ios/Vote/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/screens/Home.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC, useState } from 'react' 2 | import { Image, ScrollView, StatusBar, StyleSheet, Text, TextInput } from 'react-native' 3 | import { RouteProp } from '@react-navigation/native' 4 | import { Route, ScreenNavigatorParamList } from './types' 5 | import { NativeStackNavigationProp } from 'react-native-screens/lib/typescript/types' 6 | import { colors } from '../shared/style' 7 | import { Button } from '../shared/buttons/Button' 8 | import { useTranslation } from 'react-i18next' 9 | import { en } from '../shared/i18n' 10 | 11 | type HomeScreenRouteProp = RouteProp 12 | 13 | type HomeScreenNavigationProp = NativeStackNavigationProp< 14 | ScreenNavigatorParamList, 15 | Route.HOME 16 | > 17 | 18 | type Props = { 19 | navigation: HomeScreenNavigationProp 20 | route: HomeScreenRouteProp 21 | } 22 | 23 | const Home: FC = ({ navigation }) => { 24 | const { t } = useTranslation() 25 | 26 | // const [address, setAddress] = useState( 27 | // '10174 E. 59th Ave, Denver, CO 80238', 28 | // ) 29 | const [address, setAddress] = useState(undefined) 30 | const onPress = () => { 31 | if (address !== undefined) { 32 | navigation.navigate(Route.POLLING_LOCATIONS, { address }) 33 | } 34 | } 35 | const onChangeAddress = (text: string) => { 36 | setAddress(text) 37 | } 38 | return ( 39 | <> 40 | 41 | 42 | 43 | 51 |