ManuallyRequestSheet.RequestButton
Primary action button component that handles authorization requests with Material Design contained styling and theme integration.
Quick Example
import { DataSync } from "@ovok/native";
import { BottomSheetModal } from "@gorhom/bottom-sheet";
import { HKQuantityTypeIdentifier } from "@kingstinct/react-native-healthkit";
import React from "react";
import { Text } from "react-native-paper";
const RequestButtonExample = () => {
const manuallyRequestSheetRef = React.useRef<BottomSheetModal | null>(null);
const shouldOpenManuallyRequestSheet = React.useRef(true);
const onRefManuallyRequestSheet = React.useCallback(
(ref: BottomSheetModal | null) => {
// This is a workaround to ensure the sheet is expanded when the ref is set (after the component is mounted)
// if you need to open sheet on button press, you can use the `shouldOpenManuallyRequestSheet` ref and remove the `if` check
manuallyRequestSheetRef.current = ref;
if (shouldOpenManuallyRequestSheet.current) {
ref?.present();
shouldOpenManuallyRequestSheet.current = false;
}
},
[],
);
const renderManualRequestUI = React.useCallback(
(requestAccess: () => void) => {
return (
<DataSync.ManuallyRequestSheet ref={onRefManuallyRequestSheet}>
<DataSync.ManuallyRequestSheet.Container>
<DataSync.ManuallyRequestSheet.RequestButton
onPress={requestAccess}
>
Request
</DataSync.ManuallyRequestSheet.RequestButton>
</DataSync.ManuallyRequestSheet.Container>
</DataSync.ManuallyRequestSheet>
);
},
[onRefManuallyRequestSheet],
);
return (
// This component is wrapped in the AppleHealthAuthorizationProvider
// to handle the authorization process
<DataSync.AppleHealthAuthorizationProvider
readIdentifiers={[HKQuantityTypeIdentifier.bodyMass]}
renderManualRequestUI={renderManualRequestUI}
skipRequest={false}
>
{/* You have to be authorized to sync the health data */}
<Text>Hello</Text>
</DataSync.AppleHealthAuthorizationProvider>
);
};
export default RequestButtonExample;
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
children | React.ReactNode | ✓ | - | Button text content |
mode | ButtonMode | - | contained | Button style mode |
onPress | () => void | - | - | Button press handler |
loading | boolean | - | false | Show loading state |
disabled | boolean | - | false | Disable button |
testID | string | - | - | Test identifier |
Inherits all ButtonProps from react-native-paper
Component Behavior
The RequestButton component provides:
- Primary Action: Uses Material Design
containedmode by default for prominence - Loading State: Built-in loading indicator during async operations
- Disabled State: Automatic styling when button is disabled
- Theme Integration: Uses theme primary color for contained styling
- Press Handling: Supports async operations with proper feedback
Styling
Theme Colors Used
theme.colors.primary- Button background (contained mode)theme.colors.onPrimary- Button text color (contained mode)theme.colors.primary- Text color (outlined/text modes)
Related Components
- ManuallyRequestSheet.SkipButton - Secondary action button typically used alongside
- ManuallyRequestSheet.Description - Description text that typically precedes the button
- ManuallyRequestSheet.Container - Container that holds the button