This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev-history' into 'master'
Dev history See merge request asl-proyectos/cazdata-frontend!3
- Loading branch information
Showing
14 changed files
with
602 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Flutter", | ||
"request": "launch", | ||
"type": "dart" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class JourniesList{ | ||
final List<Journey> journies; | ||
|
||
JourniesList({this.journies}); | ||
|
||
factory JourniesList.fromJson(List<dynamic> parsedJson) { | ||
|
||
List<Journey> journies = new List<Journey>(); | ||
journies = parsedJson.map((i)=>Journey.fromJson(i)).toList(); | ||
|
||
return new JourniesList( | ||
journies: journies | ||
); | ||
} | ||
} | ||
|
||
class Journey { | ||
final String id; | ||
final String title; | ||
final String startTime; | ||
final String endTime; | ||
final int distance; | ||
final int minutes; | ||
final int calories; | ||
|
||
Journey( | ||
{this.id, this.title, this.startTime, this.endTime,this.distance, this.minutes, this.calories}); | ||
|
||
Map toJson() { | ||
return { | ||
'id': this.id, | ||
'title': this.title, | ||
'starts_at': this.startTime, | ||
'ends_at': this.endTime, | ||
'distance': this.distance, | ||
'calories': calories | ||
}; | ||
} | ||
|
||
|
||
factory Journey.fromJson(Map<String, dynamic> json) { | ||
return new Journey( | ||
id: json['id'], | ||
title: json['title'], | ||
startTime: json['starts_at'], | ||
endTime: json['ends_at'], | ||
distance: json['distance'], | ||
calories: json['calories'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:cazdata_frontend/model/journey.dart'; | ||
import 'package:cazdata_frontend/services/networking/index.dart'; | ||
import 'package:cazdata_frontend/services/repository/journey.repository.dart'; | ||
import 'package:rxdart/subjects.dart'; | ||
|
||
class JourneyBloc { | ||
JourneyRepository _journeyRepository; | ||
StreamController _journeyController; | ||
|
||
StreamSink<Response<dynamic>> get journeySinkJourneys => | ||
_journeyController.sink; | ||
Stream<Response<dynamic>> get journeyStreamJourneys => | ||
_journeyController.stream; | ||
|
||
JourneyBloc() { | ||
_journeyRepository = new JourneyRepository(); | ||
_journeyController = BehaviorSubject<Response<dynamic>>(); | ||
} | ||
|
||
getJournies() async { | ||
_journeyController.add(Response.loading('Get journeys.')); | ||
try { | ||
JourniesList journeyResponse = await _journeyRepository.getJournies(); | ||
|
||
_journeyController.add(Response.completed(journeyResponse)); | ||
} catch (e) { | ||
_journeyController.add(Response.error(e.toString())); | ||
print(e); | ||
} | ||
} | ||
|
||
dispose() { | ||
_journeyController?.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:cazdata_frontend/model/journey.dart'; | ||
import 'package:cazdata_frontend/services/networking/index.dart'; | ||
import 'package:cazdata_frontend/util/url.dart'; | ||
|
||
|
||
class JourneyRepository { | ||
ApiProvider _provider = ApiProvider(); | ||
|
||
Future<JourniesList> getJournies() async { | ||
final response = | ||
await _provider.get(Url.apiBaseUrl + "/journeys"); | ||
|
||
|
||
JourniesList journiesList = JourniesList.fromJson(response); | ||
|
||
return journiesList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import 'package:cazdata_frontend/model/journey.dart'; | ||
import 'package:cazdata_frontend/ui/widget/data-on-map.widget.dart'; | ||
import 'package:cazdata_frontend/util/colors.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class DetailsJourney extends StatelessWidget { | ||
|
||
final Journey journey; | ||
|
||
const DetailsJourney({ | ||
this.journey, | ||
Key key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
||
DateTime startTime = DateTime.parse(journey.startTime); | ||
DateTime endTime = DateTime.parse(journey.endTime); | ||
final int difference = endTime.difference(startTime).inMinutes; | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('CazData'), | ||
), | ||
body: DefaultTextStyle( | ||
style: TextStyle( | ||
inherit: true, | ||
fontSize: 14.0, | ||
fontWeight: FontWeight.normal, | ||
fontFamily: 'Montserrat', | ||
decoration: TextDecoration.none, | ||
decorationColor: Colors.black, | ||
decorationStyle: TextDecorationStyle.solid, | ||
color: Colors.black), | ||
child: Center( | ||
child: Container( | ||
margin: const EdgeInsets.all(20), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
children: <Widget>[ | ||
Row( | ||
children: <Widget>[ | ||
Expanded( | ||
flex: 3, | ||
child: Text( | ||
'Detalle Jornada', | ||
style: TextStyle( | ||
fontSize: 32, fontWeight: FontWeight.bold), | ||
), | ||
), | ||
], | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: 10.0), | ||
child: Text( | ||
'Informaci贸n', | ||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24), | ||
), | ||
), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: <Widget>[ | ||
Padding( | ||
padding: const EdgeInsets.only(top: 10.0), | ||
child: Text( | ||
journey.title, | ||
style: TextStyle(fontSize: 20), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: 10.0), | ||
child: Text( | ||
journey.startTime.substring(0,10), | ||
style: TextStyle(fontSize: 20), | ||
), | ||
), | ||
], | ||
), | ||
Row( | ||
children: <Widget>[ | ||
Expanded( | ||
child: Padding( | ||
padding: const EdgeInsets.all(15.0), | ||
child: Card( | ||
color: Color.fromARGB(255, 241, 243, 246), | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.only( | ||
topLeft: Radius.circular(16), | ||
topRight: Radius.circular(16), | ||
) | ||
), | ||
child: Center( | ||
child: Column( | ||
children: <Widget>[ | ||
Row( | ||
children: <Widget>[ | ||
DataOnMapWidget( | ||
distance: journey.distance.toString(), | ||
time: difference.toString(), | ||
calories: journey.calories.toString() | ||
) | ||
], | ||
), | ||
Row( | ||
children: <Widget>[ | ||
SizedBox( | ||
width: MediaQuery.of(context).size.width - 78, | ||
height: MediaQuery.of(context).size.height - 440, | ||
) | ||
], | ||
), | ||
], | ||
) | ||
) | ||
), | ||
), | ||
) | ||
], | ||
), | ||
Row( | ||
children: <Widget>[ | ||
Expanded( | ||
child: FlatButton( | ||
onPressed: () { | ||
/*...*/ | ||
}, | ||
color: greenLight, | ||
textColor: Colors.white, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: new BorderRadius.circular(18.0)), | ||
child: Text("Compartir jornada", | ||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17)), | ||
), | ||
) | ||
],) | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.