-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.native.js
208 lines (200 loc) · 5.28 KB
/
index.native.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* External dependencies
*/
import { SafeAreaView, ScrollView, StyleSheet, View } from 'react-native';
import { TransitionPresets } from '@react-navigation/stack';
/**
* WordPress dependencies
*/
import {
BottomSheet,
BottomSheetConsumer,
PanelBody,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { helpFilled, plusCircleFilled, trash, cog } from '@wordpress/icons';
import { useSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
import {
requestContactCustomerSupport,
requestGotoCustomerSupportOptions,
} from '@wordpress/react-native-bridge';
/**
* Internal dependencies
*/
import styles from './style.scss';
import HelpDetailNavigationScreen from './help-detail-navigation-screen';
import HelpTopicRow from './help-topic-row';
import HelpGetSupportButton from './help-get-support-button';
import IntroToBlocks from './intro-to-blocks';
import AddBlocks from './add-blocks';
import MoveBlocks from './move-blocks';
import RemoveBlocks from './remove-blocks';
import CustomizeBlocks from './customize-blocks';
import moveBlocksIcon from './icon-move-blocks';
import HelpSectionTitle from './help-section-title';
const HELP_TOPICS = [
{
label: __( 'What is a block?' ),
slug: 'what-is-a-block',
icon: helpFilled,
view: <IntroToBlocks />,
},
{
label: __( 'Add blocks' ),
slug: 'add-blocks',
icon: plusCircleFilled,
view: <AddBlocks />,
},
{
label: __( 'Move blocks' ),
slug: 'move-blocks',
icon: moveBlocksIcon,
view: <MoveBlocks />,
},
{
label: __( 'Remove blocks' ),
slug: 'remove-blocks',
icon: trash,
view: <RemoveBlocks />,
},
{
label: __( 'Customize blocks' ),
slug: 'customize-blocks',
icon: cog,
view: <CustomizeBlocks />,
},
];
function EditorHelpTopics( { close, isVisible, onClose, showSupport } ) {
const { postType } = useSelect( ( select ) => ( {
postType: select( editorStore ).getEditedPostAttribute( 'type' ),
} ) );
const title =
postType === 'page'
? __( 'How to edit your page' )
: __( 'How to edit your post' );
const supportSection = (
<>
<HelpSectionTitle>{ __( 'Get support' ) }</HelpSectionTitle>
<HelpGetSupportButton
title={ __( 'Contact support' ) }
onPress={ requestContactCustomerSupport }
/>
<HelpGetSupportButton
title={ __( 'More support options' ) }
onPress={ requestGotoCustomerSupportOptions }
/>
</>
);
return (
<BottomSheet
isVisible={ isVisible }
onClose={ onClose }
hideHeader
hasNavigation
contentStyle={ styles.contentContainer }
testID="editor-help-modal"
>
<SafeAreaView style={ styles.safeAreaContainer }>
<BottomSheet.NavigationContainer
animate
main
style={ styles.navigationContainer }
>
<BottomSheet.NavigationScreen
isScrollable
fullScreen
name="help-topics"
>
<View style={ styles.container }>
<BottomSheet.NavBar>
<BottomSheet.NavBar.DismissButton
onPress={ close }
iosText={ __( 'Close' ) }
/>
<BottomSheet.NavBar.Heading>
{ title }
</BottomSheet.NavBar.Heading>
</BottomSheet.NavBar>
<BottomSheetConsumer>
{ ( { listProps } ) => {
const contentContainerStyle =
StyleSheet.flatten(
listProps.contentContainerStyle
);
return (
<ScrollView
{ ...listProps }
contentContainerStyle={ {
...contentContainerStyle,
paddingBottom: Math.max(
listProps.safeAreaBottomInset,
contentContainerStyle.paddingBottom
),
/**
* Remove margin set via `hideHeader`. Combining a header
* and navigation in this bottom sheet is at odds with the
* current `BottomSheet` implementation.
*/
marginTop: 0,
} }
>
<PanelBody>
<HelpSectionTitle>
{ __( 'The basics' ) }
</HelpSectionTitle>
{ /* Print out help topics. */ }
{ HELP_TOPICS.map(
(
{ label, icon, slug },
index
) => {
const isLastItem =
index ===
HELP_TOPICS.length -
1;
return (
<HelpTopicRow
key={ slug }
label={ label }
icon={ icon }
screenName={
slug
}
isLastItem={
isLastItem
}
/>
);
}
) }
{ showSupport &&
supportSection }
</PanelBody>
</ScrollView>
);
} }
</BottomSheetConsumer>
</View>
</BottomSheet.NavigationScreen>
{ /* Print out help detail screens. */ }
{ HELP_TOPICS.map( ( { view, label, slug } ) => {
return (
<HelpDetailNavigationScreen
key={ slug }
name={ slug }
content={ view }
label={ label }
options={ {
gestureEnabled: false,
...TransitionPresets.DefaultTransition,
} }
/>
);
} ) }
</BottomSheet.NavigationContainer>
</SafeAreaView>
</BottomSheet>
);
}
export default EditorHelpTopics;