-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted auto complete pop up from ComposeText. (#717)
* Extracted auto complete pop up from ComposeText. Don't show them between topic and message field. Show them above topic field. * Improved styles of popup. - Change background color with theme. - List looks like they are part of ComposeBox (like messenger). - Use RawLabel for text in emoji row. * Set max height of pop to 1/4th height of window. almost half is taken by keyboard and compose box and another 1/4th should be kept for nav bar, status bar and some part of message list.
- Loading branch information
1 parent
856b2ab
commit 3387037
Showing
5 changed files
with
91 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* @flow */ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
|
||
import { MatchResult } from '../types'; | ||
import getAutocompletedText from './getAutocompletedText'; | ||
import EmojiAutocomplete from './EmojiAutocomplete'; | ||
import StreamAutocomplete from './StreamAutocomplete'; | ||
import PeopleAutocomplete from './PeopleAutocomplete'; | ||
|
||
type Props = { | ||
text: string, | ||
onAutocomplete: (input: string) => void, | ||
}; | ||
|
||
export default class AutoCompleteView extends React.Component { | ||
|
||
props: Props; | ||
|
||
handleAutocomplete = (autocomplete: string) => { | ||
const { text, onAutocomplete } = this.props; | ||
const newText = getAutocompletedText(text, autocomplete); | ||
onAutocomplete(newText); | ||
} | ||
|
||
render() { | ||
const { text } = this.props; | ||
const lastword: MatchResult = text.match(/\b(\w+)$/); | ||
const lastWordPrefix = lastword && lastword.index && text[lastword.index - 1]; | ||
return ( | ||
<View> | ||
{lastWordPrefix === ':' && lastword && | ||
<EmojiAutocomplete filter={lastword[0]} onAutocomplete={this.handleAutocomplete} />} | ||
{lastWordPrefix === '#' && lastword && | ||
<StreamAutocomplete filter={lastword[0]} onAutocomplete={this.handleAutocomplete} />} | ||
{lastWordPrefix === '@' && lastword && | ||
<PeopleAutocomplete filter={lastword[0]} onAutocomplete={this.handleAutocomplete} />} | ||
</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
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