Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, {Component} from 'react';
  9. import {
  10. Platform, StyleSheet, Text, View, TouchableOpacity, TextInput
  11. } from 'react-native';
  12. import AgoraRTCView from './components/agora';
  13. const instructions = Platform.select({
  14. ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  15. android:
  16. 'Double tap R on your keyboard to reload,\n' +
  17. 'Shake or press menu button for dev menu',
  18. });
  19. const styles = StyleSheet.create({
  20. container: {
  21. flex: 1,
  22. justifyContent: 'center',
  23. alignItems: 'center',
  24. backgroundColor: '#F5FCFF',
  25. },
  26. welcome: {
  27. fontSize: 20,
  28. textAlign: 'center',
  29. margin: 10,
  30. },
  31. instructions: {
  32. textAlign: 'center',
  33. color: '#333333',
  34. marginBottom: 5,
  35. },
  36. button: {
  37. height: 44,
  38. paddingHorizontal:20,
  39. backgroundColor:'#6A71DD',
  40. borderRadius:10,
  41. justifyContent:'center',
  42. alignItems:'center',
  43. marginTop: 10
  44. }
  45. });
  46. type Props = {};
  47. export default class App extends Component<Props> {
  48. constructor(props) {
  49. super(props);
  50. this.state = {
  51. showLive: false,
  52. error: undefined,
  53. channelProfile: 1,
  54. videoProfile: 40,
  55. clientRole: 1,
  56. swapWidthAndHeight: true,
  57. channelName: 'defaultChannel'
  58. };
  59. }
  60. joinChannel = () => {
  61. this.setState({
  62. showLive: true
  63. })
  64. }
  65. onCancel = (error) => {
  66. console.log("[error]", error);
  67. this.setState({
  68. showLive: false,
  69. error
  70. })
  71. }
  72. render() {
  73. if (this.state.showLive) {
  74. return (<AgoraRTCView
  75. onCancel={this.onCancel}
  76. channelProfile={this.state.channelProfile}
  77. videoProfile={this.state.videoProfile}
  78. clientRole={this.state.clientRole}
  79. swapWidthAndHeight={this.state.swapWidthAndHeight}
  80. channelName={this.state.channelName}
  81. ></AgoraRTCView>);
  82. }
  83. return (
  84. <View style={styles.container}>
  85. {this.state.error && <Text>Error Message: {error}</Text>}
  86. <TextInput
  87. style={{height: 40}}
  88. keyboardType='numeric'
  89. placeholder="Enter channelProfile (numeric)"
  90. onChangeText={(text) => {
  91. let matched = text.match(/\d+/g) && text.match(/\d+/g)[0]
  92. if (matched) {
  93. this.setState({channelProfile: +matched})
  94. }
  95. }
  96. } />
  97. <TextInput
  98. style={{height: 40}}
  99. keyboardType='numeric'
  100. placeholder="Enter videoProfile (numeric)"
  101. onChangeText={(text) => {
  102. let matched = text.match(/\d+/g) && text.match(/\d+/g)[0]
  103. if (matched) {
  104. this.setState({videoProfile: +matched})
  105. } }
  106. } />
  107. <TextInput
  108. style={{height: 40}}
  109. keyboardType='numeric'
  110. placeholder="Enter clientRole (numeric)"
  111. onChangeText={(text) => {
  112. let matched = text.match(/\d+/g) && text.match(/\d+/g)[0]
  113. if (matched) {
  114. this.setState({clientRole: +matched})
  115. } }
  116. } />
  117. <TextInput
  118. style={{height: 40}}
  119. placeholder="Enter channelName"
  120. onChnageText={(text) => this.setState({channelName: text})}
  121. />
  122. <TouchableOpacity
  123. style={styles.button}
  124. onPress={this.joinChannel}
  125. >
  126. <Text style={{color: "#fff"}}>join room</Text>
  127. </TouchableOpacity>
  128. </View>
  129. );
  130. }
  131. }