diff options
| -rw-r--r-- | lib/pages/all_routes_page.dart | 87 | ||||
| -rw-r--r-- | lib/services/storegear_api_service.dart | 38 |
2 files changed, 90 insertions, 35 deletions
diff --git a/lib/pages/all_routes_page.dart b/lib/pages/all_routes_page.dart index 39b49c2..495fc49 100644 --- a/lib/pages/all_routes_page.dart +++ b/lib/pages/all_routes_page.dart @@ -23,10 +23,14 @@ class _AllRoutesPageState extends State<AllRoutesPage> { @override initState() { super.initState(); - debugPrint('XDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD!!!'); - apiService.getRoutes().then((value) => { - setState(() => {routeInfo = value}) - }); + + try { + apiService.getRoutes().then((value) { + setState(() => {routeInfo = value}); + }); + } catch (e) { + debugPrint(e.toString()); + } } List<Widget> createRoutesDataWidgets() { @@ -37,18 +41,30 @@ class _AllRoutesPageState extends State<AllRoutesPage> { padding: const EdgeInsets.only(bottom: 8, left: 10, right: 10), child: Container( decoration: BoxDecoration( - border: Border.all(color: Style.logbookEntryBorder), - color: Style.logbookEntryBackground, - borderRadius: BorderRadius.all(Radius.circular(8))), + color: Style.background, + borderRadius: BorderRadius.all(Radius.circular(4))), child: Padding( padding: const EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - route.tripNumber.toString(), + 'Route ' + route.tripNumber.toString(), + textAlign: TextAlign.center, style: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 24), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(0), + ), + ), + OutlinedButton( + onPressed: () {}, + child: Text('Bekijk'), ), ], ), @@ -64,7 +80,7 @@ class _AllRoutesPageState extends State<AllRoutesPage> { var monthDataWidgets = createRoutesDataWidgets(); if (monthDataWidgets.isEmpty) { return Center( - child: Text('Geen data beschikbaar'), + child: Text('Geen routes beschikbaar'), ); } @@ -104,27 +120,32 @@ class _AllRoutesPageState extends State<AllRoutesPage> { @override Widget build(BuildContext context) { - return ShaderMask( - shaderCallback: (Rect rect) { - return LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Style.background, - Colors.transparent, - Colors.transparent, - Style.background - ], - stops: [ - 0.0, - 0.05, - 0.95, - 1.0 - ], // 10% purple, 80% transparent, 10% purple - ).createShader(rect); - }, - blendMode: BlendMode.dstOut, - child: getLoadingScreenOrDataList(), + return Scaffold( + body: Container( + color: Colors.white, + child: ShaderMask( + shaderCallback: (Rect rect) { + return LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Style.background, + Colors.transparent, + Colors.transparent, + Style.background + ], + stops: [ + 0.0, + 0.05, + 0.95, + 1.0 + ], // 10% purple, 80% transparent, 10% purple + ).createShader(rect); + }, + blendMode: BlendMode.dstOut, + child: getLoadingScreenOrDataList(), + ), + ), ); } } diff --git a/lib/services/storegear_api_service.dart b/lib/services/storegear_api_service.dart index b346292..ecd0c94 100644 --- a/lib/services/storegear_api_service.dart +++ b/lib/services/storegear_api_service.dart @@ -30,8 +30,42 @@ class StoregearApiService extends IStoregearApiService { } } + _getMockRouteList() { + return RouteList.fromJson(jsonDecode(''' +{ + "routes": [ + { + "timeframe_key": "96870", + "trip_key": "18996870", + "trip_number": "9", + "trip_pda_status": "5", + "trip_pda_status_description": "Rit overgedragen", + "trip_sequence_number": "1", + "number_in_trip": "139", + "plate": "VND-37-B", + "damage_registration": true, + "eva": "11:11", + "trip_date": "4/11/2022", + "first_address_lat": "50.8996568140536", + "first_address_lng": "5.75238472757395", + "started": "true", + "all_tasks_finished": "false", + "start_km": "24704", + "end_km": null, + "tasks_enriched": "true", + "in_trip_scan_finished": "true", + "eva_added": "true", + "trip_start_request_sent": "true" + } + ] +} +''')); + } + @override Future<RouteList> getRoutes() async { + return _getMockRouteList(); + debugPrint('WE GOT HERE!!! ' + apiKey); final response = await http.get( Uri.parse('http://dhlapis.com/delivery/v1/routes'), @@ -44,9 +78,9 @@ class StoregearApiService extends IStoregearApiService { var content = jsonDecode(response.body); if (content["message"] != null) { - content = jsonEncode(RouteList()); + return RouteList(routes: []); } - + debugPrint('amogus'); return RouteList.fromJson(content); } else { // If the server did not return a 200 OK response, |
