Skip to content

Commit

Permalink
v5.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Jan 18, 2024
1 parent d77e8c0 commit 4c3f87d
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [5.20.0] - 2024-01-18

* New `--bottom-nav` flag to create bottom nav pages. E.g. `metro make:page dashboard_nav --bottom-nav`
* Add new stub for creating pages that use bottom navigation tabs
* Update pubspec.yaml

## [5.19.0] - 2024-01-15

* Update page and controller stub to use `view` instead of `build`
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ packages:
dependency: transitive
description:
name: nylo_support
sha256: "1599c99829be2dca30420a5b9d2f1c7b389fda7c484ccdf9a2a46af0be3274bb"
sha256: "65846df5fd7bb32070302f7f2d8bcaccbe607b61b19322da4ee89357838e6242"
url: "https://pub.dev"
source: hosted
version: "5.31.0"
version: "5.32.0"
page_transition:
dependency: transitive
description:
Expand Down
42 changes: 41 additions & 1 deletion lib/metro/metro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:cli_dialog/cli_dialog.dart';
import 'package:nylo_framework/json_dart_generator/dart_code_generator.dart';
import 'package:nylo_framework/metro/stubs/config_stub.dart';
import 'package:nylo_framework/metro/stubs/interceptor_stub.dart';
import 'package:nylo_framework/metro/stubs/page_bottom_nav_stub.dart';
import 'package:nylo_framework/metro/stubs/route_guard_stub.dart';
import 'package:nylo_support/metro/models/metro_project_file.dart';
import 'package:nylo_support/metro/models/ny_command.dart';
Expand Down Expand Up @@ -47,7 +48,7 @@ List<NyCommand> allCommands = [
name: "page",
options: 1,
category: "make",
arguments: ["-h", "-f", "-c"],
arguments: ["-h", "-f", "-c", "-b"],
action: _makePage),
NyCommand(
name: "stateful_widget",
Expand Down Expand Up @@ -1021,6 +1022,13 @@ _makePage(List<String> arguments) async {
negatable: false,
);

parser.addFlag(
bottomNavFlag,
abbr: 'b',
help: 'Creates a new page with a bottom navigation bar',
negatable: false,
);

final ArgResults argResults = parser.parse(arguments);

MetroService.hasHelpFlag(argResults[helpFlag], parser.usage);
Expand All @@ -1046,6 +1054,38 @@ _makePage(List<String> arguments) async {
exit(1);
}

if (argResults[bottomNavFlag]) {
final dialogQuestions = CLI_Dialog(listQuestions: [
[
{
'question': 'How many tabs will the page have?',
'options': ["1", "2", "3", "4", "5"]
},
'bottom_tabs'
],
]).ask();

int bottomTabs = int.parse(dialogQuestions['bottom_tabs']);

String stubBottomNavPage = pageBottomNavStub(
className: argResults.arguments.first, tabCount: bottomTabs);

MetroProjectFile projectFile = MetroService.createMetroProjectFile(
argResults.arguments.first,
prefix: RegExp(r'(_?page)'));

await MetroService.makePage(
projectFile.name,
stubBottomNavPage,
forceCreate: hasForceFlag ?? false,
addToRoute: true,
isInitialPage: initialPage,
isAuthPage: authPage,
creationPath: projectFile.creationPath,
);
return;
}

MetroProjectFile projectFile = MetroService.createMetroProjectFile(
argResults.arguments.first,
prefix: RegExp(r'(_?page)'));
Expand Down
66 changes: 66 additions & 0 deletions lib/metro/stubs/page_bottom_nav_stub.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:recase/recase.dart';

/// This stub is used to create a new bottom nav page.
String pageBottomNavStub({required String className, required int tabCount}) =>
'''
import 'package:flutter/material.dart';
import 'package:nylo_framework/nylo_framework.dart';
class ${className.pascalCase}Page extends NyStatefulWidget {
static const path = '/${className.paramCase}';
${className.pascalCase}Page() : super(path, child: _${className.pascalCase}PageState());
}
class _${className.pascalCase}PageState extends NyState<${className.pascalCase}Page> {
int _currentIndex = 0;
final List<Widget> _pages = [
''' +
List.generate(tabCount,
(index) => ' Container(child: Text("Tab ${index + 1}"),),')
.join('\n') +
'''\n
];
@override
init() async {
}
/// Use boot if you need to load data before the [view] is rendered.
// @override
// boot() async {
// await Future.delayed(Duration(seconds: 2));
// }
@override
Widget view(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('${className.pascalCase}'),
),
body: _pages[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
items: [
''' +
List.generate(
tabCount,
(index) =>
' BottomNavigationBarItem(\n icon: Icon(Icons.home),\n label: \'Tab ${index + 1}\',\n ),')
.join('\n') +
'''\n
],
),
);
}
}
''';
2 changes: 1 addition & 1 deletion lib/nylo_framework.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export 'package:nylo_support/networking/ny_base_api_service.dart';
export 'package:dio/dio.dart';

/// Nylo version
const String nyloVersion = 'v5.19.0';
const String nyloVersion = 'v5.20.0';
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ packages:
dependency: "direct main"
description:
name: nylo_support
sha256: "1599c99829be2dca30420a5b9d2f1c7b389fda7c484ccdf9a2a46af0be3274bb"
sha256: "65846df5fd7bb32070302f7f2d8bcaccbe607b61b19322da4ee89357838e6242"
url: "https://pub.dev"
source: hosted
version: "5.31.0"
version: "5.32.0"
page_transition:
dependency: "direct main"
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nylo_framework
description: Micro-framework for Flutter that's built to simplify app development for Flutter projects.
version: 5.19.0
version: 5.20.0
homepage: https://nylo.dev
repository: https://github.com/nylo-core/framework/tree/5.x
issue_tracker: https://github.com/nylo-core/framework/issues
Expand All @@ -16,7 +16,7 @@ environment:

dependencies:
flutter_dotenv: ^5.1.0
nylo_support: ^5.31.0
nylo_support: ^5.32.0
theme_provider: ^0.6.0
page_transition: ^2.1.0
cli_dialog: ^0.5.0
Expand Down

0 comments on commit 4c3f87d

Please sign in to comment.