generateDashboardModule function

Future<void> generateDashboardModule(
  1. String projectPath,
  2. String pageName, {
  3. required bool hasBottomBar,
  4. required bool hasDrawer,
  5. required List<String> tabNames,
  6. required List<String> drawerNames,
  7. String? additionalImports,
})

Implementation

Future<void> generateDashboardModule(
  String projectPath,
  String pageName, {
  required bool hasBottomBar,
  required bool hasDrawer,
  required List<String> tabNames,
  required List<String> drawerNames,
  String? additionalImports,
}) async {
  // 1. Generate the sub-pages for each tab
  final List<String> subPageImports = [];
  final projectName = getProjectName(projectPath);

  for (final tab in tabNames) {
    print('📦 Generating sub-page: $tab...');
    await generatePageModule(
      projectPath,
      tab,
      uiType: 'blank', // Use CustomBody based blank template
      addApiCalling: false, // Defaulting to false for sub-pages
    );
    final normalizedTab = toSnakeCase(tab);
    subPageImports.add(
        "import 'package:$projectName/presentation/pages/$normalizedTab/${normalizedTab}_page.dart';");
  }

  // 2. Generate the dashboard host page with the sub-page imports
  final combinedImports = (additionalImports ?? "") + subPageImports.join('\n');

  await generatePageModule(
    projectPath,
    pageName,
    uiType: 'dashboard',
    hasBottomBar: hasBottomBar,
    hasDrawer: hasDrawer,
    tabNames: tabNames,
    drawerNames: drawerNames,
    additionalImports: combinedImports,
  );
}