├── .watchmanconfig ├── src ├── cljsjs │ ├── react.cljs │ └── react │ │ └── dom.cljs ├── om_next_react_native_router_flux │ ├── state.cljs │ ├── components │ │ ├── home.cljs │ │ ├── register.cljs │ │ ├── login.cljs │ │ ├── modalbox.cljs │ │ ├── tab_view.cljs │ │ └── launch.cljs │ ├── ios │ │ └── core.cljs │ ├── react_requires.cljs │ ├── android │ │ └── core.cljs │ ├── react_helpers.cljs │ └── routing.cljs └── re_natal │ └── support.cljs ├── android ├── settings.gradle ├── app │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── omnextreactnativerouterflux │ │ │ └── MainActivity.java │ ├── proguard-rules.pro │ ├── react.gradle │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── images ├── cljs.png ├── cljs@2x.png └── cljs@3x.png ├── env ├── prod │ └── env │ │ ├── ios │ │ └── main.cljs │ │ └── android │ │ └── main.cljs └── dev │ ├── env │ ├── ios │ │ └── main.cljs │ └── android │ │ └── main.cljs │ └── user.clj ├── doc └── intro.md ├── .hgignore ├── test └── om_next_react_native_router_flux │ └── core_test.clj ├── .re-natal ├── package.json ├── ios ├── OmNextReactNativeRouterFlux │ ├── AppDelegate.h │ ├── main.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── AppDelegate.m │ └── Base.lproj │ │ └── LaunchScreen.xib ├── OmNextReactNativeRouterFluxTests │ ├── Info.plist │ └── OmNextReactNativeRouterFluxTests.m └── OmNextReactNativeRouterFlux.xcodeproj │ ├── xcshareddata │ └── xcschemes │ │ └── OmNextReactNativeRouterFlux.xcscheme │ └── project.pbxproj ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── .flowconfig ├── project.clj └── figwheel-bridge.js /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /src/cljsjs/react.cljs: -------------------------------------------------------------------------------- 1 | (ns cljsjs.react) -------------------------------------------------------------------------------- /src/cljsjs/react/dom.cljs: -------------------------------------------------------------------------------- 1 | (ns cljsjs.react.dom) -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'OmNextReactNativeRouterFlux' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /images/cljs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/images/cljs.png -------------------------------------------------------------------------------- /images/cljs@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/images/cljs@2x.png -------------------------------------------------------------------------------- /images/cljs@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/images/cljs@3x.png -------------------------------------------------------------------------------- /env/prod/env/ios/main.cljs: -------------------------------------------------------------------------------- 1 | (ns env.ios.main 2 | (:require [om-next-react-native-router-flux.ios.core :as core])) 3 | 4 | (core/init) -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OmNextReactNativeRouterFlux 3 | 4 | -------------------------------------------------------------------------------- /env/prod/env/android/main.cljs: -------------------------------------------------------------------------------- 1 | (ns env.android.main 2 | (:require [om-next-react-native-router-flux.android.core :as core])) 3 | 4 | (core/init) -------------------------------------------------------------------------------- /doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to om-next-react-native-router-flux 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | target/** 3 | classes/** 4 | checkouts/** 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-port 11 | .gitignore 12 | .git/** 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seantempesta/om-next-react-native-router-flux/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /test/om_next_react_native_router_flux/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.core-test 2 | (:require [clojure.test :refer :all] 3 | [om-next-react-native-router-flux.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /.re-natal: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OmNextReactNativeRouterFlux", 3 | "interface": "om-next", 4 | "androidHost": "localhost", 5 | "modules": [ 6 | "react-native-router-flux", 7 | "react-native-button", 8 | "react-native-modalbox", 9 | "react-native-navbar" 10 | ], 11 | "imageDirs": [ 12 | "images" 13 | ] 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OmNextReactNativeRouterFlux", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node_modules/react-native/packager/packager.sh" 7 | }, 8 | "dependencies": { 9 | "react-native": "0.20.0", 10 | "react-native-button": "^1.4.2", 11 | "react-native-modalbox": "^1.3.1", 12 | "react-native-navbar": "^1.2.1", 13 | "react-native-router-flux": "^2.2.7" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/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 | -------------------------------------------------------------------------------- /env/dev/env/ios/main.cljs: -------------------------------------------------------------------------------- 1 | (ns ^:figwheel-no-load env.ios.main 2 | (:require [om.next :as om] 3 | [om-next-react-native-router-flux.ios.core :as core] 4 | [om-next-react-native-router-flux.state :as state] 5 | [figwheel.client :as figwheel :include-macros true])) 6 | 7 | (enable-console-print!) 8 | 9 | (figwheel/watch-and-reload 10 | :websocket-url "ws://localhost:3449/figwheel-ws" 11 | :heads-up-display true 12 | :jsload-callback #(om/add-root! state/reconciler core/AppRoot 1)) 13 | 14 | (core/init) 15 | 16 | (def root-el (core/app-root)) -------------------------------------------------------------------------------- /env/dev/env/android/main.cljs: -------------------------------------------------------------------------------- 1 | (ns ^:figwheel-no-load env.android.main 2 | (:require [om.next :as om] 3 | [om-next-react-native-router-flux.android.core :as core] 4 | [om-next-react-native-router-flux.state :as state] 5 | [figwheel.client :as figwheel :include-macros true])) 6 | 7 | (enable-console-print!) 8 | 9 | (figwheel/watch-and-reload 10 | :websocket-url "ws://localhost:3449/figwheel-ws" 11 | :heads-up-display true 12 | :jsload-callback #(om/add-root! state/reconciler core/AppRoot 1)) 13 | 14 | (core/init) 15 | 16 | (def root-el (core/app-root)) -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/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 | -------------------------------------------------------------------------------- /.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/IJ 26 | # 27 | .idea 28 | .gradle 29 | local.properties 30 | 31 | # node.js 32 | # 33 | node_modules/ 34 | npm-debug.log 35 | 36 | # Generated by re-natal 37 | # 38 | index.android.js 39 | index.ios.js 40 | target/ 41 | 42 | # Figwheel 43 | # 44 | figwheel_server.log -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/state.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.state 2 | (:require [om.next :as om] 3 | [re-natal.support :as sup])) 4 | 5 | (defonce app-state (atom {:app/msg "Hello Clojure in iOS and Android!"})) 6 | 7 | (defmulti read om/dispatch) 8 | (defmethod read :default 9 | [{:keys [state]} k _] 10 | (let [st @state] 11 | (if-let [[_ v] (find st k)] 12 | {:value v} 13 | {:value :not-found}))) 14 | 15 | (defonce reconciler 16 | (om/reconciler 17 | {:state app-state 18 | :parser (om/parser {:read read}) 19 | :root-render sup/root-render 20 | :root-unmount sup/root-unmount})) -------------------------------------------------------------------------------- /env/dev/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:use [figwheel-sidecar.repl-api :as ra])) 3 | ;; This namespace is loaded automatically by nREPL 4 | 5 | ;; read project.clj to get build configs 6 | (def profiles (->> "project.clj" 7 | slurp 8 | read-string 9 | (drop-while #(not= % :profiles)) 10 | (apply hash-map) 11 | :profiles)) 12 | 13 | (def cljs-builds (get-in profiles [:dev :cljsbuild :builds])) 14 | 15 | (defn start-figwheel 16 | "Start figwheel for one or more builds" 17 | [& build-ids] 18 | (ra/start-figwheel! 19 | {:build-ids build-ids 20 | :all-builds cljs-builds}) 21 | (ra/cljs-repl)) 22 | 23 | (defn stop-figwheel 24 | "Stops figwheel" 25 | [] 26 | (ra/stop-figwheel!)) -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFluxTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased][unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-02-22 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-02-22 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [unreleased]: https://github.com/your-name/om-next-react-native-router-flux/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/om-next-react-native-router-flux/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /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 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/home.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.home 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] ;; IMPORTANT! Must be required first 6 | [om-next-react-native-router-flux.react-helpers :refer [button]] ;; IMPORTANT! Must be required second 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | (def styles {:container {:flex 1 10 | :justifyContent "center" 11 | :alignItems "center" 12 | :backgroundColor "#F5FCFF"}}) 13 | (defui Home 14 | Object 15 | (render [this] 16 | (view {:style (:container styles)} 17 | (text {} "Replace Screen") 18 | (button {:onPress #(.pop Actions)} "Back")))) 19 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/register.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.register 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] 6 | [om-next-react-native-router-flux.react-helpers :refer [button]] 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | (def styles {:container {:flex 1 10 | :justifyContent "center" 11 | :alignItems "center" 12 | :backgroundColor "#F5FCFF"}}) 13 | 14 | (defui Register 15 | Object 16 | (render [this] 17 | (view {:style (:container styles)} 18 | (text {} "Register page") 19 | (button {:onPress #(.home Actions)} "Replace screen") 20 | (button {:onPress #(.pop Actions)} "Back")))) 21 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/ios/core.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.ios.core 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require [om-next-react-native-router-flux.react-requires] ;; IMPORTANT! Must be required first 5 | [om-next-react-native-router-flux.react-helpers] ;; IMPORTANT! Must be required second 6 | [om.next :as om :refer-macros [defui]] 7 | [re-natal.support :as sup] 8 | [om-next-react-native-router-flux.state :as state] 9 | [om-next-react-native-router-flux.routing :refer [Routing]])) 10 | 11 | (def app-registry (.-AppRegistry js/React)) 12 | (def logo-img (js/require "./images/cljs.png")) 13 | 14 | (def AppRoot Routing) 15 | 16 | (defonce RootNode (sup/root-node! 1)) 17 | (defonce app-root (om/factory Routing)) 18 | 19 | (defn init [] 20 | (om/add-root! state/reconciler Routing 1) 21 | (.registerComponent app-registry "OmNextReactNativeRouterFlux" (fn [] app-root))) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/react_requires.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.react-requires) 2 | 3 | ; react-native 4 | (set! js/React (js/require "react-native")) 5 | (defonce Navigator (.-Navigator js/React)) 6 | 7 | ; react-native-navbar 8 | (defonce NavigationBar (js/require "react-native-navbar/index.js")) 9 | 10 | ; react-native-button 11 | (defonce Button (js/require "react-native-button/Button.js")) 12 | 13 | ; react-native-tabs 14 | (defonce Tabs (js/require "react-native-tabs/index.js")) 15 | 16 | ; react-native-router-flux 17 | (defonce ReactNativeRouterFlux (js/require "react-native-router-flux/index.js")) 18 | (defonce Schema (aget ReactNativeRouterFlux "Schema")) 19 | (defonce Router (aget ReactNativeRouterFlux "Router")) 20 | (defonce Route (aget ReactNativeRouterFlux "Route")) 21 | (defonce TabBar (aget ReactNativeRouterFlux "TabBar")) 22 | (defonce Actions (aget ReactNativeRouterFlux "Actions")) 23 | (defonce Animations (aget ReactNativeRouterFlux "Animations")) 24 | 25 | ; react-native-modalbox 26 | (defonce ReactNativeModalbox (js/require "react-native-modalbox/index.js")) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # om-next-react-native-router-flux 2 | 3 | Looking for a React Native routing solution that doesn't suck? This solution uses [om.next](https://github.com/omcljs/om/) and [react-native-router-flux](https://github.com/aksonov/react-native-router-flux). 4 | 5 | ## Features 6 | * Tabs 7 | * Modals 8 | * Action Sheets 9 | * Screen transition animations (or lack thereof) 10 | 11 | ## Test it out 12 | 1. Install [re-natal](https://github.com/drapanjanas/re-natal) 13 | 1. Clone this repo 14 | 15 | ```sh 16 | git clone https://github.com/seantempesta/om-next-react-native-router-flux.git 17 | ``` 18 | 1. cd into the directory 19 | 20 | ```sh 21 | cd om-next-react-native-router-flux 22 | ``` 23 | 1. Install npm packages 24 | 25 | ```sh 26 | $ npm install 27 | ``` 28 | 1. Set up figwheel for development 29 | 30 | ```sh 31 | re-natal use-figwheel 32 | ``` 33 | 1. Run react's package manager and start up figwheel in two separate terminals 34 | 35 | ```sh 36 | $ react-native run-ios 37 | $ lein figwheel ios 38 | ``` 39 | 40 | 41 | License 42 | ---- 43 | 44 | MIT 45 | 46 | 47 | **Free Software, Hell Yeah!** 48 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/omnextreactnativerouterflux/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.omnextreactnativerouterflux; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactPackage; 5 | import com.facebook.react.shell.MainReactPackage; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public class MainActivity extends ReactActivity { 11 | 12 | /** 13 | * Returns the name of the main component registered from JavaScript. 14 | * This is used to schedule rendering of the component. 15 | */ 16 | @Override 17 | protected String getMainComponentName() { 18 | return "OmNextReactNativeRouterFlux"; 19 | } 20 | 21 | /** 22 | * Returns whether dev mode should be enabled. 23 | * This enables e.g. the dev menu. 24 | */ 25 | @Override 26 | protected boolean getUseDeveloperSupport() { 27 | return BuildConfig.DEBUG; 28 | } 29 | 30 | /** 31 | * A list of packages used by the app. If the app uses additional views 32 | * or modules besides the default ones, add more packages here. 33 | */ 34 | @Override 35 | protected List getPackages() { 36 | return Arrays.asList( 37 | new MainReactPackage() 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/login.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.login 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] 6 | [om-next-react-native-router-flux.react-helpers :refer [button]] 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | 10 | (def styles {:container {:flex 1 11 | :justifyContent "center" 12 | :alignItems "center" 13 | :backgroundColor "#F5FCFF"}}) 14 | (defui Login 15 | Object 16 | (render [this] 17 | (let [all-props (om/props this) 18 | data "FIXME"] 19 | (view {:style (:container styles)} 20 | (text {} (str "Login page " data)) 21 | (button {:onPress #(.loginModal2 Actions)} "Login 2") 22 | (button {:onPress #(.pop Actions)} "Back"))))) 23 | 24 | (defui Login2 25 | Object 26 | (render [this] 27 | (let [data "FIXME"] 28 | (view {:style (:container styles)} 29 | (text {} (str "Login2 page: " data)) 30 | (button {:onPress #(.pop Actions)} "Back"))))) -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/modalbox.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.modalbox 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions]] ;; IMPORTANT! Must be required first 6 | [om-next-react-native-router-flux.react-helpers :refer [modal]] ;; IMPORTANT! Must be required second 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | (def styles {:modal {:justifyContent "center" 10 | :alignItems "center" 11 | :height 300 12 | :width 300} 13 | :text {:color "black" 14 | :fontSize 22}}) 15 | 16 | (defui Modalbox 17 | Object 18 | (componentWillMount [this] 19 | (om/set-state! this {:isOpen true})) 20 | (render [this] 21 | (let [local-state (om.next/get-state this) 22 | isOpen (:isOpen local-state)] 23 | (modal {:style (:modal styles) 24 | :animationDuration 200 25 | :swipeThreshold 100 26 | :position "center" 27 | :isOpen isOpen 28 | :onClosed #(.dismiss Actions)} 29 | (text {:key "text-1" 30 | :style (:text styles)} "ReactNativeModalBox") 31 | (text {:key "text-2"} "(swipe down to close"))))) -------------------------------------------------------------------------------- /src/re_natal/support.cljs: -------------------------------------------------------------------------------- 1 | (ns re-natal.support 2 | (:require [om.next :refer-macros [ui]])) 3 | 4 | (defonce root-nodes (atom {})) 5 | 6 | (defn root-node! 7 | "A substitute for a real root node (1) for mounting om-next component. 8 | You have to call function :on-render and :on-unmount in reconciler :root-render :root-unmount function." 9 | [id] 10 | (let [content (atom nil) 11 | instance (atom nil) 12 | class (ui Object 13 | (componentWillMount [this] (reset! instance this)) 14 | (render [_] @content))] 15 | (swap! root-nodes assoc id {:on-render (fn [el] 16 | (reset! content el) 17 | (when @instance 18 | (.forceUpdate @instance))) 19 | :on-unmount (fn []) 20 | :class class}) 21 | class)) 22 | (defn root-render 23 | "Use this as reconciler :root-render function." 24 | [el id] 25 | (let [node (get @root-nodes id) 26 | on-render (:on-render node)] 27 | (when on-render (on-render el)))) 28 | 29 | (defn root-unmount 30 | "Use this as reconciler :root-unmount function." 31 | [id] 32 | (let [node (get @root-nodes id) 33 | unmount-fn (:on-unmount node)] 34 | (when unmount-fn (unmount-fn)))) 35 | 36 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/tab_view.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.tab-view 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] 6 | [om-next-react-native-router-flux.react-helpers :refer [button]] 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | (def styles {:container {:flex 1 10 | :justifyContent "center" 11 | :alignItems "center" 12 | :backgroundColor "#F5FCFF"}}) 13 | 14 | (defui TabIcon 15 | Object 16 | (render [this] 17 | (let [all-props (om/props this) 18 | title "TITLE!" 19 | selected true] 20 | (text {:style {:color (if selected "red" "black")}} title)))) 21 | 22 | (defui TabView 23 | Object 24 | (render [this] 25 | (let [title "TITLE!"] 26 | (view {:style (:container styles)} 27 | (text {} (str "Tab " title)) 28 | (button {:onPress #(.pop Actions)} "Back") 29 | (button {:onPress #(.tab1 Actions)} "Switch to tab1"))))) 30 | 31 | (defui TabView2 32 | Object 33 | (render [this] 34 | (let [name "1"] 35 | (view {:style (:container styles)} 36 | (text {} (str "Tab " name)))))) 37 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/android/core.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.android.core 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require [om.next :as om :refer-macros [defui]] 5 | [re-natal.support :as sup] 6 | [om-next-react-native-router-flux.state :as state])) 7 | 8 | (set! js/React (js/require "react-native")) 9 | 10 | (def app-registry (.-AppRegistry js/React)) 11 | (def logo-img (js/require "./images/cljs.png")) 12 | 13 | (defui AppRoot 14 | static om/IQuery 15 | (query [this] 16 | '[:app/msg]) 17 | Object 18 | (render [this] 19 | (let [{:keys [app/msg]} (om/props this)] 20 | (view {:style {:flexDirection "column" :margin 40 :alignItems "center"}} 21 | (text {:style {:fontSize 30 :fontWeight "100" :marginBottom 20 :textAlign "center"}} msg) 22 | (image {:source logo-img 23 | :style {:width 80 :height 80 :marginBottom 30}}) 24 | (touchable-highlight {:style {:backgroundColor "#999" :padding 10 :borderRadius 5} 25 | :onPress #(alert "HELLO!")} 26 | (text {:style {:color "white" :textAlign "center" :fontWeight "bold"}} "press me")))))) 27 | 28 | (defonce RootNode (sup/root-node! 1)) 29 | (defonce app-root (om/factory RootNode)) 30 | 31 | (defn init [] 32 | (om/add-root! state/reconciler AppRoot 1) 33 | (.registerComponent app-registry "OmNextReactNativeRouterFlux" (fn [] app-root))) -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 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 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSAllowsArbitraryLoads 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/components/launch.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.components.launch 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] 6 | [om-next-react-native-router-flux.react-helpers :refer [button]] 7 | [om.next :as om :refer-macros [defui]])) 8 | 9 | (def styles {:container {:flex 1 10 | :justifyContent "center" 11 | :alignItems "center" 12 | :backgroundColor "#F5FCFF"}}) 13 | 14 | (defui Launch 15 | Object 16 | (render [this] 17 | (view {:style (:container styles)} 18 | (text {} "Launch page") 19 | (button {:onPress #(.login Actions (clj->js {:data "Custom data" 20 | :title "Custom title"}))} "Go to Login page") 21 | (button {:onPress #(.register Actions)} "Go to Register page") 22 | (button {:onPress #(.register2 Actions)} "Go to Register page without animation") 23 | (button {:onPress #(.modalBox Actions)} "PopUp with ReactNativeModalBox") 24 | (button {:onPress #(.tabbar Actions)} "Go to TabBar") 25 | (button {:onPress #(.showActionSheet Actions (clj->js {:callback (fn [index] 26 | (js/alert (str "Selected:" index)) 27 | true)}))} "Show ActionSheet") 28 | ))) 29 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | # We fork some components by platform. 4 | .*/*.web.js 5 | .*/*.android.js 6 | 7 | # Some modules have their own node_modules with overlap 8 | .*/node_modules/node-haste/.* 9 | 10 | # Ugh 11 | .*/node_modules/babel.* 12 | .*/node_modules/babylon.* 13 | .*/node_modules/invariant.* 14 | 15 | # Ignore react and fbjs where there are overlaps, but don't ignore 16 | # anything that react-native relies on 17 | .*/node_modules/fbjs/lib/Map.js 18 | .*/node_modules/fbjs/lib/Promise.js 19 | .*/node_modules/fbjs/lib/fetch.js 20 | .*/node_modules/fbjs/lib/ExecutionEnvironment.js 21 | .*/node_modules/fbjs/lib/isEmpty.js 22 | .*/node_modules/fbjs/lib/crc32.js 23 | .*/node_modules/fbjs/lib/ErrorUtils.js 24 | 25 | # Flow has a built-in definition for the 'react' module which we prefer to use 26 | # over the currently-untyped source 27 | .*/node_modules/react/react.js 28 | .*/node_modules/react/lib/React.js 29 | .*/node_modules/react/lib/ReactDOM.js 30 | 31 | # Ignore commoner tests 32 | .*/node_modules/commoner/test/.* 33 | 34 | # See https://github.com/facebook/flow/issues/442 35 | .*/react-tools/node_modules/commoner/lib/reader.js 36 | 37 | # Ignore jest 38 | .*/node_modules/jest-cli/.* 39 | 40 | # Ignore Website 41 | .*/website/.* 42 | 43 | [include] 44 | 45 | [libs] 46 | node_modules/react-native/Libraries/react-native/react-native-interface.js 47 | 48 | [options] 49 | module.system=haste 50 | 51 | munge_underscores=true 52 | 53 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 54 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub' 55 | 56 | suppress_type=$FlowIssue 57 | suppress_type=$FlowFixMe 58 | suppress_type=$FixMe 59 | 60 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 61 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 62 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 63 | 64 | [version] 65 | 0.21.0 66 | -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/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 | /** 21 | * Loading JavaScript code - uncomment the one you want. 22 | * 23 | * OPTION 1 24 | * Load from development server. Start the server from the repository root: 25 | * 26 | * $ npm start 27 | * 28 | * To run on device, change `localhost` to the IP address of your computer 29 | * (you can get this by typing `ifconfig` into the terminal and selecting the 30 | * `inet` value under `en0:`) and make sure your computer and iOS device are 31 | * on the same Wi-Fi network. 32 | */ 33 | 34 | jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; 35 | 36 | /** 37 | * OPTION 2 38 | * Load from pre-bundled file on disk. The static bundle is automatically 39 | * generated by "Bundle React Native code and images" build step. 40 | */ 41 | 42 | // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 43 | 44 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 45 | moduleName:@"OmNextReactNativeRouterFlux" 46 | initialProperties:nil 47 | launchOptions:launchOptions]; 48 | 49 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 50 | UIViewController *rootViewController = [UIViewController new]; 51 | rootViewController.view = rootView; 52 | self.window.rootViewController = rootViewController; 53 | [self.window makeKeyAndVisible]; 54 | return YES; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFluxTests/OmNextReactNativeRouterFluxTests.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 | #import 12 | 13 | #import "RCTLog.h" 14 | #import "RCTRootView.h" 15 | 16 | #define TIMEOUT_SECONDS 240 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface OmNextReactNativeRouterFluxTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation OmNextReactNativeRouterFluxTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /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 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | 30 | # Do not strip any method/class that is annotated with @DoNotStrip 31 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 32 | -keepclassmembers class * { 33 | @com.facebook.proguard.annotations.DoNotStrip *; 34 | } 35 | 36 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 37 | void set*(***); 38 | *** get*(); 39 | } 40 | 41 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 42 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 43 | -keepclassmembers,includedescriptorclasses class * { native ; } 44 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 45 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 46 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 47 | 48 | -dontwarn com.facebook.react.** 49 | 50 | # okhttp 51 | 52 | -keepattributes Signature 53 | -keepattributes *Annotation* 54 | -keep class com.squareup.okhttp.** { *; } 55 | -keep interface com.squareup.okhttp.** { *; } 56 | -dontwarn com.squareup.okhttp.** 57 | 58 | # okio 59 | 60 | -keep class sun.misc.Unsafe { *; } 61 | -dontwarn java.nio.file.* 62 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 63 | -dontwarn okio.** 64 | 65 | # stetho 66 | 67 | -dontwarn com.facebook.stetho.** 68 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/react_helpers.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.react-helpers 2 | (:require [om-next-react-native-router-flux.react-requires :as rr])) ;; IMPORTANT! Must be required first) 3 | 4 | ; react-native-navbar 5 | ; 6 | (defn navigation-bar 7 | "Simple interop for third party js react-native-navbar/NavigationBar component" 8 | [opts & children] 9 | (apply js/React.createElement rr/NavigationBar (clj->js opts) (clj->js children))) 10 | 11 | ; react-native-router-flux 12 | ; 13 | (defn schema 14 | "Simple interop for third party js react-native-router-flux/Schema component" 15 | [opts & children] 16 | (.createElement js/React rr/Schema (clj->js opts) (clj->js children))) 17 | 18 | (defn router 19 | "Interop to react-native-router-flux/Router component 20 | 21 | HACK: Instead of taking props as a map and converting it to javascript (thus killing om's immutable props), 22 | this fn destructures a vector into router-props and om-props, converts the router-props to javascript 23 | and appends om-props under the key :om-props." 24 | [[router-props om-props] & children] 25 | (let [js-props (clj->js router-props)] 26 | (aset js-props "om-props" om-props) 27 | (.createElement js/React rr/Router js-props (clj->js children)))) 28 | 29 | (defn route 30 | "Simple interop for third party js react-native-router-flux/Route component 31 | NOTE: Only one child is allowed." 32 | [opts & children] 33 | (.createElement js/React rr/Route (clj->js opts) (clj->js (first children)))) 34 | 35 | (defn tab-bar 36 | "Simple interop for third party js react-native-router-flux/TabBar component" 37 | [opts & children] 38 | (.createElement js/React rr/TabBar (clj->js opts) (clj->js children))) 39 | 40 | (defn actions 41 | "Simple interop for third party js react-native-router-flux/Actions component" 42 | [opts & children] 43 | (.createElement js/React rr/Actions (clj->js opts) (clj->js children))) 44 | 45 | (defn animations 46 | "Simple interop for third party js react-native-router-flux/Animations component" 47 | [opts & children] 48 | (.createElement js/React rr/Animations (clj->js opts) (clj->js children))) 49 | 50 | ;; react-native-button 51 | ;; 52 | (defn button 53 | "Simple interop for third party js react-native-button/Button component" 54 | [opts & children] 55 | (.createElement js/React rr/Button (clj->js opts) (clj->js children))) 56 | 57 | ;; react-native-tabs 58 | ;; 59 | (defn tabs 60 | "Simple interop for third party js react-native-tabs/Tabs component" 61 | [opts & children] 62 | (.createElement js/React rr/Tabs (clj->js opts) (clj->js children))) 63 | 64 | 65 | ;; react-native-modalbox 66 | (defn modal 67 | "Simple interop for third party js react-native-tabs/Tabs component" 68 | [opts & children] 69 | (.createElement js/React rr/ReactNativeModalbox (clj->js opts) (clj->js children))) 70 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject om-next-react-native-router-flux "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.7.0"] 7 | [org.clojure/clojurescript "1.7.170"] 8 | [org.omcljs/om "1.0.0-alpha28" :exclusions [cljsjs/react cljsjs/react-dom]] 9 | [natal-shell "0.1.6"]] 10 | :plugins [[lein-cljsbuild "1.1.1"] 11 | [lein-figwheel "0.5.0-2"]] 12 | :clean-targets ["target/" "index.ios.js" "index.android.js"] 13 | :aliases {"prod-build" ^{:doc "Recompile code with prod profile."} 14 | ["do" "clean" 15 | ["with-profile" "prod" "cljsbuild" "once" "ios"] 16 | ["with-profile" "prod" "cljsbuild" "once" "android"]]} 17 | :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2"] 18 | [com.cemerick/piggieback "0.2.1"]] 19 | :source-paths ["src" "env/dev"] 20 | :cljsbuild {:builds {:ios {:source-paths ["src" "env/dev"] 21 | :figwheel true 22 | :compiler {:output-to "target/ios/not-used.js" 23 | :main "env.ios.main" 24 | :output-dir "target/ios" 25 | :optimizations :none}} 26 | :android {:source-paths ["src" "env/dev"] 27 | :figwheel true 28 | :compiler {:output-to "target/android/not-used.js" 29 | :main "env.android.main" 30 | :output-dir "target/android" 31 | :optimizations :none}}}} 32 | :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}} 33 | :prod {:cljsbuild {:builds {:ios {:source-paths ["src" "env/prod"] 34 | :compiler {:output-to "index.ios.js" 35 | :main "env.ios.main" 36 | :output-dir "target/ios" 37 | :optimizations :simple}} 38 | :android {:source-paths ["src" "env/prod"] 39 | :compiler {:output-to "index.android.js" 40 | :main "env.android.main" 41 | :output-dir "target/android" 42 | :optimizations :simple}}}} 43 | }}) -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux/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 | -------------------------------------------------------------------------------- /android/app/react.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.tools.ant.taskdefs.condition.Os 2 | 3 | def config = project.hasProperty("react") ? project.react : []; 4 | 5 | def bundleAssetName = config.bundleAssetName ?: "index.android.bundle" 6 | def entryFile = config.entryFile ?: "index.android.js" 7 | 8 | // because elvis operator 9 | def elvisFile(thing) { 10 | return thing ? file(thing) : null; 11 | } 12 | 13 | def reactRoot = elvisFile(config.root) ?: file("../../") 14 | def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"] 15 | 16 | void runBefore(String dependentTaskName, Task task) { 17 | Task dependentTask = tasks.findByPath(dependentTaskName); 18 | if (dependentTask != null) { 19 | dependentTask.dependsOn task 20 | } 21 | } 22 | 23 | gradle.projectsEvaluated { 24 | // Grab all build types and product flavors 25 | def buildTypes = android.buildTypes.collect { type -> type.name } 26 | def productFlavors = android.productFlavors.collect { flavor -> flavor.name } 27 | 28 | // When no product flavors defined, use empty 29 | if (!productFlavors) productFlavors.add('') 30 | 31 | productFlavors.each { productFlavorName -> 32 | buildTypes.each { buildTypeName -> 33 | // Create variant and source names 34 | def sourceName = "${buildTypeName}" 35 | def targetName = "${sourceName.capitalize()}" 36 | if (productFlavorName) { 37 | sourceName = "${productFlavorName}${targetName}" 38 | } 39 | 40 | // React js bundle directories 41 | def jsBundleDirConfigName = "jsBundleDir${targetName}" 42 | def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?: 43 | file("$buildDir/intermediates/assets/${sourceName}") 44 | 45 | def resourcesDirConfigName = "jsBundleDir${targetName}" 46 | def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?: 47 | file("$buildDir/intermediates/res/merged/${sourceName}") 48 | def jsBundleFile = file("$jsBundleDir/$bundleAssetName") 49 | 50 | // Bundle task name for variant 51 | def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets" 52 | 53 | def currentBundleTask = tasks.create( 54 | name: bundleJsAndAssetsTaskName, 55 | type: Exec) { 56 | group = "react" 57 | description = "bundle JS and assets for ${targetName}." 58 | 59 | // Create dirs if they are not there (e.g. the "clean" task just ran) 60 | doFirst { 61 | jsBundleDir.mkdirs() 62 | resourcesDir.mkdirs() 63 | } 64 | 65 | // Set up inputs and outputs so gradle can cache the result 66 | inputs.files fileTree(dir: reactRoot, excludes: inputExcludes) 67 | outputs.dir jsBundleDir 68 | outputs.dir resourcesDir 69 | 70 | // Set up the call to the react-native cli 71 | workingDir reactRoot 72 | 73 | // Set up dev mode 74 | def devEnabled = !targetName.toLowerCase().contains("release") 75 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 76 | commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}", 77 | "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir 78 | } else { 79 | commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}", 80 | "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir 81 | } 82 | 83 | enabled config."bundleIn${targetName}" ?: targetName.toLowerCase().contains("release") 84 | } 85 | 86 | // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process 87 | currentBundleTask.dependsOn("merge${targetName}Resources") 88 | currentBundleTask.dependsOn("merge${targetName}Assets") 89 | 90 | runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask) 91 | runBefore("processX86${targetName}Resources", currentBundleTask) 92 | runBefore("processUniversal${targetName}Resources", currentBundleTask) 93 | runBefore("process${targetName}Resources", currentBundleTask) 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ios/OmNextReactNativeRouterFlux.xcodeproj/xcshareddata/xcschemes/OmNextReactNativeRouterFlux.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property is in the format 'bundleIn${productFlavor}${buildType}' 30 | * // bundleInFreeDebug: true, 31 | * // bundleInPaidRelease: true, 32 | * // bundleInBeta: true, 33 | * 34 | * // the root of your project, i.e. where "package.json" lives 35 | * root: "../../", 36 | * 37 | * // where to put the JS bundle asset in debug mode 38 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 39 | * 40 | * // where to put the JS bundle asset in release mode 41 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 42 | * 43 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 44 | * // require('./image.png')), in debug mode 45 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 46 | * 47 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 48 | * // require('./image.png')), in release mode 49 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 50 | * 51 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 52 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 53 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 54 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 55 | * // for example, you might want to remove it from here. 56 | * inputExcludes: ["android/**", "ios/**"] 57 | * ] 58 | */ 59 | 60 | apply from: "react.gradle" 61 | 62 | /** 63 | * Set this to true to create three separate APKs instead of one: 64 | * - A universal APK that works on all devices 65 | * - An APK that only works on ARM devices 66 | * - An APK that only works on x86 devices 67 | * The advantage is the size of the APK is reduced by about 4MB. 68 | * Upload all the APKs to the Play Store and people will download 69 | * the correct one based on the CPU architecture of their device. 70 | */ 71 | def enableSeparateBuildPerCPUArchitecture = false 72 | 73 | /** 74 | * Run Proguard to shrink the Java bytecode in release builds. 75 | */ 76 | def enableProguardInReleaseBuilds = false 77 | 78 | android { 79 | compileSdkVersion 23 80 | buildToolsVersion "23.0.1" 81 | 82 | defaultConfig { 83 | applicationId "com.omnextreactnativerouterflux" 84 | minSdkVersion 16 85 | targetSdkVersion 22 86 | versionCode 1 87 | versionName "1.0" 88 | ndk { 89 | abiFilters "armeabi-v7a", "x86" 90 | } 91 | } 92 | splits { 93 | abi { 94 | enable enableSeparateBuildPerCPUArchitecture 95 | universalApk false 96 | reset() 97 | include "armeabi-v7a", "x86" 98 | } 99 | } 100 | buildTypes { 101 | release { 102 | minifyEnabled enableProguardInReleaseBuilds 103 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 104 | } 105 | } 106 | // applicationVariants are e.g. debug, release 107 | applicationVariants.all { variant -> 108 | variant.outputs.each { output -> 109 | // For each separate APK per architecture, set a unique version code as described here: 110 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 111 | def versionCodes = ["armeabi-v7a":1, "x86":2] 112 | def abi = output.getFilter(OutputFile.ABI) 113 | if (abi != null) { // null for the universal-debug, universal-release variants 114 | output.versionCodeOverride = 115 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 116 | } 117 | } 118 | } 119 | } 120 | 121 | dependencies { 122 | compile fileTree(dir: "libs", include: ["*.jar"]) 123 | compile "com.android.support:appcompat-v7:23.0.1" 124 | compile "com.facebook.react:react-native:0.20.+" 125 | } 126 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /src/om_next_react_native_router_flux/routing.cljs: -------------------------------------------------------------------------------- 1 | (ns om-next-react-native-router-flux.routing 2 | (:require-macros [natal-shell.components :refer [view text image touchable-highlight]] 3 | [natal-shell.alert :refer [alert]]) 4 | (:require 5 | [om-next-react-native-router-flux.react-requires :refer [Actions Navigator ReactNativeModalbox TabBar]] 6 | [om-next-react-native-router-flux.react-helpers :refer [router route schema]] 7 | [om-next-react-native-router-flux.components.home :refer [Home]] 8 | [om-next-react-native-router-flux.components.launch :refer [Launch]] 9 | [om-next-react-native-router-flux.components.login :refer [Login Login2]] 10 | [om-next-react-native-router-flux.components.register :refer [Register]] 11 | [om-next-react-native-router-flux.components.tab-view :refer [TabView TabIcon]] 12 | [om-next-react-native-router-flux.components.modalbox :refer [Modalbox]] 13 | [om.next :as om :refer-macros [defui]])) 14 | 15 | (defui Header 16 | Object 17 | (render [this] 18 | (text {} "Header"))) 19 | 20 | (defui Routing 21 | Object 22 | (render [this] 23 | (let [om-props (om/props this)] 24 | (router [{:hideNavBar true 25 | :name "root"} 26 | om-props] 27 | (schema {:key "schema-modal" 28 | :name "modal" 29 | :sceneConfig (aget Navigator "SceneConfigs" "FloatFromBottom")}) 30 | (schema {:key "schema-default" 31 | :name "default" 32 | :sceneConfig (aget Navigator "SceneConfigs" "FloatFromRight")}) 33 | (schema {:key "schema-withoutAnimation" 34 | :name "withoutAnimation"}) 35 | (schema {:key "schema-tab" 36 | :name "tab" 37 | :type "switch" 38 | :icon TabIcon}) 39 | (route {:key "route-register" 40 | :name "register" 41 | :component Register}) 42 | (route {:key "route-showActionSheet" 43 | :name "showActionSheet" 44 | :type "actionSheet" 45 | :title "What do you want to do?" 46 | :options ["Delete" "Save" "Cancel"] 47 | :cancelButtonIndex 2 48 | :destructiveButtonIndex 0}) 49 | (route {:key "route-home" 50 | :name "home" 51 | :component Home 52 | :title "Replace" 53 | :type "replace"}) 54 | (route {:key "route-login" 55 | :name "login" 56 | :schema "modal"} 57 | (router [{:key "router-loginRouter" 58 | :name "loginRouter"} 59 | om-props] 60 | (route {:key "route-loginModal" 61 | :name "loginModal" 62 | :component Login 63 | :schema "modal"}) 64 | (route {:key "route-loginModal2" 65 | :name "loginModal2" 66 | :hideNavBar true 67 | :component Login2 68 | :title "Login2"}))) 69 | (route {:key "route-register2" 70 | :name "register2" 71 | :component Register 72 | :title "Register2" 73 | :schema "withoutAnimation"}) 74 | (route {:key "route-modalBox" 75 | :name "modalBox" 76 | :type "modal" 77 | :component Modalbox}) 78 | (route {:key "route-tabbar" 79 | :name "tabbar"} 80 | (router [{:key "router-tabbar" 81 | :footer TabBar 82 | :showNavigationBar false} 83 | om-props] 84 | (route {:key "route-tab1" 85 | :name "tab1" 86 | :schema "tab" 87 | :title "Tab #1"} 88 | (router [{:key "router-tab1" 89 | :onPop #(do (.log js/console "onPop is called!") 90 | true)} 91 | om-props] 92 | (route {:key "route-tab1_1" 93 | :name "tab1_1" 94 | :component TabView 95 | :title "Tab #1_1"}))) 96 | (route {:key "route-tab2" 97 | :name "tab2" 98 | :schema "tab" 99 | :title "Tab #2" 100 | :hideNavBar true} 101 | (router [{:key "router-tab2" 102 | :onPop #(do (.log js/console "onPop is called!") 103 | true)} 104 | om-props] 105 | (route {:key "route-tab2_1" 106 | :name "tab1_1" 107 | :component TabView 108 | :title "Tab #2_1"}) 109 | (route {:key "route-tab2_2" 110 | :name "tab2_2" 111 | :component TabView 112 | :title "Tab #2_2"}))) 113 | (route {:key "route-tab3" 114 | :name "tab3" 115 | :schema "tab" 116 | :title "Tab #3" 117 | :component TabView 118 | :hideTabBar true}) 119 | (route {:key "route-tab4" 120 | :name "tab4" 121 | :schema "tab" 122 | :title "Tab #4" 123 | :component TabView}) 124 | (route {:key "route-tab5" 125 | :name "tab5" 126 | :schema "tab" 127 | :title "Tab #5" 128 | :component TabView}) 129 | )) 130 | 131 | (route {:key "route-launch" 132 | :name "launch" 133 | :title "Launch" 134 | :component Launch 135 | :header Header 136 | :wrapRouter true 137 | :hideNavBar true 138 | :initial true}) 139 | 140 | )))) -------------------------------------------------------------------------------- /figwheel-bridge.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Originally taken from https://github.com/decker405/figwheel-react-native 3 | * 4 | * @providesModule figwheel-bridge 5 | */ 6 | 7 | var CLOSURE_UNCOMPILED_DEFINES = null; 8 | 9 | var config = { 10 | basePath: "target/", 11 | googBasePath: 'goog/', 12 | serverPort: 8081 13 | }; 14 | 15 | var React = require('react-native'); 16 | var self; 17 | var scriptQueue = []; 18 | var serverHost = null; // will be set dynamically 19 | var fileBasePath = null; // will be set dynamically 20 | var evaluate = eval; // This is needed, direct calls to eval does not work (RN packager???) 21 | var externalModules = {}; 22 | var evalListeners = []; // functions to be called when a script is evaluated 23 | 24 | var figwheelApp = function (platform, devHost) { 25 | return React.createClass({ 26 | getInitialState: function () { 27 | return {loaded: false} 28 | }, 29 | render: function () { 30 | if (!this.state.loaded) { 31 | var plainStyle = {flex: 1, alignItems: 'center', justifyContent: 'center'}; 32 | return ( 33 | 34 | Waiting for Figwheel to load files. 35 | 36 | ); 37 | } 38 | return this.state.root; 39 | }, 40 | componentDidMount: function () { 41 | var app = this; 42 | if (typeof goog === "undefined") { 43 | loadApp(platform, devHost, function(appRoot) { 44 | app.setState({root: appRoot, loaded: true}) 45 | }); 46 | } 47 | } 48 | }) 49 | }; 50 | 51 | // evaluates js code ensuring proper ordering 52 | function customEval(url, javascript, success, error) { 53 | if (scriptQueue.length > 0) { 54 | if (scriptQueue[0] === url) { 55 | try { 56 | evaluate(javascript); 57 | console.info('Evaluated: ' + url); 58 | scriptQueue.shift(); 59 | evalListeners.forEach(function (listener) { 60 | listener(url) 61 | }); 62 | success(); 63 | } catch (e) { 64 | console.error('Evaluation error in: ' + url); 65 | console.error(e); 66 | error(); 67 | } 68 | } else { 69 | setTimeout(function () { 70 | customEval(url, javascript, success, error) 71 | }, 5); 72 | } 73 | } else { 74 | console.error('Something bad happened...'); 75 | error() 76 | } 77 | } 78 | 79 | var isChrome = function () { 80 | return typeof importScripts === "function" 81 | }; 82 | 83 | function asyncImportScripts(url, success, error) { 84 | console.info('(asyncImportScripts) Importing: ' + url); 85 | scriptQueue.push(url); 86 | fetch(url) 87 | .then(function (response) { 88 | return response.text() 89 | }) 90 | .then(function (responseText) { 91 | return customEval(url, responseText, success, error); 92 | }) 93 | .catch(function (error) { 94 | console.error('Error loading script, please check your config setup.'); 95 | console.error(error); 96 | return error(); 97 | }); 98 | } 99 | 100 | function syncImportScripts(url, success, error) { 101 | try { 102 | importScripts(url); 103 | console.info('Evaluated: ' + url); 104 | evalListeners.forEach(function (listener) { 105 | listener(url) 106 | }); 107 | success(); 108 | } catch (e) { 109 | error() 110 | } 111 | } 112 | 113 | // Loads js file sync if possible or async. 114 | function importJs(src, success, error) { 115 | if (typeof success !== 'function') { 116 | success = function () { 117 | }; 118 | } 119 | if (typeof error !== 'function') { 120 | error = function () { 121 | }; 122 | } 123 | 124 | var file = fileBasePath + '/' + src; 125 | 126 | console.info('(importJs) Importing: ' + file); 127 | if (isChrome()) { 128 | syncImportScripts(serverBaseUrl("localhost") + '/' + file, success, error); 129 | } else { 130 | asyncImportScripts(serverBaseUrl(serverHost) + '/' + file, success, error); 131 | } 132 | } 133 | 134 | function interceptRequire() { 135 | var oldRequire = window.require; 136 | console.info("Shimming require"); 137 | window.require = function (id) { 138 | console.info("Requiring: " + id); 139 | if (externalModules[id]) { 140 | return externalModules[id]; 141 | } 142 | return oldRequire(id); 143 | }; 144 | } 145 | 146 | // do not show debug messages in yellow box 147 | function debugToLog() { 148 | console.debug = console.log; 149 | } 150 | 151 | function serverBaseUrl(host) { 152 | return "http://" + host + ":" + config.serverPort 153 | } 154 | 155 | function loadApp(platform, devHost, onLoadCb) { 156 | serverHost = devHost; 157 | fileBasePath = config.basePath + platform; 158 | 159 | evalListeners.push(function (url) { 160 | if (url.indexOf('jsloader') > -1) { 161 | shimJsLoader(); 162 | } 163 | }); 164 | 165 | // callback when app is ready to get the reloadable component 166 | var mainJs = '/env/' + platform + '/main.js'; 167 | evalListeners.push(function (url) { 168 | if (url.indexOf(mainJs) > -1) { 169 | onLoadCb(env[platform].main.root_el); 170 | console.log('Done loading Clojure app'); 171 | } 172 | }); 173 | 174 | if (typeof goog === "undefined") { 175 | console.log('Loading Closure base.'); 176 | interceptRequire(); 177 | importJs('goog/base.js', function () { 178 | shimBaseGoog(); 179 | fakeLocalStorageAndDocument(); 180 | importJs('cljs_deps.js'); 181 | importJs('goog/deps.js', function () { 182 | debugToLog(); 183 | // This is needed because of RN packager 184 | // seriously React packager? why. 185 | var googreq = goog.require; 186 | 187 | googreq('figwheel.connect'); 188 | }); 189 | }); 190 | } 191 | } 192 | 193 | function startApp(appName, platform, devHost) { 194 | React.AppRegistry.registerComponent( 195 | appName, () => figwheelApp(platform, devHost)); 196 | } 197 | 198 | function withModules(moduleById) { 199 | externalModules = moduleById; 200 | return self; 201 | } 202 | 203 | // Goog fixes 204 | function shimBaseGoog() { 205 | console.info('Shimming goog functions.'); 206 | goog.basePath = 'goog/'; 207 | goog.writeScriptSrcNode = importJs; 208 | goog.writeScriptTag_ = function (src, optSourceText) { 209 | importJs(src); 210 | return true; 211 | }; 212 | goog.inHtmlDocument_ = function () { 213 | return true; 214 | }; 215 | } 216 | 217 | function fakeLocalStorageAndDocument() { 218 | window.localStorage = {}; 219 | window.localStorage.getItem = function () { 220 | return 'true'; 221 | }; 222 | window.localStorage.setItem = function () { 223 | }; 224 | 225 | window.document = {}; 226 | window.document.body = {}; 227 | window.document.body.dispatchEvent = function () { 228 | }; 229 | window.document.createElement = function () { 230 | }; 231 | 232 | if (typeof window.location === 'undefined') { 233 | window.location = {}; 234 | } 235 | console.debug = console.warn; 236 | window.addEventListener = function () { 237 | }; 238 | // make figwheel think that heads-up-display divs are there 239 | window.document.querySelector = function (selector) { 240 | return {}; 241 | }; 242 | window.document.getElementById = function (id) { 243 | return {style:{}}; 244 | }; 245 | } 246 | 247 | // Figwheel fixes 248 | // Used by figwheel - uses importScript to load JS rather than