├── .gitignore ├── CREDITS ├── README.md ├── ReactNativeHackerNews.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── ReactNativeHackerNews.xccheckout ├── xcshareddata │ └── xcschemes │ │ └── ReactNativeHackerNews.xcscheme └── xcuserdata │ └── jfriend.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Routes.js ├── components ├── ArticleScreen.js ├── Badge.js ├── Comment.js ├── CommentsScreen.js ├── Loading.js ├── Refreshing.js ├── StoreWatchMixin.js ├── StoryListItem.js ├── Text.js ├── TopStoriesScreen.js ├── View.js ├── baseStyles.js └── colors.js ├── config.js ├── iOS ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── LaunchScreen.xib ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── iPhoneApp-60x60@2x.png │ │ ├── iPhoneSettings-29x29@2x.png │ │ └── iPhoneSpotlight-40x40@2x-1.png │ ├── comment.imageset │ │ ├── Contents.json │ │ └── comment.png │ ├── disclosure.imageset │ │ ├── Contents.json │ │ └── disclosure.png │ └── disclosure90.imageset │ │ ├── Contents.json │ │ └── disclosure90.png ├── Info.plist └── main.m ├── images ├── comment.png ├── disclosure.png ├── disclosure90.png └── hackernews-icon.png ├── index.ios.js ├── package.json ├── stores ├── Collection.js ├── Story.js └── TopStory.js └── util └── merge.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore docs files 2 | _gh_pages 3 | _site 4 | .ruby-version 5 | 6 | # Numerous always-ignore extensions 7 | *.diff 8 | *.err 9 | *.orig 10 | *.log 11 | *.rej 12 | *.swo 13 | *.swp 14 | *.zip 15 | *.vi 16 | *~ 17 | 18 | # OS or Editor folders 19 | .DS_Store 20 | ._* 21 | Thumbs.db 22 | .cache 23 | .project 24 | .settings 25 | .tmproj 26 | *.esproj 27 | nbproject 28 | *.sublime-project 29 | *.sublime-workspace 30 | .idea 31 | 32 | # Xcode 33 | UserInterfaceState.xcuserstate 34 | xcuserdata 35 | 36 | # Komodo 37 | *.komodoproject 38 | .komodotools 39 | 40 | # Folders to ignore 41 | node_modules 42 | bower_components 43 | 44 | lib/ 45 | example/output/ 46 | 47 | main.jsbundle 48 | 49 | images/generated/ 50 | 51 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | Speech Bubble icon (https://thenounproject.com/term/speech-bubble/60326/) © Michael Zenaty, available under a Creative Commons – Attribution (CC BY 3.0) license 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactNativeHackerNews 2 | 3 | React Native-based Hacker News reading app 4 | 5 | Uses [hacker-news-mobile-api](https://github.com/jsdf/hacker-news-mobile-api) 6 | 7 | This app is a descendent of my isomorphic React-based Hacker News mobile web app, [hacker-news-mobile](https://github.com/jsdf/hacker-news-mobile) 8 | 9 | ### pretty pictures 10 | 11 | ![React Native Hacker News](http://i.imgur.com/gVmrxDe.png) 12 | ![React Native Hacker News Comments](http://i.imgur.com/FYOgBYc.png) 13 | 14 | Speech Bubble icon (https://thenounproject.com/term/speech-bubble/60326/) © Michael Zenaty, available under a [Creative Commons – Attribution (CC BY 3.0)](https://creativecommons.org/licenses/by/3.0/us/) license. 15 | -------------------------------------------------------------------------------- /ReactNativeHackerNews.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */; }; 11 | 00481BEA1AC0C89D00671115 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 00481BE91AC0C89D00671115 /* libicucore.dylib */; }; 12 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 13 | 00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */; }; 14 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 15 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; 16 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; 17 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; 18 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 19 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 20 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 21 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 22 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 23 | 73C21DEF1ACAD782001F6793 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73C21DEE1ACAD719001F6793 /* libRCTLinking.a */; }; 24 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 00481BE51AC0C7FA00671115 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */; 31 | proxyType = 2; 32 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 33 | remoteInfo = RCTWebSocketDebugger; 34 | }; 35 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { 36 | isa = PBXContainerItemProxy; 37 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 38 | proxyType = 2; 39 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 40 | remoteInfo = RCTActionSheet; 41 | }; 42 | 00C302B31ABCB8E700DB3ED1 /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */; 45 | proxyType = 2; 46 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 47 | remoteInfo = RCTAdSupport; 48 | }; 49 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { 50 | isa = PBXContainerItemProxy; 51 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 52 | proxyType = 2; 53 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 54 | remoteInfo = RCTGeolocation; 55 | }; 56 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { 57 | isa = PBXContainerItemProxy; 58 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 59 | proxyType = 2; 60 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 61 | remoteInfo = RCTImage; 62 | }; 63 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { 64 | isa = PBXContainerItemProxy; 65 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 66 | proxyType = 2; 67 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 68 | remoteInfo = RCTNetwork; 69 | }; 70 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { 71 | isa = PBXContainerItemProxy; 72 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 73 | proxyType = 2; 74 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 75 | remoteInfo = RCTVibration; 76 | }; 77 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { 78 | isa = PBXContainerItemProxy; 79 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 80 | proxyType = 2; 81 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 82 | remoteInfo = React; 83 | }; 84 | 73C21DED1ACAD719001F6793 /* PBXContainerItemProxy */ = { 85 | isa = PBXContainerItemProxy; 86 | containerPortal = 73C21DE91ACAD719001F6793 /* RCTLinking.xcodeproj */; 87 | proxyType = 2; 88 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 89 | remoteInfo = RCTLinking; 90 | }; 91 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { 92 | isa = PBXContainerItemProxy; 93 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 94 | proxyType = 2; 95 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 96 | remoteInfo = RCTText; 97 | }; 98 | /* End PBXContainerItemProxy section */ 99 | 100 | /* Begin PBXFileReference section */ 101 | 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocketDebugger.xcodeproj; path = "node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj"; sourceTree = ""; }; 102 | 00481BE91AC0C89D00671115 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; }; 103 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; 104 | 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = "node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj"; sourceTree = ""; }; 105 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; 106 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; 107 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 108 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; 109 | 13B07F961A680F5B00A75B9A /* ReactNativeHackerNews.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReactNativeHackerNews.app; sourceTree = BUILT_PRODUCTS_DIR; }; 110 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = iOS/AppDelegate.h; sourceTree = ""; }; 111 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = iOS/AppDelegate.m; sourceTree = ""; }; 112 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 113 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = iOS/Images.xcassets; sourceTree = ""; }; 114 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = iOS/Info.plist; sourceTree = ""; }; 115 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = iOS/main.m; sourceTree = ""; }; 116 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; 117 | 73C21DE91ACAD719001F6793 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "node_modules/react-native/Libraries/Image/../LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 118 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 119 | /* End PBXFileReference section */ 120 | 121 | /* Begin PBXFrameworksBuildPhase section */ 122 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 123 | isa = PBXFrameworksBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 73C21DEF1ACAD782001F6793 /* libRCTLinking.a in Frameworks */, 127 | 00481BEA1AC0C89D00671115 /* libicucore.dylib in Frameworks */, 128 | 146834051AC3E58100842450 /* libReact.a in Frameworks */, 129 | 00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */, 130 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 131 | 00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */, 132 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 133 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 134 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 135 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 136 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXFrameworksBuildPhase section */ 141 | 142 | /* Begin PBXGroup section */ 143 | 00481BDC1AC0C7FA00671115 /* Products */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */, 147 | ); 148 | name = Products; 149 | sourceTree = ""; 150 | }; 151 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, 155 | ); 156 | name = Products; 157 | sourceTree = ""; 158 | }; 159 | 00C302B01ABCB8E700DB3ED1 /* Products */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */, 163 | ); 164 | name = Products; 165 | sourceTree = ""; 166 | }; 167 | 00C302B61ABCB90400DB3ED1 /* Products */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, 171 | ); 172 | name = Products; 173 | sourceTree = ""; 174 | }; 175 | 00C302BC1ABCB91800DB3ED1 /* Products */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, 179 | ); 180 | name = Products; 181 | sourceTree = ""; 182 | }; 183 | 00C302D41ABCB9D200DB3ED1 /* Products */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, 187 | ); 188 | name = Products; 189 | sourceTree = ""; 190 | }; 191 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, 195 | ); 196 | name = Products; 197 | sourceTree = ""; 198 | }; 199 | 13B07FAE1A68108700A75B9A /* ReactNativeHackerNews */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 203 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 204 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 205 | 13B07FB61A68108700A75B9A /* Info.plist */, 206 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 207 | 13B07FB71A68108700A75B9A /* main.m */, 208 | ); 209 | name = ReactNativeHackerNews; 210 | sourceTree = ""; 211 | }; 212 | 146834001AC3E56700842450 /* Products */ = { 213 | isa = PBXGroup; 214 | children = ( 215 | 146834041AC3E56700842450 /* libReact.a */, 216 | ); 217 | name = Products; 218 | sourceTree = ""; 219 | }; 220 | 73C21DEA1ACAD719001F6793 /* Products */ = { 221 | isa = PBXGroup; 222 | children = ( 223 | 73C21DEE1ACAD719001F6793 /* libRCTLinking.a */, 224 | ); 225 | name = Products; 226 | sourceTree = ""; 227 | }; 228 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 229 | isa = PBXGroup; 230 | children = ( 231 | 73C21DE91ACAD719001F6793 /* RCTLinking.xcodeproj */, 232 | 146833FF1AC3E56700842450 /* React.xcodeproj */, 233 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 234 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 235 | 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */, 236 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 237 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, 238 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, 239 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 240 | 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */, 241 | 00481BE91AC0C89D00671115 /* libicucore.dylib */, 242 | ); 243 | name = Libraries; 244 | sourceTree = ""; 245 | }; 246 | 832341B11AAA6A8300B99B32 /* Products */ = { 247 | isa = PBXGroup; 248 | children = ( 249 | 832341B51AAA6A8300B99B32 /* libRCTText.a */, 250 | ); 251 | name = Products; 252 | sourceTree = ""; 253 | }; 254 | 83CBB9F61A601CBA00E9B192 = { 255 | isa = PBXGroup; 256 | children = ( 257 | 13B07FAE1A68108700A75B9A /* ReactNativeHackerNews */, 258 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 259 | 83CBBA001A601CBA00E9B192 /* Products */, 260 | ); 261 | sourceTree = ""; 262 | }; 263 | 83CBBA001A601CBA00E9B192 /* Products */ = { 264 | isa = PBXGroup; 265 | children = ( 266 | 13B07F961A680F5B00A75B9A /* ReactNativeHackerNews.app */, 267 | ); 268 | name = Products; 269 | sourceTree = ""; 270 | }; 271 | /* End PBXGroup section */ 272 | 273 | /* Begin PBXNativeTarget section */ 274 | 13B07F861A680F5B00A75B9A /* ReactNativeHackerNews */ = { 275 | isa = PBXNativeTarget; 276 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ReactNativeHackerNews" */; 277 | buildPhases = ( 278 | 13B07F871A680F5B00A75B9A /* Sources */, 279 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 280 | 13B07F8E1A680F5B00A75B9A /* Resources */, 281 | ); 282 | buildRules = ( 283 | ); 284 | dependencies = ( 285 | ); 286 | name = ReactNativeHackerNews; 287 | productName = "Hello World"; 288 | productReference = 13B07F961A680F5B00A75B9A /* ReactNativeHackerNews.app */; 289 | productType = "com.apple.product-type.application"; 290 | }; 291 | /* End PBXNativeTarget section */ 292 | 293 | /* Begin PBXProject section */ 294 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 295 | isa = PBXProject; 296 | attributes = { 297 | LastUpgradeCheck = 0610; 298 | ORGANIZATIONNAME = Facebook; 299 | TargetAttributes = { 300 | 13B07F861A680F5B00A75B9A = { 301 | DevelopmentTeam = 9W54YB5T38; 302 | }; 303 | }; 304 | }; 305 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactNativeHackerNews" */; 306 | compatibilityVersion = "Xcode 3.2"; 307 | developmentRegion = English; 308 | hasScannedForEncodings = 0; 309 | knownRegions = ( 310 | en, 311 | Base, 312 | ); 313 | mainGroup = 83CBB9F61A601CBA00E9B192; 314 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 315 | projectDirPath = ""; 316 | projectReferences = ( 317 | { 318 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; 319 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 320 | }, 321 | { 322 | ProductGroup = 00C302B01ABCB8E700DB3ED1 /* Products */; 323 | ProjectRef = 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */; 324 | }, 325 | { 326 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; 327 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 328 | }, 329 | { 330 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; 331 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 332 | }, 333 | { 334 | ProductGroup = 73C21DEA1ACAD719001F6793 /* Products */; 335 | ProjectRef = 73C21DE91ACAD719001F6793 /* RCTLinking.xcodeproj */; 336 | }, 337 | { 338 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; 339 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 340 | }, 341 | { 342 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; 343 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 344 | }, 345 | { 346 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; 347 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 348 | }, 349 | { 350 | ProductGroup = 00481BDC1AC0C7FA00671115 /* Products */; 351 | ProjectRef = 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */; 352 | }, 353 | { 354 | ProductGroup = 146834001AC3E56700842450 /* Products */; 355 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; 356 | }, 357 | ); 358 | projectRoot = ""; 359 | targets = ( 360 | 13B07F861A680F5B00A75B9A /* ReactNativeHackerNews */, 361 | ); 362 | }; 363 | /* End PBXProject section */ 364 | 365 | /* Begin PBXReferenceProxy section */ 366 | 00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */ = { 367 | isa = PBXReferenceProxy; 368 | fileType = archive.ar; 369 | path = libRCTWebSocketDebugger.a; 370 | remoteRef = 00481BE51AC0C7FA00671115 /* PBXContainerItemProxy */; 371 | sourceTree = BUILT_PRODUCTS_DIR; 372 | }; 373 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { 374 | isa = PBXReferenceProxy; 375 | fileType = archive.ar; 376 | path = libRCTActionSheet.a; 377 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; 378 | sourceTree = BUILT_PRODUCTS_DIR; 379 | }; 380 | 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */ = { 381 | isa = PBXReferenceProxy; 382 | fileType = archive.ar; 383 | path = libRCTAdSupport.a; 384 | remoteRef = 00C302B31ABCB8E700DB3ED1 /* PBXContainerItemProxy */; 385 | sourceTree = BUILT_PRODUCTS_DIR; 386 | }; 387 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { 388 | isa = PBXReferenceProxy; 389 | fileType = archive.ar; 390 | path = libRCTGeolocation.a; 391 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; 392 | sourceTree = BUILT_PRODUCTS_DIR; 393 | }; 394 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { 395 | isa = PBXReferenceProxy; 396 | fileType = archive.ar; 397 | path = libRCTImage.a; 398 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; 399 | sourceTree = BUILT_PRODUCTS_DIR; 400 | }; 401 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { 402 | isa = PBXReferenceProxy; 403 | fileType = archive.ar; 404 | path = libRCTNetwork.a; 405 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; 406 | sourceTree = BUILT_PRODUCTS_DIR; 407 | }; 408 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { 409 | isa = PBXReferenceProxy; 410 | fileType = archive.ar; 411 | path = libRCTVibration.a; 412 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; 413 | sourceTree = BUILT_PRODUCTS_DIR; 414 | }; 415 | 146834041AC3E56700842450 /* libReact.a */ = { 416 | isa = PBXReferenceProxy; 417 | fileType = archive.ar; 418 | path = libReact.a; 419 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; 420 | sourceTree = BUILT_PRODUCTS_DIR; 421 | }; 422 | 73C21DEE1ACAD719001F6793 /* libRCTLinking.a */ = { 423 | isa = PBXReferenceProxy; 424 | fileType = archive.ar; 425 | path = libRCTLinking.a; 426 | remoteRef = 73C21DED1ACAD719001F6793 /* PBXContainerItemProxy */; 427 | sourceTree = BUILT_PRODUCTS_DIR; 428 | }; 429 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { 430 | isa = PBXReferenceProxy; 431 | fileType = archive.ar; 432 | path = libRCTText.a; 433 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; 434 | sourceTree = BUILT_PRODUCTS_DIR; 435 | }; 436 | /* End PBXReferenceProxy section */ 437 | 438 | /* Begin PBXResourcesBuildPhase section */ 439 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 440 | isa = PBXResourcesBuildPhase; 441 | buildActionMask = 2147483647; 442 | files = ( 443 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 444 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 445 | ); 446 | runOnlyForDeploymentPostprocessing = 0; 447 | }; 448 | /* End PBXResourcesBuildPhase section */ 449 | 450 | /* Begin PBXSourcesBuildPhase section */ 451 | 13B07F871A680F5B00A75B9A /* Sources */ = { 452 | isa = PBXSourcesBuildPhase; 453 | buildActionMask = 2147483647; 454 | files = ( 455 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 456 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 457 | ); 458 | runOnlyForDeploymentPostprocessing = 0; 459 | }; 460 | /* End PBXSourcesBuildPhase section */ 461 | 462 | /* Begin PBXVariantGroup section */ 463 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 464 | isa = PBXVariantGroup; 465 | children = ( 466 | 13B07FB21A68108700A75B9A /* Base */, 467 | ); 468 | name = LaunchScreen.xib; 469 | path = iOS; 470 | sourceTree = ""; 471 | }; 472 | /* End PBXVariantGroup section */ 473 | 474 | /* Begin XCBuildConfiguration section */ 475 | 13B07F941A680F5B00A75B9A /* Debug */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 479 | CODE_SIGN_IDENTITY = "iPhone Developer"; 480 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 481 | HEADER_SEARCH_PATHS = ( 482 | "$(inherited)", 483 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 484 | "$(SRCROOT)/node_modules/react-native/React/**", 485 | ); 486 | INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 488 | OTHER_LDFLAGS = "-ObjC"; 489 | PRODUCT_NAME = ReactNativeHackerNews; 490 | PROVISIONING_PROFILE = ""; 491 | }; 492 | name = Debug; 493 | }; 494 | 13B07F951A680F5B00A75B9A /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 498 | CODE_SIGN_IDENTITY = "iPhone Developer"; 499 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 500 | HEADER_SEARCH_PATHS = ( 501 | "$(inherited)", 502 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 503 | "$(SRCROOT)/node_modules/react-native/React/**", 504 | ); 505 | INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 507 | OTHER_LDFLAGS = "-ObjC"; 508 | PRODUCT_NAME = ReactNativeHackerNews; 509 | PROVISIONING_PROFILE = ""; 510 | }; 511 | name = Release; 512 | }; 513 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ALWAYS_SEARCH_USER_PATHS = NO; 517 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 518 | CLANG_CXX_LIBRARY = "libc++"; 519 | CLANG_ENABLE_MODULES = YES; 520 | CLANG_ENABLE_OBJC_ARC = YES; 521 | CLANG_WARN_BOOL_CONVERSION = YES; 522 | CLANG_WARN_CONSTANT_CONVERSION = YES; 523 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 524 | CLANG_WARN_EMPTY_BODY = YES; 525 | CLANG_WARN_ENUM_CONVERSION = YES; 526 | CLANG_WARN_INT_CONVERSION = YES; 527 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 528 | CLANG_WARN_UNREACHABLE_CODE = YES; 529 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 530 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 531 | COPY_PHASE_STRIP = NO; 532 | ENABLE_STRICT_OBJC_MSGSEND = YES; 533 | GCC_C_LANGUAGE_STANDARD = gnu99; 534 | GCC_DYNAMIC_NO_PIC = NO; 535 | GCC_OPTIMIZATION_LEVEL = 0; 536 | GCC_PREPROCESSOR_DEFINITIONS = ( 537 | "DEBUG=1", 538 | "$(inherited)", 539 | ); 540 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 541 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 542 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 543 | GCC_WARN_UNDECLARED_SELECTOR = YES; 544 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 545 | GCC_WARN_UNUSED_FUNCTION = YES; 546 | GCC_WARN_UNUSED_VARIABLE = YES; 547 | HEADER_SEARCH_PATHS = ( 548 | "$(inherited)", 549 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 550 | "$(SRCROOT)/node_modules/react-native/React/**", 551 | ); 552 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 553 | MTL_ENABLE_DEBUG_INFO = YES; 554 | ONLY_ACTIVE_ARCH = YES; 555 | SDKROOT = iphoneos; 556 | }; 557 | name = Debug; 558 | }; 559 | 83CBBA211A601CBA00E9B192 /* Release */ = { 560 | isa = XCBuildConfiguration; 561 | buildSettings = { 562 | ALWAYS_SEARCH_USER_PATHS = NO; 563 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 564 | CLANG_CXX_LIBRARY = "libc++"; 565 | CLANG_ENABLE_MODULES = YES; 566 | CLANG_ENABLE_OBJC_ARC = YES; 567 | CLANG_WARN_BOOL_CONVERSION = YES; 568 | CLANG_WARN_CONSTANT_CONVERSION = YES; 569 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 570 | CLANG_WARN_EMPTY_BODY = YES; 571 | CLANG_WARN_ENUM_CONVERSION = YES; 572 | CLANG_WARN_INT_CONVERSION = YES; 573 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 574 | CLANG_WARN_UNREACHABLE_CODE = YES; 575 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 576 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 577 | COPY_PHASE_STRIP = YES; 578 | ENABLE_NS_ASSERTIONS = NO; 579 | ENABLE_STRICT_OBJC_MSGSEND = YES; 580 | GCC_C_LANGUAGE_STANDARD = gnu99; 581 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 582 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 583 | GCC_WARN_UNDECLARED_SELECTOR = YES; 584 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 585 | GCC_WARN_UNUSED_FUNCTION = YES; 586 | GCC_WARN_UNUSED_VARIABLE = YES; 587 | HEADER_SEARCH_PATHS = ( 588 | "$(inherited)", 589 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 590 | "$(SRCROOT)/node_modules/react-native/React/**", 591 | ); 592 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 593 | MTL_ENABLE_DEBUG_INFO = NO; 594 | SDKROOT = iphoneos; 595 | VALIDATE_PRODUCT = YES; 596 | }; 597 | name = Release; 598 | }; 599 | /* End XCBuildConfiguration section */ 600 | 601 | /* Begin XCConfigurationList section */ 602 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ReactNativeHackerNews" */ = { 603 | isa = XCConfigurationList; 604 | buildConfigurations = ( 605 | 13B07F941A680F5B00A75B9A /* Debug */, 606 | 13B07F951A680F5B00A75B9A /* Release */, 607 | ); 608 | defaultConfigurationIsVisible = 0; 609 | defaultConfigurationName = Release; 610 | }; 611 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactNativeHackerNews" */ = { 612 | isa = XCConfigurationList; 613 | buildConfigurations = ( 614 | 83CBBA201A601CBA00E9B192 /* Debug */, 615 | 83CBBA211A601CBA00E9B192 /* Release */, 616 | ); 617 | defaultConfigurationIsVisible = 0; 618 | defaultConfigurationName = Release; 619 | }; 620 | /* End XCConfigurationList section */ 621 | }; 622 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 623 | } 624 | -------------------------------------------------------------------------------- /ReactNativeHackerNews.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ReactNativeHackerNews.xcodeproj/project.xcworkspace/xcshareddata/ReactNativeHackerNews.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 382509EF-E93C-4744-BD99-C09AA9E555CA 9 | IDESourceControlProjectName 10 | ReactNativeHackerNews 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 19EF99C2D44FB5C98C7FBFCB53F31BE736AB780D 14 | github.com:jsdf/ReactNativeHackerNews.git 15 | 16 | IDESourceControlProjectPath 17 | ReactNativeHackerNews.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 19EF99C2D44FB5C98C7FBFCB53F31BE736AB780D 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:jsdf/ReactNativeHackerNews.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 19EF99C2D44FB5C98C7FBFCB53F31BE736AB780D 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 19EF99C2D44FB5C98C7FBFCB53F31BE736AB780D 36 | IDESourceControlWCCName 37 | ReactNativeHackerNews 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ReactNativeHackerNews.xcodeproj/xcshareddata/xcschemes/ReactNativeHackerNews.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ReactNativeHackerNews.xcodeproj/xcuserdata/jfriend.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ReactNativeHackerNews.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 13B07F861A680F5B00A75B9A 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Routes.js: -------------------------------------------------------------------------------- 1 | class Routes { 2 | static register(name, handler) { 3 | if (this.handlers == null) this.handlers = {} 4 | this.handlers[name] = handler 5 | } 6 | static get(name, params) { 7 | if (this.handlers[name] == null) throw new Error('unknown route') 8 | return this.handlers[name](params) 9 | } 10 | static TopStories() { 11 | return { 12 | component: require('./components/TopStoriesScreen'), 13 | title: 'Top Stories', 14 | } 15 | } 16 | static Article(story) { 17 | return { 18 | component: require('./components/ArticleScreen'), 19 | title: story.title, 20 | passProps: {url: story.url} 21 | } 22 | } 23 | static Link(url) { 24 | return { 25 | component: require('./components/ArticleScreen'), 26 | title: url, 27 | passProps: {url: url} 28 | } 29 | } 30 | static Comments(story) { 31 | if (story == null) throw new Error('missing argument: story') 32 | 33 | var route = { 34 | component: require('./components/CommentsScreen'), 35 | title: 'Comments', 36 | } 37 | 38 | // TODO: get title from store? 39 | if (story.title) route.title = `Comments – ${story.title}` 40 | 41 | route.passProps = {storyId: story.id} 42 | 43 | return route 44 | } 45 | } 46 | 47 | module.exports = Routes 48 | -------------------------------------------------------------------------------- /components/ArticleScreen.js: -------------------------------------------------------------------------------- 1 | var moment = require('moment') 2 | var React = require('react-native') 3 | var { 4 | WebView, 5 | ScrollView, 6 | StyleSheet, 7 | } = React 8 | 9 | var Routes = require('../Routes') 10 | var View = require('./View') 11 | var Text = require('./Text') 12 | var Loading = require('./Loading') 13 | 14 | var ArticleScreen = React.createClass({ 15 | renderError(domain, code, description) { 16 | return error :( - {description} 17 | }, 18 | renderLoading() { 19 | return ( 20 | 21 | article 22 | 23 | ) 24 | }, 25 | render() { 26 | return ( 27 | 32 | ) 33 | } 34 | }) 35 | 36 | var styles = StyleSheet.create({ 37 | contentContainer: { 38 | padding: 10, 39 | }, 40 | }) 41 | 42 | module.exports = ArticleScreen 43 | -------------------------------------------------------------------------------- /components/Badge.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | var { 3 | View, 4 | Text, 5 | StyleSheet, 6 | } = React 7 | 8 | var Badge = React.createClass({ 9 | render() { 10 | return ( 11 | 12 | 13 | 14 | ) 15 | } 16 | }) 17 | 18 | var styles = StyleSheet.create({ 19 | badge: { 20 | margin: 0, 21 | padding: 0, 22 | backgroundColor: '#dddddd', 23 | borderColor: '#dddddd', 24 | borderRadius: 10, 25 | borderWidth: 4, 26 | }, 27 | badgeText: { 28 | margin: 0, 29 | padding: 0, 30 | fontSize: 9, 31 | backgroundColor: '#dddddd', 32 | }, 33 | }) 34 | 35 | module.exports = Badge 36 | -------------------------------------------------------------------------------- /components/Comment.js: -------------------------------------------------------------------------------- 1 | var moment = require('moment') 2 | var React = require('react-native') 3 | var { 4 | TouchableHighlight, 5 | StyleSheet, 6 | Image, 7 | PixelRatio, 8 | } = React 9 | var HTMLView = require('react-native-htmlview') 10 | 11 | var View = require('./View') 12 | var Text = require('./Text') 13 | var colors = require('./colors') 14 | 15 | var Comment = React.createClass({ 16 | getInitialState() { 17 | return { 18 | open: true, 19 | } 20 | }, 21 | handleDisclosureClick(e) { 22 | this.setState({open: !this.state.open}) 23 | }, 24 | renderBody(comment) { 25 | return ( 26 | 27 | 28 | {comment.childItems ? : null} 29 | 30 | ) 31 | }, 32 | render() { 33 | var {comment} = this.props 34 | var {open} = this.state 35 | 36 | if (comment == null) return null 37 | 38 | return ( 39 | 40 | 41 | 42 | 46 | 47 | {' '} 48 | {moment(comment.time*1000).fromNow()} by {comment.by} 49 | 50 | 51 | 52 | {open ? this.renderBody(comment) : null} 53 | 54 | ) 55 | } 56 | }) 57 | 58 | var CommentList = React.createClass({ 59 | renderComment(comment) { 60 | return 61 | }, 62 | render() { 63 | return ( 64 | 65 | {this.props.comments.map(this.renderComment)} 66 | 67 | ) 68 | } 69 | }) 70 | 71 | var styles = StyleSheet.create({ 72 | inline: { 73 | flexDirection: 'row', 74 | }, 75 | muted: { 76 | opacity: 0.3, 77 | }, 78 | textMuted: { 79 | color: colors.grey 80 | }, 81 | comment: { 82 | margin: 4, 83 | padding: 4, 84 | }, 85 | commentBody: { 86 | paddingLeft: 10, 87 | borderLeftColor: colors.grey, 88 | borderLeftWidth: 1 / PixelRatio.get(), 89 | }, 90 | disclosure: { 91 | width: 14, 92 | height: 14, 93 | marginLeft: 2, 94 | marginRight: 8, 95 | }, 96 | disclosureRow: { 97 | paddingLeft: 0, 98 | paddingTop: 4, 99 | paddingBottom: 4, 100 | }, 101 | }) 102 | 103 | module.exports = Comment 104 | -------------------------------------------------------------------------------- /components/CommentsScreen.js: -------------------------------------------------------------------------------- 1 | var _ = require('underscore') 2 | var moment = require('moment') 3 | var React = require('react-native') 4 | var { 5 | ListView, 6 | StyleSheet, 7 | } = React 8 | var RefreshableListView = require('react-native-refreshable-listview') 9 | 10 | var Story = require('../stores/Story') 11 | var Routes = require('../Routes') 12 | var StoreWatchMixin = require('./StoreWatchMixin') 13 | var View = require('./View') 14 | var Text = require('./Text') 15 | var Badge = require('./Badge') 16 | var Loading = require('./Loading') 17 | var Comment = require('./Comment') 18 | 19 | var baseDataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.id !== r2.id}) 20 | 21 | var CommentsScreen = React.createClass({ 22 | mixins: [ 23 | StoreWatchMixin, 24 | ], 25 | getInitialState() { 26 | return { 27 | dataSource: baseDataSource.cloneWithRows(this.getComments() || []), 28 | } 29 | }, 30 | componentDidMount() { 31 | if (!this.getStory()) this.loadStory() 32 | }, 33 | getStoreWatches() { 34 | this.watchStore(Story, _.debounce(() => { 35 | if (this.isMounted()) { 36 | this.setState({ 37 | dataSource: baseDataSource.cloneWithRows(this.getComments() || []), 38 | }) 39 | } 40 | }, 100)) 41 | }, 42 | loadStory(callback) { 43 | Story.fetch(this.props.storyId).then(callback) 44 | }, 45 | getStory() { 46 | return Story.get(this.props.storyId) 47 | }, 48 | getComments() { 49 | var story = this.getStory() 50 | return story && story.childItems || null 51 | }, 52 | isLoaded() { 53 | return this.getComments() != null 54 | }, 55 | renderComment(comment) { 56 | return 57 | }, 58 | render() { 59 | if (!this.isLoaded()) { 60 | return comments 61 | } else { 62 | return ( 63 | 69 | ) 70 | } 71 | } 72 | }) 73 | 74 | var styles = StyleSheet.create({ 75 | }) 76 | 77 | module.exports = CommentsScreen 78 | -------------------------------------------------------------------------------- /components/Loading.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | var { 3 | ActivityIndicatorIOS, 4 | StyleSheet, 5 | } = React 6 | 7 | var View = require('./View') 8 | var Text = require('./Text') 9 | 10 | var Loading = React.createClass({ 11 | render() { 12 | return ( 13 | 14 | 15 | Loading {this.props.children} 16 | 17 | 18 | 19 | ) 20 | } 21 | }) 22 | 23 | var styles = StyleSheet.create({ 24 | container: { 25 | flex: 1, 26 | justifyContent: 'center', 27 | alignItems: 'center', 28 | backgroundColor: 'white', 29 | }, 30 | loading: { 31 | justifyContent: 'space-around', 32 | margin: 50, 33 | height: 70, 34 | }, 35 | }) 36 | 37 | module.exports = Loading 38 | -------------------------------------------------------------------------------- /components/Refreshing.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | var { 3 | ActivityIndicatorIOS, 4 | StyleSheet, 5 | } = React 6 | 7 | var View = require('./View') 8 | var Text = require('./Text') 9 | 10 | var Refreshing = React.createClass({ 11 | render() { 12 | return ( 13 | 14 | 15 | Refreshing {this.props.children} 16 | 17 | 18 | 19 | ) 20 | } 21 | }) 22 | 23 | var styles = StyleSheet.create({ 24 | wrapper: { 25 | height: 60, 26 | marginTop: 10, 27 | }, 28 | container: { 29 | flex: 1, 30 | justifyContent: 'space-around', 31 | alignItems: 'center', 32 | backgroundColor: 'white', 33 | }, 34 | loading: { 35 | height: 60, 36 | }, 37 | }) 38 | 39 | module.exports = Refreshing 40 | -------------------------------------------------------------------------------- /components/StoreWatchMixin.js: -------------------------------------------------------------------------------- 1 | var StoreWatchMixin = { 2 | watchStore(store, handler) { 3 | this.storeWatches = this.storeWatches || new Map 4 | this.storeWatches.set(store, handler || this.defaultStoreWatchHandler) 5 | }, 6 | componentDidMount() { 7 | if (typeof this.getStoreWatches != 'function') return 8 | this.getStoreWatches() 9 | 10 | if (!this.storeWatches) return 11 | for (var watch of this.storeWatches) { 12 | var [store, handler] = watch 13 | store.addListener('change', handler) 14 | } 15 | }, 16 | componentWillUnmount() { 17 | if (!this.storeWatches) return 18 | for (var watch of this.storeWatches) { 19 | var [store, handler] = watch 20 | store.removeListener('change', handler) 21 | } 22 | }, 23 | defaultStoreWatchHandler() { 24 | if (this.isMounted()) { 25 | this.forceUpdate() 26 | } 27 | }, 28 | } 29 | 30 | module.exports = StoreWatchMixin 31 | -------------------------------------------------------------------------------- /components/StoryListItem.js: -------------------------------------------------------------------------------- 1 | var moment = require('moment') 2 | var React = require('react-native') 3 | var { 4 | Image, 5 | PixelRatio, 6 | StyleSheet, 7 | TouchableHighlight 8 | } = React 9 | 10 | var View = require('./View') 11 | var Text = require('./Text') 12 | var Badge = require('./Badge') 13 | 14 | var StoryListItem = React.createClass({ 15 | handleSelectArticle() { 16 | this.props.onSelectArticle(this.props.story) 17 | }, 18 | handleSelectComments() { 19 | this.props.onSelectComments(this.props.story) 20 | }, 21 | renderTitle(story) { 22 | return ( 23 | 24 | {story.position}. {story.title} 25 | 26 | ) 27 | }, 28 | renderByline(story) { 29 | return ( 30 | 31 | {story.score} points 32 | 33 | 34 | {' '} 35 | submitted {moment(story.time*1000).fromNow()} by {story.by} 36 | 37 | 38 | 39 | ) 40 | }, 41 | renderArticleButton() { 42 | var {story} = this.props 43 | 44 | return ( 45 | 46 | 47 | 48 | {this.renderTitle(story)} 49 | {this.renderByline(story)} 50 | 51 | 52 | 53 | ) 54 | }, 55 | renderCommentsButton() { 56 | var {story} = this.props 57 | 58 | return ( 59 | 60 | 61 | 65 | {story.descendants} comments 66 | 67 | 68 | ) 69 | }, 70 | render() { 71 | return ( 72 | 73 | 74 | {this.renderArticleButton()} 75 | {this.renderCommentsButton()} 76 | 77 | 78 | 79 | ) 80 | } 81 | }) 82 | 83 | var cellPadding = 8 84 | 85 | var styles = StyleSheet.create({ 86 | white: { 87 | backgroundColor: 'white', 88 | }, 89 | textContainer: { 90 | flex: 1, 91 | backgroundColor: 'white', 92 | }, 93 | icon: { 94 | width: 32, 95 | height: 32, 96 | }, 97 | storyCell: { 98 | flex: 1, 99 | flexDirection: 'column', 100 | flexWrap: 'nowrap', 101 | justifyContent: 'space-around', 102 | alignItems: 'stretch', 103 | padding: cellPadding, 104 | }, 105 | storyTitle: { 106 | height: 44, 107 | fontSize: 16, 108 | fontWeight: '500', 109 | marginBottom: 2, 110 | }, 111 | storyTime: { 112 | color: '#999999', 113 | fontSize: 12, 114 | }, 115 | row: { 116 | alignItems: 'center', 117 | backgroundColor: 'white', 118 | flexDirection: 'row', 119 | }, 120 | itemRow: { 121 | height: 80, 122 | alignItems: 'stretch', 123 | backgroundColor: 'white', 124 | }, 125 | byline: { 126 | padding: 0, 127 | }, 128 | commentsCell: { 129 | marginLeft: 10, 130 | padding: cellPadding, 131 | width: 80, 132 | alignItems: 'center', 133 | backgroundColor: 'white', 134 | }, 135 | commentsText: { 136 | fontSize: 10, 137 | textAlign: 'center', 138 | }, 139 | cellBorder: { 140 | backgroundColor: 'rgba(0, 0, 0, 0.1)', 141 | // Trick to get the thinest line the device can display 142 | height: 1 / PixelRatio.get(), 143 | marginLeft: 4, 144 | }, 145 | }) 146 | 147 | module.exports = StoryListItem 148 | -------------------------------------------------------------------------------- /components/Text.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | 3 | var Text = React.createClass({ 4 | setNativeProps() { 5 | var {text} = this.refs 6 | text.setNativeProps.apply(text, arguments) 7 | }, 8 | render() { 9 | return ( 10 | 15 | ) 16 | } 17 | }) 18 | 19 | var styles = React.StyleSheet.create({ 20 | text: { 21 | }, 22 | }) 23 | 24 | module.exports = Text 25 | -------------------------------------------------------------------------------- /components/TopStoriesScreen.js: -------------------------------------------------------------------------------- 1 | var _ = require('underscore') 2 | var React = require('react-native') 3 | var { 4 | ListView, 5 | StyleSheet, 6 | } = React 7 | var RefreshableListView = require('react-native-refreshable-listview') 8 | 9 | var Routes = require('../Routes') 10 | var TopStory = require('../stores/TopStory') 11 | var View = require('./View') 12 | var Text = require('./Text') 13 | var StoreWatchMixin = require('./StoreWatchMixin') 14 | var StoryListItem = require('./StoryListItem') 15 | var Loading = require('./Loading') 16 | 17 | var baseDataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.id !== r2.id}) 18 | 19 | var TopStoriesScreen = React.createClass({ 20 | mixins: [ 21 | StoreWatchMixin, 22 | ], 23 | getInitialState() { 24 | return { 25 | dataSource: baseDataSource.cloneWithRows(this.getTopStories()), 26 | } 27 | }, 28 | componentDidMount() { 29 | var topStories = this.getTopStories() 30 | if (!(topStories && topStories.length)) this.loadTopStories() 31 | }, 32 | getStoreWatches() { 33 | this.watchStore(TopStory, _.debounce(() => { 34 | if (this.isMounted()) { 35 | this.setState({dataSource: baseDataSource.cloneWithRows(this.getTopStories())}) 36 | } 37 | }, 100)) 38 | }, 39 | loadTopStories() { 40 | return TopStory.fetch() 41 | }, 42 | getTopStories() { 43 | return TopStory.ordered() 44 | }, 45 | gotoComments(story) { 46 | this.props.navigator.push(Routes.Comments(story)) 47 | }, 48 | gotoArticle(story) { 49 | this.props.navigator.push(Routes.Article(story)) 50 | }, 51 | renderStory(story) { 52 | return ( 53 | 58 | ) 59 | }, 60 | renderStoriesListView() { 61 | if (this.state.dataSource.getRowCount() === 0) { 62 | return ( 63 | top stories 64 | ) 65 | } else { 66 | return ( 67 | 74 | } 75 | /> 76 | ) 77 | } 78 | }, 79 | render() { 80 | return this.renderStoriesListView() 81 | } 82 | }) 83 | 84 | var indicatorStylesheet = StyleSheet.create({ 85 | wrapper: { 86 | backgroundColor: '#ffffff', 87 | height: 60, 88 | marginTop: 10, 89 | }, 90 | }) 91 | 92 | module.exports = TopStoriesScreen 93 | -------------------------------------------------------------------------------- /components/View.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | 3 | var View = React.createClass({ 4 | setNativeProps() { 5 | var {view} = this.refs 6 | view.setNativeProps.apply(view, arguments) 7 | }, 8 | render() { 9 | return ( 10 | 15 | ) 16 | } 17 | }) 18 | 19 | var styles = React.StyleSheet.create({ 20 | view: { 21 | backgroundColor: 'white', 22 | }, 23 | }) 24 | 25 | module.exports = View 26 | -------------------------------------------------------------------------------- /components/baseStyles.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | var {StyleSheet} = React 3 | 4 | var colors = require('./colors') 5 | 6 | var baseStyles = StyleSheet.create({ 7 | white: { 8 | backgroundColor: 'white', 9 | }, 10 | blueText: { 11 | color: colors.blue, 12 | }, 13 | }) 14 | 15 | module.exports = baseStyles 16 | 17 | -------------------------------------------------------------------------------- /components/colors.js: -------------------------------------------------------------------------------- 1 | var colors = { 2 | blue: '#007AFF', 3 | grey: '#BBBBBB', 4 | } 5 | 6 | module.exports = colors 7 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | "apiHost": "http://api.hackernewsmobile.com/" 3 | } 4 | 5 | module.exports = config 6 | -------------------------------------------------------------------------------- /iOS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /iOS/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTRootView.h" 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | NSURL *jsCodeLocation; 19 | 20 | // Loading JavaScript code - uncomment the one you want. 21 | 22 | // OPTION 1 23 | // Load from development server. Start the server from the repository root: 24 | // 25 | // $ npm start 26 | // 27 | // To run on device, change `localhost` to the IP address of your computer, and make sure your computer and 28 | // iOS device are on the same Wi-Fi network. 29 | jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; 30 | 31 | // OPTION 2 32 | // Load from pre-bundled file on disk. To re-generate the static bundle, run 33 | // 34 | // $ curl http://localhost:8081/index.ios.bundle -o main.jsbundle 35 | // 36 | // and uncomment the next following line 37 | // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 38 | 39 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 40 | moduleName:@"ReactNativeHackerNews" 41 | launchOptions:launchOptions]; 42 | 43 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 44 | UIViewController *rootViewController = [[UIViewController alloc] init]; 45 | rootViewController.view = rootView; 46 | self.window.rootViewController = rootViewController; 47 | [self.window makeKeyAndVisible]; 48 | return YES; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /iOS/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /iOS/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "iPhoneSettings-29x29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "idiom" : "iphone", 11 | "size" : "29x29", 12 | "scale" : "3x" 13 | }, 14 | { 15 | "size" : "40x40", 16 | "idiom" : "iphone", 17 | "filename" : "iPhoneSpotlight-40x40@2x-1.png", 18 | "scale" : "2x" 19 | }, 20 | { 21 | "idiom" : "iphone", 22 | "size" : "40x40", 23 | "scale" : "3x" 24 | }, 25 | { 26 | "size" : "60x60", 27 | "idiom" : "iphone", 28 | "filename" : "iPhoneApp-60x60@2x.png", 29 | "scale" : "2x" 30 | }, 31 | { 32 | "idiom" : "iphone", 33 | "size" : "60x60", 34 | "scale" : "3x" 35 | } 36 | ], 37 | "info" : { 38 | "version" : 1, 39 | "author" : "xcode" 40 | } 41 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/AppIcon.appiconset/iPhoneApp-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/AppIcon.appiconset/iPhoneApp-60x60@2x.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/AppIcon.appiconset/iPhoneSettings-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/AppIcon.appiconset/iPhoneSettings-29x29@2x.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/AppIcon.appiconset/iPhoneSpotlight-40x40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/AppIcon.appiconset/iPhoneSpotlight-40x40@2x-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/comment.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "comment.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/comment.imageset/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/comment.imageset/comment.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/disclosure.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "disclosure.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/disclosure.imageset/disclosure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/disclosure.imageset/disclosure.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/disclosure90.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "disclosure90.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/disclosure90.imageset/disclosure90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/iOS/Images.xcassets/disclosure90.imageset/disclosure90.png -------------------------------------------------------------------------------- /iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | HackerNews 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | co.jsdf.$(PRODUCT_NAME:rfc1034identifier) 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 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /iOS/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /images/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/images/comment.png -------------------------------------------------------------------------------- /images/disclosure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/images/disclosure.png -------------------------------------------------------------------------------- /images/disclosure90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/images/disclosure90.png -------------------------------------------------------------------------------- /images/hackernews-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsdf/ReactNativeHackerNews/8a28faea87f4674c490308cb8a98be057d72b4c2/images/hackernews-icon.png -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var React = require('react-native') 4 | var { 5 | AppRegistry, 6 | StyleSheet, 7 | NavigatorIOS, 8 | Text, 9 | View, 10 | } = React 11 | 12 | var Routes = require('./Routes') 13 | 14 | var ReactNativeHackerNews = React.createClass({ 15 | render: function() { 16 | return ( 17 | 21 | ) 22 | } 23 | }) 24 | 25 | var styles = StyleSheet.create({ 26 | container: { 27 | flex: 1, 28 | backgroundColor: 'white', 29 | }, 30 | }) 31 | 32 | AppRegistry.registerComponent('ReactNativeHackerNews', () => ReactNativeHackerNews) 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ReactNativeHackerNews", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node_modules/react-native/packager/packager.sh" 7 | }, 8 | "dependencies": { 9 | "entities": "^1.1.1", 10 | "events": "^1.0.2", 11 | "htmlparser2": "^3.8.2", 12 | "moment": "^2.9.0", 13 | "react-native": "^0.4.1", 14 | "react-native-htmlview": "^0.1.2", 15 | "react-native-refreshable-listview": "^1.0.0", 16 | "underscore": "^1.7.0", 17 | "url": "^0.10.3", 18 | "url-join": "0.0.1", 19 | "util": "^0.10.3", 20 | "xtend": "^4.0.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /stores/Collection.js: -------------------------------------------------------------------------------- 1 | var _ = require('underscore') 2 | var {EventEmitter} = require('events') 3 | var urlJoin = require('url-join') 4 | 5 | class CollectionStore extends EventEmitter { 6 | static url() { throw new Error('unimplemented method') } 7 | static fetch(id) { 8 | return fetch(urlJoin(this.url(), id)) 9 | .then(response => response.json()) 10 | } 11 | constructor() { 12 | this.items = {} 13 | } 14 | emitChange() { 15 | this.emit('change') 16 | } 17 | fetch(id) { 18 | return this.constructor.fetch(id) 19 | .then((item) => this.set(item)) 20 | } 21 | set(item) { 22 | this.items[item.id] = item 23 | this.emitChange() 24 | return item 25 | } 26 | get(id) { 27 | return this.items[id] 28 | } 29 | all() { 30 | return _.values(this.items) 31 | } 32 | reset(items) { 33 | this.items = {} 34 | // items could be an array or object 35 | _.each(items, (item) => { 36 | this.set(item) 37 | }) 38 | } 39 | toJSON() { 40 | return this.items 41 | } 42 | } 43 | 44 | module.exports = CollectionStore 45 | -------------------------------------------------------------------------------- /stores/Story.js: -------------------------------------------------------------------------------- 1 | var urlJoin = require('url-join') 2 | var CollectionStore = require('./Collection') 3 | var config = require('../config') 4 | 5 | const API_PATH = urlJoin(config.apiHost, '/item') 6 | 7 | class StoryStore extends CollectionStore { 8 | static url() { return API_PATH } 9 | } 10 | 11 | module.exports = new StoryStore -------------------------------------------------------------------------------- /stores/TopStory.js: -------------------------------------------------------------------------------- 1 | var _ = require('underscore') 2 | var urlJoin = require('url-join') 3 | var CollectionStore = require('./Collection') 4 | var config = require('../config') 5 | 6 | const API_PATH = urlJoin(config.apiHost, '/') 7 | 8 | class TopStoryStore extends CollectionStore { 9 | static url() { return API_PATH } 10 | static fetch() { 11 | return fetch(this.url()) 12 | .then(response => response.json()) 13 | } 14 | fetch() { 15 | return this.constructor.fetch() 16 | .then((items) => { 17 | this.reset(items) 18 | this.emitChange() 19 | return items 20 | }) 21 | } 22 | ordered() { 23 | return _.sortBy(this.all(), 'position') 24 | } 25 | } 26 | 27 | module.exports = new TopStoryStore 28 | -------------------------------------------------------------------------------- /util/merge.js: -------------------------------------------------------------------------------- 1 | module.exports = require('xtend/mutable') 2 | --------------------------------------------------------------------------------