mirror of
https://github.com/status-im/status-mobile.git
synced 2025-03-01 08:40:50 +00:00
Added discover screen - part 2
This commit is contained in:
parent
376241fe38
commit
14523c6e18
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SyngIm",
|
"name": "SyngIm",
|
||||||
"interface": "reagent",
|
"interface": "reagent",
|
||||||
"androidHost": "10.0.3.2",
|
"androidHost": "10.0.2.2",
|
||||||
"modules": [
|
"modules": [
|
||||||
"react-native-contacts",
|
"react-native-contacts",
|
||||||
"react-native-invertible-scroll-view",
|
"react-native-invertible-scroll-view",
|
||||||
@ -13,7 +13,8 @@
|
|||||||
"react-native-action-button",
|
"react-native-action-button",
|
||||||
"react-native-vector-icons/Ionicons",
|
"react-native-vector-icons/Ionicons",
|
||||||
"react-native-circle-checkbox",
|
"react-native-circle-checkbox",
|
||||||
"react-native-randombytes"
|
"react-native-randombytes",
|
||||||
|
"react-native-carousel-control"
|
||||||
],
|
],
|
||||||
"imageDirs": [
|
"imageDirs": [
|
||||||
"images"
|
"images"
|
||||||
|
19
README.md
19
README.md
@ -4,7 +4,24 @@ A Clojure library designed to ... well, that part is up to you.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
FIXME
|
- install syng-lib/protocol in lein
|
||||||
|
|
||||||
|
Linux:
|
||||||
|
|
||||||
|
optional: $ npm upgrade -g re-natal
|
||||||
|
optional: $ re-natal upgrade
|
||||||
|
$ re-natal deps
|
||||||
|
$ re-natal use-android-device <real|genymotion|avd>
|
||||||
|
$ re-natal use-figwheel
|
||||||
|
$ lein figwheel android
|
||||||
|
|
||||||
|
- new terminal(only for linux)
|
||||||
|
$ react-native start
|
||||||
|
|
||||||
|
- new terminal
|
||||||
|
$ adb reverse tcp:8081 tcp:8081
|
||||||
|
$ adb reverse tcp:3449 tcp:3449
|
||||||
|
$ react-native run-android
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
2
env/dev/env/android/main.cljs
vendored
2
env/dev/env/android/main.cljs
vendored
@ -11,7 +11,7 @@
|
|||||||
(def root-el (r/as-element [reloader]))
|
(def root-el (r/as-element [reloader]))
|
||||||
|
|
||||||
(figwheel/watch-and-reload
|
(figwheel/watch-and-reload
|
||||||
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
|
:websocket-url "ws://10.0.2.2:3449/figwheel-ws"
|
||||||
:heads-up-display true
|
:heads-up-display true
|
||||||
:jsload-callback #(swap! cnt inc))
|
:jsload-callback #(swap! cnt inc))
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var CLOSURE_UNCOMPILED_DEFINES = null;
|
var CLOSURE_UNCOMPILED_DEFINES = null;
|
||||||
|
var debugEnabled = false;
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
basePath: "target/",
|
basePath: "target/",
|
||||||
@ -13,13 +14,24 @@ var config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
var WebSocket = require('WebSocket');
|
||||||
var self;
|
var self;
|
||||||
var scriptQueue = [];
|
var scriptQueue = [];
|
||||||
var serverHost = null; // will be set dynamically
|
var serverHost = null; // will be set dynamically
|
||||||
var fileBasePath = null; // will be set dynamically
|
var fileBasePath = null; // will be set dynamically
|
||||||
var evaluate = eval; // This is needed, direct calls to eval does not work (RN packager???)
|
var evaluate = eval; // This is needed, direct calls to eval does not work (RN packager???)
|
||||||
var externalModules = {};
|
var externalModules = {};
|
||||||
var evalListeners = []; // functions to be called when a script is evaluated
|
var evalListeners = [ // Functions to be called after each js file is loaded and evaluated
|
||||||
|
function (url) {
|
||||||
|
if (url.indexOf('jsloader') > -1) {
|
||||||
|
shimJsLoader();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (url) {
|
||||||
|
if (url.indexOf('/figwheel/client/socket') > -1) {
|
||||||
|
setCorrectWebSocketImpl();
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
var figwheelApp = function (platform, devHost) {
|
var figwheelApp = function (platform, devHost) {
|
||||||
return React.createClass({
|
return React.createClass({
|
||||||
@ -40,7 +52,7 @@ var figwheelApp = function (platform, devHost) {
|
|||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
var app = this;
|
var app = this;
|
||||||
if (typeof goog === "undefined") {
|
if (typeof goog === "undefined") {
|
||||||
loadApp(platform, devHost, function(appRoot) {
|
loadApp(platform, devHost, function (appRoot) {
|
||||||
app.setState({root: appRoot, loaded: true})
|
app.setState({root: appRoot, loaded: true})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -48,13 +60,19 @@ var figwheelApp = function (platform, devHost) {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function logDebug(msg) {
|
||||||
|
if (debugEnabled) {
|
||||||
|
console.log(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// evaluates js code ensuring proper ordering
|
// evaluates js code ensuring proper ordering
|
||||||
function customEval(url, javascript, success, error) {
|
function customEval(url, javascript, success, error) {
|
||||||
if (scriptQueue.length > 0) {
|
if (scriptQueue.length > 0) {
|
||||||
if (scriptQueue[0] === url) {
|
if (scriptQueue[0] === url) {
|
||||||
try {
|
try {
|
||||||
evaluate(javascript);
|
evaluate(javascript);
|
||||||
console.info('Evaluated: ' + url);
|
logDebug('Evaluated: ' + url);
|
||||||
scriptQueue.shift();
|
scriptQueue.shift();
|
||||||
evalListeners.forEach(function (listener) {
|
evalListeners.forEach(function (listener) {
|
||||||
listener(url)
|
listener(url)
|
||||||
@ -81,7 +99,7 @@ var isChrome = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function asyncImportScripts(url, success, error) {
|
function asyncImportScripts(url, success, error) {
|
||||||
console.info('(asyncImportScripts) Importing: ' + url);
|
logDebug('(asyncImportScripts) Importing: ' + url);
|
||||||
scriptQueue.push(url);
|
scriptQueue.push(url);
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
@ -100,7 +118,7 @@ function asyncImportScripts(url, success, error) {
|
|||||||
function syncImportScripts(url, success, error) {
|
function syncImportScripts(url, success, error) {
|
||||||
try {
|
try {
|
||||||
importScripts(url);
|
importScripts(url);
|
||||||
console.info('Evaluated: ' + url);
|
logDebug('Evaluated: ' + url);
|
||||||
evalListeners.forEach(function (listener) {
|
evalListeners.forEach(function (listener) {
|
||||||
listener(url)
|
listener(url)
|
||||||
});
|
});
|
||||||
@ -123,7 +141,7 @@ function importJs(src, success, error) {
|
|||||||
|
|
||||||
var file = fileBasePath + '/' + src;
|
var file = fileBasePath + '/' + src;
|
||||||
|
|
||||||
console.info('(importJs) Importing: ' + file);
|
logDebug('(importJs) Importing: ' + file);
|
||||||
if (isChrome()) {
|
if (isChrome()) {
|
||||||
syncImportScripts(serverBaseUrl("localhost") + '/' + file, success, error);
|
syncImportScripts(serverBaseUrl("localhost") + '/' + file, success, error);
|
||||||
} else {
|
} else {
|
||||||
@ -143,43 +161,49 @@ function interceptRequire() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not show debug messages in yellow box
|
function compileWarningsToYellowBox() {
|
||||||
function debugToLog() {
|
var log = window.console.log;
|
||||||
console.debug = console.log;
|
var compileWarningRx = /Figwheel: Compile/;
|
||||||
|
window.console.log = function (msg) {
|
||||||
|
if (compileWarningRx.test(msg)) {
|
||||||
|
console.warn(msg);
|
||||||
|
} else {
|
||||||
|
log.call(window.console, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function serverBaseUrl(host) {
|
function serverBaseUrl(host) {
|
||||||
return "http://" + host + ":" + config.serverPort
|
return "http://" + host + ":" + config.serverPort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCorrectWebSocketImpl() {
|
||||||
|
figwheel.client.socket.get_websocket_imp = function () {
|
||||||
|
return WebSocket;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function loadApp(platform, devHost, onLoadCb) {
|
function loadApp(platform, devHost, onLoadCb) {
|
||||||
serverHost = devHost;
|
serverHost = devHost;
|
||||||
fileBasePath = config.basePath + platform;
|
fileBasePath = config.basePath + platform;
|
||||||
|
|
||||||
evalListeners.push(function (url) {
|
|
||||||
if (url.indexOf('jsloader') > -1) {
|
|
||||||
shimJsLoader();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// callback when app is ready to get the reloadable component
|
// callback when app is ready to get the reloadable component
|
||||||
var mainJs = '/env/' + platform + '/main.js';
|
var mainJs = '/env/' + platform + '/main.js';
|
||||||
evalListeners.push(function (url) {
|
evalListeners.push(function (url) {
|
||||||
if (url.indexOf(mainJs) > -1) {
|
if (url.indexOf(mainJs) > -1) {
|
||||||
onLoadCb(env[platform].main.root_el);
|
onLoadCb(env[platform].main.root_el);
|
||||||
console.log('Done loading Clojure app');
|
console.info('Done loading Clojure app');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof goog === "undefined") {
|
if (typeof goog === "undefined") {
|
||||||
console.log('Loading Closure base.');
|
console.info('Loading Closure base.');
|
||||||
interceptRequire();
|
interceptRequire();
|
||||||
|
compileWarningsToYellowBox();
|
||||||
importJs('goog/base.js', function () {
|
importJs('goog/base.js', function () {
|
||||||
shimBaseGoog();
|
shimBaseGoog();
|
||||||
fakeLocalStorageAndDocument();
|
|
||||||
importJs('cljs_deps.js');
|
importJs('cljs_deps.js');
|
||||||
importJs('goog/deps.js', function () {
|
importJs('goog/deps.js', function () {
|
||||||
debugToLog();
|
|
||||||
// This is needed because of RN packager
|
// This is needed because of RN packager
|
||||||
// seriously React packager? why.
|
// seriously React packager? why.
|
||||||
var googreq = goog.require;
|
var googreq = goog.require;
|
||||||
@ -209,39 +233,6 @@ function shimBaseGoog() {
|
|||||||
importJs(src);
|
importJs(src);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
goog.inHtmlDocument_ = function () {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function fakeLocalStorageAndDocument() {
|
|
||||||
window.localStorage = {};
|
|
||||||
window.localStorage.getItem = function () {
|
|
||||||
return 'true';
|
|
||||||
};
|
|
||||||
window.localStorage.setItem = function () {
|
|
||||||
};
|
|
||||||
|
|
||||||
window.document = {};
|
|
||||||
window.document.body = {};
|
|
||||||
window.document.body.dispatchEvent = function () {
|
|
||||||
};
|
|
||||||
window.document.createElement = function () {
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof window.location === 'undefined') {
|
|
||||||
window.location = {};
|
|
||||||
}
|
|
||||||
console.debug = console.warn;
|
|
||||||
window.addEventListener = function () {
|
|
||||||
};
|
|
||||||
// make figwheel think that heads-up-display divs are there
|
|
||||||
window.document.querySelector = function (selector) {
|
|
||||||
return {};
|
|
||||||
};
|
|
||||||
window.document.getElementById = function (id) {
|
|
||||||
return {style:{}};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figwheel fixes
|
// Figwheel fixes
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"awesome-phonenumber": "^1.0.12",
|
"awesome-phonenumber": "^1.0.12",
|
||||||
"react-native": "^0.22.0",
|
"react-native": "^0.22.0",
|
||||||
"react-native-action-button": "^1.1.3",
|
"react-native-action-button": "^1.1.3",
|
||||||
|
"react-native-carousel-control": "^1.0.1",
|
||||||
"react-native-circle-checkbox": "^0.1.3",
|
"react-native-circle-checkbox": "^0.1.3",
|
||||||
"react-native-contacts": "^0.2.1",
|
"react-native-contacts": "^0.2.1",
|
||||||
"react-native-i18n": "0.0.8",
|
"react-native-i18n": "0.0.8",
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
[syng-im.subs]
|
[syng-im.subs]
|
||||||
[syng-im.components.react :refer [navigator app-registry]]
|
[syng-im.components.react :refer [navigator app-registry]]
|
||||||
[syng-im.components.contact-list.contact-list :refer [contact-list]]
|
[syng-im.components.contact-list.contact-list :refer [contact-list]]
|
||||||
|
[syng-im.components.discovery.discovery :refer [discovery]]
|
||||||
[syng-im.components.chat :refer [chat]]
|
[syng-im.components.chat :refer [chat]]
|
||||||
[syng-im.components.sign-up :refer [sign-up-view]]
|
[syng-im.components.sign-up :refer [sign-up-view]]
|
||||||
[syng-im.components.sign-up-confirm :refer [sign-up-confirm-view]]
|
[syng-im.components.sign-up-confirm :refer [sign-up-confirm-view]]
|
||||||
@ -34,7 +35,7 @@
|
|||||||
(add-event-listener "hardwareBackPress" new-listener)))))
|
(add-event-listener "hardwareBackPress" new-listener)))))
|
||||||
|
|
||||||
(defn app-root []
|
(defn app-root []
|
||||||
[navigator {:initial-route (clj->js {:view-id :chat-list})
|
[navigator {:initial-route (clj->js {:view-id :discovery})
|
||||||
:render-scene (fn [route nav]
|
:render-scene (fn [route nav]
|
||||||
(log/debug "route" route)
|
(log/debug "route" route)
|
||||||
(when true ;; nav/*nav-render*
|
(when true ;; nav/*nav-render*
|
||||||
@ -42,6 +43,7 @@
|
|||||||
view-id (keyword view-id)]
|
view-id (keyword view-id)]
|
||||||
(init-back-button-handler! nav)
|
(init-back-button-handler! nav)
|
||||||
(case view-id
|
(case view-id
|
||||||
|
:discovery (r/as-element [discovery {:navigator nav}])
|
||||||
:chat-list (r/as-element [chats-list {:navigator nav}])
|
:chat-list (r/as-element [chats-list {:navigator nav}])
|
||||||
:new-group (r/as-element [new-group {:navigator nav}])
|
:new-group (r/as-element [new-group {:navigator nav}])
|
||||||
:contact-list (r/as-element [contact-list {:navigator nav}])
|
:contact-list (r/as-element [contact-list {:navigator nav}])
|
||||||
@ -51,6 +53,7 @@
|
|||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(dispatch-sync [:initialize-db])
|
(dispatch-sync [:initialize-db])
|
||||||
|
;;(dispatch-sync [:generate-discoveries])
|
||||||
(dispatch [:initialize-crypt])
|
(dispatch [:initialize-crypt])
|
||||||
(dispatch [:initialize-protocol])
|
(dispatch [:initialize-protocol])
|
||||||
(dispatch [:load-user-phone-number])
|
(dispatch [:load-user-phone-number])
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
(def toolbar-android (r/adapt-react-class (.-ToolbarAndroid js/React)))
|
(def toolbar-android (r/adapt-react-class (.-ToolbarAndroid js/React)))
|
||||||
(def list-view (r/adapt-react-class (.-ListView js/React)))
|
(def list-view (r/adapt-react-class (.-ListView js/React)))
|
||||||
(def text-input (r/adapt-react-class (.-TextInput js/React)))
|
(def text-input (r/adapt-react-class (.-TextInput js/React)))
|
||||||
|
(def scroll-view (r/adapt-react-class (.-ScrollView js/React)))
|
||||||
|
|
||||||
(def platform (.. js/React -Platform -OS))
|
(def platform (.. js/React -Platform -OS))
|
||||||
|
|
||||||
|
@ -28,3 +28,6 @@
|
|||||||
(defn chat-command-content-path [chat-id]
|
(defn chat-command-content-path [chat-id]
|
||||||
[:chats chat-id :command-input :content])
|
[:chats chat-id :command-input :content])
|
||||||
(def new-group-path [:new-group])
|
(def new-group-path [:new-group])
|
||||||
|
(def updated-discovery-signal-path [:discovery-updated-signal])
|
||||||
|
(defn updated-discovery-signal-path [discovery-id]
|
||||||
|
[:discoveries discovery-id :discovery-updated-signal])
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
set-initialized]]
|
set-initialized]]
|
||||||
[syng-im.models.user-data :as user-data]
|
[syng-im.models.user-data :as user-data]
|
||||||
[syng-im.models.contacts :as contacts]
|
[syng-im.models.contacts :as contacts]
|
||||||
|
[syng-im.models.discoveries :as discoveries]
|
||||||
[syng-im.models.messages :refer [save-message
|
[syng-im.models.messages :refer [save-message
|
||||||
update-message!
|
update-message!
|
||||||
message-by-id]]
|
message-by-id]]
|
||||||
@ -274,6 +275,12 @@
|
|||||||
(log/debug action from group-id identities)
|
(log/debug action from group-id identities)
|
||||||
(create-chat db group-id identities true group-name)))
|
(create-chat db group-id identities true group-name)))
|
||||||
|
|
||||||
|
;; -- Discovery --------------------------------------------------------------
|
||||||
|
|
||||||
|
(register-handler :generate-discoveries
|
||||||
|
(fn [db _]
|
||||||
|
(discoveries/save-discoveries (discoveries/generate-discoveries 10))))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,24 @@
|
|||||||
:group-chat "bool"
|
:group-chat "bool"
|
||||||
:timestamp "int"
|
:timestamp "int"
|
||||||
:contacts {:type "list"
|
:contacts {:type "list"
|
||||||
:objectType "chat-contact"}}}]})
|
:objectType "chat-contact"}}}
|
||||||
|
{:name :tag
|
||||||
|
:primaryKey :name
|
||||||
|
:properties {:name "string"
|
||||||
|
:count {:type "int"
|
||||||
|
:optional true
|
||||||
|
:default 1}}}
|
||||||
|
{:name :discoveries
|
||||||
|
:primaryKey :whisper-id
|
||||||
|
:properties {:name "string"
|
||||||
|
:status "string"
|
||||||
|
:whisper-id "string"
|
||||||
|
:photo "string"
|
||||||
|
:tags {:type "list"
|
||||||
|
:objectType "tag"}
|
||||||
|
:last-updated "date"}}
|
||||||
|
|
||||||
|
]})
|
||||||
|
|
||||||
|
|
||||||
(def realm (js/Realm. (clj->js opts)))
|
(def realm (js/Realm. (clj->js opts)))
|
||||||
@ -122,7 +139,7 @@
|
|||||||
(.-length objs))
|
(.-length objs))
|
||||||
|
|
||||||
(defn get-list [schema-name]
|
(defn get-list [schema-name]
|
||||||
(vals (js->clj (.objects realm (to-string schema-name)) :keywordize-keys true)))
|
(vals (js->clj (.slice (.objects realm (to-string schema-name)) 0) :keywordize-keys true)))
|
||||||
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
@ -13,3 +13,5 @@
|
|||||||
(def smile (js/require "./images/smile.png"))
|
(def smile (js/require "./images/smile.png"))
|
||||||
(def att (js/require "./images/att.png"))
|
(def att (js/require "./images/att.png"))
|
||||||
(def v (js/require "./images/v.png"))
|
(def v (js/require "./images/v.png"))
|
||||||
|
(def menu (js/require "./images/ic_menu_black_24dp_1x.png"))
|
||||||
|
(def search (js.require "./images/ic_search_black_24dp_1x.png"))
|
@ -7,6 +7,8 @@
|
|||||||
[syng-im.models.chats :refer [chats-list
|
[syng-im.models.chats :refer [chats-list
|
||||||
chats-updated?
|
chats-updated?
|
||||||
chat-by-id]]
|
chat-by-id]]
|
||||||
|
[syng-im.models.discoveries :refer [discovery-list
|
||||||
|
discovery-updated?]]
|
||||||
[syng-im.models.messages :refer [get-messages]]
|
[syng-im.models.messages :refer [get-messages]]
|
||||||
[syng-im.models.contacts :refer [contacts-list]]
|
[syng-im.models.contacts :refer [contacts-list]]
|
||||||
[syng-im.handlers.suggestions :refer [get-suggestions]]))
|
[syng-im.handlers.suggestions :refer [get-suggestions]]))
|
||||||
@ -63,6 +65,16 @@
|
|||||||
(chat-by-id chat-id))
|
(chat-by-id chat-id))
|
||||||
(reaction)))))
|
(reaction)))))
|
||||||
|
|
||||||
|
;; -- Discoveries list --------------------------------------------------------------
|
||||||
|
|
||||||
|
(register-sub :get-discoveries
|
||||||
|
(fn [db _]
|
||||||
|
(let [discovery-updated (-> (discovery-updated? @db)
|
||||||
|
(reaction))]
|
||||||
|
(reaction
|
||||||
|
(let [_ @discovery-updated]
|
||||||
|
(discovery-list))))))
|
||||||
|
|
||||||
;; -- User data --------------------------------------------------------------
|
;; -- User data --------------------------------------------------------------
|
||||||
|
|
||||||
(register-sub
|
(register-sub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user