From ebd8618043f2c3d9f3358df7c6d66b73daff332b Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Fri, 3 Mar 2023 14:42:11 +0100 Subject: [PATCH] feat: add feature template --- apps/wyatt_feature_brick/.gitignore | 47 ------- apps/wyatt_feature_brick/.metadata | 30 ----- apps/wyatt_feature_brick/README.md | 16 --- apps/wyatt_feature_brick/brick_config.yaml | 13 -- .../lib/feature_name/feature_name.dart | 2 - apps/wyatt_feature_brick/lib/main.dart | 115 ------------------ apps/wyatt_feature_template/brickgen.yaml | 16 +++ .../hooks/post_gen.dart | 39 ++++++ .../wyatt_feature_template/hooks/pubspec.yaml | 7 ++ .../wyatt_feature_template/.gitignore | 7 ++ .../wyatt_feature_template/CHANGELOG.md | 3 + .../wyatt_feature_template/README.md | 39 ++++++ .../analysis_options.yaml | 0 .../feature_name_bloc/feature_name_bloc.dart | 0 .../feature_name_bloc/feature_name_event.dart | 0 .../feature_name_bloc/feature_name_state.dart | 0 .../feature_name_cubit.dart | 2 + .../feature_name_state.dart | 0 .../lib/feature_name/feature_name.dart | 6 + .../feature_name_consumer_widget.dart | 2 +- .../screens/feature_name_provider.dart | 2 +- .../screens/feature_name_screen.dart | 4 +- .../screens/widgets}/feature_name_parent.dart | 4 + .../screens/widgets}/feature_name_widget.dart | 0 .../wyatt_feature_template/lib/main.dart | 63 ++++++++++ .../wyatt_feature_template}/pubspec.yaml | 8 +- .../{{feature_name.snakeCase()}}_bloc.dart | 26 ++++ .../{{feature_name.snakeCase()}}_event.dart | 20 +++ .../{{feature_name.snakeCase()}}_state.dart | 20 +++ .../{{feature_name.snakeCase()}}_cubit.dart | 23 ++++ .../{{feature_name.snakeCase()}}_state.dart | 20 +++ .../{{feature_name.snakeCase()}}_parent.dart | 19 +++ .../{{feature_name.snakeCase()}}_widget.dart | 12 ++ ...re_name.snakeCase()}}_consumer_widget.dart | 18 +++ ...{{feature_name.snakeCase()}}_provider.dart | 22 ++++ .../{{feature_name.snakeCase()}}_screen.dart | 33 +++++ .../{{feature_name.snakeCase()}}.dart | 6 + bricks/wyatt_feature_template/brick.yaml | 12 ++ .../hooks/post_gen.dart | 39 ++++++ .../wyatt_feature_template/hooks/pubspec.yaml | 7 ++ 40 files changed, 470 insertions(+), 232 deletions(-) delete mode 100644 apps/wyatt_feature_brick/.gitignore delete mode 100644 apps/wyatt_feature_brick/.metadata delete mode 100644 apps/wyatt_feature_brick/README.md delete mode 100644 apps/wyatt_feature_brick/brick_config.yaml delete mode 100644 apps/wyatt_feature_brick/lib/feature_name/feature_name.dart delete mode 100644 apps/wyatt_feature_brick/lib/main.dart create mode 100644 apps/wyatt_feature_template/brickgen.yaml create mode 100644 apps/wyatt_feature_template/hooks/post_gen.dart create mode 100644 apps/wyatt_feature_template/hooks/pubspec.yaml create mode 100644 apps/wyatt_feature_template/wyatt_feature_template/.gitignore create mode 100644 apps/wyatt_feature_template/wyatt_feature_template/CHANGELOG.md create mode 100644 apps/wyatt_feature_template/wyatt_feature_template/README.md rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/analysis_options.yaml (100%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/blocs/feature_name_bloc/feature_name_bloc.dart (100%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/blocs/feature_name_bloc/feature_name_event.dart (100%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/blocs/feature_name_bloc/feature_name_state.dart (100%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart (95%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/blocs/feature_name_cubit/feature_name_state.dart (100%) create mode 100644 apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/feature_name.dart rename apps/{wyatt_feature_brick/lib/feature_name/screens/widgets => wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens}/feature_name_consumer_widget.dart (89%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/screens/feature_name_provider.dart (92%) rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/lib/feature_name/screens/feature_name_screen.dart (91%) rename apps/{wyatt_feature_brick/lib/feature_name/screens => wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets}/feature_name_parent.dart (70%) rename apps/{wyatt_feature_brick/lib/feature_name/stateless => wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets}/feature_name_widget.dart (100%) create mode 100644 apps/wyatt_feature_template/wyatt_feature_template/lib/main.dart rename apps/{wyatt_feature_brick => wyatt_feature_template/wyatt_feature_template}/pubspec.yaml (86%) create mode 100644 bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_bloc.dart create mode 100644 bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_event.dart create mode 100644 bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_state.dart create mode 100644 bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_cubit.dart create mode 100644 bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_state.dart create mode 100644 bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_parent.dart create mode 100644 bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_widget.dart create mode 100644 bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_consumer_widget.dart create mode 100644 bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_provider.dart create mode 100644 bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_screen.dart create mode 100644 bricks/wyatt_feature_template/__brick__/{{feature_name.snakeCase()}}.dart create mode 100644 bricks/wyatt_feature_template/brick.yaml create mode 100644 bricks/wyatt_feature_template/hooks/post_gen.dart create mode 100644 bricks/wyatt_feature_template/hooks/pubspec.yaml diff --git a/apps/wyatt_feature_brick/.gitignore b/apps/wyatt_feature_brick/.gitignore deleted file mode 100644 index a8e938c..0000000 --- a/apps/wyatt_feature_brick/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Web related -lib/generated_plugin_registrant.dart - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release diff --git a/apps/wyatt_feature_brick/.metadata b/apps/wyatt_feature_brick/.metadata deleted file mode 100644 index 2544bab..0000000 --- a/apps/wyatt_feature_brick/.metadata +++ /dev/null @@ -1,30 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled. - -version: - revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - channel: stable - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - - platform: android - create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/apps/wyatt_feature_brick/README.md b/apps/wyatt_feature_brick/README.md deleted file mode 100644 index 90ea944..0000000 --- a/apps/wyatt_feature_brick/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# wyatt_feature_brick - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/apps/wyatt_feature_brick/brick_config.yaml b/apps/wyatt_feature_brick/brick_config.yaml deleted file mode 100644 index 08597d8..0000000 --- a/apps/wyatt_feature_brick/brick_config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: wyatt_feature_brick -description: New feature brick including state mananement -path_to_brickify: lib/feature_name - -version: 0.1.1 - -vars: - feature_name: - type: string - name: feature_name - description: Name of the feature - default: Dash - prompt: What is the name of your new feature \ No newline at end of file diff --git a/apps/wyatt_feature_brick/lib/feature_name/feature_name.dart b/apps/wyatt_feature_brick/lib/feature_name/feature_name.dart deleted file mode 100644 index ee71b07..0000000 --- a/apps/wyatt_feature_brick/lib/feature_name/feature_name.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'screens/feature_name_provider.dart'; -export 'screens/feature_name_screen.dart'; diff --git a/apps/wyatt_feature_brick/lib/main.dart b/apps/wyatt_feature_brick/lib/main.dart deleted file mode 100644 index e016029..0000000 --- a/apps/wyatt_feature_brick/lib/main.dart +++ /dev/null @@ -1,115 +0,0 @@ -import 'package:flutter/material.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} diff --git a/apps/wyatt_feature_template/brickgen.yaml b/apps/wyatt_feature_template/brickgen.yaml new file mode 100644 index 0000000..e4182a1 --- /dev/null +++ b/apps/wyatt_feature_template/brickgen.yaml @@ -0,0 +1,16 @@ +name: wyatt_feature_template +description: A Wyatt Architecture Feature template + +version: 0.1.0 + +vars: + feature_name: + compilable: feature_name + type: string + description: The feature name + default: Feature Name + prompt: "What is the feature name?" + +brickgen: + path_to_brickify: wyatt_feature_template/lib/feature_name + hooks: true diff --git a/apps/wyatt_feature_template/hooks/post_gen.dart b/apps/wyatt_feature_template/hooks/post_gen.dart new file mode 100644 index 0000000..398a858 --- /dev/null +++ b/apps/wyatt_feature_template/hooks/post_gen.dart @@ -0,0 +1,39 @@ +// Copyright (C) 2022 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import 'dart:io'; + +import 'package:mason/mason.dart'; + +void removeGitKeepFiles(String targetPath) { + if (!FileSystemEntity.isDirectorySync(targetPath)) { + throw ArgumentError('Target must be a directory', 'targetPath'); + } + + Directory(targetPath) + .listSync(recursive: true) + .whereType() + .forEach((file) { + if (file.path.contains('.gitkeep')) { + file.deleteSync(recursive: true); + } + }); +} + +Future run(HookContext context) async { + final workingDirectory = Directory.current.path; + removeGitKeepFiles(workingDirectory); +} diff --git a/apps/wyatt_feature_template/hooks/pubspec.yaml b/apps/wyatt_feature_template/hooks/pubspec.yaml new file mode 100644 index 0000000..454f6df --- /dev/null +++ b/apps/wyatt_feature_template/hooks/pubspec.yaml @@ -0,0 +1,7 @@ +name: hooks + +environment: + sdk: ">=2.18.0 <3.0.0" + +dependencies: + mason: any \ No newline at end of file diff --git a/apps/wyatt_feature_template/wyatt_feature_template/.gitignore b/apps/wyatt_feature_template/wyatt_feature_template/.gitignore new file mode 100644 index 0000000..3cceda5 --- /dev/null +++ b/apps/wyatt_feature_template/wyatt_feature_template/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/apps/wyatt_feature_template/wyatt_feature_template/CHANGELOG.md b/apps/wyatt_feature_template/wyatt_feature_template/CHANGELOG.md new file mode 100644 index 0000000..effe43c --- /dev/null +++ b/apps/wyatt_feature_template/wyatt_feature_template/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/apps/wyatt_feature_template/wyatt_feature_template/README.md b/apps/wyatt_feature_template/wyatt_feature_template/README.md new file mode 100644 index 0000000..8b55e73 --- /dev/null +++ b/apps/wyatt_feature_template/wyatt_feature_template/README.md @@ -0,0 +1,39 @@ + + +TODO: Put a short description of the package here that helps potential users +know whether this package might be useful for them. + +## Features + +TODO: List what your package can do. Maybe include images, gifs, or videos. + +## Getting started + +TODO: List prerequisites and provide or point to information on how to +start using the package. + +## Usage + +TODO: Include short and useful examples for package users. Add longer examples +to `/example` folder. + +```dart +const like = 'sample'; +``` + +## Additional information + +TODO: Tell users more about the package: where to find more information, how to +contribute to the package, how to file issues, what response they can expect +from the package authors, and more. diff --git a/apps/wyatt_feature_brick/analysis_options.yaml b/apps/wyatt_feature_template/wyatt_feature_template/analysis_options.yaml similarity index 100% rename from apps/wyatt_feature_brick/analysis_options.yaml rename to apps/wyatt_feature_template/wyatt_feature_template/analysis_options.yaml diff --git a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_bloc.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_bloc.dart similarity index 100% rename from apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_bloc.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_bloc.dart diff --git a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_event.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_event.dart similarity index 100% rename from apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_event.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_event.dart diff --git a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_state.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_state.dart similarity index 100% rename from apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_bloc/feature_name_state.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_bloc/feature_name_state.dart diff --git a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart similarity index 95% rename from apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart index 4cd8374..b826c2d 100644 --- a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_cubit/feature_name_cubit.dart @@ -12,6 +12,8 @@ class FeatureNameCubit extends Cubit { /// {@macro feature_name_cubit} FeatureNameCubit() : super(const FeatureNameInitial()); + /// Add your usecases + /// A description for yourCustomFunction FutureOr yourCustomFunction() async { // TODO(wyatt): Add custom UI logic diff --git a/apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_cubit/feature_name_state.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_cubit/feature_name_state.dart similarity index 100% rename from apps/wyatt_feature_brick/lib/feature_name/blocs/feature_name_cubit/feature_name_state.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/blocs/feature_name_cubit/feature_name_state.dart diff --git a/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/feature_name.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/feature_name.dart new file mode 100644 index 0000000..6ec5e7f --- /dev/null +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/feature_name.dart @@ -0,0 +1,6 @@ +export 'blocs/feature_name_bloc/feature_name_bloc.dart'; +export 'screens/feature_name_consumer_widget.dart'; +export 'screens/feature_name_provider.dart'; +export 'screens/feature_name_screen.dart'; +export 'screens/widgets/feature_name_parent.dart'; +export 'screens/widgets/feature_name_widget.dart'; diff --git a/apps/wyatt_feature_brick/lib/feature_name/screens/widgets/feature_name_consumer_widget.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_consumer_widget.dart similarity index 89% rename from apps/wyatt_feature_brick/lib/feature_name/screens/widgets/feature_name_consumer_widget.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_consumer_widget.dart index d207eb7..a2d0903 100644 --- a/apps/wyatt_feature_brick/lib/feature_name/screens/widgets/feature_name_consumer_widget.dart +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_consumer_widget.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; -import '../../blocs/feature_name_cubit/feature_name_cubit.dart'; +import '../blocs/feature_name_cubit/feature_name_cubit.dart'; /// {@template feature_name_consumer_widget} /// FeatureNameConsumerWidget is a stateful widget. Aware of state changes. diff --git a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_provider.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_provider.dart similarity index 92% rename from apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_provider.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_provider.dart index c153af2..0d47910 100644 --- a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_provider.dart +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_provider.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; import '../blocs/feature_name_cubit/feature_name_cubit.dart'; -import 'widgets/feature_name_consumer_widget.dart'; +import 'feature_name_consumer_widget.dart'; /// {@template feature_name_provider} /// FeatureNameProvider provides bloc to his children. diff --git a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_screen.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_screen.dart similarity index 91% rename from apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_screen.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_screen.dart index 26e6dd0..d854c4d 100644 --- a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_screen.dart +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/feature_name_screen.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; +import './widgets/feature_name_parent.dart'; import '../blocs/feature_name_cubit/feature_name_cubit.dart'; -import '../stateless/feature_name_widget.dart'; -import 'feature_name_parent.dart'; +import 'widgets/feature_name_widget.dart'; /// {@template feature_name_screen} /// FeatureNameScreen is the merge of Provider and Consumer. diff --git a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_parent.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets/feature_name_parent.dart similarity index 70% rename from apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_parent.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets/feature_name_parent.dart index 977c5f3..96ccb2c 100644 --- a/apps/wyatt_feature_brick/lib/feature_name/screens/feature_name_parent.dart +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets/feature_name_parent.dart @@ -1,6 +1,10 @@ import 'package:flutter/material.dart'; +/// {@template feature_name_parent} +/// FeatureNameParent description +/// {@endtemplate} class FeatureNameParent extends StatelessWidget { + /// {@macro feature_name_parent} const FeatureNameParent({ required this.child, super.key, diff --git a/apps/wyatt_feature_brick/lib/feature_name/stateless/feature_name_widget.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets/feature_name_widget.dart similarity index 100% rename from apps/wyatt_feature_brick/lib/feature_name/stateless/feature_name_widget.dart rename to apps/wyatt_feature_template/wyatt_feature_template/lib/feature_name/screens/widgets/feature_name_widget.dart diff --git a/apps/wyatt_feature_template/wyatt_feature_template/lib/main.dart b/apps/wyatt_feature_template/wyatt_feature_template/lib/main.dart new file mode 100644 index 0000000..289dc0d --- /dev/null +++ b/apps/wyatt_feature_template/wyatt_feature_template/lib/main.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) => MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + _counter++; + }); + } + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); +} diff --git a/apps/wyatt_feature_brick/pubspec.yaml b/apps/wyatt_feature_template/wyatt_feature_template/pubspec.yaml similarity index 86% rename from apps/wyatt_feature_brick/pubspec.yaml rename to apps/wyatt_feature_template/wyatt_feature_template/pubspec.yaml index 92a89c6..33040d8 100644 --- a/apps/wyatt_feature_brick/pubspec.yaml +++ b/apps/wyatt_feature_template/wyatt_feature_template/pubspec.yaml @@ -1,11 +1,9 @@ -name: wyatt_feature_brick +name: wyatt_feature_template description: A new Flutter project. -version: 1.0.0+1 - -publish_to: "none" +version: 1.0.0 environment: - sdk: ">=2.18.0 <3.0.0" + sdk: '>=2.19.2 <3.0.0' dependencies: flutter: { sdk: flutter } diff --git a/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_bloc.dart b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_bloc.dart new file mode 100644 index 0000000..899569a --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_bloc.dart @@ -0,0 +1,26 @@ +import 'dart:async'; + +import 'package:equatable/equatable.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_event.dart'; +part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_state.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc description +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc extends Bloc<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc} + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Bloc() : super(const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial()) { + on(_onCustom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event); + } + + FutureOr _onCustom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event( + Custom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event event, + Emitter<{{#pascalCase}}{{feature_name}}{{/pascalCase}}State> emit, + ) async { + // TODO(wyatt): Add custom UI logic + const _ = 1 + 1; + return; + } +} diff --git a/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_event.dart b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_event.dart new file mode 100644 index 0000000..8175332 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_event.dart @@ -0,0 +1,20 @@ +part of '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_event} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event description +/// {@endtemplate} +abstract class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event extends Equatable { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_event} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event(); +} + +/// {@template custom_{{#snakeCase}}{{feature_name}}{{/snakeCase}}_event} +/// Event added when some custom logic happens +/// {@endtemplate} +class Custom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event extends {{#pascalCase}}{{feature_name}}{{/pascalCase}}Event { + /// {@macro custom_{{#snakeCase}}{{feature_name}}{{/snakeCase}}_event} + const Custom{{#pascalCase}}{{feature_name}}{{/pascalCase}}Event(); + + @override + List get props => []; +} diff --git a/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_state.dart b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_state.dart new file mode 100644 index 0000000..936b07c --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_bloc/{{feature_name.snakeCase()}}_state.dart @@ -0,0 +1,20 @@ +part of '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_state} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}State description +/// {@endtemplate} +abstract class {{#pascalCase}}{{feature_name}}{{/pascalCase}}State extends Equatable { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_state} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}State(); +} + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_initial} +/// The initial state of {{#pascalCase}}{{feature_name}}{{/pascalCase}}State +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial extends {{#pascalCase}}{{feature_name}}{{/pascalCase}}State { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_initial} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial(); + + @override + List get props => []; +} diff --git a/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_cubit.dart b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_cubit.dart new file mode 100644 index 0000000..23e7059 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_cubit.dart @@ -0,0 +1,23 @@ +import 'dart:async'; + +import 'package:equatable/equatable.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +part '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_state.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit description +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit extends Cubit<{{#pascalCase}}{{feature_name}}{{/pascalCase}}State> { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit} + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit() : super(const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial()); + + /// Add your usecases + + /// A description for yourCustomFunction + FutureOr yourCustomFunction() async { + // TODO(wyatt): Add custom UI logic + const _ = 1 + 1; + return; + } +} diff --git a/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_state.dart b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_state.dart new file mode 100644 index 0000000..60e3ac3 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/blocs/{{feature_name.snakeCase()}}_cubit/{{feature_name.snakeCase()}}_state.dart @@ -0,0 +1,20 @@ +part of '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_state} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}State description +/// {@endtemplate} +abstract class {{#pascalCase}}{{feature_name}}{{/pascalCase}}State extends Equatable { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_state} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}State(); +} + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_initial} +/// The initial state of {{#pascalCase}}{{feature_name}}{{/pascalCase}}State +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial extends {{#pascalCase}}{{feature_name}}{{/pascalCase}}State { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_initial} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Initial(); + + @override + List get props => []; +} diff --git a/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_parent.dart b/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_parent.dart new file mode 100644 index 0000000..b11db60 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_parent.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_parent} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent description +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent extends StatelessWidget { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_parent} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent({ + required this.child, + super.key, + }); + + final Widget child; + + @override + Widget build(BuildContext context) => Scaffold( + body: SafeArea(child: child), + ); +} diff --git a/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_widget.dart b/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_widget.dart new file mode 100644 index 0000000..d3f96d8 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/screens/widgets/{{feature_name.snakeCase()}}_widget.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget is a stateless widget. (Not aware of cubit or bloc states) +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget extends StatelessWidget { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget({super.key}); + + @override + Widget build(BuildContext context) => Container(); +} diff --git a/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_consumer_widget.dart b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_consumer_widget.dart new file mode 100644 index 0000000..5f40168 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_consumer_widget.dart @@ -0,0 +1,18 @@ +// ignore_for_file: always_use_package_imports + +import 'package:flutter/material.dart'; +import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; + +import '../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget is a stateful widget. Aware of state changes. +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget + extends CubitConsumerScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget({super.key}); + + @override + Widget onBuild(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State state) => Container(); +} diff --git a/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_provider.dart b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_provider.dart new file mode 100644 index 0000000..20a2210 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_provider.dart @@ -0,0 +1,22 @@ +// ignore_for_file: always_use_package_imports + +import 'package:flutter/material.dart'; +import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; + +import '../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart'; +import '{{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider provides bloc to his children. +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider + extends CubitProviderScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Provider({super.key}); + + @override + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit create(BuildContext context) => {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit(); + + @override + Widget builder(BuildContext context) => const {{#pascalCase}}{{feature_name}}{{/pascalCase}}ConsumerWidget(); +} diff --git a/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_screen.dart b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_screen.dart new file mode 100644 index 0000000..6166869 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/screens/{{feature_name.snakeCase()}}_screen.dart @@ -0,0 +1,33 @@ +// ignore_for_file: always_use_package_imports + +import 'package:flutter/material.dart'; +import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; + +import './widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_parent.dart'; +import '../blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_cubit.dart'; +import 'widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget.dart'; + +/// {@template {{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen} +/// {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen is the merge of Provider and Consumer. +/// {@endtemplate} +class {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen + extends CubitScreen<{{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State> { + /// {@macro {{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen} + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Screen({super.key}); + + @override + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit create(BuildContext context) => {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit(); + + @override + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit init(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}Cubit bloc) => + bloc..yourCustomFunction(); + + @override + Widget parent(BuildContext context, Widget child) => + {{#pascalCase}}{{feature_name}}{{/pascalCase}}Parent(child: child); + + // Rebuild on every bloc changes + @override + Widget onBuild(BuildContext context, {{#pascalCase}}{{feature_name}}{{/pascalCase}}State state) => + const {{#pascalCase}}{{feature_name}}{{/pascalCase}}Widget(); +} diff --git a/bricks/wyatt_feature_template/__brick__/{{feature_name.snakeCase()}}.dart b/bricks/wyatt_feature_template/__brick__/{{feature_name.snakeCase()}}.dart new file mode 100644 index 0000000..1b4b3c3 --- /dev/null +++ b/bricks/wyatt_feature_template/__brick__/{{feature_name.snakeCase()}}.dart @@ -0,0 +1,6 @@ +export 'blocs/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_bloc.dart'; +export 'screens/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_consumer_widget.dart'; +export 'screens/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_provider.dart'; +export 'screens/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_screen.dart'; +export 'screens/widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_parent.dart'; +export 'screens/widgets/{{#snakeCase}}{{feature_name}}{{/snakeCase}}_widget.dart'; diff --git a/bricks/wyatt_feature_template/brick.yaml b/bricks/wyatt_feature_template/brick.yaml new file mode 100644 index 0000000..6556761 --- /dev/null +++ b/bricks/wyatt_feature_template/brick.yaml @@ -0,0 +1,12 @@ +name: wyatt_feature_template +description: A Wyatt Architecture Feature template + +version: 0.1.0 + +vars: + feature_name: + type: string + description: The feature name + default: Feature Name + prompt: What is the feature name? + diff --git a/bricks/wyatt_feature_template/hooks/post_gen.dart b/bricks/wyatt_feature_template/hooks/post_gen.dart new file mode 100644 index 0000000..398a858 --- /dev/null +++ b/bricks/wyatt_feature_template/hooks/post_gen.dart @@ -0,0 +1,39 @@ +// Copyright (C) 2022 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import 'dart:io'; + +import 'package:mason/mason.dart'; + +void removeGitKeepFiles(String targetPath) { + if (!FileSystemEntity.isDirectorySync(targetPath)) { + throw ArgumentError('Target must be a directory', 'targetPath'); + } + + Directory(targetPath) + .listSync(recursive: true) + .whereType() + .forEach((file) { + if (file.path.contains('.gitkeep')) { + file.deleteSync(recursive: true); + } + }); +} + +Future run(HookContext context) async { + final workingDirectory = Directory.current.path; + removeGitKeepFiles(workingDirectory); +} diff --git a/bricks/wyatt_feature_template/hooks/pubspec.yaml b/bricks/wyatt_feature_template/hooks/pubspec.yaml new file mode 100644 index 0000000..454f6df --- /dev/null +++ b/bricks/wyatt_feature_template/hooks/pubspec.yaml @@ -0,0 +1,7 @@ +name: hooks + +environment: + sdk: ">=2.18.0 <3.0.0" + +dependencies: + mason: any \ No newline at end of file