parent
0af746b06b
commit
d3b48f156c
|
@ -32,7 +32,8 @@
|
|||
(add-event-listener "hardwareBackPress" new-listener)))))
|
||||
|
||||
(defn app-root []
|
||||
[navigator {:initial-route (clj->js {:view-id :chat-list})
|
||||
[navigator {:initial-route (clj->js {:view-id ;:chat-list
|
||||
:chat})
|
||||
:render-scene (fn [route nav]
|
||||
(log/debug "route" route)
|
||||
(when true ;; nav/*nav-render*
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
(ns syng-im.components.chat.suggestions
|
||||
(:require-macros
|
||||
[natal-shell.core :refer [with-error-view]])
|
||||
(:require [clojure.string :as cstr]
|
||||
[reagent.core :as r]
|
||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.components.react :refer [view
|
||||
image
|
||||
text
|
||||
list-view
|
||||
list-item]]
|
||||
[syng-im.utils.listview :refer [to-datasource]]
|
||||
[syng-im.utils.utils :refer [log toast http-post]]
|
||||
[syng-im.utils.logging :as log]))
|
||||
|
||||
(defn suggestion-list-item [suggestion]
|
||||
[view {:style {:flexDirection "row"
|
||||
:marginVertical 5
|
||||
:marginHorizontal 10
|
||||
:height 20
|
||||
;; :backgroundColor "white"
|
||||
}}
|
||||
[text {:underlineColorAndroid "#9CBFC0"
|
||||
:style {:flex 1
|
||||
:marginLeft 18
|
||||
:lineHeight 18
|
||||
:fontSize 14
|
||||
:fontFamily "Avenir-Roman"
|
||||
:color "#9CBFC0"}}
|
||||
(:text suggestion)]])
|
||||
|
||||
(defn render-row [row section-id row-id]
|
||||
(list-item [suggestion-list-item (js->clj row :keywordize-keys true)]))
|
||||
|
||||
(defn suggestions-view []
|
||||
(let [suggestions (subscribe [:get-suggestions])]
|
||||
(fn []
|
||||
(when @suggestions
|
||||
[view {:style {:flexDirection "row"
|
||||
:marginVertical 5
|
||||
:marginHorizontal 10
|
||||
:height 120
|
||||
:backgroundColor "#E5F5F6"
|
||||
:borderRadius 5}}
|
||||
[list-view {:dataSource (to-datasource @suggestions)
|
||||
:renderRow render-row
|
||||
:style {}}]]))))
|
|
@ -4,6 +4,7 @@
|
|||
view
|
||||
image
|
||||
text-input]]
|
||||
[syng-im.components.chat.suggestions :refer [suggestions-view]]
|
||||
[syng-im.utils.logging :as log]
|
||||
[syng-im.resources :as res]
|
||||
[reagent.core :as r]))
|
||||
|
@ -13,6 +14,7 @@
|
|||
(let [text (r/atom nil)
|
||||
chat-id (subscribe [:get-current-chat-id])]
|
||||
(fn []
|
||||
[view {:style {:flexDirection "column"}}
|
||||
[view {:style {:flexDirection "row"
|
||||
:margin 10
|
||||
:height 40
|
||||
|
@ -34,6 +36,7 @@
|
|||
:placeholder "Enter your message here"
|
||||
:value @text
|
||||
:onChangeText (fn [new-text]
|
||||
(dispatch [:generate-suggestions new-text])
|
||||
(reset! text new-text)
|
||||
(r/flush))
|
||||
:onSubmitEditing (fn [e]
|
||||
|
@ -48,4 +51,5 @@
|
|||
:style {:marginTop 14
|
||||
:marginRight 16
|
||||
:width 17
|
||||
:height 14}}]])))
|
||||
:height 14}}]]
|
||||
[suggestions-view]])))
|
||||
|
|
|
@ -8,11 +8,7 @@
|
|||
list-item]]
|
||||
[syng-im.components.resources :as res]
|
||||
[syng-im.components.contact-list.contact :refer [contact-view]]
|
||||
[syng-im.utils.logging :as log]
|
||||
;; [messenger.comm.intercom :as intercom]
|
||||
;; [messenger.components.contact-list.contact :refer [contact]]
|
||||
;; [messenger.components.iname :as in]
|
||||
))
|
||||
[syng-im.utils.logging :as log]))
|
||||
|
||||
(defn render-row [navigator row section-id row-id]
|
||||
(list-item [contact-view {:navigator navigator
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(def ethereum-rpc-url "http://localhost:8545")
|
||||
|
||||
;; (def server-address "http://rpc0.syng.im:20000/")
|
||||
(def server-address "http://10.0.3.2:3000/")
|
||||
(def server-address "http://rpc0.syng.im:20000/")
|
||||
;; (def server-address "http://10.0.3.2:3000/")
|
||||
|
||||
(def text-content-type "text/plain")
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
(def app-db {:greeting "Hello Clojure in iOS and Android!"
|
||||
:identity-password "replace-me-with-user-entered-password"
|
||||
:contacts []
|
||||
:chat {:current-chat-id "0x0479a5ed1f38cadfad1db6cd56c4b659b0ebe052bbe9efa950f6660058519fa4ca6be2dda66afa80de96ab00eb97a2605d5267a1e8f4c2a166ab551f6826608cdd"}
|
||||
:chat {:current-chat-id "0x0479a5ed1f38cadfad1db6cd56c4b659b0ebe052bbe9efa950f6660058519fa4ca6be2dda66afa80de96ab00eb97a2605d5267a1e8f4c2a166ab551f6826608cdd"
|
||||
:suggestions []}
|
||||
:chats {}
|
||||
:chats-updated-signal 0})
|
||||
|
||||
|
@ -16,6 +17,7 @@
|
|||
(def protocol-initialized-path [:protocol-initialized])
|
||||
(def identity-password-path [:identity-password])
|
||||
(def current-chat-id-path [:chat :current-chat-id])
|
||||
(def input-suggestions-path [:chat :suggestions])
|
||||
(def updated-chats-signal-path [:chats-updated-signal])
|
||||
(defn updated-chat-signal-path [chat-id]
|
||||
[:chats chat-id :chat-updated-signal])
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
message-by-id]]
|
||||
[syng-im.handlers.server :as server]
|
||||
[syng-im.handlers.contacts :as contacts-service]
|
||||
[syng-im.handlers.suggestions :as suggestions-service]
|
||||
|
||||
[syng-im.models.chats :refer [create-chat]]
|
||||
[syng-im.models.chat :refer [signal-chat-updated
|
||||
|
@ -143,3 +144,9 @@
|
|||
(log/debug action "chat-id" chat-id)
|
||||
(nav-push navigator {:view-id :chat})
|
||||
(set-current-chat-id db chat-id)))
|
||||
|
||||
;; -- Chat --------------------------------------------------------------
|
||||
|
||||
(register-handler :generate-suggestions
|
||||
(fn [db [_ text]]
|
||||
(suggestions-service/generate-suggestions db text)))
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
(ns syng-im.handlers.suggestions
|
||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.db :as db]
|
||||
[syng-im.utils.utils :refer [log on-error http-post]]
|
||||
[syng-im.utils.logging :as log]))
|
||||
|
||||
(def commands [{:text "!phone"}
|
||||
{:text "!send"}
|
||||
{:text "!request"}
|
||||
{:text "!help"}])
|
||||
|
||||
(defn get-suggestions [text]
|
||||
(when (= (get text 0) "!")
|
||||
(filterv #(.startsWith (:text %) text) commands)))
|
||||
|
||||
(defn generate-suggestions [db text]
|
||||
(assoc-in db db/input-suggestions-path (get-suggestions text)))
|
|
@ -1,6 +1,7 @@
|
|||
(ns syng-im.subs
|
||||
(:require-macros [reagent.ratom :refer [reaction]])
|
||||
(:require [re-frame.core :refer [register-sub]]
|
||||
[syng-im.db :as db]
|
||||
[syng-im.models.chat :refer [current-chat-id
|
||||
chat-updated?]]
|
||||
[syng-im.models.chats :refer [chats-list
|
||||
|
@ -24,6 +25,10 @@
|
|||
(-> (current-chat-id @db)
|
||||
(reaction))))
|
||||
|
||||
(register-sub :get-suggestions
|
||||
(fn [db _]
|
||||
(reaction (get-in @db db/input-suggestions-path))))
|
||||
|
||||
;; -- Chats list --------------------------------------------------------------
|
||||
|
||||
(register-sub :get-chats
|
||||
|
|
Loading…
Reference in New Issue