mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-13 10:16:01 +00:00
Messages scroll direction
Former-commit-id: 995738ba19bf614e753fadf47fcccb29ecca8643
This commit is contained in:
parent
8fa81ec0ff
commit
5cd48e241a
@ -3,7 +3,8 @@
|
|||||||
"interface": "om-next",
|
"interface": "om-next",
|
||||||
"androidHost": "10.0.3.2",
|
"androidHost": "10.0.3.2",
|
||||||
"modules": [
|
"modules": [
|
||||||
"react-native-contacts"
|
"react-native-contacts",
|
||||||
|
"react-native-invertible-scroll-view"
|
||||||
],
|
],
|
||||||
"imageDirs": [
|
"imageDirs": [
|
||||||
"images"
|
"images"
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"react-native": "0.20.0",
|
"react-native": "0.20.0",
|
||||||
"react-native-contacts": "^0.2.1",
|
"react-native-contacts": "^0.2.1",
|
||||||
"react-native-i18n": "0.0.8",
|
"react-native-i18n": "0.0.8",
|
||||||
|
"react-native-invertible-scroll-view": "^0.2.0",
|
||||||
"web3": "^0.15.2"
|
"web3": "^0.15.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(ns messenger.android.chat
|
(ns messenger.android.chat
|
||||||
(:require-macros
|
(:require-macros
|
||||||
[natal-shell.components :refer [view text image touchable-highlight list-view
|
[natal-shell.components :refer [view text image touchable-highlight list-view
|
||||||
toolbar-android]]
|
text-input toolbar-android]]
|
||||||
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
||||||
[natal-shell.core :refer [with-error-view]]
|
[natal-shell.core :refer [with-error-view]]
|
||||||
[natal-shell.alert :refer [alert]])
|
[natal-shell.alert :refer [alert]])
|
||||||
@ -10,6 +10,8 @@
|
|||||||
[messenger.state :as state]
|
[messenger.state :as state]
|
||||||
[messenger.android.resources :as res]))
|
[messenger.android.resources :as res]))
|
||||||
|
|
||||||
|
(set! js/InvertibleScrollView (js/require "react-native-invertible-scroll-view"))
|
||||||
|
|
||||||
(defn nav-pop [nav]
|
(defn nav-pop [nav]
|
||||||
(binding [state/*nav-render* false]
|
(binding [state/*nav-render* false]
|
||||||
(.pop nav)))
|
(.pop nav)))
|
||||||
@ -20,12 +22,15 @@
|
|||||||
[:message/by-id id])
|
[:message/by-id id])
|
||||||
static om/IQuery
|
static om/IQuery
|
||||||
(query [this]
|
(query [this]
|
||||||
'[:id :body :outgoing :delivery-status :datetime])
|
'[:id :body :outgoing :delivery-status :date :new-day])
|
||||||
Object
|
Object
|
||||||
(render [this]
|
(render
|
||||||
(let [{:keys [id body outgoing delivery-status datetime]}
|
[this]
|
||||||
|
(let [{:keys [id body outgoing delivery-status date new-day]}
|
||||||
(om/props this)]
|
(om/props this)]
|
||||||
(view {:height 70}
|
(view {:paddingHorizontal 15}
|
||||||
|
;;; date
|
||||||
|
(when new-day
|
||||||
(text {:style {:marginVertical 10
|
(text {:style {:marginVertical 10
|
||||||
:fontFamily "Avenir-Roman"
|
:fontFamily "Avenir-Roman"
|
||||||
:fontSize 11
|
:fontSize 11
|
||||||
@ -34,9 +39,14 @@
|
|||||||
:lineHeight 15
|
:lineHeight 15
|
||||||
:textAlign "center"
|
:textAlign "center"
|
||||||
:opacity 0.8}}
|
:opacity 0.8}}
|
||||||
datetime)
|
date))
|
||||||
|
;;; body
|
||||||
|
(view {:style (merge {:width 260
|
||||||
|
:marginVertical 5}
|
||||||
|
(if outgoing
|
||||||
|
{:alignSelf "flex-end"}
|
||||||
|
{:alignSelf "flex-start"}))}
|
||||||
(view {:style (merge {:borderRadius 6
|
(view {:style (merge {:borderRadius 6
|
||||||
:marginVertical 5
|
|
||||||
:paddingVertical 12
|
:paddingVertical 12
|
||||||
:paddingHorizontal 16}
|
:paddingHorizontal 16}
|
||||||
(if outgoing
|
(if outgoing
|
||||||
@ -47,7 +57,7 @@
|
|||||||
(text {:style {:fontSize 14
|
(text {:style {:fontSize 14
|
||||||
:fontFamily "Avenir-Roman"
|
:fontFamily "Avenir-Roman"
|
||||||
:color "#4A5258"}}
|
:color "#4A5258"}}
|
||||||
body))))))
|
body)))))))
|
||||||
|
|
||||||
(def message (om/factory Message {:keyfn :id}))
|
(def message (om/factory Message {:keyfn :id}))
|
||||||
|
|
||||||
@ -56,10 +66,13 @@
|
|||||||
|
|
||||||
(defn generate-message [n]
|
(defn generate-message [n]
|
||||||
{:id n
|
{:id n
|
||||||
:body "This is a text. This is a text."
|
:body (if (= (rem n 3) 0)
|
||||||
|
(apply str n "." (repeat 5 " This is a text."))
|
||||||
|
(str n ". This is a text."))
|
||||||
:outgoing (< (rand) 0.5)
|
:outgoing (< (rand) 0.5)
|
||||||
:delivery-status (if (< (rand) 0.5) :delivered :seen)
|
:delivery-status (if (< (rand) 0.5) :delivered :seen)
|
||||||
:datetime "15:30"})
|
:date "TODAY"
|
||||||
|
:new-day (= (rem n 3) 0)})
|
||||||
|
|
||||||
(defn generate-messages [n]
|
(defn generate-messages [n]
|
||||||
(map generate-message (range 1 (inc n))))
|
(map generate-message (range 1 (inc n))))
|
||||||
@ -67,16 +80,21 @@
|
|||||||
(defn load-messages []
|
(defn load-messages []
|
||||||
(clone-with-rows (data-source {:rowHasChanged (fn [row1 row2]
|
(clone-with-rows (data-source {:rowHasChanged (fn [row1 row2]
|
||||||
(not= row1 row2))})
|
(not= row1 row2))})
|
||||||
(vec (generate-messages 10))))
|
(vec (generate-messages 100))))
|
||||||
|
|
||||||
|
(defui NewMessage
|
||||||
|
Object
|
||||||
|
(render
|
||||||
|
[this]
|
||||||
|
(view {}
|
||||||
|
(text-input {}))))
|
||||||
|
|
||||||
|
(def new-message (om/factory NewMessage))
|
||||||
|
|
||||||
(defui Chat
|
(defui Chat
|
||||||
;; static om/IQuery
|
|
||||||
;; (query [this]
|
|
||||||
;; '[:contacts-ds])
|
|
||||||
Object
|
Object
|
||||||
;; (componentDidMount [this]
|
(render
|
||||||
;; (load-contacts))
|
[this]
|
||||||
(render [this]
|
|
||||||
(let [{:keys [nav]} (om/get-computed this)
|
(let [{:keys [nav]} (om/get-computed this)
|
||||||
messages-ds (load-messages)]
|
messages-ds (load-messages)]
|
||||||
(view {:style {:flex 1}}
|
(view {:style {:flex 1}}
|
||||||
@ -91,7 +109,13 @@
|
|||||||
:onIconClicked (fn []
|
:onIconClicked (fn []
|
||||||
(nav-pop nav))})
|
(nav-pop nav))})
|
||||||
(list-view {:dataSource messages-ds
|
(list-view {:dataSource messages-ds
|
||||||
|
:renderScrollComponent
|
||||||
|
(fn [props]
|
||||||
|
(js/React.createElement js/InvertibleScrollView
|
||||||
|
(clj->js (merge (js->clj props)
|
||||||
|
{:inverted true}))))
|
||||||
:renderRow render-row
|
:renderRow render-row
|
||||||
:style {}})))))
|
:style {}})
|
||||||
|
(new-message)))))
|
||||||
|
|
||||||
(def chat (om/factory Chat))
|
(def chat (om/factory Chat))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user