[#3832] Hide tab bar when keyboard visible

This commit is contained in:
kwingram25 2018-04-13 17:17:04 -07:00 committed by Roman Volosovskyi
parent 62af757fa1
commit c145c8a19f
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
5 changed files with 26 additions and 4 deletions

View File

@ -44,13 +44,16 @@
"keyboardDidShow"
(fn [e]
(let [h (.. e -endCoordinates -height)]
(dispatch [:hide-tab-bar])
(when-not (= h @keyboard-height)
(dispatch [:set :keyboard-height h])
(dispatch [:set :keyboard-max-height h])))))
(.addListener react/keyboard
"keyboardDidHide"
#(when-not (= 0 @keyboard-height)
(dispatch [:set :keyboard-height 0])))
(fn [_]
(dispatch [:show-tab-bar])
(when (zero? @keyboard-height)
(dispatch [:set :keyboard-height 0]))))
(.hide react/splash-screen)
(.addEventListener react/app-state "change" app-state-change-handler))
:component-did-mount

View File

@ -21,6 +21,7 @@
(def app-db {:current-public-key nil
:status-module-initialized? (or platform/ios? js/goog.DEBUG)
:keyboard-height 0
:tab-bar-visible? true
:accounts/accounts {}
:navigation-stack '()
:contacts/contacts {}
@ -64,6 +65,7 @@
;;height of native keyboard if shown
(spec/def ::keyboard-height (spec/nilable number?))
(spec/def ::keyboard-max-height (spec/nilable number?))
(spec/def ::tab-bar-visible? (spec/nilable boolean?))
;;:online - presence of internet connection in the phone
(spec/def ::network-status (spec/nilable keyword?))
@ -184,6 +186,7 @@
::status-node-started?
::keyboard-height
::keyboard-max-height
::tab-bar-visible?
::network-status
::mailserver-status
::peers-count

View File

@ -400,3 +400,13 @@
[re-frame/trim-v]
(fn [db [item-id value]]
(assoc-in db [:chat-animations item-id :delete-swiped] value)))
(handlers/register-handler-db
:show-tab-bar
(fn [db _]
(assoc db :tab-bar-visible? true)))
(handlers/register-handler-db
:hide-tab-bar
(fn [db _]
(assoc db :tab-bar-visible? false)))

View File

@ -65,7 +65,8 @@
^{:key view-id} [tab view-id content (= view-id current-view-id) accessibility-label count-subscription])])
(views/defview main-tabs []
(views/letsubs [view-id [:get :view-id]]
(views/letsubs [view-id [:get :view-id]
tab-bar-visible? [:tab-bar-visible?]]
[react/view common.styles/flex
[status-bar.view/status-bar {:type (if (= view-id :wallet) :wallet-tab :main)}]
[react/view common.styles/main-container
@ -93,4 +94,5 @@
{:component profile.user/my-profile
:views :my-profile
:current-view view-id}]]
[tabs view-id]]]))
(when tab-bar-visible?
[tabs view-id])]]))

View File

@ -57,6 +57,10 @@
(fn [sync-state]
(#{:pending :in-progress} sync-state)))
(reg-sub :tab-bar-visible?
(fn [db _]
(get db :tab-bar-visible?)))
(reg-sub :get-screen-params
(fn [db [_ view-id]]
(get-in db [:navigation/screen-params (or view-id (:view-id db))])))