Suggestions styles

This commit is contained in:
virvar 2016-04-01 11:10:38 +03:00
parent 079c262bec
commit 7f761944a9
6 changed files with 47 additions and 31 deletions

View File

@ -25,7 +25,7 @@
_ (log/debug "messages=" msgs) _ (log/debug "messages=" msgs)
datasource (to-realm-datasource msgs)] datasource (to-realm-datasource msgs)]
[view {:style {:flex 1 [view {:style {:flex 1
:backgroundColor "white"}} :backgroundColor "#eef2f5"}}
(when android? (when android?
;; TODO add IOS version ;; TODO add IOS version
[toolbar-android {:logo res/logo-icon [toolbar-android {:logo res/logo-icon

View File

@ -32,7 +32,6 @@
[view {:style {:flexDirection "row"}} [view {:style {:flexDirection "row"}}
[view {:style {:flexDirection "column" [view {:style {:flexDirection "column"
:margin 10 :margin 10
:width 120
:backgroundColor "blue" :backgroundColor "blue"
:borderRadius 10}} :borderRadius 10}}
[text {:style {:marginVertical 3 [text {:style {:marginVertical 3

View File

@ -30,7 +30,6 @@
[view {:style {:flexDirection "row"}} [view {:style {:flexDirection "row"}}
[view {:style {:flexDirection "column" [view {:style {:flexDirection "column"
:margin 10 :margin 10
:width 120
:backgroundColor "blue" :backgroundColor "blue"
:borderRadius 10}} :borderRadius 10}}
[text {:style {:marginVertical 3 [text {:style {:marginVertical 3

View File

@ -11,23 +11,23 @@
[reagent.core :as r])) [reagent.core :as r]))
(defn plain-message-input-view [] (defn plain-message-input-view []
(let [text (r/atom nil) (let [text (r/atom "!")
chat-id (subscribe [:get-current-chat-id])] chat-id (subscribe [:get-current-chat-id])]
(dispatch [:generate-suggestions @text]) (dispatch [:generate-suggestions @text])
(fn [] (fn []
[view {:style {:flexDirection "column"}} [view {:style {:flexDirection "column"}}
[suggestions-view] [suggestions-view]
[view {:style {:flexDirection "row" [view {:style {:flexDirection "row"
:margin 10 :margin 1
:height 40 :height 40
:backgroundColor "#E5F5F6" :backgroundColor "white"
:borderRadius 5}} :borderRadius 5}}
[image {:source res/mic [image {:source res/mic
:style {:marginTop 11 :style {:marginTop 11
:marginLeft 14 :marginLeft 14
:width 13 :width 13
:height 20}}] :height 20}}]
[text-input {:underlineColorAndroid "#9CBFC0" [text-input {:underlineColorAndroid "transparent"
:style {:flex 1 :style {:flex 1
:marginLeft 18 :marginLeft 18
:lineHeight 42 :lineHeight 42
@ -35,7 +35,7 @@
:fontFamily "Avenir-Roman" :fontFamily "Avenir-Roman"
:color "#9CBFC0"} :color "#9CBFC0"}
:autoFocus false :autoFocus false
:placeholder "Enter your message here" :placeholder "Type"
:value @text :value @text
:onChangeText (fn [new-text] :onChangeText (fn [new-text]
(dispatch [:generate-suggestions new-text]) (dispatch [:generate-suggestions new-text])

View File

@ -21,24 +21,30 @@
[touchable-highlight {:onPress (fn [] [touchable-highlight {:onPress (fn []
(set-command-input (keyword (:command suggestion))))} (set-command-input (keyword (:command suggestion))))}
[view {:style {:flexDirection "row" [view {:style {:flexDirection "row"
:marginVertical 5 :marginVertical 1
:marginHorizontal 0
:height 40
:backgroundColor "white"}}
[view {:style {:flexDirection "column"
:position "absolute"
:top 10
:left 60
:backgroundColor (:color suggestion)
:borderRadius 10}}
[text {:style {:marginTop -2
:marginHorizontal 10 :marginHorizontal 10
:height 20 :fontSize 14
;; :backgroundColor "white" :fontFamily "Avenir-Roman"
}} :color "white"}}
(:text suggestion)]]
[text {:style {:flex 1 [text {:style {:flex 1
:marginLeft 18 :position "absolute"
:top 7
:left 190
:lineHeight 18 :lineHeight 18
:fontSize 14 :fontSize 14
:fontFamily "Avenir-Roman" :fontFamily "Avenir-Roman"
:color "#9CBFC0"}} :color "black"}}
(:text suggestion)]
[text {:style {:flex 1
:marginLeft 18
:lineHeight 18
:fontSize 14
:fontFamily "Avenir-Roman"
:color "#9CBFC0"}}
(:description suggestion)]]]) (:description suggestion)]]])
(defn render-row [row section-id row-id] (defn render-row [row section-id row-id]
@ -50,10 +56,10 @@
(let [suggestions @suggestions-atom] (let [suggestions @suggestions-atom]
(when (not (empty? suggestions)) (when (not (empty? suggestions))
[view {:style {:flexDirection "row" [view {:style {:flexDirection "row"
:marginVertical 5 :marginVertical 1
:marginHorizontal 10 :marginHorizontal 0
:height 120 :height (min 105 (* 42 (count suggestions)))
:backgroundColor "#E5F5F6" :backgroundColor "#eef2f5"
:borderRadius 5}} :borderRadius 5}}
[list-view {:dataSource (to-datasource suggestions) [list-view {:dataSource (to-datasource suggestions)
:renderRow render-row :renderRow render-row

View File

@ -4,18 +4,30 @@
[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 :phone (def commands [{:command :money
:text "!money"
:description "Send money"
:color "#48ba30"}
{:command :location
:text "!location"
:description "Send location"
:color "#9a5dcf"}
{:command :phone
:text "!phone" :text "!phone"
:description "Send phone number"} :description "Send phone number"
:color "#48ba30"}
{:command :send {:command :send
:text "!send" :text "!send"
:description "Send location"} :description "Send location"
:color "#9a5dcf"}
{:command :request {:command :request
:text "!request" :text "!request"
:description "Send request"} :description "Send request"
:color "#48ba30"}
{:command :help {:command :help
:text "!help" :text "!help"
:description "Help"}]) :description "Help"
:color "#9a5dcf"}])
(defn get-suggestions [text] (defn get-suggestions [text]
(if (= (get text 0) "!") (if (= (get text 0) "!")