import { css } from '@emotion/react'; import { useMemo } from 'react'; import { androidPermissions, AndroidPermission, PermissionReference } from './data'; import { Callout } from '~/ui/components/Callout'; import { Cell, HeaderCell, Row, Table, TableHead } from '~/ui/components/Table'; import { CODE, P, createPermalinkedComponent } from '~/ui/components/Text'; // TODO(cedric): all commented code is related to the "granter" column. // This column defines if the permission is granted by the system or user (requires notification). // We have to clearly communicate what it means before showing it to the user. type AndroidPermissionsProps = { permissions: PermissionReference[]; }; // const grantedByInfo = 'Some permissions are granted by the system without user approval'; export function AndroidPermissions({ permissions }: AndroidPermissionsProps) { const list = useMemo(() => getPermissions(permissions), [permissions]); return ( Android Permission {/* Granted by */} Description {list.map(permission => ( ))}
); } const PermissionPermalink = createPermalinkedComponent(P, { baseNestingLevel: 4, }); function AndroidPermissionRow({ name, description, explanation, warning, apiDeprecated, }: AndroidPermission) { return ( {name} {/* {getPermissionGranter(permission)} */} {!!description && (

{description}

)} {!!warning && ( {warning} )} {explanation && !warning && ( )}
); } function getPermissions(permissions: AndroidPermissionsProps['permissions']) { return permissions .map(permission => typeof permission === 'string' ? androidPermissions[permission] : { ...androidPermissions[permission.name], ...permission } ) .filter(Boolean); } // const grantedByInfoStyle = css` // white-space: nowrap; // `; const descriptionSpaceStyle = css` margin-bottom: 1rem; `; const quoteStyle = css` margin-bottom: 0; `; // function getPermissionGranter(permission: AndroidPermission): 'user' | 'system' | 'none' { // if (!permission.protection) return 'none'; // if (permission.protection.includes('dangerous')) return 'user'; // return 'system'; // }