fix for https://github.com/status-im/status-react/issues/934 , implemented contacts-list-modal, refactored common styles

This commit is contained in:
Andrey Shovkoplyas 2017-03-23 17:31:22 +03:00 committed by Roman Volosovskyi
parent b8a491e66d
commit 6ca2f61eb3
29 changed files with 298 additions and 189 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon_address_blue.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon_fullscreen_blue.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

View File

@ -15,6 +15,7 @@
[status-im.components.context-menu :refer [menu-context]]
[status-im.contacts.search-results :refer [contacts-search-results]]
[status-im.contacts.views.contact-list :refer [contact-list]]
[status-im.contacts.views.contact-list-modal :refer [contact-list-modal]]
[status-im.contacts.views.new-contact :refer [new-contact]]
[status-im.qr-scanner.screen :refer [qr-scanner]]
[status-im.discover.search-results :refer [discover-search-results]]
@ -153,7 +154,7 @@
:qr-scanner qr-scanner
:qr-code-view qr-code-view
:confirm confirm
:contact-list-modal contact-list)]
:contact-list-modal contact-list-modal)]
[component])]])]]))))})))
(defn init []

View File

@ -140,11 +140,6 @@
:confirm-button-label {:color styles/color-white
:font-size 14
:letter-spacing 0.5}
:action-button-label {:color styles/color-black
:font-size 16
:line-height 24}
:action-button {:height 56}
:separator {:height 0}
:bottom-gradient {:height 3}
:input-label {:left 4}
:input-error-text {:margin-left 4}

View File

@ -1,6 +1,6 @@
(ns status-im.components.action-button.action-button
(:require [status-im.components.action-button.styles :as st]
[status-im.components.common.common :refer [separator]]
[status-im.components.common.common :refer [list-separator]]
[status-im.components.react :refer [view
text
icon
@ -16,4 +16,4 @@
label]]]])
(defn action-separator []
[separator st/action-separator])
[list-separator])

View File

