From 8b01ee53f715a89885e89ebb283645d682efefb5 Mon Sep 17 00:00:00 2001
From: Matthew Nitschke <39171685+matthewnitschke-wk@users.noreply.github.com>
Date: Thu, 2 Jul 2020 15:03:54 -0600
Subject: [PATCH] Added code snippet for react-redux connected components
 (#501)

* added vscode snippets for connected components

* added intelij snippet

* removed extra ignore comment

* formatted json file

* address pr comments
---
 snippets/snippets.json | 25 +++++++++++++++++++++++++
 snippets/snippets.xml  |  8 ++++++++
 2 files changed, 33 insertions(+)

diff --git a/snippets/snippets.json b/snippets/snippets.json
index 28e5f7fd4..322e3656c 100644
--- a/snippets/snippets.json
+++ b/snippets/snippets.json
@@ -98,5 +98,30 @@
       "}"
     ],
     "description": "Creates a stateful OverReact component with abbreviated props and state declarations"
+  },
+  "connectedStatelessComponent": {
+    "prefix": "orStlessConnect",
+    "body": [
+      "import 'package:over_react/over_react.dart';",
+      "import 'package:over_react/over_react_redux.dart';",
+      "",
+      "part '${1:FileName}.over_react.g.dart';",
+      "",
+      "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = connect<${3:SomeReduxStoreState}, ${2:MyComponent}Props>(",
+      "\tmapStateToProps: (state) => (${2:MyComponent}()),",
+      "\tmapDispatchToProps: (dispatch) => (${2:MyComponent}()),",
+      ")(_$${2:MyComponent}); // ignore: undefined_identifier",
+      "",
+      "mixin ${2:MyComponent}Props on UiProps {}",
+      "",
+      "class ${2:MyComponent}Component extends UiComponent2<${2:MyComponent}Props> {",
+      "\t@override",
+      "\tget defaultProps => (newProps());",
+      "",
+      "\t@override",
+      "\trender() { }",
+      "}"
+    ],
+    "description": "Creates a stateless and connected OverReact component"
   }
 }
diff --git a/snippets/snippets.xml b/snippets/snippets.xml
index 82aff5d60..486acec0d 100644
--- a/snippets/snippets.xml
+++ b/snippets/snippets.xml
@@ -42,3 +42,11 @@
     <option name="DART" value="true" />
   </context>
 </template>
+<template name="orStlessConnect" value="import 'package:over_react/over_react.dart';&#10;import 'package:over_react/over_react_redux.dart';&#10;&#10;part '$FileName$.over_react.g.dart';&#10;&#10;UiFactory&lt;$MyComponent$Props&gt; $MyComponent$ = connect&lt;$SomeReduxStoreState$, $MyComponent$Props&gt;(&#10;  mapStateToProps: (state) =&gt; ($MyComponent$()),&#10;  mapDispatchToProps: (dispatch) =&gt; ($MyComponent$()),&#10;)(_$$$MyComponent$); // ignore: undefined_identifier&#10;&#10;mixin $MyComponent$Props on UiProps {}&#10;&#10;class $MyComponent$Component extends UiComponent2&lt;$MyComponent$Props&gt; {&#10;  @override&#10;  get defaultProps =&gt; (newProps());&#10;&#10;  @override&#10;  render() { }&#10;}" description="Creates a stateless and connected over_react component" toReformat="false" toShortenFQNames="true">
+  <variable name="FileName" expression="" defaultValue="&quot;foo&quot;" alwaysStopAt="true" />
+  <variable name="MyComponent" expression="" defaultValue="&quot;Foo&quot;" alwaysStopAt="true" />
+  <variable name="SomeReduxStoreState" expression="" defaultValue="&quot;Foo&quot;" alwaysStopAt="true" />
+  <context>
+    <option name="DART" value="true" />
+  </context>
+</template>