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
29 changes: 28 additions & 1 deletion lib/commands/impl/create/page/page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand All @@ -24,6 +26,7 @@ class CreatePageCommand extends Command {

@override
List<String> get alias => ['module', '-p', '-m'];

@override
Future<void> execute() async {
var isProject = false;
Expand Down Expand Up @@ -109,6 +112,7 @@ class CreatePageCommand extends Command {
),
'views',
);

var bindingFile = handleFileCreate(
name,
'binding',
Expand All @@ -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),
Expand Down
16 changes: 12 additions & 4 deletions lib/samples/impl/getx_pattern/get_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
17 changes: 17 additions & 0 deletions lib/samples/impl/local_data_source.dart
Original file line number Diff line number Diff line change
@@ -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 {

}
''';
}
17 changes: 17 additions & 0 deletions lib/samples/impl/remote_data_source.dart
Original file line number Diff line number Diff line change
@@ -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 {
}
''';
}