react-native-navigation的迁移库

CocktailsListMasterScreen.tsx 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const React = require('react');
  2. const CocktailsView = require('../sharedElementTransition/CocktailsView')
  3. const { Platform } = require('react-native');
  4. const Navigation = require('../../services/Navigation');
  5. const Screens = require('../Screens');
  6. import CocktailsListScreen from '../sharedElementTransition/CocktailsListScreen';
  7. import { NavigationButtonPressedEvent } from 'react-native-navigation';
  8. const {
  9. PUSH_MASTER_BTN
  10. } = require('../../testIDs');
  11. export default class CocktailsListMasterScreen extends CocktailsListScreen {
  12. static options() {
  13. return {
  14. ...Platform.select({
  15. android: {
  16. statusBar: {
  17. style: 'dark',
  18. backgroundColor: 'white'
  19. }
  20. }
  21. }),
  22. topBar: {
  23. title: {
  24. text: 'Cocktails'
  25. },
  26. rightButtons: [{
  27. id: 'pushMaster',
  28. testID: PUSH_MASTER_BTN,
  29. text: 'push'
  30. }]
  31. }
  32. }
  33. }
  34. constructor(props: any) {
  35. super(props);
  36. Navigation.events().bindComponent(this);
  37. }
  38. navigationButtonPressed(event: NavigationButtonPressedEvent) {
  39. if (event.buttonId === 'pushMaster') {
  40. Navigation.push(this, Screens.Pushed)
  41. }
  42. }
  43. render() {
  44. return (
  45. <CocktailsView
  46. onItemPress={this.updateDetailsScreen}
  47. onItemLongPress={this.pushCocktailDetails}
  48. />
  49. );
  50. }
  51. updateDetailsScreen = (item: any) => {
  52. Navigation.updateProps('DETAILS_COMPONENT_ID', item);
  53. }
  54. }