Skip to content

Commit

Permalink
feat: add Unknown view to Web template (#8)
Browse files Browse the repository at this point in the history
* Add UI constants

* Add UnknownView

* Redirect to UnknownView when route was not find

* Compile templates
  • Loading branch information
ferrarafer authored Apr 10, 2023
1 parent c84deca commit d54c8e9
Show file tree
Hide file tree
Showing 11 changed files with 640 additions and 107 deletions.
6 changes: 6 additions & 0 deletions lib/src/templates/app/web/lib/app/app.dart.stk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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
Expand All @@ -11,6 +12,11 @@ import 'package:stacked_services/stacked_services.dart';
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),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/templates/app/web/lib/ui/common/app_colors.dart.stk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'package:flutter/material.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;
21 changes: 21 additions & 0 deletions lib/src/templates/app/web/lib/ui/common/app_styles.dart.stk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';

TextStyle get ktsHeading1 => const TextStyle(
fontSize: 80,
height: 0.95,
fontWeight: FontWeight.w800,
);

TextStyle get ktsHeading2 => const TextStyle(
fontSize: 40,
height: 0.95,
fontWeight: FontWeight.w800,
);

TextStyle get ktsBodyRegular => const TextStyle(
fontSize: 15,
);

TextStyle get ktsBodyLarge => const TextStyle(
fontSize: 20,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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';

class UnknownView extends StackedView<UnknownViewModel> {
const UnknownView({super.key});

@override
Widget builder(
BuildContext context,
UnknownViewModel viewModel,
Widget? child,
) {
return ScreenTypeLayout.builder(
mobile: (_) => const UnknownViewMobile(),
tablet: (_) => const UnknownViewTablet(),
desktop: (_) => const UnknownViewDesktop(),
);
}

@override
UnknownViewModel viewModelBuilder(
BuildContext context,
) =>
UnknownViewModel();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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';

import 'unknown_viewmodel.dart';

class UnknownViewDesktop extends ViewModelWidget<UnknownViewModel> {
const UnknownViewDesktop({super.key});

@override
Widget build(BuildContext context, UnknownViewModel viewModel) {
return Scaffold(
backgroundColor: kcBackgroundColor,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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';

import 'unknown_viewmodel.dart';

class UnknownViewMobile extends ViewModelWidget<UnknownViewModel> {
const UnknownViewMobile({super.key});

@override
Widget build(BuildContext context, UnknownViewModel viewModel) {
return Scaffold(
backgroundColor: kcBackgroundColor,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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';

import 'unknown_viewmodel.dart';

class UnknownViewTablet extends ViewModelWidget<UnknownViewModel> {
const UnknownViewTablet({super.key});

@override
Widget build(BuildContext context, UnknownViewModel viewModel) {
return Scaffold(
backgroundColor: kcBackgroundColor,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'404',
style: ktsHeading1.copyWith(color: kcWhite, letterSpacing: 20.0),
),
verticalSpaceSmall,
Text(
'PAGE NOT FOUND',
style: ktsBodyLarge.copyWith(
color: kcWhite,
letterSpacing: 20.0,
wordSpacing: 10.0,
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:stacked/stacked.dart';

class UnknownViewModel extends BaseViewModel {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:{{packageName}}/{{{relativeLocatorFilePath}}}';

import '../helpers/test_helpers.dart';

void main() {
group('UnknownViewModel Tests -', () {
setUp(() => registerServices());
tearDown(() => locator.reset());
});
}
Loading

0 comments on commit d54c8e9

Please sign in to comment.