From dbf90a2a43938808d8b3baedd472c21af868c374 Mon Sep 17 00:00:00 2001 From: iagolirapassos Date: Sun, 5 Jan 2025 01:35:17 -0300 Subject: [PATCH] Fix for workspace resizing and tab seletiong colors... New fix --- js/blocks/.goutputstream-IS8JZ2 | 151 ++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 js/blocks/.goutputstream-IS8JZ2 diff --git a/js/blocks/.goutputstream-IS8JZ2 b/js/blocks/.goutputstream-IS8JZ2 new file mode 100644 index 0000000..b0b2aeb --- /dev/null +++ b/js/blocks/.goutputstream-IS8JZ2 @@ -0,0 +1,151 @@ +//blocks/method_inserts.js +'use strict'; +Blockly.Blocks['post_runnable'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".post new Runnable"); + this.appendStatementInput("CONTENT") + .setCheck(null) + .appendField("content"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Executes code inside a Runnable using post with a prefix."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['post_runnable'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + const content = Blockly.JavaScript.statementToCode(block, 'CONTENT'); + return `${prefix}.post(new Runnable() {\n @Override\n public void run() {\n${content} }\n});\n`; +}; + +Blockly.Blocks['run_on_ui_thread'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".$form().runOnUiThread"); + this.appendStatementInput("CONTENT") + .setCheck(null) + .appendField("content"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Runs code on the UI thread with a prefix."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['run_on_ui_thread'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + const content = Blockly.JavaScript.statementToCode(block, 'CONTENT'); + return `${prefix}.runOnUiThread(new Runnable() {\n @Override\n public void run() {\n${content} }\n});\n`; +}; + + +Blockly.Blocks['set_on_click_listener'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".setOnClickListener"); + this.appendStatementInput("CONTENT") + .setCheck(null) + .appendField("content"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Sets an OnClickListener with a prefix."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['set_on_click_listener'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + const content = Blockly.JavaScript.statementToCode(block, 'CONTENT'); + return `${prefix}.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n${content} }\n});\n`; +}; + +Blockly.Blocks['add_text_view'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".addTextView"); + this.appendValueInput("TEXT") + .setCheck("String") + .appendField("with text"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Adds a TextView with specified text to a layout."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['add_text_view'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + const text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_ATOMIC); + return `${prefix}.addView(new TextView(context) {{ setText(${text}); }});\n`; +}; + +Blockly.Blocks['add_image_view'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".addImageView"); + this.appendValueInput("IMAGE_PATH") + .setCheck("String") + .appendField("with image path"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Adds an ImageView with the specified image path."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['add_image_view'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + const imagePath = Blockly.JavaScript.valueToCode(block, 'IMAGE_PATH', Blockly.JavaScript.ORDER_ATOMIC); + return `${prefix}.addView(new ImageView(context) {{ setImageURI(Uri.parse(${imagePath})); }});\n`; +}; + +Blockly.Blocks['scroll_to_bottom'] = { + init: function() { + this.appendDummyInput() + .appendField(new Blockly.FieldTextInput("prefix"), "PREFIX") + .appendField(".scrollToBottom"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Scrolls a ScrollView to the bottom."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['scroll_to_bottom'] = function(block) { + const prefix = block.getFieldValue('PREFIX'); + return `${prefix}.post(new Runnable() {\n @Override\n public void run() {\n ${prefix}.fullScroll(View.FOCUS_DOWN);\n }\n});\n`; +}; + +Blockly.Blocks['show_toast'] = { + init: function() { + this.appendDummyInput() + .appendField("Show Toast"); + this.appendValueInput("MESSAGE") + .setCheck("String") + .appendField("message"); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour("#4CAF50"); + this.setTooltip("Shows a toast message."); + this.setHelpUrl(""); + } +}; + +Blockly.JavaScript['show_toast'] = function(block) { + const message = Blockly.JavaScript.valueToCode(block, 'MESSAGE', Blockly.JavaScript.ORDER_ATOMIC); + return `Toast.makeText(context, ${message}, Toast.LENGTH_SHORT).show();\n`; +}; +