Skip to content

Commit

Permalink
Merge pull request #4 from thapp-com-br/wrap-get
Browse files Browse the repository at this point in the history
update wrap + snippets
  • Loading branch information
kauemurakami authored Jul 19, 2020
2 parents cfa655a + c6cfcc6 commit 30fb35d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "get-snippets",
"displayName": "GetX Snippets",
"description": "An extension to accelerate the process of developing applications with flutter, aimed at everyone using the Get package.",
"version": "3.1.0",
"version": "3.1.1",
"publisher": "get-snippets",
"engines": {
"vscode": "^1.2.0"
Expand Down
14 changes: 4 additions & 10 deletions snippets/snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"",
"class ${1:My}Controller extends GetxController {",
"",
"\tfinal ${2:My}Repository repository;",
"\t$1Controller({@required this.repository}) : assert(repository != null);",
"",
"\tfinal _${3:obj} = ''.obs;",
"\tset $3(value) => this._$3.value = value;",
"\tget $3 => this._$3.value;",
Expand Down Expand Up @@ -102,9 +99,6 @@
"",
"class ${1:My}Page extends StatelessWidget {",
"",
"//repository injection",
"final ${2:My}Repository repository = $2Repository(apiClient: ${6:My}ApiClient(httpClient: http.Client()));",
"",
"\t@override",
"\tWidget build(BuildContext context) {",
"",
Expand All @@ -113,7 +107,7 @@
"",
"\t\tbody: ${3:Container}(",
"\t\t\tchild: GetX<${4:My}Controller>(",
"\t\t\t\tinit: $4Controller(repository: repository),",
"\t\t\t\tinit: $4Controller(),",
"\t\t\t\tbuilder: (_){",
"\t\t\t\t\treturn ${5:Container}();",
"\t\t\t\t}),",
Expand Down Expand Up @@ -151,7 +145,7 @@
"prefix": "getx",
"body": [
"GetX<${1:My}Controller>(",
"\tinit: ${1:My}Controller(repository: repository),",
"\tinit: ${1:My}Controller(),",
"\tbuilder: (_) => Text(_.var),",
"",
")"
Expand Down Expand Up @@ -429,7 +423,7 @@
"",
"\t//autoRemove: false,",
"\t//assignId: false,",
"\tinit: $1Controller(repository : repository),",
"\tinit: $1Controller(),",
"\tinitState: (state){ Get.find<$1Controller>().obj = 'fast code get snittpets' ;},",
"\tbuilder: (_) {",
"\t\treturn",
Expand Down Expand Up @@ -459,7 +453,7 @@
"",
"\t//autoRemove: false,",
"\t//assignId: false,",
"\tinit: $1Controller(repository : repository),",
"\tinit: $1Controller(),",
"\tinitState: (state){ Get.find<$1Controller>().obj = 'fast code get snittpets' ;},",
"\tbuilder: (_) {",
"\t\treturn",
Expand Down
12 changes: 3 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
return [];
}
const pickedText = editorX.document.getText(editorX.selection);
//
var removeOne = pickedText.substring(
pickedText.lastIndexOf("GetBuilder"),
pickedText.lastIndexOf("return")
);
console.log(removeOne);
//

const codeActions = [];
if (pickedText !== '') {
codeActions.push({
Expand Down Expand Up @@ -103,15 +97,15 @@ export const activate = (context: vscode.ExtensionContext) => {
vscode.commands.registerCommand(
"get.wrapInGetx",
() => {
insertSnippet("GetX<${1:My}Controller>(\n" + SpaceX() + "init: ${1:My}Controller(${2:repository: repository}),\n" + SpaceX() + "initState: (_) {},\n" + SpaceX() + "builder: (_) {\n" + SpaceX() + SpaceX() + "return ", "\n },\n" + "),", SpaceX(), false, false);
insertSnippet("GetX<${1:My}Controller>(\n" + SpaceX() + "init: ${1:My}Controller(),\n" + SpaceX() + "initState: (_) {},\n" + SpaceX() + "builder: (_) {\n" + SpaceX() + SpaceX() + "return ", "\n },\n" + "),", SpaceX(), false, false);
})
);

context.subscriptions.push(
vscode.commands.registerCommand(
"get.wrapInGetBuilder",
() => {
insertSnippet("GetBuilder<${1:My}Controller>(\n" + SpaceX() + "init: ${1:My}Controller(${2:repository: repository}),\n" + SpaceX() + "initState: (_) {},\n" + SpaceX() + "builder: (_) {\n" + SpaceX() + SpaceX() + "return ", "\n },\n" + "),", SpaceX(), false, false);
insertSnippet("GetBuilder<${1:My}Controller>(\n" + SpaceX() + "init: ${1:My}Controller(),\n" + SpaceX() + "initState: (_) {},\n" + SpaceX() + "builder: (_) {\n" + SpaceX() + SpaceX() + "return ", "\n },\n" + "),", SpaceX(), false, false);
})
);

Expand Down
Binary file removed test.png
Binary file not shown.

0 comments on commit 30fb35d

Please sign in to comment.