parent
4e39130176
commit
6beda2ace2
|
@ -131,6 +131,7 @@ dependencies {
|
|||
compile project(':react-native-linear-gradient')
|
||||
compile project(':ReactNativeAndroidSmsListener')
|
||||
compile project(':react-native-camera')
|
||||
compile project(':react-native-orientation')
|
||||
// compile(name:'geth', ext:'aar')
|
||||
compile(group: 'status-im', name: 'android-geth', version: '1.4.0-201604110816-a97a114', ext: 'aar')
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import com.bitgo.randombytes.RandomBytesPackage;
|
||||
import com.BV.LinearGradient.LinearGradientPackage;
|
||||
import com.centaurwarchief.smslistener.SmsListener;
|
||||
import com.github.yamill.orientation.OrientationPackage;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
@ -35,7 +36,8 @@ import java.io.File;
|
|||
import com.lwansbrough.RCTCamera.*;
|
||||
import com.i18n.reactnativei18n.ReactNativeI18n;
|
||||
import io.realm.react.RealmReactPackage;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
|
@ -181,7 +183,16 @@ public class MainActivity extends ReactActivity {
|
|||
new RandomBytesPackage(),
|
||||
new LinearGradientPackage(),
|
||||
new RCTCameraPackage(),
|
||||
new SmsListener(this)
|
||||
new SmsListener(this),
|
||||
new OrientationPackage(this)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Intent intent = new Intent("onConfigurationChanged");
|
||||
intent.putExtra("newConfig", newConfig);
|
||||
this.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,3 +20,5 @@ include ':ReactNativeAndroidSmsListener'
|
|||
project(':ReactNativeAndroidSmsListener').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-sms-listener/android')
|
||||
include ':react-native-camera'
|
||||
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
|
||||
include ':react-native-orientation', ':app'
|
||||
project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation/android')
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
"react-native-qrcode": "^0.2.2",
|
||||
"react-native-randombytes": "^2.1.0",
|
||||
"react-native-vector-icons": "^1.3.4",
|
||||
"react-native-orientation": "^1.17.0",
|
||||
"realm": "^0.11.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[status-im.handlers]
|
||||
[status-im.subs]
|
||||
[status-im.components.react :refer [navigator app-registry device-event-emitter]]
|
||||
[status-im.components.react :refer [navigator app-registry device-event-emitter
|
||||
orientation]]
|
||||
[status-im.components.main-tabs :refer [main-tabs]]
|
||||
[status-im.contacts.screen :refer [contact-list]]
|
||||
[status-im.contacts.views.new-contact :refer [new-contact]]
|
||||
|
@ -33,12 +34,20 @@
|
|||
true)))]
|
||||
(add-event-listener "hardwareBackPress" new-listener)))
|
||||
|
||||
(defn orientation->keyword [o]
|
||||
(keyword (.toLowerCase o)))
|
||||
|
||||
(defn app-root []
|
||||
(let [signed-up (subscribe [:get :signed-up])
|
||||
view-id (subscribe [:get :view-id])]
|
||||
(r/create-class
|
||||
{:component-will-mount
|
||||
(fn []
|
||||
(let [o (orientation->keyword (.getInitialOrientation orientation))]
|
||||
(dispatch [:set :orientation o]))
|
||||
(.addOrientationListener
|
||||
orientation
|
||||
#(dispatch [:set :orientation (orientation->keyword %)]))
|
||||
(.addListener device-event-emitter
|
||||
"keyboardDidShow"
|
||||
(fn [e]
|
||||
|
|
|
@ -34,11 +34,15 @@
|
|||
;; TODO stub data: request message info
|
||||
"By ???, MMM 1st at HH:mm"]])
|
||||
|
||||
(defn create-response-pan-responder [response-height kb-height]
|
||||
(defn pan-responder [response-height kb-height orientation]
|
||||
(drag/create-pan-responder
|
||||
{:on-move (fn [_ gesture]
|
||||
(when (> (Math/abs (.-dy gesture)) 10)
|
||||
(let [to-value (- (:height (react/get-dimensions "window"))
|
||||
(let [w (react/get-dimensions "window")
|
||||
p (if (= :portrait @orientation)
|
||||
:height
|
||||
:width)
|
||||
to-value (- (p w)
|
||||
@kb-height
|
||||
(.-moveY gesture))]
|
||||
(anim/start
|
||||
|
@ -51,8 +55,9 @@
|
|||
(.-_value response-height)])))}))
|
||||
|
||||
(defn request-info [response-height]
|
||||
(let [kb-height (subscribe [:get :keyboard-height])
|
||||
pan-responder (create-response-pan-responder response-height kb-height)
|
||||
(let [orientation (subscribe [:get :orientation])
|
||||
kb-height (subscribe [:get :keyboard-height])
|
||||
pan-responder (pan-responder response-height kb-height orientation)
|
||||
command (subscribe [:get-chat-command])]
|
||||
(fn [response-height]
|
||||
[view (merge (drag/pan-handlers pan-responder)
|
||||
|
@ -73,11 +78,11 @@
|
|||
(defn container [response-height & children]
|
||||
(let [;; todo to-response-height, cur-response-height must be specific
|
||||
;; for each chat
|
||||
to-response-height (subscribe [:animations :to-response-height])
|
||||
changed (subscribe [:animations :response-height-changed])
|
||||
context {:to-value to-response-height
|
||||
:val response-height}
|
||||
on-update (container-animation-logic context)]
|
||||
to-response-height (subscribe [:animations :to-response-height])
|
||||
changed (subscribe [:animations :response-height-changed])
|
||||
context {:to-value to-response-height
|
||||
:val response-height}
|
||||
on-update (container-animation-logic context)]
|
||||
(r/create-class
|
||||
{:component-did-mount
|
||||
on-update
|
||||
|
|
|
@ -77,3 +77,4 @@
|
|||
|
||||
(def dismiss-keyboard! (u/require "dismissKeyboard"))
|
||||
(def device-event-emitter (.-DeviceEventEmitter react))
|
||||
(def orientation (u/require "react-native-orientation"))
|
||||
|
|
Loading…
Reference in New Issue