react-native-navigation的迁移库

Options.ts 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. // tslint:disable jsdoc-format
  2. import { ImageRequireSource, Insets } from 'react-native';
  3. type Color = string;
  4. type FontFamily = string;
  5. type LayoutOrientation = 'portrait' | 'landscape';
  6. type AndroidDensityNumber = number;
  7. export interface OptionsSplitView {
  8. /**
  9. * Master view display mode
  10. * @default 'auto'
  11. */
  12. displayMode?: 'auto' | 'visible' | 'hidden' | 'overlay';
  13. /**
  14. * Master view side. Leading is left. Trailing is right.
  15. * @default 'leading'
  16. */
  17. primaryEdge?: 'leading' | 'trailing';
  18. /**
  19. * Set the minimum width of master view
  20. */
  21. minWidth?: number;
  22. /**
  23. * Set the maximum width of master view
  24. */
  25. maxWidth?: number;
  26. }
  27. export interface OptionsStatusBar {
  28. /**
  29. * Set the status bar visibility
  30. * @default true
  31. */
  32. visible?: boolean;
  33. /**
  34. * Set the text color of the status bar
  35. * @default 'light'
  36. */
  37. style?: 'light' | 'dark';
  38. /**
  39. * Set the background color of the status bar
  40. * #### (Android specific)
  41. */
  42. backgroundColor?: Color;
  43. /**
  44. * Draw screen behind the status bar
  45. * #### (Android specific)
  46. */
  47. drawBehind?: boolean;
  48. }
  49. export interface OptionsLayout {
  50. /**
  51. * Set the screen background color
  52. */
  53. backgroundColor?: Color;
  54. /**
  55. * Set the allowed orientations
  56. */
  57. orientation?: LayoutOrientation[];
  58. /**
  59. * Layout top margin
  60. * #### (Android specific)
  61. */
  62. topMargin?: number;
  63. }
  64. export enum OptionsModalPresentationStyle {
  65. 'formSheet',
  66. 'pageSheet',
  67. 'overFullScreen',
  68. 'overCurrentContext',
  69. 'currentContext',
  70. 'popOver',
  71. 'fullScreen',
  72. 'none',
  73. }
  74. export interface OptionsTopBarLargeTitle {
  75. /**
  76. * Enable large titles
  77. */
  78. visible?: boolean;
  79. /**
  80. * Set the font size of large title's text
  81. */
  82. fontSize?: number;
  83. /**
  84. * Set the color of large title's text
  85. */
  86. color?: Color;
  87. /**
  88. * Set the font family of large title's text
  89. */
  90. fontFamily?: FontFamily;
  91. }
  92. export interface OptionsTopBarTitle {
  93. /**
  94. * Text to display in the title area
  95. */
  96. text?: string;
  97. /**
  98. * Font size
  99. */
  100. fontSize?: number;
  101. /**
  102. * Text color
  103. */
  104. color?: Color;
  105. /**
  106. * Title font family
  107. *
  108. * Make sure that the font is available
  109. */
  110. fontFamily?: FontFamily;
  111. /**
  112. * Custom component as the title view
  113. */
  114. component?: {
  115. /**
  116. * Component reference id, Auto generated if empty
  117. */
  118. id?: string;
  119. /**
  120. * Name of your component
  121. */
  122. name: string;
  123. /**
  124. * Set component alignment
  125. */
  126. alignment?: 'center' | 'fill';
  127. /**
  128. * Properties to pass down to the component
  129. */
  130. passProps?: object;
  131. };
  132. /**
  133. * Top Bar title height in densitiy pixels
  134. * #### (Android specific)
  135. */
  136. height?: number;
  137. /**
  138. * Title alignment
  139. * #### (Android specific)
  140. */
  141. alignment?: 'center' | 'fill';
  142. }
  143. export interface OptionsTopBarSubtitle {
  144. /**
  145. * Set subtitle text
  146. */
  147. text?: string;
  148. /**
  149. * Set subtitle font size
  150. */
  151. fontSize?: number;
  152. /**
  153. * Set subtitle color
  154. */
  155. color?: Color;
  156. /**
  157. * Set subtitle font family
  158. */
  159. fontFamily?: FontFamily;
  160. /**
  161. * Set subtitle alignment
  162. */
  163. alignment?: 'center';
  164. }
  165. export interface OptionsTopBarBackButton {
  166. /**
  167. * Image to show as the back button
  168. */
  169. icon?: ImageRequireSource;
  170. /**
  171. * Weither the back button is visible or not
  172. * @default true
  173. */
  174. visible?: boolean;
  175. /**
  176. * Set the back button title
  177. * #### (iOS specific)
  178. */
  179. title?: string;
  180. /**
  181. * Show title or just the icon
  182. * #### (iOS specific)
  183. */
  184. showTitle?: boolean;
  185. /**
  186. * Back button icon and text color
  187. */
  188. color?: Color;
  189. }
  190. export interface OptionsTopBarBackground {
  191. /**
  192. * Background color of the top bar
  193. */
  194. color?: Color;
  195. /**
  196. * Clip the top bar background to bounds if set to true.
  197. * #### (iOS specific)
  198. */
  199. clipToBounds?: boolean;
  200. /**
  201. * Set a custom component for the Top Bar background
  202. */
  203. component?: {
  204. name?: string;
  205. };
  206. /**
  207. * Allows the NavBar to be translucent (blurred)
  208. * #### (iOS specific)
  209. */
  210. translucent?: boolean;
  211. /**
  212. * Enable background blur
  213. * #### (iOS specific)
  214. */
  215. blur?: boolean;
  216. }
  217. export interface OptionsTopBarButton {
  218. /**
  219. * Button id for reference press event
  220. */
  221. id: string;
  222. /**
  223. * Set the button icon
  224. */
  225. icon?: ImageRequireSource;
  226. /**
  227. * Set the button as a custom component
  228. */
  229. component?: {
  230. name: string;
  231. /**
  232. * Properties to pass down to the component
  233. */
  234. passProps?: object;
  235. };
  236. /**
  237. * Set the button text
  238. */
  239. text?: string;
  240. /**
  241. * Set the button enabled or disabled
  242. * @default true
  243. */
  244. enabled?: boolean;
  245. /**
  246. * Disable icon tinting
  247. */
  248. disableIconTint?: boolean;
  249. /**
  250. * Set text color
  251. */
  252. color?: Color;
  253. /**
  254. * Set text color in disabled state
  255. */
  256. disabledColor?: Color;
  257. /**
  258. * Set testID for reference in E2E tests
  259. */
  260. testID?: string;
  261. }
  262. export interface OptionsTopBar {
  263. /**
  264. * Show or hide the top bar
  265. */
  266. visible?: boolean;
  267. /**
  268. * Controls whether TopBar visibility changes should be animated
  269. */
  270. animate?: boolean;
  271. /**
  272. * Top bar will hide and show based on users scroll direction
  273. */
  274. hideOnScroll?: boolean;
  275. /**
  276. * Change button colors in the top bar
  277. */
  278. buttonColor?: Color;
  279. /**
  280. * Draw behind the navbar
  281. */
  282. drawBehind?: boolean;
  283. /**
  284. * Can be used to reference the top bar in E2E tests
  285. */
  286. testID?: string;
  287. /**
  288. * Title configuration
  289. */
  290. title?: OptionsTopBarTitle;
  291. /**
  292. * Subtitle configuration
  293. */
  294. subtitle?: OptionsTopBarSubtitle;
  295. /**
  296. * Back button configuration
  297. */
  298. backButton?: OptionsTopBarBackButton;
  299. /**
  300. * List of buttons to the left
  301. */
  302. leftButtons?: OptionsTopBarButton[];
  303. /**
  304. * List of buttons to the right
  305. */
  306. rightButtons?: OptionsTopBarButton[];
  307. /**
  308. * Background configuration
  309. */
  310. background?: OptionsTopBarBackground;
  311. /**
  312. * Control the NavBar blur style
  313. * #### (iOS specific)
  314. * @requires translucent: true
  315. * @default 'default'
  316. */
  317. barStyle?: 'default' | 'black';
  318. /**
  319. * Disable the border on bottom of the navbar
  320. * #### (iOS specific)
  321. * @default false
  322. */
  323. noBorder?: boolean;
  324. /**
  325. * Show a UISearchBar in the Top Bar
  326. * #### (iOS 11+ specific)
  327. */
  328. searchBar?: boolean;
  329. /**
  330. * Hides the UISearchBar when scrolling
  331. * #### (iOS 11+ specific)
  332. */
  333. searchBarHiddenWhenScrolling?: boolean;
  334. /**
  335. * The placeholder value in the UISearchBar
  336. * #### (iOS 11+ specific)
  337. */
  338. searchBarPlaceholder?: string;
  339. /**
  340. * Control the Large Title configuration
  341. * #### (iOS 11+ specific)
  342. */
  343. largeTitle?: OptionsTopBarLargeTitle;
  344. /**
  345. * Set the height of the navbar in dp
  346. * #### (Android specific)
  347. */
  348. height?: AndroidDensityNumber;
  349. /**
  350. * Change the navbar border color
  351. * #### (Android specific)
  352. */
  353. borderColor?: Color;
  354. /**
  355. * Set the border height of the navbar in dp
  356. * #### (Android specific)
  357. */
  358. borderHeight?: AndroidDensityNumber;
  359. /**
  360. * Set the elevation of the navbar in dp
  361. * #### (Android specific)
  362. */
  363. elevation?: AndroidDensityNumber;
  364. }
  365. export interface OptionsBottomTabs {
  366. /**
  367. * Show or hide the bottom tabs
  368. */
  369. visible?: boolean;
  370. /**
  371. * Enable animations when toggling visibility
  372. */
  373. animate?: boolean;
  374. /**
  375. * Switch to another screen within the bottom tabs via index (starting from 0)
  376. */
  377. currentTabIndex?: number;
  378. /**
  379. * Switch to another screen within the bottom tabs via screen name
  380. */
  381. currentTabId?: string;
  382. /**
  383. * Set a testID to reference the bottom tabs
  384. */
  385. testID?: string;
  386. /**
  387. * Draw screen component under the tab bar
  388. */
  389. drawBehind?: boolean;
  390. /**
  391. * Set a background color for the bottom tabs
  392. */
  393. backgroundColor?: Color;
  394. /**
  395. * Control the Bottom Tabs blur style
  396. * #### (iOS specific)
  397. * @requires translucent: true
  398. * @default 'default'
  399. */
  400. barStyle?: 'default' | 'black';
  401. /**
  402. * Allows the Bottom Tabs to be translucent (blurred)
  403. * #### (iOS specific)
  404. */
  405. translucent?: boolean;
  406. /**
  407. * Hide the top line of the Tab Bar
  408. * #### (iOS specific)
  409. */
  410. hideShadow?: boolean;
  411. /**
  412. * Control the text display mode below the tab icon
  413. * #### (Android specific)
  414. */
  415. titleDisplayMode?: 'alwaysShow' | 'showWhenActive' | 'alwaysHide';
  416. /**
  417. * Set the elevation of the Bottom Tabs in dp
  418. * #### (Android specific)
  419. */
  420. elevation?: AndroidDensityNumber;
  421. }
  422. export interface OptionsBottomTab {
  423. /**
  424. * Set the text to display below the icon
  425. */
  426. text?: string;
  427. /**
  428. * Set the text in a badge that is overlayed over the component
  429. */
  430. badge?: string;
  431. /**
  432. * Set the background color of the badge that is overlayed over the component
  433. */
  434. badgeColor?: string;
  435. /**
  436. * Set a testID to reference the tab in E2E tests
  437. */
  438. testID?: string;
  439. /**
  440. * Set the tab icon
  441. */
  442. icon?: ImageRequireSource;
  443. /**
  444. * Set the icon tint
  445. */
  446. iconColor?: Color;
  447. /**
  448. * Set the text color
  449. */
  450. textColor?: Color;
  451. /**
  452. * Set the selected icon tint
  453. */
  454. selectedIconColor?: Color;
  455. /**
  456. * Set the selected text color
  457. */
  458. selectedTextColor?: Color;
  459. /**
  460. * Set the text font family
  461. */
  462. fontFamily?: FontFamily;
  463. /**
  464. * Set the text font size
  465. */
  466. fontSize?: number;
  467. /**
  468. * Set the insets of the icon
  469. * #### (iOS specific)
  470. */
  471. iconInsets?: Insets;
  472. /**
  473. * Set selected icon image
  474. * #### (iOS specific)
  475. */
  476. selectedIcon?: ImageRequireSource;
  477. /**
  478. * Set true if you want to disable the icon tinting
  479. * #### (iOS specific)
  480. */
  481. disableIconTint?: boolean;
  482. /**
  483. * Set true if you want to disable the text tinting
  484. * #### (iOS specific)
  485. */
  486. disableSelectedIconTint?: boolean;
  487. /**
  488. * Set the font size for selected tabs
  489. * #### (Android specific)
  490. */
  491. selectedFontSize?: number;
  492. }
  493. export interface SideMenuSide {
  494. /**
  495. * Show or hide the side menu
  496. */
  497. visible?: boolean;
  498. /**
  499. * Enable or disable the side menu
  500. */
  501. enabled?: boolean;
  502. }
  503. export interface OptionsSideMenu {
  504. /**
  505. * Configure the left side menu
  506. */
  507. left?: SideMenuSide;
  508. /**
  509. * Configure the right side menu
  510. */
  511. right?: SideMenuSide;
  512. /**
  513. * Configure how a user is allowed to open a drawer using gestures
  514. * #### (iOS specific)
  515. * @default 'entireScreen'
  516. */
  517. openGestureMode?: 'entireScreen' | 'bezel';
  518. }
  519. export interface OptionsOverlay {
  520. /**
  521. * Capture touches outside of the Component View
  522. */
  523. interceptTouchOutside?: boolean;
  524. }
  525. export interface OptionsPreviewAction {
  526. /**
  527. * Reference ID to get callbacks from
  528. */
  529. id: string;
  530. /**
  531. * Action text
  532. */
  533. title: string;
  534. /**
  535. * Action style
  536. */
  537. style?: 'default' | 'selected' | 'destructive';
  538. /**
  539. * Subactions that will be shown when this action is pressed.
  540. */
  541. actions?: OptionsPreviewAction[];
  542. }
  543. export interface OptionsPreview {
  544. /**
  545. * Pass a react node tag to mark a SourceRect for a specific
  546. * peek and pop preview element.
  547. */
  548. reactTag?: number;
  549. /**
  550. * You can set this property specify the width of the preview.
  551. * If the width is greater than the device width, it will be zoomed in.
  552. */
  553. width?: number;
  554. /**
  555. * Height of the preview
  556. */
  557. height?: 100;
  558. /**
  559. * You can control if the users gesture will result in pushing
  560. * the preview screen into the stack.
  561. */
  562. commit?: boolean;
  563. /**
  564. * List of actions that will appear underneath the preview window.
  565. * They can be nested for sub actions.
  566. */
  567. actions?: OptionsPreviewAction[];
  568. }
  569. export interface OptionsAnimationPropertyConfig {
  570. /**
  571. * Animate from this value, ex. 0
  572. */
  573. from?: number;
  574. /**
  575. * Animate to this value, ex. 1
  576. */
  577. to?: number;
  578. /**
  579. * Animation duration
  580. * @default 300
  581. */
  582. duration?: number;
  583. /**
  584. * Animation delay
  585. * @default 0
  586. */
  587. startDelay?: number;
  588. /**
  589. * Animation interplation
  590. */
  591. interpolation?: 'accelerate' | 'decelerate';
  592. }
  593. export interface OptionsAnimationProperties {
  594. /**
  595. * Animate the element over translateX
  596. */
  597. x?: OptionsAnimationPropertyConfig;
  598. /**
  599. * Animate the element over translateY
  600. */
  601. y?: OptionsAnimationPropertyConfig;
  602. /**
  603. * Animate the element over opacity
  604. */
  605. alpha?: OptionsAnimationPropertyConfig;
  606. /**
  607. * Animate the element over scaleX
  608. */
  609. scaleX?: OptionsAnimationPropertyConfig;
  610. /**
  611. * Animate the element over scaleY
  612. */
  613. scaleY?: OptionsAnimationPropertyConfig;
  614. /**
  615. * Animate the element over rotationX
  616. */
  617. rotationX?: OptionsAnimationPropertyConfig;
  618. /**
  619. * Animate the element over rotationY
  620. */
  621. rotationY?: OptionsAnimationPropertyConfig;
  622. /**
  623. * Animate the element over rotation
  624. */
  625. rotation?: OptionsAnimationPropertyConfig;
  626. }
  627. export interface OptionsAnimationPropertiesId extends OptionsAnimationProperties {
  628. /**
  629. * ID of the Top Bar we want to animate
  630. */
  631. id?: string;
  632. }
  633. export interface OptionsAnimationSeparate {
  634. /**
  635. * Configure animations for the top bar
  636. */
  637. topBar?: OptionsAnimationPropertiesId;
  638. /**
  639. * Configure animations for the bottom tabs
  640. */
  641. bottomTabs?: OptionsAnimationPropertiesId;
  642. /**
  643. * Configure animations for the content (Screen)
  644. */
  645. content?: OptionsAnimationPropertiesId;
  646. }
  647. export interface OptionsAnimations {
  648. /**
  649. * Configure the setRoot animation
  650. */
  651. setRoot?: OptionsAnimationProperties;
  652. /**
  653. * Configure what animates when a screen is pushed
  654. */
  655. push?: OptionsAnimationSeparate;
  656. /**
  657. * Configure what animates when a screen is popped
  658. */
  659. pop?: OptionsAnimationSeparate;
  660. /**
  661. * Configure what animates when modal is shown
  662. */
  663. showModal?: OptionsAnimationProperties;
  664. /**
  665. * Configure what animates when modal is dismissed
  666. */
  667. dismissModal?: OptionsAnimationProperties;
  668. }
  669. export interface Options {
  670. /**
  671. * Configure the status bar
  672. */
  673. statusBar?: OptionsStatusBar;
  674. /**
  675. * Configure the layout
  676. */
  677. layout?: OptionsLayout;
  678. /**
  679. * Configure the presentation style of the modal
  680. */
  681. modalPresentationStyle?: OptionsModalPresentationStyle;
  682. /**
  683. * Configure the top bar
  684. */
  685. topBar?: OptionsTopBar;
  686. /**
  687. * Configure the bottom tabs
  688. */
  689. bottomTabs?: OptionsBottomTabs;
  690. /**
  691. * Configure the bottom tab associated to the screen
  692. */
  693. bottomTab?: OptionsBottomTab;
  694. /**
  695. * Configure the side menu
  696. */
  697. sideMenu?: OptionsSideMenu;
  698. /**
  699. * Configure the overlay
  700. */
  701. overlay?: OptionsOverlay;
  702. /**
  703. * Animation used for navigation commands that modify the layout
  704. * hierarchy can be controlled in options.
  705. *
  706. * Animations can be modified per command and it's also possible
  707. * to change the default animation for each command.
  708. *
  709. * Example:
  710. ```js
  711. setRoot: {
  712. y: {
  713. from: 1000,
  714. to: 0,
  715. duration: 500,
  716. interpolation: 'accelerate',
  717. },
  718. alpha: {
  719. from: 0,
  720. to: 1,
  721. duration: 400,
  722. startDelay: 100,
  723. interpolation: 'accelerate'
  724. }
  725. }
  726. ```
  727. */
  728. animations?: OptionsAnimations;
  729. /**
  730. * Preview configuration for Peek and Pop
  731. * #### (iOS specific)
  732. */
  733. preview?: OptionsPreview;
  734. /**
  735. * Enable or disable swipe back to pop gesture
  736. * #### (iOS specific)
  737. * @default true
  738. */
  739. popGesture?: boolean;
  740. /**
  741. * Background image for the screen
  742. * #### (iOS specific)
  743. */
  744. backgroundImage?: ImageRequireSource;
  745. /**
  746. * Background image for the Navigation View
  747. * #### (iOS specific)
  748. */
  749. rootBackgroundImage?: ImageRequireSource;
  750. /**
  751. * Enable or disable automatically blurring focused input, dismissing keyboard on unmount
  752. * #### (Android specific)
  753. * @default false
  754. */
  755. blurOnUnmount?: boolean;
  756. }