diff --git a/lib/base/models/journey_plan/leg.dart b/lib/base/models/journey_plan/leg.dart index 1c52395d..4d98e56e 100644 --- a/lib/base/models/journey_plan/leg.dart +++ b/lib/base/models/journey_plan/leg.dart @@ -13,6 +13,7 @@ class Leg extends Equatable { static const _fromPlace = "from"; static const _startTime = "startTime"; static const _endTime = "endTime"; + static const _arrivalDelay = "arrivalDelay"; static const _intermediatePlaces = "intermediatePlaces"; static const _transitLeg = "transitLeg"; @@ -28,6 +29,7 @@ class Leg extends Equatable { final Place fromPlace; final DateTime startTime; final DateTime endTime; + final int? arrivalDelay; final List? intermediatePlaces; final bool transitLeg; final List accumulatedPoints; @@ -45,6 +47,7 @@ class Leg extends Equatable { required this.fromPlace, required this.startTime, required this.endTime, + this.arrivalDelay, required this.intermediatePlaces, required this.transitLeg, this.accumulatedPoints = const [], @@ -77,6 +80,7 @@ class Leg extends Equatable { int.tryParse(json[_startTime].toString()) ?? 0), endTime: DateTime.fromMillisecondsSinceEpoch( int.tryParse(json[_endTime].toString()) ?? 0), + arrivalDelay: json[_arrivalDelay], intermediatePlaces: json[_intermediatePlaces] != null ? List.from( (json[_intermediatePlaces] as List).map( @@ -102,6 +106,7 @@ class Leg extends Equatable { _fromPlace: fromPlace.toJson(), _startTime: startTime.millisecondsSinceEpoch, _endTime: endTime.millisecondsSinceEpoch, + _arrivalDelay: arrivalDelay, _intermediatePlaces: intermediatePlaces?.map((itinerary) => itinerary.toJson()).toList(), _transitLeg: transitLeg, @@ -121,6 +126,7 @@ class Leg extends Equatable { Place? fromPlace, DateTime? startTime, DateTime? endTime, + int? arrivalDelay, bool? rentedBike, bool? intermediatePlace, bool? transitLeg, @@ -141,6 +147,7 @@ class Leg extends Equatable { fromPlace: fromPlace ?? this.fromPlace, startTime: startTime ?? this.startTime, endTime: endTime ?? this.endTime, + arrivalDelay: arrivalDelay ?? this.arrivalDelay, transitLeg: transitLeg ?? this.transitLeg, intermediatePlaces: intermediatePlaces ?? this.intermediatePlaces, accumulatedPoints: accumulatedPoints ?? this.accumulatedPoints, @@ -194,6 +201,7 @@ class Leg extends Equatable { fromPlace, startTime, endTime, + arrivalDelay, intermediatePlaces, transitLeg, accumulatedPoints, diff --git a/lib/base/pages/home/services/online_request_plan/rest_request_plan.dart b/lib/base/pages/home/services/online_request_plan/rest_request_plan.dart index b6cd02ba..85669c78 100644 --- a/lib/base/pages/home/services/online_request_plan/rest_request_plan.dart +++ b/lib/base/pages/home/services/online_request_plan/rest_request_plan.dart @@ -42,7 +42,7 @@ class RestRequestPlanService implements RequestPlanService { "fromPlace": from.toString(), "toPlace": to.toString(), "date": _todayMonthDayYear(), - "time": '12:00:00', + "time": "20:00", // _nowHourMinute(), "numItineraries": "5", "mode": _parseTransportModes(transportModes), }); @@ -69,10 +69,16 @@ class RestRequestPlanService implements RequestPlanService { String _todayMonthDayYear() { final today = DateTime.now(); return "${today.month.toString().padLeft(2, '0')}-" - "01-" + + "${today.day.toString().padLeft(2, '0')}-"+ today.year.toString(); } + String _nowHourMinute() { + final today = DateTime.now(); + return "${today.hour.toString().padLeft(2, '0')}-" + "${today.minute.toString().padLeft(2, '0')}"; + } + String _parseTransportModes(List list) { return list.map((e) => e.name).join(","); } diff --git a/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/itinerary_details_card.dart b/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/itinerary_details_card.dart index ee95b766..d0190186 100644 --- a/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/itinerary_details_card.dart +++ b/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/itinerary_details_card.dart @@ -67,6 +67,7 @@ class ItineraryDetailsCard extends StatelessWidget { location: mapRouteState.fromPlace?.displayName(localization) ?? '', + arrivalAt: itineraryLeg.arrivalDelay != null ? itineraryLeg.startTime.add(new Duration(seconds: itineraryLeg.arrivalDelay!)) : null, child: Stack( clipBehavior: Clip.none, children: [ diff --git a/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/line_dash_components.dart b/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/line_dash_components.dart index 890f6908..fb3d640c 100644 --- a/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/line_dash_components.dart +++ b/lib/base/pages/home/widgets/plan_itinerary_tabs/itinerary_details_card/line_dash_components.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:timer_count_down/timer_count_down.dart'; import 'package:trufi_core/base/models/enums/transport_mode.dart'; import 'package:trufi_core/base/models/journey_plan/plan.dart'; @@ -28,6 +29,7 @@ class TransportDash extends StatelessWidget { if (showBeforeLine) DashLinePlace( date: leg.startTimeString, + arrivalAt: leg.arrivalDelay != null ? leg.startTime.add(new Duration(seconds: leg.arrivalDelay!)) : null, location: leg.fromPlace.name, color: leg.primaryColor, ), @@ -46,6 +48,7 @@ class TransportDash extends StatelessWidget { if (showAfterLine) DashLinePlace( date: leg.endTimeString.toString(), + arrivalAt: leg.arrivalDelay != null ? leg.endTime.add(new Duration(seconds: leg.arrivalDelay!)) : null, location: leg.toPlace.name.toString(), color: leg.primaryColor, ), @@ -154,6 +157,7 @@ class SeparatorPlace extends StatelessWidget { class DashLinePlace extends StatelessWidget { final String date; final String location; + final DateTime? arrivalAt; final Widget? child; final Color? color; @@ -163,6 +167,7 @@ class DashLinePlace extends StatelessWidget { required this.location, this.child, this.color, + this.arrivalAt }) : super(key: key); @override @@ -216,6 +221,32 @@ class DashLinePlace extends StatelessWidget { ), ), ), + if (arrivalAt != null) + Row( + children: [ + Container( + margin: const EdgeInsets.symmetric(horizontal: 3), + child: + Countdown( + seconds: 3600, + build: (BuildContext context, double time) => Text( + (arrivalAt!.difference(DateTime.now()).inMinutes.toString() + " min " + (arrivalAt!.difference(DateTime.now()).inSeconds % 60).toString().padLeft(2, '0')) + " sec", + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.orange, + ), + ), + interval: Duration(milliseconds: 500), + ), + ), + Icon( + Icons.share_arrival_time, + size: 18, + color: Colors.orange, + ), + ] + ) , ], ), ); diff --git a/pubspec.lock b/pubspec.lock index cd4483a2..fdaac096 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,20 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - app_review: - dependency: "direct main" - description: - name: app_review - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2+1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" async_executor: dependency: "direct main" description: @@ -63,28 +56,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" + cross_file: + dependency: transitive + description: + name: cross_file + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.3+4" crypto: dependency: transitive description: @@ -154,7 +147,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -370,7 +363,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" latlong2: dependency: "direct main" description: @@ -398,14 +391,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mgrs_dart: dependency: transitive description: @@ -489,7 +489,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" path_drawing: dependency: transitive description: @@ -636,42 +636,42 @@ packages: name: share_plus url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "4.5.3" share_plus_linux: dependency: transitive description: name: share_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "3.0.1" share_plus_macos: dependency: transitive description: name: share_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "3.0.1" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "3.2.0" share_plus_web: dependency: transitive description: name: share_plus_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "3.1.0" share_plus_windows: dependency: transitive description: name: share_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "3.0.1" sky_engine: dependency: transitive description: flutter @@ -683,7 +683,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" sqflite: dependency: transitive description: @@ -718,7 +718,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" synchronized: dependency: "direct main" description: @@ -732,14 +732,21 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.12" + timer_count_down: + dependency: "direct main" + description: + name: timer_count_down + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.2" transparent_image: dependency: transitive description: @@ -858,7 +865,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" web_socket_channel: dependency: transitive description: @@ -895,5 +902,5 @@ packages: source: hosted version: "5.3.1" sdks: - dart: ">=2.15.0 <3.0.0" - flutter: ">=2.8.1" + dart: ">=2.17.0 <3.0.0" + flutter: ">=2.11.0" diff --git a/pubspec.yaml b/pubspec.yaml index 57265848..bd582b36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,7 +35,8 @@ dependencies: uni_links: ^0.5.1 # Workaround fix version errors for device_info_plus device_info_plus_platform_interface: '2.3.0+1' - + timer_count_down: ^2.2.0 + dev_dependencies: flutter_test: sdk: flutter