@sudobility/building_blocks_rn 0.0.33 → 0.0.35
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,14 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { View, Text, ScrollView } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
3
4
|
import { createThemedStyles } from '../../utils/styles';
|
|
4
5
|
import { useIsRTL } from '../../hooks/useRTL';
|
|
6
|
+
const rtlStyles = StyleSheet.create({
|
|
7
|
+
text: {
|
|
8
|
+
writingDirection: 'rtl',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
5
11
|
function TextSectionView({ section, level = 2, }) {
|
|
6
12
|
const styles = useStyles();
|
|
7
13
|
const isRTL = useIsRTL();
|
|
8
14
|
return (_jsxs(View, { style: styles.section, children: [_jsx(Text, { style: [
|
|
9
15
|
level === 2 ? styles.sectionTitle : styles.subsectionTitle,
|
|
10
|
-
isRTL &&
|
|
11
|
-
], children: section.title }), section.content && (_jsx(Text, { style: [styles.sectionContent, isRTL &&
|
|
16
|
+
isRTL && rtlStyles.text,
|
|
17
|
+
], children: section.title }), section.content && (_jsx(Text, { style: [styles.sectionContent, isRTL && rtlStyles.text], children: section.content })), section.items && section.items.length > 0 && (_jsx(View, { style: styles.list, children: section.items.map((item, index) => (_jsxs(View, { style: styles.listItem, children: [_jsx(Text, { style: styles.bullet, children: '\u2022' }), _jsx(Text, { style: [styles.listItemText, isRTL && rtlStyles.text], children: item })] }, index))) })), section.subsections?.map((sub, index) => (_jsx(TextSectionView, { section: sub, level: 3 }, index)))] }));
|
|
12
18
|
}
|
|
13
19
|
export function AppTextScreen({ text, lastUpdatedDate, ScreenWrapper, style, }) {
|
|
14
20
|
const styles = useStyles();
|
|
@@ -18,7 +24,7 @@ export function AppTextScreen({ text, lastUpdatedDate, ScreenWrapper, style, })
|
|
|
18
24
|
: lastUpdatedDate
|
|
19
25
|
? `Last updated: ${lastUpdatedDate}`
|
|
20
26
|
: undefined;
|
|
21
|
-
const content = (_jsxs(View, { style: [styles.container, style], children: [_jsx(Text, { style: [styles.title, isRTL &&
|
|
27
|
+
const content = (_jsxs(View, { style: [styles.container, style], children: [_jsx(Text, { style: [styles.title, isRTL && rtlStyles.text], children: text.title }), lastUpdated && (_jsx(Text, { style: [styles.lastUpdated, isRTL && rtlStyles.text], children: lastUpdated })), text.sections.map((section, index) => (_jsx(TextSectionView, { section: section }, index))), text.contact && (_jsxs(View, { style: styles.contactSection, children: [_jsx(Text, { style: [styles.sectionTitle, isRTL && rtlStyles.text], children: text.contact.title }), _jsx(Text, { style: [styles.sectionContent, isRTL && rtlStyles.text], children: text.contact.description }), _jsx(Text, { style: [styles.contactInfo, isRTL && rtlStyles.text], children: text.contact.info }), text.contact.gdprNotice && (_jsx(Text, { style: [styles.gdprNotice, isRTL && rtlStyles.text], children: text.contact.gdprNotice }))] }))] }));
|
|
22
28
|
if (ScreenWrapper) {
|
|
23
29
|
return _jsx(ScreenWrapper, { children: content });
|
|
24
30
|
}
|
|
@@ -99,7 +105,4 @@ const useStyles = createThemedStyles(colors => ({
|
|
|
99
105
|
marginTop: 12,
|
|
100
106
|
fontStyle: 'italic',
|
|
101
107
|
},
|
|
102
|
-
rtlText: {
|
|
103
|
-
writingDirection: 'rtl',
|
|
104
|
-
},
|
|
105
108
|
}));
|
|
@@ -52,5 +52,6 @@ export const RTL_LANGUAGES = ['ar'];
|
|
|
52
52
|
* Check if a language code is RTL.
|
|
53
53
|
*/
|
|
54
54
|
export function isRTL(languageCode) {
|
|
55
|
-
|
|
55
|
+
const baseCode = languageCode.toLowerCase().replace('_', '-').split('-')[0];
|
|
56
|
+
return RTL_LANGUAGES.includes(baseCode);
|
|
56
57
|
}
|