Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

wv0.native.js 12KB

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