Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Unknown view to Web template #8

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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