├── .buckconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── App.js ├── DatContentLoader.js ├── DatURL.js ├── LICENSE ├── Pages ├── Browser.js ├── Directory.js ├── File.js ├── HTML.js ├── Image.js ├── Loading.js ├── Markdown.js └── Welcome.js ├── README.md ├── __tests__ └── App.js ├── android ├── app │ ├── BUCK │ ├── build.gradle │ ├── build_defs.bzl │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── datmobile │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── 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 │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties └── settings.gradle ├── app.json ├── assets ├── banner.png ├── banner.svg ├── logo.png └── logo.svg ├── babel.config.js ├── empty.js ├── index.js ├── ios ├── Datmobile-tvOS │ └── Info.plist ├── Datmobile-tvOSTests │ └── Info.plist ├── Datmobile.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── Datmobile-tvOS.xcscheme │ │ └── Datmobile.xcscheme ├── Datmobile │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Info.plist │ └── main.m └── DatmobileTests │ ├── DatmobileTests.m │ └── Info.plist ├── package.json ├── react-native-dat-webview └── index.js ├── react-native-dat └── index.js ├── shim.js └── yarn.lock /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.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 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | package-lock.json 59 | 60 | index.android.bundle 61 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { 3 | StyleSheet, 4 | View, 5 | TextInput, 6 | Button, 7 | BackHandler, 8 | Linking 9 | } from 'react-native' 10 | 11 | import Dat from './react-native-dat' 12 | import RARF, { cachePath } from 'random-access-rn-file' 13 | import path from 'path' 14 | 15 | import Welcome from './Pages/Welcome' 16 | import Loading from './Pages/Loading' 17 | import Directory from './Pages/Directory' 18 | import File from './Pages/File' 19 | import Image from './Pages/Image' 20 | import Markdown from './Pages/Markdown' 21 | import HTML from './Pages/HTML' 22 | import Browser from './Pages/Browser' 23 | 24 | const PAGE_MAPPING = { 25 | 'browser': Browser, 26 | 'welcome': Welcome, 27 | 'loading': Loading 28 | } 29 | 30 | export default class App extends Component { 31 | constructor (props) { 32 | super(props) 33 | 34 | this.state = { 35 | page: 'welcome', 36 | url: 'dat://', 37 | data: null 38 | } 39 | 40 | this.history = [] 41 | 42 | this.dat = new Dat({ 43 | db: (file) => { 44 | const finalPath = path.join(cachePath, file) 45 | return RARF(finalPath) 46 | } 47 | }) 48 | 49 | this.input = null 50 | 51 | this.navigateTo = (url) => { 52 | if (this.state.url === url) return 53 | console.log('Navigating to', url) 54 | this.history.push(this.state.url) 55 | // Navigating 56 | if ((url + '') === 'dat://') { 57 | this.setState({ 58 | url, 59 | page: 'welcome' 60 | }) 61 | } else { 62 | this.setState({ 63 | url, 64 | page: 'loading' 65 | }) 66 | 67 | this.dat.get(url).then(() => { 68 | this.setState({ 69 | url, 70 | page: 'browser' 71 | }) 72 | }) 73 | } 74 | } 75 | 76 | this.goBack = () => { 77 | const url = this.history.pop() 78 | this.navigateTo(url) 79 | this.history.pop() 80 | } 81 | 82 | this.navigateToCurrentURL = () => { 83 | this.navigateTo(this.state.url) 84 | } 85 | this.setInputRef = (input) => { 86 | this.input = input 87 | } 88 | } 89 | 90 | componentDidMount () { 91 | BackHandler.addEventListener('hardwareBackPress', () => { 92 | if (!this.history.length) return false 93 | 94 | this.goBack() 95 | 96 | return true 97 | }) 98 | 99 | Linking.getInitialURL().then((url) => { 100 | if (url) { 101 | this.navigateTo(url) 102 | } 103 | }).catch(err => console.error('An error occurred', err)) 104 | } 105 | 106 | render () { 107 | let RenderComponent = Loading 108 | 109 | const page = this.state.page 110 | 111 | const gotComponent = PAGE_MAPPING[page] 112 | if (gotComponent) RenderComponent = gotComponent 113 | 114 | return ( 115 | 116 | 117 |