App.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. if (buttonIndex === 0) {
  51. CallNative.openSetting();
  52. }
  53. if (buttonIndex === 1) {
  54. CallNative.openProfile();
  55. }
  56. if (buttonIndex === 2) {
  57. CallNative.openContactCenter();
  58. }
  59. if (buttonIndex === 3) {
  60. CallNative.openNotificationCenter();
  61. }
  62. if (buttonIndex === 4) {
  63. CallNative.openChat();
  64. }
  65. if (buttonIndex === 5) {
  66. CallNative.openCall();
  67. }
  68. if (buttonIndex === 6) {
  69. CallNative.openStreaming();
  70. }
  71. else {
  72. // Cancel button or tapping outside the action menu
  73. }
  74. },
  75. );
  76. } else {
  77. // Android implementation
  78. setActionSheetVisible(true);
  79. }
  80. };
  81. const handleActionSheetPress = async (buttonIndex: any) => {
  82. setActionSheetVisible(false);
  83. //FEATURES2
  84. };
  85. return (
  86. <View style={styles.container}>
  87. <StatusBar animated={true} barStyle="default" showHideTransition="fade" />
  88. <View style={styles.viewAppBar}>
  89. <Text style={styles.textTitle}>NexilisSampleCode</Text>
  90. <IconButton
  91. onPress={handlePress}
  92. iconName="ellipsis-horizontal"
  93. iconSize={30}
  94. iconColor="white"
  95. />
  96. </View>
  97. {isActionSheetVisible && (
  98. <View>
  99. //FEATURES3
  100. <Button title="Cancel" onPress={() => setActionSheetVisible(false)} />
  101. </View>
  102. )}
  103. </View>
  104. );
  105. };
  106. const styles = StyleSheet.create({
  107. loginButtonSection: {
  108. width: '100%',
  109. height: '100%',
  110. justifyContent: 'center',
  111. alignItems: 'center',
  112. },
  113. container: {
  114. flex: 1,
  115. },
  116. viewAppBar: {
  117. width: '100%',
  118. height: '10%',
  119. backgroundColor: '#3669ad',
  120. justifyContent: 'center',
  121. position: 'relative',
  122. },
  123. textTitle: {
  124. position: 'absolute',
  125. left: '30%',
  126. color: 'white',
  127. fontSize: 18,
  128. top: '50%',
  129. },
  130. iconButton: {
  131. position: 'absolute',
  132. right: '5%',
  133. top: -8,
  134. color: 'white',
  135. },
  136. });
  137. export default App;