command suggestions design
This commit is contained in:
parent
58675d5509
commit
a1556ee335
|
@ -113,7 +113,6 @@
|
||||||
content)
|
content)
|
||||||
command-info {:command command :content content'}]
|
command-info {:command command :content content'}]
|
||||||
(-> db
|
(-> db
|
||||||
;(assoc-in [:chats current-chat-id :command-input :command] nil)
|
|
||||||
(commands/stage-command command-info)
|
(commands/stage-command command-info)
|
||||||
(assoc :staged-command command-info)))))
|
(assoc :staged-command command-info)))))
|
||||||
|
|
||||||
|
@ -138,7 +137,6 @@
|
||||||
(defn update-text
|
(defn update-text
|
||||||
[{:keys [current-chat-id] :as db} [_ text]]
|
[{:keys [current-chat-id] :as db} [_ text]]
|
||||||
(let [suggestions (get-in db [:command-suggestions current-chat-id])]
|
(let [suggestions (get-in db [:command-suggestions current-chat-id])]
|
||||||
(println :hui (count suggestions) text :bla)
|
|
||||||
(if-not (= 1 (count suggestions))
|
(if-not (= 1 (count suggestions))
|
||||||
(update-input-text db text)
|
(update-input-text db text)
|
||||||
db)))
|
db)))
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
(fn [{:keys [current-chat-id] :as db} _]
|
(fn [{:keys [current-chat-id] :as db} _]
|
||||||
(let [suggestions? (seq (get-in db [:command-suggestions current-chat-id]))
|
(let [suggestions? (seq (get-in db [:command-suggestions current-chat-id]))
|
||||||
current (get-in db [:animations :command-suggestions-height])
|
current (get-in db [:animations :command-suggestions-height])
|
||||||
height (if suggestions? middle-height 0.1)
|
height (if suggestions? middle-height 10)
|
||||||
changed? (if (and suggestions? (not= 0.1 current))
|
changed? (if (and suggestions?
|
||||||
|
(not (nil? current))
|
||||||
|
(not= 10 current))
|
||||||
identity inc)]
|
identity inc)]
|
||||||
(-> db
|
(-> db
|
||||||
(update :animations assoc :command-suggestions-height height)
|
(update :animations assoc :command-suggestions-height height)
|
||||||
|
@ -43,7 +45,7 @@
|
||||||
type (get-in db path)]
|
type (get-in db path)]
|
||||||
(if (= :response type)
|
(if (= :response type)
|
||||||
minimum-suggestion-height
|
minimum-suggestion-height
|
||||||
0.1)))
|
10)))
|
||||||
|
|
||||||
(register-handler :animate-show-response
|
(register-handler :animate-show-response
|
||||||
[(after #(dispatch [:command-edit-mode]))]
|
[(after #(dispatch [:command-edit-mode]))]
|
||||||
|
@ -52,7 +54,6 @@
|
||||||
height (if suggestions?
|
height (if suggestions?
|
||||||
middle-height
|
middle-height
|
||||||
(get-minimum-height db))]
|
(get-minimum-height db))]
|
||||||
(println "hei" suggestions? )
|
|
||||||
(assoc-in db [:animations :to-response-height] height))))
|
(assoc-in db [:animations :to-response-height] height))))
|
||||||
|
|
||||||
(defn fix-height
|
(defn fix-height
|
||||||
|
|
|
@ -12,22 +12,23 @@
|
||||||
text2-color
|
text2-color
|
||||||
text3-color]]))
|
text3-color]]))
|
||||||
|
|
||||||
(def suggestion-height 88)
|
(def suggestion-height 60)
|
||||||
|
|
||||||
|
(def suggestion-highlight
|
||||||
|
{:margin-left 57})
|
||||||
|
|
||||||
(def suggestion-container
|
(def suggestion-container
|
||||||
{:flexDirection :column
|
{:backgroundColor color-white})
|
||||||
:paddingLeft 16
|
|
||||||
:backgroundColor color-white})
|
|
||||||
|
|
||||||
(def suggestion-sub-container
|
(def suggestion-sub-container
|
||||||
{:height suggestion-height
|
{:height suggestion-height
|
||||||
:borderBottomWidth 1
|
:borderBottomWidth 1
|
||||||
:borderBottomColor separator-color})
|
:borderBottomColor separator-color
|
||||||
|
:flex-direction :row})
|
||||||
|
|
||||||
(defn suggestion-background
|
(defn suggestion-background
|
||||||
[{:keys [color]}]
|
[{:keys [color]}]
|
||||||
{:alignSelf :flex-start
|
{:marginTop 10
|
||||||
:marginTop 10
|
|
||||||
:height 24
|
:height 24
|
||||||
:backgroundColor color
|
:backgroundColor color
|
||||||
:borderRadius 50})
|
:borderRadius 50})
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
{:flexDirection :row
|
{:flexDirection :row
|
||||||
:marginVertical 1
|
:marginVertical 1
|
||||||
:marginHorizontal 0
|
:marginHorizontal 0
|
||||||
|
:flex 1
|
||||||
:height (min 168 (* suggestion-height suggestions-count))
|
:height (min 168 (* suggestion-height suggestions-count))
|
||||||
:backgroundColor color-white
|
:backgroundColor color-white
|
||||||
:borderRadius 5})
|
:borderRadius 5})
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require-macros [status-im.utils.views :refer [defview]])
|
(:require-macros [status-im.utils.views :refer [defview]])
|
||||||
(:require [re-frame.core :refer [subscribe dispatch]]
|
(:require [re-frame.core :refer [subscribe dispatch]]
|
||||||
[status-im.components.react :refer [view
|
[status-im.components.react :refer [view
|
||||||
|
scroll-view
|
||||||
text
|
text
|
||||||
icon
|
icon
|
||||||
touchable-highlight
|
touchable-highlight
|
||||||
|
@ -15,7 +16,8 @@
|
||||||
[status-im.components.animation :as anim]
|
[status-im.components.animation :as anim]
|
||||||
[status-im.components.drag-drop :as drag]
|
[status-im.components.drag-drop :as drag]
|
||||||
[status-im.components.react :as react]
|
[status-im.components.react :as react]
|
||||||
[status-im.chat.suggestions-responder :as resp]))
|
[status-im.chat.suggestions-responder :as resp]
|
||||||
|
[status-im.chat.constants :as c]))
|
||||||
|
|
||||||
(defn set-command-input [command]
|
(defn set-command-input [command]
|
||||||
(dispatch [:set-chat-command command]))
|
(dispatch [:set-chat-command command]))
|
||||||
|
@ -26,29 +28,39 @@
|
||||||
:as suggestion}]]
|
:as suggestion}]]
|
||||||
(let [label (str "!" name)]
|
(let [label (str "!" name)]
|
||||||
[touchable-highlight
|
[touchable-highlight
|
||||||
{:onPress #(set-command-input command)}
|
{:onPress #(set-command-input command)
|
||||||
|
:style st/suggestion-highlight}
|
||||||
[view st/suggestion-container
|
[view st/suggestion-container
|
||||||
[view st/suggestion-sub-container
|
[view st/suggestion-sub-container
|
||||||
[view (st/suggestion-background suggestion)
|
[view {:flex 0.6}
|
||||||
[text {:style st/suggestion-text} label]]
|
[text {:style st/value-text} label]
|
||||||
[text {:style st/value-text} label]
|
[text {:style st/description-text} description]]
|
||||||
[text {:style st/description-text} description]]]]))
|
[view {:flex 0.4
|
||||||
|
:flex-direction :column
|
||||||
|
:align-items :flex-end
|
||||||
|
:margin-right 16}
|
||||||
|
[view (st/suggestion-background suggestion)
|
||||||
|
[text {:style st/suggestion-text} label]]]]]]))
|
||||||
|
|
||||||
(defn render-row [row _ _]
|
(defn render-row [row _ _]
|
||||||
(list-item [suggestion-list-item row]))
|
(list-item [suggestion-list-item row]))
|
||||||
|
|
||||||
|
(defn title [s]
|
||||||
|
[view {:margin-left 57
|
||||||
|
:margin-bottom 16}
|
||||||
|
[text {:style {:font-size 13
|
||||||
|
:color :#8f838c93}} s]])
|
||||||
|
|
||||||
(defn suggestions-view []
|
(defview suggestions-view []
|
||||||
(let
|
[suggestions [:get-suggestions]
|
||||||
[suggestions (subscribe [:get-suggestions])]
|
requests [:get :chat-requests]]
|
||||||
(r/create-class
|
[scroll-view
|
||||||
{:reagent-render
|
(when requests [title "Requests"])
|
||||||
(fn []
|
[title "Commands"]
|
||||||
[view (st/suggestions-container (count @suggestions))
|
[view (st/suggestions-container (count suggestions))
|
||||||
[list-view {:dataSource (to-datasource @suggestions)
|
[list-view {:dataSource (to-datasource suggestions)
|
||||||
:enableEmptySections true
|
:keyboardShouldPersistTaps true
|
||||||
:keyboardShouldPersistTaps true
|
:renderRow render-row}]]])
|
||||||
:renderRow render-row}]])})))
|
|
||||||
|
|
||||||
(defn header [h]
|
(defn header [h]
|
||||||
(let [orientation (subscribe [:get :orientation])
|
(let [orientation (subscribe [:get :orientation])
|
||||||
|
@ -64,7 +76,7 @@
|
||||||
[icon :drag_down ddst/drag-down-icon]])))
|
[icon :drag_down ddst/drag-down-icon]])))
|
||||||
|
|
||||||
(defn container-animation-logic [{:keys [to-value val]}]
|
(defn container-animation-logic [{:keys [to-value val]}]
|
||||||
(let [to-value @to-value]
|
(when-let [to-value @to-value]
|
||||||
(anim/start (anim/spring val {:toValue to-value}))))
|
(anim/start (anim/spring val {:toValue to-value}))))
|
||||||
|
|
||||||
(defn container [h & elements]
|
(defn container [h & elements]
|
||||||
|
@ -86,7 +98,8 @@
|
||||||
(into [animated-view {:style (st/container h)}] elements))})))
|
(into [animated-view {:style (st/container h)}] elements))})))
|
||||||
|
|
||||||
(defn suggestion-container []
|
(defn suggestion-container []
|
||||||
(let [h (anim/create-value 0)]
|
(let [h (anim/create-value 10)]
|
||||||
[container h
|
[container h
|
||||||
[header h]
|
[header h]
|
||||||
[suggestions-view]]))
|
[suggestions-view]
|
||||||
|
[view {:height c/input-height}]]))
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
(defn register-handler
|
(defn register-handler
|
||||||
([name handler] (register-handler name nil handler))
|
([name handler] (register-handler name nil handler))
|
||||||
([name middleware handler]
|
([name middleware handler]
|
||||||
(re-core/register-handler name [#_debug middleware] handler)))
|
(re-core/register-handler name [debug middleware] handler)))
|
||||||
|
|
Loading…
Reference in New Issue