App.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import React, {useState} from 'react';
  2. import {
  3. NativeModules,
  4. StyleSheet,
  5. View,
  6. StatusBar,
  7. Text,
  8. TouchableOpacity,
  9. ActionSheetIOS,
  10. Platform,
  11. Button,
  12. } from 'react-native';
  13. import Icon from 'react-native-vector-icons/Ionicons';
  14. const App = () => {
  15. const {CallNative} = NativeModules;
  16. if (Platform.OS === 'ios') {
  17. CallNative.connect();
  18. }
  19. Icon.loadFont();
  20. const IconButton = ({onPress, iconName, iconSize, iconColor}: any) => {
  21. return (
  22. <TouchableOpacity onPress={onPress}>
  23. <Icon
  24. name={iconName}
  25. size={iconSize}
  26. color={iconColor}
  27. style={styles.iconButton}
  28. />
  29. </TouchableOpacity>
  30. );
  31. };
  32. const [isActionSheetVisible, setActionSheetVisible] = useState(false);
  33. const handlePress = () => {
  34. showActionMenu();
  35. };
  36. const showActionMenu = () => {
  37. if (Platform.OS === 'ios') {
  38. const options = [
  39. 'Features'
  40. ];
  41. ActionSheetIOS.showActionSheetWithOptions(
  42. {
  43. options: options,
  44. cancelButtonIndex: options.length - 1,
  45. // destructiveButtonIndex: 2, // Index of the destructive option (optional)
  46. tintColor: 'blue', // Color of the option text (optional)
  47. },
  48. buttonIndex => {
  49. // Handle the selected option
  50. //FEATURES1
  51. else {
  52. // Cancel button or tapping outside the action menu
  53. }
  54. },
  55. );
  56. } else {
  57. // Android implementation
  58. setActionSheetVisible(true);
  59. }
  60. };
  61. const handleActionSheetPress = async (buttonIndex: any) => {
  62. setActionSheetVisible(false);
  63. //FEATURES2
  64. };
  65. return (
  66. <View style={styles.container}>
  67. <StatusBar animated={true} barStyle="default" showHideTransition="fade" />
  68. <View style={styles.viewAppBar}>
  69. <Text style={styles.textTitle}>NexilisSampleCode</Text>
  70. <IconButton
  71. onPress={handlePress}
  72. iconName="ellipsis-horizontal"
  73. iconSize={30}
  74. iconColor="white"
  75. />
  76. </View>
  77. {isActionSheetVisible && (
  78. <View>
  79. //FEATURES3
  80. <Button title="Cancel" onPress={() => setActionSheetVisible(false)} />
  81. </View>
  82. )}
  83. </View>
  84. );
  85. };
  86. const styles = StyleSheet.create({
  87. loginButtonSection: {
  88. width: '100%',
  89. height: '100%',
  90. justifyContent: 'center',
  91. alignItems: 'center',
  92. },
  93. container: {
  94. flex: 1,
  95. },
  96. viewAppBar: {
  97. width: '100%',
  98. height: '10%',
  99. backgroundColor: '#3669ad',
  100. justifyContent: 'center',
  101. position: 'relative',
  102. },
  103. textTitle: {
  104. position: 'absolute',
  105. left: '30%',
  106. color: 'white',
  107. fontSize: 18,
  108. top: '50%',
  109. },
  110. iconButton: {
  111. position: 'absolute',
  112. right: '5%',
  113. top: -8,
  114. color: 'white',
  115. },
  116. });
  117. export default App;