From 1d1e7637ccd9e2f5b117d99408ab36b0e4d34d6f Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Fri, 3 Mar 2023 14:41:50 +0100 Subject: [PATCH] fix: rename layout in app template --- apps/wyatt_app_template/brickgen.yaml | 1 + .../starting_template/lib/main.dart | 115 ------------------ .../counter/screens/counter_provider.dart | 4 +- .../lib/presentation/features/home/home.dart | 4 +- ...d.dart => starting_template_scaffold.dart} | 4 +- .../__brick__/lib/main.dart | 115 ------------------ .../counter/screens/counter_provider.dart | 4 +- .../lib/presentation/features/home/home.dart | 4 +- ...{project_name.snakeCase()}}_scaffold.dart} | 4 +- 9 files changed, 13 insertions(+), 242 deletions(-) delete mode 100644 apps/wyatt_app_template/starting_template/lib/main.dart rename apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/{wyatt_app_template_scaffold.dart => starting_template_scaffold.dart} (87%) delete mode 100644 bricks/wyatt_app_template/__brick__/lib/main.dart rename bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/{wyatt_app_template_scaffold.dart => {{project_name.snakeCase()}}_scaffold.dart} (80%) diff --git a/apps/wyatt_app_template/brickgen.yaml b/apps/wyatt_app_template/brickgen.yaml index 78f9e3d..7ee4e4f 100644 --- a/apps/wyatt_app_template/brickgen.yaml +++ b/apps/wyatt_app_template/brickgen.yaml @@ -37,6 +37,7 @@ vars: prompt: "What is the project name?" formats: - snake_case + - pascal_case bundle_id: compilable: io.wyattapp.start diff --git a/apps/wyatt_app_template/starting_template/lib/main.dart b/apps/wyatt_app_template/starting_template/lib/main.dart deleted file mode 100644 index e016029..0000000 --- a/apps/wyatt_app_template/starting_template/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_app_template/starting_template/lib/presentation/features/counter/screens/counter_provider.dart b/apps/wyatt_app_template/starting_template/lib/presentation/features/counter/screens/counter_provider.dart index 7917abf..bbcd05a 100644 --- a/apps/wyatt_app_template/starting_template/lib/presentation/features/counter/screens/counter_provider.dart +++ b/apps/wyatt_app_template/starting_template/lib/presentation/features/counter/screens/counter_provider.dart @@ -7,7 +7,7 @@ import 'package:starting_template/domain/usecases/counter/increment.dart'; import 'package:starting_template/domain/usecases/counter/reset.dart'; import 'package:starting_template/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart'; import 'package:starting_template/presentation/features/counter/screens/widgets/counter_consumer_widget.dart'; -import 'package:starting_template/presentation/shared/layouts/wyatt_app_template_scaffold.dart'; +import 'package:starting_template/presentation/shared/layouts/starting_template_scaffold.dart'; import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; /// {@template counter_provider} @@ -38,7 +38,7 @@ class CounterProvider extends CubitProviderScreen { bloc..getCurrent(); @override - Widget builder(BuildContext context) => WyattAppTemplateScaffold( + Widget builder(BuildContext context) => StartingTemplateScaffold( title: Text(context.l10n.counterAppBarTitle), body: const CounterConsumerWidget(), fabChildren: [ diff --git a/apps/wyatt_app_template/starting_template/lib/presentation/features/home/home.dart b/apps/wyatt_app_template/starting_template/lib/presentation/features/home/home.dart index a886492..d32ea92 100644 --- a/apps/wyatt_app_template/starting_template/lib/presentation/features/home/home.dart +++ b/apps/wyatt_app_template/starting_template/lib/presentation/features/home/home.dart @@ -4,7 +4,7 @@ import 'package:go_router/go_router.dart'; import 'package:starting_template/core/extensions/build_context_extension.dart'; import 'package:starting_template/gen/assets.gen.dart'; import 'package:starting_template/presentation/features/counter/counter.dart'; -import 'package:starting_template/presentation/shared/layouts/wyatt_app_template_scaffold.dart'; +import 'package:starting_template/presentation/shared/layouts/starting_template_scaffold.dart'; class Home extends StatelessWidget { const Home({super.key}); @@ -12,7 +12,7 @@ class Home extends StatelessWidget { static const String pageName = 'homePage'; @override - Widget build(BuildContext context) => WyattAppTemplateScaffold( + Widget build(BuildContext context) => StartingTemplateScaffold( body: Center( child: Column( children: [ diff --git a/apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart b/apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/starting_template_scaffold.dart similarity index 87% rename from apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart rename to apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/starting_template_scaffold.dart index 60e2dee..52e425d 100644 --- a/apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart +++ b/apps/wyatt_app_template/starting_template/lib/presentation/shared/layouts/starting_template_scaffold.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -class WyattAppTemplateScaffold extends StatelessWidget { - const WyattAppTemplateScaffold({ +class StartingTemplateScaffold extends StatelessWidget { + const StartingTemplateScaffold({ required this.body, super.key, this.title, diff --git a/bricks/wyatt_app_template/__brick__/lib/main.dart b/bricks/wyatt_app_template/__brick__/lib/main.dart deleted file mode 100644 index e016029..0000000 --- a/bricks/wyatt_app_template/__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/bricks/wyatt_app_template/__brick__/lib/presentation/features/counter/screens/counter_provider.dart b/bricks/wyatt_app_template/__brick__/lib/presentation/features/counter/screens/counter_provider.dart index 8b56c08..b17d165 100644 --- a/bricks/wyatt_app_template/__brick__/lib/presentation/features/counter/screens/counter_provider.dart +++ b/bricks/wyatt_app_template/__brick__/lib/presentation/features/counter/screens/counter_provider.dart @@ -7,7 +7,7 @@ import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/domain/usecases/cou import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/domain/usecases/counter/reset.dart'; import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart'; import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/screens/widgets/counter_consumer_widget.dart'; -import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/wyatt_app_template_scaffold.dart'; +import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/{{#snakeCase}}{{project_name}}{{/snakeCase}}_scaffold.dart'; import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; /// {@template counter_provider} @@ -38,7 +38,7 @@ class CounterProvider extends CubitProviderScreen { bloc..getCurrent(); @override - Widget builder(BuildContext context) => WyattAppTemplateScaffold( + Widget builder(BuildContext context) => {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold( title: Text(context.l10n.counterAppBarTitle), body: const CounterConsumerWidget(), fabChildren: [ diff --git a/bricks/wyatt_app_template/__brick__/lib/presentation/features/home/home.dart b/bricks/wyatt_app_template/__brick__/lib/presentation/features/home/home.dart index e9deaaa..9e2dd3c 100644 --- a/bricks/wyatt_app_template/__brick__/lib/presentation/features/home/home.dart +++ b/bricks/wyatt_app_template/__brick__/lib/presentation/features/home/home.dart @@ -4,7 +4,7 @@ import 'package:go_router/go_router.dart'; import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/core/extensions/build_context_extension.dart'; import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/gen/assets.gen.dart'; import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/counter.dart'; -import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/wyatt_app_template_scaffold.dart'; +import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/{{#snakeCase}}{{project_name}}{{/snakeCase}}_scaffold.dart'; class Home extends StatelessWidget { const Home({super.key}); @@ -12,7 +12,7 @@ class Home extends StatelessWidget { static const String pageName = 'homePage'; @override - Widget build(BuildContext context) => WyattAppTemplateScaffold( + Widget build(BuildContext context) => {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold( body: Center( child: Column( children: [ diff --git a/bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart b/bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/{{project_name.snakeCase()}}_scaffold.dart similarity index 80% rename from bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart rename to bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/{{project_name.snakeCase()}}_scaffold.dart index 60e2dee..3807595 100644 --- a/bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/wyatt_app_template_scaffold.dart +++ b/bricks/wyatt_app_template/__brick__/lib/presentation/shared/layouts/{{project_name.snakeCase()}}_scaffold.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -class WyattAppTemplateScaffold extends StatelessWidget { - const WyattAppTemplateScaffold({ +class {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold extends StatelessWidget { + const {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold({ required this.body, super.key, this.title,