parent
2704529dee
commit
15f1a547a1
|
@ -1,5 +1,6 @@
|
||||||
(ns syng-im.components.chat.chat-message-new
|
(ns syng-im.components.chat.chat-message-new
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require
|
||||||
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
view
|
view
|
||||||
image
|
image
|
||||||
|
@ -7,77 +8,20 @@
|
||||||
text-input
|
text-input
|
||||||
touchable-highlight]]
|
touchable-highlight]]
|
||||||
[syng-im.components.chat.plain-message-input :refer [plain-message-input-view]]
|
[syng-im.components.chat.plain-message-input :refer [plain-message-input-view]]
|
||||||
|
[syng-im.components.chat.simple-command-input :refer [simple-command-input-view]]
|
||||||
[syng-im.components.chat.phone-input :refer [phone-input-view]]
|
[syng-im.components.chat.phone-input :refer [phone-input-view]]
|
||||||
[syng-im.utils.utils :refer [log toast http-post]]
|
[syng-im.utils.utils :refer [log toast http-post]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.resources :as res]
|
[syng-im.resources :as res]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(defn cancel-command-input []
|
(defn default-command-input-view [command]
|
||||||
(dispatch [:set-input-command nil]))
|
[simple-command-input-view command "default"])
|
||||||
|
|
||||||
(defn default-command-input-view []
|
|
||||||
(let [message-atom (r/atom nil)
|
|
||||||
chat-id (subscribe [:get-current-chat-id])]
|
|
||||||
(fn []
|
|
||||||
(let [message @message-atom]
|
|
||||||
[view {:style {:flexDirection "row"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:backgroundColor "white"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:margin 10
|
|
||||||
:width 200
|
|
||||||
:backgroundColor "#E5F5F6"
|
|
||||||
:borderRadius 10}}
|
|
||||||
[view {:style {:flexDirection "row"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:margin 10
|
|
||||||
:backgroundColor "blue"
|
|
||||||
:borderRadius 10}}
|
|
||||||
[text {:style {:marginVertical 3
|
|
||||||
:marginHorizontal 10
|
|
||||||
:fontSize 14
|
|
||||||
:fontFamily "Avenir-Roman"
|
|
||||||
:color "white"}}
|
|
||||||
"!<command>"]]
|
|
||||||
[touchable-highlight {:style {:marginTop 14
|
|
||||||
:marginRight 16
|
|
||||||
:position "absolute"
|
|
||||||
:top 3
|
|
||||||
:right 20}
|
|
||||||
:onPress (fn []
|
|
||||||
(cancel-command-input))}
|
|
||||||
[image {:source res/att
|
|
||||||
:style {:width 17
|
|
||||||
:height 14}}]]]
|
|
||||||
[text-input {:style {:flex 1
|
|
||||||
:marginLeft 8
|
|
||||||
:lineHeight 42
|
|
||||||
:fontSize 14
|
|
||||||
:fontFamily "Avenir-Roman"
|
|
||||||
:color "#9CBFC0"}
|
|
||||||
:underlineColorAndroid "transparent"
|
|
||||||
:autoFocus true
|
|
||||||
:value message
|
|
||||||
:onChangeText (fn [new-text]
|
|
||||||
)
|
|
||||||
:onSubmitEditing (fn [e]
|
|
||||||
)}]]]
|
|
||||||
[touchable-highlight {:style {:marginTop 14
|
|
||||||
:marginRight 16
|
|
||||||
:position "absolute"
|
|
||||||
:right 20
|
|
||||||
:bottom 20}
|
|
||||||
:onPress (fn []
|
|
||||||
(cancel-command-input))}
|
|
||||||
[image {:source res/att
|
|
||||||
:style {:width 34
|
|
||||||
:height 28}}]]]))))
|
|
||||||
|
|
||||||
(defn special-input-view [command]
|
(defn special-input-view [command]
|
||||||
(case command
|
(case (:command command)
|
||||||
:phone [phone-input-view]
|
:phone [phone-input-view command]
|
||||||
[default-command-input-view]))
|
[default-command-input-view command]))
|
||||||
|
|
||||||
(defn chat-message-new []
|
(defn chat-message-new []
|
||||||
(let [input-command-atom (subscribe [:get-input-command])]
|
(let [input-command-atom (subscribe [:get-input-command])]
|
||||||
|
|
|
@ -1,74 +1,9 @@
|
||||||
(ns syng-im.components.chat.phone-input
|
(ns syng-im.components.chat.phone-input
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require
|
||||||
[syng-im.components.react :refer [android?
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
view
|
[syng-im.components.chat.simple-command-input :refer [simple-command-input-view]]
|
||||||
image
|
|
||||||
text
|
|
||||||
text-input
|
|
||||||
touchable-highlight]]
|
|
||||||
[syng-im.utils.utils :refer [log toast http-post]]
|
[syng-im.utils.utils :refer [log toast http-post]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]))
|
||||||
[syng-im.resources :as res]
|
|
||||||
[reagent.core :as r]))
|
|
||||||
|
|
||||||
(defn cancel-command-input []
|
(defn phone-input-view [command]
|
||||||
(dispatch [:set-input-command nil]))
|
[simple-command-input-view command "phone-pad"])
|
||||||
|
|
||||||
(defn phone-input-view []
|
|
||||||
(let [message-atom (r/atom nil)
|
|
||||||
chat-id (subscribe [:get-current-chat-id])]
|
|
||||||
(fn []
|
|
||||||
(let [message @message-atom]
|
|
||||||
[view {:style {:flexDirection "row"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:backgroundColor "white"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:margin 10
|
|
||||||
:width 200
|
|
||||||
:backgroundColor "#E5F5F6"
|
|
||||||
:borderRadius 10}}
|
|
||||||
[view {:style {:flexDirection "row"}}
|
|
||||||
[view {:style {:flexDirection "column"
|
|
||||||
:margin 10
|
|
||||||
:backgroundColor "blue"
|
|
||||||
:borderRadius 10}}
|
|
||||||
[text {:style {:marginVertical 3
|
|
||||||
:marginHorizontal 10
|
|
||||||
:fontSize 14
|
|
||||||
:fontFamily "Avenir-Roman"
|
|
||||||
:color "white"}}
|
|
||||||
"!phone"]]
|
|
||||||
[touchable-highlight {:style {:marginTop 14
|
|
||||||
:marginRight 16
|
|
||||||
:position "absolute"
|
|
||||||
:top 3
|
|
||||||
:right 20}
|
|
||||||
:onPress (fn []
|
|
||||||
(cancel-command-input))}
|
|
||||||
[image {:source res/att
|
|
||||||
:style {:width 17
|
|
||||||
:height 14}}]]]
|
|
||||||
[text-input {:style {:flex 1
|
|
||||||
:marginLeft 8
|
|
||||||
:lineHeight 42
|
|
||||||
:fontSize 14
|
|
||||||
:fontFamily "Avenir-Roman"
|
|
||||||
:color "#9CBFC0"}
|
|
||||||
:underlineColorAndroid "transparent"
|
|
||||||
:autoFocus true
|
|
||||||
:keyboardType "phone-pad"
|
|
||||||
:value message
|
|
||||||
:onChangeText (fn [new-text]
|
|
||||||
)
|
|
||||||
:onSubmitEditing (fn [e]
|
|
||||||
)}]]]
|
|
||||||
[touchable-highlight {:style {:marginTop 14
|
|
||||||
:marginRight 16
|
|
||||||
:position "absolute"
|
|
||||||
:right 20
|
|
||||||
:bottom 20}
|
|
||||||
:onPress (fn []
|
|
||||||
(cancel-command-input))}
|
|
||||||
[image {:source res/att
|
|
||||||
:style {:width 34
|
|
||||||
:height 28}}]]]))))
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
(ns syng-im.components.chat.simple-command-input
|
||||||
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
|
[syng-im.components.react :refer [android?
|
||||||
|
view
|
||||||
|
image
|
||||||
|
text
|
||||||
|
text-input
|
||||||
|
touchable-highlight]]
|
||||||
|
[syng-im.utils.utils :refer [log toast http-post]]
|
||||||
|
[syng-im.utils.logging :as log]
|
||||||
|
[syng-im.resources :as res]
|
||||||
|
[reagent.core :as r]))
|
||||||
|
|
||||||
|
(defn cancel-command-input []
|
||||||
|
(dispatch [:set-input-command nil]))
|
||||||
|
|
||||||
|
(defn simple-command-input-view [command input-type]
|
||||||
|
(let [message-atom (r/atom nil)
|
||||||
|
chat-id (subscribe [:get-current-chat-id])]
|
||||||
|
(fn []
|
||||||
|
(let [message @message-atom]
|
||||||
|
[view {:style {:flexDirection "row"}}
|
||||||
|
[view {:style {:flex 1
|
||||||
|
:flexDirection "column"
|
||||||
|
:backgroundColor "white"}}
|
||||||
|
[view {:style {:flexDirection "column"
|
||||||
|
:margin 10
|
||||||
|
:width 200
|
||||||
|
:backgroundColor "#ebf0f4"
|
||||||
|
:borderRadius 10}}
|
||||||
|
[view {:style {:flexDirection "row"}}
|
||||||
|
[view {:style {:flexDirection "column"
|
||||||
|
:margin 10
|
||||||
|
:backgroundColor (:color command)
|
||||||
|
:borderRadius 10}}
|
||||||
|
[text {:style {:marginTop -2
|
||||||
|
:marginHorizontal 10
|
||||||
|
:fontSize 14
|
||||||
|
:fontFamily "Avenir-Roman"
|
||||||
|
:color "white"}}
|
||||||
|
(:text command)]]
|
||||||
|
[touchable-highlight {:style {:marginTop 14
|
||||||
|
:marginRight 16
|
||||||
|
:position "absolute"
|
||||||
|
:top 3
|
||||||
|
:right 20}
|
||||||
|
:onPress (fn []
|
||||||
|
(cancel-command-input))}
|
||||||
|
[image {:source res/att
|
||||||
|
:style {:width 17
|
||||||
|
:height 14}}]]]
|
||||||
|
[text-input {:style {:flex 1
|
||||||
|
:marginLeft 8
|
||||||
|
:lineHeight 42
|
||||||
|
:fontSize 14
|
||||||
|
:fontFamily "Avenir-Roman"
|
||||||
|
:color "#9CBFC0"}
|
||||||
|
:underlineColorAndroid "transparent"
|
||||||
|
:autoFocus true
|
||||||
|
:keyboardType input-type
|
||||||
|
:value message
|
||||||
|
:onChangeText (fn [new-text]
|
||||||
|
)
|
||||||
|
:onSubmitEditing (fn [e]
|
||||||
|
)}]]]
|
||||||
|
[touchable-highlight {:style {:marginTop 14
|
||||||
|
:marginRight 16
|
||||||
|
:position "absolute"
|
||||||
|
:right 20
|
||||||
|
:bottom 20}
|
||||||
|
:onPress (fn []
|
||||||
|
(cancel-command-input))}
|
||||||
|
[image {:source res/att
|
||||||
|
:style {:width 34
|
||||||
|
:height 28}}]]]))))
|
|
@ -1,8 +1,9 @@
|
||||||
(ns syng-im.handlers.commands
|
(ns syng-im.handlers.commands
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
|
[syng-im.models.commands :refer [get-command]]
|
||||||
[syng-im.utils.utils :refer [log on-error http-post]]
|
[syng-im.utils.utils :refer [log on-error http-post]]
|
||||||
[syng-im.utils.logging :as log]))
|
[syng-im.utils.logging :as log]))
|
||||||
|
|
||||||
(defn set-input-command [db command]
|
(defn set-input-command [db command]
|
||||||
(assoc-in db db/input-command-path command))
|
(assoc-in db db/input-command-path (get-command command)))
|
||||||
|
|
|
@ -1,36 +1,13 @@
|
||||||
(ns syng-im.handlers.suggestions
|
(ns syng-im.handlers.suggestions
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
|
[syng-im.models.commands :refer [commands suggestions]]
|
||||||
[syng-im.utils.utils :refer [log on-error http-post]]
|
[syng-im.utils.utils :refer [log on-error http-post]]
|
||||||
[syng-im.utils.logging :as log]))
|
[syng-im.utils.logging :as log]))
|
||||||
|
|
||||||
(def commands [{:command :money
|
|
||||||
:text "!money"
|
|
||||||
:description "Send money"
|
|
||||||
:color "#48ba30"}
|
|
||||||
{:command :location
|
|
||||||
:text "!location"
|
|
||||||
:description "Send location"
|
|
||||||
:color "#9a5dcf"}
|
|
||||||
{:command :phone
|
|
||||||
:text "!phone"
|
|
||||||
:description "Send phone number"
|
|
||||||
:color "#48ba30"}
|
|
||||||
{:command :send
|
|
||||||
:text "!send"
|
|
||||||
:description "Send location"
|
|
||||||
:color "#9a5dcf"}
|
|
||||||
{:command :request
|
|
||||||
:text "!request"
|
|
||||||
:description "Send request"
|
|
||||||
:color "#48ba30"}
|
|
||||||
{:command :help
|
|
||||||
:text "!help"
|
|
||||||
:description "Help"
|
|
||||||
:color "#9a5dcf"}])
|
|
||||||
|
|
||||||
(defn get-suggestions [text]
|
(defn get-suggestions [text]
|
||||||
(if (= (get text 0) "!")
|
(if (= (get text 0) "!")
|
||||||
|
;; TODO change 'commands' to 'suggestions'
|
||||||
(filterv #(.startsWith (:text %) text) commands)
|
(filterv #(.startsWith (:text %) text) commands)
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
(ns syng-im.models.commands
|
||||||
|
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
||||||
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
|
[syng-im.utils.utils :refer [log toast]]
|
||||||
|
[syng-im.persistence.realm :as realm]))
|
||||||
|
|
||||||
|
(def commands [{:command :money
|
||||||
|
:text "!money"
|
||||||
|
:description "Send money"
|
||||||
|
:color "#48ba30"
|
||||||
|
:suggestion true}
|
||||||
|
{:command :location
|
||||||
|
:text "!location"
|
||||||
|
:description "Send location"
|
||||||
|
:color "#9a5dcf"
|
||||||
|
:suggestion true}
|
||||||
|
{:command :phone
|
||||||
|
:text "!phone"
|
||||||
|
:description "Send phone number"
|
||||||
|
:color "#48ba30"
|
||||||
|
:suggestion false}
|
||||||
|
{:command :send
|
||||||
|
:text "!send"
|
||||||
|
:description "Send location"
|
||||||
|
:color "#9a5dcf"
|
||||||
|
:suggestion true}
|
||||||
|
{:command :request
|
||||||
|
:text "!request"
|
||||||
|
:description "Send request"
|
||||||
|
:color "#48ba30"
|
||||||
|
:suggestion true}
|
||||||
|
{:command :keypair-password
|
||||||
|
:text "!keypairPassword"
|
||||||
|
:description ""
|
||||||
|
:color "#019af0"
|
||||||
|
:suggestion false}
|
||||||
|
{:command :help
|
||||||
|
:text "!help"
|
||||||
|
:description "Help"
|
||||||
|
:color "#9a5dcf"
|
||||||
|
:suggestion true}])
|
||||||
|
|
||||||
|
(def suggestions (filterv :suggestion commands))
|
||||||
|
|
||||||
|
(defn get-command [command-key]
|
||||||
|
(first (filter #(= command-key (:command %)) commands)))
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
(register-sub :get-input-command
|
(register-sub :get-input-command
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(reaction (get-in @db db/input-command-path))))
|
(reaction (get-in @db db/input-command-path))
|
||||||
|
;; (let [input-command-name ]
|
||||||
|
;; (reaction @input-command-name))
|
||||||
|
))
|
||||||
|
|
||||||
;; -- Chats list --------------------------------------------------------------
|
;; -- Chats list --------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue