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

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