@planningcenter/chat-react-native 4.5.0-rc.8 → 4.5.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenLayout.d.ts","sourceRoot":"","sources":["../../src/navigation/screenLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"screenLayout.d.ts","sourceRoot":"","sources":["../../src/navigation/screenLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;CAAE,2CAY1E;AAED,wBAAgB,8BAA8B,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;CAAE,2CAQ5F"}
|
|
@@ -2,19 +2,22 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
2
2
|
import { useRoute } from '@react-navigation/native';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Suspense } from 'react';
|
|
5
|
-
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
6
6
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
7
7
|
import { DefaultLoading } from '../components/page/loading';
|
|
8
8
|
import { PageErrorBoundary } from '../components/page/page_error_boundary';
|
|
9
9
|
import { ChatAccessGate } from './chat_access_gate';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export function ScreenLayout(t0) {
|
|
12
|
-
const $ = _c(
|
|
12
|
+
const $ = _c(10);
|
|
13
13
|
const {
|
|
14
14
|
children
|
|
15
15
|
} = t0;
|
|
16
16
|
const route = useRoute();
|
|
17
17
|
const styles = useStyles();
|
|
18
|
+
const {
|
|
19
|
+
fontScale
|
|
20
|
+
} = useWindowDimensions();
|
|
18
21
|
let t1;
|
|
19
22
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
20
23
|
t1 = /*#__PURE__*/_jsx(DefaultLoading, {});
|
|
@@ -34,28 +37,29 @@ export function ScreenLayout(t0) {
|
|
|
34
37
|
t2 = $[2];
|
|
35
38
|
}
|
|
36
39
|
let t3;
|
|
37
|
-
if ($[3] !== styles.screen || $[
|
|
40
|
+
if ($[3] !== fontScale || $[4] !== styles.screen || $[5] !== t2) {
|
|
38
41
|
t3 = /*#__PURE__*/_jsx(View, {
|
|
39
42
|
style: styles.screen,
|
|
40
43
|
children: t2
|
|
41
|
-
});
|
|
42
|
-
$[3] =
|
|
43
|
-
$[4] =
|
|
44
|
-
$[5] =
|
|
44
|
+
}, fontScale);
|
|
45
|
+
$[3] = fontScale;
|
|
46
|
+
$[4] = styles.screen;
|
|
47
|
+
$[5] = t2;
|
|
48
|
+
$[6] = t3;
|
|
45
49
|
} else {
|
|
46
|
-
t3 = $[
|
|
50
|
+
t3 = $[6];
|
|
47
51
|
}
|
|
48
52
|
let t4;
|
|
49
|
-
if ($[
|
|
53
|
+
if ($[7] !== route.name || $[8] !== t3) {
|
|
50
54
|
t4 = /*#__PURE__*/_jsx(PageErrorBoundary, {
|
|
51
55
|
screenName: route.name,
|
|
52
56
|
children: t3
|
|
53
57
|
});
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
58
|
+
$[7] = route.name;
|
|
59
|
+
$[8] = t3;
|
|
60
|
+
$[9] = t4;
|
|
57
61
|
} else {
|
|
58
|
-
t4 = $[
|
|
62
|
+
t4 = $[9];
|
|
59
63
|
}
|
|
60
64
|
return t4;
|
|
61
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenLayout.js","names":["useRoute","React","Suspense","StyleSheet","View","useSafeAreaInsets","DefaultLoading","PageErrorBoundary","ChatAccessGate","jsx","_jsx","ScreenLayout","t0","$","_c","children","route","styles","useStyles","t1","Symbol","for","t2","fallback","t3","screen","style","t4","name","screenName","ScreenLayoutWithChatAccessGate","insets","left","right","create","flex","paddingLeft","paddingRight"],"sources":["../../src/navigation/screenLayout.tsx"],"sourcesContent":["import { useRoute } from '@react-navigation/native'\nimport React from 'react'\nimport { Suspense } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { DefaultLoading } from '../components/page/loading'\nimport { PageErrorBoundary } from '../components/page/page_error_boundary'\nimport { ChatAccessGate } from './chat_access_gate'\n\nexport function ScreenLayout({ children }: { children: React.ReactElement }) {\n const route = useRoute()\n const styles = useStyles()\n\n return (\n <PageErrorBoundary screenName={route.name}>\n <View style={styles.screen}>\n <Suspense fallback={<DefaultLoading />}>{children}</Suspense>\n </View>\n </PageErrorBoundary>\n )\n}\n\nexport function ScreenLayoutWithChatAccessGate({ children }: { children: React.ReactElement }) {\n return (\n <ScreenLayout>\n <ChatAccessGate>\n <Suspense fallback={<DefaultLoading />}>{children}</Suspense>\n </ChatAccessGate>\n </ScreenLayout>\n )\n}\n\nconst useStyles = () => {\n const insets = useSafeAreaInsets()\n\n return StyleSheet.create({\n screen: {\n flex: 1,\n paddingLeft: insets.left,\n paddingRight: insets.right,\n },\n })\n}\n"],"mappings":";AAAA,SAASA,QAAQ,QAAQ,0BAA0B;AACnD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"file":"screenLayout.js","names":["useRoute","React","Suspense","StyleSheet","useWindowDimensions","View","useSafeAreaInsets","DefaultLoading","PageErrorBoundary","ChatAccessGate","jsx","_jsx","ScreenLayout","t0","$","_c","children","route","styles","useStyles","fontScale","t1","Symbol","for","t2","fallback","t3","screen","style","t4","name","screenName","ScreenLayoutWithChatAccessGate","insets","left","right","create","flex","paddingLeft","paddingRight"],"sources":["../../src/navigation/screenLayout.tsx"],"sourcesContent":["import { useRoute } from '@react-navigation/native'\nimport React from 'react'\nimport { Suspense } from 'react'\nimport { StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { DefaultLoading } from '../components/page/loading'\nimport { PageErrorBoundary } from '../components/page/page_error_boundary'\nimport { ChatAccessGate } from './chat_access_gate'\n\nexport function ScreenLayout({ children }: { children: React.ReactElement }) {\n const route = useRoute()\n const styles = useStyles()\n const { fontScale } = useWindowDimensions()\n\n return (\n <PageErrorBoundary screenName={route.name}>\n <View key={fontScale} style={styles.screen}>\n <Suspense fallback={<DefaultLoading />}>{children}</Suspense>\n </View>\n </PageErrorBoundary>\n )\n}\n\nexport function ScreenLayoutWithChatAccessGate({ children }: { children: React.ReactElement }) {\n return (\n <ScreenLayout>\n <ChatAccessGate>\n <Suspense fallback={<DefaultLoading />}>{children}</Suspense>\n </ChatAccessGate>\n </ScreenLayout>\n )\n}\n\nconst useStyles = () => {\n const insets = useSafeAreaInsets()\n\n return StyleSheet.create({\n screen: {\n flex: 1,\n paddingLeft: insets.left,\n paddingRight: insets.right,\n },\n })\n}\n"],"mappings":";AAAA,SAASA,QAAQ,QAAQ,0BAA0B;AACnD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,IAAI,QAAQ,cAAc;AACpE,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,cAAc,QAAQ,oBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEnD,OAAO,SAAAC,aAAAC,EAAA;EAAA,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YAAA,EACVN,MAAM,CAAAE;MACtB;IACF,CAAC,CAAC;IAAArB,CAAA,MAAAmB,MAAA,CAAAC,IAAA;IAAApB,CAAA,MAAAmB,MAAA,CAAAE,KAAA;IAAArB,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OANKD,EAML;AAAA,CACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.5.0
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sf-symbols-typescript": "^2.2.0",
|
|
85
85
|
"typescript": "~6.0.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "1d039e29c9590629c3bdf53e65c17d7a0b7178f7"
|
|
88
88
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { render } from '@testing-library/react-native'
|
|
2
|
+
import React, { useEffect } from 'react'
|
|
3
|
+
import { ScreenLayout } from '../../navigation/screenLayout'
|
|
4
|
+
|
|
5
|
+
jest.mock('react-native', () => {
|
|
6
|
+
const actual = jest.requireActual('react-native')
|
|
7
|
+
return Object.defineProperty(actual, 'useWindowDimensions', {
|
|
8
|
+
value: jest.fn(),
|
|
9
|
+
configurable: true,
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
jest.mock('@react-navigation/native', () => ({ useRoute: () => ({ name: 'Conversations' }) }))
|
|
13
|
+
jest.mock('react-native-safe-area-context', () => ({
|
|
14
|
+
useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),
|
|
15
|
+
}))
|
|
16
|
+
jest.mock('../../components/page/page_error_boundary', () => ({
|
|
17
|
+
PageErrorBoundary: ({ children }: { children: React.ReactNode }) => children,
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
const mockUseWindowDimensions = require('react-native').useWindowDimensions
|
|
21
|
+
const onMount = jest.fn()
|
|
22
|
+
|
|
23
|
+
function Child() {
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
onMount()
|
|
26
|
+
}, [])
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('ScreenLayout', () => {
|
|
31
|
+
afterEach(() => jest.clearAllMocks())
|
|
32
|
+
|
|
33
|
+
test('remounts its screen when the font scale changes, and only then', () => {
|
|
34
|
+
mockUseWindowDimensions.mockReturnValue({ fontScale: 1 })
|
|
35
|
+
const screen = render(
|
|
36
|
+
<ScreenLayout>
|
|
37
|
+
<Child />
|
|
38
|
+
</ScreenLayout>
|
|
39
|
+
)
|
|
40
|
+
screen.rerender(
|
|
41
|
+
<ScreenLayout>
|
|
42
|
+
<Child />
|
|
43
|
+
</ScreenLayout>
|
|
44
|
+
)
|
|
45
|
+
expect(onMount).toHaveBeenCalledTimes(1)
|
|
46
|
+
|
|
47
|
+
mockUseWindowDimensions.mockReturnValue({ fontScale: 1.2 })
|
|
48
|
+
screen.rerender(
|
|
49
|
+
<ScreenLayout>
|
|
50
|
+
<Child />
|
|
51
|
+
</ScreenLayout>
|
|
52
|
+
)
|
|
53
|
+
expect(onMount).toHaveBeenCalledTimes(2)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRoute } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { Suspense } from 'react'
|
|
4
|
-
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { DefaultLoading } from '../components/page/loading'
|
|
7
7
|
import { PageErrorBoundary } from '../components/page/page_error_boundary'
|
|
@@ -10,10 +10,11 @@ import { ChatAccessGate } from './chat_access_gate'
|
|
|
10
10
|
export function ScreenLayout({ children }: { children: React.ReactElement }) {
|
|
11
11
|
const route = useRoute()
|
|
12
12
|
const styles = useStyles()
|
|
13
|
+
const { fontScale } = useWindowDimensions()
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<PageErrorBoundary screenName={route.name}>
|
|
16
|
-
<View style={styles.screen}>
|
|
17
|
+
<View key={fontScale} style={styles.screen}>
|
|
17
18
|
<Suspense fallback={<DefaultLoading />}>{children}</Suspense>
|
|
18
19
|
</View>
|
|
19
20
|
</PageErrorBoundary>
|