diff --git a/lib/commands/impl/create/page/page.dart b/lib/commands/impl/create/page/page.dart index 9ad5f014..917eafff 100644 --- a/lib/commands/impl/create/page/page.dart +++ b/lib/commands/impl/create/page/page.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:cli_dialog/cli_dialog.dart'; +import 'package:get_cli/samples/impl/remote_data_source.dart'; import 'package:recase/recase.dart'; import '../../../../common/menu/menu.dart'; @@ -15,6 +16,7 @@ import '../../../../functions/routes/get_add_route.dart'; import '../../../../samples/impl/get_binding.dart'; import '../../../../samples/impl/get_controller.dart'; import '../../../../samples/impl/get_view.dart'; +import '../../../../samples/impl/local_data_source.dart'; import '../../../interface/command.dart'; /// The command create a Binding and Controller page and view @@ -24,6 +26,7 @@ class CreatePageCommand extends Command { @override List get alias => ['module', '-p', '-m']; + @override Future execute() async { var isProject = false; @@ -109,6 +112,7 @@ class CreatePageCommand extends Command { ), 'views', ); + var bindingFile = handleFileCreate( name, 'binding', @@ -124,7 +128,30 @@ class CreatePageCommand extends Command { ), 'bindings', ); - + var remoteDataSourceFile = handleFileCreate( + name, + 'remote_data_source', + path, + extraFolder, + RemoteDataSourceSample( + '', + '${name.pascalCase}RemoteDataSource', + overwrite: overwrite, + ), + 'data_sources', + ); + var localDataSourceFile = handleFileCreate( + name, + 'local_data_source', + path, + extraFolder, + LocalDataSourceSample( + '', + '${name.pascalCase}LocalDataSource', + overwrite: overwrite, + ), + 'data_sources', + ); addRoute( name, Structure.pathToDirImport(bindingFile.path), diff --git a/lib/samples/impl/getx_pattern/get_main.dart b/lib/samples/impl/getx_pattern/get_main.dart index 233c6616..85257be3 100644 --- a/lib/samples/impl/getx_pattern/get_main.dart +++ b/lib/samples/impl/getx_pattern/get_main.dart @@ -10,14 +10,22 @@ import 'package:get/get.dart'; import 'app/routes/app_pages.dart'; void main() { - runApp( - GetMaterialApp( + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GetMaterialApp( title: "Application", initialRoute: AppPages.INITIAL, getPages: AppPages.routes, - ), - ); + ); + } } + '''; String get _serverMain => '''import 'package:get_server/get_server.dart'; diff --git a/lib/samples/impl/local_data_source.dart b/lib/samples/impl/local_data_source.dart new file mode 100644 index 00000000..043d5cd0 --- /dev/null +++ b/lib/samples/impl/local_data_source.dart @@ -0,0 +1,17 @@ +import 'package:get_cli/samples/interface/sample_interface.dart'; + +/// [Sample] file from Module_View file creation. +class LocalDataSourceSample extends Sample { + final String _name; + + LocalDataSourceSample(String path, this._name, {bool overwrite = false}) + : super(path, overwrite: overwrite); + + @override + String get content => ''' + +class $_name { + +} + '''; +} diff --git a/lib/samples/impl/remote_data_source.dart b/lib/samples/impl/remote_data_source.dart new file mode 100644 index 00000000..292f82f4 --- /dev/null +++ b/lib/samples/impl/remote_data_source.dart @@ -0,0 +1,17 @@ +import '../../common/utils/pubspec/pubspec_utils.dart'; +import '../interface/sample_interface.dart'; + +/// [Sample] file from Module_View file creation. +class RemoteDataSourceSample extends Sample { + final String _name; + + RemoteDataSourceSample(String path, this._name, {bool overwrite = false}) + : super(path, overwrite: overwrite); + + @override + String get content => ''' + +class $_name { +} + '''; +}