Skip to content

Commit

Permalink
Merge pull request #13 from alvaromerinog/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alvaromerinog authored Aug 26, 2021
2 parents 22ab752 + ca78fd8 commit 4c8d2b9
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 32 deletions.
75 changes: 61 additions & 14 deletions lib/pages/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ class _HistoryState extends State<History> {
List? maintenances;
String registration = '';
Map? arguments;
Widget maintenancesWidget = SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
Widget maintenancesWidget = ListView(
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 0),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Center(
child: SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
),
),
],
);

@override
Expand All @@ -38,9 +46,17 @@ class _HistoryState extends State<History> {
if (newRegistration != registration) {
registration = newRegistration;
arguments = {"email": this.email, "registration": this.registration};
maintenancesWidget = SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
maintenancesWidget = ListView(
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 0),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Center(
child: SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
),
),
],
);
getMaintenances();
}
Expand All @@ -50,10 +66,17 @@ class _HistoryState extends State<History> {
FutureOr onGoBack(dynamic value) {
getMaintenances();
setState(() {
maintenancesWidget = SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
);
maintenancesWidget = ListView(
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 0),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Center(
child: SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
),
),
]);
});
}

Expand All @@ -78,10 +101,34 @@ class _HistoryState extends State<History> {
.selectMaintenances();
this.buildMaintenances(maintenances);
} on Exception {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('No se han podido recuperar los vehículos.'),
backgroundColor: Colors.red,
));
setState(() {
ListView(
padding: EdgeInsets.fromLTRB(10, 10, 10, 100),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Card(
margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
elevation: 20,
color: Colors.white,
child: ListTile(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
leading: Icon(
Icons.dangerous,
color: Colors.red,
size: 30,
),
title: Text('No se han podido recuperar los mantenimientos.',
style: TextStyle(fontSize: 20.0)),
),
),
],
);
});
}
}

Expand Down
67 changes: 50 additions & 17 deletions lib/pages/vehicles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ class _VehiclesState extends State<Vehicles> {
String? registration;
static String selectedRegistration = '';
int selectedIndex = 0;
Widget vehiclesWidget = SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
Widget vehiclesWidget = ListView(
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 0),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Center(
child: SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
),
),
],
);

@override
Expand All @@ -36,20 +44,21 @@ class _VehiclesState extends State<Vehicles> {
}
}

@override
void didUpdateWidget(covariant Vehicles oldWidget) {
getVehicles();
super.didUpdateWidget(oldWidget);
}

FutureOr onGoBack(dynamic value) {
selectedIndex = 0;
getVehicles();
setState(() {
vehiclesWidget = SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
);
vehiclesWidget = ListView(
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 0),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Center(
child: SpinKitChasingDots(
color: Colors.blue[800],
size: 50.0,
),
),
]);
});
}

Expand All @@ -74,10 +83,34 @@ class _VehiclesState extends State<Vehicles> {
vehicles = await VehiclesGet(email: this.email).selectVehicles();
buildVehicles(vehicles);
} on Exception {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('No se han podido recuperar los vehículos.'),
backgroundColor: Colors.red,
));
setState(() {
ListView(
padding: EdgeInsets.fromLTRB(10, 10, 10, 100),
physics: const AlwaysScrollableScrollPhysics(),
children: [
Card(
margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
elevation: 20,
color: Colors.white,
child: ListTile(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
leading: Icon(
Icons.dangerous,
color: Colors.red,
size: 30,
),
title: Text('No se han podido recuperar los vehículos.',
style: TextStyle(fontSize: 20.0)),
),
),
],
);
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Vehicle maintenances management app.

publish_to: 'none'

version: 1.0.0+4
version: 1.1.1+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 4c8d2b9

Please sign in to comment.