-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add navigation to link settings and add link picker screen
- Loading branch information
Showing
9 changed files
with
163 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/components/src/mobile/link-picker/link-picker-screen.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { useNavigation, useRoute } from '@react-navigation/native'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { LinkPicker } from './'; | ||
|
||
const LinkPickerScreen = ( { returnScreenName } ) => { | ||
const navigation = useNavigation(); | ||
const route = useRoute(); | ||
|
||
const onLinkPicked = ( { url, title } ) => { | ||
navigation.navigate( returnScreenName, { | ||
inputValue: url, | ||
text: title, | ||
} ); | ||
}; | ||
|
||
const onCancel = () => { | ||
navigation.goBack(); | ||
}; | ||
|
||
const { inputValue } = route.params; | ||
return useMemo( () => { | ||
return ( | ||
<LinkPicker | ||
value={ inputValue } | ||
onLinkPicked={ onLinkPicked } | ||
onCancel={ onCancel } | ||
/> | ||
); | ||
}, [ inputValue ] ); | ||
}; | ||
|
||
export default LinkPickerScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/components/src/mobile/link-settings/link-settings-navigation.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import BottomSheet from '../bottom-sheet'; | ||
import LinkSettingsScreen from './link-settings-screen'; | ||
import LinkPickerScreen from '../link-picker/link-picker-screen'; | ||
|
||
const linkSettingsScreens = { | ||
settings: 'LinkSettingsScreen', | ||
linkPicker: 'linkPicker', | ||
}; | ||
|
||
function LinkSettingsNavigation( props ) { | ||
if ( ! props.withBottomSheet ) { | ||
return <LinkSettingsScreen { ...props } />; | ||
} | ||
return ( | ||
<BottomSheet | ||
isVisible={ props.isVisible } | ||
onClose={ props.onClose } | ||
hideHeader | ||
withNavigation | ||
> | ||
<BottomSheet.NavigationContainer animate main> | ||
<BottomSheet.NavigationScreen | ||
name={ linkSettingsScreens.settings } | ||
> | ||
<LinkSettingsScreen { ...props } withBottomSheet /> | ||
</BottomSheet.NavigationScreen> | ||
<BottomSheet.NavigationScreen | ||
name={ linkSettingsScreens.linkPicker } | ||
isScrollable | ||
fullScreen | ||
> | ||
<LinkPickerScreen | ||
returnScreenName={ linkSettingsScreens.settings } | ||
/> | ||
</BottomSheet.NavigationScreen> | ||
</BottomSheet.NavigationContainer> | ||
</BottomSheet> | ||
); | ||
} | ||
|
||
export default LinkSettingsNavigation; |
36 changes: 36 additions & 0 deletions
36
packages/components/src/mobile/link-settings/link-settings-screen.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { useNavigation, useRoute } from '@react-navigation/native'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import LinkSettings from './'; | ||
|
||
const LinkSettingsScreen = ( props ) => { | ||
const navigation = useNavigation(); | ||
const route = useRoute(); | ||
const { url = '' } = props.attributes || {}; | ||
const { inputValue = url } = route.params || {}; | ||
|
||
const onLinkCellPressed = () => { | ||
navigation.navigate( 'linkPicker', { inputValue } ); | ||
}; | ||
|
||
return useMemo( () => { | ||
return ( | ||
<LinkSettings | ||
onLinkCellPressed={ onLinkCellPressed } | ||
urlValue={ inputValue } | ||
{ ...props } | ||
/> | ||
); | ||
}, [ props, inputValue, navigation, route ] ); | ||
}; | ||
|
||
export default LinkSettingsScreen; |