Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ class BlocWrapWithBlocBuilderIntentionAction : BlocWrapWithIntentionAction(Snipp
override fun getText(): String {
return "Wrap with BlocBuilder"
}
}
class BlocWrapWithCubitBuilderIntentionAction : BlocWrapWithIntentionAction(SnippetType.CubitBuilder) {
/**
* If this action is applicable, returns the text to be shown in the list of intention actions available.
*/
override fun getText(): String {
return "Wrap with BlocBuilder (Cubit)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ class BlocWrapWithBlocConsumerIntentionAction : BlocWrapWithIntentionAction(Snip
override fun getText(): String {
return "Wrap with BlocConsumer"
}
}
class BlocWrapWithCubitConsumerIntentionAction : BlocWrapWithIntentionAction(SnippetType.CubitConsumer) {
/**
* If this action is applicable, returns the text to be shown in the list of intention actions available.
*/
override fun getText(): String {
return "Wrap with BlocConsumer (Cubit)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ class BlocWrapWithBlocListenerIntentionAction : BlocWrapWithIntentionAction(Snip
override fun getText(): String {
return "Wrap with BlocListener"
}
}
class BlocWrapWithCubitListenerIntentionAction : BlocWrapWithIntentionAction(SnippetType.CubitListener) {
/**
* If this action is applicable, returns the text to be shown in the list of intention actions available.
*/
override fun getText(): String {
return "Wrap with BlocListener (Cubit)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ class BlocWrapWithBlocProviderIntentionAction : BlocWrapWithIntentionAction(Snip
override fun getText(): String {
return "Wrap with BlocProvider"
}
}
class BlocWrapWithCubitProviderIntentionAction : BlocWrapWithIntentionAction(SnippetType.CubitProvider) {
/**
* If this action is applicable, returns the text to be shown in the list of intention actions available.
*/
override fun getText(): String {
return "Wrap with BlocProvider (Cubit)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ class BlocWrapWithBlocSelectorIntentionAction : BlocWrapWithIntentionAction(Snip
override fun getText(): String {
return "Wrap with BlocSelector"
}
}
class BlocWrapWithCubitSelectorIntentionAction : BlocWrapWithIntentionAction(SnippetType.CubitSelector) {
/**
* If this action is applicable, returns the text to be shown in the list of intention actions available.
*/
override fun getText(): String {
return "Wrap with BlocSelector (Cubit)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.bloc.intellij_generator_plugin.intention_action

enum class SnippetType {
BlocBuilder, BlocSelector, BlocListener, BlocProvider, BlocConsumer, RepositoryProvider, MultiBlocProvider, MultiRepositoryProvider, MultiBlocListener,
CubitBuilder, CubitSelector, CubitListener, CubitProvider, CubitConsumer
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ object Snippets {
const val PREFIX_SELECTION = "Subject"

private const val SUFFIX_BLOC = "Bloc"
private const val SUFFIX_CUBIT = "Cubit"
private const val SUFFIX_STATE = "State"
private const val SUFFIX_REPOSITORY = "Repository"

Expand All @@ -16,9 +17,13 @@ object Snippets {
fun getSnippet(snippetType: SnippetType?, blocWidget: String, widget: String): String {
return when (snippetType) {
SnippetType.BlocSelector -> blocSelectorSnippet(widget)
SnippetType.CubitSelector -> blocSelectorSnippet(widget, SUFFIX_CUBIT)
SnippetType.BlocListener -> blocListenerSnippet(widget)
SnippetType.CubitListener -> blocListenerSnippet(widget, SUFFIX_CUBIT)
SnippetType.BlocProvider -> blocProviderSnippet(widget)
SnippetType.CubitProvider -> blocProviderSnippet(widget, SUFFIX_CUBIT)
SnippetType.BlocConsumer -> blocConsumerSnippet(widget)
SnippetType.CubitConsumer -> blocConsumerSnippet(widget, SUFFIX_CUBIT)
SnippetType.RepositoryProvider -> repositoryProviderSnippet(widget)
SnippetType.MultiBlocProvider -> multiBlocProviderSnippet(blocWidget, widget)
SnippetType.MultiBlocListener -> multiBlocListenerSnippet(blocWidget, widget)
Expand All @@ -27,16 +32,16 @@ object Snippets {
}
}

private fun blocBuilderSnippet(widget: String): String {
return "BlocBuilder<$BLOC_SNIPPET_KEY, $STATE_SNIPPET_KEY>(\n" +
private fun blocBuilderSnippet(widget: String, type: String = SUFFIX_BLOC): String {
return "BlocBuilder<$PREFIX_SELECTION$type, $STATE_SNIPPET_KEY>(\n" +
" builder: (context, state) {\n" +
" return $widget;\n" +
" },\n" +
")"
}

private fun blocSelectorSnippet(widget: String): String {
return "BlocSelector<$BLOC_SNIPPET_KEY, $STATE_SNIPPET_KEY, $SELECTED_STATE_SNIPPET_KEY>(\n" +
private fun blocSelectorSnippet(widget: String, type: String = SUFFIX_BLOC): String {
return "BlocSelector<$PREFIX_SELECTION$type, $STATE_SNIPPET_KEY, $SELECTED_STATE_SNIPPET_KEY>(\n" +
" selector: (state) {\n" +
" // TODO: return selected state\n" +
" },\n" +
Expand All @@ -46,24 +51,24 @@ object Snippets {
")"
}

private fun blocListenerSnippet(widget: String): String {
return "BlocListener<$BLOC_SNIPPET_KEY, $STATE_SNIPPET_KEY>(\n" +
private fun blocListenerSnippet(widget: String, type: String = SUFFIX_BLOC): String {
return "BlocListener<$PREFIX_SELECTION$type, $STATE_SNIPPET_KEY>(\n" +
" listener: (context, state) {\n" +
" // TODO: implement listener\n" +
" },\n" +
" child: $widget,\n" +
")"
}

private fun blocProviderSnippet(widget: String): String {
private fun blocProviderSnippet(widget: String, type: String = SUFFIX_BLOC): String {
return "BlocProvider(\n" +
" create: (context) => $BLOC_SNIPPET_KEY(),\n" +
" create: (context) => $PREFIX_SELECTION$type(),\n" +
" child: $widget,\n" +
")"
}

private fun blocConsumerSnippet(widget: String): String {
return "BlocConsumer<$BLOC_SNIPPET_KEY, $STATE_SNIPPET_KEY>(\n" +
private fun blocConsumerSnippet(widget: String, type: String = SUFFIX_BLOC): String {
return "BlocConsumer<$PREFIX_SELECTION$type, $STATE_SNIPPET_KEY>(\n" +
" listener: (context, state) {\n" +
" // TODO: implement listener\n" +
" },\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,51 @@
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithCubitProviderIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithBlocBuilderIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithCubitBuilderIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithBlocSelectorIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithCubitSelectorIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithBlocListenerIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithCubitListenerIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithBlocConsumerIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithCubitConsumerIntentionAction
</className>
<category>Bloc</category>
</intentionAction>
<intentionAction>
<className>
com.bloc.intellij_generator_plugin.intention_action.BlocWrapWithRepositoryProviderIntentionAction
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: BlocBuilder<SubjectCubit, SubjectState>(
builder: (context, state) {
return Text('Example');
},
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('Example'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<body>Wraps the current widget in a BlocBuilder with Cubit-template.</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: BlocConsumer<SubjectCubit, SubjectState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
return Text('Example');
},
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('Example'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<body>Wraps the current widget in a BlocConsumer with Cubit-template.</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: BlocListener<SubjectCubit, SubjectState>(
listener: (context, state) {
// TODO: implement listener
},
child: Text('Example'),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('Example'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<body>Wraps the current widget in a BlocListener with Cubit-template.</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: BlocProvider(
create: (context) => SubjectCubit(),
child: Text('Example'),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('Example'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<body>Wraps the current widget in a BlocProvider with Cubit-template.</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: BlocSelector<SubjectCubit, SubjectState, SelectedState>(
selector: (state) {
// TODO: return selected state
},
builder: (state) {
return Text('Example');
},
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CounterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('Example'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<body>Wraps the current widget in a BlocSelector with Cubit-template.</body>
</html>