Start command input on button click

This commit is contained in:
virvar 2016-05-10 13:12:49 +03:00
parent 8324cf4109
commit 6bbd5bf92d
4 changed files with 18 additions and 3 deletions

View File

@ -27,7 +27,8 @@
[view st/input-container
[suggestions-view]
[view st/input-view
[icon :list st/list-icon]
[touchable-highlight {:on-press #(dispatch [:switch-command-suggestions])}
[view nil [icon :list st/list-icon]]]
[text-input {:style st/message-input
:autoFocus (pos? (count @staged-commands-atom))
:onChangeText set-input-message

View File

@ -29,7 +29,8 @@
get-command-handler
load-commands
apply-staged-commands
check-suggestion]]
check-suggestion
switch-command-suggestions]]
[syng-im.handlers.sign-up :as sign-up-service]
[syng-im.models.chats :refer [chat-exists?
create-chat
@ -487,6 +488,10 @@
(register-handler :set-chat-input-text
((enrich update-command) update-text))
(register-handler :switch-command-suggestions
(fn [db [_]]
(switch-command-suggestions db)))
(register-handler :set-chat-command
(fn [db [_ command-key]]
;; todo what is going on there?!

View File

@ -1,7 +1,9 @@
(ns syng-im.handlers.suggestions
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.db :as db]
[syng-im.models.chat :refer [current-chat-id]]
[syng-im.models.chat :refer [current-chat-id
set-chat-input-text
get-chat-input-text]]
[syng-im.models.commands :refer [commands
suggestions
get-commands
@ -62,3 +64,7 @@
[suggestion] (filter #(= suggestion-text' (:text %))
(get-commands db))]
suggestion)))
(defn switch-command-suggestions [db]
(let [text (get-chat-input-text db)]
(set-chat-input-text db (if (suggestion? text) nil "!"))))

View File

@ -43,6 +43,9 @@
(defn set-chat-input-text [db text]
(assoc-in db (db/chat-input-text-path (current-chat-id db)) text))
(defn get-chat-input-text [db]
(get-in db (db/chat-input-text-path (current-chat-id db))))
(comment
(swap! re-frame.db/app-db (fn [db]