-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
user-status: Add UI for setting emoji status #5277
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e6e8f21
UserStatusScreen [nfc]: Make a conditional more transparent
chrisbobbe 8e516b6
UserStatusScreen [nfc]: Consistently represent "unset" in statusText …
chrisbobbe d99c077
UserStatusScreen [nfc]: Make statusText state a string
chrisbobbe 2ce27e5
UserStatusScreen [nfc]: Rename input-value state
chrisbobbe 32a127d
UserStatusScreen [nfc]: Pull out status <-> input-value converters
chrisbobbe 4304dea
UserStatusScreen: Trim entered text status before interpreting it
chrisbobbe f25b469
EmojiPickerScreen: Use plain-old navigation.goBack()
chrisbobbe 7a8208b
EmojiPickerScreen: Put callback in route params
chrisbobbe 96901e3
Emoji [nfc]: Allow setting size
chrisbobbe bbba246
UserStatusScreen [nfc]: Add "input row" View, to soon include emoji i…
chrisbobbe cf1a32c
UserStatusScreen [nfc]: Move `useContext` upward, with selectors
chrisbobbe 261341c
UserStatusScreen: Translate status-text suggestions
chrisbobbe c7013e3
AccountDetails: Show status emoji, if set
chrisbobbe 254b00f
UserStatusScreen: Add and use EmojiInput, for status emoji
chrisbobbe a0643fd
UserStatusScreen: Move and re-style "clear" button
chrisbobbe 5b0e2f8
UserStatusScreen: Have clear button only clear the inputs, not save too
chrisbobbe 5100d57
UserStatusScreen: Rename "Update" button to "Save"; remove checkmark …
chrisbobbe 977d59f
UserStatusScreen: Disable "Save" button when status unchanged
chrisbobbe ed6e6e1
UserStatusScreen: Make status suggestions use new emoji-status feature!
chrisbobbe 6d62335
UserStatusScreen: Add "Busy" option
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,89 @@ | ||
/* @flow strict-local */ | ||
import React, { useContext, useCallback, useMemo } from 'react'; | ||
import type { Node } from 'react'; | ||
import { Platform } from 'react-native'; | ||
import type { AppNavigationProp } from '../nav/AppNavigator'; | ||
|
||
import { ThemeContext } from '../styles/theme'; | ||
import Touchable from '../common/Touchable'; | ||
import Emoji from '../emoji/Emoji'; | ||
import { Icon } from '../common/Icons'; | ||
import type { EmojiType } from '../types'; | ||
import { createStyleSheet, BORDER_COLOR } from '../styles'; | ||
|
||
export type Value = null | {| +type: EmojiType, +code: string, +name: string |}; | ||
|
||
export type Props = $ReadOnly<{| | ||
value: Value, | ||
onChangeValue: Value => void, | ||
|
||
/** | ||
* Component must be under the stack nav that has the emoji-picker screen | ||
* | ||
* Pass this down from props or `useNavigation`. | ||
*/ | ||
navigation: AppNavigationProp<>, | ||
|
||
/** | ||
* Give appropriate right margin | ||
*/ | ||
rightMargin?: true, | ||
|}>; | ||
|
||
/** | ||
* A controlled input component to let the user choose an emoji. | ||
* | ||
* When pressed, opens the emoji-picker screen, and populates with the emoji | ||
* chosen by the user, if any. | ||
* | ||
* Designed for harmony with our Input component. If changing the appearance | ||
* of this or that component, we should try to keep that harmony. | ||
*/ | ||
export default function EmojiInput(props: Props): Node { | ||
const { value, onChangeValue, navigation, rightMargin } = props; | ||
|
||
const { color } = useContext(ThemeContext); | ||
|
||
const handlePress = useCallback(() => { | ||
navigation.push('emoji-picker', { onPressEmoji: onChangeValue }); | ||
}, [navigation, onChangeValue]); | ||
|
||
const styles = useMemo( | ||
() => | ||
createStyleSheet({ | ||
touchable: { | ||
// Min touch-target size | ||
minWidth: 48, | ||
minHeight: 48, | ||
|
||
alignItems: 'center', | ||
justifyContent: 'center', | ||
|
||
marginRight: rightMargin ? 4 : undefined, | ||
|
||
// For harmony with the `Input` component, which differs between | ||
// platforms because of platform conventions. Border on iOS, no | ||
// border on Android. | ||
...(Platform.OS === 'ios' | ||
? { | ||
borderWidth: 1, | ||
borderColor: BORDER_COLOR, | ||
borderRadius: 2, | ||
padding: 8, | ||
} | ||
: Object.freeze({})), | ||
}, | ||
}), | ||
[rightMargin], | ||
); | ||
|
||
return ( | ||
<Touchable style={styles.touchable} onPress={handlePress}> | ||
{value ? ( | ||
<Emoji code={value.code} type={value.type} size={24} /> | ||
) : ( | ||
<Icon color={color} size={24} name="smile" /> | ||
)} | ||
</Touchable> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting. Why are the border and padding only on iOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, this needs a comment (and should possibly change). It's meant to mimic
Input
, which hasThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it. IIRC that conditional is there in order to conform to platform conventions. This UI might call for something else, though.