Compare commits

...
Author SHA1 Message Date
Ulises M a0720aaadd WIP: underline & quote texts 2023-04-04 13:32:03 -06:00
Ulises M 33c5d57167 WIP: Messages 2023-04-03 15:06:20 -06:00
4 changed files with 37 additions and 28 deletions
+1 -1
View File
@@ -172,4 +172,4 @@
:show-line-numbers false
:style #js {}
:custom-style #js {:backgroundColor nil}}
children])
#_children])
@@ -1,31 +1,42 @@
(ns status-im2.contexts.chat.messages.content.text.view
(:require
[quo2.core :as quo]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[status-im2.contexts.chat.messages.content.text.style :as style]
[status-im2.contexts.chat.messages.link-preview.view :as link-preview]
[utils.re-frame :as rf]
[utils.i18n :as i18n]))
(:require [quo2.core :as quo]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[status-im2.contexts.chat.messages.content.text.style :as style]
[status-im2.contexts.chat.messages.link-preview.view :as link-preview]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- underline [children]
[quo/text {:style {:text-decoration-line :underline}}
children])
;; TODO: ask for an exmaple for multiline quote
(defn- quote [children]
[rn/view {:style {:flex-direction :row}}
[quo/text {:style {:color colors/neutral-40
:margin-right 10}}
"|"]
[quo/text children]])
(defn render-inline
[units {:keys [type literal destination]} chat-id]
(case (keyword type)
:code
(conj units [rn/view {:style (merge style/block (style/code))} [quo/text {:weight :code} literal]])
(conj units [rn/view {:style (merge style/block (style/code))}
[quo/text {:weight :code} literal]])
:emph
(conj units [quo/text {:style {:font-style :italic}} literal])
:strong
(conj units [quo/text {:weight :bold} literal])
(conj units [quote literal])
:strong-emph
(conj units
[quo/text
{:weight :bold
:style {:font-style :italic}} literal])
(conj units [quo/text
{:weight :bold
:style {:font-style :italic}}
literal])
:del
(conj units [quo/text {:style {:text-decoration-line :line-through}} literal])
@@ -38,7 +49,7 @@
destination])
:mention
(conj
(conj ;; TODO: fix vertical alignment in mention
units
[rn/touchable-opacity
{:active-opacity 1
@@ -51,7 +62,6 @@
:edited
(conj units
[quo/text
{:weight :medium
:style {:font-size 11 ; Font-size must be used instead of props or the
@@ -59,6 +69,7 @@
:color (colors/theme-colors colors/neutral-40
colors/neutral-50)}}
literal])
:status-tag
(let [community-id (rf/sub [:community-id-by-chat-id chat-id])]
(conj units
@@ -72,29 +83,27 @@
(conj units literal)))
(defn render-block
[blocks {:keys [type literal children]} chat-id]
(case (keyword type)
:paragraph
(conj blocks
[rn/view {:style style/paragraph}
(reduce
(fn [acc e]
(render-inline acc e chat-id))
(reduce (fn [acc e]
(render-inline acc e chat-id))
[quo/text]
children)])
:edited-block
(conj blocks
[rn/view {:style style/paragraph}
(reduce
(fn [acc e]
(render-inline acc e chat-id))
(reduce (fn [acc e]
(render-inline acc e chat-id))
[quo/text]
children)])
:blockquote
;; TODO: ask for an exmaple for multiline quote
(conj blocks
[rn/view {:style style/quote}
[quo/text literal]])
@@ -117,7 +126,7 @@
(update parsed-text
(dec items-count)
(fn [last-literal]
(update last-literal :children into [{:literal " "} edited-tag])))
(update last-literal :children conj {:literal " "} edited-tag)))
(conj parsed-text {:type :edited-block :children [edited-tag]}))))
(defn render-parsed-text
@@ -127,8 +136,7 @@
(render-block acc e chat-id))
[:<>]
(cond-> (:parsed-text content)
edited-at
add-edited-tag))])
edited-at add-edited-tag))])
(defn text-content
[message-data context]
@@ -115,7 +115,7 @@
:header [list-header chat]
:footer [list-footer chat]
:data messages
:render-data render-data
:render-data render-data ;; TODO: What does this key do?
:render-fn render-fn
:on-viewable-items-changed on-viewable-items-changed
:on-end-reached list-on-end-reached
+1
View File
@@ -228,6 +228,7 @@
(re-frame/subscribe [:chats/joined chat-id])])
(fn [[message-list messages pin-messages loading-messages? synced-from chat-type joined] [_ chat-id]]
;;TODO (perf)
(let [message-list-seq (models.message-list/->seq message-list)]
; Don't show gaps if that's the case as we are still loading messages
(if (and (empty? message-list-seq) loading-messages?)