Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
205 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import ComposeIcon from './ComposeIcon'; | ||
|
||
export default (props) => { | ||
switch (props.modeSelected) { | ||
case 0: | ||
return (<ComposeIcon name="ios-chatbubbles" onChange={props.onModeChange} />); | ||
case 1: | ||
return (<ComposeIcon name="ios-add-circle-outline" onChange={props.onModeChange} />); | ||
default: | ||
return (<ComposeIcon name="bullhorn" onChange={props.onModeChange} />); | ||
|
||
} | ||
}; |
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,75 @@ | ||
import React from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
|
||
import ComposeOptions from './ComposeOptions'; | ||
import ModeSelector from './ModeSelector'; | ||
import StreamBox from './ModeViews/StreamBox'; | ||
import { isTopicNarrow, isStreamNarrow, isPrivateOrGroupNarrow } from '../utils/narrow'; | ||
|
||
const inlineStyles = StyleSheet.create({ | ||
wrapper: { | ||
flexDirection: 'row', | ||
}, | ||
divider: { | ||
width: 2, | ||
backgroundColor: '#ecf0f1', | ||
margin: 4 | ||
}, | ||
}); | ||
|
||
export default class ModeView extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
modeSelected: 0, | ||
}; | ||
} | ||
|
||
handleModeChanged = () => { | ||
const { setOperator, setOperand, narrow } = this.props; | ||
if (this.state.modeSelected === 0 && (isTopicNarrow(narrow) || isStreamNarrow(narrow))) { | ||
if (narrow.length === 1) { | ||
setOperand(narrow[0].operand); | ||
setOperator(''); | ||
} else { | ||
setOperand(narrow[0].operand); | ||
setOperator(narrow[1].operand); | ||
} | ||
} else { | ||
setOperator(null); | ||
setOperand(null); | ||
} | ||
this.setState({ | ||
modeSelected: (this.state.modeSelected === 1) ? 0 : this.state.modeSelected + 1 | ||
}); | ||
}; | ||
|
||
render() { | ||
const { modeSelected } = this.state; | ||
const { setOperator, setOperand, operator, operand, | ||
optionSelected, handleOptionSelected, narrow } = this.props; | ||
|
||
return ( | ||
<View style={inlineStyles.wrapper}> | ||
{(isTopicNarrow(narrow) || isStreamNarrow(narrow)) && | ||
<View style={inlineStyles.wrapper}> | ||
<ModeSelector modeSelected={modeSelected} onModeChange={this.handleModeChanged} /> | ||
<View style={inlineStyles.divider} /> | ||
</View> | ||
} | ||
{modeSelected === 0 && | ||
<ComposeOptions selected={optionSelected} onChange={handleOptionSelected} /> | ||
} | ||
{modeSelected === 1 && | ||
<StreamBox | ||
operator={operator} | ||
operand={operand} | ||
setOperator={setOperator} | ||
setOperand={setOperand} | ||
narrow={narrow} | ||
/> | ||
} | ||
</View> | ||
); | ||
} | ||
} |
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,58 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Text, TextInput, StyleSheet } from 'react-native'; | ||
|
||
|
||
const styles = StyleSheet.create({ | ||
streamInputWrapper: { | ||
flexDirection: 'row', alignItems: 'center', flex: 1 | ||
}, | ||
streamInput: { | ||
flex: 0.2, | ||
margin: 2 | ||
}, | ||
topicInput: { | ||
flex: 0.8, | ||
margin: 2 | ||
} | ||
}); | ||
|
||
export default class StreamBox extends Component { | ||
componentWillReceiveProps(nextProps) { | ||
if (this.props.narrow !== nextProps.narrow) { | ||
if (nextProps.narrow[0].operator !== 'pm-with') { | ||
const { setOperand, setOperator } = this.props; | ||
setOperand(nextProps.narrow[0].operand); | ||
setOperator(nextProps.narrow[0].operator); | ||
} | ||
} | ||
} | ||
|
||
render() { | ||
const { operator, setOperator, operand, setOperand } = this.props; | ||
return ( | ||
<View style={styles.streamInputWrapper}> | ||
<TextInput | ||
style={styles.streamInput} | ||
placeholder={'Stream'} | ||
onChange={(event) => { | ||
setOperand(event.nativeEvent.text); | ||
}} | ||
onEndEditing={() => { | ||
this.operandInput.focus(); | ||
}} | ||
value={operand} | ||
/> | ||
<Text>{'>'}</Text> | ||
<TextInput | ||
ref={component => { this.operandInput = component; }} | ||
style={styles.topicInput} | ||
placeholder={'Topic'} | ||
onChange={(event) => setOperator( | ||
event.nativeEvent.text | ||
)} | ||
value={operator} | ||
/> | ||
</View> | ||
); | ||
} | ||
} |
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