You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wv0.native.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. import { WebView } from 'react-native-webview';
  2. import React, { PureComponent,Component,Button as Button_v0, } from 'react';
  3. // import { Button as Button_v0,} from 'react';
  4. import { Button } from 'react-native-paper';
  5. // Button as R_Button
  6. import { Button as Button_v2, useTheme } from 'react-native-paper';
  7. import {
  8. Animated,
  9. Keyboard,
  10. SafeAreaView,
  11. TextInput,
  12. TouchableHighlight,
  13. TouchableOpacity,
  14. View,
  15. Button as Button_v1,
  16. // Text,
  17. } from 'react-native';
  18. import * as rn from 'react-native';
  19. import * as rn_cam from './rn_cam';
  20. var Text2 = rn.Text
  21. import {AbstractButton} from '../react/features/base/toolbox/components';
  22. import { Header, LoadingIndicator, Text } from '../react/features/base/react';
  23. // clog("glob_vhook:",)
  24. glob_vhook.btns = {
  25. Button_v0,
  26. Button_v1,
  27. Button_v2,
  28. }
  29. function onMsg(event ){
  30. clog("OBMSG>>>>")
  31. var onMsg = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("onMsg",{that:this,event},{}) : {}
  32. }
  33. type Props = {}
  34. // class Wview_ui extends AbstractButton<Props> {
  35. class Wview_ui extends PureComponent<Props> {
  36. // class Wview_ui extends AbstractButton<Props, any> {
  37. // icon = "IconMessage";
  38. constructor(props) {
  39. super(props);
  40. this.v1="a"
  41. clog("Wview_v1 init")
  42. glob_vhook.nodes.wvui = this
  43. }
  44. render() {
  45. // return
  46. }
  47. }
  48. function dbg_vbx_onpress(event){
  49. clog("dbg_vbx_onpress:",event)
  50. clog("dbg_vbx_onpress:a",arguments)
  51. clog("dbg_vbx_onpress:this",this)
  52. clog("dbg_vbx_onpress:color",this.color)
  53. clog("dbg_vbx_onpress:currentTarget",event.currentTarget)
  54. clog("dbg_vbx_onpress:prop_id",this.prop_id)
  55. }
  56. function fncb_only_v2(fn_name,arg1){
  57. var that0 = this
  58. // var ret = function(arg2){
  59. return function(arg2){
  60. // return tglob_au.run_dev_cbs(fn_name,{arg1,arg2,argx:arguments})
  61. // clog("???2",fn_name)
  62. var ret2 = tglob_au.run_dev_cbs(fn_name,{arg1,arg2,argx:arguments,thats:{that0,that1:this}})
  63. return ret2.o.ret
  64. }
  65. // return ret
  66. }
  67. function fncb_only(fn_name){
  68. var ret
  69. if (window.glob_vhook.rcb[fn_name]){
  70. // ret = window.glob_vhook.rcb[fn_name](fn_name,o,dflt_ret)
  71. // (fn_name,o,dflt_ret)
  72. ret = {status:1,fn:window.glob_vhook.rcb[fn_name]}
  73. } else {
  74. ret = {status:0,fn:window.nop}
  75. }
  76. return ret
  77. }
  78. // class Wview_btns extends Component<Props> {
  79. class Wview_btns extends PureComponent<Props> {
  80. constructor(props) {
  81. super(props);
  82. }
  83. render(){
  84. // wview_btns = tglob_au.run_dev_cbs("wview_btns",{that:this})
  85. var x1 = tglob_au.run_dev_cbs("wview_btns",{that:this}) || {o:{}}
  86. var wview_btns = x1.o.ret || {}
  87. // clog("\n\n\n\nwview_btns",wview_btns)
  88. // wview_btns.style_b1 || {}
  89. // wview_btns.style_b2 || {}
  90. // wview_btns.style_v0 || {}
  91. // color = { wv0_styles_dev.vb1_color || "#00ffffff" }
  92. // onPress = {fncb_only("vbx_press").fn.bind(this)}
  93. // style={wview_btns.style_v0 || {}}
  94. // prop_id = "b1"
  95. // prop_id = "b2"
  96. // <View style={wview_btns.style_v1 || {}}>
  97. // </View>
  98. // <View style={wview_btns.style_v2 || {}}>
  99. // </View>
  100. // style={ {} }
  101. // return (
  102. // NEED CONSTS DEFS
  103. var ret_con = {}
  104. var ret = (
  105. <View style={wview_btns.style_v0 || {}}>
  106. <Button_v2
  107. prop_id = "b1"
  108. style = { wview_btns.style_b1 || {}}
  109. labelStyle = { wview_btns.style_b2l || {}}
  110. color={wview_btns.color_b1}
  111. onPress = {fncb_only_v2("vbx_press",{wvt:this,ret_con,button_action:"wb_toggle"})}
  112. >
  113. {wview_btns.b1_txt || "udef1"}
  114. </Button_v2>
  115. <Button_v2
  116. prop_id = "b2"
  117. style = { wview_btns.style_b2 || {}}
  118. labelStyle = { wview_btns.style_b2l || {}}
  119. color={wview_btns.color_b2}
  120. onPress = {fncb_only_v2("vbx_press",{wvt:this,ret_con,button_action:"tbox_toggle"})}
  121. >
  122. {wview_btns.b2_txt || "udef2"}
  123. </Button_v2>
  124. {
  125. !!0 && <Text style={wview_btns.style_v2 || {}}>Wview_vx</Text>
  126. }
  127. { !!0 && <Text style={wview_btns.style_v2 || {}}>Wview_vx2</Text> }
  128. </View>
  129. )
  130. ret_con.ret= ret
  131. return ret
  132. }
  133. }
  134. class Wview_vx extends Component<Props> {
  135. constructor(props) {
  136. super(props);
  137. }
  138. render(){
  139. var wb_url
  140. // tglob_au.run_dev_cbs("render_vvx",{that:this,args:arguments,a:"z?"})
  141. if (glob_vhook?.fns?.gen_xcal_room3) {
  142. wb_url = glob_vhook.fns.gen_xcal_room3().room_url
  143. } else {
  144. // wb_url = "https://excalidraw.videocorners.com/#room=4zmaf7d5jtcx4pqgruba,4zmaf7BMXbI6tCEiW7rbgy"
  145. wb_url = "https://excalidraw.videocorners.com/#room=4zxcald5jtcx4pqgruba,4zxcalBMXbI6tCEiW7rbgy"
  146. }
  147. var webview_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("webview_style",{that:this},{}) : {}
  148. var wv0_styles = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("wv0_styles",{that:this},{}) : {}
  149. // <View
  150. // style = {wv0_styles.v1 || {}}
  151. // >
  152. var wv0_styles_dev = this.wv0_styles_dev || {}
  153. // window.postMessage("Your message");
  154. // console.log(">>>>>>>..?")
  155. var injectedJs = `(function(){
  156. console.log(">>>>>>>..")
  157. this.webView.postMessage("ZZ")
  158. return "Send me back!"}());
  159. `;
  160. injectedJs =`
  161. setTimeout(function () {
  162. window.ReactNativeWebView.postMessage("Hello!")
  163. console.log("QWETUI\n")
  164. window.top.postMessage('hello2', '*')
  165. }, 2000)
  166. `
  167. // clog("VVX:")
  168. return (
  169. <View style={wv0_styles_dev.vx_v}>
  170. <WebView source = {{uri:wb_url}}
  171. style = {wv0_styles_dev.webview_style || {}}
  172. injectedJavaScript={injectedJs}
  173. startInLoadingState
  174. javaScriptEnabledAndroid={true}
  175. javaScriptEnabled={true}
  176. onMessage={onMsg}
  177. ></WebView>
  178. </View>
  179. )
  180. return (
  181. <View style={this.props.vx_v}>
  182. <Text style={this.props.vx_tx} >Wview_vx</Text>
  183. </View>
  184. )
  185. }
  186. }
  187. // class Wview_vx
  188. class Wview_v1 extends PureComponent<Props> {
  189. // class Wview_v1 extends Component<Props> {
  190. constructor(props) {
  191. super(props);
  192. // const { palette } = useTheme();
  193. this.v1="a"
  194. // this.palette=palette
  195. tglob_au.reg_qxi_cb(this.rs_state.bind(this),"SET_TILE_VIEW_DIMENSIONS","RS_STATE")
  196. tglob_au.reg_dev_cb(this.rs_state2.bind(this),"rerender_Wview_v1","rerender")
  197. clog("Wview_v1 init")
  198. }
  199. rs_state2(a1,a2,a3,a4,a5){
  200. this.setState(() => {
  201. return { unseen3: Math.random() }
  202. });
  203. }
  204. rs_state(a1,a2,a3,a4,a5){
  205. // clog("RS_STATE",this,{a1,a2,a3,a4,a5})
  206. // clog("RS_STATE",{a1,a2,a3,a4,a5})
  207. this.setState(() => {
  208. // console.log('setting state');
  209. var wv0_dev = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("wv0_dev",{that:this},{}) : {}
  210. // return { unseen: "does not display" }
  211. return { unseen2: wv0_dev.ret }
  212. });
  213. /*
  214. try {
  215. // var s = this.props
  216. var s = this.state
  217. clog("::::",s)
  218. } catch (err){
  219. console.error("ERR:,")
  220. }
  221. */
  222. }
  223. /*
  224. componentDidMount() {
  225. setInterval(() => {
  226. this.setState(() => {
  227. // console.log('setting state');
  228. var wv0_dev = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("wv0_dev",{that:this},{}) : {}
  229. return { unseen: "does not display" }
  230. // return { unseen: wv0_dev.ret }
  231. });
  232. }, 1000);
  233. }
  234. */
  235. render() {
  236. var wb_url
  237. // clog("Wview_v1 render")
  238. // console.log("wview_v1 render.")
  239. if (glob_vhook?.fns?.gen_xcal_room3) {
  240. wb_url = glob_vhook.fns.gen_xcal_room3().room_url
  241. } else {
  242. // wb_url = "https://excalidraw.videocorners.com/#room=4zmaf7d5jtcx4pqgruba,4zmaf7BMXbI6tCEiW7rbgy"
  243. wb_url = "https://excalidraw.videocorners.com/#room=4zxcald5jtcx4pqgruba,4zxcalBMXbI6tCEiW7rbgy"
  244. }
  245. var webview_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("webview_style",{that:this},{}) : {}
  246. var wv0_styles = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("wv0_styles",{that:this},{}) : {}
  247. // <View
  248. // style = {wv0_styles.v1 || {}}
  249. // >
  250. var wv0_styles_dev = this.wv0_styles_dev || {}
  251. // window.postMessage("Your message");
  252. // console.log(">>>>>>>..?")
  253. var injectedJs = `(function(){
  254. console.log(">>>>>>>..")
  255. this.webView.postMessage("ZZ")
  256. return "Send me back!"}());
  257. `;
  258. injectedJs =`
  259. setTimeout(function () {
  260. window.ReactNativeWebView.postMessage("Hello!")
  261. console.log("QWETUI\n")
  262. window.top.postMessage('hello2', '*')
  263. }, 2000)
  264. `
  265. // <View style = { wv0_styles.v1 || {} }>
  266. // style = {webview_style}
  267. // <WebView source = {{uri:"https://excalidraw.videocorners.com/#room=4zxcald5jtcx4pqgruba,4zxcalBMXbI6tCEiW7rbgy"}}
  268. // <WebView source = {{uri:"https://excalidraw.videocorners.com/#room=4zxcald5jtcx4pqgruba,4zxcalBMXbI6tCEiW7rbgy"}}
  269. // {t('polls.create.create')}
  270. // <Wview_ui style = { wv0_styles_dev.vb1 || {}} />
  271. // vx_v
  272. // vx_tx
  273. return (
  274. <View style = { wv0_styles_dev.v1 || {} }>
  275. <Text style = { wv0_styles_dev.txt || {} }
  276. >
  277. Z??
  278. </Text>
  279. <Wview_vx
  280. vx_tx = { wv0_styles_dev.vx_tx || {} }
  281. vx_v = { wv0_styles_dev.vx_v || {} }
  282. ></Wview_vx>
  283. <Wview_btns
  284. pt0 = { wv0_styles_dev.wv_b0 || {}}
  285. style = { wv0_styles_dev.wv_b || {}}
  286. ></Wview_btns>
  287. <Button_v2
  288. title = "Cheems"
  289. style = { wv0_styles_dev.vb1 || {}}
  290. color = { wv0_styles_dev.vb1_color || "#00ffffff" }
  291. onPress = {fncb_only("vb1_press").fn.bind(this)}
  292. >
  293. {wv0_styles_dev.vb1_txt || "udef"}
  294. </Button_v2>
  295. <Text2 style = { wv0_styles_dev.txt2 || {} }
  296. >
  297. Z2
  298. </Text2>
  299. </View>
  300. )
  301. }
  302. }
  303. // <rn_cam.ExampleApp></rn_cam.ExampleApp>
  304. // color = { this.palette.screen01Header }
  305. export {Wview_v1}