-
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
18 changed files
with
263 additions
and
303 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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,72 +1,63 @@ | ||
(ns status-im.chat.views.input.suggestions | ||
(:require-macros [status-im.utils.views :refer [defview]]) | ||
(:require [re-frame.core :refer [subscribe dispatch]] | ||
[status-im.ui.components.react :refer [view | ||
scroll-view | ||
touchable-highlight | ||
text | ||
icon]] | ||
[status-im.data-store.messages :as messages] | ||
(:require [re-frame.core :as re-frame] | ||
[status-im.ui.components.react :as react] | ||
[status-im.chat.styles.input.suggestions :as style] | ||
[status-im.chat.constants :as const] | ||
[status-im.chat.views.input.animations.expandable :refer [expandable-view]] | ||
[status-im.chat.views.input.utils :as input-utils] | ||
[status-im.i18n :refer [label]] | ||
[taoensso.timbre :as log] | ||
[status-im.chat.utils :as chat-utils])) | ||
[status-im.chat.views.input.animations.expandable :as expandable] | ||
[status-im.chat.utils :as chat.utils] | ||
[status-im.i18n :as i18n])) | ||
|
||
(defn suggestion-item [{:keys [on-press name description last?]}] | ||
[touchable-highlight {:on-press on-press} | ||
[view (style/item-suggestion-container last?) | ||
[view {:style style/item-suggestion-name} | ||
[text {:style style/item-suggestion-name-text | ||
:font :roboto-mono} name]] | ||
[text {:style style/item-suggestion-description | ||
:number-of-lines 2} | ||
[react/touchable-highlight {:on-press on-press} | ||
[react/view (style/item-suggestion-container last?) | ||
[react/view {:style style/item-suggestion-name} | ||
[react/text {:style style/item-suggestion-name-text | ||
:font :roboto-mono} name]] | ||
[react/text {:style style/item-suggestion-description | ||
:number-of-lines 2} | ||
description]]]) | ||
|
||
(defview response-item [{:keys [name description] | ||
{:keys [type message-id]} :request :as command} last?] | ||
[{:keys [chat-id]} [:get-current-chat]] | ||
{:keys [message-id]} :request :as command} last?] | ||
[{{:keys [params]} :content} [:get-current-chat-message message-id]] | ||
[suggestion-item | ||
{:on-press #(let [{:keys [params]} (messages/get-message-content-by-id message-id) | ||
metadata (assoc params :to-message-id message-id)] | ||
(dispatch [:select-chat-input-command command metadata])) | ||
:name (chat-utils/command-name command) | ||
{:on-press #(let [metadata (assoc params :to-message-id message-id)] | ||
(re-frame/dispatch [:select-chat-input-command command metadata])) | ||
:name (chat.utils/command-name command) | ||
:description description | ||
:last? last?}]) | ||
|
||
(defn command-item [{:keys [name description bot] :as command} last?] | ||
[suggestion-item | ||
{:on-press #(dispatch [:select-chat-input-command command nil]) | ||
:name (chat-utils/command-name command) | ||
{:on-press #(re-frame/dispatch [:select-chat-input-command command nil]) | ||
:name (chat.utils/command-name command) | ||
:description description | ||
:last? last?}]) | ||
|
||
(defn item-title [top-padding? s] | ||
[view (style/item-title-container top-padding?) | ||
[text {:style style/item-title-text} | ||
s]]) | ||
(defn item-title [top-padding? title] | ||
[react/view (style/item-title-container top-padding?) | ||
[react/text {:style style/item-title-text} | ||
title]]) | ||
|
||
(defview suggestions-view [] | ||
[show-suggestions? [:show-suggestions?] | ||
responses [:get-available-responses] | ||
commands [:get-available-commands]] | ||
(when show-suggestions? | ||
[expandable-view {:key :suggestions | ||
:draggable? false | ||
:height 212} | ||
[view {:flex 1} | ||
[scroll-view {:keyboardShouldPersistTaps :always} | ||
[expandable/expandable-view {:key :suggestions | ||
:draggable? false | ||
:height 212} | ||
[react/view {:flex 1} | ||
[react/scroll-view {:keyboardShouldPersistTaps :always} | ||
(when (seq responses) | ||
[view | ||
[item-title false (label :t/suggestions-requests)] | ||
[react/view | ||
[item-title false (i18n/label :t/suggestions-requests)] | ||
(for [[i response] (map-indexed vector responses)] | ||
^{:key i} | ||
[response-item response (= i (dec (count responses)))])]) | ||
(when (seq commands) | ||
[view | ||
[item-title (seq responses) (label :t/suggestions-commands)] | ||
[react/view | ||
[item-title (seq responses) (i18n/label :t/suggestions-commands)] | ||
(for [[i command] (map-indexed vector commands)] | ||
^{:key i} | ||
[command-item command (= i (dec (count commands)))])])]]])) |
Oops, something went wrong.