react-native-navigation的迁移库

Options.ts 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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. export interface OptionsBottomTab {
  403. /**
  404. * Set the text to display below the icon
  405. */
  406. text?: string;
  407. /**
  408. * Set the text in a badge that is overlayed over the component
  409. */
  410. badge?: string;
  411. /**
  412. * Set a testID to reference the tab in E2E tests
  413. */
  414. testID?: string;
  415. /**
  416. * Set the tab icon
  417. */
  418. icon?: ImageRequireSource;
  419. /**
  420. * Set the icon tint
  421. */
  422. iconColor?: Color;
  423. /**
  424. * Set the text color
  425. */
  426. textColor?: Color;
  427. /**
  428. * Set the selected icon tint
  429. */
  430. selectedIconColor?: Color;
  431. /**
  432. * Set the selected text color
  433. */
  434. selectedTextColor?: Color;
  435. /**
  436. * Set the text font family
  437. */
  438. fontFamily?: FontFamily;
  439. /**
  440. * Set the text font size
  441. */
  442. fontSize?: number;
  443. /**
  444. * Set the insets of the icon
  445. * #### (iOS specific)
  446. */
  447. iconInsets?: Insets;
  448. /**
  449. * Set selected icon image
  450. * #### (iOS specific)
  451. */
  452. selectedIcon?: ImageRequireSource;
  453. /**
  454. * Set true if you want to disable the icon tinting
  455. * #### (iOS specific)
  456. */
  457. disableIconTint?: boolean;
  458. /**
  459. * Set true if you want to disable the text tinting
  460. * #### (iOS specific)
  461. */
  462. disableSelectedIconTint?: boolean;
  463. /**
  464. * Set the font size for selected tabs
  465. * #### (Android specific)
  466. */
  467. selectedFontSize?: number;
  468. }
  469. export interface SideMenuSide {
  470. /**
  471. * Show or hide the side menu
  472. */
  473. visible?: boolean;
  474. /**
  475. * Enable or disable the side menu
  476. */
  477. enabled?: boolean;
  478. }
  479. export interface OptionsSideMenu {
  480. /**
  481. * Configure the left side menu
  482. */
  483. left?: SideMenuSide;
  484. /**
  485. * Configure the right side menu
  486. */
  487. right?: SideMenuSide;
  488. }
  489. export interface OptionsOverlay {
  490. /**
  491. * Capture touches outside of the Component View
  492. */
  493. interceptTouchOutside?: boolean;
  494. }
  495. export interface OptionsPreviewAction {
  496. /**
  497. * Reference ID to get callbacks from
  498. */
  499. id: string;
  500. /**
  501. * Action text
  502. */
  503. title: string;
  504. /**
  505. * Action style
  506. */
  507. style?: 'default' | 'selected' | 'destructive';
  508. /**
  509. * Subactions that will be shown when this action is pressed.
  510. */
  511. actions?: OptionsPreviewAction[];
  512. }
  513. export interface OptionsPreview {
  514. /**
  515. * Pass a react node tag to mark a SourceRect for a specific
  516. * peek and pop preview element.
  517. */
  518. reactTag?: number;
  519. /**
  520. * You can set this property specify the width of the preview.
  521. * If the width is greater than the device width, it will be zoomed in.
  522. */
  523. width?: number;
  524. /**
  525. * Height of the preview
  526. */
  527. height?: 100;
  528. /**
  529. * You can control if the users gesture will result in pushing
  530. * the preview screen into the stack.
  531. */
  532. commit?: boolean;
  533. /**
  534. * List of actions that will appear underneath the preview window.
  535. * They can be nested for sub actions.
  536. */
  537. actions?: OptionsPreviewAction[];
  538. }
  539. export interface OptionsAnimationPropertyConfig {
  540. /**
  541. * Animate from this value, ex. 0
  542. */
  543. from?: number;
  544. /**
  545. * Animate to this value, ex. 1
  546. */
  547. to?: number;
  548. /**
  549. * Animation duration
  550. * @default 300
  551. */
  552. duration?: number;
  553. /**
  554. * Animation delay
  555. * @default 0
  556. */
  557. startDelay?: number;
  558. /**
  559. * Animation interplation
  560. */
  561. interpolation?: 'accelerate' | 'decelerate';
  562. }
  563. export interface OptionsAnimationProperties {
  564. /**
  565. * Animate the element over translateX
  566. */
  567. x?: OptionsAnimationPropertyConfig;
  568. /**
  569. * Animate the element over translateY
  570. */
  571. y?: OptionsAnimationPropertyConfig;
  572. /**
  573. * Animate the element over opacity
  574. */
  575. alpha?: OptionsAnimationPropertyConfig;
  576. /**
  577. * Animate the element over scaleX
  578. */
  579. scaleX?: OptionsAnimationPropertyConfig;
  580. /**
  581. * Animate the element over scaleY
  582. */
  583. scaleY?: OptionsAnimationPropertyConfig;
  584. /**
  585. * Animate the element over rotationX
  586. */
  587. rotationX?: OptionsAnimationPropertyConfig;
  588. /**
  589. * Animate the element over rotationY
  590. */
  591. rotationY?: OptionsAnimationPropertyConfig;
  592. /**
  593. * Animate the element over rotation
  594. */
  595. rotation?: OptionsAnimationPropertyConfig;
  596. }
  597. export interface OptionsAnimationPropertiesId extends OptionsAnimationProperties {
  598. /**
  599. * ID of the Top Bar we want to animate
  600. */
  601. id?: string;
  602. }
  603. export interface OptionsAnimationSeparate {
  604. /**
  605. * Configure animations for the top bar
  606. */
  607. topBar?: OptionsAnimationPropertiesId;
  608. /**
  609. * Configure animations for the bottom tabs
  610. */
  611. bottomTabs?: OptionsAnimationPropertiesId;
  612. /**
  613. * Configure animations for the content (Screen)
  614. */
  615. content?: OptionsAnimationPropertiesId;
  616. }
  617. export interface OptionsAnimations {
  618. /**
  619. * Configure the setRoot animation
  620. */
  621. setRoot?: OptionsAnimationProperties;
  622. /**
  623. * Configure what animates when a screen is pushed
  624. */
  625. push?: OptionsAnimationSeparate;
  626. /**
  627. * Configure what animates when a screen is popped
  628. */
  629. pop?: OptionsAnimationSeparate;
  630. /**
  631. * Configure what animates when modal is shown
  632. */
  633. showModal?: OptionsAnimationProperties;
  634. /**
  635. * Configure what animates when modal is dismissed
  636. */
  637. dismissModal?: OptionsAnimationProperties;
  638. }
  639. export interface Options {
  640. /**
  641. * Configure the status bar
  642. */
  643. statusBar?: OptionsStatusBar;
  644. /**
  645. * Configure the layout
  646. */
  647. layout?: OptionsLayout;
  648. /**
  649. * Configure the presentation style of the modal
  650. */
  651. modalPresentationStyle?: OptionsModalPresentationStyle;
  652. /**
  653. * Configure the top bar
  654. */
  655. topBar?: OptionsTopBar;
  656. /**
  657. * Configure the bottom tabs
  658. */
  659. bottomTabs?: OptionsBottomTabs;
  660. /**
  661. * Configure the bottom tab associated to the screen
  662. */
  663. bottomTab?: OptionsBottomTab;
  664. /**
  665. * Configure the side menu
  666. */
  667. sideMenu?: OptionsSideMenu;
  668. /**
  669. * Configure the overlay
  670. */
  671. overlay?: OptionsOverlay;
  672. /**
  673. * Animation used for navigation commands that modify the layout
  674. * hierarchy can be controlled in options.
  675. *
  676. * Animations can be modified per command and it's also possible
  677. * to change the default animation for each command.
  678. *
  679. * Example:
  680. ```js
  681. setRoot: {
  682. y: {
  683. from: 1000,
  684. to: 0,
  685. duration: 500,
  686. interpolation: 'accelerate',
  687. },
  688. alpha: {
  689. from: 0,
  690. to: 1,
  691. duration: 400,
  692. startDelay: 100,
  693. interpolation: 'accelerate'
  694. }
  695. }
  696. ```
  697. */
  698. animations?: OptionsAnimations;
  699. /**
  700. * Preview configuration for Peek and Pop
  701. * #### (iOS specific)
  702. */
  703. preview?: OptionsPreview;
  704. /**
  705. * Enable or disable swipe back to pop gesture
  706. * #### (iOS specific)
  707. * @default true
  708. */
  709. popGesture?: boolean;
  710. /**
  711. * Background image for the screen
  712. * #### (iOS specific)
  713. */
  714. backgroundImage?: ImageRequireSource;
  715. /**
  716. * Background image for the Navigation View
  717. * #### (iOS specific)
  718. */
  719. rootBackgroundImage?: ImageRequireSource;
  720. }