@codeleap/mobile 2.3.5 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/components/ActionIcon/index.tsx +0 -32
- package/src/components/ActionIcon/styles.ts +0 -97
- package/src/components/ActivityIndicator/index.tsx +0 -50
- package/src/components/ActivityIndicator/styles.ts +0 -68
- package/src/components/Animated.tsx +0 -34
- package/src/components/AutoComplete/index.tsx +0 -163
- package/src/components/AutoComplete/styles.ts +0 -44
- package/src/components/Backdrop/index.tsx +0 -48
- package/src/components/Backdrop/styles.ts +0 -33
- package/src/components/Button/index.tsx +0 -155
- package/src/components/Button/styles.ts +0 -129
- package/src/components/Calendar/index.tsx +0 -65
- package/src/components/Calendar/style.ts +0 -35
- package/src/components/Calendar/types.ts +0 -102
- package/src/components/Checkbox/index.tsx +0 -91
- package/src/components/Checkbox/styles.ts +0 -81
- package/src/components/ContentView/index.tsx +0 -63
- package/src/components/ContentView/styles.ts +0 -24
- package/src/components/Drawer/index.tsx +0 -33
- package/src/components/Drawer/styles.ts +0 -43
- package/src/components/EmptyPlaceholder/index.tsx +0 -88
- package/src/components/EmptyPlaceholder/styles.ts +0 -58
- package/src/components/FileInput/index.tsx +0 -181
- package/src/components/FileInput/styles.ts +0 -15
- package/src/components/Grid/index.tsx +0 -117
- package/src/components/Grid/styles.ts +0 -11
- package/src/components/Icon/index.tsx +0 -69
- package/src/components/Icon/styles.ts +0 -57
- package/src/components/Image/index.tsx +0 -91
- package/src/components/Image/styles.ts +0 -20
- package/src/components/ImageView/Spotlight.tsx +0 -157
- package/src/components/ImageView/component.tsx +0 -38
- package/src/components/ImageView/index.ts +0 -2
- package/src/components/InputLabel/index.tsx +0 -38
- package/src/components/InputLabel/styles.ts +0 -19
- package/src/components/List/PaginationIndicator.tsx +0 -71
- package/src/components/List/index.tsx +0 -114
- package/src/components/List/styles.ts +0 -19
- package/src/components/Modal/index.tsx +0 -218
- package/src/components/Modal/styles.ts +0 -153
- package/src/components/MultiSelect/index.tsx +0 -138
- package/src/components/MultiSelect/styles.ts +0 -18
- package/src/components/MultiSelect/types.ts +0 -42
- package/src/components/Navigation/Navigation.tsx +0 -54
- package/src/components/Navigation/constants.ts +0 -8
- package/src/components/Navigation/index.tsx +0 -3
- package/src/components/Navigation/types.ts +0 -35
- package/src/components/Navigation/utils.tsx +0 -57
- package/src/components/Pager/index.tsx +0 -121
- package/src/components/Pager/styles.ts +0 -81
- package/src/components/RadioInput/index.tsx +0 -106
- package/src/components/RadioInput/styles.ts +0 -67
- package/src/components/Scroll/index.tsx +0 -124
- package/src/components/Scroll/styles.ts +0 -18
- package/src/components/Sections/index.tsx +0 -91
- package/src/components/SegmentedControl/index.tsx +0 -204
- package/src/components/SegmentedControl/styles.ts +0 -89
- package/src/components/Select/index.tsx +0 -167
- package/src/components/Select/styles.ts +0 -62
- package/src/components/Select/types.ts +0 -43
- package/src/components/Slider/Mark.tsx +0 -46
- package/src/components/Slider/Thumb.tsx +0 -29
- package/src/components/Slider/index.tsx +0 -130
- package/src/components/Slider/styles.ts +0 -76
- package/src/components/Slider/types.ts +0 -30
- package/src/components/Switch/index.tsx +0 -91
- package/src/components/Switch/styles.ts +0 -38
- package/src/components/Text/index.tsx +0 -123
- package/src/components/Text/styles.ts +0 -50
- package/src/components/TextInput/index.tsx +0 -319
- package/src/components/TextInput/styles.ts +0 -127
- package/src/components/Touchable/index.tsx +0 -174
- package/src/components/Touchable/styles.ts +0 -28
- package/src/components/View/index.tsx +0 -103
- package/src/components/View/styles.ts +0 -24
- package/src/components/components.ts +0 -42
- package/src/components/defaultStyles.ts +0 -62
- package/src/components/legacy/Modal/index.tsx +0 -163
- package/src/components/legacy/Modal/styles.ts +0 -125
- package/src/components/legacy/Pager/index.tsx +0 -242
- package/src/components/legacy/Pager/styles.ts +0 -51
- package/src/components/legacy/index.ts +0 -2
- package/src/modules/documentPicker.ts +0 -7
- package/src/modules/fastImage.ts +0 -2
- package/src/modules/imageCropPicker.d.ts +0 -497
- package/src/modules/index.d.ts +0 -682
- package/src/modules/reactNavigation.ts +0 -15
- package/src/modules/textInputMask.ts +0 -11
- package/src/modules/types/documentPicker.d.ts +0 -215
- package/src/modules/types/fileTypes.ts +0 -138
- package/src/modules/types/textInputMask.ts +0 -9
- package/src/types/index.ts +0 -1
- package/src/types/utility.ts +0 -9
- package/src/utils/KeyboardAware/context.tsx +0 -75
- package/src/utils/KeyboardAware/index.ts +0 -17
- package/src/utils/KeyboardAware/keyboardHooks.ts +0 -124
- package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +0 -4
- package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +0 -618
- package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +0 -13
- package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +0 -6
- package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +0 -6
- package/src/utils/KeyboardAware/types.ts +0 -159
- package/src/utils/ModalManager/components.tsx +0 -112
- package/src/utils/ModalManager/context.tsx +0 -260
- package/src/utils/ModalManager/index.ts +0 -16
- package/src/utils/OSAlert.ts +0 -180
- package/src/utils/PermissionManager/context.tsx +0 -302
- package/src/utils/PermissionManager/index.ts +0 -20
- package/src/utils/PermissionManager/types.ts +0 -24
- package/src/utils/hooks.ts +0 -163
- package/src/utils/index.ts +0 -11
- package/src/utils/input.ts +0 -51
- package/src/utils/misc.ts +0 -83
- package/src/utils/notifications.ts +0 -206
- package/src/utils/theme.ts +0 -58
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { FunctionType, silentLogger } from '@codeleap/common'
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import { firebase, FirebaseMessagingTypes } from '@react-native-firebase/messaging'
|
|
4
|
-
|
|
5
|
-
const messaging = firebase.messaging
|
|
6
|
-
|
|
7
|
-
const MODULE = 'Notifications'
|
|
8
|
-
|
|
9
|
-
export type Message = FirebaseMessagingTypes.RemoteMessage
|
|
10
|
-
export type MessageType = 'foreground' | 'background' | 'press' | 'initial'
|
|
11
|
-
|
|
12
|
-
export type NotificationHandler = FunctionType<[message: Message, type: MessageType], any>
|
|
13
|
-
|
|
14
|
-
export type HandleNotificationParam = {
|
|
15
|
-
data: Message
|
|
16
|
-
type: MessageType
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type NotificationStateChangeListener = FunctionType<[isInitialized: boolean, token?: string], any>
|
|
20
|
-
export class NotificationManager {
|
|
21
|
-
|
|
22
|
-
stateChangeListeners:NotificationStateChangeListener[] = []
|
|
23
|
-
|
|
24
|
-
messageListeners:NotificationHandler[] = []
|
|
25
|
-
|
|
26
|
-
_initialized = false
|
|
27
|
-
|
|
28
|
-
unsubscribeFromMessage = null
|
|
29
|
-
|
|
30
|
-
unsubscribeFromBackgroundMessage = null
|
|
31
|
-
|
|
32
|
-
unsubscribeFromPress = null
|
|
33
|
-
|
|
34
|
-
_currentToken = null
|
|
35
|
-
|
|
36
|
-
_initialNoficationHandled = false
|
|
37
|
-
|
|
38
|
-
constructor(private logger = silentLogger, public autoHandleInitialNotification = true) {
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async init() {
|
|
42
|
-
// return
|
|
43
|
-
if (this.initialized) return
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
|
|
47
|
-
await messaging().registerDeviceForRemoteMessages()
|
|
48
|
-
// logger.log('firebase registeted', '', MODULE)
|
|
49
|
-
|
|
50
|
-
const token = await messaging().getToken()
|
|
51
|
-
// logger.log('init token', { token }, MODULE)
|
|
52
|
-
|
|
53
|
-
if (token) {
|
|
54
|
-
this.currentToken = token
|
|
55
|
-
|
|
56
|
-
this.initialized = true
|
|
57
|
-
} else {
|
|
58
|
-
this.currentToken = null
|
|
59
|
-
this.initialized = false
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
messaging().onTokenRefresh(newToken => {
|
|
63
|
-
// logger.log('onTokenRefresh', { newToken }, MODULE)
|
|
64
|
-
if (token) {
|
|
65
|
-
this.currentToken = newToken
|
|
66
|
-
|
|
67
|
-
this.initialized = true
|
|
68
|
-
} else {
|
|
69
|
-
this.currentToken = null
|
|
70
|
-
this.initialized = false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
})
|
|
74
|
-
// logger.log('init success', {}, MODULE)
|
|
75
|
-
} catch (e) {
|
|
76
|
-
this.logger.error('Failed to initialize notification services', e, MODULE)
|
|
77
|
-
// OSAlert.error({ title: 'Failed to initialize notification services' })
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async deinit() {
|
|
82
|
-
[
|
|
83
|
-
this.unsubscribeFromMessage,
|
|
84
|
-
this.unsubscribeFromBackgroundMessage,
|
|
85
|
-
this.unsubscribeFromPress,
|
|
86
|
-
].forEach(unsubscribe => {
|
|
87
|
-
if (unsubscribe) {
|
|
88
|
-
unsubscribe()
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
this.initialized = false
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private async handleNotification(args:HandleNotificationParam) {
|
|
96
|
-
for (const listener of this.messageListeners) {
|
|
97
|
-
await listener(args.data, args.type)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
get currentToken() {
|
|
102
|
-
return this._currentToken
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
set currentToken(token: string) {
|
|
106
|
-
this._currentToken = token
|
|
107
|
-
this.triggerStateChange()
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
get initialized() {
|
|
111
|
-
return this._initialized
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
set initialized(to:boolean) {
|
|
115
|
-
|
|
116
|
-
if (to) {
|
|
117
|
-
this.logger.info('Initialized', '', MODULE)
|
|
118
|
-
this.unsubscribeFromMessage = messaging().onMessage((msg) => {
|
|
119
|
-
this.handleNotification({
|
|
120
|
-
data: msg,
|
|
121
|
-
type: 'foreground',
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
this.unsubscribeFromBackgroundMessage = messaging().setBackgroundMessageHandler(async (msg) => {
|
|
126
|
-
this.handleNotification({
|
|
127
|
-
data: msg,
|
|
128
|
-
type: 'background',
|
|
129
|
-
})
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
this.unsubscribeFromPress = messaging().onNotificationOpenedApp(msg => {
|
|
133
|
-
this.logger.info('Notification press', msg, MODULE)
|
|
134
|
-
this.handleNotification({
|
|
135
|
-
data: msg,
|
|
136
|
-
type: 'press',
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
if (!this._initialNoficationHandled && this.autoHandleInitialNotification) {
|
|
141
|
-
this.getInitialNotification().then(msg => {
|
|
142
|
-
if (!msg.data) return
|
|
143
|
-
this.logger.info('Notification initial', msg, MODULE)
|
|
144
|
-
this.handleNotification(msg).then(() => {
|
|
145
|
-
this._initialNoficationHandled = true
|
|
146
|
-
}).catch(e => {
|
|
147
|
-
this._initialNoficationHandled = true
|
|
148
|
-
this.logger.error('Error handling initial notification', e, MODULE)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
this.unsubscribeFromMessage = null
|
|
154
|
-
|
|
155
|
-
this.unsubscribeFromBackgroundMessage = null
|
|
156
|
-
|
|
157
|
-
this.unsubscribeFromPress = null
|
|
158
|
-
|
|
159
|
-
this.logger.info('Deinitialized', '', MODULE)
|
|
160
|
-
}
|
|
161
|
-
this._initialized = to
|
|
162
|
-
|
|
163
|
-
this.triggerStateChange()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
onNotification(handler:NotificationHandler) {
|
|
167
|
-
const newLen = this.messageListeners.push(handler)
|
|
168
|
-
|
|
169
|
-
return () => {
|
|
170
|
-
this.messageListeners.splice(newLen - 1)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private triggerStateChange() {
|
|
175
|
-
this.stateChangeListeners.forEach(l => {
|
|
176
|
-
l(this._initialized, this.currentToken)
|
|
177
|
-
})
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
onStateChange(handler:NotificationStateChangeListener) {
|
|
181
|
-
const newLen = this.stateChangeListeners.push(handler)
|
|
182
|
-
|
|
183
|
-
return () => {
|
|
184
|
-
this.stateChangeListeners.splice(newLen - 1)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async getInitialNotification():Promise<HandleNotificationParam> {
|
|
190
|
-
try {
|
|
191
|
-
|
|
192
|
-
const msg = await messaging().getInitialNotification()
|
|
193
|
-
return {
|
|
194
|
-
data: msg as Message,
|
|
195
|
-
type: 'initial',
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
} catch (e) {
|
|
199
|
-
return {
|
|
200
|
-
data: null,
|
|
201
|
-
type: 'initial',
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
package/src/utils/theme.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Platform, Dimensions, StatusBar, StyleSheet } from 'react-native'
|
|
2
|
-
import DeviceInfo from 'react-native-device-info'
|
|
3
|
-
|
|
4
|
-
type AppValues = {
|
|
5
|
-
headerHeight: number
|
|
6
|
-
tabBarHeight: number
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function getMobileThemeValues(initialWindowMetrics, values: AppValues) {
|
|
10
|
-
const screenDimensions = Dimensions.get('screen')
|
|
11
|
-
|
|
12
|
-
const hasNotch = Platform.OS === 'ios' ? (Dimensions.get('window').height >= 812) : (initialWindowMetrics?.insets?.top > 24 || StatusBar.currentHeight > 24)
|
|
13
|
-
const hasIsland = DeviceInfo.hasDynamicIsland()
|
|
14
|
-
const bottomNavHeight = Platform.OS === 'android' ? initialWindowMetrics?.insets?.bottom : 0
|
|
15
|
-
|
|
16
|
-
const prefersConstantNavigationBar = bottomNavHeight > 0
|
|
17
|
-
|
|
18
|
-
const safeAreaTop = Platform.OS === 'ios' ? (hasNotch ? 34 + (hasIsland ? 12 : 0) : 20) : StatusBar.currentHeight
|
|
19
|
-
|
|
20
|
-
const safeAreaBottom = (hasNotch && !prefersConstantNavigationBar ? 20 : 0)
|
|
21
|
-
return {
|
|
22
|
-
...screenDimensions,
|
|
23
|
-
|
|
24
|
-
pixel: StyleSheet.hairlineWidth,
|
|
25
|
-
hasNotch,
|
|
26
|
-
hasIsland,
|
|
27
|
-
prefersConstantNavigationBar,
|
|
28
|
-
safeAreaTop,
|
|
29
|
-
safeAreaBottom,
|
|
30
|
-
keyboardVerticalOffset: Platform.OS === 'ios' ? 57 : 47,
|
|
31
|
-
get headerHeight() { return values.headerHeight + safeAreaTop },
|
|
32
|
-
get tabBarHeight() { return values.tabBarHeight + (prefersConstantNavigationBar ? 0 : this.safeAreaBottom) },
|
|
33
|
-
bottomNavHeight,
|
|
34
|
-
get window() {
|
|
35
|
-
return {
|
|
36
|
-
height: screenDimensions.height - (bottomNavHeight + safeAreaTop),
|
|
37
|
-
width: screenDimensions.width,
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
transitions: {
|
|
41
|
-
modal: {
|
|
42
|
-
duration: 100,
|
|
43
|
-
type: 'timing',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
buttons: {
|
|
47
|
-
small: {
|
|
48
|
-
height: 40,
|
|
49
|
-
},
|
|
50
|
-
default: {
|
|
51
|
-
height: 50,
|
|
52
|
-
},
|
|
53
|
-
large: {
|
|
54
|
-
height: 60,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
}
|
|
58
|
-
}
|