Skip to content

Commit

Permalink
fix: Web app template (#12)
Browse files Browse the repository at this point in the history
* Remove app_styles.dart dependency

* Compile templates
  • Loading branch information
ferrarafer authored Apr 18, 2023
1 parent 37f5770 commit 0e96bbe
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 194 deletions.
21 changes: 0 additions & 21 deletions lib/src/templates/app/web/lib/ui/common/app_styles.dart.stk

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:{{packageName}}/ui/common/app_colors.dart';
import 'package:{{packageName}}/ui/common/app_styles.dart';
import 'package:{{packageName}}/ui/common/ui_helpers.dart';
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
Expand All @@ -16,16 +15,23 @@ class UnknownViewDesktop extends ViewModelWidget<UnknownViewModel> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
style: TextStyle(
color: Colors.white,
fontSize: 80,
fontWeight: FontWeight.w800,
height: 0.95,
letterSpacing: 20.0,
),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
style: TextStyle(
color: Colors.white,
fontSize: 20,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:{{packageName}}/ui/common/app_colors.dart';
import 'package:{{packageName}}/ui/common/app_styles.dart';
import 'package:{{packageName}}/ui/common/ui_helpers.dart';
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
Expand All @@ -16,16 +15,23 @@ class UnknownViewMobile extends ViewModelWidget<UnknownViewModel> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
style: TextStyle(
color: Colors.white,
fontSize: 80,
fontWeight: FontWeight.w800,
height: 0.95,
letterSpacing: 20.0,
),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
style: TextStyle(
color: Colors.white,
fontSize: 20,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
Expand All @@ -35,4 +41,4 @@ class UnknownViewMobile extends ViewModelWidget<UnknownViewModel> {
),
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:{{packageName}}/ui/common/app_colors.dart';
import 'package:{{packageName}}/ui/common/app_styles.dart';
import 'package:{{packageName}}/ui/common/ui_helpers.dart';
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
Expand All @@ -16,16 +15,23 @@ class UnknownViewTablet extends ViewModelWidget<UnknownViewModel> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
style: TextStyle(
color: Colors.white,
fontSize: 80,
fontWeight: FontWeight.w800,
height: 0.95,
letterSpacing: 20.0,
),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
style: TextStyle(
color: Colors.white,
fontSize: 20,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
Expand Down
129 changes: 48 additions & 81 deletions lib/src/templates/compiled_template_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
relativeOutputPath: kAppWebTemplateUiHelpersPath,
content: kAppWebTemplateUiHelpersContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kAppWebTemplateAppStylesPath,
content: kAppWebTemplateAppStylesContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kAppWebTemplateAppStringsPath,
content: kAppWebTemplateAppStringsContent,
Expand Down Expand Up @@ -159,10 +155,6 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
relativeOutputPath: kAppWebTemplatePubspecYamlStkPath,
content: kAppWebTemplatePubspecYamlStkContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kAppWebTemplateSettingsJsonStkPath,
content: kAppWebTemplateSettingsJsonStkContent,
fileType: FileType.text),
],
modificationFiles: [],
),
Expand Down Expand Up @@ -285,21 +277,18 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
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',
),

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',
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',
),
],
],
),
},
'view': {
Expand Down Expand Up @@ -327,22 +316,18 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
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: [
Expand Down Expand Up @@ -376,22 +361,18 @@ Map<String, Map<String, StackedTemplate>> 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',
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',
),
],
],
),
},
'service': {
Expand All @@ -410,81 +391,71 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
ModificationFile(
relativeModificationPath: 'test/helpers/test_helpers.dart',
modificationIdentifier: '// @stacked-mock-create',
modificationTemplate:
'''Mock{{serviceName}} getAndRegister{{serviceName}}() {
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',
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',
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: '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}}/{{{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-mock-spec',
modificationTemplate:
'''MockSpec<{{serviceName}}>(onMissingStub: OnMissingStub.returnDefault),''',
modificationProblemError:
'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
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',
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',
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': {
'empty': StackedTemplate(
templateFiles: [
TemplateFile(
relativeOutputPath:
kBottomSheetEmptyTemplateGenericSheetModelTestPath,
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelTestPath,
content: kBottomSheetEmptyTemplateGenericSheetModelTestContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelPath,
content: kBottomSheetEmptyTemplateGenericSheetModelContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath:
kBottomSheetEmptyTemplateGenericSheetUseModelPath,
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetUseModelPath,
content: kBottomSheetEmptyTemplateGenericSheetUseModelContent,
fileType: FileType.text),
TemplateFile(
Expand All @@ -496,23 +467,19 @@ return service;
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',
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',
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',
),
],
],
),
},
};
Loading

0 comments on commit 0e96bbe

Please sign in to comment.