react-native-navigation的迁移库

Options.ts 14KB

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