diff --git a/android/src/main/java/expo/modules/ui/ExpoUIModule.kt b/android/src/main/java/expo/modules/ui/ExpoUIModule.kt
index d58b54fc30ba0f9e5bc35b505ae598161a59b9b1..2da4df803a918d034921d41d49d92121e6303f82 100644
--- a/android/src/main/java/expo/modules/ui/ExpoUIModule.kt
+++ b/android/src/main/java/expo/modules/ui/ExpoUIModule.kt
@@ -29,6 +29,13 @@ import expo.modules.ui.button.IconButtonContent
import expo.modules.ui.button.FilledIconButtonContent
import expo.modules.ui.button.FilledTonalIconButtonContent
import expo.modules.ui.button.OutlinedIconButtonContent
+import expo.modules.ui.button.SplitButtonCheckedChangeEvent
+import expo.modules.ui.button.SplitButtonLayoutContent
+import expo.modules.ui.button.SplitButtonLayoutProps
+import expo.modules.ui.button.SplitButtonLeadingButtonContent
+import expo.modules.ui.button.SplitButtonLeadingButtonProps
+import expo.modules.ui.button.SplitButtonTrailingButtonContent
+import expo.modules.ui.button.SplitButtonTrailingButtonProps
import expo.modules.ui.graphics.ImageLoader
import expo.modules.ui.icon.IconView
import expo.modules.ui.image.ImageView
@@ -294,6 +301,26 @@ class ExpoUIModule : Module() {
}
}
+ ExpoUIView<SplitButtonLayoutProps>("SplitButtonLayoutView") {
+ Content { props -> SplitButtonLayoutContent(props) }
+ }
+
+ ExpoUIView<SplitButtonLeadingButtonProps>("SplitButtonLeadingButtonView") {
+ val onButtonPressed by Event<Unit>()
+
+ Content { props ->
+ SplitButtonLeadingButtonContent(props) { onButtonPressed(Unit) }
+ }
+ }
+
+ ExpoUIView<SplitButtonTrailingButtonProps>("SplitButtonTrailingButtonView") {
+ val onCheckedChange by Event<SplitButtonCheckedChangeEvent>()
+
+ Content { props ->
+ SplitButtonTrailingButtonContent(props) { onCheckedChange(it) }
+ }
+ }
+
ExpoUIView<ButtonProps>("FilledTonalButton") {
val onButtonPressed by Event<ButtonPressedEvent>()
@@ -533,6 +560,10 @@ class ExpoUIModule : Module() {
}
}
+ ExpoUIView<TopAppBarProps>("TopAppBarView") {
+ Content { props -> TopAppBarContent(props) }
+ }
+
ExpoUIView<HorizontalFloatingToolbarProps>("HorizontalFloatingToolbarView") {
Content { props ->
HorizontalFloatingToolbarContent(props)
diff --git a/android/src/main/java/expo/modules/ui/HostView.kt b/android/src/main/java/expo/modules/ui/HostView.kt
index 4887034bf7e3e6b5d8d2c1ae25932f5a24f9435d..6eaf039a14820ddaf635a1538c2a9a644cf704fb 100644
--- a/android/src/main/java/expo/modules/ui/HostView.kt
+++ b/android/src/main/java/expo/modules/ui/HostView.kt
@@ -69,6 +69,7 @@ internal enum class ExpoLayoutDirection(val value: String) : Enumerable {
internal data class HostProps(
val colorScheme: MutableState<ExpoColorScheme?> = mutableStateOf(null),
val seedColor: MutableState<android.graphics.Color?> = mutableStateOf(null),
+ val colorOverrides: MutableState<Map<String, android.graphics.Color>?> = mutableStateOf(null),
val layoutDirection: MutableState<ExpoLayoutDirection> = mutableStateOf(ExpoLayoutDirection.LeftToRight),
val useViewportSizeMeasurement: MutableState<Boolean> = mutableStateOf(false),
val ignoreSafeAreaKeyboardInsets: MutableState<Boolean> = mutableStateOf(false),
@@ -153,9 +154,60 @@ internal class HostView(context: Context, appContext: AppContext) :
val seededScheme = remember(seedArgb, isDark) {
seedArgb?.let { seedColorScheme(it, isDark) }
}
- val colorScheme = seededScheme
+ val baseColorScheme = seededScheme
?: props.colorScheme.value?.toColorScheme(context)
?: ExpoColorScheme.defaultColorScheme(context, isSystemInDarkTheme())
+ val overrides = props.colorOverrides.value.orEmpty()
+ val colorScheme = baseColorScheme.copy(
+ primary = overrides["primary"]?.composeOrNull ?: baseColorScheme.primary,
+ onPrimary = overrides["onPrimary"]?.composeOrNull ?: baseColorScheme.onPrimary,
+ primaryContainer = overrides["primaryContainer"]?.composeOrNull ?: baseColorScheme.primaryContainer,
+ onPrimaryContainer = overrides["onPrimaryContainer"]?.composeOrNull ?: baseColorScheme.onPrimaryContainer,
+ inversePrimary = overrides["inversePrimary"]?.composeOrNull ?: baseColorScheme.inversePrimary,
+ secondary = overrides["secondary"]?.composeOrNull ?: baseColorScheme.secondary,
+ onSecondary = overrides["onSecondary"]?.composeOrNull ?: baseColorScheme.onSecondary,
+ secondaryContainer = overrides["secondaryContainer"]?.composeOrNull ?: baseColorScheme.secondaryContainer,
+ onSecondaryContainer = overrides["onSecondaryContainer"]?.composeOrNull ?: baseColorScheme.onSecondaryContainer,
+ tertiary = overrides["tertiary"]?.composeOrNull ?: baseColorScheme.tertiary,
+ onTertiary = overrides["onTertiary"]?.composeOrNull ?: baseColorScheme.onTertiary,
+ tertiaryContainer = overrides["tertiaryContainer"]?.composeOrNull ?: baseColorScheme.tertiaryContainer,
+ onTertiaryContainer = overrides["onTertiaryContainer"]?.composeOrNull ?: baseColorScheme.onTertiaryContainer,
+ background = overrides["background"]?.composeOrNull ?: baseColorScheme.background,
+ onBackground = overrides["onBackground"]?.composeOrNull ?: baseColorScheme.onBackground,
+ surface = overrides["surface"]?.composeOrNull ?: baseColorScheme.surface,
+ onSurface = overrides["onSurface"]?.composeOrNull ?: baseColorScheme.onSurface,
+ surfaceVariant = overrides["surfaceVariant"]?.composeOrNull ?: baseColorScheme.surfaceVariant,
+ onSurfaceVariant = overrides["onSurfaceVariant"]?.composeOrNull ?: baseColorScheme.onSurfaceVariant,
+ surfaceTint = overrides["surfaceTint"]?.composeOrNull ?: baseColorScheme.surfaceTint,
+ inverseSurface = overrides["inverseSurface"]?.composeOrNull ?: baseColorScheme.inverseSurface,
+ inverseOnSurface = overrides["inverseOnSurface"]?.composeOrNull ?: baseColorScheme.inverseOnSurface,
+ error = overrides["error"]?.composeOrNull ?: baseColorScheme.error,
+ onError = overrides["onError"]?.composeOrNull ?: baseColorScheme.onError,
+ errorContainer = overrides["errorContainer"]?.composeOrNull ?: baseColorScheme.errorContainer,
+ onErrorContainer = overrides["onErrorContainer"]?.composeOrNull ?: baseColorScheme.onErrorContainer,
+ outline = overrides["outline"]?.composeOrNull ?: baseColorScheme.outline,
+ outlineVariant = overrides["outlineVariant"]?.composeOrNull ?: baseColorScheme.outlineVariant,
+ scrim = overrides["scrim"]?.composeOrNull ?: baseColorScheme.scrim,
+ surfaceBright = overrides["surfaceBright"]?.composeOrNull ?: baseColorScheme.surfaceBright,
+ surfaceDim = overrides["surfaceDim"]?.composeOrNull ?: baseColorScheme.surfaceDim,
+ surfaceContainer = overrides["surfaceContainer"]?.composeOrNull ?: baseColorScheme.surfaceContainer,
+ surfaceContainerHigh = overrides["surfaceContainerHigh"]?.composeOrNull ?: baseColorScheme.surfaceContainerHigh,
+ surfaceContainerHighest = overrides["surfaceContainerHighest"]?.composeOrNull ?: baseColorScheme.surfaceContainerHighest,
+ surfaceContainerLow = overrides["surfaceContainerLow"]?.composeOrNull ?: baseColorScheme.surfaceContainerLow,
+ surfaceContainerLowest = overrides["surfaceContainerLowest"]?.composeOrNull ?: baseColorScheme.surfaceContainerLowest,
+ primaryFixed = overrides["primaryFixed"]?.composeOrNull ?: baseColorScheme.primaryFixed,
+ primaryFixedDim = overrides["primaryFixedDim"]?.composeOrNull ?: baseColorScheme.primaryFixedDim,
+ onPrimaryFixed = overrides["onPrimaryFixed"]?.composeOrNull ?: baseColorScheme.onPrimaryFixed,
+ onPrimaryFixedVariant = overrides["onPrimaryFixedVariant"]?.composeOrNull ?: baseColorScheme.onPrimaryFixedVariant,
+ secondaryFixed = overrides["secondaryFixed"]?.composeOrNull ?: baseColorScheme.secondaryFixed,
+ secondaryFixedDim = overrides["secondaryFixedDim"]?.composeOrNull ?: baseColorScheme.secondaryFixedDim,
+ onSecondaryFixed = overrides["onSecondaryFixed"]?.composeOrNull ?: baseColorScheme.onSecondaryFixed,
+ onSecondaryFixedVariant = overrides["onSecondaryFixedVariant"]?.composeOrNull ?: baseColorScheme.onSecondaryFixedVariant,
+ tertiaryFixed = overrides["tertiaryFixed"]?.composeOrNull ?: baseColorScheme.tertiaryFixed,
+ tertiaryFixedDim = overrides["tertiaryFixedDim"]?.composeOrNull ?: baseColorScheme.tertiaryFixedDim,
+ onTertiaryFixed = overrides["onTertiaryFixed"]?.composeOrNull ?: baseColorScheme.onTertiaryFixed,
+ onTertiaryFixedVariant = overrides["onTertiaryFixedVariant"]?.composeOrNull ?: baseColorScheme.onTertiaryFixedVariant
+ )
val layoutDirection = props.layoutDirection.value.toLayoutDirection()
// Material3's `MaterialTheme` does not provide `LocalContentColor` — only `Surface` does — so
diff --git a/android/src/main/java/expo/modules/ui/TopAppBarView.kt b/android/src/main/java/expo/modules/ui/TopAppBarView.kt
new file mode 100644
index 0000000000000000000000000000000000000000..4ed0132d57fc7aff08ecb7ee84fb8fa48942931b
--- /dev/null
+++ b/android/src/main/java/expo/modules/ui/TopAppBarView.kt
@@ -0,0 +1,47 @@
+@file:OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
+
+package expo.modules.ui
+
+import android.graphics.Color
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.material3.TopAppBar
+import androidx.compose.material3.TopAppBarDefaults
+import androidx.compose.runtime.Composable
+import expo.modules.kotlin.records.Field
+import expo.modules.kotlin.records.Record
+import expo.modules.kotlin.types.OptimizedRecord
+import expo.modules.kotlin.views.ComposeProps
+import expo.modules.kotlin.views.FunctionalComposableScope
+import expo.modules.kotlin.views.OptimizedComposeProps
+
+@OptimizedRecord
+class TopAppBarColors : Record {
+ @Field val containerColor: Color? = null
+ @Field val titleContentColor: Color? = null
+ @Field val navigationIconContentColor: Color? = null
+ @Field val actionIconContentColor: Color? = null
+}
+
+@OptimizedComposeProps
+data class TopAppBarProps(
+ val colors: TopAppBarColors = TopAppBarColors(),
+ val applyWindowInsets: Boolean = true,
+ val modifiers: ModifierList = emptyList()
+) : ComposeProps
+
+@Composable
+fun FunctionalComposableScope.TopAppBarContent(props: TopAppBarProps) {
+ TopAppBar(
+ title = { Children(UIComposableScope(), filter = { isSlotWithName(it, "title") }) },
+ navigationIcon = { Children(UIComposableScope(), filter = { isSlotWithName(it, "navigationIcon") }) },
+ actions = { Children(UIComposableScope(), filter = { isSlotWithName(it, "actions") }) },
+ colors = TopAppBarDefaults.topAppBarColors(
+ containerColor = props.colors.containerColor.compose,
+ titleContentColor = props.colors.titleContentColor.compose,
+ navigationIconContentColor = props.colors.navigationIconContentColor.compose,
+ actionIconContentColor = props.colors.actionIconContentColor.compose
+ ),
+ windowInsets = if (props.applyWindowInsets) TopAppBarDefaults.windowInsets else WindowInsets(0, 0, 0, 0),
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
+ )
+}
diff --git a/android/src/main/java/expo/modules/ui/button/SplitButton.kt b/android/src/main/java/expo/modules/ui/button/SplitButton.kt
new file mode 100644
index 0000000000000000000000000000000000000000..10df003066fb0703645c4306bd557590b2cae9aa
--- /dev/null
+++ b/android/src/main/java/expo/modules/ui/button/SplitButton.kt
@@ -0,0 +1,95 @@
+@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
+
+package expo.modules.ui.button
+
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
+import androidx.compose.material3.SplitButtonDefaults
+import androidx.compose.material3.SplitButtonLayout
+import androidx.compose.runtime.Composable
+import expo.modules.kotlin.records.Field
+import expo.modules.kotlin.records.Record
+import expo.modules.kotlin.types.OptimizedRecord
+import expo.modules.kotlin.views.ComposeProps
+import expo.modules.kotlin.views.FunctionalComposableScope
+import expo.modules.kotlin.views.OptimizedComposeProps
+import expo.modules.ui.ModifierList
+import expo.modules.ui.ModifierRegistry
+import expo.modules.ui.UIComposableScope
+import expo.modules.ui.compose
+import expo.modules.ui.isSlotWithName
+
+@OptimizedComposeProps
+data class SplitButtonLayoutProps(
+ val modifiers: ModifierList = emptyList()
+) : ComposeProps
+
+@OptimizedComposeProps
+data class SplitButtonLeadingButtonProps(
+ val colors: ButtonColors = ButtonColors(),
+ val enabled: Boolean = true,
+ val modifiers: ModifierList = emptyList()
+) : ComposeProps
+
+@OptimizedComposeProps
+data class SplitButtonTrailingButtonProps(
+ val checked: Boolean = false,
+ val colors: ButtonColors = ButtonColors(),
+ val enabled: Boolean = true,
+ val modifiers: ModifierList = emptyList()
+) : ComposeProps
+
+@OptimizedRecord
+data class SplitButtonCheckedChangeEvent(
+ @Field val checked: Boolean = false
+) : Record
+
+@Composable
+fun FunctionalComposableScope.SplitButtonLayoutContent(props: SplitButtonLayoutProps) {
+ SplitButtonLayout(
+ leadingButton = { Children(UIComposableScope(), filter = { isSlotWithName(it, "leadingButton") }) },
+ trailingButton = { Children(UIComposableScope(), filter = { isSlotWithName(it, "trailingButton") }) },
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
+ )
+}
+
+@Composable
+fun FunctionalComposableScope.SplitButtonLeadingButtonContent(
+ props: SplitButtonLeadingButtonProps,
+ onClick: () -> Unit
+) {
+ SplitButtonDefaults.LeadingButton(
+ onClick = onClick,
+ enabled = props.enabled,
+ colors = ButtonDefaults.buttonColors(
+ containerColor = props.colors.containerColor.compose,
+ contentColor = props.colors.contentColor.compose,
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
+ disabledContentColor = props.colors.disabledContentColor.compose
+ ),
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
+ ) {
+ Children(UIComposableScope(rowScope = this))
+ }
+}
+
+@Composable
+fun FunctionalComposableScope.SplitButtonTrailingButtonContent(
+ props: SplitButtonTrailingButtonProps,
+ onCheckedChange: (SplitButtonCheckedChangeEvent) -> Unit
+) {
+ SplitButtonDefaults.TrailingButton(
+ checked = props.checked,
+ onCheckedChange = { onCheckedChange(SplitButtonCheckedChangeEvent(it)) },
+ enabled = props.enabled,
+ colors = ButtonDefaults.buttonColors(
+ containerColor = props.colors.containerColor.compose,
+ contentColor = props.colors.contentColor.compose,
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
+ disabledContentColor = props.colors.disabledContentColor.compose
+ ),
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
+ ) {
+ Children(UIComposableScope(rowScope = this))
+ }
+}
diff --git a/build/jetpack-compose/Host/index.d.ts b/build/jetpack-compose/Host/index.d.ts
index b586b653a991ce8840b9994a6fe1e6af75480ece..e32f6e093fde22e9cfc9d7ff612cddb59e036945 100644
--- a/build/jetpack-compose/Host/index.d.ts
+++ b/build/jetpack-compose/Host/index.d.ts
@@ -1,6 +1,7 @@
import { type Ref } from 'react';
import { type ColorSchemeName, type ColorValue, type StyleProp, type ViewStyle } from 'react-native';
import { type PrimitiveBaseProps } from '../layout';
+import type { MaterialColors } from '../colors';
export interface HostProps extends PrimitiveBaseProps {
/**
* When true, the host view will update its size in the React Native view tree to match the content's layout from Jetpack Compose.
@@ -41,6 +42,7 @@ export interface HostProps extends PrimitiveBaseProps {
* available to descendants via `useMaterialColors()`.
*/
seedColor?: ColorValue;
+ colorOverrides?: Partial<MaterialColors>;
/**
* The layout direction for the content.
* Defaults to the current locale direction from I18nManager.
diff --git a/build/jetpack-compose/Host/index.js b/build/jetpack-compose/Host/index.js
index 39856563a8cf1119f3a72e37fd35d48d245041bf..2b4a4f946f2ff04a5563c4cd8a29f28b0c5cc08b 100644
--- a/build/jetpack-compose/Host/index.js
+++ b/build/jetpack-compose/Host/index.js
@@ -8,16 +8,17 @@ import { useMergeRefs } from '../../utils/useMergeRefs';
import { getMaterialColors, HostPaletteContext } from '../colors';
const HostNativeView = requireNativeView('ExpoUI', 'HostView');
export function Host(props) {
- const { matchContents, modifiers, onLayoutContent, layoutDirection, colorScheme, seedColor, ref, children, ...restProps } = props;
+ const { matchContents, modifiers, onLayoutContent, layoutDirection, colorScheme, seedColor, colorOverrides, ref, children, ...restProps } = props;
const schemeString = colorScheme === 'light' || colorScheme === 'dark' ? colorScheme : undefined;
const systemScheme = useRNColorScheme();
const resolvedScheme = schemeString ?? (systemScheme === 'dark' ? 'dark' : 'light');
- const palette = useMemo(()=>getMaterialColors({
+ const palette = useMemo(()=>({ ...getMaterialColors({
scheme: resolvedScheme,
seedColor
- }), [
+ }), ...colorOverrides }), [
resolvedScheme,
- seedColor
+ seedColor,
+ colorOverrides
]);
const hostRef = useTextInputHostRef();
const mergedRef = useMergeRefs(ref, hostRef);
@@ -33,6 +34,7 @@ export function Host(props) {
matchContentsHorizontal: typeof matchContents === 'object' ? matchContents.horizontal : matchContents,
colorScheme: schemeString,
seedColor: seedColor,
+ colorOverrides: colorOverrides,
onLayoutContent: onLayoutContent,
layoutDirection: layoutDirection ?? (I18nManager.getConstants().isRTL ? 'rightToLeft' : 'leftToRight'),
ref: mergedRef,
diff --git a/build/jetpack-compose/SplitButton/index.d.ts b/build/jetpack-compose/SplitButton/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..4c228bd16b10c8d08d96c96bb143e07769d06aa6
--- /dev/null
+++ b/build/jetpack-compose/SplitButton/index.d.ts
@@ -0,0 +1,73 @@
+import type { ReactNode } from 'react';
+import type { ModifierConfig } from '../../types';
+import type { ButtonColors } from '../Button';
+export interface SplitButtonLayoutProps {
+ /**
+ * A `SplitButtonLayout.LeadingButton` and a `SplitButtonLayout.TrailingButton`.
+ */
+ children: ReactNode;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+}
+export interface SplitButtonLeadingButtonProps {
+ /**
+ * Callback that is called when the leading button is clicked.
+ */
+ onClick?: () => void;
+ /**
+ * Whether the button is enabled for user interaction.
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Colors for button elements.
+ */
+ colors?: ButtonColors;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+ /**
+ * Content to display inside the button.
+ */
+ children: ReactNode;
+}
+export interface SplitButtonTrailingButtonProps {
+ /**
+ * Whether the trailing button is checked, usually while its menu is expanded.
+ */
+ checked: boolean;
+ /**
+ * Callback that is called when the checked state changes.
+ */
+ onCheckedChange?: (checked: boolean) => void;
+ /**
+ * Whether the button is enabled for user interaction.
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Colors for button elements.
+ */
+ colors?: ButtonColors;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+ /**
+ * Content to display inside the button, usually a chevron icon.
+ */
+ children: ReactNode;
+}
+/**
+ * A Material 3 split button: a leading action button and a trailing toggle button,
+ * usually anchoring a `DropdownMenu` of related actions.
+ */
+declare function SplitButtonLayout(props: SplitButtonLayoutProps): import("react/jsx-runtime").JSX.Element;
+declare namespace SplitButtonLayout {
+ var LeadingButton: (props: SplitButtonLeadingButtonProps) => import("react/jsx-runtime").JSX.Element;
+ var TrailingButton: (props: SplitButtonTrailingButtonProps) => import("react/jsx-runtime").JSX.Element;
+}
+export { SplitButtonLayout };
diff --git a/build/jetpack-compose/SplitButton/index.js b/build/jetpack-compose/SplitButton/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e723b1e28d30ba0410437eaa5a1a9a0f50e6ad4
--- /dev/null
+++ b/build/jetpack-compose/SplitButton/index.js
@@ -0,0 +1,47 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+import { requireNativeView } from 'expo';
+import { createViewModifierEventListener } from '../modifiers/utils';
+const SplitButtonLayoutNativeView = requireNativeView('ExpoUI', 'SplitButtonLayoutView');
+const LeadingButtonNativeView = requireNativeView('ExpoUI', 'SplitButtonLeadingButtonView');
+const TrailingButtonNativeView = requireNativeView('ExpoUI', 'SplitButtonTrailingButtonView');
+const SlotNativeView = requireNativeView('ExpoUI', 'SlotView');
+function LeadingButton(props) {
+ const { onClick, modifiers, ...restProps } = props;
+ return /*#__PURE__*/ _jsx(SlotNativeView, {
+ slotName: "leadingButton",
+ children: /*#__PURE__*/ _jsx(LeadingButtonNativeView, {
+ modifiers: modifiers,
+ ...modifiers ? createViewModifierEventListener(modifiers) : undefined,
+ ...restProps,
+ enabled: props.enabled ?? true,
+ onButtonPressed: onClick ? ()=>onClick() : undefined
+ })
+ });
+}
+function TrailingButton(props) {
+ const { onCheckedChange, modifiers, ...restProps } = props;
+ return /*#__PURE__*/ _jsx(SlotNativeView, {
+ slotName: "trailingButton",
+ children: /*#__PURE__*/ _jsx(TrailingButtonNativeView, {
+ modifiers: modifiers,
+ ...modifiers ? createViewModifierEventListener(modifiers) : undefined,
+ ...restProps,
+ enabled: props.enabled ?? true,
+ onCheckedChange: onCheckedChange ? ({ nativeEvent: { checked } })=>onCheckedChange(checked) : undefined
+ })
+ });
+}
+/**
+ * A Material 3 split button: a leading action button and a trailing toggle button,
+ * usually anchoring a `DropdownMenu` of related actions.
+ */ function SplitButtonLayout(props) {
+ const { modifiers, ...restProps } = props;
+ return /*#__PURE__*/ _jsx(SplitButtonLayoutNativeView, {
+ modifiers: modifiers,
+ ...modifiers ? createViewModifierEventListener(modifiers) : undefined,
+ ...restProps
+ });
+}
+SplitButtonLayout.LeadingButton = LeadingButton;
+SplitButtonLayout.TrailingButton = TrailingButton;
+export { SplitButtonLayout };
diff --git a/build/jetpack-compose/TopAppBar/index.d.ts b/build/jetpack-compose/TopAppBar/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..63afa28d56a9b0260de16d32e08bd7405e2c517d
--- /dev/null
+++ b/build/jetpack-compose/TopAppBar/index.d.ts
@@ -0,0 +1,15 @@
+import type { ReactNode } from 'react';
+import type { ColorValue } from 'react-native';
+import type { ExpoModifier } from '../../types';
+export interface TopAppBarProps {
+ children: ReactNode;
+ colors?: { containerColor?: ColorValue; titleContentColor?: ColorValue; navigationIconContentColor?: ColorValue; actionIconContentColor?: ColorValue };
+ applyWindowInsets?: boolean;
+ modifiers?: ExpoModifier[];
+}
+export declare function TopAppBar(props: TopAppBarProps): import('react/jsx-runtime').JSX.Element;
+export declare namespace TopAppBar {
+ var Title: ({ children }: { children: ReactNode }) => import('react/jsx-runtime').JSX.Element;
+ var NavigationIcon: ({ children }: { children: ReactNode }) => import('react/jsx-runtime').JSX.Element;
+ var Actions: ({ children }: { children: ReactNode }) => import('react/jsx-runtime').JSX.Element;
+}
diff --git a/build/jetpack-compose/TopAppBar/index.js b/build/jetpack-compose/TopAppBar/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..c6557fe6cb559c7d922fc02ce25fa2bf080a50d6
--- /dev/null
+++ b/build/jetpack-compose/TopAppBar/index.js
@@ -0,0 +1,11 @@
+import { jsx } from 'react/jsx-runtime';
+import { requireNativeView } from 'expo';
+import { createViewModifierEventListener } from '../modifiers/utils';
+const NativeTopAppBar = requireNativeView('ExpoUI', 'TopAppBarView');
+const Slot = requireNativeView('ExpoUI', 'SlotView');
+export function TopAppBar({ modifiers, ...props }) {
+ return jsx(NativeTopAppBar, { ...props, modifiers, ...(modifiers ? createViewModifierEventListener(modifiers) : undefined) });
+}
+TopAppBar.Title = function Title({ children }) { return jsx(Slot, { style: { position: 'absolute' }, slotName: 'title', children }); };
+TopAppBar.NavigationIcon = function NavigationIcon({ children }) { return jsx(Slot, { style: { position: 'absolute' }, slotName: 'navigationIcon', children }); };
+TopAppBar.Actions = function Actions({ children }) { return jsx(Slot, { style: { position: 'absolute' }, slotName: 'actions', children }); };
diff --git a/build/jetpack-compose/index.d.ts b/build/jetpack-compose/index.d.ts
index fa70b3574c4c40753b683a98c053caaf63e0385b..96fbbbeaba8396cc9c5cf255c61991bbb2afa899 100644
--- a/build/jetpack-compose/index.d.ts
+++ b/build/jetpack-compose/index.d.ts
@@ -1,3 +1,4 @@
+export * from './TopAppBar';
import './MaterialSymbolsAssetsTransformer.fx';
export * from './AlertDialog';
export * from './Badge';
@@ -21,6 +22,7 @@ export * from './ListItem';
export * from './RNHostView';
export * from './DatePicker';
export * from './SegmentedButton';
+export * from './SplitButton';
export * from './Progress';
export * from './Slider';
export * from './Spacer';
diff --git a/build/jetpack-compose/index.js b/build/jetpack-compose/index.js
index 2457ed1be68b4295442f24a6175fa347cbf80cdb..f394321920fbf1ebb6c7c68bb46690538a05aa0d 100644
--- a/build/jetpack-compose/index.js
+++ b/build/jetpack-compose/index.js
@@ -1,3 +1,4 @@
+export * from './TopAppBar';
import './MaterialSymbolsAssetsTransformer.fx';
export * from './AlertDialog';
export * from './Badge';
@@ -21,6 +22,7 @@ export * from './ListItem';
export * from './RNHostView';
export * from './DatePicker';
export * from './SegmentedButton';
+export * from './SplitButton';
export * from './Progress';
export * from './Slider';
export * from './Spacer';
diff --git a/src/jetpack-compose/Host/index.tsx b/src/jetpack-compose/Host/index.tsx
index e994f6e1fbad28414207482deeceb542a7b95746..d0ed70a3b9ab0ce5e5c1fd9106c0759f181b6e96 100644
--- a/src/jetpack-compose/Host/index.tsx
+++ b/src/jetpack-compose/Host/index.tsx
@@ -12,7 +12,7 @@ import {
import { NativeTreeContext, useWarnIfNestedHost } from '../../NativeTreeContext';
import { TextInputHostProvider, useTextInputHostRef } from '../../keyboard';
import { useMergeRefs } from '../../utils/useMergeRefs';
-import { getMaterialColors, HostPaletteContext } from '../colors';
+import { getMaterialColors, HostPaletteContext, type MaterialColors } from '../colors';
import { type PrimitiveBaseProps } from '../layout';
export interface HostProps extends PrimitiveBaseProps {
@@ -52,6 +52,9 @@ export interface HostProps extends PrimitiveBaseProps {
*/
seedColor?: ColorValue;
+ /** Explicit Material roles, applied after the seed or system palette. */
+ colorOverrides?: Partial<MaterialColors>;
+
/**
* The layout direction for the content.
* Defaults to the current locale direction from I18nManager.
@@ -93,6 +96,7 @@ export function Host(props: HostProps) {
layoutDirection,
colorScheme,
seedColor,
+ colorOverrides,
ref,
children,
...restProps
@@ -102,8 +106,8 @@ export function Host(props: HostProps) {
const systemScheme = useRNColorScheme();
const resolvedScheme = schemeString ?? (systemScheme === 'dark' ? 'dark' : 'light');
const palette = useMemo(
- () => getMaterialColors({ scheme: resolvedScheme, seedColor }),
- [resolvedScheme, seedColor]
+ () => ({ ...getMaterialColors({ scheme: resolvedScheme, seedColor }), ...colorOverrides }),
+ [resolvedScheme, seedColor, colorOverrides]
);
const hostRef = useTextInputHostRef();
const mergedRef = useMergeRefs(ref, hostRef);
@@ -123,6 +127,7 @@ export function Host(props: HostProps) {
}
colorScheme={schemeString}
seedColor={seedColor}
+ colorOverrides={colorOverrides}
onLayoutContent={onLayoutContent}
layoutDirection={
layoutDirection ?? (I18nManager.getConstants().isRTL ? 'rightToLeft' : 'leftToRight')
diff --git a/src/jetpack-compose/SplitButton/index.tsx b/src/jetpack-compose/SplitButton/index.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..05cba2bfa15b553f74ccacac0b889fae73b13007
--- /dev/null
+++ b/src/jetpack-compose/SplitButton/index.tsx
@@ -0,0 +1,142 @@
+import { requireNativeView } from 'expo';
+import type { ReactNode } from 'react';
+
+import type { ModifierConfig, ViewEvent } from '../../types';
+import type { ButtonColors } from '../Button';
+import { createViewModifierEventListener } from '../modifiers/utils';
+
+export interface SplitButtonLayoutProps {
+ /**
+ * A `SplitButtonLayout.LeadingButton` and a `SplitButtonLayout.TrailingButton`.
+ */
+ children: ReactNode;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+}
+
+export interface SplitButtonLeadingButtonProps {
+ /**
+ * Callback that is called when the leading button is clicked.
+ */
+ onClick?: () => void;
+ /**
+ * Whether the button is enabled for user interaction.
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Colors for button elements.
+ */
+ colors?: ButtonColors;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+ /**
+ * Content to display inside the button.
+ */
+ children: ReactNode;
+}
+
+export interface SplitButtonTrailingButtonProps {
+ /**
+ * Whether the trailing button is checked, usually while its menu is expanded.
+ */
+ checked: boolean;
+ /**
+ * Callback that is called when the checked state changes.
+ */
+ onCheckedChange?: (checked: boolean) => void;
+ /**
+ * Whether the button is enabled for user interaction.
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Colors for button elements.
+ */
+ colors?: ButtonColors;
+ /**
+ * Modifiers for the component.
+ */
+ modifiers?: ModifierConfig[];
+ /**
+ * Content to display inside the button, usually a chevron icon.
+ */
+ children: ReactNode;
+}
+
+type NativeLeadingButtonProps = Omit<SplitButtonLeadingButtonProps, 'onClick'> &
+ ViewEvent<'onButtonPressed', void>;
+
+type NativeTrailingButtonProps = Omit<SplitButtonTrailingButtonProps, 'onCheckedChange'> &
+ ViewEvent<'onCheckedChange', { checked: boolean }>;
+
+const SplitButtonLayoutNativeView: React.ComponentType<SplitButtonLayoutProps> = requireNativeView(
+ 'ExpoUI',
+ 'SplitButtonLayoutView'
+);
+const LeadingButtonNativeView: React.ComponentType<NativeLeadingButtonProps> = requireNativeView(
+ 'ExpoUI',
+ 'SplitButtonLeadingButtonView'
+);
+const TrailingButtonNativeView: React.ComponentType<NativeTrailingButtonProps> = requireNativeView(
+ 'ExpoUI',
+ 'SplitButtonTrailingButtonView'
+);
+const SlotNativeView: React.ComponentType<{ slotName: string; children: ReactNode }> =
+ requireNativeView('ExpoUI', 'SlotView');
+
+function LeadingButton(props: SplitButtonLeadingButtonProps) {
+ const { onClick, modifiers, ...restProps } = props;
+ return (
+ <SlotNativeView slotName="leadingButton">
+ <LeadingButtonNativeView
+ modifiers={modifiers}
+ {...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
+ {...restProps}
+ enabled={props.enabled ?? true}
+ onButtonPressed={onClick ? () => onClick() : undefined}
+ />
+ </SlotNativeView>
+ );
+}
+
+function TrailingButton(props: SplitButtonTrailingButtonProps) {
+ const { onCheckedChange, modifiers, ...restProps } = props;
+ return (
+ <SlotNativeView slotName="trailingButton">
+ <TrailingButtonNativeView
+ modifiers={modifiers}
+ {...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
+ {...restProps}
+ enabled={props.enabled ?? true}
+ onCheckedChange={
+ onCheckedChange ? ({ nativeEvent: { checked } }) => onCheckedChange(checked) : undefined
+ }
+ />
+ </SlotNativeView>
+ );
+}
+
+/**
+ * A Material 3 split button: a leading action button and a trailing toggle button,
+ * usually anchoring a `DropdownMenu` of related actions.
+ */
+function SplitButtonLayout(props: SplitButtonLayoutProps) {
+ const { modifiers, ...restProps } = props;
+ return (
+ <SplitButtonLayoutNativeView
+ modifiers={modifiers}
+ {...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
+ {...restProps}
+ />
+ );
+}
+
+SplitButtonLayout.LeadingButton = LeadingButton;
+SplitButtonLayout.TrailingButton = TrailingButton;
+
+export { SplitButtonLayout };
diff --git a/src/jetpack-compose/TopAppBar/index.tsx b/src/jetpack-compose/TopAppBar/index.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..ca6982443d5711c48e90e79a57b794055efbfcb5
--- /dev/null
+++ b/src/jetpack-compose/TopAppBar/index.tsx
@@ -0,0 +1,28 @@
+import { requireNativeView } from 'expo';
+import type { ReactNode, ComponentType } from 'react';
+import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
+import type { ExpoModifier } from '../../types';
+import { createViewModifierEventListener } from '../modifiers/utils';
+
+export interface TopAppBarProps {
+ children: ReactNode;
+ colors?: {
+ containerColor?: ColorValue;
+ titleContentColor?: ColorValue;
+ navigationIconContentColor?: ColorValue;
+ actionIconContentColor?: ColorValue;
+ };
+ /** False when the React Native parent already applies safe-area padding. */
+ applyWindowInsets?: boolean;
+ modifiers?: ExpoModifier[];
+}
+const NativeTopAppBar: ComponentType<TopAppBarProps> = requireNativeView('ExpoUI', 'TopAppBarView');
+const Slot: ComponentType<{ slotName: string; children: ReactNode; style?: StyleProp<ViewStyle> }> = requireNativeView('ExpoUI', 'SlotView');
+
+/** Compose positions the slots; absolute Yoga layout avoids double-counting their offsets. */
+export function TopAppBar({ modifiers, ...props }: TopAppBarProps) {
+ return <NativeTopAppBar {...props} modifiers={modifiers} {...(modifiers ? createViewModifierEventListener(modifiers) : undefined)} />;
+}
+TopAppBar.Title = function Title({ children }: { children: ReactNode }) { return <Slot style={{ position: "absolute" }} slotName="title">{children}</Slot>; };
+TopAppBar.NavigationIcon = function NavigationIcon({ children }: { children: ReactNode }) { return <Slot style={{ position: "absolute" }} slotName="navigationIcon">{children}</Slot>; };
+TopAppBar.Actions = function Actions({ children }: { children: ReactNode }) { return <Slot style={{ position: "absolute" }} slotName="actions">{children}</Slot>; };
diff --git a/src/jetpack-compose/index.ts b/src/jetpack-compose/index.ts
index 77fe3d7412fb0ef423e3d7a870676ebb54f07350..08ab59f63c7b40f4727500a37d95bed4f262de82 100644
--- a/src/jetpack-compose/index.ts
+++ b/src/jetpack-compose/index.ts
@@ -1,3 +1,4 @@
+export * from './TopAppBar';
import './MaterialSymbolsAssetsTransformer.fx';
export * from './AlertDialog';
@@ -22,6 +23,7 @@ export * from './ListItem';
export * from './RNHostView';
export * from './DatePicker';
export * from './SegmentedButton';
+export * from './SplitButton';
export * from './Progress';
export * from './Slider';
export * from './Spacer';