react-native-navigation的迁移库

Options.ts 15KB

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