-
-
Notifications
You must be signed in to change notification settings - Fork 675
More prep work for handling safe areas. #4683
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
060fb11
OptionButton [nfc]: Use `styles.settingsIcon` more directly.
chrisbobbe 3a6896c
OptionRow [nfc]: Use `styles.settingsIcon` more directly.
chrisbobbe 8874c15
miscStyles: Use `size` prop instead of `fontSize` style for icon size.
chrisbobbe e8571d2
NavButton: Don't use `fontSize` to control icon size.
chrisbobbe 65536f1
NavButton: Use standard icon size of 24, instead of using 26.
chrisbobbe f486c01
TitleStream [nfc]: Tie `StreamIcon` size to stream name size.
chrisbobbe 600b1b8
SwitchRow [nfc]: Rename, from `OptionRow`.
chrisbobbe 0b9ff5c
EditStreamCard [nfc]: Follow recent `OptionRow` -> `SwitchRow` rename.
chrisbobbe 9b316f3
LanguagePickerItem [nfc]: Convert to a function component.
chrisbobbe 2c4ccc3
SelectableOptionRow [nfc]: Add, to replace `LanguagePickerItem`.
chrisbobbe de6c41b
SelectableOptionRow [nfc]: Widen interface to match name (1/5).
chrisbobbe f9a340e
SelectableOptionRow [nfc]: Widen interface to match name (2/5).
chrisbobbe 20cb6f8
SelectableOptionRow [nfc]: Widen interface to match name (3/5).
chrisbobbe 77e2a02
SelectableOptionRow [nfc]: Widen interface to match name (4/5).
chrisbobbe fa7f284
SelectableOptionRow [nfc]: Widen interface to match name (5/5).
chrisbobbe 43b8de1
LanguagePicker [nfc]: Use new, multi-purpose `SelectableOptionRow`.
chrisbobbe aad2962
SelectableOptionRow [nfc]: Tighten event handler interface.
chrisbobbe 8f14439
SelectableOptionRow [nfc]: Comment about `itemKey`.
chrisbobbe 040b1f3
SelectableOptionRow [nfc]: Reorder variables.
chrisbobbe 55ccae4
SelectableOptionRow: Make `subtitle` optional.
chrisbobbe f3a9a0a
UserStatusScreen: Use new `SelectableOptionRow`.
chrisbobbe cfc9308
NestedNavRow [nfc]: Rename, from `OptionButton`.
chrisbobbe 0e4f0bc
UserPickerCard [nfc]: Convert to function component (1/7).
chrisbobbe a7397b8
UserPickerCard [nfc]: Convert to function component (2/7).
chrisbobbe d53ded9
UserPickerCard [nfc]: Convert to function component (3/7).
chrisbobbe 34ff815
UserPickerCard [nfc]: Convert to function component (4/7).
chrisbobbe 391118e
UserPickerCard [nfc]: Convert to function component (5/7).
chrisbobbe ffff16f
UserPickerCard: Put `this.listRef` nullish check in the right place.
chrisbobbe 2c9735f
UserPickerCard [nfc]: Make `this.listRef` nullish check more compact.
chrisbobbe d69dc45
UserPickerCard [nfc]: Convert to function component (6/7).
chrisbobbe cc03c4f
react: Add `usePrevious`.
chrisbobbe d5fce7f
UserPickerCard [nfc]: Convert to function component (7/7).
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 hidden or 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 hidden or 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 hidden or 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,73 @@ | ||
/* @flow strict-local */ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
|
||
import { RawLabel, Touchable } from '.'; | ||
import { BRAND_COLOR, createStyleSheet } from '../styles'; | ||
import { IconDone } from './Icons'; | ||
|
||
const styles = createStyleSheet({ | ||
wrapper: { | ||
flex: 1, | ||
flexDirection: 'column', | ||
}, | ||
subtitle: { | ||
fontWeight: '300', | ||
fontSize: 13, | ||
}, | ||
listItem: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingTop: 12, | ||
paddingBottom: 12, | ||
paddingLeft: 16, | ||
paddingRight: 16, | ||
}, | ||
}); | ||
|
||
type Props<TItemKey: string | number> = $ReadOnly<{| | ||
// A key to uniquely identify the item. The function passed as | ||
// `onRequestSelectionChange` gets passed this. We would have just | ||
// called this `key` except that would collide with React's builtin | ||
// `key` attribute (which callers should also pass if they're in a | ||
// position that requires it). | ||
itemKey: TItemKey, | ||
|
||
title: string, | ||
subtitle?: string, | ||
selected: boolean, | ||
|
||
// We might have called this `onPress`, but | ||
// - pressing just happens to be how this component wants the user | ||
// to manually select/deselect | ||
// - callers don't have a license to do whatever they want here; see | ||
// note in jsdoc | ||
onRequestSelectionChange: (itemKey: TItemKey, requestedValue: boolean) => void, | ||
|}>; | ||
|
||
/** | ||
* A labeled row for an item among related items; shows a checkmark | ||
* when selected. | ||
* | ||
* NOTE: This isn't an all-purpose action button. The component has | ||
* two essential states: selected and deselected. These must clearly | ||
* represent two states in the app; e.g., for each supported locale, | ||
* it is either active or not. The event handler shouldn't do random | ||
* things that aren't related to that state, like navigating to a | ||
* different screen. | ||
*/ | ||
export default function SelectableOptionRow<TItemKey: string | number>(props: Props<TItemKey>) { | ||
const { itemKey, title, subtitle, selected, onRequestSelectionChange } = props; | ||
|
||
return ( | ||
<Touchable onPress={() => onRequestSelectionChange(itemKey, !selected)}> | ||
<View style={styles.listItem}> | ||
<View style={styles.wrapper}> | ||
<RawLabel text={title} /> | ||
{subtitle !== undefined && <RawLabel text={subtitle} style={styles.subtitle} />} | ||
</View> | ||
<View>{selected && <IconDone size={16} color={BRAND_COLOR} />}</View> | ||
</View> | ||
</Touchable> | ||
); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,20 @@ | ||
/* @flow strict-local */ | ||
import { useRef, useEffect } from 'react'; | ||
|
||
/** | ||
* A Hook for the value of a prop, state, etc., from the previous | ||
* render, or the first render if this is the first. | ||
* | ||
* From | ||
* https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state, | ||
* which says, "It’s possible that in the future React will provide a | ||
* `usePrevious` Hook out of the box since it’s a relatively common | ||
* use case." | ||
*/ | ||
export function usePrevious<T>(value: T): T { | ||
const ref = useRef<T>(value); | ||
useEffect(() => { | ||
ref.current = value; | ||
}); | ||
return ref.current; | ||
} |
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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
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.
It would be good to include in the commit message here what you intend to use this component for, it's not clear to me from the name.