Skip to content

Commit

Permalink
Desktop works with react-navigation v3
Browse files Browse the repository at this point in the history
  • Loading branch information
vkjr committed Aug 9, 2019
1 parent e64777f commit e242b4d
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .env
Expand Up @@ -19,5 +19,5 @@ SNOOPY=0
RPC_NETWORKS_ONLY=0
PARTITIONED_TOPIC=0
CONTRACT_NODES=1
MOBILE_UI_FOR_DESKTOP=0
MOBILE_UI_FOR_DESKTOP=1
STATUS_GO_PROTOCOL=0
1 change: 1 addition & 0 deletions clj-rn.conf.edn
Expand Up @@ -84,6 +84,7 @@
"react-native-desktop-config"
"react-native-desktop-shortcuts"
"react-native-desktop-notification"
"react-native-desktop-gesture-handler"
"text-encoding"
"js-sha3"
"web3-utils"
Expand Down
6 changes: 4 additions & 2 deletions desktop_files/package.json.orig
Expand Up @@ -20,6 +20,7 @@
"modules/react-native-desktop-config/desktop",
"modules/react-native-desktop-shortcuts/desktop",
"modules/react-native-desktop-notification/desktop",
"modules/react-native-desktop-gesture-handler/desktop",
"node_modules/google-breakpad"
],
"desktopFonts": [
Expand Down Expand Up @@ -68,14 +69,15 @@
"querystring-es3": "0.2.1",
"react": "16.6.1",
"react-dom": "16.4.2",
"react-native": "git+https://github.com/status-im/react-native-desktop.git#v0.57.8_10",
"react-native": "git+https://github.com/status-im/react-native-desktop.git#master",
"react-native-background-timer": "2.0.0",
"react-native-camera": "0.10.0",
"react-native-config": "git+https://github.com/status-im/react-native-config.git#v0.11.2-status",
"react-native-crypto": "2.1.1",
"react-native-dialogs": "0.0.20",
"react-native-fetch-polyfill": "1.1.2",
"react-native-fs": "git+https://github.com/status-im/react-native-fs.git#v2.9.7-status",
"react-native-gesture-handler": "^1.3.0",
"react-native-http": "git+https://github.com/tradle/react-native-http.git#834492d",
"react-native-http-bridge": "0.6.1",
"react-native-image-crop-picker": "0.18.1",
Expand All @@ -92,7 +94,7 @@
"react-native-udp": "2.2.1",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-status-rn049-desktop",
"react-native-navigation-twopane": "git+https://github.com/status-im/react-native-navigation-twopane.git#v0.0.2-status",
"react-navigation": "^2.12.1",
"react-navigation": "^3.11.0",
"realm": "git+https://github.com/status-im/realm-js.git#v2.20.1",
"rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status",
"status-conan": "git+https://github.com/status-im/status-conan.git#v1.0.0",
Expand Down
203 changes: 96 additions & 107 deletions desktop_files/yarn.lock

Large diffs are not rendered by default.

@@ -0,0 +1,9 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_TYPE_NAMES ${REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_TYPE_NAMES}
\"GestureHandlerModule\" PARENT_SCOPE)

set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC ${REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/gesturehandlermodule.cpp PARENT_SCOPE)

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2017-present, Status Research and Development GmbH.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/

#include "gesturehandlermodule.h"
#include "bridge.h"
#include "eventdispatcher.h"

#include <QGuiApplication>
#include <QQuickItem>
#include <QScreen>

namespace {
struct RegisterQMLMetaType {
RegisterQMLMetaType() { qRegisterMetaType<GestureHandlerModule *>(); }
} registerMetaType;
} // namespace


class GestureHandlerModulePrivate {
public:
Bridge* bridge = nullptr;
};

GestureHandlerModule::GestureHandlerModule(QObject* parent) : QObject(parent), d_ptr(new GestureHandlerModulePrivate) {}

GestureHandlerModule::~GestureHandlerModule() {}

void GestureHandlerModule::setBridge(Bridge* bridge) {
Q_D(GestureHandlerModule);
d->bridge = bridge;
}

QString GestureHandlerModule::moduleName() {
return "RNGestureHandlerModule";
}

QList<ModuleMethod*> GestureHandlerModule::methodsToExport() {
return QList<ModuleMethod*>{};
}

QVariantMap GestureHandlerModule::constantsToExport() {
Q_D(GestureHandlerModule);

QVariantMap directionValues{{"RIGHT", 1}, {"LEFT", 2}, {"UP", 4}, {"DOWN", 8}};

// QRect screenGeometry = screen->geometry();
// QVariantMap screenValues{{"fontScale", 8},
// {"width", screenGeometry.width()},
// {"height", screenGeometry.height()},
// {"scale", screen->devicePixelRatio()}};

// QVariantMap values{{"screen", screenValues}, {"window", windowValues}};

return QVariantMap{{"Direction", directionValues}};
}

void GestureHandlerModule::handleSetJSResponder(int viewTag, void* blockNativeResponder) {}

void GestureHandlerModule::handleClearJSResponder() {}

void GestureHandlerModule::createGestureHandler(const QString& handlerName, int handlerTag, void* config) {}
void GestureHandlerModule::attachGestureHandler(int handlerTag, int viewTag) {}
void GestureHandlerModule::updateGestureHandler(int handlerTag, void* config) {}
void GestureHandlerModule::dropGestureHandler(int handlerTag) {}
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2017-present, Status Research and Development GmbH.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/

#ifndef GESTUREHANDLER_H
#define GESTUREHANDLER_H

#include "moduleinterface.h"

#include <QVariantMap>

class GestureHandlerModulePrivate;
class GestureHandlerModule : public QObject, public ModuleInterface {
Q_OBJECT
Q_INTERFACES(ModuleInterface)

Q_DECLARE_PRIVATE(GestureHandlerModule)

public:
Q_INVOKABLE GestureHandlerModule(QObject* parent = 0);
~GestureHandlerModule();

void setBridge(Bridge* bridge) override;

QString moduleName() override;
QList<ModuleMethod*> methodsToExport() override;
QVariantMap constantsToExport() override;

Q_INVOKABLE void handleSetJSResponder(int viewTag, void* blockNativeResponder);
Q_INVOKABLE void handleClearJSResponder();
Q_INVOKABLE void createGestureHandler(const QString& handlerName, int handlerTag, void* config);
Q_INVOKABLE void attachGestureHandler(int handlerTag, int viewTag);
Q_INVOKABLE void updateGestureHandler(int handlerTag, void* config);
Q_INVOKABLE void dropGestureHandler(int handlerTag);


private:
QScopedPointer<GestureHandlerModulePrivate> d_ptr;
};

#endif // GESTUREHANDLER_H
5 changes: 5 additions & 0 deletions modules/react-native-desktop-gesture-handler/index.js
@@ -0,0 +1,5 @@
'use strict';

var RNGestureHandlerModule = require('react-native').NativeModules.RNGestureHandlerModule;

module.exports = RNGestureHandlerModule;
13 changes: 13 additions & 0 deletions modules/react-native-desktop-gesture-handler/package.json
@@ -0,0 +1,13 @@
{
"private": true,
"nativePackage": true,
"name": "react-native-desktop-gesture-handler",
"version": "1.0.0",
"description": "Mock for react-native-gesture-handler package",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": ""
}
Expand Up @@ -34,6 +34,7 @@
(def snoopy-filter (fn [] #js {}))
(def snoopy-bars (fn [] #js {}))
(def snoopy-buffer (fn [] #js {}))
(def react-native-screens (fn [] #js {}))
(def background-timer (fn [] #js {:setTimeout (fn [cb ms] (js/setTimeout cb ms))}))
(def react-navigation (js/require "react-navigation"))
(def react-native-navigation-twopane (js/require "react-native-navigation-twopane"))
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-desktop.sh
Expand Up @@ -27,6 +27,7 @@ external_modules_dir=( \
'node_modules/google-breakpad' \
'modules/react-native-desktop-linking/desktop' \
'modules/react-native-desktop-menu/desktop' \
'modules/react-native-desktop-gesture-handler' \
'modules/react-native-desktop-config/desktop' \
'modules/react-native-desktop-shortcuts/desktop' \
'modules/react-native-desktop-notification/desktop' \
Expand Down Expand Up @@ -354,7 +355,7 @@ if is_macos; then
local exeDir="$contentsDir/MacOS"

[ $VERBOSE_LEVEL -ge 1 ] && echo "Checking rpaths in ${dylib}"

# Walk through the dependencies of $dylib
local dependencies=$(otool -L "$dylib" | grep -E "\s+/nix/" | sed "s|@executable_path|$exeDir|" | awk -F "(" '{print $1}' | xargs)
local moduleDirPath=$(dirname $dylib)
Expand Down
38 changes: 24 additions & 14 deletions src/status_im/ui/components/bottom_bar/core.cljs
Expand Up @@ -69,9 +69,10 @@
(when (pos? (if count @count 0))
[react/view tabs.styles/counter
[components.common/counter @count]])]
[react/view {:style tabs.styles/tab-title-container}
[react/text {:style (tabs.styles/new-tab-title active?)}
label]]]]))
(when-not platform/desktop?
[react/view {:style tabs.styles/tab-title-container}
[react/text {:style (tabs.styles/new-tab-title active?)}
label]])]]))

(defn tabs [current-view-id]
[react/view
Expand Down Expand Up @@ -132,17 +133,26 @@
(when-not (contains? #{:enter-pin-login
:enter-pin-sign
:enter-pin-settings} view-id)
(if platform/ios?
[tabs-animation-wrapper-ios
[react/animated-view
{:style (tabs.styles/animated-container visible? keyboard-shown?)}
[tabs tab]]]
[tabs-animation-wrapper-android
keyboard-shown?
view-id
[react/animated-view
{:style (tabs.styles/animated-container visible? keyboard-shown?)}
[tabs tab]]])))}))
(case platform/os
"ios" [tabs-animation-wrapper-ios
[react/animated-view
{:style (tabs.styles/animated-container visible? keyboard-shown?)}
[tabs tab]]]
"android" [tabs-animation-wrapper-android
keyboard-shown?
view-id
[react/animated-view
{:style (tabs.styles/animated-container visible? keyboard-shown?)}
[tabs tab]]]
"desktop"
;[tabs-animation-wrapper-android
; keyboard-shown?
; view-id
; [react/animated-view
; {:style (tabs.styles/animated-container visible? keyboard-shown?)}
[tabs tab]
;]]
)))}))

