forked from status-im/status-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.cljs
More file actions
51 lines (48 loc) · 1.91 KB
/
core.cljs
File metadata and controls
51 lines (48 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(ns status-im.ios.core
(:require [reagent.core :as reagent]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
status-im.utils.db
status-im.ui.screens.db
status-im.ui.screens.events
status-im.ui.screens.subs
status-im.data-store.core
[status-im.ui.screens.views :as views]
[status-im.ui.components.react :as react]
[status-im.utils.notifications :as notifications]
[status-im.core :as core]
[status-im.utils.instabug :as instabug]
[status-im.utils.snoopy :as snoopy]))
(defn app-state-change-handler [state]
(dispatch [:app-state-change state]))
(defn app-root []
(let [keyboard-height (subscribe [:get :keyboard-height])]
(reagent/create-class
{:component-will-mount
(fn []
(.addListener react/keyboard
"keyboardWillShow"
(fn [e]
(let [h (.. e -endCoordinates -height)]
(when-not (= h @keyboard-height)
(dispatch [:set :keyboard-height h])
(dispatch [:set :keyboard-max-height h])))))
(.addListener react/keyboard
"keyboardWillHide"
#(when-not (= 0 @keyboard-height)
(dispatch [:set :keyboard-height 0])))
(.hide react/splash-screen)
(.addEventListener react/app-state "change" app-state-change-handler))
:component-did-mount
(fn []
(notifications/on-refresh-fcm-token)
(notifications/on-notification))
:component-will-unmount
(fn []
(.stop react/http-bridge)
(.removeEventListener react/app-state "change" app-state-change-handler))
:display-name "root"
:reagent-render views/main})))
(defn init []
(core/init app-root)
(snoopy/subscribe!)
(instabug/init))