Skip to content
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

feat: adjust Button #3114

Merged
merged 7 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 136 additions & 11 deletions example/src/Examples/ButtonExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import ScreenWrapper from '../ScreenWrapper';
const ButtonExample = () => {
const theme = useTheme();

const color = theme.isV3 ? theme.colors.secondary : theme.colors.accent;
const color = theme.isV3 ? theme.colors.inversePrimary : theme.colors.accent;

return (
<ScreenWrapper>
<List.Section title="Text button">
<List.Section title={`Text button ${theme.isV3 ? '(text)' : ''}`}>
<View style={styles.row}>
<Button onPress={() => {}} style={styles.button}>
Default
</Button>
<Button color={color} onPress={() => {}} style={styles.button}>
<Button textColor={color} onPress={() => {}} style={styles.button}>
Custom
</Button>
<Button disabled onPress={() => {}} style={styles.button}>
Expand All @@ -37,14 +37,68 @@ const ButtonExample = () => {
</Button>
</View>
</List.Section>
<List.Section title="Outlined button">
{theme.isV3 && (
<List.Section title="Contained-tonal button (tonal)">
<View style={styles.row}>
<Button
mode="contained-tonal"
onPress={() => {}}
style={styles.button}
>
Default
</Button>
<Button
mode="contained-tonal"
buttonColor={color}
onPress={() => {}}
style={styles.button}
>
Custom
</Button>
<Button
mode="contained-tonal"
disabled
onPress={() => {}}
style={styles.button}
>
Disabled
</Button>
<Button
mode="contained-tonal"
icon="camera"
onPress={() => {}}
style={styles.button}
>
Icon
</Button>
<Button
mode="contained-tonal"
loading
onPress={() => {}}
style={styles.button}
>
Loading
</Button>
<Button
mode="contained-tonal"
icon="camera"
onPress={() => {}}
style={styles.button}
contentStyle={styles.flexReverse}
>
Icon right
</Button>
</View>
</List.Section>
)}
<List.Section title={`Outlined button ${theme.isV3 ? '(outlined)' : ''}`}>
<View style={styles.row}>
<Button mode="outlined" onPress={() => {}} style={styles.button}>
Default
</Button>
<Button
mode="outlined"
color={color}
textColor={color}
onPress={() => {}}
style={styles.button}
>
Expand Down Expand Up @@ -75,24 +129,24 @@ const ButtonExample = () => {
Loading
</Button>
<Button
icon="heart"
mode="outlined"
icon="camera"
onPress={() => {}}
style={styles.button}
labelStyle={styles.fontStyles}
contentStyle={styles.flexReverse}
>
Custom Font
Icon right
</Button>
</View>
</List.Section>
<List.Section title="Contained button">
<List.Section title={`Contained button ${theme.isV3 ? '(filled)' : ''}`}>
<View style={styles.row}>
<Button mode="contained" onPress={() => {}} style={styles.button}>
Default
</Button>
<Button
mode="contained"
color={color}
buttonColor={color}
onPress={() => {}}
style={styles.button}
>
Expand Down Expand Up @@ -122,9 +176,68 @@ const ButtonExample = () => {
>
Loading
</Button>
<Button
mode="contained"
icon="camera"
onPress={() => {}}
style={styles.button}
contentStyle={styles.flexReverse}
>
Icon right
</Button>
</View>
</List.Section>
<List.Section title="Custom icon">
{theme.isV3 && (
<List.Section title={'Elevated button (elevated)'}>
<View style={styles.row}>
<Button mode="elevated" onPress={() => {}} style={styles.button}>
Default
</Button>
<Button
mode="elevated"
buttonColor={color}
onPress={() => {}}
style={styles.button}
>
Custom
</Button>
<Button
mode="elevated"
disabled
onPress={() => {}}
style={styles.button}
>
Disabled
</Button>
<Button
mode="elevated"
icon="camera"
onPress={() => {}}
style={styles.button}
>
Icon
</Button>
<Button
mode="elevated"
loading
onPress={() => {}}
style={styles.button}
>
Loading
</Button>
<Button
mode="elevated"
icon="camera"
onPress={() => {}}
style={styles.button}
contentStyle={styles.flexReverse}
>
Icon right
</Button>
</View>
</List.Section>
)}
<List.Section title="Custom">
<View style={styles.row}>
<Button
mode="outlined"
Expand Down Expand Up @@ -157,6 +270,15 @@ const ButtonExample = () => {
>
Custom component
</Button>
<Button
icon="heart"
mode="outlined"
onPress={() => {}}
style={styles.button}
labelStyle={[styles.fontStyles, theme.isV3 && styles.md3FontStyles]}
>
Custom Font
</Button>
</View>
</List.Section>
</ScreenWrapper>
Expand All @@ -177,6 +299,9 @@ const styles = StyleSheet.create({
flexReverse: {
flexDirection: 'row-reverse',
},
md3FontStyles: {
lineHeight: 32,
},
fontStyles: {
fontWeight: '800',
fontSize: 24,
Expand Down
2 changes: 1 addition & 1 deletion src/babel/__fixtures__/rewrite-imports/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Text } from 'react-native';
import PaperProvider from "react-native-paper/lib/module/core/Provider";
import BottomNavigation from "react-native-paper/lib/module/components/BottomNavigation/BottomNavigation";
import Button from "react-native-paper/lib/module/components/Button";
import Button from "react-native-paper/lib/module/components/Button/Button";
import FAB from "react-native-paper/lib/module/components/FAB";
import Appbar from "react-native-paper/lib/module/components/Appbar";
import * as MD2Colors from "react-native-paper/lib/module/styles/themes/v2/colors";
Expand Down
4 changes: 2 additions & 2 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { View, ViewStyle, StyleSheet, StyleProp, Animated } from 'react-native';
import Surface from './Surface';
import Text from './Typography/Text';
import Button from './Button';
import Button from './Button/Button';
import Icon, { IconSource } from './Icon';
import { withTheme } from '../core/theming';
import type { $RemoveChildren, Theme } from '../types';
Expand Down Expand Up @@ -238,7 +238,7 @@ const Banner = ({
compact
mode="text"
style={styles.button}
color={theme.colors?.primary}
textColor={theme.colors?.primary}
{...others}
>
{label}
Expand Down
Loading