@ -1,30 +1,40 @@
(ns status-im.components.action-button.styles
(:require [status-im.utils.platform :as p]
[status-im.components.styles :refer [color-white
(:require-macros [status-im.utils.styles :refer [defstyle]])
(:require [status-im.components.styles :refer [color-white
color-light-blue-transparent
color-light-blue
color-black]]))
(def action-button
(merge (get-in p/platform-specific [:component-styles :action-button])
{:padding-left 16
:flex-direction :row
:align-items :center}))
(defstyle action-button
{:padding-left 16
:flex-direction :row
:align-items :center
:ios {:height 64}
:android {:height 56}})
(def action-button-icon-container
(merge (get-in p/platform-specific [:component-styles :action-button-icon-container])
{:border-radius 50
:width 40
:height 40
:align-items :center
:justify-content :center}))
(defstyle action-button-icon-container
{:border-radius 50
:width 40
:height 40
:align-items :center
:justify-content :center
:ios {:background-color color-light-blue-transparent}})
(def action-button-label-container
{:padding-left 16})
(def action-button-label
(get-in p/platform-specific [:component-styles :action-button-label]))
(defstyle action-button-label
{:ios {:color color-light-blue
:letter-spacing -0.2
:font-size 17
:line-height 20}
:android {:color color-black
:font-size 16
:line-height 24}})
(defstyle actions-list
{:background-color color-white
:android {:padding-top 8
:padding-bottom 8}})
(def action-separator
{:margin-left 72})

View File

@ -1,17 +1,35 @@
(ns status-im.components.common.common
(:require [status-im.components.react :refer [view linear-gradient]]
(:require [status-im.components.react :refer [view text linear-gradient]]
[status-im.utils.platform :as p]
[status-im.components.common.styles :as st]))
(defn top-shaddow []
[linear-gradient
{:style st/gradient-bottom
:colors st/gradient-bottom-colors}])
(when p/android?
[linear-gradient
{:style st/gradient-bottom
:colors st/gradient-bottom-colors}]))
(defn bottom-shaddow []
[linear-gradient
{:style st/gradient-top
:colors st/gradient-top-colors}])
(when p/android?
[linear-gradient
{:style st/gradient-top
:colors st/gradient-top-colors}]))
(defn separator [style]
[view st/separator-wrapper
[view (merge st/separator style)]])
(defn list-separator []
[separator st/list-separator])
(defn form-title [label & [count-value]]
[view
[view st/form-title-container
[text {:style st/form-title
:font :medium}
label]
(when-not (nil? count-value)
[text {:style st/form-title-count
:font :medium}
count-value])]
[top-shaddow]])

View File

@ -1,6 +1,11 @@
(ns status-im.components.common.styles
(:require-macros [status-im.utils.styles :refer [defstyle]])
(:require [status-im.utils.platform :as p]
[status-im.components.styles :refer [color-white color-light-gray]]))
[status-im.components.styles :refer [color-white
color-light-gray
color-gray5
text4-color
text1-color]]))
(def gradient-top
{:flexDirection :row
@ -24,5 +29,37 @@
(def separator-wrapper
{:background-color color-white})
(def separator
(get-in p/platform-specific [:component-styles :separator]))
(defstyle separator
{:android {:height 0}
:ios {:height 1
:background-color color-gray5
:opacity 0.5}})
(def list-separator
{:margin-left 72})
(defstyle form-title-container
{:padding-left 16
:flex 1
:flex-direction :row
:ios {:background-color color-white
:padding-top 19
:padding-bottom 15
:margin-top 16}
:android {:background-color color-light-gray
:padding-top 25
:padding-bottom 18
:margin-top 0}})
(defstyle form-title
{:ios {:color text1-color
:font-size 16}
:android {:color text4-color
:font-size 14}})
(def form-title-count
(merge form-title
{:opacity 0.6
:padding-left 8
:color text4-color}))

View File

@ -75,13 +75,12 @@
[options-btn group])])
(defn contact-group-form [{:keys [contacts contacts-count group edit? click-handler]}]
(let [shadows? (get-in platform-specific [:group-block-shadows?])
subtitle (:name group)]
(let [subtitle (:name group)]
[view st/contact-group
(when subtitle
[subtitle-view subtitle contacts-count group edit?])
(when (and subtitle shadows?)
[top-shaddow])
(when subtitle
[top-shaddow])
[view st/contacts-list
[view st/contact-list-spacing]
(doall
@ -116,8 +115,7 @@
:uppercase? (get-in platform-specific [:uppercase?])
:font (get-in platform-specific [:component-styles :contacts :show-all-text-font])}
(str (- contacts-count contacts-limit) " " (label :t/more))]]]]])
(when shadows?
[bottom-shaddow])]))
[bottom-shaddow]]))
(defview contact-group-view [{:keys [group] :as params}]
[contacts [:all-added-group-contacts-with-limit (:group-id group) contacts-limit]

View File

@ -31,6 +31,9 @@
(def contacts-list
{:background-color color-white})
(def contacts-list-modal
{:background-color toolbar-background2})
(def empty-contact-groups
(merge contact-groups
{:align-items :center

View File

@ -30,6 +30,11 @@
(sort-contacts)
(reaction)))))
(register-sub :all-added-people-contacts
(fn [_ _]
(let [contacts (subscribe [:all-added-contacts])]
(reaction (remove #(true? (:dapp? %)) @contacts)))))
(defn filter-group-contacts [group-contacts contacts]
(filter #(group-contacts (:whisper-identity %)) contacts))

View File

@ -21,35 +21,11 @@
[status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific]]))
(defn new-group-chat-view []
[view
[touchable-highlight
{:on-press #(dispatch [:open-contact-toggle-list :chat-group])}
[view st/contact-container
[view st/option-inner-container
[view st/option-inner
[image {:source {:uri :icon_private_group_big}
:style st/group-icon}]]
[view st/info-container
[text {:style st/name-text}
(label :t/new-group-chat)]]]]]
[touchable-highlight
{:on-press #(dispatch [:navigate-to :new-public-group])}
[view st/contact-container
[view st/option-inner-container
[view st/option-inner
[image {:source {:uri :icon_public_group_big}
:style st/group-icon}]]
[view st/info-container
[text {:style st/name-text}
(label :t/new-public-group-chat)]]]]]])
(defn render-row [chat-modal click-handler action params group edit?]
(defn render-row [group edit?]
(fn [row _ _]
(list-item
^{:key row}
[contact-view {:contact row
:letter? chat-modal
:extended? edit?
:extend-options (when group
[{:value #(dispatch [:hide-contact row])
@ -57,37 +33,7 @@
{:value #(dispatch [:remove-contact-from-group
(:whisper-identity row)
(:group-id group)])
:text (label :t/remove-from-group)}])
:on-click (when (and (not edit?) click-handler)
#(click-handler row action params))}])))
(defn contact-list-entry [{:keys [click-handler icon icon-style label]}]
[touchable-highlight
{:on-press click-handler}
[view st/contact-container
[view st/contact-inner-container
[image {:source {:uri icon}
:style icon-style}]
[view st/info-container
[text {:style st/name-text
:number-of-lines 1}
label]]]]])
(defn modal-view [action click-handler]
[view
[contact-list-entry {:click-handler #(do
(dispatch [:send-to-webview-bridge
{:event (name :webview-send-transaction)}])
(dispatch [:navigate-back]))
:icon :icon_enter_address
:icon-style st/enter-address-icon
:label (label :t/enter-address)}]
[contact-list-entry {:click-handler #(click-handler :qr-scan action)
:icon :icon_scan_q_r
:icon-style st/scan-qr-icon
:label (label (if (= :request action)
:t/show-qr
:t/scan-qr))}]])
:text (label :t/remove-from-group)}])}])))
(defview contact-list-toolbar-edit [group]
[toolbar {:nav-action (act/back #(dispatch [:set-in [:contact-list-ui-props :edit?] false]))
@ -97,51 +43,37 @@
(or (:name group) (label :t/contacts-group-new-chat)))}])
(defview contact-list-toolbar [group]
[modal [:get :modal]
show-search [:get-in [:toolbar-search :show]]
[show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar-with-search
{:show-search? (= show-search :contact-list)
:search-text search-text
:search-key :contact-list
:title (if-not group
(label :t/contacts)
(or (:name group) (label :t/contacts-group-new-chat)))
(label :t/contacts)
(or (:name group) (label :t/contacts-group-new-chat)))
:search-placeholder (label :t/search-contacts)
:actions (if modal
(act/back #(dispatch [:navigate-back]))
[(act/opts [{:text (label :t/edit)
:value #(dispatch [:set-in [:contact-list-ui-props :edit?] true])}])])}))
:actions [(act/opts [{:text (label :t/edit)
:value #(dispatch [:set-in [:contact-list-ui-props :edit?] true])}])]}))
(defn render-separator [_ row-id _]
(list-item ^{:key row-id}
[separator st/contact-item-separator]))
(defview contacts-list-view [group modal click-handler action edit?]
[contacts [:all-added-group-contacts-filtered (:group-id group)]
params [:get :contacts-click-params]]
(let [show-new-group-chat? (and (= group :people)
(get-in platform-specific [:chats :new-chat-in-toolbar?]))]
(when contacts
[list-view {:dataSource (lw/to-datasource contacts)
:enableEmptySections true
:renderRow (render-row modal click-handler action params group edit?)
:bounces false
:keyboardShouldPersistTaps true
:renderHeader #(list-item
[view
(if show-new-group-chat?
[new-group-chat-view]
[view st/contact-list-spacing])])
:renderFooter #(list-item [view st/contact-list-spacing])
:renderSeparator render-separator
:style st/contacts-list}])))
(defview contacts-list-view [group edit?]
[contacts [:all-added-group-contacts-filtered (:group-id group)]]
[list-view {:dataSource (lw/to-datasource contacts)
:enableEmptySections true
:renderRow (render-row group edit?)
:bounces false
:keyboardShouldPersistTaps true
:renderHeader #(list-item [view st/contact-list-spacing])
:renderFooter #(list-item [view st/contact-list-spacing])
:renderSeparator render-separator
:style st/contacts-list}])
(defview contact-list []
[action [:get :contacts-click-action]
modal [:get :modal]
edit? [:get-in [:contact-list-ui-props :edit?]]
click-handler [:get :contacts-click-handler]
[edit? [:get-in [:contact-list-ui-props :edit?]]
group [:get :contacts-group]
type [:get :group-type]]
[drawer-view
@ -151,7 +83,4 @@
(if edit?
[contact-list-toolbar-edit group]
[contact-list-toolbar group])]
;; todo add stub
(when modal
[modal-view action click-handler])
[contacts-list-view group modal click-handler action edit?]]])
[contacts-list-view group edit?]]])

View File

@ -0,0 +1,90 @@
(ns status-im.contacts.views.contact-list-modal
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.components.common.common :refer [list-separator form-title bottom-shaddow]]
[status-im.components.react :refer [view text
image
icon
touchable-highlight
list-view
list-item]]
[status-im.contacts.views.contact :refer [contact-view]]
[status-im.components.action-button.action-button :refer [action-button
action-separator]]
[status-im.components.action-button.styles :refer [actions-list]]
[status-im.components.text-field.view :refer [text-field]]
[status-im.components.status-bar :refer [status-bar]]
[status-im.components.toolbar-new.view :refer [toolbar-with-search toolbar]]
[status-im.components.toolbar-new.actions :as act]
[status-im.components.toolbar-new.styles :refer [toolbar-background1]]
[status-im.components.drawer.view :refer [drawer-view open-drawer]]
[status-im.components.image-button.view :refer [scan-button]]
[status-im.contacts.styles :as st]
[status-im.utils.listview :as lw]
[status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific]]))
(defn render-separator [_ row-id _]
(list-item ^{:key row-id}
[list-separator]))
(defview contact-list-modal-toolbar []
[show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar-with-search
{:show-search? (= show-search :contact-list)
:search-text search-text
:search-key :contact-list
:title (label :t/contacts)
:search-placeholder (label :t/search-contacts)}))
(defn actions-view [action click-handler]
[view actions-list
[action-button (label :t/enter-address)
:address_blue
#(do
(dispatch [:send-to-webview-bridge
{:event (name :webview-send-transaction)}])
(dispatch [:navigate-back]))]
[action-separator]
(if (= :request action)
[action-button (label :t/show-qr)
:q_r_blue
#(click-handler :qr-scan action)]
[action-button (label :t/scan-qr)
:fullscreen_blue
#(click-handler :qr-scan action)])])
(defn render-row [click-handler action params]
(fn [row _ _]
(list-item
^{:key row}
[contact-view {:contact row
:on-click #(when click-handler
(click-handler row action params))}])))
(defview contact-list-modal []
[contacts [:contacts-filtered :all-added-people-contacts]
click-handler [:get :contacts-click-handler]
action [:get :contacts-click-action]
params [:get :contacts-click-params]]
[drawer-view
[view {:flex 1}
[status-bar]
[contact-list-modal-toolbar]
[list-view {:dataSource (lw/to-datasource contacts)
:enableEmptySections true
:renderRow (render-row click-handler action params)
:bounces false
:keyboardShouldPersistTaps true
:renderHeader #(list-item
[view
[actions-view action click-handler]
[bottom-shaddow]
[form-title (label :t/choose-from-contacts) (count contacts)]
[view st/contact-list-spacing]])
:renderFooter #(list-item [view
[view st/contact-list-spacing]
[bottom-shaddow]])
:renderSeparator render-separator
:style st/contacts-list-modal}]]])

View File

@ -13,6 +13,7 @@
[status-im.components.main-tabs :refer [main-tabs]]
[status-im.contacts.search-results :refer [contacts-search-results]]
[status-im.contacts.views.contact-list :refer [contact-list]]
[status-im.contacts.views.contact-list-modal :refer [contact-list-modal]]
[status-im.contacts.views.new-contact :refer [new-contact]]
[status-im.qr-scanner.screen :refer [qr-scanner]]
[status-im.discover.search-results :refer [discover-search-results]]
@ -135,7 +136,7 @@
:qr-scanner qr-scanner
:qr-code-view qr-code-view
:confirm confirm
:contact-list-modal contact-list)]
:contact-list-modal contact-list-modal)]
[component])]])]))))})))
(defn init []

View File

@ -163,15 +163,6 @@
:font-size 17
:line-height 20
:letter-spacing -0.2}
:action-button-label {:color styles/color-light-blue
:letter-spacing -0.2
:font-size 17
:line-height 20}
:action-button-icon-container {:background-color styles/color-light-blue-transparent}
:action-button {:height 64}
:separator {:height 1
:background-color styles/color-gray5
:opacity 0.5}
:bottom-gradient {:height 1}
:input-label {:left 0}
:input-error-text {:margin-left 0}

