-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
(ns status-im.ui.screens.chat.message.gap | ||
(:require-macros [status-im.utils.views :as views]) | ||
(:require [status-im.ui.components.react :as react] | ||
[re-frame.core :as re-frame] | ||
[status-im.i18n :as i18n] | ||
[status-im.utils.datetime :as datetime] | ||
[status-im.ui.screens.chat.styles.input.gap :as style])) | ||
|
||
(defn on-press | ||
[ids first-gap? idx list-ref] | ||
(fn [] | ||
(when (and list-ref @list-ref) | ||
(.scrollToIndex @list-ref | ||
#js {:index (max 0 (dec idx)) | ||
:viewOffset 20 | ||
:viewPosition 0.5})) | ||
(if first-gap? | ||
(re-frame/dispatch [:chat.ui/fetch-more]) | ||
(re-frame/dispatch [:chat.ui/fill-gaps ids])))) | ||
|
||
(views/defview gap | ||
[{:keys [gaps first-gap?]} idx list-ref] | ||
(views/letsubs [in-progress? [:chats/fetching-gap-in-progress? | ||
(if first-gap? | ||
[:first-gap] | ||
(:ids gaps))] | ||
connected? [:mailserver/connected?] | ||
range [:chats/range] | ||
intro-status [:chats/current-chat-intro-status]] | ||
(let [ids (:ids gaps) | ||
intro-loading? (= intro-status :loading)] | ||
(when-not (and first-gap? intro-loading?) | ||
[react/view {:style style/gap-container} | ||
[react/touchable-highlight | ||
{:on-press (when (and connected? (not in-progress?)) | ||
(on-press ids first-gap? idx list-ref)) | ||
:style style/touchable} | ||
[react/view {:style style/label-container} | ||
(if in-progress? | ||
[react/activity-indicator] | ||
[react/nested-text | ||
{:style (style/gap-text connected?)} | ||
(i18n/label (if first-gap? | ||
:t/load-more-messages | ||
:t/fetch-messages)) | ||
(when first-gap? | ||
[{:style style/date} | ||
(let [date (datetime/timestamp->long-date | ||
(* 1000 (:lowest-request-from range)))] | ||
(str | ||
"\n" | ||
(i18n/label :t/load-messages-before | ||
{:date date})))])])]]])))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ns status-im.ui.screens.chat.styles.input.gap | ||
(:require [status-im.ui.components.colors :as colors])) | ||
|
||
(def gap-container | ||
{:align-self :stretch | ||
:margin-top 24 | ||
:margin-bottom 24 | ||
:height 48 | ||
:align-items :center | ||
:justify-content :center | ||
:border-color colors/gray-light | ||
:border-top-width 1 | ||
:border-bottom-width 1 | ||
:background-color :white}) | ||
|
||
(def label-container | ||
{:flex 1 | ||
:align-items :center | ||
:justify-content :center | ||
:text-align :center}) | ||
|
||
(defn gap-text [connected?] | ||
{:text-align :center | ||
:color (if connected? | ||
colors/blue | ||
colors/gray)}) | ||
|
||
(def touchable | ||
{:height 48}) | ||
|
||
(def date | ||
{:typography :caption | ||
:color colors/gray}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters