1+ import { SymbolView } from "./AppSymbol" ;
12import {
23 Box ,
3- Button ,
4+ Button as ComposeButton ,
45 LoadingIndicator ,
56 FilledTonalButton ,
67 Host ,
78 Row ,
9+ RNHostView ,
810 Text ,
911 TextButton ,
1012} from "@expo/ui/jetpack-compose" ;
@@ -13,37 +15,42 @@ import { View } from "react-native";
1315
1416import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider" ;
1517import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole" ;
16- import type { MaterialButtonProps } from "./MaterialButton " ;
18+ import type { ButtonProps } from "./Button " ;
1719import { useAndroidControlSizing } from "./useAndroidControlSizing" ;
1820
19- export function MaterialButton ( props : MaterialButtonProps ) {
21+ export function Button ( props : ButtonProps ) {
2022 const { themeAppearance, themeVariables : colors } = useAppearancePreferences ( ) ;
2123 const typography = useScaledTextRole ( "footnote" ) ;
2224 const { scale, mediumIconSize } = useAndroidControlSizing ( ) ;
2325 const tone = props . tone ?? "secondary" ;
2426 const Component =
25- tone === "text" ? TextButton : tone === "secondary" ? FilledTonalButton : Button ;
27+ tone === "text" ? TextButton : tone === "secondary" ? FilledTonalButton : ComposeButton ;
2628 const containerColor =
27- tone === "primary"
28- ? colors [ "--color-primary" ]
29- : tone === "danger"
30- ? colors [ "--color-danger" ]
31- : tone === "text"
32- ? "#00000000"
33- : colors [ "--color-secondary" ] ;
29+ tone === "contrast"
30+ ? colors [ "--color-foreground" ]
31+ : tone === "primary"
32+ ? colors [ "--color-primary" ]
33+ : tone === "danger"
34+ ? colors [ "--color-danger" ]
35+ : tone === "text"
36+ ? "#00000000"
37+ : colors [ "--color-secondary" ] ;
3438 const contentColor =
35- tone === "primary"
36- ? colors [ "--color-primary-foreground" ]
37- : tone === "danger"
38- ? colors [ "--color-danger-foreground" ]
39- : tone === "text"
40- ? colors [ "--color-primary-text" ]
41- : colors [ "--color-secondary-foreground" ] ;
39+ tone === "contrast"
40+ ? colors [ "--color-screen" ]
41+ : tone === "primary"
42+ ? colors [ "--color-primary-foreground" ]
43+ : tone === "danger"
44+ ? colors [ "--color-danger-foreground" ]
45+ : tone === "text"
46+ ? colors [ "--color-primary-text" ]
47+ : colors [ "--color-secondary-foreground" ] ;
4248 return (
4349 < View
4450 accessible
4551 accessibilityRole = "button"
4652 accessibilityLabel = { props . label }
53+ accessibilityHint = { props . accessibilityHint }
4754 accessibilityState = { {
4855 disabled : Boolean ( props . disabled || props . loading ) ,
4956 busy : Boolean ( props . loading ) ,
@@ -84,6 +91,21 @@ export function MaterialButton(props: MaterialButtonProps) {
8491 />
8592 < Box modifiers = { [ size ( 8 * scale , 1 ) ] } />
8693 </ >
94+ ) : props . icon ? (
95+ < >
96+ < RNHostView matchContents modifiers = { [ size ( mediumIconSize , mediumIconSize ) ] } >
97+ < View style = { { width : mediumIconSize , height : mediumIconSize } } >
98+ < SymbolView
99+ name = { props . icon }
100+ size = { mediumIconSize }
101+ tintColor = {
102+ props . disabled ? colors [ "--color-foreground-muted" ] : contentColor
103+ }
104+ />
105+ </ View >
106+ </ RNHostView >
107+ < Box modifiers = { [ size ( 8 * scale , 1 ) ] } />
108+ </ >
87109 ) : null }
88110 < Text style = { { ...typography , fontWeight : "500" } } > { props . label } </ Text >
89111 </ Row >
0 commit comments