diff --git a/app/build.gradle b/app/build.gradle index e36afca..f4b8a4a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,6 +82,9 @@ android { //javaMaxHeapSize "4g" preDexLibraries false } + dataBinding { + enabled = true + } } dependencies { @@ -109,9 +112,11 @@ dependencies { exclude module: 'library' } compile project(':library') + compile project(':rn') } else { compile project(':my') compile project(':home') compile project(':girls') + compile project(':rn') } } diff --git a/app/src/main/java/com/dhc/flyabbit/di/component/HActivityComponent.java b/app/src/main/java/com/dhc/flyabbit/di/component/HActivityComponent.java index 62f399f..225b7b7 100644 --- a/app/src/main/java/com/dhc/flyabbit/di/component/HActivityComponent.java +++ b/app/src/main/java/com/dhc/flyabbit/di/component/HActivityComponent.java @@ -1,5 +1,6 @@ package com.dhc.flyabbit.di.component; +import com.dhc.flyabbit.ui.MainActivity; import com.dhc.library.di.ActivityScope; import com.dhc.library.di.component.AppComponent; import com.dhc.library.di.module.ActivityModule; @@ -16,7 +17,7 @@ public interface HActivityComponent { -// void inject(WelcomeActivity WelcomeActivity); + void inject(MainActivity mainActivity); // // void inject(HomeActivity homeActivity); diff --git a/app/src/main/java/com/dhc/flyabbit/ui/MainActivity.java b/app/src/main/java/com/dhc/flyabbit/ui/MainActivity.java index f2dea13..487e493 100644 --- a/app/src/main/java/com/dhc/flyabbit/ui/MainActivity.java +++ b/app/src/main/java/com/dhc/flyabbit/ui/MainActivity.java @@ -1,18 +1,25 @@ package com.dhc.flyabbit.ui; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.support.annotation.Nullable; import android.util.Log; -import android.view.ViewGroup; +import android.view.KeyEvent; import com.alibaba.android.arouter.facade.annotation.Route; import com.dhc.flyabbit.R; -import com.dhc.library.utils.delegate.OnShowHomeListener; -import com.dhc.library.base.XDaggerActivity; +import com.dhc.flyabbit.di.HDiHelper; +import com.dhc.library.base.BaseActivity; import com.dhc.library.data.SPHelper; import com.dhc.library.data.net.Constants; import com.dhc.library.utils.AppContext; import com.dhc.library.utils.AppUtil; +import com.dhc.library.utils.ReactManagerFactory; +import com.dhc.library.utils.delegate.OnShowHomeListener; +import com.facebook.react.ReactInstanceManager; import me.yokeyword.fragmentation.SupportFragment; import me.yokeyword.fragmentation.helper.FragmentLifecycleCallbacks; @@ -23,11 +30,10 @@ * 描述 ${主页面} */ @Route(path = "/app/MainActivity") -public class MainActivity extends XDaggerActivity implements OnShowHomeListener { - - private ViewGroup mViewGroup; - private ViewGroup mContentView; - +public class MainActivity extends BaseActivity implements OnShowHomeListener { + private static final int REDBOX_PERMISSION_MESSAGE =112 ; + private int OVERLAY_PERMISSION_REQ_CODE = 111; + protected ReactInstanceManager mReactInstanceManager; @Override protected int getLayout() { @@ -38,6 +44,21 @@ protected int getLayout() protected void onCreate(@Nullable Bundle savedInstanceState) { setTheme(R.style.AppTheme); super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!Settings.canDrawOverlays(this)) { + Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + getPackageName())); + startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE); + } + } + if (Build.VERSION.SDK_INT >= 23) { + // Get permission to show redbox in dev builds. + if (!Settings.canDrawOverlays(this)) { + Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); + this.startActivity(serviceIntent); + } + } + mReactInstanceManager= ReactManagerFactory.getReactInstanceManager(); } @Override @@ -78,6 +99,7 @@ public void onFragmentCreated(SupportFragment fragment, Bundle savedInstanceStat } + @Override public void onBackPressedSupport() { super.onBackPressedSupport(); @@ -86,6 +108,7 @@ public void onBackPressedSupport() { @Override public void initInject(Bundle savedInstanceState) { //TODO 依赖注入 + HDiHelper.getActivityComponent(getActivityModule()).inject(this); } @@ -94,4 +117,24 @@ public void initInject(Bundle savedInstanceState) { public void showHome() { replaceLoadRootFragment(R.id.fl_container, MainFragment.newInstance(),true); } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) { + mReactInstanceManager.showDevOptionsDialog(); + return true; + } + return super.onKeyUp(keyCode, event); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == OVERLAY_PERMISSION_REQ_CODE) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!Settings.canDrawOverlays(this)) { + // SYSTEM_ALERT_WINDOW permission not granted... + } + } + } + } } diff --git a/app/src/main/java/com/dhc/flyabbit/ui/MainFragment.java b/app/src/main/java/com/dhc/flyabbit/ui/MainFragment.java index c328c90..f72651b 100644 --- a/app/src/main/java/com/dhc/flyabbit/ui/MainFragment.java +++ b/app/src/main/java/com/dhc/flyabbit/ui/MainFragment.java @@ -8,9 +8,10 @@ import com.dhc.flyabbit.gank.ui.GankFragment; import com.dhc.flyabbit.home.ui.HomeFragment; import com.dhc.flyabbit.my.MyFragment; -import com.dhc.library.utils.delegate.OnBackToFirstListener; +import com.dhc.flyabbit.rn.ReactNativeFragment; import com.dhc.library.base.XDaggerFragment; import com.dhc.library.data.account.AccountManager; +import com.dhc.library.utils.delegate.OnBackToFirstListener; import com.dhc.library.widget.bottombar.BottomBar; import com.dhc.library.widget.bottombar.BottomBarTab; @@ -27,13 +28,14 @@ public class MainFragment extends XDaggerFragment implements OnBackToFirstListener { private BottomBar mBottomBar; - private String[] mTitles = {"干货", "妹子", "关于"}; + private String[] mTitles = {"干货", "妹子","ReactNative", "关于"}; private int[] mIconUnselectIds = { R.mipmap.ic_drawer_gank, - R.mipmap.ic_drawer_meizi, R.mipmap.ic_drawer_setting}; + R.mipmap.ic_drawer_meizi, R.mipmap.ic_drawer_setting,R.mipmap.ic_drawer_setting}; public static final int FIRST = 0; public static final int SECOND = 1; public static final int THIRD = 2; + public static final int FOUR = 3; public int current = -1; private SupportFragment[] mFragments = new SupportFragment[4]; @@ -49,7 +51,8 @@ private void initView(View view) { mBottomBar = (BottomBar) view.findViewById(R.id.bottomBar); mBottomBar.addItem(new BottomBarTab(_mActivity, mIconUnselectIds[0], mTitles[0])) .addItem(new BottomBarTab(_mActivity, mIconUnselectIds[1], mTitles[1])) - .addItem(new BottomBarTab(_mActivity, mIconUnselectIds[2], mTitles[2])); + .addItem(new BottomBarTab(_mActivity, mIconUnselectIds[2], mTitles[2])) + .addItem(new BottomBarTab(_mActivity, mIconUnselectIds[3], mTitles[3])); mBottomBar.setOnTabSelectedListener(new BottomBar.OnTabSelectedListener() { @@ -86,15 +89,18 @@ public void initInject(Bundle savedInstanceState) { if (savedInstanceState == null) { mFragments[FIRST] = HomeFragment.newInstance(); mFragments[SECOND] = GankFragment.newInstance(); - mFragments[THIRD] = MyFragment.newInstance(); + mFragments[THIRD] = ReactNativeFragment.newInstance(); + mFragments[FOUR] = MyFragment.newInstance(); loadMultipleRootFragment(R.id.fl_tab_container, FIRST, mFragments[FIRST], mFragments[SECOND], - mFragments[THIRD]); + mFragments[THIRD], + mFragments[FOUR]); } else { mFragments[FIRST] = findChildFragment(HomeFragment.class); mFragments[SECOND] = findChildFragment(GankFragment.class); - mFragments[THIRD] = findChildFragment(MyFragment.class); + mFragments[THIRD] = findChildFragment(ReactNativeFragment.class); + mFragments[FOUR] = findChildFragment(MyFragment.class); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5ebfa58..c673fc2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,7 @@ + - \ No newline at end of file + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6bb87f5..5e89972 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,10 @@ allprojects { jcenter() mavenCentral() maven { url "https://jitpack.io" } + maven { + // All of React Native (JS, Android binaries) is installed from npm + url "$rootDir/./rn/node_modules/react-native/android" + } } tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') diff --git a/girls/build.gradle b/girls/build.gradle index 3286f37..9a4322a 100644 --- a/girls/build.gradle +++ b/girls/build.gradle @@ -63,6 +63,9 @@ android { } aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false + dataBinding { + enabled = true + } } dependencies { diff --git a/home/build.gradle b/home/build.gradle index 740e856..dd67597 100644 --- a/home/build.gradle +++ b/home/build.gradle @@ -63,6 +63,9 @@ android { } aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false + dataBinding { + enabled = true + } } dependencies { diff --git a/library/build.gradle b/library/build.gradle index 13a3ba9..6a1d5cc 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -140,7 +140,7 @@ dependencies { provided rootProject.ext.dependencies["javax.annotation"] annotationProcessor rootProject.ext.dependencies["dagger-compiler"] //dagger2的apt注解 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //阿里的Arouter的apt注解 - + compile "com.facebook.react:react-native:+" // From node_modules. } diff --git a/library/src/main/java/com/dhc/library/base/BaseActivity.java b/library/src/main/java/com/dhc/library/base/BaseActivity.java index 068ede0..802c220 100644 --- a/library/src/main/java/com/dhc/library/base/BaseActivity.java +++ b/library/src/main/java/com/dhc/library/base/BaseActivity.java @@ -16,6 +16,8 @@ import com.dhc.library.R; import com.dhc.library.data.bean.ToolBarOptions; +import com.dhc.library.di.IDaggerListener; +import com.dhc.library.di.module.ActivityModule; import com.dhc.library.utils.ToolbarUtil; import com.dhc.library.utils.logger.KLog; import com.tbruyelle.rxpermissions2.RxPermissions; @@ -34,7 +36,7 @@ * 时间 :2016/11/15 16:08 * 描述 :无MVP的activity基类 */ -public abstract class BaseActivity extends SupportActivity implements LifecycleProvider { +public abstract class BaseActivity extends SupportActivity implements LifecycleProvider,IDaggerListener { protected Context mContext; private Toolbar toolbar; public RxPermissions mRxPermissions; @@ -48,6 +50,7 @@ public abstract class BaseActivity extends SupportActivity implements LifecycleP @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + initInject(savedInstanceState); super.onCreate(savedInstanceState); lifecycleSubject.onNext(ActivityEvent.CREATE); if (getLayout() > 0) { @@ -73,6 +76,11 @@ public void onClick(View view) { }); } + + protected ActivityModule getActivityModule() { + return new ActivityModule(this); + } + /** * 设置标题栏 * diff --git a/library/src/main/java/com/dhc/library/base/BaseFragment.java b/library/src/main/java/com/dhc/library/base/BaseFragment.java index b146758..137cf2a 100644 --- a/library/src/main/java/com/dhc/library/base/BaseFragment.java +++ b/library/src/main/java/com/dhc/library/base/BaseFragment.java @@ -15,6 +15,8 @@ import android.view.inputmethod.InputMethodManager; import com.dhc.library.data.bean.ToolBarOptions; +import com.dhc.library.di.IDaggerListener; +import com.dhc.library.di.module.FragmentModule; import com.dhc.library.utils.ToolbarUtil; import com.dhc.library.utils.logger.KLog; import com.tbruyelle.rxpermissions2.RxPermissions; @@ -37,7 +39,7 @@ * 时间 :2016/11/15 16:08 * 描述 :无MVP的Fragment基类 */ -public abstract class BaseFragment extends SupportFragment implements LifecycleProvider { +public abstract class BaseFragment extends SupportFragment implements LifecycleProvider,IDaggerListener { private static final Handler handler = new Handler(); private Toolbar toolbar; protected View mView; @@ -91,6 +93,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, int layoutId = getLayoutId(); if (layoutId > 0) mView = inflater.inflate(layoutId, null); + initInject(savedInstanceState); return mView; } @@ -175,6 +178,10 @@ public void onClick(View v) { } } + protected FragmentModule getFragmentModule() { + return new FragmentModule(this); + } + protected void doYouWantTodo(){ } diff --git a/library/src/main/java/com/dhc/library/base/XDaggerActivity.java b/library/src/main/java/com/dhc/library/base/XDaggerActivity.java index ac4e235..65b4e94 100644 --- a/library/src/main/java/com/dhc/library/base/XDaggerActivity.java +++ b/library/src/main/java/com/dhc/library/base/XDaggerActivity.java @@ -4,8 +4,6 @@ import android.os.Bundle; import android.support.annotation.Nullable; -import com.dhc.library.di.IDaggerListener; -import com.dhc.library.di.module.ActivityModule; import com.dhc.library.utils.ToastUtil; import com.trello.rxlifecycle2.LifecycleTransformer; @@ -17,13 +15,12 @@ * 时间 :2016/11/15 16:06 * 描述 :MVP activity基类 */ -public abstract class XDaggerActivity extends BaseActivity implements IBaseView ,IDaggerListener { +public abstract class XDaggerActivity extends BaseActivity implements IBaseView { @Inject protected T mPresenter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - initInject(savedInstanceState); if (mPresenter != null) mPresenter.attachView(this); super.onCreate(savedInstanceState); @@ -59,9 +56,7 @@ public final void showToast(String msg) { } - protected ActivityModule getActivityModule() { - return new ActivityModule(this); - } + @Override protected void onDestroy() { diff --git a/library/src/main/java/com/dhc/library/base/XDaggerFragment.java b/library/src/main/java/com/dhc/library/base/XDaggerFragment.java index 141a1b1..3c2697e 100644 --- a/library/src/main/java/com/dhc/library/base/XDaggerFragment.java +++ b/library/src/main/java/com/dhc/library/base/XDaggerFragment.java @@ -3,12 +3,9 @@ import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import com.dhc.library.di.IDaggerListener; -import com.dhc.library.di.module.FragmentModule; import com.trello.rxlifecycle2.LifecycleTransformer; import javax.inject.Inject; @@ -23,19 +20,8 @@ public abstract class XDaggerFragment extends BaseFrag @Inject protected T mPresenter; public boolean isShowView=false; - protected FragmentModule getFragmentModule() { - return new FragmentModule(this); - } - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - int layoutId = getLayoutId(); - if (layoutId > 0) - mView = inflater.inflate(layoutId, null); - initInject(savedInstanceState); - return mView; - } + @Override public LifecycleTransformer bindLifecycle() { diff --git a/library/src/main/java/com/dhc/library/di/component/AppComponent.java b/library/src/main/java/com/dhc/library/di/component/AppComponent.java index f0a4dc8..3401e80 100644 --- a/library/src/main/java/com/dhc/library/di/component/AppComponent.java +++ b/library/src/main/java/com/dhc/library/di/component/AppComponent.java @@ -35,4 +35,5 @@ public interface AppComponent { * that depend on {@link AppComponent}. */ Random random(); + } diff --git a/library/src/main/java/com/dhc/library/di/module/AppModule.java b/library/src/main/java/com/dhc/library/di/module/AppModule.java index c15666d..8940698 100644 --- a/library/src/main/java/com/dhc/library/di/module/AppModule.java +++ b/library/src/main/java/com/dhc/library/di/module/AppModule.java @@ -8,6 +8,7 @@ import com.dhc.library.data.HttpHelper; import com.dhc.library.data.IDataHelper; import com.dhc.library.di.ContextLife; +import com.dhc.library.utils.AppUtil; import java.util.Random; @@ -33,6 +34,7 @@ public AppModule(BaseApplication application) { @Singleton @ContextLife("Application") BaseApplication provideApplicationContext() { + AppUtil.syncIsDebug(application.getApplicationContext()); return application; } @@ -57,4 +59,5 @@ public Random random() { return new Random(); } + } diff --git a/library/src/main/java/com/dhc/library/utils/ReactManagerFactory.java b/library/src/main/java/com/dhc/library/utils/ReactManagerFactory.java new file mode 100644 index 0000000..bbd105b --- /dev/null +++ b/library/src/main/java/com/dhc/library/utils/ReactManagerFactory.java @@ -0,0 +1,37 @@ +package com.dhc.library.utils; + +import android.app.Application; + +import com.facebook.react.ReactInstanceManager; +import com.facebook.react.common.LifecycleState; +import com.facebook.react.shell.MainReactPackage; + +/** + * 创建者 邓浩宸 + * 创建时间 2017/9/20 16:26 + * 描述 ${TODO} + */ + +public class ReactManagerFactory { + private static ReactInstanceManager instance; + + private ReactManagerFactory() { + + } + + public static synchronized ReactInstanceManager getReactInstanceManager() { + if (instance == null) { + instance = ReactInstanceManager.builder() + .setApplication((Application) AppContext.get()) + .setBundleAssetName("index.android.bundle") + .setJSMainModuleName("index.android") + .addPackage(new MainReactPackage()) + .setUseDeveloperSupport(true) + .setInitialLifecycleState(LifecycleState.RESUMED) + .build(); + ; + } + return instance; + } + +} diff --git a/my/build.gradle b/my/build.gradle index 9318643..0a80b07 100644 --- a/my/build.gradle +++ b/my/build.gradle @@ -70,6 +70,9 @@ android { //javaMaxHeapSize "4g" preDexLibraries false } + dataBinding { + enabled = true + } } dependencies { diff --git a/rn/.gitignore b/rn/.gitignore new file mode 100644 index 0000000..13f987f --- /dev/null +++ b/rn/.gitignore @@ -0,0 +1,2 @@ +/build +/node_modules/ diff --git a/rn/app.json b/rn/app.json new file mode 100644 index 0000000..c6ca557 --- /dev/null +++ b/rn/app.json @@ -0,0 +1,4 @@ +{ + "name": "FlyabbitForRN", + "displayName": "FlyabbitForRN" +} \ No newline at end of file diff --git a/rn/app/Example.js b/rn/app/Example.js new file mode 100644 index 0000000..6e4edb9 --- /dev/null +++ b/rn/app/Example.js @@ -0,0 +1,223 @@ +import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import Launch from './components/Launch'; +import Register from './components/Register'; +import Login from './components/Login'; +import Login2 from './components/Login2'; +import Login3 from './components/Login3'; +import CardStackStyleInterpolator from 'react-navigation/src/views/CardStackStyleInterpolator'; +import { + Scene, + Router, + Actions, + Reducer, + ActionConst, + Overlay, + Tabs, + Modal, + Drawer, + Stack, + Lightbox, +} from 'react-native-router-flux'; +import Home from './components/Home'; +import DrawerContent from './components/drawer/DrawerContent'; +import TabView from './components/TabView'; +import TabIcon from './components/TabIcon'; +import EchoView from './components/EchoView'; +import MessageBar from './components/MessageBar'; +import ErrorModal from './components/modal/ErrorModal'; +import DemoLightbox from './components/lightbox/DemoLightbox'; +import MenuIcon from './images/menu_burger.png'; + +const styles = StyleSheet.create({ + container: { + flex: 1, backgroundColor: 'transparent', justifyContent: 'center', + alignItems: 'center', + }, + tabBarStyle: { + backgroundColor: '#eee', + }, + tabBarSelectedItemStyle: { + backgroundColor: '#ddd', + }, +}); + +const reducerCreate = params => {//这里箭头式的函数声明 + const defaultReducer = new Reducer(params);//const便是不可以改变的 + return (state, action) => { + console.log('ACTION:', action); + return defaultReducer(state, action); + }; +}; + +//es5的写法 +// const reducerCreate =function (params) { +// const defaultReducer = new Reducer(params); +// return function(state, action) { +// console.log('ACTION:', action); +// return defaultReducer(state, action); +// }; +// }; + +const getSceneStyle = () => ({ + backgroundColor: '#F5FCFF', + shadowOpacity: 1, + shadowRadius: 3, +}); + +const Example = () => ( + + //空白的页面因为Router只能包含一个组件 + ({ screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid })} + > + + navigation.state.key} /> + + + + + + + + + + {/* + Wrapper Scene needed to fix a bug where the tabs would + reload as a modal ontop of itself + */} + + + + alert('Right button')} + rightTitle="Right" + + /> + + + + + + Right} + /> + alert('onBack button!')} + backTitle="Back!" + panHandlers={null} + /> + + + + { }} + /> + + + + + + + + + + + + + + + + console.log('onExit')} + leftTitle="Cancel" + onLeft={Actions.pop} + /> + + + + + + + + +); + +export default Example; diff --git a/rn/app/components/EchoView.js b/rn/app/components/EchoView.js new file mode 100644 index 0000000..e791031 --- /dev/null +++ b/rn/app/components/EchoView.js @@ -0,0 +1,37 @@ +import React from 'react'; +import {View, Text, StyleSheet} from "react-native"; +import Button from "react-native-button"; +import {Actions} from "react-native-router-flux"; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "#F5FCFF", + borderWidth: 2, + borderColor: 'red', + }, + instructions: { + textAlign: "center", + color: "#333333", + marginBottom: 5, + }, + smaller: { + marginBottom: 5, + fontSize: 12, + }, +}); + + +export default class extends React.Component { + render(){ + return ( + + routeName: {this.props.name} + + + ); + } +} + diff --git a/rn/app/components/Error.js b/rn/app/components/Error.js new file mode 100644 index 0000000..d015be4 --- /dev/null +++ b/rn/app/components/Error.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { View, Text, StyleSheet, Animated, Dimensions } from 'react-native'; +import Button from 'react-native-button'; +import { Actions } from 'react-native-router-flux'; + +const { height: deviceHeight } = Dimensions.get("window"); + +const styles = StyleSheet.create({ + container: { + position: 'absolute', + top: 0, + bottom: 0, + left: 0, + right: 0, + backgroundColor: 'transparent', + justifyContent: 'center', + alignItems: 'center', + }, +}); + +export default class extends React.Component { + constructor(props) { + super(props); + + this.state = { + offset: new Animated.Value(-deviceHeight) + }; + } + + componentDidMount() { + Animated.timing(this.state.offset, { + duration: 150, + toValue: 0 + }).start(); + } + + closeModal() { + Animated.timing(this.state.offset, { + duration: 150, + toValue: -deviceHeight + }).start(Actions.pop); + } + + render() { + return ( + + + {this.props.data} + + + + ); + } +} diff --git a/rn/app/components/Home.js b/rn/app/components/Home.js new file mode 100644 index 0000000..beed44b --- /dev/null +++ b/rn/app/components/Home.js @@ -0,0 +1,36 @@ +import React from 'react'; +import {View, Text, StyleSheet} from "react-native"; +import Button from "react-native-button"; +import {Actions} from "react-native-router-flux"; + +var styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "#F5FCFF", + }, + welcome: { + fontSize: 20, + textAlign: "center", + margin: 10, + }, + instructions: { + textAlign: "center", + color: "#333333", + marginBottom: 5, + }, +}); + +class Home extends React.Component { + render(){ + return ( + + Replace screen + + + ); + } +} + +module.exports = Home; diff --git a/rn/app/components/Launch.js b/rn/app/components/Launch.js new file mode 100644 index 0000000..01e4e75 --- /dev/null +++ b/rn/app/components/Launch.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { View, Text, StyleSheet, Button } from 'react-native'; +import { Actions } from 'react-native-router-flux'; +import { MessageBarManager } from 'react-native-message-bar'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'transparent', + }, +}); + +class Launch extends React.Component { + render() { + return ( + + Welcome + + + + + ); + } +} diff --git a/rn/app/components/Login2.js b/rn/app/components/Login2.js new file mode 100644 index 0000000..2be72dc --- /dev/null +++ b/rn/app/components/Login2.js @@ -0,0 +1,29 @@ +import React from 'react'; +import {View, Text, StyleSheet} from "react-native"; +import Button from "react-native-button"; +import {Actions} from "react-native-router-flux"; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "#F5FCFF", + }, +}); + +export default class extends React.Component { + render(){ + const title = this.props.title || 'No Title'; + const data = this.props.data || 'No Data'; + return ( + + Login page 2 + Title: {title} + Data: {data} + + + + ); + } +} diff --git a/rn/app/components/Login3.js b/rn/app/components/Login3.js new file mode 100644 index 0000000..63cf44b --- /dev/null +++ b/rn/app/components/Login3.js @@ -0,0 +1,43 @@ +import React from 'react'; +import {View, Text, StyleSheet} from "react-native"; +import Button from "react-native-button"; +import {Actions} from "react-native-router-flux"; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "#F5FCFF", + }, +}); + +const popToRoot = () => { + Actions.popTo("launch"); +}; + +const popToLogin1 = () => { + Actions.popTo("loginModal"); +}; + +const popToLogin2 = () => { + Actions.popTo("loginModal2"); +}; + +export default class extends React.Component { + render(){ + const title = this.props.title || 'No Title'; + const data = this.props.data || 'No Data'; + return ( + + Login page 3 + Title: {title} + Data: {data} + + + + + + ); + } +} diff --git a/rn/app/components/MessageBar.js b/rn/app/components/MessageBar.js new file mode 100644 index 0000000..875c228 --- /dev/null +++ b/rn/app/components/MessageBar.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { MessageBar, MessageBarManager } from 'react-native-message-bar'; + +export default class extends React.Component { + componentDidMount() { + // Register the alert located on this master page + // This MessageBar will be accessible from the current (same) component, and from its child component + // The MessageBar is then declared only once, in your main component. + MessageBarManager.registerMessageBar(this.refs.alert); + } + + componentWillUnmount() { + // Remove the alert located on this master page from the manager + MessageBarManager.unregisterMessageBar(); + } + + render() { + return ; + } +} diff --git a/rn/app/components/Register.js b/rn/app/components/Register.js new file mode 100644 index 0000000..bd81f38 --- /dev/null +++ b/rn/app/components/Register.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { View, Text, StyleSheet } from 'react-native'; +import Button from 'react-native-button'; +import { Actions } from 'react-native-router-flux'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#F5FCFF', + }, +}); + +export default class Register extends React.Component { + render() { + return + Register page + + + + + } +} diff --git a/rn/app/components/TabIcon.js b/rn/app/components/TabIcon.js new file mode 100644 index 0000000..371ffdb --- /dev/null +++ b/rn/app/components/TabIcon.js @@ -0,0 +1,22 @@ +import React, { + PropTypes, +} from 'react'; +import { + Text, +} from 'react-native'; + +const propTypes = { + selected: PropTypes.bool, + title: PropTypes.string, +}; + +const TabIcon = (props) => { + return {props.title} + +}; + +TabIcon.propTypes = propTypes; + +export default TabIcon; diff --git a/rn/app/components/TabView.js b/rn/app/components/TabView.js new file mode 100644 index 0000000..aaa1225 --- /dev/null +++ b/rn/app/components/TabView.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { PropTypes } from "react"; +import { StyleSheet, Text, View, ViewPropTypes } from "react-native"; +import Button from 'react-native-button'; +import { Actions } from 'react-native-router-flux'; + +const contextTypes = { + drawer: React.PropTypes.object, +}; + +const propTypes = { + name: PropTypes.string, + sceneStyle: ViewPropTypes.style, + title: PropTypes.string, +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'transparent', + borderWidth: 2, + borderColor: 'red', + }, +}); + +class TabView extends React.Component { + render() { + return ( + + Tab title:{this.props.title} name:{this.props.name} + Tab data:{this.props.data} + {this.props.name === 'tab_1_1' && + + } + {this.props.name === 'tab_2_1' && + + } + + + + + + + + + ); + } +} +TabView.contextTypes = contextTypes; +TabView.propTypes = propTypes; + +export default TabView; diff --git a/rn/app/components/drawer/DrawerContent.js b/rn/app/components/drawer/DrawerContent.js new file mode 100644 index 0000000..ac6910e --- /dev/null +++ b/rn/app/components/drawer/DrawerContent.js @@ -0,0 +1,53 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { StyleSheet, Text, View, ViewPropTypes } from 'react-native'; +import Button from 'react-native-button'; +import { Actions } from 'react-native-router-flux'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'transparent', + borderWidth: 2, + borderColor: 'red', + }, +}); + +class DrawerContent extends React.Component { + static propTypes = { + name: PropTypes.string, + sceneStyle: ViewPropTypes.style, + title: PropTypes.string, + } + + static contextTypes = { + drawer: React.PropTypes.object, + } + + render() { + return ( + + Drawer Content + + Title: {this.props.title} + {this.props.name === 'tab1_1' && + + } + {this.props.name === 'tab2_1' && + + } + + + + + + + + + ); + } +} + +export default DrawerContent; diff --git a/rn/app/components/lightbox/BaseLightbox.js b/rn/app/components/lightbox/BaseLightbox.js new file mode 100644 index 0000000..44e9956 --- /dev/null +++ b/rn/app/components/lightbox/BaseLightbox.js @@ -0,0 +1,77 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { View, StyleSheet, Animated, Dimensions, Button } from 'react-native'; +import { Actions } from 'react-native-router-flux'; + +const { height: deviceHeight, width: deviceWidth } = Dimensions.get('window'); + +export default class BaseLightbox extends Component { + static propTypes = { + children: PropTypes.any, + horizontalPercent: PropTypes.number, + verticalPercent: PropTypes.number, + } + + constructor(props) { + super(props); + + this.state = { + opacity: new Animated.Value(0), + }; + } + + componentDidMount() { + Animated.timing(this.state.opacity, { + duration: 100, + toValue: 1, + }).start(); + } + + closeModal = () => { + Animated.timing(this.state.opacity, { + duration: 100, + toValue: 0, + }).start(Actions.pop); + } + + _renderLightBox = () => { + const { children, horizontalPercent = 1, verticalPercent = 1 } = this.props; + const height = verticalPercent ? deviceHeight * verticalPercent : deviceHeight; + const width = horizontalPercent ? deviceWidth * horizontalPercent : deviceWidth; + return ( + + {children} +