From 553af640503fdaf5fcb50af09b2a4eb013043df7 Mon Sep 17 00:00:00 2001 From: Pebkac03 Date: Thu, 12 Dec 2024 18:21:57 +0100 Subject: [PATCH 1/2] feat: added --disable-version-check flag --- bin/stacked.dart | 6 +++++- lib/src/constants/command_constants.dart | 2 ++ lib/src/constants/message_constants.dart | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/stacked.dart b/bin/stacked.dart index 1b054e5..9e69724 100644 --- a/bin/stacked.dart +++ b/bin/stacked.dart @@ -27,6 +27,8 @@ Future main(List arguments) async { negatable: false, help: kCommandHelpVersion, ) + ..argParser.addFlag(ksDisableVersionCheck, + negatable: false, help: kCommandHelpDisableVersionCheck) // ..argParser.addFlag( // ksEnableAnalytics, // negatable: false, @@ -56,7 +58,9 @@ Future main(List arguments) async { /// triggered twice // if (_handleAnalytics(argResults)) exit(0); - await _notifyNewVersionAvailable(arguments: arguments); + !argResults[ksDisableVersionCheck] + ? await _notifyNewVersionAvailable(arguments: arguments) + : {}; runner.run(arguments); } on InvalidStackedStructureException catch (e) { diff --git a/lib/src/constants/command_constants.dart b/lib/src/constants/command_constants.dart index 8a9845e..5138761 100644 --- a/lib/src/constants/command_constants.dart +++ b/lib/src/constants/command_constants.dart @@ -1,4 +1,5 @@ /// Stores all the commands used throughout the app that +library; const String ksDart = 'dart'; const String ksFlutter = 'flutter'; @@ -12,6 +13,7 @@ const String ksBuildRunner = 'build_runner'; const String ksDeleteConflictOutputs = 'delete-conflicting-outputs'; const String ksDeleteConflictingOutputs = '--delete-conflicting-outputs'; const String ksVersion = 'version'; +const String ksDisableVersionCheck = 'disable-version-check'; const String ksEnableAnalytics = 'enable-analytics'; const String ksDisableAnalytics = 'disable-analytics'; const String ksExcludeRoute = 'exclude-route'; diff --git a/lib/src/constants/message_constants.dart b/lib/src/constants/message_constants.dart index 4e7a533..1e4b9fe 100644 --- a/lib/src/constants/message_constants.dart +++ b/lib/src/constants/message_constants.dart @@ -1,5 +1,6 @@ /// Stores all the messages used throughout the app that communicates /// with the user of the package. +library; /// Message shown when we encounter a failure during generation that's caused by an invalid /// app structure. @@ -25,6 +26,9 @@ for the stacked-cli roadmap. const String kCommandHelpVersion = 'Print the current version.'; +const String kCommandHelpDisableVersionCheck = + 'Disables version check, primarily used during development'; + const String kCommandHelpEnableAnalytics = 'Enable Analytics.'; const String kCommandHelpDisableAnalytics = 'Disable Analytics.'; From f08e730324e00351857649672afb29f4a416cb46 Mon Sep 17 00:00:00 2001 From: Pebkac03 Date: Thu, 12 Dec 2024 18:22:54 +0100 Subject: [PATCH 2/2] fix: force unix path separators in compiled_templates.dart --- lib/src/services/template_service.dart | 8 +- lib/src/templates/compiled_constants.dart | 14 +- lib/src/templates/compiled_template_map.dart | 575 +- lib/src/templates/compiled_templates.dart | 5162 +++++++++--------- test/helpers/test_helpers.mocks.dart | 833 ++- 5 files changed, 3618 insertions(+), 2974 deletions(-) diff --git a/lib/src/services/template_service.dart b/lib/src/services/template_service.dart index 5221101..99ab3d1 100644 --- a/lib/src/services/template_service.dart +++ b/lib/src/services/template_service.dart @@ -93,8 +93,12 @@ class TemplateService { } final outputTemplate = Template(kTemplateDataStructure); - final templateItemsData = { - 'templateItems': allTemplateItems.map((e) => e.toJson()).toList(), + final Map>> templateItemsData = { + 'templateItems': allTemplateItems.map((e) { + Map result = e.toJson(); + result['path'] = result['path'].replaceAll(r'\', '/'); + return result; + }).toList(), }; final allTemplateItemsContent = diff --git a/lib/src/templates/compiled_constants.dart b/lib/src/templates/compiled_constants.dart index 4a3a61e..5d09875 100644 --- a/lib/src/templates/compiled_constants.dart +++ b/lib/src/templates/compiled_constants.dart @@ -1,26 +1,26 @@ -/// NOTE: This is generated code from the compileTemplates command. Do not +/// NOTE: This is generated code from the compileTemplates command. Do not /// modify by hand. /// This file should be checked into source control. Map> kCompiledTemplateTypes = { 'app': [ - 'web', 'mobile', + 'web', ], - 'widget': [ + 'bottom_sheet': [ 'empty', ], 'dialog': [ 'empty', ], - 'view': [ + 'service': [ 'empty', - 'web', ], - 'service': [ + 'view': [ 'empty', + 'web', ], - 'bottom_sheet': [ + 'widget': [ 'empty', ], }; diff --git a/lib/src/templates/compiled_template_map.dart b/lib/src/templates/compiled_template_map.dart index 66cab8f..c1c3a6f 100644 --- a/lib/src/templates/compiled_template_map.dart +++ b/lib/src/templates/compiled_template_map.dart @@ -5,290 +5,306 @@ import 'package:stacked_cli/src/templates/compiled_templates.dart'; Map> kCompiledStackedTemplates = { 'app': { - 'web': StackedTemplate( + 'mobile': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: kAppWebTemplateStackedJsonStkPath, - content: kAppWebTemplateStackedJsonStkContent, + relativeOutputPath: kAppMobileTemplateSettingsJsonStkPath, + content: kAppMobileTemplateSettingsJsonStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewmodelTestPath, - content: kAppWebTemplateUnknownViewmodelTestContent, + relativeOutputPath: kAppMobileTemplateAppPath, + content: kAppMobileTemplateAppContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewmodelTestPath, - content: kAppWebTemplateHomeViewmodelTestContent, + relativeOutputPath: kAppMobileTemplateMainPath, + content: kAppMobileTemplateMainContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateNoticeSheetModelTestPath, - content: kAppWebTemplateNoticeSheetModelTestContent, + relativeOutputPath: kAppMobileTemplateNoticeSheetPath, + content: kAppMobileTemplateNoticeSheetContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateInfoAlertDialogModelTestPath, - content: kAppWebTemplateInfoAlertDialogModelTestContent, + relativeOutputPath: kAppMobileTemplateNoticeSheetModelPath, + content: kAppMobileTemplateNoticeSheetModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateTestHelpersPath, - content: kAppWebTemplateTestHelpersContent, + relativeOutputPath: kAppMobileTemplateAppColorsPath, + content: kAppMobileTemplateAppColorsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateBuildYamlStkPath, - content: kAppWebTemplateBuildYamlStkContent, + relativeOutputPath: kAppMobileTemplateAppStringsPath, + content: kAppMobileTemplateAppStringsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateMainIconPngStkPath, - content: kAppWebTemplateMainIconPngStkContent, - fileType: FileType.image), - TemplateFile( - relativeOutputPath: kAppWebTemplateIndexHtmlStkPath, - content: kAppWebTemplateIndexHtmlStkContent, + relativeOutputPath: kAppMobileTemplateUiHelpersPath, + content: kAppMobileTemplateUiHelpersContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateFaviconPngStkPath, - content: kAppWebTemplateFaviconPngStkContent, - fileType: FileType.image), - TemplateFile( - relativeOutputPath: kAppWebTemplateREADMEMdStkPath, - content: kAppWebTemplateREADMEMdStkContent, + relativeOutputPath: kAppMobileTemplateInfoAlertDialogPath, + content: kAppMobileTemplateInfoAlertDialogContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateMainPath, - content: kAppWebTemplateMainContent, + relativeOutputPath: kAppMobileTemplateInfoAlertDialogModelPath, + content: kAppMobileTemplateInfoAlertDialogModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateAppConstantsPath, - content: kAppWebTemplateAppConstantsContent, + relativeOutputPath: kAppMobileTemplateHomeViewPath, + content: kAppMobileTemplateHomeViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUiHelpersPath, - content: kAppWebTemplateUiHelpersContent, + relativeOutputPath: kAppMobileTemplateHomeViewmodelPath, + content: kAppMobileTemplateHomeViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateAppStringsPath, - content: kAppWebTemplateAppStringsContent, + relativeOutputPath: kAppMobileTemplateHomeViewV1Path, + content: kAppMobileTemplateHomeViewV1Content, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateAppColorsPath, - content: kAppWebTemplateAppColorsContent, + relativeOutputPath: kAppMobileTemplateStartupViewPath, + content: kAppMobileTemplateStartupViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateNoticeSheetModelPath, - content: kAppWebTemplateNoticeSheetModelContent, + relativeOutputPath: kAppMobileTemplateStartupViewmodelPath, + content: kAppMobileTemplateStartupViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateNoticeSheetPath, - content: kAppWebTemplateNoticeSheetContent, + relativeOutputPath: kAppMobileTemplateStartupViewV1Path, + content: kAppMobileTemplateStartupViewV1Content, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateInfoAlertDialogModelPath, - content: kAppWebTemplateInfoAlertDialogModelContent, + relativeOutputPath: kAppMobileTemplatePubspecYamlStkPath, + content: kAppMobileTemplatePubspecYamlStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateInfoAlertDialogPath, - content: kAppWebTemplateInfoAlertDialogContent, + relativeOutputPath: kAppMobileTemplateREADMEMdStkPath, + content: kAppMobileTemplateREADMEMdStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewDesktopPath, - content: kAppWebTemplateHomeViewDesktopContent, + relativeOutputPath: kAppMobileTemplateStackedJsonStkPath, + content: kAppMobileTemplateStackedJsonStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewMobilePath, - content: kAppWebTemplateHomeViewMobileContent, + relativeOutputPath: kAppMobileTemplateTestHelpersPath, + content: kAppMobileTemplateTestHelpersContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewPath, - content: kAppWebTemplateHomeViewContent, + relativeOutputPath: kAppMobileTemplateHomeViewmodelTestPath, + content: kAppMobileTemplateHomeViewmodelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewmodelPath, - content: kAppWebTemplateHomeViewmodelContent, + relativeOutputPath: kAppMobileTemplateInfoAlertDialogModelTestPath, + content: kAppMobileTemplateInfoAlertDialogModelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHomeViewTabletPath, - content: kAppWebTemplateHomeViewTabletContent, + relativeOutputPath: kAppMobileTemplateNoticeSheetModelTestPath, + content: kAppMobileTemplateNoticeSheetModelTestContent, fileType: FileType.text), + ], + modificationFiles: [], + ), + 'web': StackedTemplate( + templateFiles: [ TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewPath, - content: kAppWebTemplateUnknownViewContent, + relativeOutputPath: kAppWebTemplateSettingsJsonStkPath, + content: kAppWebTemplateSettingsJsonStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewDesktopPath, - content: kAppWebTemplateUnknownViewDesktopContent, + relativeOutputPath: kAppWebTemplateBuildYamlStkPath, + content: kAppWebTemplateBuildYamlStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewTabletPath, - content: kAppWebTemplateUnknownViewTabletContent, + relativeOutputPath: kAppWebTemplateAppPath, + content: kAppWebTemplateAppContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewmodelPath, - content: kAppWebTemplateUnknownViewmodelContent, + relativeOutputPath: kAppWebTemplateHoverExtensionsPath, + content: kAppWebTemplateHoverExtensionsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateUnknownViewMobilePath, - content: kAppWebTemplateUnknownViewMobileContent, + relativeOutputPath: kAppWebTemplateMainPath, + content: kAppWebTemplateMainContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateStartupViewmodelPath, - content: kAppWebTemplateStartupViewmodelContent, + relativeOutputPath: kAppWebTemplateNoticeSheetPath, + content: kAppWebTemplateNoticeSheetContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateStartupViewPath, - content: kAppWebTemplateStartupViewContent, + relativeOutputPath: kAppWebTemplateNoticeSheetModelPath, + content: kAppWebTemplateNoticeSheetModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateScaleOnHoverPath, - content: kAppWebTemplateScaleOnHoverContent, + relativeOutputPath: kAppWebTemplateAppColorsPath, + content: kAppWebTemplateAppColorsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateTranslateOnHoverPath, - content: kAppWebTemplateTranslateOnHoverContent, + relativeOutputPath: kAppWebTemplateAppConstantsPath, + content: kAppWebTemplateAppConstantsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateAppPath, - content: kAppWebTemplateAppContent, + relativeOutputPath: kAppWebTemplateAppStringsPath, + content: kAppWebTemplateAppStringsContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateHoverExtensionsPath, - content: kAppWebTemplateHoverExtensionsContent, + relativeOutputPath: kAppWebTemplateUiHelpersPath, + content: kAppWebTemplateUiHelpersContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplatePubspecYamlStkPath, - content: kAppWebTemplatePubspecYamlStkContent, + relativeOutputPath: kAppWebTemplateInfoAlertDialogPath, + content: kAppWebTemplateInfoAlertDialogContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppWebTemplateSettingsJsonStkPath, - content: kAppWebTemplateSettingsJsonStkContent, + relativeOutputPath: kAppWebTemplateInfoAlertDialogModelPath, + content: kAppWebTemplateInfoAlertDialogModelContent, fileType: FileType.text), - ], - modificationFiles: [], - ), - 'mobile': StackedTemplate( - templateFiles: [ TemplateFile( - relativeOutputPath: kAppMobileTemplateStackedJsonStkPath, - content: kAppMobileTemplateStackedJsonStkContent, + relativeOutputPath: kAppWebTemplateHomeViewPath, + content: kAppWebTemplateHomeViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateHomeViewmodelTestPath, - content: kAppMobileTemplateHomeViewmodelTestContent, + relativeOutputPath: kAppWebTemplateHomeViewDesktopPath, + content: kAppWebTemplateHomeViewDesktopContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateNoticeSheetModelTestPath, - content: kAppMobileTemplateNoticeSheetModelTestContent, + relativeOutputPath: kAppWebTemplateHomeViewMobilePath, + content: kAppWebTemplateHomeViewMobileContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateInfoAlertDialogModelTestPath, - content: kAppMobileTemplateInfoAlertDialogModelTestContent, + relativeOutputPath: kAppWebTemplateHomeViewTabletPath, + content: kAppWebTemplateHomeViewTabletContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateTestHelpersPath, - content: kAppMobileTemplateTestHelpersContent, + relativeOutputPath: kAppWebTemplateHomeViewmodelPath, + content: kAppWebTemplateHomeViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateREADMEMdStkPath, - content: kAppMobileTemplateREADMEMdStkContent, + relativeOutputPath: kAppWebTemplateStartupViewPath, + content: kAppWebTemplateStartupViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateMainPath, - content: kAppMobileTemplateMainContent, + relativeOutputPath: kAppWebTemplateStartupViewmodelPath, + content: kAppWebTemplateStartupViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateUiHelpersPath, - content: kAppMobileTemplateUiHelpersContent, + relativeOutputPath: kAppWebTemplateUnknownViewPath, + content: kAppWebTemplateUnknownViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateAppStringsPath, - content: kAppMobileTemplateAppStringsContent, + relativeOutputPath: kAppWebTemplateUnknownViewDesktopPath, + content: kAppWebTemplateUnknownViewDesktopContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateAppColorsPath, - content: kAppMobileTemplateAppColorsContent, + relativeOutputPath: kAppWebTemplateUnknownViewMobilePath, + content: kAppWebTemplateUnknownViewMobileContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateNoticeSheetModelPath, - content: kAppMobileTemplateNoticeSheetModelContent, + relativeOutputPath: kAppWebTemplateUnknownViewTabletPath, + content: kAppWebTemplateUnknownViewTabletContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateNoticeSheetPath, - content: kAppMobileTemplateNoticeSheetContent, + relativeOutputPath: kAppWebTemplateUnknownViewmodelPath, + content: kAppWebTemplateUnknownViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateInfoAlertDialogModelPath, - content: kAppMobileTemplateInfoAlertDialogModelContent, + relativeOutputPath: kAppWebTemplateScaleOnHoverPath, + content: kAppWebTemplateScaleOnHoverContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateInfoAlertDialogPath, - content: kAppMobileTemplateInfoAlertDialogContent, + relativeOutputPath: kAppWebTemplateTranslateOnHoverPath, + content: kAppWebTemplateTranslateOnHoverContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateHomeViewV1Path, - content: kAppMobileTemplateHomeViewV1Content, + relativeOutputPath: kAppWebTemplatePubspecYamlStkPath, + content: kAppWebTemplatePubspecYamlStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateHomeViewPath, - content: kAppMobileTemplateHomeViewContent, + relativeOutputPath: kAppWebTemplateREADMEMdStkPath, + content: kAppWebTemplateREADMEMdStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateHomeViewmodelPath, - content: kAppMobileTemplateHomeViewmodelContent, + relativeOutputPath: kAppWebTemplateStackedJsonStkPath, + content: kAppWebTemplateStackedJsonStkContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateStartupViewmodelPath, - content: kAppMobileTemplateStartupViewmodelContent, + relativeOutputPath: kAppWebTemplateTestHelpersPath, + content: kAppWebTemplateTestHelpersContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateStartupViewV1Path, - content: kAppMobileTemplateStartupViewV1Content, + relativeOutputPath: kAppWebTemplateHomeViewmodelTestPath, + content: kAppWebTemplateHomeViewmodelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateStartupViewPath, - content: kAppMobileTemplateStartupViewContent, + relativeOutputPath: kAppWebTemplateInfoAlertDialogModelTestPath, + content: kAppWebTemplateInfoAlertDialogModelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateAppPath, - content: kAppMobileTemplateAppContent, + relativeOutputPath: kAppWebTemplateNoticeSheetModelTestPath, + content: kAppWebTemplateNoticeSheetModelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplatePubspecYamlStkPath, - content: kAppMobileTemplatePubspecYamlStkContent, + relativeOutputPath: kAppWebTemplateUnknownViewmodelTestPath, + content: kAppWebTemplateUnknownViewmodelTestContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kAppMobileTemplateSettingsJsonStkPath, - content: kAppMobileTemplateSettingsJsonStkContent, + relativeOutputPath: kAppWebTemplateFaviconPngStkPath, + content: kAppWebTemplateFaviconPngStkContent, + fileType: FileType.image), + TemplateFile( + relativeOutputPath: kAppWebTemplateIndexHtmlStkPath, + content: kAppWebTemplateIndexHtmlStkContent, fileType: FileType.text), + TemplateFile( + relativeOutputPath: kAppWebTemplateMainIconPngStkPath, + content: kAppWebTemplateMainIconPngStkContent, + fileType: FileType.image), ], modificationFiles: [], ), }, - 'widget': { + 'bottom_sheet': { 'empty': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: kWidgetEmptyTemplateGenericModelTestPath, - content: kWidgetEmptyTemplateGenericModelTestContent, + relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetPath, + content: kBottomSheetEmptyTemplateGenericSheetContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kWidgetEmptyTemplateGenericUseModelPath, - content: kWidgetEmptyTemplateGenericUseModelContent, + relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelPath, + content: kBottomSheetEmptyTemplateGenericSheetModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kWidgetEmptyTemplateGenericPath, - content: kWidgetEmptyTemplateGenericContent, + relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetUseModelPath, + content: kBottomSheetEmptyTemplateGenericSheetUseModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kWidgetEmptyTemplateGenericModelPath, - content: kWidgetEmptyTemplateGenericModelContent, + relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelTestPath, + content: kBottomSheetEmptyTemplateGenericSheetModelTestContent, fileType: FileType.text), ], - modificationFiles: [], + modificationFiles: [ + ModificationFile( + relativeModificationPath: 'lib/app/app.dart', + modificationIdentifier: '// @stacked-import', + modificationTemplate: '''import \'package:{{packageName}}/{{{bottomSheetsPath}}}/{{sheetFolderName}}/{{sheetFilename}}\';''', + modificationProblemError: 'The bottom sheet registration should be stored in lib/app/app.dart', + modificationName: 'Add import for \'{{sheetName}}\' class', + ), + + ModificationFile( + relativeModificationPath: 'lib/app/app.dart', + modificationIdentifier: '// @stacked-bottom-sheet', + modificationTemplate: '''StackedBottomsheet(classType: {{sheetName}}),''', + modificationProblemError: 'The bottom sheet registration should be stored in lib/app/app.dart', + modificationName: 'Add \'{{sheetName}}\' dependency to StackedApp annotations file', + ), + ], ), }, 'dialog': { 'empty': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: kDialogEmptyTemplateGenericDialogModelTestPath, - content: kDialogEmptyTemplateGenericDialogModelTestContent, + relativeOutputPath: kDialogEmptyTemplateGenericDialogPath, + content: kDialogEmptyTemplateGenericDialogContent, fileType: FileType.text), TemplateFile( relativeOutputPath: kDialogEmptyTemplateGenericDialogModelPath, @@ -299,83 +315,144 @@ Map> kCompiledStackedTemplates = { content: kDialogEmptyTemplateGenericDialogUseModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kDialogEmptyTemplateGenericDialogPath, - content: kDialogEmptyTemplateGenericDialogContent, + relativeOutputPath: kDialogEmptyTemplateGenericDialogModelTestPath, + content: kDialogEmptyTemplateGenericDialogModelTestContent, fileType: FileType.text), ], modificationFiles: [ + ModificationFile( + relativeModificationPath: 'lib/app/app.dart', + modificationIdentifier: '// @stacked-import', + modificationTemplate: '''import \'package:{{packageName}}/{{{dialogsPath}}}/{{dialogFolderName}}/{{dialogFilename}}\';''', + modificationProblemError: 'The dialog registration should be stored in lib/app/app.dart', + modificationName: 'Add import for \'{{dialogName}}\' class', + ), + ModificationFile( relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-dialog', modificationTemplate: '''StackedDialog(classType: {{dialogName}}),''', - modificationProblemError: - 'The dialog registration should be stored in lib/app/app.dart', - modificationName: - 'Add \'{{dialogName}}\' dependency to StackedApp annotations file', + modificationProblemError: 'The dialog registration should be stored in lib/app/app.dart', + modificationName: 'Add \'{{dialogName}}\' dependency to StackedApp annotations file', ), + ], + ), + }, + 'service': { + 'empty': StackedTemplate( + templateFiles: [ + TemplateFile( + relativeOutputPath: kServiceEmptyTemplateGenericServicePath, + content: kServiceEmptyTemplateGenericServiceContent, + fileType: FileType.text), + TemplateFile( + relativeOutputPath: kServiceEmptyTemplateGenericServiceTestPath, + content: kServiceEmptyTemplateGenericServiceTestContent, + fileType: FileType.text), + ], + modificationFiles: [ ModificationFile( relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{dialogsPath}}}/{{dialogFolderName}}/{{dialogFilename}}\';''', - modificationProblemError: - 'The dialog registration should be stored in lib/app/app.dart', - modificationName: 'Add import for \'{{dialogName}}\' class', + modificationTemplate: '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''', + modificationProblemError: 'The service registration should be stored in lib/app/app.dart', + modificationName: 'Add {{serviceName}} import to StackedApp annotations file', ), - ], + + ModificationFile( + relativeModificationPath: 'test/helpers/test_helpers.dart', + modificationIdentifier: '// @stacked-import', + modificationTemplate: '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''', + modificationProblemError: 'It seems your test_helpers.dart file is not in test/helpers/test_helpers.dart. Add a stacked.json file and set the path for \'test_helpers_path\' to the folder we can locate your test_helpers.dart file', + modificationName: 'Add {{serviceName}} import to test helpers', + ), + + ModificationFile( + relativeModificationPath: 'test/helpers/test_helpers.dart', + modificationIdentifier: '// @stacked-mock-spec', + modificationTemplate: '''MockSpec<{{serviceName}}>(onMissingStub: OnMissingStub.returnDefault),''', + modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', + modificationName: 'Create {{serviceName}} mock to test helpers', + ), + + ModificationFile( + relativeModificationPath: 'test/helpers/test_helpers.dart', + modificationIdentifier: '// @stacked-mock-create', + modificationTemplate: '''Mock{{serviceName}} getAndRegister{{serviceName}}() { +_removeRegistrationIfExists<{{serviceName}}>(); +final service = Mock{{serviceName}}(); +{{locatorName}}.registerSingleton<{{serviceName}}>(service); +return service; +}''', + modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', + modificationName: 'Add {{serviceName}} mock to test helpers', + ), + + ModificationFile( + relativeModificationPath: 'lib/app/app.dart', + modificationIdentifier: '// @stacked-service', + modificationTemplate: '''LazySingleton(classType: {{serviceName}}),''', + modificationProblemError: 'The service registration should be stored in lib/app/app.dart', + modificationName: 'Add {{serviceName}} dependency to StackedApp annotations file', + ), + + ModificationFile( + relativeModificationPath: 'test/helpers/test_helpers.dart', + modificationIdentifier: '// @stacked-mock-register', + modificationTemplate: '''getAndRegister{{serviceName}}();''', + modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', + modificationName: 'Add {{serviceName}} register to test helpers', + ), + ], ), }, 'view': { 'empty': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: kViewEmptyTemplateGenericViewmodelTestPath, - content: kViewEmptyTemplateGenericViewmodelTestContent, + relativeOutputPath: kViewEmptyTemplateGenericViewPath, + content: kViewEmptyTemplateGenericViewContent, fileType: FileType.text), TemplateFile( relativeOutputPath: kViewEmptyTemplateGenericViewmodelPath, content: kViewEmptyTemplateGenericViewmodelContent, fileType: FileType.text), - TemplateFile( - relativeOutputPath: kViewEmptyTemplateGenericViewPath, - content: kViewEmptyTemplateGenericViewContent, - fileType: FileType.text), TemplateFile( relativeOutputPath: kViewEmptyTemplateGenericViewV1Path, content: kViewEmptyTemplateGenericViewV1Content, fileType: FileType.text), + TemplateFile( + relativeOutputPath: kViewEmptyTemplateGenericViewmodelTestPath, + content: kViewEmptyTemplateGenericViewmodelTestContent, + fileType: FileType.text), ], modificationFiles: [ ModificationFile( relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-route', modificationTemplate: '''MaterialRoute(page: {{viewName}}),''', - modificationProblemError: - 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', - modificationName: - 'Add {{viewName}} route where @StackedApp annotation is located', + modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', + modificationName: 'Add {{viewName}} route where @StackedApp annotation is located', ), + ModificationFile( relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''', - modificationProblemError: - 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', - modificationName: - 'Add {{viewName}} route import where @StackedApp annotation is located', + modificationTemplate: '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''', + modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', + modificationName: 'Add {{viewName}} route import where @StackedApp annotation is located', ), - ], + ], ), 'web': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: kViewWebTemplateGenericViewmodelTestPath, - content: kViewWebTemplateGenericViewmodelTestContent, + relativeOutputPath: kViewWebTemplateGenericViewPath, + content: kViewWebTemplateGenericViewContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kViewWebTemplateGenericViewmodelPath, - content: kViewWebTemplateGenericViewmodelContent, + relativeOutputPath: kViewWebTemplateGenericViewDesktopPath, + content: kViewWebTemplateGenericViewDesktopContent, fileType: FileType.text), TemplateFile( relativeOutputPath: kViewWebTemplateGenericViewMobilePath, @@ -386,12 +463,12 @@ Map> kCompiledStackedTemplates = { content: kViewWebTemplateGenericViewTabletContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kViewWebTemplateGenericViewPath, - content: kViewWebTemplateGenericViewContent, + relativeOutputPath: kViewWebTemplateGenericViewmodelPath, + content: kViewWebTemplateGenericViewmodelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kViewWebTemplateGenericViewDesktopPath, - content: kViewWebTemplateGenericViewDesktopContent, + relativeOutputPath: kViewWebTemplateGenericViewmodelTestPath, + content: kViewWebTemplateGenericViewmodelTestContent, fileType: FileType.text), ], modificationFiles: [ @@ -399,143 +476,41 @@ Map> kCompiledStackedTemplates = { relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-route', modificationTemplate: '''CustomRoute(page: {{viewName}}),''', - modificationProblemError: - 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', - modificationName: - 'Add {{viewName}} route where @StackedApp annotation is located', - ), - ModificationFile( - relativeModificationPath: 'lib/app/app.dart', - modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''', - modificationProblemError: - 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', - modificationName: - 'Add {{viewName}} route import where @StackedApp annotation is located', - ), - ], - ), - }, - 'service': { - 'empty': StackedTemplate( - templateFiles: [ - TemplateFile( - relativeOutputPath: kServiceEmptyTemplateGenericServiceTestPath, - content: kServiceEmptyTemplateGenericServiceTestContent, - fileType: FileType.text), - TemplateFile( - relativeOutputPath: kServiceEmptyTemplateGenericServicePath, - content: kServiceEmptyTemplateGenericServiceContent, - fileType: FileType.text), - ], - modificationFiles: [ - ModificationFile( - relativeModificationPath: 'test/helpers/test_helpers.dart', - modificationIdentifier: '// @stacked-mock-create', - modificationTemplate: - '''Mock{{serviceName}} getAndRegister{{serviceName}}() { -_removeRegistrationIfExists<{{serviceName}}>(); -final service = Mock{{serviceName}}(); -{{locatorName}}.registerSingleton<{{serviceName}}>(service); -return service; -}''', - modificationProblemError: - 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', - modificationName: 'Add {{serviceName}} mock to test helpers', - ), - ModificationFile( - relativeModificationPath: 'lib/app/app.dart', - modificationIdentifier: '// @stacked-service', - modificationTemplate: - '''LazySingleton(classType: {{serviceName}}),''', - modificationProblemError: - 'The service registration should be stored in lib/app/app.dart', - modificationName: - 'Add {{serviceName}} dependency to StackedApp annotations file', + modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', + modificationName: 'Add {{viewName}} route where @StackedApp annotation is located', ), + ModificationFile( relativeModificationPath: 'lib/app/app.dart', modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''', - modificationProblemError: - 'The service registration should be stored in lib/app/app.dart', - modificationName: - 'Add {{serviceName}} import to StackedApp annotations file', + modificationTemplate: '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''', + modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/', + modificationName: 'Add {{viewName}} route import where @StackedApp annotation is located', ), - ModificationFile( - relativeModificationPath: 'test/helpers/test_helpers.dart', - modificationIdentifier: '// @stacked-mock-spec', - modificationTemplate: - '''MockSpec<{{serviceName}}>(onMissingStub: OnMissingStub.returnDefault),''', - modificationProblemError: - 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', - modificationName: 'Create {{serviceName}} mock to test helpers', - ), - ModificationFile( - relativeModificationPath: 'test/helpers/test_helpers.dart', - modificationIdentifier: '// @stacked-mock-register', - modificationTemplate: '''getAndRegister{{serviceName}}();''', - modificationProblemError: - 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart', - modificationName: 'Add {{serviceName}} register to test helpers', - ), - ModificationFile( - relativeModificationPath: 'test/helpers/test_helpers.dart', - modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''', - modificationProblemError: - 'It seems your test_helpers.dart file is not in test/helpers/test_helpers.dart. Add a stacked.json file and set the path for \'test_helpers_path\' to the folder we can locate your test_helpers.dart file', - modificationName: 'Add {{serviceName}} import to test helpers', - ), - ], + ], ), }, - 'bottom_sheet': { + 'widget': { 'empty': StackedTemplate( templateFiles: [ TemplateFile( - relativeOutputPath: - kBottomSheetEmptyTemplateGenericSheetModelTestPath, - content: kBottomSheetEmptyTemplateGenericSheetModelTestContent, + relativeOutputPath: kWidgetEmptyTemplateGenericPath, + content: kWidgetEmptyTemplateGenericContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelPath, - content: kBottomSheetEmptyTemplateGenericSheetModelContent, + relativeOutputPath: kWidgetEmptyTemplateGenericModelPath, + content: kWidgetEmptyTemplateGenericModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: - kBottomSheetEmptyTemplateGenericSheetUseModelPath, - content: kBottomSheetEmptyTemplateGenericSheetUseModelContent, + relativeOutputPath: kWidgetEmptyTemplateGenericUseModelPath, + content: kWidgetEmptyTemplateGenericUseModelContent, fileType: FileType.text), TemplateFile( - relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetPath, - content: kBottomSheetEmptyTemplateGenericSheetContent, + relativeOutputPath: kWidgetEmptyTemplateGenericModelTestPath, + content: kWidgetEmptyTemplateGenericModelTestContent, fileType: FileType.text), ], - modificationFiles: [ - ModificationFile( - relativeModificationPath: 'lib/app/app.dart', - modificationIdentifier: '// @stacked-bottom-sheet', - modificationTemplate: - '''StackedBottomsheet(classType: {{sheetName}}),''', - modificationProblemError: - 'The bottom sheet registration should be stored in lib/app/app.dart', - modificationName: - 'Add \'{{sheetName}}\' dependency to StackedApp annotations file', - ), - ModificationFile( - relativeModificationPath: 'lib/app/app.dart', - modificationIdentifier: '// @stacked-import', - modificationTemplate: - '''import \'package:{{packageName}}/{{{bottomSheetsPath}}}/{{sheetFolderName}}/{{sheetFilename}}\';''', - modificationProblemError: - 'The bottom sheet registration should be stored in lib/app/app.dart', - modificationName: 'Add import for \'{{sheetName}}\' class', - ), - ], + modificationFiles: [], ), }, }; diff --git a/lib/src/templates/compiled_templates.dart b/lib/src/templates/compiled_templates.dart index b77ae21..99a3ee8 100644 --- a/lib/src/templates/compiled_templates.dart +++ b/lib/src/templates/compiled_templates.dart @@ -1,1202 +1,1292 @@ /// NOTE: This is generated code from the compileTemplates command. Do not modify by hand /// This file should be checked into source control. -// -------- StackedJsonStk Template Data ---------- -const String kAppWebTemplateStackedJsonStkPath = 'stacked.json.stk'; +// -------- SettingsJsonStk Template Data ---------- -const String kAppWebTemplateStackedJsonStkContent = ''' +const String kAppMobileTemplateSettingsJsonStkPath = + '.vscode/settings.json.stk'; + +const String kAppMobileTemplateSettingsJsonStkContent = ''' { - "bottom_sheets_path": "ui/bottom_sheets", - "dialogs_path": "ui/dialogs", - "line_length": 80, - "locator_name": "locator", - "prefer_web": true, - "register_mocks_function": "registerServices", - "services_path": "services", - "stacked_app_file_path": "app/app.dart", - "test_helpers_file_path": "helpers/test_helpers.dart", - "test_services_path": "services", - "test_views_path": "viewmodels", - "test_widgets_path": "widget_models", - "v1": false, - "views_path": "ui/views", - "widgets_path": "ui/widgets/common" + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "*.dart": "\${capture}.mobile.dart, \${capture}.tablet.dart, \${capture}.desktop.dart, \${capture}.form.dart, \${capture}.g.dart, \${capture}.freezed.dart, \${capture}.logger.dart, \${capture}.locator.dart, \${capture}.router.dart, \${capture}.dialogs.dart, \${capture}.bottomsheets.dart" + } } + '''; // -------------------------------------------------- -// -------- UnknownViewmodelTest Template Data ---------- -const String kAppWebTemplateUnknownViewmodelTestPath = - 'test/viewmodels/unknown_viewmodel_test.dart.stk'; +// -------- App Template Data ---------- -const String kAppWebTemplateUnknownViewmodelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kAppMobileTemplateAppPath = + 'lib/app/app.dart.stk'; -import '../helpers/test_helpers.dart'; +const String kAppMobileTemplateAppContent = ''' +import 'package:{{packageName}}/{{{bottomSheetsPath}}}/notice/notice_sheet.dart'; +import 'package:{{packageName}}/{{{dialogsPath}}}/info_alert/info_alert_dialog.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_view.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/startup/startup_view.dart'; +import 'package:stacked/stacked_annotations.dart'; +import 'package:stacked_services/stacked_services.dart'; +// @stacked-import + +@StackedApp( + routes: [ + MaterialRoute(page: HomeView), + MaterialRoute(page: StartupView), + // @stacked-route + ], + dependencies: [ + LazySingleton(classType: BottomSheetService), + LazySingleton(classType: DialogService), + LazySingleton(classType: NavigationService), + // @stacked-service + ], + bottomsheets: [ + StackedBottomsheet(classType: NoticeSheet), + // @stacked-bottom-sheet + ], + dialogs: [ + StackedDialog(classType: InfoAlertDialog), + // @stacked-dialog + ], +) +class App {} -void main() { - group('UnknownViewModel Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); -} '''; // -------------------------------------------------- -// -------- HomeViewmodelTest Template Data ---------- -const String kAppWebTemplateHomeViewmodelTestPath = - 'test/viewmodels/home_viewmodel_test.dart.stk'; +// -------- Main Template Data ---------- -const String kAppWebTemplateHomeViewmodelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; +const String kAppMobileTemplateMainPath = + 'lib/main.dart.stk'; + +const String kAppMobileTemplateMainContent = ''' +import 'package:flutter/material.dart'; import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/ui/common/app_strings.dart'; -import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_viewmodel.dart'; +import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; +import 'package:stacked_services/stacked_services.dart'; -import '{{{viewTestHelpersImport}}}'; +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await setupLocator(); + setupDialogUi(); + setupBottomSheetUi(); + runApp(const MainApp()); +} -void main() { - HomeViewModel getModel() => HomeViewModel(); +class MainApp extends StatelessWidget { + const MainApp({super.key}); - group('HomeViewmodelTest -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); + @override + Widget build(BuildContext context) { + return MaterialApp( + initialRoute: Routes.startupView, + onGenerateRoute: StackedRouter().onGenerateRoute, + navigatorKey: StackedService.navigatorKey, + navigatorObservers: [ + StackedService.routeObserver, + ], + ); + } +} - group('incrementCounter -', () { - test('When called once should return Counter is: 1', () { - final model = getModel(); - model.incrementCounter(); - expect(model.counterLabel, 'Counter is: 1'); - }); - }); +'''; - group('showBottomSheet -', () { - test('When called, should show custom bottom sheet using notice variant', - () { - final bottomSheetService = getAndRegisterBottomSheetService(); +// -------------------------------------------------- - final model = getModel(); - model.showBottomSheet(); - verify(bottomSheetService.showCustomSheet( - variant: BottomSheetType.notice, - title: ksHomeBottomSheetTitle, - description: ksHomeBottomSheetDescription, - )); - }); - }); - }); + +// -------- NoticeSheet Template Data ---------- + +const String kAppMobileTemplateNoticeSheetPath = + 'lib/ui/bottom_sheets/notice/notice_sheet.dart.stk'; + +const String kAppMobileTemplateNoticeSheetContent = ''' +import 'package:flutter/material.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; + +import 'notice_sheet_model.dart'; + +class NoticeSheet extends StackedView { + final Function(SheetResponse)? completer; + final SheetRequest request; + const NoticeSheet({ + Key? key, + required this.completer, + required this.request, + }) : super(key: key); + + @override + Widget builder( + BuildContext context, + NoticeSheetModel viewModel, + Widget? child, + ) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + request.title!, + style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), + ), + verticalSpaceTiny, + Text( + request.description!, + style: const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + verticalSpaceLarge, + ], + ), + ); + } + + @override + NoticeSheetModel viewModelBuilder(BuildContext context) => + NoticeSheetModel(); } '''; // -------------------------------------------------- -// -------- NoticeSheetModelTest Template Data ---------- -const String kAppWebTemplateNoticeSheetModelTestPath = - 'test/viewmodels/notice_sheet_model_test.dart.stk'; +// -------- NoticeSheetModel Template Data ---------- -const String kAppWebTemplateNoticeSheetModelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kAppMobileTemplateNoticeSheetModelPath = + 'lib/ui/bottom_sheets/notice/notice_sheet_model.dart.stk'; -import '{{{viewTestHelpersImport}}}'; +const String kAppMobileTemplateNoticeSheetModelContent = ''' +import 'package:stacked/stacked.dart'; -void main() { - group('InfoAlertDialogModel Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); -} +class NoticeSheetModel extends BaseViewModel {} '''; // -------------------------------------------------- -// -------- InfoAlertDialogModelTest Template Data ---------- -const String kAppWebTemplateInfoAlertDialogModelTestPath = - 'test/viewmodels/info_alert_dialog_model_test.dart.stk'; +// -------- AppColors Template Data ---------- -const String kAppWebTemplateInfoAlertDialogModelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kAppMobileTemplateAppColorsPath = + 'lib/ui/common/app_colors.dart.stk'; -import '{{{viewTestHelpersImport}}}'; +const String kAppMobileTemplateAppColorsContent = ''' +import 'package:flutter/material.dart'; -void main() { - group('InfoAlertDialogModel Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); -} +const Color kcPrimaryColor = Color(0xFF9600FF); +const Color kcPrimaryColorDark = Color(0xFF300151); +const Color kcDarkGreyColor = Color(0xFF1A1B1E); +const Color kcMediumGrey = Color(0xFF474A54); +const Color kcLightGrey = Color.fromARGB(255, 187, 187, 187); +const Color kcVeryLightGrey = Color(0xFFE3E3E3); +const Color kcBackgroundColor = kcDarkGreyColor; '''; // -------------------------------------------------- -// -------- TestHelpers Template Data ---------- -const String kAppWebTemplateTestHelpersPath = - 'test/helpers/test_helpers.dart.stk'; +// -------- AppStrings Template Data ---------- -const String kAppWebTemplateTestHelpersContent = ''' -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:stacked_services/stacked_services.dart'; -// @stacked-import +const String kAppMobileTemplateAppStringsPath = + 'lib/ui/common/app_strings.dart.stk'; -import 'test_helpers.mocks.dart'; - -@GenerateMocks([], customMocks: [ - MockSpec(onMissingStub: OnMissingStub.returnDefault), - MockSpec(onMissingStub: OnMissingStub.returnDefault), - MockSpec(onMissingStub: OnMissingStub.returnDefault), - // @stacked-mock-spec -]) -void registerServices() { - getAndRegisterRouterService(); - getAndRegisterBottomSheetService(); - getAndRegisterDialogService(); - // @stacked-mock-register -} - -MockRouterService getAndRegisterRouterService() { - _removeRegistrationIfExists(); - final service = MockRouterService(); - locator.registerSingleton(service); - return service; -} - -MockBottomSheetService getAndRegisterBottomSheetService({ - SheetResponse? showCustomSheetResponse, -}) { - _removeRegistrationIfExists(); - final service = MockBottomSheetService(); - - when(service.showCustomSheet( - enableDrag: anyNamed('enableDrag'), - enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), - exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), - ignoreSafeArea: anyNamed('ignoreSafeArea'), - isScrollControlled: anyNamed('isScrollControlled'), - barrierDismissible: anyNamed('barrierDismissible'), - additionalButtonTitle: anyNamed('additionalButtonTitle'), - variant: anyNamed('variant'), - title: anyNamed('title'), - hasImage: anyNamed('hasImage'), - imageUrl: anyNamed('imageUrl'), - showIconInMainButton: anyNamed('showIconInMainButton'), - mainButtonTitle: anyNamed('mainButtonTitle'), - showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), - secondaryButtonTitle: anyNamed('secondaryButtonTitle'), - showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), - takesInput: anyNamed('takesInput'), - barrierColor: anyNamed('barrierColor'), - barrierLabel: anyNamed('barrierLabel'), - customData: anyNamed('customData'), - data: anyNamed('data'), - description: anyNamed('description'), - )).thenAnswer((realInvocation) => - Future.value(showCustomSheetResponse ?? SheetResponse())); +const String kAppMobileTemplateAppStringsContent = ''' +const String ksHomeBottomSheetTitle = 'Build Great Apps!'; +const String ksHomeBottomSheetDescription = + 'Stacked is built to help you build better apps. Give us a chance and we\\'ll prove it to you. Check out stacked.filledstacks.com to learn more'; - locator.registerSingleton(service); - return service; -} +'''; -MockDialogService getAndRegisterDialogService() { - _removeRegistrationIfExists(); - final service = MockDialogService(); - locator.registerSingleton(service); - return service; -} +// -------------------------------------------------- -// @stacked-mock-create -void _removeRegistrationIfExists() { - if (locator.isRegistered()) { - locator.unregister(); - } -} +// -------- UiHelpers Template Data ---------- -'''; +const String kAppMobileTemplateUiHelpersPath = + 'lib/ui/common/ui_helpers.dart.stk'; -// -------------------------------------------------- +const String kAppMobileTemplateUiHelpersContent = ''' +import 'dart:math'; -// -------- BuildYamlStk Template Data ---------- +import 'package:flutter/material.dart'; -const String kAppWebTemplateBuildYamlStkPath = 'build.yaml.stk'; +const double _tinySize = 5.0; +const double _smallSize = 10.0; +const double _mediumSize = 25.0; +const double _largeSize = 50.0; +const double _massiveSize = 120.0; -const String kAppWebTemplateBuildYamlStkContent = ''' -targets: - \$default: - builders: - stacked_generator|stackedRouterGenerator: - options: - navigator2: true -'''; +const Widget horizontalSpaceTiny = SizedBox(width: _tinySize); +const Widget horizontalSpaceSmall = SizedBox(width: _smallSize); +const Widget horizontalSpaceMedium = SizedBox(width: _mediumSize); +const Widget horizontalSpaceLarge = SizedBox(width: _largeSize); -// -------------------------------------------------- +const Widget verticalSpaceTiny = SizedBox(height: _tinySize); +const Widget verticalSpaceSmall = SizedBox(height: _smallSize); +const Widget verticalSpaceMedium = SizedBox(height: _mediumSize); +const Widget verticalSpaceLarge = SizedBox(height: _largeSize); +const Widget verticalSpaceMassive = SizedBox(height: _massiveSize); -// -------- MainIconPngStk Template Data ---------- +Widget spacedDivider = const Column( + children: [ + verticalSpaceMedium, + Divider(color: Colors.blueGrey, height: 5.0), + verticalSpaceMedium, + ], +); -const String kAppWebTemplateMainIconPngStkPath = 'web/main-icon.png.stk'; +Widget verticalSpace(double height) => SizedBox(height: height); -const String kAppWebTemplateMainIconPngStkContent = ''' -iVBORw0KGgoAAAANSUhEUgAAALMAAACzCAYAAADCFC3zAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAN5SURBVHgB7daLjVNBDEDRF0QjVEIrdMLSAS3RyZZAByGWdqUQ5Z/5eGbOkSw3cC152wAAAAAAAAAAAAAAAACAjHZbYfuDDW77tdvt3raCvmzQXvGQg5hprUrIQcy0VC3kIGZaqRpyEDMtVA85iJnamoQcxExNzUIOYqaWpiEHMVND85CDmCmtS8hBzJTULeQgZkrpGnIQMyV0DzmImVelCDmImVekCTmImWelCjmImWekCzmImUelDDmImUekDTmImXulDjmImXukDzmImVuGCDmImWuGCTmImUuGCjmImXOGCzmImVNDhhzEzLFhQw5i5tPQIQcxE4YPOYiZKUIOYl7bNCEHMa9rqpCDmNc0XchBzOuZMuQg5rVMG3IQ8zqmDjmIeQ3ThxzEPL8lQg5intsyIQcxz2upkIOY57RcyEHM81ky5CDmuSwbchDzPJYOOYh5DsuHHMQ8PiF/EPPYhHxEzOMS8gkxj0nIZ4h5PEK+QMxjEfIVYh6HkG8Q8xiEfAcx5yfkO4k5NyE/QMx5CflBYs5JyE8Qcz5CfpKYcxHyC8Sch5BfJOYchFyAmPsTciFi7kvIBYm5HyEXJuY+hFyBmNsTciVibkvIFYm5HSFXttsK2+/3bxunvh/mz8axv4fj/r0VVDxm/nc47p+H9bZx6v0Q87etIG9GRUJuS8yVCLk9MVcg5D7EXJiQ+xFzQULuS8yFCLk/MRcg5BzE/CIh5yHmFwg5FzE/Scj5iPkJQs5JzA8Scl5ifoCQcxPznYScn5jvIOQxiPkGIY9DzFcIeSxivkDI4xHzGUIek5hPCHlcYj4i5LGJ+YOQxyfmTcizWD5mIc9j6ZiFPJdlYxbyfJaMWchzWi5mIc9rqZiFPLdlYhby/JaIWchrmD5mIa9j6piFvJZpYxbyeqaMWchrmi5mIa9rqpiFvLZpYhYyU8QsZMLwMQuZT0PHLGSODRuzkDk1ZMxC5pzhYhYylwwVs5C5ZpiYhcwtQ8QsZO6RPmYhc6/UMQuZR6SNWcg8KmXMQuYZ6WIWMs9KFbOQeUWamIXMq1LELGRK6B6zkCmla8xCpqRuMQuZ0rrELGRqaB6zkKmlacxCpqZmMQuZ2prELGRaqB6zkGmlasxCpqVqMQuZ1qrELGR6+LoVdgj5x2HFvG9w2fsGAAAAAAAAAAAAAAAAACzhH8sFZqawpyetAAAAAElFTkSuQmCC -'''; +double screenWidth(BuildContext context) => MediaQuery.of(context).size.width; +double screenHeight(BuildContext context) => MediaQuery.of(context).size.height; -// -------------------------------------------------- +double screenHeightFraction(BuildContext context, + {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => + min((screenHeight(context) - offsetBy) / dividedBy, max); -// -------- IndexHtmlStk Template Data ---------- +double screenWidthFraction(BuildContext context, + {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => + min((screenWidth(context) - offsetBy) / dividedBy, max); -const String kAppWebTemplateIndexHtmlStkPath = 'web/index.html.stk'; +double halfScreenWidth(BuildContext context) => + screenWidthFraction(context, dividedBy: 2); -const String kAppWebTemplateIndexHtmlStkContent = ''' - - +double thirdScreenWidth(BuildContext context) => + screenWidthFraction(context, dividedBy: 3); - - - +double getResponsiveLargeFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 21, max: 31); - - - +double getResponsiveExtraLargeFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 25); - - - - - +double getResponsiveMassiveFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 30); - - +double getResponsiveFontSize(BuildContext context, + {double? fontSize, double? max}) { + max ??= 100; - - - + var responsiveSize = min( + screenWidthFraction(context, dividedBy: 10) * ((fontSize ?? 100) / 100), + max); + return responsiveSize; +} - My Stacked Application - - - - - - +'''; - - - -
-
- - - - -
- -
- - - -'''; - -// -------------------------------------------------- - -// -------- FaviconPngStk Template Data ---------- - -const String kAppWebTemplateFaviconPngStkPath = 'web/favicon.png.stk'; - -const String kAppWebTemplateFaviconPngStkContent = ''' -iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgBpVTNasJAEN7dxLQl+FNEFBRR8VCQgo+gryCkh9499CnUg/gMvo3eFWw9eBLS4sWT2oOHRLOdWWLYxkRT+8GS3cnkm28mM0tIMOhpwzmn7plKdurawz9EdLtdNhqNWKvVekyn0ynLsghjTPg4jsNt26a6rnO09/v9r2Qy6UwmkwOlwoX7yZVqtWqA07v78uqKx+NmsVhsw179Jc4wDKVcLrejEvkXCHlBDlmdlkgkPm8lhKw+arWahipRKikUCspqtSqe2FOpFKnX6+QSZrMZ2W63Yr/b7Z6htshl45kOh8MnOWKj0eCXAD8vSKmOf54ho6qqnEREr9fDbjizZzIZikBCut/v6X/IENBeQikSck3TrnFdJJMghJ3V0L86nc5ZHbHOsk82m9WFUCTEzg8DkEVRhpOE6jhD57CUo5IR4tVQpMyCUg5KM0LKorH5crn8lqNhY4/HY9JsNkMVYWPLWK/XXutRmJQHGPQ5uXH0cGxLpdK9SNeVe8jlcgNyI2CWB6ZpHjwDjgxGyOfzb3+5JIBoXqlUXuG2uSOnHpQCUSi0slgs7qCNVAwCEHXZbDZYV+8sZpYxJxaLHaFc1nQ6PYLZCcsAy6BIT0U6eza83X2CBH4AHNJFlWlQookAAAAASUVORK5CYII= -'''; - -// -------------------------------------------------- - -// -------- READMEMdStk Template Data ---------- - -const String kAppWebTemplateREADMEMdStkPath = 'README.md.stk'; - -const String kAppWebTemplateREADMEMdStkContent = ''' -# {{packageName}} - -{{packageDescription}} -'''; - -// -------------------------------------------------- - -// -------- Main Template Data ---------- - -const String kAppWebTemplateMainPath = 'lib/main.dart.stk'; - -const String kAppWebTemplateMainContent = ''' -import 'package:flutter/material.dart'; -import 'package:responsive_builder/responsive_builder.dart'; -import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; -import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; -import 'package:url_strategy/url_strategy.dart'; -import 'package:flutter_animate/flutter_animate.dart'; - -Future main() async { - WidgetsFlutterBinding.ensureInitialized(); - setPathUrlStrategy(); - await setupLocator(stackedRouter: stackedRouter); - setupDialogUi(); - setupBottomSheetUi(); - runApp(const MainApp()); -} - -class MainApp extends StatelessWidget { - const MainApp({super.key}); + const InfoAlertDialog({ + Key? key, + required this.request, + required this.completer, + }) : super(key: key); @override - Widget build(BuildContext context) { - return ResponsiveApp( - builder: (_) => MaterialApp.router( - routerDelegate: stackedRouter.delegate(), - routeInformationParser: stackedRouter.defaultRouteParser(), + Widget builder( + BuildContext context, + InfoAlertDialogModel viewModel, + Widget? child, + ) { + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + request.title!, + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.w900), + ), + verticalSpaceTiny, + Text( + request.description!, + style: + const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + ], + ), + ), + Container( + width: _graphicSize, + height: _graphicSize, + decoration: const BoxDecoration( + color: Color(0xffF6E7B0), + borderRadius: BorderRadius.all( + Radius.circular(_graphicSize / 2), + ), + ), + alignment: Alignment.center, + child: const Text( + '⭐️', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + verticalSpaceMedium, + GestureDetector( + onTap: () => completer(DialogResponse( + confirmed: true, + )), + child: Container( + height: 50, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(10), + ), + child: const Text( + 'Got it', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + ) + ], + ), ), - ).animate().fadeIn( - delay: const Duration(milliseconds: 50), - duration: const Duration(milliseconds: 400), - ); + ); } + + @override + InfoAlertDialogModel viewModelBuilder(BuildContext context) => + InfoAlertDialogModel(); } '''; // -------------------------------------------------- -// -------- AppConstants Template Data ---------- -const String kAppWebTemplateAppConstantsPath = - 'lib/ui/common/app_constants.dart.stk'; +// -------- InfoAlertDialogModel Template Data ---------- -const String kAppWebTemplateAppConstantsContent = ''' -/// The max width the content can ever take up on the screen -const double kdDesktopMaxContentWidth = 1150; +const String kAppMobileTemplateInfoAlertDialogModelPath = + 'lib/ui/dialogs/info_alert/info_alert_dialog_model.dart.stk'; -// The max height the homeview will take up -const double kdDesktopMaxContentHeight = 750; +const String kAppMobileTemplateInfoAlertDialogModelContent = ''' +import 'package:stacked/stacked.dart'; + +class InfoAlertDialogModel extends BaseViewModel {} '''; // -------------------------------------------------- -// -------- UiHelpers Template Data ---------- -const String kAppWebTemplateUiHelpersPath = 'lib/ui/common/ui_helpers.dart.stk'; +// -------- HomeView Template Data ---------- -const String kAppWebTemplateUiHelpersContent = ''' -import 'dart:math'; +const String kAppMobileTemplateHomeViewPath = + 'lib/ui/views/home/home_view.dart.stk'; +const String kAppMobileTemplateHomeViewContent = ''' import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -const double _tinySize = 5.0; -const double _smallSize = 10.0; -const double _mediumSize = 25.0; -const double _largeSize = 50.0; -const double _massiveSize = 120.0; - -const Widget horizontalSpaceTiny = SizedBox(width: _tinySize); -const Widget horizontalSpaceSmall = SizedBox(width: _smallSize); -const Widget horizontalSpaceMedium = SizedBox(width: _mediumSize); -const Widget horizontalSpaceLarge = SizedBox(width: _largeSize); +import 'home_viewmodel.dart'; -const Widget verticalSpaceTiny = SizedBox(height: _tinySize); -const Widget verticalSpaceSmall = SizedBox(height: _smallSize); -const Widget verticalSpaceMedium = SizedBox(height: _mediumSize); -const Widget verticalSpaceLarge = SizedBox(height: _largeSize); -const Widget verticalSpaceMassive = SizedBox(height: _massiveSize); +class HomeView extends StackedView { + const HomeView({Key? key}) : super(key: key); -Widget spacedDivider = const Column( - children: [ - verticalSpaceMedium, - Divider(color: Colors.blueGrey, height: 5.0), - verticalSpaceMedium, - ], -); - -Widget verticalSpace(double height) => SizedBox(height: height); - -double screenWidth(BuildContext context) => MediaQuery.of(context).size.width; -double screenHeight(BuildContext context) => MediaQuery.of(context).size.height; - -double screenHeightFraction(BuildContext context, - {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => - min((screenHeight(context) - offsetBy) / dividedBy, max); - -double screenWidthFraction(BuildContext context, - {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => - min((screenWidth(context) - offsetBy) / dividedBy, max); - -double halfScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 2); - -double thirdScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 3); - -double quarterScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 4); - -double getResponsiveHorizontalSpaceMedium(BuildContext context) => - screenWidthFraction(context, dividedBy: 10); -double getResponsiveSmallFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 14, max: 15); - -double getResponsiveMediumFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 16, max: 17); - -double getResponsiveLargeFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 21, max: 31); - -double getResponsiveExtraLargeFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 25); - -double getResponsiveMassiveFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 30); - -double getResponsiveFontSize(BuildContext context, - {double? fontSize, double? max}) { - max ??= 100; + @override + Widget builder( + BuildContext context, + HomeViewModel viewModel, + Widget? child, + ) { + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + verticalSpaceLarge, + Column( + children: [ + const Text( + 'Hello, STACKED!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + verticalSpaceMedium, + MaterialButton( + color: Colors.black, + onPressed: viewModel.incrementCounter, + child: Text( + viewModel.counterLabel, + style: const TextStyle(color: Colors.white), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showDialog, + child: const Text( + 'Show Dialog', + style: TextStyle( + color: Colors.white, + ), + ), + ), + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showBottomSheet, + child: const Text( + 'Show Bottom Sheet', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ], + ) + ], + ), + ), + ), + ), + ); + } - var responsiveSize = min( - screenWidthFraction(context, dividedBy: 10) * ((fontSize ?? 100) / 100), - max); - - return responsiveSize; + @override + HomeViewModel viewModelBuilder( + BuildContext context, + ) => HomeViewModel(); } '''; // -------------------------------------------------- -// -------- AppStrings Template Data ---------- - -const String kAppWebTemplateAppStringsPath = - 'lib/ui/common/app_strings.dart.stk'; - -const String kAppWebTemplateAppStringsContent = ''' -const String ksHomeBottomSheetTitle = 'Build Great Apps!'; -const String ksHomeBottomSheetDescription = - 'Stacked is built to help you build better apps. Give us a chance and we\\'ll prove it to you. Check out stacked.filledstacks.com to learn more'; - -'''; - -// -------------------------------------------------- - -// -------- AppColors Template Data ---------- -const String kAppWebTemplateAppColorsPath = 'lib/ui/common/app_colors.dart.stk'; +// -------- HomeViewmodel Template Data ---------- -const String kAppWebTemplateAppColorsContent = ''' -import 'package:flutter/material.dart'; +const String kAppMobileTemplateHomeViewmodelPath = + 'lib/ui/views/home/home_viewmodel.dart.stk'; -const Color kcPrimaryColor = Color(0xFF9600FF); -const Color kcPrimaryColorDark = Color(0xFF300151); -const Color kcBlack = Color(0xFF000000); -const Color kcDarkGreyColor = Color(0xFF1A1B1E); -const Color kcMediumGrey = Color(0xFF474A54); -const Color kcLightGrey = Color.fromARGB(255, 187, 187, 187); -const Color kcVeryLightGrey = Color(0xFFE3E3E3); -const Color kcWhite = Color(0xFFFFFFFF); -const Color kcBackgroundColor = kcDarkGreyColor; +const String kAppMobileTemplateHomeViewmodelContent = ''' +import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/ui/common/app_strings.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; -'''; +class HomeViewModel extends BaseViewModel { + final _dialogService = locator(); + final _bottomSheetService = locator(); -// -------------------------------------------------- + String get counterLabel => 'Counter is: \$_counter'; -// -------- NoticeSheetModel Template Data ---------- + int _counter = 0; -const String kAppWebTemplateNoticeSheetModelPath = - 'lib/ui/bottom_sheets/notice/notice_sheet_model.dart.stk'; + void incrementCounter() { + _counter++; + rebuildUi(); + } -const String kAppWebTemplateNoticeSheetModelContent = ''' -import 'package:stacked/stacked.dart'; + void showDialog() { + _dialogService.showCustomDialog( + variant: DialogType.infoAlert, + title: 'Stacked Rocks!', + description: 'Give stacked \$_counter stars on Github', + ); + } -class NoticeSheetModel extends BaseViewModel {} + void showBottomSheet() { + _bottomSheetService.showCustomSheet( + variant: BottomSheetType.notice, + title: ksHomeBottomSheetTitle, + description: ksHomeBottomSheetDescription, + ); + } +} '''; // -------------------------------------------------- -// -------- NoticeSheet Template Data ---------- -const String kAppWebTemplateNoticeSheetPath = - 'lib/ui/bottom_sheets/notice/notice_sheet.dart.stk'; +// -------- HomeViewV1 Template Data ---------- -const String kAppWebTemplateNoticeSheetContent = ''' +const String kAppMobileTemplateHomeViewV1Path = + 'lib/ui/views/home/home_view_v1.dart.stk'; + +const String kAppMobileTemplateHomeViewV1Content = ''' import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; import 'package:{{packageName}}/ui/common/app_colors.dart'; import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; - -import 'notice_sheet_model.dart'; -class NoticeSheet extends StackedView { - final Function(SheetResponse)? completer; - final SheetRequest request; - const NoticeSheet({ - Key? key, - required this.completer, - required this.request, - }) : super(key: key); +import 'home_viewmodel.dart'; - @override - Widget builder( - BuildContext context, - NoticeSheetModel viewModel, - Widget? child, - ) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - request.title!, - style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), - ), - verticalSpaceTiny, - Text( - request.description!, - style: const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - verticalSpaceLarge, - ], - ), - ); - } +class HomeView extends StatelessWidget { + const HomeView({Key? key}) : super(key: key); @override - NoticeSheetModel viewModelBuilder(BuildContext context) => - NoticeSheetModel(); + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + viewModelBuilder: () => HomeViewModel(), + builder: (context, model, child) => Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + verticalSpaceLarge, + Column( + children: [ + const Text( + 'Hello, STACKED!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + verticalSpaceMedium, + MaterialButton( + color: Colors.black, + onPressed: model.incrementCounter, + child: Text( + model.counterLabel, + style: const TextStyle(color: Colors.white), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MaterialButton( + color: kcDarkGreyColor, + child: const Text( + 'Show Dialog', + style: TextStyle( + color: Colors.white, + ), + ), + onPressed: model.showDialog, + ), + MaterialButton( + color: kcDarkGreyColor, + child: const Text( + 'Show Bottom Sheet', + style: TextStyle( + color: Colors.white, + ), + ), + onPressed: model.showBottomSheet, + ), + ], + ) + ], + ), + ), + ), + ), + ), + ); + } } - '''; // -------------------------------------------------- -// -------- InfoAlertDialogModel Template Data ---------- - -const String kAppWebTemplateInfoAlertDialogModelPath = - 'lib/ui/dialogs/info_alert/info_alert_dialog_model.dart.stk'; - -const String kAppWebTemplateInfoAlertDialogModelContent = ''' -import 'package:stacked/stacked.dart'; - -class InfoAlertDialogModel extends BaseViewModel {} - -'''; -// -------------------------------------------------- - -// -------- InfoAlertDialog Template Data ---------- +// -------- StartupView Template Data ---------- -const String kAppWebTemplateInfoAlertDialogPath = - 'lib/ui/dialogs/info_alert/info_alert_dialog.dart.stk'; +const String kAppMobileTemplateStartupViewPath = + 'lib/ui/views/startup/startup_view.dart.stk'; -const String kAppWebTemplateInfoAlertDialogContent = ''' +const String kAppMobileTemplateStartupViewContent = ''' import 'package:flutter/material.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/scheduler.dart'; import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; - -import 'info_alert_dialog_model.dart'; - -const double _graphicSize = 60; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -class InfoAlertDialog extends StackedView { - final DialogRequest request; - final Function(DialogResponse) completer; +import 'startup_viewmodel.dart'; - const InfoAlertDialog({ - Key? key, - required this.request, - required this.completer, - }) : super(key: key); +class StartupView extends StackedView { + const StartupView({Key? key}) : super(key: key); @override Widget builder( BuildContext context, - InfoAlertDialogModel viewModel, + StartupViewModel viewModel, Widget? child, ) { - return Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - backgroundColor: Colors.white, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), + return const Scaffold( + body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ + Text( + 'STACKED', + style: TextStyle(fontSize: 40, fontWeight: FontWeight.w900), + ), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - request.title!, - style: const TextStyle( - fontSize: 16, fontWeight: FontWeight.w900), - ), - verticalSpaceTiny, - Text( - request.description!, - style: - const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - ], - ), - ), - Container( - width: _graphicSize, - height: _graphicSize, - decoration: const BoxDecoration( - color: Color(0xffF6E7B0), - borderRadius: BorderRadius.all( - Radius.circular(_graphicSize / 2), - ), - ), - alignment: Alignment.center, - child: const Text( - '⭐️', - style: TextStyle(fontSize: 30), + Text('Loading ...', style: TextStyle(fontSize: 16)), + horizontalSpaceSmall, + SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + color: Colors.black, + strokeWidth: 6, ), ) ], ), - verticalSpaceMedium, - GestureDetector( - onTap: () => completer(DialogResponse( - confirmed: true, - )), - child: Container( - height: 50, - width: double.infinity, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.circular(10), + ], + ), + ), + ); + } + + @override + StartupViewModel viewModelBuilder( + BuildContext context, + ) => StartupViewModel(); + + @override + void onViewModelReady(StartupViewModel viewModel) => SchedulerBinding.instance + .addPostFrameCallback((timeStamp) => viewModel.runStartupLogic()); +} + +'''; + +// -------------------------------------------------- + + +// -------- StartupViewmodel Template Data ---------- + +const String kAppMobileTemplateStartupViewmodelPath = + 'lib/ui/views/startup/startup_viewmodel.dart.stk'; + +const String kAppMobileTemplateStartupViewmodelContent = ''' +import 'package:stacked/stacked.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; +import 'package:stacked_services/stacked_services.dart'; + +class StartupViewModel extends BaseViewModel { + final _navigationService = locator(); + + // Place anything here that needs to happen before we get into the application + Future runStartupLogic() async { + await Future.delayed(const Duration(seconds: 3)); + + // This is where you can make decisions on where your app should navigate when + // you have custom startup logic + + _navigationService.replaceWithHomeView(); + } +} + +'''; + +// -------------------------------------------------- + + +// -------- StartupViewV1 Template Data ---------- + +const String kAppMobileTemplateStartupViewV1Path = + 'lib/ui/views/startup/startup_view_v1.dart.stk'; + +const String kAppMobileTemplateStartupViewV1Content = ''' +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:stacked/stacked.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; + +import 'startup_viewmodel.dart'; + +class StartupView extends StatelessWidget { + const StartupView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + builder: (context, model, child) => Scaffold( + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'STACKED', + style: TextStyle( + fontSize: 40, + fontWeight: FontWeight.w900, ), - child: const Text( - 'Got it', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 16, + ), + Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text( + 'Loading ...', + style: TextStyle( + fontSize: 16, + ), ), - ), + horizontalSpaceSmall, + SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + color: Colors.black, + strokeWidth: 6, + ), + ) + ], ), - ) - ], + ], + ), ), ), + onModelReady: (model) => SchedulerBinding.instance + .addPostFrameCallback((timeStamp) => model.runStartupLogic()), + viewModelBuilder: () => StartupViewModel(), ); } +} +'''; - @override - InfoAlertDialogModel viewModelBuilder(BuildContext context) => - InfoAlertDialogModel(); +// -------------------------------------------------- + + +// -------- PubspecYamlStk Template Data ---------- + +const String kAppMobileTemplatePubspecYamlStkPath = + 'pubspec.yaml.stk'; + +const String kAppMobileTemplatePubspecYamlStkContent = ''' +name: {{packageName}} +description: {{packageDescription}} +publish_to: 'none' +version: 0.1.0 + +environment: + sdk: '>=3.0.3 <4.0.0' + +dependencies: + flutter: + sdk: flutter + stacked: ^3.4.0 + stacked_services: ^1.1.0 + +dev_dependencies: + build_runner: ^2.4.5 + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + mockito: ^5.4.1 + stacked_generator: ^1.3.3 + +flutter: + uses-material-design: true + +'''; + +// -------------------------------------------------- + + +// -------- READMEMdStk Template Data ---------- + +const String kAppMobileTemplateREADMEMdStkPath = + 'README.md.stk'; + +const String kAppMobileTemplateREADMEMdStkContent = ''' +# {{packageName}} + +{{packageDescription}} +'''; + +// -------------------------------------------------- + + +// -------- StackedJsonStk Template Data ---------- + +const String kAppMobileTemplateStackedJsonStkPath = + 'stacked.json.stk'; + +const String kAppMobileTemplateStackedJsonStkContent = ''' +{ + "bottom_sheets_path": "ui/bottom_sheets", + "dialogs_path": "ui/dialogs", + "line_length": 80, + "locator_name": "locator", + "prefer_web": false, + "register_mocks_function": "registerServices", + "services_path": "services", + "stacked_app_file_path": "app/app.dart", + "test_helpers_file_path": "helpers/test_helpers.dart", + "test_services_path": "services", + "test_views_path": "viewmodels", + "test_widgets_path": "widget_models", + "v1": false, + "views_path": "ui/views", + "widgets_path": "ui/widgets/common" +} +'''; + +// -------------------------------------------------- + + +// -------- TestHelpers Template Data ---------- + +const String kAppMobileTemplateTestHelpersPath = + 'test/helpers/test_helpers.dart.stk'; + +const String kAppMobileTemplateTestHelpersContent = ''' +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:stacked_services/stacked_services.dart'; +// @stacked-import + +import 'test_helpers.mocks.dart'; + +@GenerateMocks([], customMocks: [ + MockSpec(onMissingStub: OnMissingStub.returnDefault), + MockSpec(onMissingStub: OnMissingStub.returnDefault), + MockSpec(onMissingStub: OnMissingStub.returnDefault), + // @stacked-mock-spec +]) +void registerServices() { + getAndRegisterNavigationService(); + getAndRegisterBottomSheetService(); + getAndRegisterDialogService(); + // @stacked-mock-register +} + +MockNavigationService getAndRegisterNavigationService() { + _removeRegistrationIfExists(); + final service = MockNavigationService(); + locator.registerSingleton(service); + return service; +} + +MockBottomSheetService getAndRegisterBottomSheetService({ + SheetResponse? showCustomSheetResponse, +}) { + _removeRegistrationIfExists(); + final service = MockBottomSheetService(); + + when(service.showCustomSheet( + enableDrag: anyNamed('enableDrag'), + enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), + exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), + ignoreSafeArea: anyNamed('ignoreSafeArea'), + isScrollControlled: anyNamed('isScrollControlled'), + barrierDismissible: anyNamed('barrierDismissible'), + additionalButtonTitle: anyNamed('additionalButtonTitle'), + variant: anyNamed('variant'), + title: anyNamed('title'), + hasImage: anyNamed('hasImage'), + imageUrl: anyNamed('imageUrl'), + showIconInMainButton: anyNamed('showIconInMainButton'), + mainButtonTitle: anyNamed('mainButtonTitle'), + showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), + secondaryButtonTitle: anyNamed('secondaryButtonTitle'), + showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), + takesInput: anyNamed('takesInput'), + barrierColor: anyNamed('barrierColor'), + barrierLabel: anyNamed('barrierLabel'), + customData: anyNamed('customData'), + data: anyNamed('data'), + description: anyNamed('description'), + )).thenAnswer((realInvocation) => + Future.value(showCustomSheetResponse ?? SheetResponse())); + + locator.registerSingleton(service); + return service; +} + +MockDialogService getAndRegisterDialogService() { + _removeRegistrationIfExists(); + final service = MockDialogService(); + locator.registerSingleton(service); + return service; +} + +// @stacked-mock-create + +void _removeRegistrationIfExists() { + if (locator.isRegistered()) { + locator.unregister(); + } +} + +'''; + +// -------------------------------------------------- + + +// -------- HomeViewmodelTest Template Data ---------- + +const String kAppMobileTemplateHomeViewmodelTestPath = + 'test/viewmodels/home_viewmodel_test.dart.stk'; + +const String kAppMobileTemplateHomeViewmodelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/ui/common/app_strings.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_viewmodel.dart'; + +import '{{{viewTestHelpersImport}}}'; + +void main() { + HomeViewModel getModel() => HomeViewModel(); + + group('HomeViewmodelTest -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + + group('incrementCounter -', () { + test('When called once should return Counter is: 1', () { + final model = getModel(); + model.incrementCounter(); + expect(model.counterLabel, 'Counter is: 1'); + }); + }); + + group('showBottomSheet -', () { + test('When called, should show custom bottom sheet using notice variant', + () { + final bottomSheetService = getAndRegisterBottomSheetService(); + + final model = getModel(); + model.showBottomSheet(); + verify(bottomSheetService.showCustomSheet( + variant: BottomSheetType.notice, + title: ksHomeBottomSheetTitle, + description: ksHomeBottomSheetDescription, + )); + }); + }); + }); } '''; // -------------------------------------------------- -// -------- HomeViewDesktop Template Data ---------- -const String kAppWebTemplateHomeViewDesktopPath = - 'lib/ui/views/home/home_view.desktop.dart.stk'; +// -------- InfoAlertDialogModelTest Template Data ---------- -const String kAppWebTemplateHomeViewDesktopContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/app_constants.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; +const String kAppMobileTemplateInfoAlertDialogModelTestPath = + 'test/viewmodels/info_alert_dialog_model_test.dart.stk'; -import 'home_viewmodel.dart'; +const String kAppMobileTemplateInfoAlertDialogModelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -class HomeViewDesktop extends ViewModelWidget { - const HomeViewDesktop({super.key}); +import '{{{viewTestHelpersImport}}}'; - @override - Widget build(BuildContext context, HomeViewModel viewModel) { - return Scaffold( - body: Center( - child: SizedBox( - width: kdDesktopMaxContentWidth, - height: kdDesktopMaxContentHeight, - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - verticalSpaceLarge, - Column( - children: [ - const Text( - 'Hello, DESKTOP UI!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - verticalSpaceMedium, - MaterialButton( - color: Colors.black, - onPressed: viewModel.incrementCounter, - child: Text( - viewModel.counterLabel, - style: const TextStyle(color: Colors.white), - ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showDialog, - child: const Text( - 'Show Dialog', - style: TextStyle( - color: Colors.white, - ), - ), - ), - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showBottomSheet, - child: const Text( - 'Show Bottom Sheet', - style: TextStyle( - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ), - ), - ); - } +void main() { + group('InfoAlertDialogModel Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); } '''; // -------------------------------------------------- -// -------- HomeViewMobile Template Data ---------- -const String kAppWebTemplateHomeViewMobilePath = - 'lib/ui/views/home/home_view.mobile.dart.stk'; +// -------- NoticeSheetModelTest Template Data ---------- -const String kAppWebTemplateHomeViewMobileContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; +const String kAppMobileTemplateNoticeSheetModelTestPath = + 'test/viewmodels/notice_sheet_model_test.dart.stk'; -import 'home_viewmodel.dart'; +const String kAppMobileTemplateNoticeSheetModelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -class HomeViewMobile extends ViewModelWidget { - const HomeViewMobile({super.key}); +import '{{{viewTestHelpersImport}}}'; - @override - Widget build(BuildContext context, HomeViewModel viewModel) { - return Scaffold( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 25.0), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - verticalSpaceLarge, - Column( - children: [ - const Text( - 'Hello, MOBILE UI!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - verticalSpaceMedium, - MaterialButton( - color: Colors.black, - onPressed: viewModel.incrementCounter, - child: Text( - viewModel.counterLabel, - style: const TextStyle(color: Colors.white), - ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showDialog, - child: const Text( - 'Show Dialog', - style: TextStyle( - color: Colors.white, - ), - ), - ), - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showBottomSheet, - child: const Text( - 'Show Bottom Sheet', - style: TextStyle( - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ), - ), - ), - ); - } +void main() { + group('InfoAlertDialogModel Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); } '''; // -------------------------------------------------- -// -------- HomeView Template Data ---------- -const String kAppWebTemplateHomeViewPath = - 'lib/ui/views/home/home_view.dart.stk'; +// -------- SettingsJsonStk Template Data ---------- -const String kAppWebTemplateHomeViewContent = ''' -import 'package:flutter/material.dart'; -import 'package:responsive_builder/responsive_builder.dart'; -import 'package:stacked/stacked.dart'; +const String kAppWebTemplateSettingsJsonStkPath = + '.vscode/settings.json.stk'; -import 'home_view.desktop.dart'; -import 'home_view.tablet.dart'; -import 'home_view.mobile.dart'; -import 'home_viewmodel.dart'; +const String kAppWebTemplateSettingsJsonStkContent = ''' +{ + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "*.dart": "\${capture}.mobile.dart, \${capture}.tablet.dart, \${capture}.desktop.dart, \${capture}.form.dart, \${capture}.g.dart, \${capture}.freezed.dart, \${capture}.logger.dart, \${capture}.locator.dart, \${capture}.router.dart, \${capture}.dialogs.dart, \${capture}.bottomsheets.dart" + } +} -class HomeView extends StackedView { - const HomeView({super.key}); +'''; - @override - Widget builder( - BuildContext context, - HomeViewModel viewModel, - Widget? child, - ) { - return ScreenTypeLayout.builder( - mobile: (_) => const HomeViewMobile(), - tablet: (_) => const HomeViewTablet(), - desktop: (_) => const HomeViewDesktop(), - ); - } +// -------------------------------------------------- - @override - HomeViewModel viewModelBuilder( - BuildContext context, - ) => - HomeViewModel(); -} + +// -------- BuildYamlStk Template Data ---------- + +const String kAppWebTemplateBuildYamlStkPath = + 'build.yaml.stk'; + +const String kAppWebTemplateBuildYamlStkContent = ''' +targets: + \$default: + builders: + stacked_generator|stackedRouterGenerator: + options: + navigator2: true +'''; + +// -------------------------------------------------- + + +// -------- App Template Data ---------- + +const String kAppWebTemplateAppPath = + 'lib/app/app.dart.stk'; + +const String kAppWebTemplateAppContent = ''' +import 'package:{{packageName}}/{{{bottomSheetsPath}}}/notice/notice_sheet.dart'; +import 'package:{{packageName}}/{{{dialogsPath}}}/info_alert/info_alert_dialog.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_view.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/startup/startup_view.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/unknown/unknown_view.dart'; +import 'package:stacked/stacked_annotations.dart'; +import 'package:stacked_services/stacked_services.dart'; +// @stacked-import + +@StackedApp( + routes: [ + CustomRoute(page: StartupView, initial: true), + CustomRoute(page: HomeView), + // @stacked-route + + CustomRoute(page: UnknownView, path: '/404'), + + /// When none of the above routes match, redirect to UnknownView + RedirectRoute(path: '*', redirectTo: '/404'), + ], + dependencies: [ + LazySingleton(classType: BottomSheetService), + LazySingleton(classType: DialogService), + LazySingleton(classType: RouterService), + // @stacked-service + ], + bottomsheets: [ + StackedBottomsheet(classType: NoticeSheet), + // @stacked-bottom-sheet + ], + dialogs: [ + StackedDialog(classType: InfoAlertDialog), + // @stacked-dialog + ], +) +class App {} '''; // -------------------------------------------------- -// -------- HomeViewmodel Template Data ---------- - -const String kAppWebTemplateHomeViewmodelPath = - 'lib/ui/views/home/home_viewmodel.dart.stk'; -const String kAppWebTemplateHomeViewmodelContent = ''' -import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; -import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/ui/common/app_strings.dart'; -import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; +// -------- HoverExtensions Template Data ---------- -class HomeViewModel extends BaseViewModel { - final _dialogService = locator(); - final _bottomSheetService = locator(); +const String kAppWebTemplateHoverExtensionsPath = + 'lib/extensions/hover_extensions.dart.stk'; - String get counterLabel => 'Counter is: \$_counter'; +const String kAppWebTemplateHoverExtensionsContent = ''' +import 'package:{{packageName}}/ui/widgets/mouse_transforms/scale_on_hover.dart'; +import 'package:{{packageName}}/ui/widgets/mouse_transforms/translate_on_hover.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; - int _counter = 0; +extension HoverExtensions on Widget { + Widget get showCursorOnHover { + return _returnUnalteredOnMobile(MouseRegion( + cursor: SystemMouseCursors.click, + child: this, + )); + } - void incrementCounter() { - _counter++; - rebuildUi(); + /// Moves the widget by x,y pixels on hover + /// + /// to move up use -y values, to move left use -x values + Widget moveOnHover({double? x, double? y}) { + return _returnUnalteredOnMobile(TranslateOnHover( + x: x, + y: y, + child: this, + )); } - void showDialog() { - _dialogService.showCustomDialog( - variant: DialogType.infoAlert, - title: 'Stacked Rocks!', - description: 'Give stacked \$_counter stars on Github', - ); + /// Scales the widget by [scale] on hover + Widget scaleOnHover({double scale = 1.1}) { + return _returnUnalteredOnMobile(ScaleOnHover( + scale: scale, + child: this, + )); } - void showBottomSheet() { - _bottomSheetService.showCustomSheet( - variant: BottomSheetType.notice, - title: ksHomeBottomSheetTitle, - description: ksHomeBottomSheetDescription, - ); + /// Takes in the alteredWidget and if we detect we're on Android or iOS + /// we return the unaltered widget. + /// + /// The reason we can do this is because all altered widgets require mouse + /// functionality to work. + Widget _returnUnalteredOnMobile(Widget alteredWidget) { + if (kIsWeb) { + return alteredWidget; + } + return this; } } - '''; // -------------------------------------------------- -// -------- HomeViewTablet Template Data ---------- -const String kAppWebTemplateHomeViewTabletPath = - 'lib/ui/views/home/home_view.tablet.dart.stk'; +// -------- Main Template Data ---------- -const String kAppWebTemplateHomeViewTabletContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +const String kAppWebTemplateMainPath = + 'lib/main.dart.stk'; + +const String kAppWebTemplateMainContent = ''' import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; +import 'package:responsive_builder/responsive_builder.dart'; +import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; +import 'package:url_strategy/url_strategy.dart'; +import 'package:flutter_animate/flutter_animate.dart'; -import 'home_viewmodel.dart'; +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + setPathUrlStrategy(); + await setupLocator(stackedRouter: stackedRouter); + setupDialogUi(); + setupBottomSheetUi(); + runApp(const MainApp()); +} -class HomeViewTablet extends ViewModelWidget { - const HomeViewTablet({super.key}); +class MainApp extends StatelessWidget { + const MainApp({super.key}); @override - Widget build(BuildContext context, HomeViewModel viewModel) { - return Scaffold( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 25.0), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - verticalSpaceLarge, - Column( - children: [ - const Text( - 'Hello, TABLET UI!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - verticalSpaceMedium, - MaterialButton( - color: Colors.black, - onPressed: viewModel.incrementCounter, - child: Text( - viewModel.counterLabel, - style: const TextStyle(color: Colors.white), - ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showDialog, - child: const Text( - 'Show Dialog', - style: TextStyle( - color: Colors.white, - ), - ), - ), - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showBottomSheet, - child: const Text( - 'Show Bottom Sheet', - style: TextStyle( - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ), - ), + Widget build(BuildContext context) { + return ResponsiveApp( + builder: (_) => MaterialApp.router( + routerDelegate: stackedRouter.delegate(), + routeInformationParser: stackedRouter.defaultRouteParser(), ), - ); + ).animate().fadeIn( + delay: const Duration(milliseconds: 50), + duration: const Duration(milliseconds: 400), + ); } } @@ -1204,299 +1294,340 @@ class HomeViewTablet extends ViewModelWidget { // -------------------------------------------------- -// -------- UnknownView Template Data ---------- -const String kAppWebTemplateUnknownViewPath = - 'lib/ui/views/unknown/unknown_view.dart.stk'; +// -------- NoticeSheet Template Data ---------- -const String kAppWebTemplateUnknownViewContent = ''' +const String kAppWebTemplateNoticeSheetPath = + 'lib/ui/bottom_sheets/notice/notice_sheet.dart.stk'; + +const String kAppWebTemplateNoticeSheetContent = ''' import 'package:flutter/material.dart'; -import 'package:responsive_builder/responsive_builder.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; -import 'unknown_view.desktop.dart'; -import 'unknown_view.tablet.dart'; -import 'unknown_view.mobile.dart'; -import 'unknown_viewmodel.dart'; +import 'notice_sheet_model.dart'; -class UnknownView extends StackedView { - const UnknownView({super.key}); +class NoticeSheet extends StackedView { + final Function(SheetResponse)? completer; + final SheetRequest request; + const NoticeSheet({ + Key? key, + required this.completer, + required this.request, + }) : super(key: key); @override Widget builder( BuildContext context, - UnknownViewModel viewModel, + NoticeSheetModel viewModel, Widget? child, ) { - return ScreenTypeLayout.builder( - mobile: (_) => const UnknownViewMobile(), - tablet: (_) => const UnknownViewTablet(), - desktop: (_) => const UnknownViewDesktop(), + return Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + request.title!, + style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), + ), + verticalSpaceTiny, + Text( + request.description!, + style: const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + verticalSpaceLarge, + ], + ), ); } @override - UnknownViewModel viewModelBuilder( - BuildContext context, - ) => - UnknownViewModel(); + NoticeSheetModel viewModelBuilder(BuildContext context) => + NoticeSheetModel(); } '''; // -------------------------------------------------- -// -------- UnknownViewDesktop Template Data ---------- - -const String kAppWebTemplateUnknownViewDesktopPath = - 'lib/ui/views/unknown/unknown_view.desktop.dart.stk'; -const String kAppWebTemplateUnknownViewDesktopContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; +// -------- NoticeSheetModel Template Data ---------- -import 'unknown_viewmodel.dart'; +const String kAppWebTemplateNoticeSheetModelPath = + 'lib/ui/bottom_sheets/notice/notice_sheet_model.dart.stk'; -class UnknownViewDesktop extends ViewModelWidget { - const UnknownViewDesktop({super.key}); +const String kAppWebTemplateNoticeSheetModelContent = ''' +import 'package:stacked/stacked.dart'; - @override - Widget build(BuildContext context, UnknownViewModel viewModel) { - return const Scaffold( - backgroundColor: kcBackgroundColor, - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '404', - style: TextStyle( - color: Colors.white, - fontSize: 80, - fontWeight: FontWeight.w800, - height: 0.95, - letterSpacing: 20.0, - ), - ), - verticalSpaceSmall, - Text( - 'PAGE NOT FOUND', - style: TextStyle( - color: Colors.white, - fontSize: 20, - letterSpacing: 20.0, - wordSpacing: 10.0, - ), - ), - ], - ), - ), - ); - } -} +class NoticeSheetModel extends BaseViewModel {} '''; // -------------------------------------------------- -// -------- UnknownViewTablet Template Data ---------- -const String kAppWebTemplateUnknownViewTabletPath = - 'lib/ui/views/unknown/unknown_view.tablet.dart.stk'; +// -------- AppColors Template Data ---------- -const String kAppWebTemplateUnknownViewTabletContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +const String kAppWebTemplateAppColorsPath = + 'lib/ui/common/app_colors.dart.stk'; + +const String kAppWebTemplateAppColorsContent = ''' import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'unknown_viewmodel.dart'; +const Color kcPrimaryColor = Color(0xFF9600FF); +const Color kcPrimaryColorDark = Color(0xFF300151); +const Color kcBlack = Color(0xFF000000); +const Color kcDarkGreyColor = Color(0xFF1A1B1E); +const Color kcMediumGrey = Color(0xFF474A54); +const Color kcLightGrey = Color.fromARGB(255, 187, 187, 187); +const Color kcVeryLightGrey = Color(0xFFE3E3E3); +const Color kcWhite = Color(0xFFFFFFFF); +const Color kcBackgroundColor = kcDarkGreyColor; -class UnknownViewTablet extends ViewModelWidget { - const UnknownViewTablet({super.key}); +'''; - @override - Widget build(BuildContext context, UnknownViewModel viewModel) { - return const Scaffold( - backgroundColor: kcBackgroundColor, - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '404', - style: TextStyle( - color: Colors.white, - fontSize: 80, - fontWeight: FontWeight.w800, - height: 0.95, - letterSpacing: 20.0, - ), - ), - verticalSpaceSmall, - Text( - 'PAGE NOT FOUND', - style: TextStyle( - color: Colors.white, - fontSize: 20, - letterSpacing: 20.0, - wordSpacing: 10.0, - ), - ), - ], - ), - ), - ); - } -} +// -------------------------------------------------- + + +// -------- AppConstants Template Data ---------- + +const String kAppWebTemplateAppConstantsPath = + 'lib/ui/common/app_constants.dart.stk'; + +const String kAppWebTemplateAppConstantsContent = ''' +/// The max width the content can ever take up on the screen +const double kdDesktopMaxContentWidth = 1150; + +// The max height the homeview will take up +const double kdDesktopMaxContentHeight = 750; '''; // -------------------------------------------------- -// -------- UnknownViewmodel Template Data ---------- -const String kAppWebTemplateUnknownViewmodelPath = - 'lib/ui/views/unknown/unknown_viewmodel.dart.stk'; +// -------- AppStrings Template Data ---------- -const String kAppWebTemplateUnknownViewmodelContent = ''' -import 'package:stacked/stacked.dart'; +const String kAppWebTemplateAppStringsPath = + 'lib/ui/common/app_strings.dart.stk'; -class UnknownViewModel extends BaseViewModel {} +const String kAppWebTemplateAppStringsContent = ''' +const String ksHomeBottomSheetTitle = 'Build Great Apps!'; +const String ksHomeBottomSheetDescription = + 'Stacked is built to help you build better apps. Give us a chance and we\\'ll prove it to you. Check out stacked.filledstacks.com to learn more'; '''; // -------------------------------------------------- -// -------- UnknownViewMobile Template Data ---------- -const String kAppWebTemplateUnknownViewMobilePath = - 'lib/ui/views/unknown/unknown_view.mobile.dart.stk'; +// -------- UiHelpers Template Data ---------- + +const String kAppWebTemplateUiHelpersPath = + 'lib/ui/common/ui_helpers.dart.stk'; + +const String kAppWebTemplateUiHelpersContent = ''' +import 'dart:math'; -const String kAppWebTemplateUnknownViewMobileContent = ''' -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'unknown_viewmodel.dart'; +const double _tinySize = 5.0; +const double _smallSize = 10.0; +const double _mediumSize = 25.0; +const double _largeSize = 50.0; +const double _massiveSize = 120.0; -class UnknownViewMobile extends ViewModelWidget { - const UnknownViewMobile({super.key}); +const Widget horizontalSpaceTiny = SizedBox(width: _tinySize); +const Widget horizontalSpaceSmall = SizedBox(width: _smallSize); +const Widget horizontalSpaceMedium = SizedBox(width: _mediumSize); +const Widget horizontalSpaceLarge = SizedBox(width: _largeSize); - @override - Widget build(BuildContext context, UnknownViewModel viewModel) { - return const Scaffold( - backgroundColor: kcBackgroundColor, - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '404', - style: TextStyle( - color: Colors.white, - fontSize: 80, - fontWeight: FontWeight.w800, - height: 0.95, - letterSpacing: 20.0, - ), - ), - verticalSpaceSmall, - Text( - 'PAGE NOT FOUND', - style: TextStyle( - color: Colors.white, - fontSize: 20, - letterSpacing: 20.0, - wordSpacing: 10.0, - ), - ), - ], - ), - ), - ); - } -} -'''; +const Widget verticalSpaceTiny = SizedBox(height: _tinySize); +const Widget verticalSpaceSmall = SizedBox(height: _smallSize); +const Widget verticalSpaceMedium = SizedBox(height: _mediumSize); +const Widget verticalSpaceLarge = SizedBox(height: _largeSize); +const Widget verticalSpaceMassive = SizedBox(height: _massiveSize); -// -------------------------------------------------- +Widget spacedDivider = const Column( + children: [ + verticalSpaceMedium, + Divider(color: Colors.blueGrey, height: 5.0), + verticalSpaceMedium, + ], +); -// -------- StartupViewmodel Template Data ---------- +Widget verticalSpace(double height) => SizedBox(height: height); -const String kAppWebTemplateStartupViewmodelPath = - 'lib/ui/views/startup/startup_viewmodel.dart.stk'; +double screenWidth(BuildContext context) => MediaQuery.of(context).size.width; +double screenHeight(BuildContext context) => MediaQuery.of(context).size.height; -const String kAppWebTemplateStartupViewmodelContent = ''' -import 'package:stacked/stacked.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; -import 'package:stacked_services/stacked_services.dart'; +double screenHeightFraction(BuildContext context, + {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => + min((screenHeight(context) - offsetBy) / dividedBy, max); + +double screenWidthFraction(BuildContext context, + {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => + min((screenWidth(context) - offsetBy) / dividedBy, max); + +double halfScreenWidth(BuildContext context) => + screenWidthFraction(context, dividedBy: 2); + +double thirdScreenWidth(BuildContext context) => + screenWidthFraction(context, dividedBy: 3); + +double quarterScreenWidth(BuildContext context) => + screenWidthFraction(context, dividedBy: 4); + +double getResponsiveHorizontalSpaceMedium(BuildContext context) => + screenWidthFraction(context, dividedBy: 10); +double getResponsiveSmallFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 14, max: 15); + +double getResponsiveMediumFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 16, max: 17); + +double getResponsiveLargeFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 21, max: 31); + +double getResponsiveExtraLargeFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 25); -class StartupViewModel extends BaseViewModel { - final _routerService = locator(); +double getResponsiveMassiveFontSize(BuildContext context) => + getResponsiveFontSize(context, fontSize: 30); - // Place anything here that needs to happen before we get into the application - Future runStartupLogic() async { - // This is where you can make decisions on where your app should navigate when - // you have custom startup logic +double getResponsiveFontSize(BuildContext context, + {double? fontSize, double? max}) { + max ??= 100; - await _routerService.replaceWith(const HomeViewRoute()); - } + var responsiveSize = min( + screenWidthFraction(context, dividedBy: 10) * ((fontSize ?? 100) / 100), + max); + + return responsiveSize; } '''; // -------------------------------------------------- -// -------- StartupView Template Data ---------- -const String kAppWebTemplateStartupViewPath = - 'lib/ui/views/startup/startup_view.dart.stk'; +// -------- InfoAlertDialog Template Data ---------- -const String kAppWebTemplateStartupViewContent = ''' +const String kAppWebTemplateInfoAlertDialogPath = + 'lib/ui/dialogs/info_alert/info_alert_dialog.dart.stk'; + +const String kAppWebTemplateInfoAlertDialogContent = ''' import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; -import 'package:stacked/stacked.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; -import 'startup_viewmodel.dart'; +import 'info_alert_dialog_model.dart'; -class StartupView extends StackedView { - const StartupView({Key? key}) : super(key: key); +const double _graphicSize = 60; + +class InfoAlertDialog extends StackedView { + final DialogRequest request; + final Function(DialogResponse) completer; + + const InfoAlertDialog({ + Key? key, + required this.request, + required this.completer, + }) : super(key: key); @override Widget builder( BuildContext context, - StartupViewModel viewModel, + InfoAlertDialogModel viewModel, Widget? child, ) { - return const Scaffold( - body: Center( + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text( - 'STACKED', - style: TextStyle(fontSize: 40, fontWeight: FontWeight.w900), - ), Row( - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Loading ...', style: TextStyle(fontSize: 16)), - horizontalSpaceSmall, - SizedBox( - width: 16, - height: 16, - child: CircularProgressIndicator( - color: Colors.black, - strokeWidth: 6, + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + request.title!, + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.w900), + ), + verticalSpaceTiny, + Text( + request.description!, + style: + const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + ], + ), + ), + Container( + width: _graphicSize, + height: _graphicSize, + decoration: const BoxDecoration( + color: Color(0xffF6E7B0), + borderRadius: BorderRadius.all( + Radius.circular(_graphicSize / 2), + ), + ), + alignment: Alignment.center, + child: const Text( + '⭐️', + style: TextStyle(fontSize: 30), ), ) ], ), + verticalSpaceMedium, + GestureDetector( + onTap: () => completer(DialogResponse( + confirmed: true, + )), + child: Container( + height: 50, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(10), + ), + child: const Text( + 'Got it', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + ) ], ), ), @@ -1504,479 +1635,679 @@ class StartupView extends StackedView { } @override - StartupViewModel viewModelBuilder( - BuildContext context, - ) => StartupViewModel(); - - @override - void onViewModelReady(StartupViewModel viewModel) => SchedulerBinding.instance - .addPostFrameCallback((timeStamp) => viewModel.runStartupLogic()); + InfoAlertDialogModel viewModelBuilder(BuildContext context) => + InfoAlertDialogModel(); } '''; // -------------------------------------------------- -// -------- ScaleOnHover Template Data ---------- -const String kAppWebTemplateScaleOnHoverPath = - 'lib/ui/widgets/mouse_transforms/scale_on_hover.dart.stk'; +// -------- InfoAlertDialogModel Template Data ---------- -const String kAppWebTemplateScaleOnHoverContent = ''' +const String kAppWebTemplateInfoAlertDialogModelPath = + 'lib/ui/dialogs/info_alert/info_alert_dialog_model.dart.stk'; + +const String kAppWebTemplateInfoAlertDialogModelContent = ''' +import 'package:stacked/stacked.dart'; + +class InfoAlertDialogModel extends BaseViewModel {} + +'''; + +// -------------------------------------------------- + + +// -------- HomeView Template Data ---------- + +const String kAppWebTemplateHomeViewPath = + 'lib/ui/views/home/home_view.dart.stk'; + +const String kAppWebTemplateHomeViewContent = ''' import 'package:flutter/material.dart'; +import 'package:responsive_builder/responsive_builder.dart'; +import 'package:stacked/stacked.dart'; -class ScaleOnHover extends StatefulWidget { - final double scale; - final Widget child; - // You can also pass the translation in here if you want to - const ScaleOnHover({super.key, required this.child, this.scale = 1.1}); +import 'home_view.desktop.dart'; +import 'home_view.tablet.dart'; +import 'home_view.mobile.dart'; +import 'home_viewmodel.dart'; + +class HomeView extends StackedView { + const HomeView({super.key}); @override - State createState() => _ScaleOnHoverState(); + Widget builder( + BuildContext context, + HomeViewModel viewModel, + Widget? child, + ) { + return ScreenTypeLayout.builder( + mobile: (_) => const HomeViewMobile(), + tablet: (_) => const HomeViewTablet(), + desktop: (_) => const HomeViewDesktop(), + ); + } + + @override + HomeViewModel viewModelBuilder( + BuildContext context, + ) => + HomeViewModel(); } -class _ScaleOnHoverState extends State { - final scaleTransform = Matrix4.identity()..scale(1.1); - final noScaleTransform = Matrix4.identity()..scale(1.0); +'''; - bool _hovering = false; +// -------------------------------------------------- + + +// -------- HomeViewDesktop Template Data ---------- + +const String kAppWebTemplateHomeViewDesktopPath = + 'lib/ui/views/home/home_view.desktop.dart.stk'; + +const String kAppWebTemplateHomeViewDesktopContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/app_constants.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; + +import 'home_viewmodel.dart'; + +class HomeViewDesktop extends ViewModelWidget { + const HomeViewDesktop({super.key}); @override - Widget build(BuildContext context) { - return MouseRegion( - onEnter: (e) => _mouseEnter(true), - onExit: (e) => _mouseEnter(false), - child: AnimatedContainer( - duration: const Duration(milliseconds: 350), - curve: Curves.easeOutCirc, - transform: _hovering ? scaleTransform : noScaleTransform, - child: widget.child, + Widget build(BuildContext context, HomeViewModel viewModel) { + return Scaffold( + body: Center( + child: SizedBox( + width: kdDesktopMaxContentWidth, + height: kdDesktopMaxContentHeight, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + verticalSpaceLarge, + Column( + children: [ + const Text( + 'Hello, DESKTOP UI!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + verticalSpaceMedium, + MaterialButton( + color: Colors.black, + onPressed: viewModel.incrementCounter, + child: Text( + viewModel.counterLabel, + style: const TextStyle(color: Colors.white), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showDialog, + child: const Text( + 'Show Dialog', + style: TextStyle( + color: Colors.white, + ), + ), + ), + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showBottomSheet, + child: const Text( + 'Show Bottom Sheet', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ], + ) + ], + ), + ), ), ); } - - void _mouseEnter(bool hover) { - setState(() { - _hovering = hover; - }); - } } + '''; // -------------------------------------------------- -// -------- TranslateOnHover Template Data ---------- -const String kAppWebTemplateTranslateOnHoverPath = - 'lib/ui/widgets/mouse_transforms/translate_on_hover.dart.stk'; +// -------- HomeViewMobile Template Data ---------- -const String kAppWebTemplateTranslateOnHoverContent = ''' -import 'package:flutter/material.dart'; +const String kAppWebTemplateHomeViewMobilePath = + 'lib/ui/views/home/home_view.mobile.dart.stk'; -class TranslateOnHover extends StatefulWidget { - final Widget child; - final double? x; - final double? y; - // You can also pass the translation in here if you want to - const TranslateOnHover({ - super.key, - required this.child, - this.x, - this.y, - }); +const String kAppWebTemplateHomeViewMobileContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; - @override - State createState() => _TranslateOnHoverState(); -} +import 'home_viewmodel.dart'; -class _TranslateOnHoverState extends State { - bool _hovering = false; +class HomeViewMobile extends ViewModelWidget { + const HomeViewMobile({super.key}); @override - Widget build(BuildContext context) { - final nonHoverTransform = Matrix4.identity()..translate(0, 0, 0); - final hoverTransform = Matrix4.identity() - ..translate( - widget.x ?? 0, - widget.y ?? 0, - ); - return MouseRegion( - onEnter: (e) => _mouseEnter(true), - onExit: (e) => _mouseEnter(false), - child: AnimatedContainer( - duration: const Duration(milliseconds: 200), - transform: _hovering ? hoverTransform : nonHoverTransform, - child: widget.child, + Widget build(BuildContext context, HomeViewModel viewModel) { + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + verticalSpaceLarge, + Column( + children: [ + const Text( + 'Hello, MOBILE UI!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + verticalSpaceMedium, + MaterialButton( + color: Colors.black, + onPressed: viewModel.incrementCounter, + child: Text( + viewModel.counterLabel, + style: const TextStyle(color: Colors.white), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showDialog, + child: const Text( + 'Show Dialog', + style: TextStyle( + color: Colors.white, + ), + ), + ), + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showBottomSheet, + child: const Text( + 'Show Bottom Sheet', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ], + ) + ], + ), + ), + ), ), ); } - - void _mouseEnter(bool hover) { - setState(() { - _hovering = hover; - }); - } } + '''; // -------------------------------------------------- -// -------- App Template Data ---------- -const String kAppWebTemplateAppPath = 'lib/app/app.dart.stk'; +// -------- HomeViewTablet Template Data ---------- -const String kAppWebTemplateAppContent = ''' -import 'package:{{packageName}}/{{{bottomSheetsPath}}}/notice/notice_sheet.dart'; -import 'package:{{packageName}}/{{{dialogsPath}}}/info_alert/info_alert_dialog.dart'; -import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_view.dart'; -import 'package:{{packageName}}/{{{viewImportPath}}}/startup/startup_view.dart'; -import 'package:{{packageName}}/{{{viewImportPath}}}/unknown/unknown_view.dart'; -import 'package:stacked/stacked_annotations.dart'; -import 'package:stacked_services/stacked_services.dart'; -// @stacked-import +const String kAppWebTemplateHomeViewTabletPath = + 'lib/ui/views/home/home_view.tablet.dart.stk'; -@StackedApp( - routes: [ - CustomRoute(page: StartupView, initial: true), - CustomRoute(page: HomeView), - // @stacked-route +const String kAppWebTemplateHomeViewTabletContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; - CustomRoute(page: UnknownView, path: '/404'), +import 'home_viewmodel.dart'; - /// When none of the above routes match, redirect to UnknownView - RedirectRoute(path: '*', redirectTo: '/404'), - ], - dependencies: [ - LazySingleton(classType: BottomSheetService), - LazySingleton(classType: DialogService), - LazySingleton(classType: RouterService), - // @stacked-service - ], - bottomsheets: [ - StackedBottomsheet(classType: NoticeSheet), - // @stacked-bottom-sheet - ], - dialogs: [ - StackedDialog(classType: InfoAlertDialog), - // @stacked-dialog - ], -) -class App {} +class HomeViewTablet extends ViewModelWidget { + const HomeViewTablet({super.key}); + + @override + Widget build(BuildContext context, HomeViewModel viewModel) { + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + verticalSpaceLarge, + Column( + children: [ + const Text( + 'Hello, TABLET UI!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + verticalSpaceMedium, + MaterialButton( + color: Colors.black, + onPressed: viewModel.incrementCounter, + child: Text( + viewModel.counterLabel, + style: const TextStyle(color: Colors.white), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showDialog, + child: const Text( + 'Show Dialog', + style: TextStyle( + color: Colors.white, + ), + ), + ), + MaterialButton( + color: kcDarkGreyColor, + onPressed: viewModel.showBottomSheet, + child: const Text( + 'Show Bottom Sheet', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ], + ) + ], + ), + ), + ), + ), + ); + } +} '''; // -------------------------------------------------- -// -------- HoverExtensions Template Data ---------- -const String kAppWebTemplateHoverExtensionsPath = - 'lib/extensions/hover_extensions.dart.stk'; +// -------- HomeViewmodel Template Data ---------- -const String kAppWebTemplateHoverExtensionsContent = ''' -import 'package:{{packageName}}/ui/widgets/mouse_transforms/scale_on_hover.dart'; -import 'package:{{packageName}}/ui/widgets/mouse_transforms/translate_on_hover.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; +const String kAppWebTemplateHomeViewmodelPath = + 'lib/ui/views/home/home_viewmodel.dart.stk'; -extension HoverExtensions on Widget { - Widget get showCursorOnHover { - return _returnUnalteredOnMobile(MouseRegion( - cursor: SystemMouseCursors.click, - child: this, - )); - } +const String kAppWebTemplateHomeViewmodelContent = ''' +import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/ui/common/app_strings.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; - /// Moves the widget by x,y pixels on hover - /// - /// to move up use -y values, to move left use -x values - Widget moveOnHover({double? x, double? y}) { - return _returnUnalteredOnMobile(TranslateOnHover( - x: x, - y: y, - child: this, - )); +class HomeViewModel extends BaseViewModel { + final _dialogService = locator(); + final _bottomSheetService = locator(); + + String get counterLabel => 'Counter is: \$_counter'; + + int _counter = 0; + + void incrementCounter() { + _counter++; + rebuildUi(); } - /// Scales the widget by [scale] on hover - Widget scaleOnHover({double scale = 1.1}) { - return _returnUnalteredOnMobile(ScaleOnHover( - scale: scale, - child: this, - )); + void showDialog() { + _dialogService.showCustomDialog( + variant: DialogType.infoAlert, + title: 'Stacked Rocks!', + description: 'Give stacked \$_counter stars on Github', + ); } - /// Takes in the alteredWidget and if we detect we're on Android or iOS - /// we return the unaltered widget. - /// - /// The reason we can do this is because all altered widgets require mouse - /// functionality to work. - Widget _returnUnalteredOnMobile(Widget alteredWidget) { - if (kIsWeb) { - return alteredWidget; - } - return this; + void showBottomSheet() { + _bottomSheetService.showCustomSheet( + variant: BottomSheetType.notice, + title: ksHomeBottomSheetTitle, + description: ksHomeBottomSheetDescription, + ); } } + '''; // -------------------------------------------------- -// -------- PubspecYamlStk Template Data ---------- - -const String kAppWebTemplatePubspecYamlStkPath = 'pubspec.yaml.stk'; - -const String kAppWebTemplatePubspecYamlStkContent = ''' -name: {{packageName}} -description: {{packageDescription}} -publish_to: 'none' -version: 0.1.0 - -environment: - sdk: '>=3.0.3 <4.0.0' -dependencies: - flutter: - sdk: flutter - stacked: ^3.4.0 - stacked_services: ^1.1.0 - url_strategy: ^0.2.0 - responsive_builder: ^0.7.0 - flutter_animate: ^4.1.1+1 +// -------- StartupView Template Data ---------- -dev_dependencies: - build_runner: ^2.4.5 - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - mockito: ^5.4.1 - stacked_generator: ^1.3.3 +const String kAppWebTemplateStartupViewPath = + 'lib/ui/views/startup/startup_view.dart.stk'; -flutter: - uses-material-design: true +const String kAppWebTemplateStartupViewContent = ''' +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:stacked/stacked.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -'''; +import 'startup_viewmodel.dart'; -// -------------------------------------------------- +class StartupView extends StackedView { + const StartupView({Key? key}) : super(key: key); -// -------- SettingsJsonStk Template Data ---------- + @override + Widget builder( + BuildContext context, + StartupViewModel viewModel, + Widget? child, + ) { + return const Scaffold( + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'STACKED', + style: TextStyle(fontSize: 40, fontWeight: FontWeight.w900), + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text('Loading ...', style: TextStyle(fontSize: 16)), + horizontalSpaceSmall, + SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + color: Colors.black, + strokeWidth: 6, + ), + ) + ], + ), + ], + ), + ), + ); + } -const String kAppWebTemplateSettingsJsonStkPath = '.vscode/settings.json.stk'; + @override + StartupViewModel viewModelBuilder( + BuildContext context, + ) => StartupViewModel(); -const String kAppWebTemplateSettingsJsonStkContent = ''' -{ - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.patterns": { - "*.dart": "\${capture}.mobile.dart, \${capture}.tablet.dart, \${capture}.desktop.dart, \${capture}.form.dart, \${capture}.g.dart, \${capture}.freezed.dart, \${capture}.logger.dart, \${capture}.locator.dart, \${capture}.router.dart, \${capture}.dialogs.dart, \${capture}.bottomsheets.dart" - } + @override + void onViewModelReady(StartupViewModel viewModel) => SchedulerBinding.instance + .addPostFrameCallback((timeStamp) => viewModel.runStartupLogic()); } '''; // -------------------------------------------------- -// -------- StackedJsonStk Template Data ---------- - -const String kAppMobileTemplateStackedJsonStkPath = 'stacked.json.stk'; - -const String kAppMobileTemplateStackedJsonStkContent = ''' -{ - "bottom_sheets_path": "ui/bottom_sheets", - "dialogs_path": "ui/dialogs", - "line_length": 80, - "locator_name": "locator", - "prefer_web": false, - "register_mocks_function": "registerServices", - "services_path": "services", - "stacked_app_file_path": "app/app.dart", - "test_helpers_file_path": "helpers/test_helpers.dart", - "test_services_path": "services", - "test_views_path": "viewmodels", - "test_widgets_path": "widget_models", - "v1": false, - "views_path": "ui/views", - "widgets_path": "ui/widgets/common" -} -'''; - -// -------------------------------------------------- -// -------- HomeViewmodelTest Template Data ---------- +// -------- StartupViewmodel Template Data ---------- -const String kAppMobileTemplateHomeViewmodelTestPath = - 'test/viewmodels/home_viewmodel_test.dart.stk'; +const String kAppWebTemplateStartupViewmodelPath = + 'lib/ui/views/startup/startup_viewmodel.dart.stk'; -const String kAppMobileTemplateHomeViewmodelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +const String kAppWebTemplateStartupViewmodelContent = ''' +import 'package:stacked/stacked.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/ui/common/app_strings.dart'; -import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_viewmodel.dart'; - -import '{{{viewTestHelpersImport}}}'; - -void main() { - HomeViewModel getModel() => HomeViewModel(); - - group('HomeViewmodelTest -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); +import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; +import 'package:stacked_services/stacked_services.dart'; - group('incrementCounter -', () { - test('When called once should return Counter is: 1', () { - final model = getModel(); - model.incrementCounter(); - expect(model.counterLabel, 'Counter is: 1'); - }); - }); +class StartupViewModel extends BaseViewModel { + final _routerService = locator(); - group('showBottomSheet -', () { - test('When called, should show custom bottom sheet using notice variant', - () { - final bottomSheetService = getAndRegisterBottomSheetService(); + // Place anything here that needs to happen before we get into the application + Future runStartupLogic() async { + // This is where you can make decisions on where your app should navigate when + // you have custom startup logic - final model = getModel(); - model.showBottomSheet(); - verify(bottomSheetService.showCustomSheet( - variant: BottomSheetType.notice, - title: ksHomeBottomSheetTitle, - description: ksHomeBottomSheetDescription, - )); - }); - }); - }); + await _routerService.replaceWith(const HomeViewRoute()); + } } '''; // -------------------------------------------------- -// -------- NoticeSheetModelTest Template Data ---------- -const String kAppMobileTemplateNoticeSheetModelTestPath = - 'test/viewmodels/notice_sheet_model_test.dart.stk'; +// -------- UnknownView Template Data ---------- + +const String kAppWebTemplateUnknownViewPath = + 'lib/ui/views/unknown/unknown_view.dart.stk'; + +const String kAppWebTemplateUnknownViewContent = ''' +import 'package:flutter/material.dart'; +import 'package:responsive_builder/responsive_builder.dart'; +import 'package:stacked/stacked.dart'; + +import 'unknown_view.desktop.dart'; +import 'unknown_view.tablet.dart'; +import 'unknown_view.mobile.dart'; +import 'unknown_viewmodel.dart'; -const String kAppMobileTemplateNoticeSheetModelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +class UnknownView extends StackedView { + const UnknownView({super.key}); -import '{{{viewTestHelpersImport}}}'; + @override + Widget builder( + BuildContext context, + UnknownViewModel viewModel, + Widget? child, + ) { + return ScreenTypeLayout.builder( + mobile: (_) => const UnknownViewMobile(), + tablet: (_) => const UnknownViewTablet(), + desktop: (_) => const UnknownViewDesktop(), + ); + } -void main() { - group('InfoAlertDialogModel Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); + @override + UnknownViewModel viewModelBuilder( + BuildContext context, + ) => + UnknownViewModel(); } '''; // -------------------------------------------------- -// -------- InfoAlertDialogModelTest Template Data ---------- -const String kAppMobileTemplateInfoAlertDialogModelTestPath = - 'test/viewmodels/info_alert_dialog_model_test.dart.stk'; +// -------- UnknownViewDesktop Template Data ---------- -const String kAppMobileTemplateInfoAlertDialogModelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kAppWebTemplateUnknownViewDesktopPath = + 'lib/ui/views/unknown/unknown_view.desktop.dart.stk'; -import '{{{viewTestHelpersImport}}}'; +const String kAppWebTemplateUnknownViewDesktopContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; -void main() { - group('InfoAlertDialogModel Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); +import 'unknown_viewmodel.dart'; + +class UnknownViewDesktop extends ViewModelWidget { + const UnknownViewDesktop({super.key}); + + @override + Widget build(BuildContext context, UnknownViewModel viewModel) { + return const Scaffold( + backgroundColor: kcBackgroundColor, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '404', + style: TextStyle( + color: Colors.white, + fontSize: 80, + fontWeight: FontWeight.w800, + height: 0.95, + letterSpacing: 20.0, + ), + ), + verticalSpaceSmall, + Text( + 'PAGE NOT FOUND', + style: TextStyle( + color: Colors.white, + fontSize: 20, + letterSpacing: 20.0, + wordSpacing: 10.0, + ), + ), + ], + ), + ), + ); + } } '''; // -------------------------------------------------- -// -------- TestHelpers Template Data ---------- -const String kAppMobileTemplateTestHelpersPath = - 'test/helpers/test_helpers.dart.stk'; +// -------- UnknownViewMobile Template Data ---------- -const String kAppMobileTemplateTestHelpersContent = ''' -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:stacked_services/stacked_services.dart'; -// @stacked-import +const String kAppWebTemplateUnknownViewMobilePath = + 'lib/ui/views/unknown/unknown_view.mobile.dart.stk'; -import 'test_helpers.mocks.dart'; +const String kAppWebTemplateUnknownViewMobileContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; -@GenerateMocks([], customMocks: [ - MockSpec(onMissingStub: OnMissingStub.returnDefault), - MockSpec(onMissingStub: OnMissingStub.returnDefault), - MockSpec(onMissingStub: OnMissingStub.returnDefault), - // @stacked-mock-spec -]) -void registerServices() { - getAndRegisterNavigationService(); - getAndRegisterBottomSheetService(); - getAndRegisterDialogService(); - // @stacked-mock-register -} +import 'unknown_viewmodel.dart'; -MockNavigationService getAndRegisterNavigationService() { - _removeRegistrationIfExists(); - final service = MockNavigationService(); - locator.registerSingleton(service); - return service; +class UnknownViewMobile extends ViewModelWidget { + const UnknownViewMobile({super.key}); + + @override + Widget build(BuildContext context, UnknownViewModel viewModel) { + return const Scaffold( + backgroundColor: kcBackgroundColor, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '404', + style: TextStyle( + color: Colors.white, + fontSize: 80, + fontWeight: FontWeight.w800, + height: 0.95, + letterSpacing: 20.0, + ), + ), + verticalSpaceSmall, + Text( + 'PAGE NOT FOUND', + style: TextStyle( + color: Colors.white, + fontSize: 20, + letterSpacing: 20.0, + wordSpacing: 10.0, + ), + ), + ], + ), + ), + ); + } } +'''; -MockBottomSheetService getAndRegisterBottomSheetService({ - SheetResponse? showCustomSheetResponse, -}) { - _removeRegistrationIfExists(); - final service = MockBottomSheetService(); +// -------------------------------------------------- - when(service.showCustomSheet( - enableDrag: anyNamed('enableDrag'), - enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), - exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), - ignoreSafeArea: anyNamed('ignoreSafeArea'), - isScrollControlled: anyNamed('isScrollControlled'), - barrierDismissible: anyNamed('barrierDismissible'), - additionalButtonTitle: anyNamed('additionalButtonTitle'), - variant: anyNamed('variant'), - title: anyNamed('title'), - hasImage: anyNamed('hasImage'), - imageUrl: anyNamed('imageUrl'), - showIconInMainButton: anyNamed('showIconInMainButton'), - mainButtonTitle: anyNamed('mainButtonTitle'), - showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), - secondaryButtonTitle: anyNamed('secondaryButtonTitle'), - showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), - takesInput: anyNamed('takesInput'), - barrierColor: anyNamed('barrierColor'), - barrierLabel: anyNamed('barrierLabel'), - customData: anyNamed('customData'), - data: anyNamed('data'), - description: anyNamed('description'), - )).thenAnswer((realInvocation) => - Future.value(showCustomSheetResponse ?? SheetResponse())); - locator.registerSingleton(service); - return service; -} +// -------- UnknownViewTablet Template Data ---------- -MockDialogService getAndRegisterDialogService() { - _removeRegistrationIfExists(); - final service = MockDialogService(); - locator.registerSingleton(service); - return service; -} +const String kAppWebTemplateUnknownViewTabletPath = + 'lib/ui/views/unknown/unknown_view.tablet.dart.stk'; -// @stacked-mock-create +const String kAppWebTemplateUnknownViewTabletContent = ''' +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; -void _removeRegistrationIfExists() { - if (locator.isRegistered()) { - locator.unregister(); +import 'unknown_viewmodel.dart'; + +class UnknownViewTablet extends ViewModelWidget { + const UnknownViewTablet({super.key}); + + @override + Widget build(BuildContext context, UnknownViewModel viewModel) { + return const Scaffold( + backgroundColor: kcBackgroundColor, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '404', + style: TextStyle( + color: Colors.white, + fontSize: 80, + fontWeight: FontWeight.w800, + height: 0.95, + letterSpacing: 20.0, + ), + ), + verticalSpaceSmall, + Text( + 'PAGE NOT FOUND', + style: TextStyle( + color: Colors.white, + fontSize: 20, + letterSpacing: 20.0, + wordSpacing: 10.0, + ), + ), + ], + ), + ), + ); } } @@ -1984,978 +2315,784 @@ void _removeRegistrationIfExists() { // -------------------------------------------------- -// -------- READMEMdStk Template Data ---------- -const String kAppMobileTemplateREADMEMdStkPath = 'README.md.stk'; +// -------- UnknownViewmodel Template Data ---------- -const String kAppMobileTemplateREADMEMdStkContent = ''' -# {{packageName}} +const String kAppWebTemplateUnknownViewmodelPath = + 'lib/ui/views/unknown/unknown_viewmodel.dart.stk'; + +const String kAppWebTemplateUnknownViewmodelContent = ''' +import 'package:stacked/stacked.dart'; + +class UnknownViewModel extends BaseViewModel {} -{{packageDescription}} '''; // -------------------------------------------------- -// -------- Main Template Data ---------- -const String kAppMobileTemplateMainPath = 'lib/main.dart.stk'; +// -------- ScaleOnHover Template Data ---------- -const String kAppMobileTemplateMainContent = ''' +const String kAppWebTemplateScaleOnHoverPath = + 'lib/ui/widgets/mouse_transforms/scale_on_hover.dart.stk'; + +const String kAppWebTemplateScaleOnHoverContent = ''' import 'package:flutter/material.dart'; -import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; -import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; -import 'package:stacked_services/stacked_services.dart'; -Future main() async { - WidgetsFlutterBinding.ensureInitialized(); - await setupLocator(); - setupDialogUi(); - setupBottomSheetUi(); - runApp(const MainApp()); +class ScaleOnHover extends StatefulWidget { + final double scale; + final Widget child; + // You can also pass the translation in here if you want to + const ScaleOnHover({super.key, required this.child, this.scale = 1.1}); + + @override + State createState() => _ScaleOnHoverState(); } -class MainApp extends StatelessWidget { - const MainApp({super.key}); +class _ScaleOnHoverState extends State { + final scaleTransform = Matrix4.identity()..scale(1.1); + final noScaleTransform = Matrix4.identity()..scale(1.0); + + bool _hovering = false; @override Widget build(BuildContext context) { - return MaterialApp( - initialRoute: Routes.startupView, - onGenerateRoute: StackedRouter().onGenerateRoute, - navigatorKey: StackedService.navigatorKey, - navigatorObservers: [ - StackedService.routeObserver, - ], + return MouseRegion( + onEnter: (e) => _mouseEnter(true), + onExit: (e) => _mouseEnter(false), + child: AnimatedContainer( + duration: const Duration(milliseconds: 350), + curve: Curves.easeOutCirc, + transform: _hovering ? scaleTransform : noScaleTransform, + child: widget.child, + ), ); } -} + void _mouseEnter(bool hover) { + setState(() { + _hovering = hover; + }); + } +} '''; // -------------------------------------------------- -// -------- UiHelpers Template Data ---------- -const String kAppMobileTemplateUiHelpersPath = - 'lib/ui/common/ui_helpers.dart.stk'; +// -------- TranslateOnHover Template Data ---------- -const String kAppMobileTemplateUiHelpersContent = ''' -import 'dart:math'; +const String kAppWebTemplateTranslateOnHoverPath = + 'lib/ui/widgets/mouse_transforms/translate_on_hover.dart.stk'; +const String kAppWebTemplateTranslateOnHoverContent = ''' import 'package:flutter/material.dart'; -const double _tinySize = 5.0; -const double _smallSize = 10.0; -const double _mediumSize = 25.0; -const double _largeSize = 50.0; -const double _massiveSize = 120.0; - -const Widget horizontalSpaceTiny = SizedBox(width: _tinySize); -const Widget horizontalSpaceSmall = SizedBox(width: _smallSize); -const Widget horizontalSpaceMedium = SizedBox(width: _mediumSize); -const Widget horizontalSpaceLarge = SizedBox(width: _largeSize); - -const Widget verticalSpaceTiny = SizedBox(height: _tinySize); -const Widget verticalSpaceSmall = SizedBox(height: _smallSize); -const Widget verticalSpaceMedium = SizedBox(height: _mediumSize); -const Widget verticalSpaceLarge = SizedBox(height: _largeSize); -const Widget verticalSpaceMassive = SizedBox(height: _massiveSize); - -Widget spacedDivider = const Column( - children: [ - verticalSpaceMedium, - Divider(color: Colors.blueGrey, height: 5.0), - verticalSpaceMedium, - ], -); - -Widget verticalSpace(double height) => SizedBox(height: height); - -double screenWidth(BuildContext context) => MediaQuery.of(context).size.width; -double screenHeight(BuildContext context) => MediaQuery.of(context).size.height; - -double screenHeightFraction(BuildContext context, - {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => - min((screenHeight(context) - offsetBy) / dividedBy, max); - -double screenWidthFraction(BuildContext context, - {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => - min((screenWidth(context) - offsetBy) / dividedBy, max); - -double halfScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 2); - -double thirdScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 3); +class TranslateOnHover extends StatefulWidget { + final Widget child; + final double? x; + final double? y; + // You can also pass the translation in here if you want to + const TranslateOnHover({ + super.key, + required this.child, + this.x, + this.y, + }); -double quarterScreenWidth(BuildContext context) => - screenWidthFraction(context, dividedBy: 4); + @override + State createState() => _TranslateOnHoverState(); +} -double getResponsiveHorizontalSpaceMedium(BuildContext context) => - screenWidthFraction(context, dividedBy: 10); -double getResponsiveSmallFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 14, max: 15); +class _TranslateOnHoverState extends State { + bool _hovering = false; -double getResponsiveMediumFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 16, max: 17); + @override + Widget build(BuildContext context) { + final nonHoverTransform = Matrix4.identity()..translate(0, 0, 0); + final hoverTransform = Matrix4.identity() + ..translate( + widget.x ?? 0, + widget.y ?? 0, + ); + return MouseRegion( + onEnter: (e) => _mouseEnter(true), + onExit: (e) => _mouseEnter(false), + child: AnimatedContainer( + duration: const Duration(milliseconds: 200), + transform: _hovering ? hoverTransform : nonHoverTransform, + child: widget.child, + ), + ); + } -double getResponsiveLargeFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 21, max: 31); + void _mouseEnter(bool hover) { + setState(() { + _hovering = hover; + }); + } +} +'''; -double getResponsiveExtraLargeFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 25); +// -------------------------------------------------- -double getResponsiveMassiveFontSize(BuildContext context) => - getResponsiveFontSize(context, fontSize: 30); -double getResponsiveFontSize(BuildContext context, - {double? fontSize, double? max}) { - max ??= 100; +// -------- PubspecYamlStk Template Data ---------- - var responsiveSize = min( - screenWidthFraction(context, dividedBy: 10) * ((fontSize ?? 100) / 100), - max); - - return responsiveSize; -} +const String kAppWebTemplatePubspecYamlStkPath = + 'pubspec.yaml.stk'; -'''; +const String kAppWebTemplatePubspecYamlStkContent = ''' +name: {{packageName}} +description: {{packageDescription}} +publish_to: 'none' +version: 0.1.0 -// -------------------------------------------------- +environment: + sdk: '>=3.0.3 <4.0.0' -// -------- AppStrings Template Data ---------- +dependencies: + flutter: + sdk: flutter + stacked: ^3.4.0 + stacked_services: ^1.1.0 + url_strategy: ^0.2.0 + responsive_builder: ^0.7.0 + flutter_animate: ^4.1.1+1 -const String kAppMobileTemplateAppStringsPath = - 'lib/ui/common/app_strings.dart.stk'; +dev_dependencies: + build_runner: ^2.4.5 + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + mockito: ^5.4.1 + stacked_generator: ^1.3.3 -const String kAppMobileTemplateAppStringsContent = ''' -const String ksHomeBottomSheetTitle = 'Build Great Apps!'; -const String ksHomeBottomSheetDescription = - 'Stacked is built to help you build better apps. Give us a chance and we\\'ll prove it to you. Check out stacked.filledstacks.com to learn more'; +flutter: + uses-material-design: true '''; // -------------------------------------------------- -// -------- AppColors Template Data ---------- -const String kAppMobileTemplateAppColorsPath = - 'lib/ui/common/app_colors.dart.stk'; +// -------- READMEMdStk Template Data ---------- -const String kAppMobileTemplateAppColorsContent = ''' -import 'package:flutter/material.dart'; +const String kAppWebTemplateREADMEMdStkPath = + 'README.md.stk'; -const Color kcPrimaryColor = Color(0xFF9600FF); -const Color kcPrimaryColorDark = Color(0xFF300151); -const Color kcDarkGreyColor = Color(0xFF1A1B1E); -const Color kcMediumGrey = Color(0xFF474A54); -const Color kcLightGrey = Color.fromARGB(255, 187, 187, 187); -const Color kcVeryLightGrey = Color(0xFFE3E3E3); -const Color kcBackgroundColor = kcDarkGreyColor; +const String kAppWebTemplateREADMEMdStkContent = ''' +# {{packageName}} +{{packageDescription}} '''; // -------------------------------------------------- -// -------- NoticeSheetModel Template Data ---------- - -const String kAppMobileTemplateNoticeSheetModelPath = - 'lib/ui/bottom_sheets/notice/notice_sheet_model.dart.stk'; -const String kAppMobileTemplateNoticeSheetModelContent = ''' -import 'package:stacked/stacked.dart'; +// -------- StackedJsonStk Template Data ---------- -class NoticeSheetModel extends BaseViewModel {} +const String kAppWebTemplateStackedJsonStkPath = + 'stacked.json.stk'; +const String kAppWebTemplateStackedJsonStkContent = ''' +{ + "bottom_sheets_path": "ui/bottom_sheets", + "dialogs_path": "ui/dialogs", + "line_length": 80, + "locator_name": "locator", + "prefer_web": true, + "register_mocks_function": "registerServices", + "services_path": "services", + "stacked_app_file_path": "app/app.dart", + "test_helpers_file_path": "helpers/test_helpers.dart", + "test_services_path": "services", + "test_views_path": "viewmodels", + "test_widgets_path": "widget_models", + "v1": false, + "views_path": "ui/views", + "widgets_path": "ui/widgets/common" +} '''; // -------------------------------------------------- -// -------- NoticeSheet Template Data ---------- -const String kAppMobileTemplateNoticeSheetPath = - 'lib/ui/bottom_sheets/notice/notice_sheet.dart.stk'; +// -------- TestHelpers Template Data ---------- -const String kAppMobileTemplateNoticeSheetContent = ''' -import 'package:flutter/material.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; +const String kAppWebTemplateTestHelpersPath = + 'test/helpers/test_helpers.dart.stk'; -import 'notice_sheet_model.dart'; +const String kAppWebTemplateTestHelpersContent = ''' +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:stacked_services/stacked_services.dart'; +// @stacked-import -class NoticeSheet extends StackedView { - final Function(SheetResponse)? completer; - final SheetRequest request; - const NoticeSheet({ - Key? key, - required this.completer, - required this.request, - }) : super(key: key); +import 'test_helpers.mocks.dart'; - @override - Widget builder( - BuildContext context, - NoticeSheetModel viewModel, - Widget? child, - ) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - request.title!, - style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), - ), - verticalSpaceTiny, - Text( - request.description!, - style: const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - verticalSpaceLarge, - ], - ), - ); - } +@GenerateMocks([], customMocks: [ + MockSpec(onMissingStub: OnMissingStub.returnDefault), + MockSpec(onMissingStub: OnMissingStub.returnDefault), + MockSpec(onMissingStub: OnMissingStub.returnDefault), + // @stacked-mock-spec +]) +void registerServices() { + getAndRegisterRouterService(); + getAndRegisterBottomSheetService(); + getAndRegisterDialogService(); + // @stacked-mock-register +} - @override - NoticeSheetModel viewModelBuilder(BuildContext context) => - NoticeSheetModel(); +MockRouterService getAndRegisterRouterService() { + _removeRegistrationIfExists(); + final service = MockRouterService(); + locator.registerSingleton(service); + return service; } -'''; +MockBottomSheetService getAndRegisterBottomSheetService({ + SheetResponse? showCustomSheetResponse, +}) { + _removeRegistrationIfExists(); + final service = MockBottomSheetService(); -// -------------------------------------------------- + when(service.showCustomSheet( + enableDrag: anyNamed('enableDrag'), + enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), + exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), + ignoreSafeArea: anyNamed('ignoreSafeArea'), + isScrollControlled: anyNamed('isScrollControlled'), + barrierDismissible: anyNamed('barrierDismissible'), + additionalButtonTitle: anyNamed('additionalButtonTitle'), + variant: anyNamed('variant'), + title: anyNamed('title'), + hasImage: anyNamed('hasImage'), + imageUrl: anyNamed('imageUrl'), + showIconInMainButton: anyNamed('showIconInMainButton'), + mainButtonTitle: anyNamed('mainButtonTitle'), + showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), + secondaryButtonTitle: anyNamed('secondaryButtonTitle'), + showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), + takesInput: anyNamed('takesInput'), + barrierColor: anyNamed('barrierColor'), + barrierLabel: anyNamed('barrierLabel'), + customData: anyNamed('customData'), + data: anyNamed('data'), + description: anyNamed('description'), + )).thenAnswer((realInvocation) => + Future.value(showCustomSheetResponse ?? SheetResponse())); -// -------- InfoAlertDialogModel Template Data ---------- + locator.registerSingleton(service); + return service; +} -const String kAppMobileTemplateInfoAlertDialogModelPath = - 'lib/ui/dialogs/info_alert/info_alert_dialog_model.dart.stk'; +MockDialogService getAndRegisterDialogService() { + _removeRegistrationIfExists(); + final service = MockDialogService(); + locator.registerSingleton(service); + return service; +} -const String kAppMobileTemplateInfoAlertDialogModelContent = ''' -import 'package:stacked/stacked.dart'; +// @stacked-mock-create -class InfoAlertDialogModel extends BaseViewModel {} +void _removeRegistrationIfExists() { + if (locator.isRegistered()) { + locator.unregister(); + } +} '''; // -------------------------------------------------- -// -------- InfoAlertDialog Template Data ---------- - -const String kAppMobileTemplateInfoAlertDialogPath = - 'lib/ui/dialogs/info_alert/info_alert_dialog.dart.stk'; - -const String kAppMobileTemplateInfoAlertDialogContent = ''' -import 'package:flutter/material.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; - -import 'info_alert_dialog_model.dart'; - -const double _graphicSize = 60; -class InfoAlertDialog extends StackedView { - final DialogRequest request; - final Function(DialogResponse) completer; +// -------- HomeViewmodelTest Template Data ---------- - const InfoAlertDialog({ - Key? key, - required this.request, - required this.completer, - }) : super(key: key); +const String kAppWebTemplateHomeViewmodelTestPath = + 'test/viewmodels/home_viewmodel_test.dart.stk'; - @override - Widget builder( - BuildContext context, - InfoAlertDialogModel viewModel, - Widget? child, - ) { - return Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - backgroundColor: Colors.white, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - request.title!, - style: const TextStyle( - fontSize: 16, fontWeight: FontWeight.w900), - ), - verticalSpaceTiny, - Text( - request.description!, - style: - const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - ], - ), - ), - Container( - width: _graphicSize, - height: _graphicSize, - decoration: const BoxDecoration( - color: Color(0xffF6E7B0), - borderRadius: BorderRadius.all( - Radius.circular(_graphicSize / 2), - ), - ), - alignment: Alignment.center, - child: const Text( - '⭐️', - style: TextStyle(fontSize: 30), - ), - ) - ], - ), - verticalSpaceMedium, - GestureDetector( - onTap: () => completer(DialogResponse( - confirmed: true, - )), - child: Container( - height: 50, - width: double.infinity, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.circular(10), - ), - child: const Text( - 'Got it', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - ), - ) - ], - ), - ), - ); - } +const String kAppWebTemplateHomeViewmodelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +import 'package:{{packageName}}/ui/common/app_strings.dart'; +import 'package:{{packageName}}/{{{viewImportPath}}}/home/home_viewmodel.dart'; - @override - InfoAlertDialogModel viewModelBuilder(BuildContext context) => - InfoAlertDialogModel(); +import '{{{viewTestHelpersImport}}}'; + +void main() { + HomeViewModel getModel() => HomeViewModel(); + + group('HomeViewmodelTest -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + + group('incrementCounter -', () { + test('When called once should return Counter is: 1', () { + final model = getModel(); + model.incrementCounter(); + expect(model.counterLabel, 'Counter is: 1'); + }); + }); + + group('showBottomSheet -', () { + test('When called, should show custom bottom sheet using notice variant', + () { + final bottomSheetService = getAndRegisterBottomSheetService(); + + final model = getModel(); + model.showBottomSheet(); + verify(bottomSheetService.showCustomSheet( + variant: BottomSheetType.notice, + title: ksHomeBottomSheetTitle, + description: ksHomeBottomSheetDescription, + )); + }); + }); + }); } '''; // -------------------------------------------------- -// -------- HomeViewV1 Template Data ---------- -const String kAppMobileTemplateHomeViewV1Path = - 'lib/ui/views/home/home_view_v1.dart.stk'; +// -------- InfoAlertDialogModelTest Template Data ---------- -const String kAppMobileTemplateHomeViewV1Content = ''' -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +const String kAppWebTemplateInfoAlertDialogModelTestPath = + 'test/viewmodels/info_alert_dialog_model_test.dart.stk'; -import 'home_viewmodel.dart'; +const String kAppWebTemplateInfoAlertDialogModelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -class HomeView extends StatelessWidget { - const HomeView({Key? key}) : super(key: key); +import '{{{viewTestHelpersImport}}}'; - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: () => HomeViewModel(), - builder: (context, model, child) => Scaffold( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 25.0), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - verticalSpaceLarge, - Column( - children: [ - const Text( - 'Hello, STACKED!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - verticalSpaceMedium, - MaterialButton( - color: Colors.black, - onPressed: model.incrementCounter, - child: Text( - model.counterLabel, - style: const TextStyle(color: Colors.white), - ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MaterialButton( - color: kcDarkGreyColor, - child: const Text( - 'Show Dialog', - style: TextStyle( - color: Colors.white, - ), - ), - onPressed: model.showDialog, - ), - MaterialButton( - color: kcDarkGreyColor, - child: const Text( - 'Show Bottom Sheet', - style: TextStyle( - color: Colors.white, - ), - ), - onPressed: model.showBottomSheet, - ), - ], - ) - ], - ), - ), - ), - ), - ), - ); - } +void main() { + group('InfoAlertDialogModel Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); } + '''; // -------------------------------------------------- -// -------- HomeView Template Data ---------- - -const String kAppMobileTemplateHomeViewPath = - 'lib/ui/views/home/home_view.dart.stk'; -const String kAppMobileTemplateHomeViewContent = ''' -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +// -------- NoticeSheetModelTest Template Data ---------- -import 'home_viewmodel.dart'; +const String kAppWebTemplateNoticeSheetModelTestPath = + 'test/viewmodels/notice_sheet_model_test.dart.stk'; -class HomeView extends StackedView { - const HomeView({Key? key}) : super(key: key); +const String kAppWebTemplateNoticeSheetModelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; - @override - Widget builder( - BuildContext context, - HomeViewModel viewModel, - Widget? child, - ) { - return Scaffold( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 25.0), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - verticalSpaceLarge, - Column( - children: [ - const Text( - 'Hello, STACKED!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - verticalSpaceMedium, - MaterialButton( - color: Colors.black, - onPressed: viewModel.incrementCounter, - child: Text( - viewModel.counterLabel, - style: const TextStyle(color: Colors.white), - ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showDialog, - child: const Text( - 'Show Dialog', - style: TextStyle( - color: Colors.white, - ), - ), - ), - MaterialButton( - color: kcDarkGreyColor, - onPressed: viewModel.showBottomSheet, - child: const Text( - 'Show Bottom Sheet', - style: TextStyle( - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ), - ), - ), - ); - } +import '{{{viewTestHelpersImport}}}'; - @override - HomeViewModel viewModelBuilder( - BuildContext context, - ) => HomeViewModel(); +void main() { + group('InfoAlertDialogModel Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); } '''; // -------------------------------------------------- -// -------- HomeViewmodel Template Data ---------- -const String kAppMobileTemplateHomeViewmodelPath = - 'lib/ui/views/home/home_viewmodel.dart.stk'; +// -------- UnknownViewmodelTest Template Data ---------- -const String kAppMobileTemplateHomeViewmodelContent = ''' -import 'package:{{packageName}}/{{{relativeBottomSheetFilePath}}}'; -import 'package:{{packageName}}/{{{relativeDialogFilePath}}}'; +const String kAppWebTemplateUnknownViewmodelTestPath = + 'test/viewmodels/unknown_viewmodel_test.dart.stk'; + +const String kAppWebTemplateUnknownViewmodelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/ui/common/app_strings.dart'; -import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; -class HomeViewModel extends BaseViewModel { - final _dialogService = locator(); - final _bottomSheetService = locator(); +import '../helpers/test_helpers.dart'; - String get counterLabel => 'Counter is: \$_counter'; +void main() { + group('UnknownViewModel Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); +} +'''; - int _counter = 0; +// -------------------------------------------------- - void incrementCounter() { - _counter++; - rebuildUi(); - } - void showDialog() { - _dialogService.showCustomDialog( - variant: DialogType.infoAlert, - title: 'Stacked Rocks!', - description: 'Give stacked \$_counter stars on Github', - ); - } +// -------- FaviconPngStk Template Data ---------- - void showBottomSheet() { - _bottomSheetService.showCustomSheet( - variant: BottomSheetType.notice, - title: ksHomeBottomSheetTitle, - description: ksHomeBottomSheetDescription, - ); - } -} +const String kAppWebTemplateFaviconPngStkPath = + 'web/favicon.png.stk'; +const String kAppWebTemplateFaviconPngStkContent = ''' +iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgBpVTNasJAEN7dxLQl+FNEFBRR8VCQgo+gryCkh9499CnUg/gMvo3eFWw9eBLS4sWT2oOHRLOdWWLYxkRT+8GS3cnkm28mM0tIMOhpwzmn7plKdurawz9EdLtdNhqNWKvVekyn0ynLsghjTPg4jsNt26a6rnO09/v9r2Qy6UwmkwOlwoX7yZVqtWqA07v78uqKx+NmsVhsw179Jc4wDKVcLrejEvkXCHlBDlmdlkgkPm8lhKw+arWahipRKikUCspqtSqe2FOpFKnX6+QSZrMZ2W63Yr/b7Z6htshl45kOh8MnOWKj0eCXAD8vSKmOf54ho6qqnEREr9fDbjizZzIZikBCut/v6X/IENBeQikSck3TrnFdJJMghJ3V0L86nc5ZHbHOsk82m9WFUCTEzg8DkEVRhpOE6jhD57CUo5IR4tVQpMyCUg5KM0LKorH5crn8lqNhY4/HY9JsNkMVYWPLWK/XXutRmJQHGPQ5uXH0cGxLpdK9SNeVe8jlcgNyI2CWB6ZpHjwDjgxGyOfzb3+5JIBoXqlUXuG2uSOnHpQCUSi0slgs7qCNVAwCEHXZbDZYV+8sZpYxJxaLHaFc1nQ6PYLZCcsAy6BIT0U6eza83X2CBH4AHNJFlWlQookAAAAASUVORK5CYII= '''; // -------------------------------------------------- -// -------- StartupViewmodel Template Data ---------- - -const String kAppMobileTemplateStartupViewmodelPath = - 'lib/ui/views/startup/startup_viewmodel.dart.stk'; -const String kAppMobileTemplateStartupViewmodelContent = ''' -import 'package:stacked/stacked.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; -import 'package:{{packageName}}/{{{relativeRouterFilePath}}}'; -import 'package:stacked_services/stacked_services.dart'; +// -------- IndexHtmlStk Template Data ---------- -class StartupViewModel extends BaseViewModel { - final _navigationService = locator(); +const String kAppWebTemplateIndexHtmlStkPath = + 'web/index.html.stk'; - // Place anything here that needs to happen before we get into the application - Future runStartupLogic() async { - await Future.delayed(const Duration(seconds: 3)); +const String kAppWebTemplateIndexHtmlStkContent = ''' + + - // This is where you can make decisions on where your app should navigate when - // you have custom startup logic + + + -// -------- StartupViewV1 Template Data ---------- + + + -const String kAppMobileTemplateStartupViewV1Path = - 'lib/ui/views/startup/startup_view_v1.dart.stk'; + + + + + -const String kAppMobileTemplateStartupViewV1Content = ''' -import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; -import 'package:stacked/stacked.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; + + -import 'startup_viewmodel.dart'; + + + + -class StartupView extends StatelessWidget { - const StartupView({Key? key}) : super(key: key); + My Stacked Application + - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - builder: (context, model, child) => Scaffold( - body: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text( - 'STACKED', - style: TextStyle( - fontSize: 40, - fontWeight: FontWeight.w900, - ), - ), - Row( - mainAxisSize: MainAxisSize.min, - children: const [ - Text( - 'Loading ...', - style: TextStyle( - fontSize: 16, - ), - ), - horizontalSpaceSmall, - SizedBox( - width: 16, - height: 16, - child: CircularProgressIndicator( - color: Colors.black, - strokeWidth: 6, - ), - ) - ], - ), - ], - ), - ), - ), - onModelReady: (model) => SchedulerBinding.instance - .addPostFrameCallback((timeStamp) => model.runStartupLogic()), - viewModelBuilder: () => StartupViewModel(), - ); - } -} -'''; + + + + -// -------------------------------------------------- + + + +
+
+ + + + +
+ +
+ + '''; // -------------------------------------------------- -// -------- PubspecYamlStk Template Data ---------- - -const String kAppMobileTemplatePubspecYamlStkPath = 'pubspec.yaml.stk'; -const String kAppMobileTemplatePubspecYamlStkContent = ''' -name: {{packageName}} -description: {{packageDescription}} -publish_to: 'none' -version: 0.1.0 +// -------- MainIconPngStk Template Data ---------- -environment: - sdk: '>=3.0.3 <4.0.0' +const String kAppWebTemplateMainIconPngStkPath = + 'web/main-icon.png.stk'; -dependencies: - flutter: - sdk: flutter - stacked: ^3.4.0 - stacked_services: ^1.1.0 +const String kAppWebTemplateMainIconPngStkContent = ''' +iVBORw0KGgoAAAANSUhEUgAAALMAAACzCAYAAADCFC3zAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAN5SURBVHgB7daLjVNBDEDRF0QjVEIrdMLSAS3RyZZAByGWdqUQ5Z/5eGbOkSw3cC152wAAAAAAAAAAAAAAAACAjHZbYfuDDW77tdvt3raCvmzQXvGQg5hprUrIQcy0VC3kIGZaqRpyEDMtVA85iJnamoQcxExNzUIOYqaWpiEHMVND85CDmCmtS8hBzJTULeQgZkrpGnIQMyV0DzmImVelCDmImVekCTmImWelCjmImWekCzmImUelDDmImUekDTmImXulDjmImXukDzmImVuGCDmImWuGCTmImUuGCjmImXOGCzmImVNDhhzEzLFhQw5i5tPQIQcxE4YPOYiZKUIOYl7bNCEHMa9rqpCDmNc0XchBzOuZMuQg5rVMG3IQ8zqmDjmIeQ3ThxzEPL8lQg5intsyIQcxz2upkIOY57RcyEHM81ky5CDmuSwbchDzPJYOOYh5DsuHHMQ8PiF/EPPYhHxEzOMS8gkxj0nIZ4h5PEK+QMxjEfIVYh6HkG8Q8xiEfAcx5yfkO4k5NyE/QMx5CflBYs5JyE8Qcz5CfpKYcxHyC8Sch5BfJOYchFyAmPsTciFi7kvIBYm5HyEXJuY+hFyBmNsTciVibkvIFYm5HSFXttsK2+/3bxunvh/mz8axv4fj/r0VVDxm/nc47p+H9bZx6v0Q87etIG9GRUJuS8yVCLk9MVcg5D7EXJiQ+xFzQULuS8yFCLk/MRcg5BzE/CIh5yHmFwg5FzE/Scj5iPkJQs5JzA8Scl5ifoCQcxPznYScn5jvIOQxiPkGIY9DzFcIeSxivkDI4xHzGUIek5hPCHlcYj4i5LGJ+YOQxyfmTcizWD5mIc9j6ZiFPJdlYxbyfJaMWchzWi5mIc9rqZiFPLdlYhby/JaIWchrmD5mIa9j6piFvJZpYxbyeqaMWchrmi5mIa9rqpiFvLZpYhYyU8QsZMLwMQuZT0PHLGSODRuzkDk1ZMxC5pzhYhYylwwVs5C5ZpiYhcwtQ8QsZO6RPmYhc6/UMQuZR6SNWcg8KmXMQuYZ6WIWMs9KFbOQeUWamIXMq1LELGRK6B6zkCmla8xCpqRuMQuZ0rrELGRqaB6zkKmlacxCpqZmMQuZ2prELGRaqB6zkGmlasxCpqVqMQuZ1qrELGR6+LoVdgj5x2HFvG9w2fsGAAAAAAAAAAAAAAAAACzhH8sFZqawpyetAAAAAElFTkSuQmCC +'''; -dev_dependencies: - build_runner: ^2.4.5 - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - mockito: ^5.4.1 - stacked_generator: ^1.3.3 +// -------------------------------------------------- -flutter: - uses-material-design: true -'''; +// -------- GenericSheet Template Data ---------- -// -------------------------------------------------- +const String kBottomSheetEmptyTemplateGenericSheetPath = + 'lib/ui/bottom_sheets/generic/generic_sheet.dart.stk'; -// -------- SettingsJsonStk Template Data ---------- +const String kBottomSheetEmptyTemplateGenericSheetContent = ''' +import 'package:flutter/material.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:stacked_services/stacked_services.dart'; -const String kAppMobileTemplateSettingsJsonStkPath = - '.vscode/settings.json.stk'; +class {{sheetName}} extends StatelessWidget { + final Function(SheetResponse response)? completer; + final SheetRequest request; + const {{sheetName}}({ + Key? key, + required this.completer, + required this.request, + }) : super(key: key); -const String kAppMobileTemplateSettingsJsonStkContent = ''' -{ - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.patterns": { - "*.dart": "\${capture}.mobile.dart, \${capture}.tablet.dart, \${capture}.desktop.dart, \${capture}.form.dart, \${capture}.g.dart, \${capture}.freezed.dart, \${capture}.logger.dart, \${capture}.locator.dart, \${capture}.router.dart, \${capture}.dialogs.dart, \${capture}.bottomsheets.dart" - } + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + request.title ?? 'Hello Stacked Sheet!!', + style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), + ), + if (request.description != null) ...[ + verticalSpaceTiny, + Text( + request.description!, + style: const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + ], + verticalSpaceLarge, + ], + ), + ); + } } '''; // -------------------------------------------------- -// -------- GenericModelTest Template Data ---------- -const String kWidgetEmptyTemplateGenericModelTestPath = - 'test/widget_models/generic_model_test.dart.stk'; +// -------- GenericSheetModel Template Data ---------- -const String kWidgetEmptyTemplateGenericModelTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kBottomSheetEmptyTemplateGenericSheetModelPath = + 'lib/ui/bottom_sheets/generic/generic_sheet_model.dart.stk'; -import '{{{widgetTestHelpersImport}}}'; +const String kBottomSheetEmptyTemplateGenericSheetModelContent = ''' +import 'package:stacked/stacked.dart'; -void main() { - group('{{widgetModelName}} Tests -', () { - setUp(() => registerServices()); - tearDown(() => locator.reset()); - }); -} +class {{sheetModelName}} extends BaseViewModel {} '''; // -------------------------------------------------- -// -------- GenericUseModel Template Data ---------- -const String kWidgetEmptyTemplateGenericUseModelPath = - 'lib/ui/widgets/common/generic/generic_use_model.dart.stk'; +// -------- GenericSheetUseModel Template Data ---------- -const String kWidgetEmptyTemplateGenericUseModelContent = ''' +const String kBottomSheetEmptyTemplateGenericSheetUseModelPath = + 'lib/ui/bottom_sheets/generic/generic_sheet_use_model.dart.stk'; + +const String kBottomSheetEmptyTemplateGenericSheetUseModelContent = ''' import 'package:flutter/material.dart'; +import 'package:{{packageName}}/ui/common/app_colors.dart'; +import 'package:{{packageName}}/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; -import '{{widgetModelFileName}}'; +import '{{sheetModelFilename}}'; -class {{widgetName}} extends StackedView<{{widgetModelName}}> { - const {{widgetName}}({super.key}); +class {{sheetName}} extends StackedView<{{sheetModelName}}> { + final Function(SheetResponse response)? completer; + final SheetRequest request; + const {{sheetName}}({ + Key? key, + required this.completer, + required this.request, + }) : super(key: key); @override Widget builder( BuildContext context, - {{widgetModelName}} viewModel, + {{sheetModelName}} viewModel, Widget? child, ) { - return const SizedBox.shrink(); - } - - @override - {{widgetModelName}} viewModelBuilder( - BuildContext context, - ) => {{widgetModelName}}(); -} -'''; - -// -------------------------------------------------- - -// -------- Generic Template Data ---------- - -const String kWidgetEmptyTemplateGenericPath = - 'lib/ui/widgets/common/generic/generic.dart.stk'; - -const String kWidgetEmptyTemplateGenericContent = ''' -import 'package:flutter/material.dart'; - -class {{widgetName}} extends StatelessWidget { - const {{widgetName}}({super.key}); + return Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + request.title ?? 'Hello Stacked Sheet!!', + style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), + ), + if (request.description != null) ...[ + verticalSpaceTiny, + Text( + request.description!, + style: const TextStyle(fontSize: 14, color: kcMediumGrey), + maxLines: 3, + softWrap: true, + ), + ], + verticalSpaceLarge, + ], + ), + ); + } @override - Widget build(BuildContext context) { - return const SizedBox.shrink(); - } + {{sheetModelName}} viewModelBuilder(BuildContext context) => + {{sheetModelName}}(); } '''; // -------------------------------------------------- -// -------- GenericModel Template Data ---------- - -const String kWidgetEmptyTemplateGenericModelPath = - 'lib/ui/widgets/common/generic/generic_model.dart.stk'; - -const String kWidgetEmptyTemplateGenericModelContent = ''' -import 'package:stacked/stacked.dart'; - -class {{widgetModelName}} extends BaseViewModel {} -'''; - -// -------------------------------------------------- -// -------- GenericDialogModelTest Template Data ---------- +// -------- GenericSheetModelTest Template Data ---------- -const String kDialogEmptyTemplateGenericDialogModelTestPath = - 'test/viewmodels/generic_dialog_model_test.dart.stk'; +const String kBottomSheetEmptyTemplateGenericSheetModelTestPath = + 'test/viewmodels/generic_sheet_model_test.dart.stk'; -const String kDialogEmptyTemplateGenericDialogModelTestContent = ''' +const String kBottomSheetEmptyTemplateGenericSheetModelTestContent = ''' import 'package:flutter_test/flutter_test.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; import '{{{viewTestHelpersImport}}}'; void main() { - group('{{dialogModelName}} Tests -', () { + group('{{sheetModelName}} Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); @@ -2965,37 +3102,21 @@ void main() { // -------------------------------------------------- -// -------- GenericDialogModel Template Data ---------- - -const String kDialogEmptyTemplateGenericDialogModelPath = - 'lib/ui/dialogs/generic/generic_dialog_model.dart.stk'; - -const String kDialogEmptyTemplateGenericDialogModelContent = ''' -import 'package:stacked/stacked.dart'; - -class {{dialogModelName}} extends BaseViewModel {} - -'''; - -// -------------------------------------------------- -// -------- GenericDialogUseModel Template Data ---------- +// -------- GenericDialog Template Data ---------- -const String kDialogEmptyTemplateGenericDialogUseModelPath = - 'lib/ui/dialogs/generic/generic_dialog_use_model.dart.stk'; +const String kDialogEmptyTemplateGenericDialogPath = + 'lib/ui/dialogs/generic/generic_dialog.dart.stk'; -const String kDialogEmptyTemplateGenericDialogUseModelContent = ''' +const String kDialogEmptyTemplateGenericDialogContent = ''' import 'package:flutter/material.dart'; import 'package:{{packageName}}/ui/common/app_colors.dart'; import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; -import '{{dialogModelFilename}}'; - const double _graphicSize = 60; -class {{dialogName}} extends StackedView<{{dialogModelName}}> { +class {{dialogName}} extends StatelessWidget { final DialogRequest request; final Function(DialogResponse) completer; @@ -3006,11 +3127,7 @@ class {{dialogName}} extends StackedView<{{dialogModelName}}> { }) : super(key: key); @override - Widget builder( - BuildContext context, - {{dialogModelName}} viewModel, - Widget? child, - ) { + Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), backgroundColor: Colors.white, @@ -3089,30 +3206,45 @@ class {{dialogName}} extends StackedView<{{dialogModelName}}> { ), ); } - - @override - {{dialogModelName}} viewModelBuilder(BuildContext context) => - {{dialogModelName}}(); } '''; // -------------------------------------------------- -// -------- GenericDialog Template Data ---------- -const String kDialogEmptyTemplateGenericDialogPath = - 'lib/ui/dialogs/generic/generic_dialog.dart.stk'; +// -------- GenericDialogModel Template Data ---------- -const String kDialogEmptyTemplateGenericDialogContent = ''' +const String kDialogEmptyTemplateGenericDialogModelPath = + 'lib/ui/dialogs/generic/generic_dialog_model.dart.stk'; + +const String kDialogEmptyTemplateGenericDialogModelContent = ''' +import 'package:stacked/stacked.dart'; + +class {{dialogModelName}} extends BaseViewModel {} + +'''; + +// -------------------------------------------------- + + +// -------- GenericDialogUseModel Template Data ---------- + +const String kDialogEmptyTemplateGenericDialogUseModelPath = + 'lib/ui/dialogs/generic/generic_dialog_use_model.dart.stk'; + +const String kDialogEmptyTemplateGenericDialogUseModelContent = ''' import 'package:flutter/material.dart'; import 'package:{{packageName}}/ui/common/app_colors.dart'; import 'package:{{packageName}}/ui/common/ui_helpers.dart'; +import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; +import '{{dialogModelFilename}}'; + const double _graphicSize = 60; -class {{dialogName}} extends StatelessWidget { +class {{dialogName}} extends StackedView<{{dialogModelName}}> { final DialogRequest request; final Function(DialogResponse) completer; @@ -3123,7 +3255,11 @@ class {{dialogName}} extends StatelessWidget { }) : super(key: key); @override - Widget build(BuildContext context) { + Widget builder( + BuildContext context, + {{dialogModelName}} viewModel, + Widget? child, + ) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), backgroundColor: Colors.white, @@ -3202,25 +3338,30 @@ class {{dialogName}} extends StatelessWidget { ), ); } + + @override + {{dialogModelName}} viewModelBuilder(BuildContext context) => + {{dialogModelName}}(); } '''; // -------------------------------------------------- -// -------- GenericViewmodelTest Template Data ---------- -const String kViewEmptyTemplateGenericViewmodelTestPath = - 'test/viewmodels/generic_viewmodel_test.dart.stk'; +// -------- GenericDialogModelTest Template Data ---------- -const String kViewEmptyTemplateGenericViewmodelTestContent = ''' +const String kDialogEmptyTemplateGenericDialogModelTestPath = + 'test/viewmodels/generic_dialog_model_test.dart.stk'; + +const String kDialogEmptyTemplateGenericDialogModelTestContent = ''' import 'package:flutter_test/flutter_test.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; import '{{{viewTestHelpersImport}}}'; void main() { - group('{{viewModelName}} Tests -', () { + group('{{dialogModelName}} Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); @@ -3230,19 +3371,44 @@ void main() { // -------------------------------------------------- -// -------- GenericViewmodel Template Data ---------- -const String kViewEmptyTemplateGenericViewmodelPath = - 'lib/ui/views/generic/generic_viewmodel.dart.stk'; +// -------- GenericService Template Data ---------- -const String kViewEmptyTemplateGenericViewmodelContent = ''' -import 'package:stacked/stacked.dart'; +const String kServiceEmptyTemplateGenericServicePath = + 'lib/services/generic_service.dart.stk'; + +const String kServiceEmptyTemplateGenericServiceContent = ''' +class {{serviceName}} { + +} +'''; + +// -------------------------------------------------- + + +// -------- GenericServiceTest Template Data ---------- + +const String kServiceEmptyTemplateGenericServiceTestPath = + 'test/services/generic_service_test.dart.stk'; + +const String kServiceEmptyTemplateGenericServiceTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; + +import '{{{serviceTestHelpersImport}}}'; + +void main() { + group('{{serviceName}}Test -', () { + setUp(() => {{registerMocksFunction}}()); + tearDown(() => {{locatorName}}.reset()); + }); +} -class {{viewModelName}} extends BaseViewModel {} '''; // -------------------------------------------------- + // -------- GenericView Template Data ---------- const String kViewEmptyTemplateGenericViewPath = @@ -3267,6 +3433,7 @@ class {{viewName}} extends StackedView<{{viewModelName}}> { backgroundColor: Theme.of(context).colorScheme.background, body: Container( padding: const EdgeInsets.only(left: 25.0, right: 25.0), + child: const Center(child: Text("{{viewName}}")), ), ); } @@ -3280,6 +3447,21 @@ class {{viewName}} extends StackedView<{{viewModelName}}> { // -------------------------------------------------- + +// -------- GenericViewmodel Template Data ---------- + +const String kViewEmptyTemplateGenericViewmodelPath = + 'lib/ui/views/generic/generic_viewmodel.dart.stk'; + +const String kViewEmptyTemplateGenericViewmodelContent = ''' +import 'package:stacked/stacked.dart'; + +class {{viewModelName}} extends BaseViewModel {} +'''; + +// -------------------------------------------------- + + // -------- GenericViewV1 Template Data ---------- const String kViewEmptyTemplateGenericViewV1Path = @@ -3311,12 +3493,13 @@ class {{viewName}} extends StatelessWidget { // -------------------------------------------------- + // -------- GenericViewmodelTest Template Data ---------- -const String kViewWebTemplateGenericViewmodelTestPath = +const String kViewEmptyTemplateGenericViewmodelTestPath = 'test/viewmodels/generic_viewmodel_test.dart.stk'; -const String kViewWebTemplateGenericViewmodelTestContent = ''' +const String kViewEmptyTemplateGenericViewmodelTestContent = ''' import 'package:flutter_test/flutter_test.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; @@ -3326,95 +3509,14 @@ void main() { group('{{viewModelName}} Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); - }); -} - -'''; - -// -------------------------------------------------- - -// -------- GenericViewmodel Template Data ---------- - -const String kViewWebTemplateGenericViewmodelPath = - 'lib/ui/views/generic/generic_viewmodel.dart.stk'; - -const String kViewWebTemplateGenericViewmodelContent = ''' -import 'package:stacked/stacked.dart'; - -class {{viewModelName}} extends BaseViewModel { -} -'''; - -// -------------------------------------------------- - -// -------- GenericViewMobile Template Data ---------- - -const String kViewWebTemplateGenericViewMobilePath = - 'lib/ui/views/generic/generic_view.mobile.dart.stk'; - -const String kViewWebTemplateGenericViewMobileContent = ''' -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; - -import '{{viewModelFileName}}'; - -class {{viewName}}Mobile extends ViewModelWidget<{{viewModelName}}> { - const {{viewName}}Mobile({super.key}); - - @override - Widget build(BuildContext context, {{viewModelName}} viewModel) { - return const Scaffold( - body: Center( - child: Text( - 'Hello, MOBILE UI!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - ), - ); - } -} - -'''; - -// -------------------------------------------------- - -// -------- GenericViewTablet Template Data ---------- - -const String kViewWebTemplateGenericViewTabletPath = - 'lib/ui/views/generic/generic_view.tablet.dart.stk'; - -const String kViewWebTemplateGenericViewTabletContent = ''' -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; - -import '{{viewModelFileName}}'; - -class {{viewName}}Tablet extends ViewModelWidget<{{viewModelName}}> { - const {{viewName}}Tablet({super.key}); - - @override - Widget build(BuildContext context, {{viewModelName}} viewModel) { - return const Scaffold( - body: Center( - child: Text( - 'Hello, TABLET UI!', - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.w900, - ), - ), - ), - ); - } + }); } '''; // -------------------------------------------------- + // -------- GenericView Template Data ---------- const String kViewWebTemplateGenericViewPath = @@ -3457,6 +3559,7 @@ class {{viewName}} extends StackedView<{{viewModelName}}> { // -------------------------------------------------- + // -------- GenericViewDesktop Template Data ---------- const String kViewWebTemplateGenericViewDesktopPath = @@ -3476,7 +3579,7 @@ class {{viewName}}Desktop extends ViewModelWidget<{{viewModelName}}> { return const Scaffold( body: Center( child: Text( - 'Hello, DESKTOP UI!', + 'Hello, DESKTOP UI - {{viewName}}!', style: TextStyle( fontSize: 35, fontWeight: FontWeight.w900, @@ -3491,54 +3594,105 @@ class {{viewName}}Desktop extends ViewModelWidget<{{viewModelName}}> { // -------------------------------------------------- -// -------- GenericServiceTest Template Data ---------- -const String kServiceEmptyTemplateGenericServiceTestPath = - 'test/services/generic_service_test.dart.stk'; +// -------- GenericViewMobile Template Data ---------- -const String kServiceEmptyTemplateGenericServiceTestContent = ''' -import 'package:flutter_test/flutter_test.dart'; -import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; +const String kViewWebTemplateGenericViewMobilePath = + 'lib/ui/views/generic/generic_view.mobile.dart.stk'; -import '{{{serviceTestHelpersImport}}}'; +const String kViewWebTemplateGenericViewMobileContent = ''' +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; -void main() { - group('{{serviceName}}Test -', () { - setUp(() => {{registerMocksFunction}}()); - tearDown(() => {{locatorName}}.reset()); - }); +import '{{viewModelFileName}}'; + +class {{viewName}}Mobile extends ViewModelWidget<{{viewModelName}}> { + const {{viewName}}Mobile({super.key}); + + @override + Widget build(BuildContext context, {{viewModelName}} viewModel) { + return const Scaffold( + body: Center( + child: Text( + 'Hello, MOBILE UI - {{viewName}}!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + ), + ); + } } '''; // -------------------------------------------------- -// -------- GenericService Template Data ---------- -const String kServiceEmptyTemplateGenericServicePath = - 'lib/services/generic_service.dart.stk'; +// -------- GenericViewTablet Template Data ---------- -const String kServiceEmptyTemplateGenericServiceContent = ''' -class {{serviceName}} { +const String kViewWebTemplateGenericViewTabletPath = + 'lib/ui/views/generic/generic_view.tablet.dart.stk'; + +const String kViewWebTemplateGenericViewTabletContent = ''' +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; + +import '{{viewModelFileName}}'; + +class {{viewName}}Tablet extends ViewModelWidget<{{viewModelName}}> { + const {{viewName}}Tablet({super.key}); + + @override + Widget build(BuildContext context, {{viewModelName}} viewModel) { + return const Scaffold( + body: Center( + child: Text( + 'Hello, TABLET UI - {{viewName}}!', + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.w900, + ), + ), + ), + ); + } +} + +'''; + +// -------------------------------------------------- + + +// -------- GenericViewmodel Template Data ---------- + +const String kViewWebTemplateGenericViewmodelPath = + 'lib/ui/views/generic/generic_viewmodel.dart.stk'; + +const String kViewWebTemplateGenericViewmodelContent = ''' +import 'package:stacked/stacked.dart'; +class {{viewModelName}} extends BaseViewModel { } '''; // -------------------------------------------------- -// -------- GenericSheetModelTest Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetModelTestPath = - 'test/viewmodels/generic_sheet_model_test.dart.stk'; +// -------- GenericViewmodelTest Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetModelTestContent = ''' +const String kViewWebTemplateGenericViewmodelTestPath = + 'test/viewmodels/generic_viewmodel_test.dart.stk'; + +const String kViewWebTemplateGenericViewmodelTestContent = ''' import 'package:flutter_test/flutter_test.dart'; import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; import '{{{viewTestHelpersImport}}}'; void main() { - group('{{sheetModelName}} Tests -', () { + group('{{viewModelName}} Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); @@ -3548,145 +3702,95 @@ void main() { // -------------------------------------------------- -// -------- GenericSheetModel Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetModelPath = - 'lib/ui/bottom_sheets/generic/generic_sheet_model.dart.stk'; +// -------- Generic Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetModelContent = ''' -import 'package:stacked/stacked.dart'; +const String kWidgetEmptyTemplateGenericPath = + 'lib/ui/widgets/common/generic/generic.dart.stk'; -class {{sheetModelName}} extends BaseViewModel {} +const String kWidgetEmptyTemplateGenericContent = ''' +import 'package:flutter/material.dart'; + +class {{widgetName}} extends StatelessWidget { + const {{widgetName}}({super.key}); + + @override + Widget build(BuildContext context) { + return const SizedBox.shrink(); + } +} '''; // -------------------------------------------------- -// -------- GenericSheetUseModel Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetUseModelPath = - 'lib/ui/bottom_sheets/generic/generic_sheet_use_model.dart.stk'; +// -------- GenericModel Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetUseModelContent = ''' +const String kWidgetEmptyTemplateGenericModelPath = + 'lib/ui/widgets/common/generic/generic_model.dart.stk'; + +const String kWidgetEmptyTemplateGenericModelContent = ''' +import 'package:stacked/stacked.dart'; + +class {{widgetModelName}} extends BaseViewModel {} +'''; + +// -------------------------------------------------- + + +// -------- GenericUseModel Template Data ---------- + +const String kWidgetEmptyTemplateGenericUseModelPath = + 'lib/ui/widgets/common/generic/generic_use_model.dart.stk'; + +const String kWidgetEmptyTemplateGenericUseModelContent = ''' import 'package:flutter/material.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; -import 'package:stacked_services/stacked_services.dart'; -import '{{sheetModelFilename}}'; +import '{{widgetModelFileName}}'; -class {{sheetName}} extends StackedView<{{sheetModelName}}> { - final Function(SheetResponse response)? completer; - final SheetRequest request; - const {{sheetName}}({ - Key? key, - required this.completer, - required this.request, - }) : super(key: key); +class {{widgetName}} extends StackedView<{{widgetModelName}}> { + const {{widgetName}}({super.key}); @override Widget builder( BuildContext context, - {{sheetModelName}} viewModel, + {{widgetModelName}} viewModel, Widget? child, ) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - request.title ?? 'Hello Stacked Sheet!!', - style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), - ), - if (request.description != null) ...[ - verticalSpaceTiny, - Text( - request.description!, - style: const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - ], - verticalSpaceLarge, - ], - ), - ); + return const SizedBox.shrink(); } @override - {{sheetModelName}} viewModelBuilder(BuildContext context) => - {{sheetModelName}}(); + {{widgetModelName}} viewModelBuilder( + BuildContext context, + ) => {{widgetModelName}}(); } - '''; // -------------------------------------------------- -// -------- GenericSheet Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetPath = - 'lib/ui/bottom_sheets/generic/generic_sheet.dart.stk'; +// -------- GenericModelTest Template Data ---------- -const String kBottomSheetEmptyTemplateGenericSheetContent = ''' -import 'package:flutter/material.dart'; -import 'package:{{packageName}}/ui/common/app_colors.dart'; -import 'package:{{packageName}}/ui/common/ui_helpers.dart'; -import 'package:stacked_services/stacked_services.dart'; +const String kWidgetEmptyTemplateGenericModelTestPath = + 'test/widget_models/generic_model_test.dart.stk'; -class {{sheetName}} extends StatelessWidget { - final Function(SheetResponse response)? completer; - final SheetRequest request; - const {{sheetName}}({ - Key? key, - required this.completer, - required this.request, - }) : super(key: key); +const String kWidgetEmptyTemplateGenericModelTestContent = ''' +import 'package:flutter_test/flutter_test.dart'; +import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}'; - @override - Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - request.title ?? 'Hello Stacked Sheet!!', - style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), - ), - if (request.description != null) ...[ - verticalSpaceTiny, - Text( - request.description!, - style: const TextStyle(fontSize: 14, color: kcMediumGrey), - maxLines: 3, - softWrap: true, - ), - ], - verticalSpaceLarge, - ], - ), - ); - } +import '{{{widgetTestHelpersImport}}}'; + +void main() { + group('{{widgetModelName}} Tests -', () { + setUp(() => registerServices()); + tearDown(() => locator.reset()); + }); } '''; // -------------------------------------------------- + diff --git a/test/helpers/test_helpers.mocks.dart b/test/helpers/test_helpers.mocks.dart index 1ea99ea..0d769b5 100644 --- a/test/helpers/test_helpers.mocks.dart +++ b/test/helpers/test_helpers.mocks.dart @@ -1,9 +1,7 @@ -// Mocks generated by Mockito 5.4.1 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in stacked_cli/test/helpers/test_helpers.dart. // Do not manually edit this file. -// @dart=2.19 - // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i6; import 'dart:io' as _i2; @@ -11,25 +9,28 @@ import 'dart:typed_data' as _i7; import 'package:ansicolor/ansicolor.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i8; import 'package:pubspec_yaml/pubspec_yaml.dart' as _i3; -import 'package:stacked_cli/src/models/template_models.dart' as _i10; -import 'package:stacked_cli/src/services/colorized_log_service.dart' as _i14; -import 'package:stacked_cli/src/services/config_service.dart' as _i15; +import 'package:stacked_cli/src/models/template_models.dart' as _i11; +import 'package:stacked_cli/src/services/colorized_log_service.dart' as _i15; +import 'package:stacked_cli/src/services/config_service.dart' as _i16; import 'package:stacked_cli/src/services/file_service.dart' as _i5; -import 'package:stacked_cli/src/services/path_service.dart' as _i8; -import 'package:stacked_cli/src/services/posthog_service.dart' as _i17; -import 'package:stacked_cli/src/services/process_service.dart' as _i16; -import 'package:stacked_cli/src/services/pub_service.dart' as _i18; -import 'package:stacked_cli/src/services/pubspec_service.dart' as _i13; -import 'package:stacked_cli/src/services/template_service.dart' as _i9; -import 'package:stacked_cli/src/templates/template_helper.dart' as _i12; +import 'package:stacked_cli/src/services/path_service.dart' as _i9; +import 'package:stacked_cli/src/services/posthog_service.dart' as _i18; +import 'package:stacked_cli/src/services/process_service.dart' as _i17; +import 'package:stacked_cli/src/services/pub_service.dart' as _i19; +import 'package:stacked_cli/src/services/pubspec_service.dart' as _i14; +import 'package:stacked_cli/src/services/template_service.dart' as _i10; +import 'package:stacked_cli/src/templates/template_helper.dart' as _i13; import 'package:stacked_cli/src/templates/template_render_functions.dart' - as _i11; + as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -67,16 +68,6 @@ class _FakeAnsiPen_2 extends _i1.SmartFake implements _i4.AnsiPen { ); } -class _FakeProcessResult_3 extends _i1.SmartFake implements _i2.ProcessResult { - _FakeProcessResult_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [FileService]. /// /// See the documentation for Mockito's code generation for more information. @@ -106,6 +97,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future writeDataFile({ required _i2.File? file, @@ -131,6 +123,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future deleteFile({ required String? filePath, @@ -148,6 +141,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future deleteFolder({required String? directoryPath}) => (super.noSuchMethod( @@ -159,6 +153,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future fileExists({required String? filePath}) => (super.noSuchMethod( @@ -170,6 +165,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(false), returnValueForMissingStub: _i6.Future.value(false), ) as _i6.Future); + @override _i6.Future readFileAsString({required String? filePath}) => (super.noSuchMethod( @@ -178,9 +174,25 @@ class MockFileService extends _i1.Mock implements _i5.FileService { [], {#filePath: filePath}, ), - returnValue: _i6.Future.value(''), - returnValueForMissingStub: _i6.Future.value(''), + returnValue: _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #readFileAsString, + [], + {#filePath: filePath}, + ), + )), + returnValueForMissingStub: + _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #readFileAsString, + [], + {#filePath: filePath}, + ), + )), ) as _i6.Future); + @override _i6.Future<_i7.Uint8List> readAsBytes({required String? filePath}) => (super.noSuchMethod( @@ -193,6 +205,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValueForMissingStub: _i6.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), ) as _i6.Future<_i7.Uint8List>); + @override _i6.Future> readFileAsLines({required String? filePath}) => (super.noSuchMethod( @@ -204,6 +217,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future>.value([]), returnValueForMissingStub: _i6.Future>.value([]), ) as _i6.Future>); + @override _i6.Future removeSpecificFileLines({ required String? filePath, @@ -223,6 +237,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future removeLinesOnFile({ required String? filePath, @@ -240,6 +255,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future removeTestHelperFunctionFromFile({ required String? filePath, @@ -257,6 +273,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future> getFilesInDirectory( {required String? directoryPath}) => @@ -271,6 +288,7 @@ class MockFileService extends _i1.Mock implements _i5.FileService { returnValueForMissingStub: _i6.Future>.value( <_i2.FileSystemEntity>[]), ) as _i6.Future>); + @override _i6.Future> getFoldersInDirectory( {required String? directoryPath}) => @@ -288,19 +306,33 @@ class MockFileService extends _i1.Mock implements _i5.FileService { /// A class which mocks [PathService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPathService extends _i1.Mock implements _i8.PathService { +class MockPathService extends _i1.Mock implements _i9.PathService { @override String get templatesPath => (super.noSuchMethod( Invocation.getter(#templatesPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#templatesPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#templatesPath), + ), ) as String); + @override String get separator => (super.noSuchMethod( Invocation.getter(#separator), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#separator), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#separator), + ), ) as String); + @override _i2.Directory get configHome => (super.noSuchMethod( Invocation.getter(#configHome), @@ -313,6 +345,7 @@ class MockPathService extends _i1.Mock implements _i8.PathService { Invocation.getter(#configHome), ), ) as _i2.Directory); + @override String join( String? part1, [ @@ -338,24 +371,67 @@ class MockPathService extends _i1.Mock implements _i8.PathService { part8, ], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #join, + [ + part1, + part2, + part3, + part4, + part5, + part6, + part7, + part8, + ], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #join, + [ + part1, + part2, + part3, + part4, + part5, + part6, + part7, + part8, + ], + ), + ), ) as String); + @override String basename(String? path) => (super.noSuchMethod( Invocation.method( #basename, [path], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #basename, + [path], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #basename, + [path], + ), + ), ) as String); } /// A class which mocks [TemplateService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTemplateService extends _i1.Mock implements _i9.TemplateService { +class MockTemplateService extends _i1.Mock implements _i10.TemplateService { @override _i6.Future compileTemplateInformation() => (super.noSuchMethod( Invocation.method( @@ -365,6 +441,7 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future renderTemplate({ required String? templateName, @@ -394,9 +471,10 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future writeOutTemplateFiles({ - required _i10.StackedTemplate? template, + required _i11.StackedTemplate? template, required String? templateName, required String? name, String? outputFolder, @@ -419,6 +497,7 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override String getTemplateOutputPath({ required String? inputTemplatePath, @@ -435,9 +514,32 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { #outputFolder: outputFolder, }, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #getTemplateOutputPath, + [], + { + #inputTemplatePath: inputTemplatePath, + #name: name, + #outputFolder: outputFolder, + }, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #getTemplateOutputPath, + [], + { + #inputTemplatePath: inputTemplatePath, + #name: name, + #outputFolder: outputFolder, + }, + ), + ), ) as String); + @override String renderContentForTemplate({ required String? content, @@ -454,14 +556,37 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { #name: name, }, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #renderContentForTemplate, + [], + { + #content: content, + #templateName: templateName, + #name: name, + }, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #renderContentForTemplate, + [], + { + #content: content, + #templateName: templateName, + #name: name, + }, + ), + ), ) as String); + @override Map getTemplateRenderData({ required String? templateName, required String? name, - Map? testRenderFunctions, + Map? testRenderFunctions, }) => (super.noSuchMethod( Invocation.method( @@ -476,6 +601,7 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: {}, returnValueForMissingStub: {}, ) as Map); + @override Map applyGlobalTemplateProperties( Map? renderTemplate, { @@ -490,9 +616,10 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: {}, returnValueForMissingStub: {}, ) as Map); + @override _i6.Future modifyExistingFiles({ - required _i10.StackedTemplate? template, + required _i11.StackedTemplate? template, required String? templateName, required String? name, String? outputPath, @@ -511,6 +638,7 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override String templateModificationName({ required String? modificationName, @@ -527,9 +655,32 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { #templateName: templateName, }, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #templateModificationName, + [], + { + #modificationName: modificationName, + #name: name, + #templateName: templateName, + }, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #templateModificationName, + [], + { + #modificationName: modificationName, + #name: name, + #templateName: templateName, + }, + ), + ), ) as String); + @override String templateModificationFileContent({ required String? fileContent, @@ -550,9 +701,36 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { #templateName: templateName, }, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #templateModificationFileContent, + [], + { + #fileContent: fileContent, + #modificationTemplate: modificationTemplate, + #modificationIdentifier: modificationIdentifier, + #name: name, + #templateName: templateName, + }, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #templateModificationFileContent, + [], + { + #fileContent: fileContent, + #modificationTemplate: modificationTemplate, + #modificationIdentifier: modificationIdentifier, + #name: name, + #templateName: templateName, + }, + ), + ), ) as String); + @override bool shouldAppendTemplate(String? relativeOutputPath) => (super.noSuchMethod( Invocation.method( @@ -567,13 +745,20 @@ class MockTemplateService extends _i1.Mock implements _i9.TemplateService { /// A class which mocks [TemplateHelper]. /// /// See the documentation for Mockito's code generation for more information. -class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { +class MockTemplateHelper extends _i1.Mock implements _i13.TemplateHelper { @override String get packageDescription => (super.noSuchMethod( Invocation.getter(#packageDescription), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#packageDescription), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#packageDescription), + ), ) as String); + @override set packageDescription(String? _packageDescription) => super.noSuchMethod( Invocation.setter( @@ -582,12 +767,20 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { ), returnValueForMissingStub: null, ); + @override String get templatesPath => (super.noSuchMethod( Invocation.getter(#templatesPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#templatesPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#templatesPath), + ), ) as String); + @override List<_i2.FileSystemEntity> getFilesWithExtension({ required List<_i2.FileSystemEntity>? filePaths, @@ -605,6 +798,7 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { returnValue: <_i2.FileSystemEntity>[], returnValueForMissingStub: <_i2.FileSystemEntity>[], ) as List<_i2.FileSystemEntity>); + @override List<_i2.FileSystemEntity> getFilesThatContainSection({ required List<_i2.FileSystemEntity>? files, @@ -622,6 +816,7 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { returnValue: <_i2.FileSystemEntity>[], returnValueForMissingStub: <_i2.FileSystemEntity>[], ) as List<_i2.FileSystemEntity>); + @override String getTemplateFileNameOnly( {required _i2.FileSystemEntity? templateFilePath}) => @@ -631,9 +826,24 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { [], {#templateFilePath: templateFilePath}, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #getTemplateFileNameOnly, + [], + {#templateFilePath: templateFilePath}, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #getTemplateFileNameOnly, + [], + {#templateFilePath: templateFilePath}, + ), + ), ) as String); + @override String getTemplateFolderName({required String? templateFilePath}) => (super.noSuchMethod( @@ -642,9 +852,24 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { [], {#templateFilePath: templateFilePath}, ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #getTemplateFolderName, + [], + {#templateFilePath: templateFilePath}, + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #getTemplateFolderName, + [], + {#templateFilePath: templateFilePath}, + ), + ), ) as String); + @override _i6.Future> getTemplateTypesFromTemplate( {required String? templateDirectoryPath}) => @@ -657,6 +882,7 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { returnValue: _i6.Future>.value([]), returnValueForMissingStub: _i6.Future>.value([]), ) as _i6.Future>); + @override _i6.Future> getFilesForTemplate({ required String? templateName, @@ -678,8 +904,9 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { returnValueForMissingStub: _i6.Future>.value( <_i2.FileSystemEntity>[]), ) as _i6.Future>); + @override - _i6.Future> + _i6.Future> getTemplateModificationsToApply({ required String? templateName, required String? templateType, @@ -693,14 +920,15 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { #templateType: templateType, }, ), - returnValue: _i6.Future>.value( - <_i10.CompiledFileModification>[]), + returnValue: _i6.Future>.value( + <_i11.CompiledFileModification>[]), returnValueForMissingStub: - _i6.Future>.value( - <_i10.CompiledFileModification>[]), - ) as _i6.Future>); + _i6.Future>.value( + <_i11.CompiledFileModification>[]), + ) as _i6.Future>); + @override - _i6.Future> getTemplateItemsToRender({ + _i6.Future> getTemplateItemsToRender({ required String? templateName, required String? templateType, }) => @@ -713,18 +941,18 @@ class MockTemplateHelper extends _i1.Mock implements _i12.TemplateHelper { #templateType: templateType, }, ), - returnValue: _i6.Future>.value( - <_i10.CompliledTemplateFile>[]), + returnValue: _i6.Future>.value( + <_i11.CompliledTemplateFile>[]), returnValueForMissingStub: - _i6.Future>.value( - <_i10.CompliledTemplateFile>[]), - ) as _i6.Future>); + _i6.Future>.value( + <_i11.CompliledTemplateFile>[]), + ) as _i6.Future>); } /// A class which mocks [PubspecService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPubspecService extends _i1.Mock implements _i13.PubspecService { +class MockPubspecService extends _i1.Mock implements _i14.PubspecService { @override _i3.PubspecYaml get pubspecYaml => (super.noSuchMethod( Invocation.getter(#pubspecYaml), @@ -737,6 +965,7 @@ class MockPubspecService extends _i1.Mock implements _i13.PubspecService { Invocation.getter(#pubspecYaml), ), ) as _i3.PubspecYaml); + @override set pubspecYaml(_i3.PubspecYaml? _pubspecYaml) => super.noSuchMethod( Invocation.setter( @@ -745,12 +974,20 @@ class MockPubspecService extends _i1.Mock implements _i13.PubspecService { ), returnValueForMissingStub: null, ); + @override String get getPackageName => (super.noSuchMethod( Invocation.getter(#getPackageName), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#getPackageName), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#getPackageName), + ), ) as String); + @override _i6.Future initialise({String? workingDirectory}) => (super.noSuchMethod( @@ -768,7 +1005,7 @@ class MockPubspecService extends _i1.Mock implements _i13.PubspecService { /// /// See the documentation for Mockito's code generation for more information. class MockColorizedLogService extends _i1.Mock - implements _i14.ColorizedLogService { + implements _i15.ColorizedLogService { @override _i4.AnsiPen get pen => (super.noSuchMethod( Invocation.getter(#pen), @@ -781,6 +1018,7 @@ class MockColorizedLogService extends _i1.Mock Invocation.getter(#pen), ), ) as _i4.AnsiPen); + @override set pen(_i4.AnsiPen? _pen) => super.noSuchMethod( Invocation.setter( @@ -789,6 +1027,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void coloredPrint( _i4.AnsiPen? pen, { @@ -802,6 +1041,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void fileOutput({ required _i5.FileModificationType? type, @@ -818,6 +1058,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void flutterOutput({required String? message}) => super.noSuchMethod( Invocation.method( @@ -827,6 +1068,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void stackedOutput({ required String? message, @@ -843,6 +1085,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void success({required String? message}) => super.noSuchMethod( Invocation.method( @@ -852,6 +1095,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void warn({required String? message}) => super.noSuchMethod( Invocation.method( @@ -861,6 +1105,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void info({required String? message}) => super.noSuchMethod( Invocation.method( @@ -870,6 +1115,7 @@ class MockColorizedLogService extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void error({required String? message}) => super.noSuchMethod( Invocation.method( @@ -884,151 +1130,295 @@ class MockColorizedLogService extends _i1.Mock /// A class which mocks [ConfigService]. /// /// See the documentation for Mockito's code generation for more information. -class MockConfigService extends _i1.Mock implements _i15.ConfigService { +class MockConfigService extends _i1.Mock implements _i16.ConfigService { @override bool get hasCustomConfig => (super.noSuchMethod( Invocation.getter(#hasCustomConfig), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override String get serviceImportPath => (super.noSuchMethod( Invocation.getter(#serviceImportPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#serviceImportPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#serviceImportPath), + ), ) as String); + @override String get servicePath => (super.noSuchMethod( Invocation.getter(#servicePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#servicePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#servicePath), + ), ) as String); + @override String get locatorName => (super.noSuchMethod( Invocation.getter(#locatorName), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#locatorName), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#locatorName), + ), ) as String); + @override String get registerMocksFunction => (super.noSuchMethod( Invocation.getter(#registerMocksFunction), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#registerMocksFunction), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#registerMocksFunction), + ), ) as String); + @override String get serviceTestHelpersImport => (super.noSuchMethod( Invocation.getter(#serviceTestHelpersImport), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#serviceTestHelpersImport), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#serviceTestHelpersImport), + ), ) as String); + @override String get bottomSheetsPath => (super.noSuchMethod( Invocation.getter(#bottomSheetsPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetsPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetsPath), + ), ) as String); + @override String get bottomSheetBuilderFilePath => (super.noSuchMethod( Invocation.getter(#bottomSheetBuilderFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetBuilderFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetBuilderFilePath), + ), ) as String); + @override String get bottomSheetTypeFilePath => (super.noSuchMethod( Invocation.getter(#bottomSheetTypeFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetTypeFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#bottomSheetTypeFilePath), + ), ) as String); + @override String get dialogsPath => (super.noSuchMethod( Invocation.getter(#dialogsPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#dialogsPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#dialogsPath), + ), ) as String); + @override String get dialogBuilderFilePath => (super.noSuchMethod( Invocation.getter(#dialogBuilderFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#dialogBuilderFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#dialogBuilderFilePath), + ), ) as String); + @override String get dialogTypeFilePath => (super.noSuchMethod( Invocation.getter(#dialogTypeFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#dialogTypeFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#dialogTypeFilePath), + ), ) as String); + @override String get stackedAppFilePath => (super.noSuchMethod( Invocation.getter(#stackedAppFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#stackedAppFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#stackedAppFilePath), + ), ) as String); + @override String get testHelpersFilePath => (super.noSuchMethod( Invocation.getter(#testHelpersFilePath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#testHelpersFilePath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#testHelpersFilePath), + ), ) as String); + @override String get testServicesPath => (super.noSuchMethod( Invocation.getter(#testServicesPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#testServicesPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#testServicesPath), + ), ) as String); + @override String get testViewsPath => (super.noSuchMethod( Invocation.getter(#testViewsPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#testViewsPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#testViewsPath), + ), ) as String); + @override String get viewImportPath => (super.noSuchMethod( Invocation.getter(#viewImportPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#viewImportPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#viewImportPath), + ), ) as String); + @override String get viewPath => (super.noSuchMethod( Invocation.getter(#viewPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#viewPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#viewPath), + ), ) as String); + @override String get viewTestHelpersImport => (super.noSuchMethod( Invocation.getter(#viewTestHelpersImport), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#viewTestHelpersImport), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#viewTestHelpersImport), + ), ) as String); + @override String get widgetPath => (super.noSuchMethod( Invocation.getter(#widgetPath), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#widgetPath), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#widgetPath), + ), ) as String); + @override String get widgetTestHelpersImport => (super.noSuchMethod( Invocation.getter(#widgetTestHelpersImport), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#widgetTestHelpersImport), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#widgetTestHelpersImport), + ), ) as String); + @override bool get v1 => (super.noSuchMethod( Invocation.getter(#v1), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override int get lineLength => (super.noSuchMethod( Invocation.getter(#lineLength), returnValue: 0, returnValueForMissingStub: 0, ) as int); + @override bool get preferWeb => (super.noSuchMethod( Invocation.getter(#preferWeb), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override _i6.Future findAndLoadConfigFile({String? configFilePath}) => (super.noSuchMethod( @@ -1040,6 +1430,7 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future composeAndLoadConfigFile({ String? configFilePath, @@ -1057,6 +1448,7 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future resolveConfigFile({String? configFilePath}) => (super.noSuchMethod( @@ -1065,9 +1457,25 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { [], {#configFilePath: configFilePath}, ), - returnValue: _i6.Future.value(''), - returnValueForMissingStub: _i6.Future.value(''), + returnValue: _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #resolveConfigFile, + [], + {#configFilePath: configFilePath}, + ), + )), + returnValueForMissingStub: + _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #resolveConfigFile, + [], + {#configFilePath: configFilePath}, + ), + )), ) as _i6.Future); + @override _i6.Future composeConfigFile({ String? configFilePath, @@ -1082,9 +1490,31 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { #projectPath: projectPath, }, ), - returnValue: _i6.Future.value(''), - returnValueForMissingStub: _i6.Future.value(''), + returnValue: _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #composeConfigFile, + [], + { + #configFilePath: configFilePath, + #projectPath: projectPath, + }, + ), + )), + returnValueForMissingStub: + _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #composeConfigFile, + [], + { + #configFilePath: configFilePath, + #projectPath: projectPath, + }, + ), + )), ) as _i6.Future); + @override _i6.Future loadConfig(String? configFilePath) => (super.noSuchMethod( Invocation.method( @@ -1094,15 +1524,29 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override String replaceCustomPaths(String? path) => (super.noSuchMethod( Invocation.method( #replaceCustomPaths, [path], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #replaceCustomPaths, + [path], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #replaceCustomPaths, + [path], + ), + ), ) as String); + @override String sanitizePath( String? path, [ @@ -1116,27 +1560,72 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { find, ], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #sanitizePath, + [ + path, + find, + ], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #sanitizePath, + [ + path, + find, + ], + ), + ), ) as String); + @override String getFilePathToHelpersAndMocks(String? path) => (super.noSuchMethod( Invocation.method( #getFilePathToHelpersAndMocks, [path], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #getFilePathToHelpersAndMocks, + [path], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #getFilePathToHelpersAndMocks, + [path], + ), + ), ) as String); + @override String exportConfig() => (super.noSuchMethod( Invocation.method( #exportConfig, [], ), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.method( + #exportConfig, + [], + ), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.method( + #exportConfig, + [], + ), + ), ) as String); + @override void setWidgetsPath(String? path) => super.noSuchMethod( Invocation.method( @@ -1150,7 +1639,7 @@ class MockConfigService extends _i1.Mock implements _i15.ConfigService { /// A class which mocks [ProcessService]. /// /// See the documentation for Mockito's code generation for more information. -class MockProcessService extends _i1.Mock implements _i16.ProcessService { +class MockProcessService extends _i1.Mock implements _i17.ProcessService { @override set formattingLineLength(String? length) => super.noSuchMethod( Invocation.setter( @@ -1159,6 +1648,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { ), returnValueForMissingStub: null, ); + @override _i6.Future runCreateApp({ required String? name, @@ -1180,6 +1670,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future runBuildRunner({ String? workingDirectory, @@ -1199,6 +1690,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future runPubGet({String? appName}) => (super.noSuchMethod( Invocation.method( @@ -1209,6 +1701,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future runFormat({ String? appName, @@ -1226,6 +1719,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future runPubGlobalActivate() => (super.noSuchMethod( Invocation.method( @@ -1235,6 +1729,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future> runPubGlobalList() => (super.noSuchMethod( Invocation.method( @@ -1244,6 +1739,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future>.value([]), returnValueForMissingStub: _i6.Future>.value([]), ) as _i6.Future>); + @override _i6.Future> runAnalyze({String? appName}) => (super.noSuchMethod( Invocation.method( @@ -1254,6 +1750,7 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { returnValue: _i6.Future>.value([]), returnValueForMissingStub: _i6.Future>.value([]), ) as _i6.Future>); + @override void logSuccessStatus(int? exitCode) => super.noSuchMethod( Invocation.method( @@ -1267,25 +1764,28 @@ class MockProcessService extends _i1.Mock implements _i16.ProcessService { /// A class which mocks [PosthogService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPosthogService extends _i1.Mock implements _i17.PosthogService { +class MockPosthogService extends _i1.Mock implements _i18.PosthogService { @override bool get verbose => (super.noSuchMethod( Invocation.getter(#verbose), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override bool get isFirstRun => (super.noSuchMethod( Invocation.getter(#isFirstRun), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override bool get enabled => (super.noSuchMethod( Invocation.getter(#enabled), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override _i6.Future enable(bool? value) => (super.noSuchMethod( Invocation.method( @@ -1295,6 +1795,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future init() => (super.noSuchMethod( Invocation.method( @@ -1304,6 +1805,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createAppEvent({ required String? name, @@ -1321,6 +1823,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createBottomSheetEvent({ required String? name, @@ -1338,6 +1841,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createDialogEvent({ required String? name, @@ -1355,6 +1859,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createServiceEvent({ required String? name, @@ -1372,6 +1877,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createViewEvent({ required String? name, @@ -1389,6 +1895,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future createWidgetEvent({ required String? name, @@ -1406,6 +1913,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future deleteDialogEvent({ required String? name, @@ -1423,6 +1931,25 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + + @override + _i6.Future deleteBottomsheetEvent({ + required String? name, + required List? arguments, + }) => + (super.noSuchMethod( + Invocation.method( + #deleteBottomsheetEvent, + [], + { + #name: name, + #arguments: arguments, + }, + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override _i6.Future deleteServiceEvent({ required String? name, @@ -1440,6 +1967,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future deleteViewEvent({ required String? name, @@ -1457,6 +1985,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future generateCodeEvent({required List? arguments}) => (super.noSuchMethod( @@ -1468,9 +1997,10 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future logExceptionEvent({ - _i17.Level? level = _i17.Level.error, + _i18.Level? level = _i18.Level.error, required String? runtimeType, required String? message, String? stackTrace = r'Not Available', @@ -1489,6 +2019,7 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override _i6.Future updateCliEvent() => (super.noSuchMethod( Invocation.method( @@ -1503,25 +2034,53 @@ class MockPosthogService extends _i1.Mock implements _i17.PosthogService { /// A class which mocks [PubService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPubService extends _i1.Mock implements _i18.PubService { +class MockPubService extends _i1.Mock implements _i19.PubService { @override _i6.Future getCurrentVersion() => (super.noSuchMethod( Invocation.method( #getCurrentVersion, [], ), - returnValue: _i6.Future.value(''), - returnValueForMissingStub: _i6.Future.value(''), + returnValue: _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #getCurrentVersion, + [], + ), + )), + returnValueForMissingStub: + _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #getCurrentVersion, + [], + ), + )), ) as _i6.Future); + @override _i6.Future getLatestVersion() => (super.noSuchMethod( Invocation.method( #getLatestVersion, [], ), - returnValue: _i6.Future.value(''), - returnValueForMissingStub: _i6.Future.value(''), + returnValue: _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #getLatestVersion, + [], + ), + )), + returnValueForMissingStub: + _i6.Future.value(_i8.dummyValue( + this, + Invocation.method( + #getLatestVersion, + [], + ), + )), ) as _i6.Future); + @override _i6.Future hasLatestVersion() => (super.noSuchMethod( Invocation.method( @@ -1531,21 +2090,23 @@ class MockPubService extends _i1.Mock implements _i18.PubService { returnValue: _i6.Future.value(false), returnValueForMissingStub: _i6.Future.value(false), ) as _i6.Future); + @override _i6.Future<_i2.ProcessResult> update() => (super.noSuchMethod( Invocation.method( #update, [], ), - returnValue: _i6.Future<_i2.ProcessResult>.value(_FakeProcessResult_3( + returnValue: _i6.Future<_i2.ProcessResult>.value( + _i8.dummyValue<_i2.ProcessResult>( this, Invocation.method( #update, [], ), )), - returnValueForMissingStub: - _i6.Future<_i2.ProcessResult>.value(_FakeProcessResult_3( + returnValueForMissingStub: _i6.Future<_i2.ProcessResult>.value( + _i8.dummyValue<_i2.ProcessResult>( this, Invocation.method( #update,