Skip to content

Commit

Permalink
Error Message Display
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhossain9797 committed Nov 14, 2019
1 parent c80bdac commit c0368d8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 16 deletions.
4 changes: 4 additions & 0 deletions lib/logic/build_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class BuildManager {

static void _motherboardCheck() {
if (build.motherboard != null) {
if (build.chassis != null &&
build.chassis.size < build.motherboard.size) {
errors.add("Your Chassis is too small for your Motherboard");
}
} else {
errors.add("You must add a Motherboard");
}
Expand Down
5 changes: 3 additions & 2 deletions lib/models/pc_chs.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/foundation.dart';
import 'package:pc_build_assistant/models/pc_component.dart';

class PCChassis extends PCComponent {
final String size;
final int size;

PCChassis({
String manufacturer,
String name,
String description,
String imgurl,
this.size,
@required this.size,
}) : super(
manufacturer: manufacturer,
name: name,
Expand Down
4 changes: 4 additions & 0 deletions lib/models/pc_mbd.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:pc_build_assistant/models/pc_component.dart';

class PCMotherboard extends PCComponent {
final int size;

PCMotherboard({
String manufacturer,
String name,
String description,
String imgurl,
@required this.size,
}) : super(
manufacturer: manufacturer,
name: name,
Expand Down
60 changes: 48 additions & 12 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class _HomeScreenState extends State<HomeScreen> {
),
height: kNavBarHeight,
child: AnimatedContainer(
duration: kButtonAnimationDuration,
duration: kAnimationDuration,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
border: Border.all(
Expand All @@ -218,13 +218,13 @@ class _HomeScreenState extends State<HomeScreen> {
//----------------------------------TAB BUTTON------------------------------------------------------
AnimatedAlign(
curve: Curves.decelerate,
duration: kSlideAnimationDuration,
duration: kAnimationDuration,
alignment: _index == 0
? Alignment.centerLeft
: Alignment.centerRight,
child: TabSlider(
left: _index == 0 ? true : false,
duration: kButtonAnimationDuration,
duration: kAnimationDuration,
width: _tabWidth,
height: _tabHeight,
colorLeft: kLoginButtonColor,
Expand All @@ -249,7 +249,7 @@ class _HomeScreenState extends State<HomeScreen> {
() {
_index = 0;
_pageController.animateToPage(0,
duration: kButtonAnimationDuration,
duration: kAnimationDuration,
curve: Curves.decelerate);
},
);
Expand All @@ -273,7 +273,7 @@ class _HomeScreenState extends State<HomeScreen> {
() {
_index = 1;
_pageController.animateToPage(1,
duration: kButtonAnimationDuration,
duration: kAnimationDuration,
curve: Curves.decelerate);
},
);
Expand Down Expand Up @@ -371,7 +371,13 @@ class _BuildPageAnimatedState extends State<BuildPageAnimated>
errorListBuilder(List<String> errors) {
List<Widget> newErrorTexts = [];
for (String error in errors) {
newErrorTexts.add(Text(error));
newErrorTexts.add(Container(
margin: EdgeInsets.all(5),
child: Text(
error,
style: TextStyle(color: kRedButtonColor),
),
));
}
setState(() {
errorTexts = newErrorTexts;
Expand Down Expand Up @@ -402,13 +408,43 @@ class _BuildPageAnimatedState extends State<BuildPageAnimated>
margin: EdgeInsets.all(10),
),
AnimatedSize(
duration: kButtonAnimationDuration,
duration: kAnimationDuration,
vsync: this,
child: Container(
margin: EdgeInsets.all(10),
child: Column(
children: errorTexts,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
margin: EdgeInsets.all(20),
child: errorTexts.length == 0
? Icon(
Icons.check,
size: 50,
color: kLoginButtonColor,
)
: Icon(
Icons.error,
size: 50,
color: kRedButtonColor,
),
),
Container(
width: 200,
margin: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: errorTexts.length > 0
? errorTexts
: [
Text(
"Your Build is Okay",
style: TextStyle(color: kLoginButtonColor),
)
],
),
),
],
),
),
Expanded(
Expand Down
2 changes: 2 additions & 0 deletions lib/storage/database_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DatabaseHelper {
name: item["name"],
description: item["description"],
imgurl: item["imgurl"],
size: item["size"],
),
);
break;
Expand All @@ -59,6 +60,7 @@ class DatabaseHelper {
name: item["name"],
description: item["description"],
imgurl: item["imgurl"],
size: item["size"],
),
);
break;
Expand Down
3 changes: 1 addition & 2 deletions lib/util/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@ const kNavBarButtonShape = RoundedRectangleBorder(
),
);

const Duration kButtonAnimationDuration = Duration(milliseconds: 500);
const Duration kSlideAnimationDuration = Duration(milliseconds: 800);
const Duration kAnimationDuration = Duration(milliseconds: 500);

0 comments on commit c0368d8

Please sign in to comment.