-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mobile: Settings screen: Create separate pages for each screen (#8567)
- Loading branch information
1 parent
0340c7f
commit 672d028
Showing
34 changed files
with
1,272 additions
and
523 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
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,44 @@ | ||
|
||
import * as React from 'react'; | ||
import { TextStyle } from 'react-native'; | ||
const FontAwesomeIcon = require('react-native-vector-icons/FontAwesome5').default; | ||
|
||
interface Props { | ||
name: string; | ||
style: TextStyle; | ||
|
||
// If `null` is given, the content must be labeled elsewhere. | ||
accessibilityLabel: string|null; | ||
} | ||
|
||
const Icon: React.FC<Props> = props => { | ||
// Matches: | ||
// 1. A prefix of word characters (\w+) | ||
// 2. A suffix of non-spaces (\S+) | ||
// An "fa-" at the beginning of the suffix is ignored. | ||
const nameMatch = props.name.match(/^(\w+)\s+(?:fa-)?(\S+)$/); | ||
|
||
const namePrefix = nameMatch ? nameMatch[1] : ''; | ||
const nameSuffix = nameMatch ? nameMatch[2] : props.name; | ||
|
||
// If there's no label, make sure that the screen reader doesn't try | ||
// to read the characters from the icon font (they don't make sense | ||
// without the icon font applied). | ||
const accessibilityHidden = props.accessibilityLabel === null; | ||
|
||
return ( | ||
<FontAwesomeIcon | ||
brand={namePrefix.startsWith('fab')} | ||
solid={namePrefix.startsWith('fas')} | ||
accessibilityLabel={props.accessibilityLabel} | ||
aria-hidden={accessibilityHidden} | ||
importantForAccessibility={ | ||
accessibilityHidden ? 'no-hide-descendants' : 'yes' | ||
} | ||
name={nameSuffix} | ||
style={props.style} | ||
/> | ||
); | ||
}; | ||
|
||
export default Icon; |
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
Oops, something went wrong.