(def disappearance-duration 150)
(def appearance-duration 100)
Expand Down
10 changes: 8 additions & 2 deletions src/status_im/ui/components/bottom_bar/styles.cljs
Expand Up @@ -8,7 +8,7 @@
(cond
platform/android? 52
platform/ios? 52
platform/desktop? 68))
platform/desktop? 36))

(def minimized-tabs-height 36)

Expand Down Expand Up @@ -86,7 +86,13 @@
:shadow-radius 4
:shadow-offset {:width 0 :height -5}
:shadow-opacity 0.3
:shadow-color "rgba(0, 9, 26, 0.12)"}})
:shadow-color "rgba(0, 9, 26, 0.12)"}
:desktop {:background-color :white
:shadow-radius 4
:shadow-offset {:width 0 :height -5}
:shadow-opacity 0.3
:shadow-color "rgba(0, 9, 26, 0.12)"}
})

(def tabs
{:height tabs-height
Expand Down
1 change: 0 additions & 1 deletion src/status_im/ui/screens/chat/input/input.cljs
Expand Up @@ -89,7 +89,6 @@
:auto-capitalize :sentences}
(when cooldown-enabled?
{:placeholder (i18n/label :cooldown/text-input-disabled)}))]))
;)

(defview invisible-input [{:keys [set-layout-width-fn value]}]
(letsubs [{:keys [input-text]} [:chats/current-chat]]
Expand Down
3 changes: 3 additions & 0 deletions src/status_im/ui/screens/chat/styles/main.cljs
Expand Up @@ -296,6 +296,9 @@
{:color colors/blue
:margin-bottom 40})

(def select-chat
{:color colors/gray})

(def messages-list-vertical-padding 46)

(def are-you-friends-bubble
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/chat/views.cljs
Expand Up @@ -469,5 +469,5 @@

(defview select-chat []
[react/view {:style {:align-items :center :justify-content :center :flex 1}}
[react/text {:style style/decline-chat}
[react/text {:style style/select-chat}
(i18n/label :t/select-chat)]])
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/home/views.cljs
Expand Up @@ -134,7 +134,7 @@
window-width)]
[react/view (merge {:flex 1 :width home-width}
(when two-pane-ui-enabled?
{:border-right-width 1 :border-right-color colors/gray-light}))
{:border-right-width 1 :border-right-color colors/gray-lighter}))
[status-bar/status-bar {:type :main}]
[react/keyboard-avoiding-view {:style {:flex 1
:align-items :center}
Expand Down

0 comments on commit e242b4d

Please sign in to comment.