parent
f6017b3fce
commit
f382e543c4
|
@ -4,4 +4,6 @@
|
||||||
(def request-info-height 61)
|
(def request-info-height 61)
|
||||||
(def response-height-normal 211)
|
(def response-height-normal 211)
|
||||||
(def minimum-suggestion-height (+ input-height request-info-height))
|
(def minimum-suggestion-height (+ input-height request-info-height))
|
||||||
(def minimum-command-suggestions-height (+ input-height 22))
|
(def suggestions-header-height 22)
|
||||||
|
(def minimum-command-suggestions-height
|
||||||
|
(+ input-height suggestions-header-height))
|
||||||
|
|
|
@ -366,8 +366,7 @@
|
||||||
(register-handler :init-chat
|
(register-handler :init-chat
|
||||||
(-> load-messages!
|
(-> load-messages!
|
||||||
((enrich init-chat))
|
((enrich init-chat))
|
||||||
((after load-commands!))
|
((after load-commands!))))
|
||||||
debug))
|
|
||||||
|
|
||||||
(defn initialize-chats
|
(defn initialize-chats
|
||||||
[{:keys [loaded-chats] :as db} _]
|
[{:keys [loaded-chats] :as db} _]
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
(animation-handler :animate-cancel-command
|
(animation-handler :animate-cancel-command
|
||||||
(after #(dispatch [:text-edit-mode]))
|
(after #(dispatch [:text-edit-mode]))
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(assoc db
|
(assoc db :to-response-height input-height)))
|
||||||
:to-response-height input-height
|
|
||||||
:messages-offset? false)))
|
|
||||||
|
|
||||||
(def response-height (+ input-height response-height-normal))
|
(def response-height (+ input-height response-height-normal))
|
||||||
|
|
||||||
|
@ -32,24 +30,19 @@
|
||||||
(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 0.1)
|
||||||
|
changed? (if (and suggestions? (not= 0.1 current))
|
||||||
|
identity inc)]
|
||||||
(-> db
|
(-> db
|
||||||
(update :animations assoc
|
(update :animations assoc :command-suggestions-height height)
|
||||||
:messages-offset? suggestions?
|
(update-in [:animations :commands-height-changed] changed?)))))
|
||||||
:messages-offset-max 22
|
|
||||||
:command-suggestions-height height)
|
|
||||||
(update-in [:animations :commands-height-changed]
|
|
||||||
(if (and suggestions? (not= 0.1 current))
|
|
||||||
identity inc))))))
|
|
||||||
|
|
||||||
(register-handler :animate-show-response
|
(register-handler :animate-show-response
|
||||||
[(after #(dispatch [:command-edit-mode]))]
|
[(after #(dispatch [:command-edit-mode]))]
|
||||||
(fn [{:keys [current-chat-id] :as db}]
|
(fn [{:keys [current-chat-id] :as db}]
|
||||||
(let [suggestions? (seq (get-in db [:suggestions current-chat-id]))
|
(let [suggestions? (seq (get-in db [:suggestions current-chat-id]))
|
||||||
height (if suggestions? middle-height minimum-suggestion-height)]
|
height (if suggestions? middle-height minimum-suggestion-height)]
|
||||||
(update db :animations assoc :messages-offset? true
|
(assoc-in db [:animations :to-response-height] height))))
|
||||||
:messages-offset-max request-info-height
|
|
||||||
:to-response-height height))))
|
|
||||||
|
|
||||||
(defn fix-height
|
(defn fix-height
|
||||||
[height-key height-signal-key suggestions-key minimum]
|
[height-key height-signal-key suggestions-key minimum]
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
:background-color background-color))))
|
:background-color background-color))))
|
||||||
|
|
||||||
(defview chat-icon []
|
(defview chat-icon []
|
||||||
[chat-id [:chat :chat-id]
|
[chat-id [:chat :chat-id]
|
||||||
group-chat [:chat :group-chat]
|
group-chat [:chat :group-chat]
|
||||||
name [:chat :name]
|
name [:chat :name]
|
||||||
color [:chat :color]]
|
color [:chat :color]]
|
||||||
;; TODO stub data ('online' property)
|
;; TODO stub data ('online' property)
|
||||||
[chat-icon-view-action chat-id group-chat name color true])
|
[chat-icon-view-action chat-id group-chat name color true])
|
||||||
|
|
||||||
|
@ -98,10 +98,10 @@
|
||||||
subtitle])]]])
|
subtitle])]]])
|
||||||
|
|
||||||
(defview menu-item-icon-profile []
|
(defview menu-item-icon-profile []
|
||||||
[chat-id [:chat :chat-id]
|
[chat-id [:chat :chat-id]
|
||||||
group-chat [:chat :group-chat]
|
group-chat [:chat :group-chat]
|
||||||
name [:chat :name]
|
name [:chat :name]
|
||||||
color [:chat :color]]
|
color [:chat :color]]
|
||||||
;; TODO stub data ('online' property)
|
;; TODO stub data ('online' property)
|
||||||
[chat-icon-view-menu-item chat-id group-chat name color true])
|
[chat-icon-view-menu-item chat-id group-chat name color true])
|
||||||
|
|
||||||
|
@ -140,12 +140,12 @@
|
||||||
:icon-style {:width 20
|
:icon-style {:width 20
|
||||||
:height 13}
|
:height 13}
|
||||||
:handler #(dispatch [:show-group-settings])}]
|
:handler #(dispatch [:show-group-settings])}]
|
||||||
[{:title (label :t/profile)
|
[{:title (label :t/profile)
|
||||||
:custom-icon [menu-item-icon-profile]
|
:custom-icon [menu-item-icon-profile]
|
||||||
:icon :menu_group
|
:icon :menu_group
|
||||||
:icon-style {:width 25
|
:icon-style {:width 25
|
||||||
:height 19}
|
:height 19}
|
||||||
:handler #(dispatch [:show-profile @chat-id])}
|
:handler #(dispatch [:show-profile @chat-id])}
|
||||||
{:title (label :t/search-chat)
|
{:title (label :t/search-chat)
|
||||||
:subtitle (label :t/not-implemented)
|
:subtitle (label :t/not-implemented)
|
||||||
:icon :search_gray_copy
|
:icon :search_gray_copy
|
||||||
|
@ -218,29 +218,26 @@
|
||||||
:custom-action [toolbar-action]}])))
|
:custom-action [toolbar-action]}])))
|
||||||
|
|
||||||
(defview messages-view [group-chat]
|
(defview messages-view [group-chat]
|
||||||
[messages [:chat :messages]
|
[messages [:chat :messages]
|
||||||
contacts [:chat :contacts]]
|
contacts [:chat :contacts]]
|
||||||
(let [contacts' (contacts-by-identity contacts)]
|
(let [contacts' (contacts-by-identity contacts)]
|
||||||
[list-view {:renderRow (message-row contacts' group-chat (count messages))
|
[list-view {:renderRow (message-row contacts' group-chat (count messages))
|
||||||
:renderScrollComponent #(invertible-scroll-view (js->clj %))
|
:renderScrollComponent #(invertible-scroll-view (js->clj %))
|
||||||
:onEndReached #(dispatch [:load-more-messages])
|
:onEndReached #(dispatch [:load-more-messages])
|
||||||
:enableEmptySections true
|
:enableEmptySections true
|
||||||
:keyboardShouldPersistTaps true
|
:keyboardShouldPersistTaps true
|
||||||
:dataSource (to-datasource-inverted messages)}]))
|
:dataSource (to-datasource-inverted messages)}]))
|
||||||
|
|
||||||
(defn messages-container-animation-logic
|
(defn messages-container-animation-logic
|
||||||
[{:keys [offset? val max]}]
|
[{:keys [offset val]}]
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(let [to-value (if @offset? @max 0)]
|
(anim/start (anim/spring val {:toValue @offset}))))
|
||||||
(anim/start (anim/spring val {:toValue to-value})))))
|
|
||||||
|
|
||||||
(defn messages-container [messages]
|
(defn messages-container [messages]
|
||||||
(let [messages-offset? (subscribe [:animations :messages-offset?])
|
(let [offset (subscribe [:messages-offset])
|
||||||
maximum-offset (subscribe [:animations :messages-offset-max])
|
|
||||||
messages-offset (anim/create-value 0)
|
messages-offset (anim/create-value 0)
|
||||||
context {:offset? messages-offset?
|
context {:offset offset
|
||||||
:val messages-offset
|
:val messages-offset}
|
||||||
:max maximum-offset}
|
|
||||||
on-update (messages-container-animation-logic context)]
|
on-update (messages-container-animation-logic context)]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:component-did-mount
|
{:component-did-mount
|
||||||
|
@ -249,7 +246,7 @@
|
||||||
on-update
|
on-update
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn [messages]
|
(fn [messages]
|
||||||
@messages-offset?
|
@offset
|
||||||
[animated-view {:style (st/messages-container messages-offset)}
|
[animated-view {:style (st/messages-container messages-offset)}
|
||||||
messages])})))
|
messages])})))
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
(:require [re-frame.core :refer [register-sub dispatch subscribe path]]
|
(:require [re-frame.core :refer [register-sub dispatch subscribe path]]
|
||||||
[status-im.models.commands :as commands]
|
[status-im.models.commands :as commands]
|
||||||
[status-im.constants :refer [response-suggesstion-resize-duration]]
|
[status-im.constants :refer [response-suggesstion-resize-duration]]
|
||||||
|
[status-im.chat.constants :as c]
|
||||||
[status-im.handlers.content-suggestions :refer [get-content-suggestions]]
|
[status-im.handlers.content-suggestions :refer [get-content-suggestions]]
|
||||||
[status-im.chat.views.plain-message :as plain-message]
|
[status-im.chat.views.plain-message :as plain-message]
|
||||||
[status-im.chat.views.command :as command]))
|
[status-im.chat.views.command :as command]))
|
||||||
|
@ -72,7 +73,7 @@
|
||||||
|
|
||||||
(register-sub :valid-plain-message?
|
(register-sub :valid-plain-message?
|
||||||
(fn [_ _]
|
(fn [_ _]
|
||||||
(let [input-message (subscribe [:get-chat-input-text])
|
(let [input-message (subscribe [:get-chat-input-text])
|
||||||
staged-commands (subscribe [:get-chat-staged-commands])]
|
staged-commands (subscribe [:get-chat-staged-commands])]
|
||||||
(reaction
|
(reaction
|
||||||
(plain-message/message-valid? @staged-commands @input-message)))))
|
(plain-message/message-valid? @staged-commands @input-message)))))
|
||||||
|
@ -116,3 +117,12 @@
|
||||||
(->> (get-in @db [:edit-mode (:current-chat-id @db)])
|
(->> (get-in @db [:edit-mode (:current-chat-id @db)])
|
||||||
(= :command)
|
(= :command)
|
||||||
(reaction))))
|
(reaction))))
|
||||||
|
|
||||||
|
(register-sub :messages-offset
|
||||||
|
(fn []
|
||||||
|
(let [command? (subscribe [:command?])
|
||||||
|
suggestions (subscribe [:get-suggestions])]
|
||||||
|
;; todo fix magic values
|
||||||
|
(reaction (cond @command? c/request-info-height
|
||||||
|
(seq @suggestions) c/suggestions-header-height
|
||||||
|
:else 0)))))
|
||||||
|
|
|
@ -40,16 +40,12 @@
|
||||||
(defn set-el [db [_ k v]]
|
(defn set-el [db [_ k v]]
|
||||||
(assoc db k v))
|
(assoc db k v))
|
||||||
|
|
||||||
(register-handler :set
|
(register-handler :set set-el)
|
||||||
debug
|
|
||||||
set-el)
|
|
||||||
|
|
||||||
(defn set-in [db [_ path v]]
|
(defn set-in [db [_ path v]]
|
||||||
(assoc-in db path v))
|
(assoc-in db path v))
|
||||||
|
|
||||||
(register-handler :set-in
|
(register-handler :set-in set-in)
|
||||||
debug
|
|
||||||
set-in)
|
|
||||||
|
|
||||||
(register-handler :set-animation
|
(register-handler :set-animation
|
||||||
(fn [db [_ k v]]
|
(fn [db [_ k v]]
|
||||||
|
|
|
@ -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