View File

@ -34,28 +34,25 @@
[view st/order-item-icon
[icon :grab_gray]]]]))
(defn render-separator [last shadows?]
(defn render-separator [last]
(fn [_ row-id _]
(list-item
(if (= row-id last)
(when shadows?
^{:key "bottom-shaddow"}
[bottom-shaddow])
^{:key "bottom-shaddow"}
[bottom-shaddow]
^{:key row-id}
[view st/order-item-separator-wrapper
[view st/order-item-separator]]))))
(defview reorder-groups []
[groups [:get :contact-groups]
order [:get :groups-order]
shadows? (get-in platform-specific [:group-block-shadows?])]
order [:get :groups-order]]
(let [this (r/current-component)]
[view st/reorder-groups-container
[status-bar]
[toolbar-view]
[view st/reorder-list-container
(when shadows?
[top-shaddow])
[top-shaddow]
[sortable-list-view
{:data groups
:order order
@ -63,5 +60,5 @@
(.forceUpdate this))
:render-row (fn [row]
(sortable-item [group-item row]))
:render-separator (render-separator (last order) shadows?)}]]
:render-separator (render-separator (last order))}]]
[confirm-button (label :t/save) #(dispatch [:save-group-order])]]))

View File

@ -166,46 +166,38 @@
(defview my-profile []
[current-account [:get-current-account]]
(let [shadows? (get-in platform-specific [:group-block-shadows?])]
[view st/profile
[status-bar]
[my-profile-toolbar]
[view st/my-profile-form
[profile-bage current-account]]
(when shadows?
[bottom-shaddow])
[view st/profile-info-container
(when shadows?
[top-shaddow])
[view st/profile-actions-container
[action-button (label :t/share-qr)
:q_r_blue
(show-qr current-account :public-key)]]
[view st/form-separator]
[my-profile-info current-account]
(when shadows?
[bottom-shaddow])]]))
[view st/profile
[status-bar]
[my-profile-toolbar]
[view st/my-profile-form
[profile-bage current-account]]
[bottom-shaddow]
[view st/profile-info-container
[top-shaddow]
[view st/profile-actions-container
[action-button (label :t/share-qr)
:q_r_blue
(show-qr current-account :public-key)]]
[view st/form-separator]
[my-profile-info current-account]
[bottom-shaddow]]])
(defview profile []
[{:keys [pending?
whisper-identity]
:as contact} [:contact]
chat-id [:get :current-chat-id]]
(let [shadows? (get-in platform-specific [:group-block-shadows?])]
[view st/profile
[status-bar]
[toolbar]
[scroll-view
[view st/profile-form
[profile-bage contact]
[add-to-contacts pending? chat-id]]
(when shadows?
[bottom-shaddow])
[view st/profile-info-container
(when shadows?
[top-shaddow])
[profile-actions whisper-identity chat-id]
[view st/form-separator]
[profile-info contact]
(when shadows?
[bottom-shaddow])]]]))
[view st/profile
[status-bar]
[toolbar]
[scroll-view
[view st/profile-form
[profile-bage contact]
[add-to-contacts pending? chat-id]]
[bottom-shaddow]
[view st/profile-info-container
[top-shaddow]
[profile-actions whisper-identity chat-id]
[view st/form-separator]
[profile-info contact]
[bottom-shaddow]]]])