-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from wordpress-mobile/feature/inserter-modal
Feature/inserter modal
- Loading branch information
Showing
6 changed files
with
224 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* @format | ||
* @flow | ||
*/ | ||
import React, { Component } from 'react'; | ||
import { FlatList, Text, TouchableHighlight, View } from 'react-native'; | ||
import Modal from 'react-native-modal'; | ||
import styles from './block-picker.scss'; | ||
// Gutenberg imports | ||
import { getBlockTypes } from '@wordpress/blocks'; | ||
|
||
type PropsType = { | ||
visible: boolean, | ||
style?: StyleSheet, | ||
onValueSelected: ( itemValue: string, itemIndex: number ) => void, | ||
onDismiss: () => void, | ||
}; | ||
|
||
// TODO: not used for now - will hold currently selected Block Type, probably makes sense for the inspector | ||
type StateType = { | ||
selectedIndex: number, | ||
}; | ||
|
||
export default class BlockPicker extends Component<PropsType, StateType> { | ||
availableBlockTypes = getBlockTypes(); | ||
|
||
constructor( props: PropsType ) { | ||
super( props ); | ||
this.state = { | ||
selectedIndex: 0, | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Modal | ||
animationType="slide" | ||
transparent={ true } | ||
isVisible={ this.props.visible } | ||
onSwipe={ this.props.onDismiss.bind( this ) } | ||
swipeDirection="down" | ||
style={ [ styles.bottomModal, this.props.style ] } | ||
backdropColor={ 'lightgrey' } | ||
backdropOpacity={ 0.4 } | ||
onBackdropPress={ this.props.onDismiss.bind( this ) }> | ||
<View style={ styles.modalContent }> | ||
<View style={ styles.shortLineStyle } /> | ||
<View> | ||
<Text style={ styles.title }>ADD BLOCK</Text> | ||
</View> | ||
<View style={ styles.lineStyle } /> | ||
<FlatList | ||
numColumns={ 3 } | ||
data={ this.availableBlockTypes } | ||
keyExtractor={ ( item ) => item.name } | ||
renderItem={ ( { item } ) => | ||
<TouchableHighlight | ||
style={ styles.touchableArea } | ||
underlayColor={ 'transparent' } | ||
activeOpacity={ .5 } | ||
onPress={ this.props.onValueSelected.bind( this, item.name ) }> | ||
<View style={ styles.modalItem }> | ||
<View style={ styles.modalIcon }> | ||
{ /* TODO: ICON IMAGE GOES HERE */ } | ||
{ /* <Text>{ item.icon.src }</Text> */ } | ||
<Text>icon</Text> | ||
</View> | ||
<Text style={ styles.modalItemLabel }>{ item.title }</Text> | ||
</View> | ||
</TouchableHighlight> | ||
} | ||
/> | ||
</View> | ||
</Modal> | ||
); | ||
} | ||
} |
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,76 @@ | ||
/** @format */ | ||
|
||
@import '../variables.scss'; | ||
|
||
.title { | ||
font-family: $default-monospace-font; | ||
font-size: 16px; | ||
font-weight: bold; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.lineStyle { | ||
border-bottom-color: lightgray; | ||
border-bottom-width: 1px; | ||
width: 100%; | ||
} | ||
|
||
.shortLineStyle { | ||
border-bottom-color: lightgray; | ||
border-bottom-width: 2px; | ||
margin-bottom: 8px; | ||
width: 40px; | ||
} | ||
|
||
.bottomModal { | ||
justify-content: flex-end; | ||
margin: 0px; | ||
} | ||
|
||
.touchableArea { | ||
border-radius: 4px 4px 4px 4px; | ||
} | ||
|
||
.modalContent { | ||
background-color: white; | ||
padding-top: 8; | ||
padding-bottom: 8; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 10px 10px 0px 0px; | ||
border-color: grey; | ||
border-width: 1px; | ||
} | ||
|
||
.modalItem { | ||
flex: 1 1 auto; | ||
margin: 5px; | ||
width: 100px; | ||
align-self: stretch; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.modalIcon { | ||
flex: 1 1 auto; | ||
background-color: lightgray; | ||
padding-left: 8; | ||
padding-right: 8; | ||
padding-top: 8; | ||
padding-bottom: 8; | ||
margin: 4px; | ||
width: 72px; | ||
height: 48px; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 4px 4px 4px 4px; | ||
} | ||
|
||
.modalItemLabel { | ||
background-color: transparent; | ||
padding-left: 2; | ||
padding-right: 2; | ||
padding-top: 2; | ||
padding-bottom: 2; | ||
justify-content: center; | ||
} |
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