-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adjust IconButton to Material You (#3187)
- Loading branch information
1 parent
8718f3f
commit 4db7fe2
Showing
19 changed files
with
2,248 additions
and
1,350 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 |
---|---|---|
@@ -1,42 +1,159 @@ | ||
import * as React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { IconButton, MD2Colors, MD3Colors, useTheme } from 'react-native-paper'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { | ||
IconButton, | ||
List, | ||
MD2Colors, | ||
MD3Colors, | ||
useTheme, | ||
} from 'react-native-paper'; | ||
import ScreenWrapper from '../ScreenWrapper'; | ||
|
||
const ButtonExample = () => { | ||
const { isV3 } = useTheme(); | ||
if (!isV3) { | ||
return ( | ||
<ScreenWrapper contentContainerStyle={styles.v2Container}> | ||
<IconButton icon="camera" size={24} onPress={() => {}} /> | ||
<IconButton | ||
icon="lock" | ||
size={24} | ||
iconColor={MD2Colors.green500} | ||
onPress={() => {}} | ||
/> | ||
<IconButton icon="camera" size={36} onPress={() => {}} /> | ||
<IconButton | ||
icon="lock" | ||
size={36} | ||
onPress={() => {}} | ||
style={{ backgroundColor: MD2Colors.lightGreen200 }} | ||
/> | ||
<IconButton icon="heart" size={60} onPress={() => {}} /> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
return ( | ||
<ScreenWrapper contentContainerStyle={styles.container}> | ||
<IconButton icon="camera" size={24} onPress={() => {}} /> | ||
<IconButton | ||
icon="lock" | ||
size={24} | ||
color={isV3 ? MD3Colors.tertiary50 : MD2Colors.green500} | ||
onPress={() => {}} | ||
/> | ||
<IconButton icon="camera" size={36} onPress={() => {}} /> | ||
<IconButton | ||
icon="lock" | ||
size={36} | ||
onPress={() => {}} | ||
style={{ | ||
backgroundColor: isV3 | ||
? MD3Colors.tertiary50 | ||
: MD2Colors.lightGreen200, | ||
}} | ||
/> | ||
<IconButton icon="heart" size={60} onPress={() => {}} /> | ||
<ScreenWrapper contentContainerStyle={styles.v3Container}> | ||
<List.Section title="Default"> | ||
<View style={styles.row}> | ||
<IconButton icon="camera" size={24} onPress={() => {}} /> | ||
<IconButton icon="camera" selected size={24} onPress={() => {}} /> | ||
<IconButton icon="camera" disabled size={24} onPress={() => {}} /> | ||
</View> | ||
</List.Section> | ||
|
||
<List.Section title="Contained"> | ||
<View style={styles.row}> | ||
<IconButton | ||
icon="camera" | ||
mode="contained" | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
icon="camera" | ||
mode="contained" | ||
selected | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
icon="camera" | ||
mode="contained" | ||
disabled | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
</View> | ||
</List.Section> | ||
|
||
<List.Section title="Contained-tonal"> | ||
<View style={styles.row}> | ||
<IconButton | ||
icon="camera" | ||
mode="contained-tonal" | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
icon="camera" | ||
selected | ||
mode="contained-tonal" | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
icon="camera" | ||
mode="contained-tonal" | ||
disabled | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
</View> | ||
</List.Section> | ||
|
||
<List.Section title="Outlined"> | ||
<View style={styles.row}> | ||
<IconButton | ||
icon="camera-outline" | ||
mode="outlined" | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
selected | ||
icon="camera" | ||
mode="outlined" | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
<IconButton | ||
icon="camera" | ||
mode="outlined" | ||
disabled | ||
size={24} | ||
onPress={() => {}} | ||
/> | ||
</View> | ||
</List.Section> | ||
|
||
<List.Section title="Custom"> | ||
<View style={styles.row}> | ||
<IconButton | ||
icon="lock" | ||
size={24} | ||
iconColor={MD3Colors.tertiary50} | ||
onPress={() => {}} | ||
/> | ||
<IconButton icon="camera" size={36} onPress={() => {}} /> | ||
<IconButton | ||
icon="lock" | ||
size={36} | ||
onPress={() => {}} | ||
containerColor={MD3Colors.tertiary60} | ||
/> | ||
<IconButton icon="heart" size={60} onPress={() => {}} /> | ||
</View> | ||
</List.Section> | ||
</ScreenWrapper> | ||
); | ||
}; | ||
|
||
ButtonExample.title = 'Icon Button'; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
v2Container: { | ||
flexDirection: 'row', | ||
padding: 8, | ||
}, | ||
v3Container: { | ||
flexDirection: 'column', | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
paddingHorizontal: 12, | ||
}, | ||
}); | ||
|
||
export default ButtonExample; |
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
Oops, something went wrong.