Нема описа

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