chat inputs/suggestions/commands

Former-commit-id: 4b1b5a9449
This commit is contained in:
Roman Volosovskyi 2016-05-09 19:28:40 +03:00
parent 5fcfd12473
commit 3be2f2c06c
16 changed files with 51 additions and 52 deletions

View File

@ -11,7 +11,7 @@
[syng-im.chat.screen :refer [chat]]
[syng-im.components.chats.chats-list :refer [chats-list]]
[syng-im.components.chats.new-group :refer [new-group]]
[syng-im.participants.views.new :refer [new-participants]]
[syng-im.participants.views.create :refer [new-participants]]
[syng-im.participants.views.remove :refer [remove-participants]]
[syng-im.utils.logging :as log]
[syng-im.utils.utils :refer [toast]]

View File

@ -1,4 +1,4 @@
(ns syng-im.components.chat.input.input-styles
(ns syng-im.chat.styles.input
(:require [syng-im.components.styles :refer [font
color-white
color-blue

View File

@ -1,4 +1,4 @@
(ns syng-im.components.chat.plain-message-input-styles
(ns syng-im.chat.styles.plain-input
(:require [syng-im.components.styles :refer [font
text2-color
color-white

View File

@ -1,4 +1,4 @@
(ns syng-im.components.chat.suggestions-styles
(ns syng-im.chat.styles.suggestions
(:require [syng-im.components.styles :refer [font color-white]]))
(def suggestion-item-container

View File

@ -1,4 +1,4 @@
(ns syng-im.components.chat.input.simple-command
(ns syng-im.chat.views.command
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.components.react :refer [view
image
@ -7,7 +7,7 @@
text-input
touchable-highlight]]
[syng-im.resources :as res]
[syng-im.components.chat.input.input-styles :as st]))
[syng-im.chat.styles.input :as st]))
(defn cancel-command-input []
(dispatch [:cancel-command]))

View File

@ -0,0 +1,6 @@
(ns syng-im.chat.views.confirmation-code
(:require
[syng-im.chat.views.command :refer [simple-command-input-view]]))
(defn confirmation-code-input-view [command]
[simple-command-input-view command {:keyboardType :numeric}])

View File

@ -0,0 +1,9 @@
(ns syng-im.chat.views.money
(:require
[syng-im.chat.views.command :refer [simple-command-input-view]]
[syng-im.chat.styles.input :as st]))
(defn money-input-view [command]
[simple-command-input-view command
{:keyboardType :numeric
:style st/money-input}])

View File

@ -2,13 +2,13 @@
(:require
[re-frame.core :refer [subscribe]]
[syng-im.components.react :refer [view]]
[syng-im.components.chat.plain-message-input :refer [plain-message-input-view]]
[syng-im.components.chat.input.simple-command :refer [simple-command-input-view]]
[syng-im.components.chat.input.phone :refer [phone-input-view]]
[syng-im.components.chat.input.password :refer [password-input-view]]
[syng-im.components.chat.input.confirmation-code :refer [confirmation-code-input-view]]
[syng-im.components.chat.input.money :refer [money-input-view]]
[syng-im.components.chat.input.simple-command-staged :refer [simple-command-staged-view]]
[syng-im.chat.views.plain-input :refer [plain-message-input-view]]
[syng-im.chat.views.command :refer [simple-command-input-view]]
[syng-im.chat.views.phone :refer [phone-input-view]]
[syng-im.chat.views.password :refer [password-input-view]]
[syng-im.chat.views.confirmation-code :refer [confirmation-code-input-view]]
[syng-im.chat.views.money :refer [money-input-view]]
[syng-im.chat.views.staged-command :refer [simple-command-staged-view]]
[syng-im.chat.styles.message :as st]))
(defn staged-command-view [stage-command]

View File

@ -1,6 +1,6 @@
(ns syng-im.components.chat.input.password
(ns syng-im.chat.views.password
(:require
[syng-im.components.chat.input.simple-command
[syng-im.chat.views.command
:refer [simple-command-input-view]]))
(defn password-input-view [command]

View File

@ -1,6 +1,6 @@
(ns syng-im.components.chat.input.phone
(ns syng-im.chat.views.phone
(:require
[syng-im.components.chat.input.simple-command
[syng-im.chat.views.command
:refer [simple-command-input-view]]))
(defn phone-input-view [command]

View File

@ -1,11 +1,11 @@
(ns syng-im.components.chat.plain-message-input
(ns syng-im.chat.views.plain-input
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.components.react :refer [view
icon
touchable-highlight
text-input]]
[syng-im.components.chat.suggestions :refer [suggestions-view]]
[syng-im.components.chat.plain-message-input-styles :as st]))
[syng-im.chat.views.suggestions :refer [suggestions-view]]
[syng-im.chat.styles.plain-input :as st]))
(defn set-input-message [message]
(dispatch [:set-chat-input-text message]))

View File

@ -1,11 +1,11 @@
(ns syng-im.components.chat.input.simple-command-staged
(ns syng-im.chat.views.staged-command
(:require [re-frame.core :refer [subscribe dispatch]]
[syng-im.components.react :refer [view
image
text
touchable-highlight]]
[syng-im.resources :as res]
[syng-im.components.chat.input.input-styles :as st]))
[syng-im.chat.styles.input :as st]))
(defn cancel-command-input [staged-command]
(dispatch [:unstage-command staged-command]))

View File

@ -1,6 +1,6 @@
(ns syng-im.components.chat.suggestions
(ns syng-im.chat.views.suggestions
(:require-macros
[natal-shell.core :refer [with-error-view]])
[natal-shell.core :refer [with-error-view]])
(:require [re-frame.core :refer [subscribe dispatch]]
[syng-im.components.react :refer [view
text
@ -8,20 +8,21 @@
list-view
list-item]]
[syng-im.utils.listview :refer [to-datasource]]
[syng-im.components.chat.suggestions-styles :as st]))
[syng-im.chat.styles.suggestions :as st]))
(defn set-command-input [command]
(dispatch [:set-chat-command command]))
(defn suggestion-list-item [suggestion]
(defn suggestion-list-item
[{:keys [description command]
label :text
:as suggestion}]
[touchable-highlight
{:onPress #(set-command-input (keyword (:command suggestion)))}
{:onPress #(set-command-input (keyword command))}
[view st/suggestion-item-container
[view (st/suggestion-background suggestion)
[text {:style st/suggestion-text}
(:text suggestion)]]
[text {:style st/suggestion-description}
(:description suggestion)]]])
[text {:style st/suggestion-text} label]]
[text {:style st/suggestion-description} description]]])
(defn render-row [row _ _]
(list-item [suggestion-list-item (js->clj row :keywordize-keys true)]))
@ -32,7 +33,7 @@
(let [suggestions @suggestions-atom]
(when (seq suggestions)
[view (st/suggestions-container suggestions)
[list-view {:dataSource (to-datasource suggestions)
[list-view {:dataSource (to-datasource suggestions)
:enableEmptySections true
:renderRow render-row
:style {}}]])))))
:renderRow render-row
:style {}}]])))))

View File

@ -1,7 +0,0 @@
(ns syng-im.components.chat.input.confirmation-code
(:require
[syng-im.components.chat.input.simple-command
:refer [simple-command-input-view]]))
(defn confirmation-code-input-view [command]
[simple-command-input-view command {:keyboardType :numeric}])

View File

@ -1,10 +0,0 @@
(ns syng-im.components.chat.input.money
(:require
[syng-im.components.chat.input.simple-command
:refer [simple-command-input-view]]
[syng-im.components.chat.input.input-styles :as st]))
(defn money-input-view [command]
[simple-command-input-view command
{:keyboardType :numeric
:style st/money-input}])

View File

@ -1,4 +1,4 @@
(ns syng-im.participants.views.new
(ns syng-im.participants.views.create
(:require [re-frame.core :refer [subscribe dispatch]]
[syng-im.resources :as res]
[syng-im.components.react :refer [view]]