UNPKG

crn-cli

Version:

The Ctrip React Native CLI Tools

1 lines 1.95 kB
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),s=r(d[2]),l=r(d[3]),o=r(d[4]),u=r(d[5]),p=r(d[6]),h=p.StyleSheet,c=p.Text,f=p.TextInput,y=p.View,b=(p.Platform,(function(p){function h(n){var o;return t(this,h),(o=s(this,l(h).call(this,n))).state={responseText:null},o.responseURL=null,o.responseHeaders=null,o}return o(h,p),n(h,[{key:"submit",value:function(t){var n=this;fetch(t).then(function(t){return n.responseURL=t.url,n.responseHeaders=t.headers,t.text()}).then(function(t){n.setState({responseText:t})})}},{key:"_renderHeaders",value:function(){if(!this.responseHeaders)return null;for(var t=[],n=Object.keys(this.responseHeaders.map),s=0;s<n.length;s++){var l=n[s],o=this.responseHeaders.get(l);t.push(u.createElement(c,null,l,": ",o))}return t}},{key:"render",value:function(){var t=this,n=this.responseURL?u.createElement(y,{style:{marginTop:10}},u.createElement(c,{style:x.label},"Server response URL:"),u.createElement(c,null,this.responseURL)):null,s=this.responseHeaders?u.createElement(y,{style:{marginTop:10}},u.createElement(c,{style:x.label},"Server response headers:"),this._renderHeaders()):null,l=this.state.responseText?u.createElement(y,{style:{marginTop:10}},u.createElement(c,{style:x.label},"Server response:"),u.createElement(f,{editable:!1,multiline:!0,defaultValue:this.state.responseText,style:x.textOutput})):null;return u.createElement(y,null,u.createElement(c,{style:x.label},"Edit URL to submit:"),u.createElement(f,{returnKeyType:"go",defaultValue:"http://www.posttestserver.com/post.php",onSubmitEditing:function(n){t.submit(n.nativeEvent.text)},style:x.textInput}),n,s,l)}}]),h})(u.Component)),x=h.create({textInput:{flex:1,borderRadius:3,borderColor:'grey',borderWidth:1,height:30,paddingLeft:8},label:{flex:1,color:'#aaa',fontWeight:'500',height:20},textOutput:{flex:1,fontSize:17,borderRadius:3,borderColor:'grey',borderWidth:1,height:200,paddingLeft:8}});m.exports=b},666801,[3,4,5,8,9,11,15]);