From 17d8fac893751fb777bb792c5f1c807ea56c4351 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Mon, 24 Jul 2023 06:55:16 +0200 Subject: [PATCH] Move to API v3 --- lib/api/station_data.dart | 8 +- lib/api/train_data.dart | 2 +- lib/models.dart | 6 +- lib/models/station_arrdep.freezed.dart | 2 +- lib/models/station_data.freezed.dart | 4 +- lib/models/station_status.freezed.dart | 2 +- lib/models/station_train.freezed.dart | 3 +- lib/models/stations_result.freezed.dart | 3 +- lib/models/train_data.dart | 361 +-- lib/models/train_data.freezed.dart | 2365 +++++++++++++++++ lib/models/train_data.g.dart | 217 ++ lib/models/trains_result.freezed.dart | 2 +- .../view_station/view_station.dart | 3 +- .../view_train/train_info.dart | 111 +- .../view_train/train_info_cupertino.dart | 4 +- ...in_info_cupertino_DisplayTrainStation.dart | 315 ++- .../view_train/train_info_fluent.dart | 2 +- ...train_info_fluent_DisplayTrainStation.dart | 352 ++- .../view_train/train_info_material.dart | 125 +- ...ain_info_material_DisplayTrainStation.dart | 390 ++- lib/providers.dart | 13 +- lib/providers.g.dart | 120 + 22 files changed, 3754 insertions(+), 656 deletions(-) create mode 100644 lib/models/train_data.freezed.dart create mode 100644 lib/models/train_data.g.dart create mode 100644 lib/providers.g.dart diff --git a/lib/api/station_data.dart b/lib/api/station_data.dart index 1b8a2a3..2c33d45 100644 --- a/lib/api/station_data.dart +++ b/lib/api/station_data.dart @@ -4,7 +4,11 @@ import 'package:http/http.dart' as http; import 'package:info_tren/api/common.dart'; import 'package:info_tren/models.dart'; -Future getStationData(String stationName) async { - final response = await http.get(Uri.https(authority, 'v3/stations/$stationName')); +Future getStationData(String stationName, [DateTime? date]) async { + final uri = Uri.https(authority, 'v3/stations/$stationName'); + if (date != null) { + uri.queryParameters['date'] = date.toIso8601String(); + } + final response = await http.get(uri); return StationData.fromJson(jsonDecode(response.body)); } diff --git a/lib/api/train_data.dart b/lib/api/train_data.dart index b451656..2102c5f 100644 --- a/lib/api/train_data.dart +++ b/lib/api/train_data.dart @@ -4,7 +4,7 @@ import 'package:info_tren/models.dart'; Future getTrain(String trainNumber, {DateTime? date}) async { date ??= DateTime.now(); - final response = await http.get(Uri.https(authority, 'v2/train/$trainNumber', { + final response = await http.get(Uri.https(authority, 'v3/trains/$trainNumber', { 'date': date.toUtc().toIso8601String(), }),); return trainDataFromJson(response.body); diff --git a/lib/models.dart b/lib/models.dart index 8e9613b..73ffa50 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -4,11 +4,11 @@ export 'package:info_tren/models/station_data.dart'; export 'package:info_tren/models/station_status.dart'; export 'package:info_tren/models/station_train.dart'; export 'package:info_tren/models/stations_result.dart'; -export 'package:info_tren/models/train_data.dart' hide State; +export 'package:info_tren/models/train_data.dart'; export 'package:info_tren/models/trains_result.dart'; export 'package:info_tren/models/ui_design.dart'; export 'package:info_tren/models/ui_timezone.dart'; -import 'package:info_tren/models/train_data.dart' show State; +import 'package:info_tren/models/train_data.dart' show TrainDataStatusState; -typedef TrainDataState = State; +typedef TrainDataState = TrainDataStatusState; \ No newline at end of file diff --git a/lib/models/station_arrdep.freezed.dart b/lib/models/station_arrdep.freezed.dart index 221c1dc..767dd5b 100644 --- a/lib/models/station_arrdep.freezed.dart +++ b/lib/models/station_arrdep.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'station_arrdep.dart'; diff --git a/lib/models/station_data.freezed.dart b/lib/models/station_data.freezed.dart index 3c017e8..304b8fd 100644 --- a/lib/models/station_data.freezed.dart +++ b/lib/models/station_data.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'station_data.dart'; @@ -158,6 +158,7 @@ class _$_StationData implements _StationData { List? get arrivals { final value = _arrivals; if (value == null) return null; + if (_arrivals is EqualUnmodifiableListView) return _arrivals; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(value); } @@ -167,6 +168,7 @@ class _$_StationData implements _StationData { List? get departures { final value = _departures; if (value == null) return null; + if (_departures is EqualUnmodifiableListView) return _departures; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(value); } diff --git a/lib/models/station_status.freezed.dart b/lib/models/station_status.freezed.dart index 4b22514..f69c4ca 100644 --- a/lib/models/station_status.freezed.dart +++ b/lib/models/station_status.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'station_status.dart'; diff --git a/lib/models/station_train.freezed.dart b/lib/models/station_train.freezed.dart index 365ce5b..7909b23 100644 --- a/lib/models/station_train.freezed.dart +++ b/lib/models/station_train.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'station_train.dart'; @@ -189,6 +189,7 @@ class _$_StationTrain implements _StationTrain { List? get route { final value = _route; if (value == null) return null; + if (_route is EqualUnmodifiableListView) return _route; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(value); } diff --git a/lib/models/stations_result.freezed.dart b/lib/models/stations_result.freezed.dart index cefa58a..5a7a226 100644 --- a/lib/models/stations_result.freezed.dart +++ b/lib/models/stations_result.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'stations_result.dart'; @@ -121,6 +121,7 @@ class _$_StationsResult implements _StationsResult { List? get stoppedAtBy { final value = _stoppedAtBy; if (value == null) return null; + if (_stoppedAtBy is EqualUnmodifiableListView) return _stoppedAtBy; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(value); } diff --git a/lib/models/train_data.dart b/lib/models/train_data.dart index 213fa68..0ba8ea9 100644 --- a/lib/models/train_data.dart +++ b/lib/models/train_data.dart @@ -4,181 +4,106 @@ import 'dart:convert'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'train_data.freezed.dart'; +part 'train_data.g.dart'; + TrainData trainDataFromJson(String str) => TrainData.fromJson(json.decode(str)); String trainDataToJson(TrainData data) => json.encode(data.toJson()); /// Results of scrapping InfoFer website for train info -class TrainData { - TrainData({ - required this.date, - required this.number, - required this.operator, - required this.rank, - required this.route, - required this.stations, - this.status, - }); - - final String date; - final String number; - final String operator; - final String rank; - final Route route; - final List stations; - final TrainDataStatus? status; - - factory TrainData.fromJson(Map json) => TrainData( - date: json["date"], - number: json["number"], - operator: json["operator"], - rank: json["rank"], - route: Route.fromJson(json["route"]), - stations: List.from( - json["stations"].map((x) => Station.fromJson(x))), - status: json["status"] == null - ? null - : TrainDataStatus.fromJson(json["status"]), - ); +@freezed +class TrainData with _$TrainData { + const TrainData._(); + + const factory TrainData({ + required String rank, + required String number, + required String date, + required String operator, + required List groups, + }) = _TrainData; + + factory TrainData.fromJson(Map json) => _$TrainDataFromJson(json); + + List get stations => groups.first.stations; + TrainDataRoute get route => groups.first.route; + TrainDataStatus? get status => groups.first.status; +} - Map toJson() => { - "date": date, - "number": number, - "operator": operator, - "rank": rank, - "route": route.toJson(), - "stations": List.from(stations.map((x) => x.toJson())), - "status": status?.toJson(), - }; +@freezed +class TrainDataGroup with _$TrainDataGroup { + const factory TrainDataGroup({ + required TrainDataRoute route, + required List stations, + TrainDataStatus? status, + }) = _TrainDataGroup; + + factory TrainDataGroup.fromJson(Map json) => _$TrainDataGroupFromJson(json); } /// Route of the train -class Route { - Route({ - required this.from, - required this.to, - }); - - final String from; - final String to; - - factory Route.fromJson(Map json) => Route( - from: json["from"], - to: json["to"], - ); - - Map toJson() => { - "from": from, - "to": to, - }; +@freezed +class TrainDataRoute with _$TrainDataRoute { + const factory TrainDataRoute({ + required String from, + required String to, + }) = _TrainDataRoute; + + factory TrainDataRoute.fromJson(Map json) => _$TrainDataRouteFromJson(json); } -class Station { - Station({ - this.arrival, - this.departure, - required this.km, - required this.name, - this.platform, - this.stoppingTime, - }); - - final StationArrDepTime? arrival; - final StationArrDepTime? departure; - final int km; - final String name; - final String? platform; - final int? stoppingTime; - - factory Station.fromJson(Map json) => Station( - arrival: json["arrival"] == null - ? null - : StationArrDepTime.fromJson(json["arrival"]), - departure: json["departure"] == null - ? null - : StationArrDepTime.fromJson(json["departure"]), - km: json["km"], - name: json["name"], - platform: json["platform"], - stoppingTime: - json["stoppingTime"], - ); - - Map toJson() => { - "arrival": arrival?.toJson(), - "departure": departure?.toJson(), - "km": km, - "name": name, - "platform": platform, - "stoppingTime": stoppingTime, - }; +@freezed +class TrainDataStation with _$TrainDataStation { + const factory TrainDataStation({ + required String name, + required String linkName, + required int km, + int? stoppingTime, + String? platform, + StationArrDepTime? arrival, + StationArrDepTime? departure, + @TrainDataNoteConverter() + required List notes, + }) = _TrainDataStation; + + factory TrainDataStation.fromJson(Map json) => _$TrainDataStationFromJson(json); } -class StationArrDepTime { - StationArrDepTime({ - required this.scheduleTime, - this.status, - }); - - final DateTime scheduleTime; - final StationArrDepTimeStatus? status; +@freezed +class StationArrDepTime with _$StationArrDepTime { + const factory StationArrDepTime({ + required DateTime scheduleTime, + StationArrDepTimeStatus? status, + }) = _StationArrDepTime; - factory StationArrDepTime.fromJson(Map json) => - StationArrDepTime( - scheduleTime: DateTime.parse(json["scheduleTime"] as String), - status: json["status"] == null ? null : StationArrDepTimeStatus.fromJson(json["status"]), - ); - - Map toJson() => { - "scheduleTime": scheduleTime.toIso8601String(), - "status": status?.toJson(), - }; + factory StationArrDepTime.fromJson(Map json) => _$StationArrDepTimeFromJson(json); } -class StationArrDepTimeStatus { - StationArrDepTimeStatus({ - required this.delay, - required this.real, - }); +@freezed +class StationArrDepTimeStatus with _$StationArrDepTimeStatus { + const factory StationArrDepTimeStatus({ + required int delay, + required bool real, + required bool cancelled, + }) = _StationArrDepTimeStatus; - final int delay; - final bool real; - - factory StationArrDepTimeStatus.fromJson(Map json) => - StationArrDepTimeStatus( - delay: json["delay"], - real: json["real"], - ); - - Map toJson() => { - "delay": delay, - "real": real, - }; + factory StationArrDepTimeStatus.fromJson(Map json) => _$StationArrDepTimeStatusFromJson(json); } -class TrainDataStatus { - TrainDataStatus({ - required this.delay, - required this.state, - required this.station, - }); +@freezed +class TrainDataStatus with _$TrainDataStatus { + const TrainDataStatus._(); - final int delay; - final State state; - final String station; + const factory TrainDataStatus({ + required int delay, + required String station, + required TrainDataStatusState state, + }) = _TrainDataStatus; - factory TrainDataStatus.fromJson(Map json) => - TrainDataStatus( - delay: json["delay"], - state: stateValues.map[json["state"]]!, - station: json["station"], - ); - - Map toJson() => { - "delay": delay, - "state": stateValues.reverse[state], - "station": station, - }; + factory TrainDataStatus.fromJson(Map json) => _$TrainDataStatusFromJson(json); @override String toString() { @@ -190,38 +115,118 @@ class TrainDataStatus { result += '${delay.abs()} min'; } result += ' la '; - switch (state) { - case State.PASSING: - result += 'trecerea fără oprire prin'; - break; - case State.ARRIVAL: - result += 'sosirea în'; - break; - case State.DEPARTURE: - result += 'plecarea din'; - break; - } + result += switch (state) { + TrainDataStatusState.passing => 'trecerea fără oprire prin', + TrainDataStatusState.arrival => 'sosirea în', + TrainDataStatusState.departure => 'plecarea din', + }; result += station; return result; } } -enum State { PASSING, ARRIVAL, DEPARTURE } +enum TrainDataStatusState { passing, arrival, departure } + +abstract class TrainDataNote { + final String kind; + + const TrainDataNote({required this.kind}); -final stateValues = EnumValues({ - "arrival": State.ARRIVAL, - "departure": State.DEPARTURE, - "passing": State.PASSING -}); + Map toJson() => { + "kind": kind, + }; +} -class EnumValues { - Map map; - Map? reverseMap; +class TrainDataNoteConverter implements JsonConverter> { + const TrainDataNoteConverter(); - EnumValues(this.map); + @override + TrainDataNote fromJson(Map json) { + return switch(json['kind']) { + 'trainNumberChange' => TrainDataNoteTrainNumberChange.fromJson(json), + 'departsAs' => TrainDataNoteDepartsAs.fromJson(json), + 'detachingWagons' => TrainDataNoteDetachingWagons.fromJson(json), + 'receivingWagons' => TrainDataNoteReceivingWagons.fromJson(json), + _ => TrainDataNoteUnknown.fromJson(json), + }; + } - Map get reverse { - reverseMap ??= map.map((k, v) => MapEntry(v, k)); - return reverseMap!; + @override + Map toJson(TrainDataNote object) { + return object.toJson(); } } + +@freezed +class TrainDataNoteTrainNumberChange with _$TrainDataNoteTrainNumberChange implements TrainDataNote { + @Implements() + const factory TrainDataNoteTrainNumberChange({ + // base + @Default("trainNumberChange") + String kind, + // impl + required String rank, + required String number, + }) = _TrainDataNoteTrainNumberChange; + + factory TrainDataNoteTrainNumberChange.fromJson(Map json) => _$TrainDataNoteTrainNumberChangeFromJson(json); +} + +@freezed +class TrainDataNoteDepartsAs with _$TrainDataNoteDepartsAs implements TrainDataNote { + @Implements() + const factory TrainDataNoteDepartsAs({ + // base + @Default("departsAs") + String kind, + // impl + required String rank, + required String number, + required DateTime departureDate, + }) = _TrainDataNoteDepartsAs; + + factory TrainDataNoteDepartsAs.fromJson(Map json) => _$TrainDataNoteDepartsAsFromJson(json); +} + +@freezed +class TrainDataNoteDetachingWagons with _$TrainDataNoteDetachingWagons implements TrainDataNote { + @Implements() + const factory TrainDataNoteDetachingWagons({ + // base + @Default("detachingWagons") + String kind, + // impl + required String station, + }) = _TrainDataNoteDetachingWagons; + + factory TrainDataNoteDetachingWagons.fromJson(Map json) => _$TrainDataNoteDetachingWagonsFromJson(json); +} +@freezed +class TrainDataNoteReceivingWagons with _$TrainDataNoteReceivingWagons implements TrainDataNote { + @Implements() + const factory TrainDataNoteReceivingWagons({ + // base + @Default("receivingWagons") + String kind, + // impl + required String station, + }) = _TrainDataNoteReceivingWagons; + + factory TrainDataNoteReceivingWagons.fromJson(Map json) => _$TrainDataNoteReceivingWagonsFromJson(json); +} + +@freezed +class TrainDataNoteUnknown with _$TrainDataNoteUnknown implements TrainDataNote { + @Implements() + const factory TrainDataNoteUnknown({ + // base + required String kind, + // impl + required Map extra, + }) = _TrainDataNoteUnknown; + + factory TrainDataNoteUnknown.fromJson(Map json) => TrainDataNoteUnknown( + kind: json['kind'], + extra: Map.from(json)..remove('kind'), + ); +} \ No newline at end of file diff --git a/lib/models/train_data.freezed.dart b/lib/models/train_data.freezed.dart new file mode 100644 index 0000000..87caf11 --- /dev/null +++ b/lib/models/train_data.freezed.dart @@ -0,0 +1,2365 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'train_data.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +TrainData _$TrainDataFromJson(Map json) { + return _TrainData.fromJson(json); +} + +/// @nodoc +mixin _$TrainData { + String get rank => throw _privateConstructorUsedError; + String get number => throw _privateConstructorUsedError; + String get date => throw _privateConstructorUsedError; + String get operator => throw _privateConstructorUsedError; + List get groups => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataCopyWith<$Res> { + factory $TrainDataCopyWith(TrainData value, $Res Function(TrainData) then) = + _$TrainDataCopyWithImpl<$Res, TrainData>; + @useResult + $Res call( + {String rank, + String number, + String date, + String operator, + List groups}); +} + +/// @nodoc +class _$TrainDataCopyWithImpl<$Res, $Val extends TrainData> + implements $TrainDataCopyWith<$Res> { + _$TrainDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? date = null, + Object? operator = null, + Object? groups = null, + }) { + return _then(_value.copyWith( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + operator: null == operator + ? _value.operator + : operator // ignore: cast_nullable_to_non_nullable + as String, + groups: null == groups + ? _value.groups + : groups // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataCopyWith<$Res> implements $TrainDataCopyWith<$Res> { + factory _$$_TrainDataCopyWith( + _$_TrainData value, $Res Function(_$_TrainData) then) = + __$$_TrainDataCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String rank, + String number, + String date, + String operator, + List groups}); +} + +/// @nodoc +class __$$_TrainDataCopyWithImpl<$Res> + extends _$TrainDataCopyWithImpl<$Res, _$_TrainData> + implements _$$_TrainDataCopyWith<$Res> { + __$$_TrainDataCopyWithImpl( + _$_TrainData _value, $Res Function(_$_TrainData) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? date = null, + Object? operator = null, + Object? groups = null, + }) { + return _then(_$_TrainData( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + operator: null == operator + ? _value.operator + : operator // ignore: cast_nullable_to_non_nullable + as String, + groups: null == groups + ? _value._groups + : groups // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainData extends _TrainData { + const _$_TrainData( + {required this.rank, + required this.number, + required this.date, + required this.operator, + required final List groups}) + : _groups = groups, + super._(); + + factory _$_TrainData.fromJson(Map json) => + _$$_TrainDataFromJson(json); + + @override + final String rank; + @override + final String number; + @override + final String date; + @override + final String operator; + final List _groups; + @override + List get groups { + if (_groups is EqualUnmodifiableListView) return _groups; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_groups); + } + + @override + String toString() { + return 'TrainData(rank: $rank, number: $number, date: $date, operator: $operator, groups: $groups)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainData && + (identical(other.rank, rank) || other.rank == rank) && + (identical(other.number, number) || other.number == number) && + (identical(other.date, date) || other.date == date) && + (identical(other.operator, operator) || + other.operator == operator) && + const DeepCollectionEquality().equals(other._groups, _groups)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, rank, number, date, operator, + const DeepCollectionEquality().hash(_groups)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataCopyWith<_$_TrainData> get copyWith => + __$$_TrainDataCopyWithImpl<_$_TrainData>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataToJson( + this, + ); + } +} + +abstract class _TrainData extends TrainData { + const factory _TrainData( + {required final String rank, + required final String number, + required final String date, + required final String operator, + required final List groups}) = _$_TrainData; + const _TrainData._() : super._(); + + factory _TrainData.fromJson(Map json) = + _$_TrainData.fromJson; + + @override + String get rank; + @override + String get number; + @override + String get date; + @override + String get operator; + @override + List get groups; + @override + @JsonKey(ignore: true) + _$$_TrainDataCopyWith<_$_TrainData> get copyWith => + throw _privateConstructorUsedError; +} + +TrainDataGroup _$TrainDataGroupFromJson(Map json) { + return _TrainDataGroup.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataGroup { + TrainDataRoute get route => throw _privateConstructorUsedError; + List get stations => throw _privateConstructorUsedError; + TrainDataStatus? get status => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataGroupCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataGroupCopyWith<$Res> { + factory $TrainDataGroupCopyWith( + TrainDataGroup value, $Res Function(TrainDataGroup) then) = + _$TrainDataGroupCopyWithImpl<$Res, TrainDataGroup>; + @useResult + $Res call( + {TrainDataRoute route, + List stations, + TrainDataStatus? status}); + + $TrainDataRouteCopyWith<$Res> get route; + $TrainDataStatusCopyWith<$Res>? get status; +} + +/// @nodoc +class _$TrainDataGroupCopyWithImpl<$Res, $Val extends TrainDataGroup> + implements $TrainDataGroupCopyWith<$Res> { + _$TrainDataGroupCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? route = null, + Object? stations = null, + Object? status = freezed, + }) { + return _then(_value.copyWith( + route: null == route + ? _value.route + : route // ignore: cast_nullable_to_non_nullable + as TrainDataRoute, + stations: null == stations + ? _value.stations + : stations // ignore: cast_nullable_to_non_nullable + as List, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as TrainDataStatus?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $TrainDataRouteCopyWith<$Res> get route { + return $TrainDataRouteCopyWith<$Res>(_value.route, (value) { + return _then(_value.copyWith(route: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $TrainDataStatusCopyWith<$Res>? get status { + if (_value.status == null) { + return null; + } + + return $TrainDataStatusCopyWith<$Res>(_value.status!, (value) { + return _then(_value.copyWith(status: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_TrainDataGroupCopyWith<$Res> + implements $TrainDataGroupCopyWith<$Res> { + factory _$$_TrainDataGroupCopyWith( + _$_TrainDataGroup value, $Res Function(_$_TrainDataGroup) then) = + __$$_TrainDataGroupCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {TrainDataRoute route, + List stations, + TrainDataStatus? status}); + + @override + $TrainDataRouteCopyWith<$Res> get route; + @override + $TrainDataStatusCopyWith<$Res>? get status; +} + +/// @nodoc +class __$$_TrainDataGroupCopyWithImpl<$Res> + extends _$TrainDataGroupCopyWithImpl<$Res, _$_TrainDataGroup> + implements _$$_TrainDataGroupCopyWith<$Res> { + __$$_TrainDataGroupCopyWithImpl( + _$_TrainDataGroup _value, $Res Function(_$_TrainDataGroup) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? route = null, + Object? stations = null, + Object? status = freezed, + }) { + return _then(_$_TrainDataGroup( + route: null == route + ? _value.route + : route // ignore: cast_nullable_to_non_nullable + as TrainDataRoute, + stations: null == stations + ? _value._stations + : stations // ignore: cast_nullable_to_non_nullable + as List, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as TrainDataStatus?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataGroup implements _TrainDataGroup { + const _$_TrainDataGroup( + {required this.route, + required final List stations, + this.status}) + : _stations = stations; + + factory _$_TrainDataGroup.fromJson(Map json) => + _$$_TrainDataGroupFromJson(json); + + @override + final TrainDataRoute route; + final List _stations; + @override + List get stations { + if (_stations is EqualUnmodifiableListView) return _stations; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_stations); + } + + @override + final TrainDataStatus? status; + + @override + String toString() { + return 'TrainDataGroup(route: $route, stations: $stations, status: $status)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataGroup && + (identical(other.route, route) || other.route == route) && + const DeepCollectionEquality().equals(other._stations, _stations) && + (identical(other.status, status) || other.status == status)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, route, + const DeepCollectionEquality().hash(_stations), status); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataGroupCopyWith<_$_TrainDataGroup> get copyWith => + __$$_TrainDataGroupCopyWithImpl<_$_TrainDataGroup>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataGroupToJson( + this, + ); + } +} + +abstract class _TrainDataGroup implements TrainDataGroup { + const factory _TrainDataGroup( + {required final TrainDataRoute route, + required final List stations, + final TrainDataStatus? status}) = _$_TrainDataGroup; + + factory _TrainDataGroup.fromJson(Map json) = + _$_TrainDataGroup.fromJson; + + @override + TrainDataRoute get route; + @override + List get stations; + @override + TrainDataStatus? get status; + @override + @JsonKey(ignore: true) + _$$_TrainDataGroupCopyWith<_$_TrainDataGroup> get copyWith => + throw _privateConstructorUsedError; +} + +TrainDataRoute _$TrainDataRouteFromJson(Map json) { + return _TrainDataRoute.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataRoute { + String get from => throw _privateConstructorUsedError; + String get to => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataRouteCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataRouteCopyWith<$Res> { + factory $TrainDataRouteCopyWith( + TrainDataRoute value, $Res Function(TrainDataRoute) then) = + _$TrainDataRouteCopyWithImpl<$Res, TrainDataRoute>; + @useResult + $Res call({String from, String to}); +} + +/// @nodoc +class _$TrainDataRouteCopyWithImpl<$Res, $Val extends TrainDataRoute> + implements $TrainDataRouteCopyWith<$Res> { + _$TrainDataRouteCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? to = null, + }) { + return _then(_value.copyWith( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataRouteCopyWith<$Res> + implements $TrainDataRouteCopyWith<$Res> { + factory _$$_TrainDataRouteCopyWith( + _$_TrainDataRoute value, $Res Function(_$_TrainDataRoute) then) = + __$$_TrainDataRouteCopyWithImpl<$Res>; + @override + @useResult + $Res call({String from, String to}); +} + +/// @nodoc +class __$$_TrainDataRouteCopyWithImpl<$Res> + extends _$TrainDataRouteCopyWithImpl<$Res, _$_TrainDataRoute> + implements _$$_TrainDataRouteCopyWith<$Res> { + __$$_TrainDataRouteCopyWithImpl( + _$_TrainDataRoute _value, $Res Function(_$_TrainDataRoute) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? to = null, + }) { + return _then(_$_TrainDataRoute( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataRoute implements _TrainDataRoute { + const _$_TrainDataRoute({required this.from, required this.to}); + + factory _$_TrainDataRoute.fromJson(Map json) => + _$$_TrainDataRouteFromJson(json); + + @override + final String from; + @override + final String to; + + @override + String toString() { + return 'TrainDataRoute(from: $from, to: $to)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataRoute && + (identical(other.from, from) || other.from == from) && + (identical(other.to, to) || other.to == to)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, from, to); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataRouteCopyWith<_$_TrainDataRoute> get copyWith => + __$$_TrainDataRouteCopyWithImpl<_$_TrainDataRoute>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataRouteToJson( + this, + ); + } +} + +abstract class _TrainDataRoute implements TrainDataRoute { + const factory _TrainDataRoute( + {required final String from, + required final String to}) = _$_TrainDataRoute; + + factory _TrainDataRoute.fromJson(Map json) = + _$_TrainDataRoute.fromJson; + + @override + String get from; + @override + String get to; + @override + @JsonKey(ignore: true) + _$$_TrainDataRouteCopyWith<_$_TrainDataRoute> get copyWith => + throw _privateConstructorUsedError; +} + +TrainDataStation _$TrainDataStationFromJson(Map json) { + return _TrainDataStation.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataStation { + String get name => throw _privateConstructorUsedError; + String get linkName => throw _privateConstructorUsedError; + int get km => throw _privateConstructorUsedError; + int? get stoppingTime => throw _privateConstructorUsedError; + String? get platform => throw _privateConstructorUsedError; + StationArrDepTime? get arrival => throw _privateConstructorUsedError; + StationArrDepTime? get departure => throw _privateConstructorUsedError; + @TrainDataNoteConverter() + List get notes => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataStationCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataStationCopyWith<$Res> { + factory $TrainDataStationCopyWith( + TrainDataStation value, $Res Function(TrainDataStation) then) = + _$TrainDataStationCopyWithImpl<$Res, TrainDataStation>; + @useResult + $Res call( + {String name, + String linkName, + int km, + int? stoppingTime, + String? platform, + StationArrDepTime? arrival, + StationArrDepTime? departure, + @TrainDataNoteConverter() List notes}); + + $StationArrDepTimeCopyWith<$Res>? get arrival; + $StationArrDepTimeCopyWith<$Res>? get departure; +} + +/// @nodoc +class _$TrainDataStationCopyWithImpl<$Res, $Val extends TrainDataStation> + implements $TrainDataStationCopyWith<$Res> { + _$TrainDataStationCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? linkName = null, + Object? km = null, + Object? stoppingTime = freezed, + Object? platform = freezed, + Object? arrival = freezed, + Object? departure = freezed, + Object? notes = null, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + linkName: null == linkName + ? _value.linkName + : linkName // ignore: cast_nullable_to_non_nullable + as String, + km: null == km + ? _value.km + : km // ignore: cast_nullable_to_non_nullable + as int, + stoppingTime: freezed == stoppingTime + ? _value.stoppingTime + : stoppingTime // ignore: cast_nullable_to_non_nullable + as int?, + platform: freezed == platform + ? _value.platform + : platform // ignore: cast_nullable_to_non_nullable + as String?, + arrival: freezed == arrival + ? _value.arrival + : arrival // ignore: cast_nullable_to_non_nullable + as StationArrDepTime?, + departure: freezed == departure + ? _value.departure + : departure // ignore: cast_nullable_to_non_nullable + as StationArrDepTime?, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $StationArrDepTimeCopyWith<$Res>? get arrival { + if (_value.arrival == null) { + return null; + } + + return $StationArrDepTimeCopyWith<$Res>(_value.arrival!, (value) { + return _then(_value.copyWith(arrival: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $StationArrDepTimeCopyWith<$Res>? get departure { + if (_value.departure == null) { + return null; + } + + return $StationArrDepTimeCopyWith<$Res>(_value.departure!, (value) { + return _then(_value.copyWith(departure: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_TrainDataStationCopyWith<$Res> + implements $TrainDataStationCopyWith<$Res> { + factory _$$_TrainDataStationCopyWith( + _$_TrainDataStation value, $Res Function(_$_TrainDataStation) then) = + __$$_TrainDataStationCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String name, + String linkName, + int km, + int? stoppingTime, + String? platform, + StationArrDepTime? arrival, + StationArrDepTime? departure, + @TrainDataNoteConverter() List notes}); + + @override + $StationArrDepTimeCopyWith<$Res>? get arrival; + @override + $StationArrDepTimeCopyWith<$Res>? get departure; +} + +/// @nodoc +class __$$_TrainDataStationCopyWithImpl<$Res> + extends _$TrainDataStationCopyWithImpl<$Res, _$_TrainDataStation> + implements _$$_TrainDataStationCopyWith<$Res> { + __$$_TrainDataStationCopyWithImpl( + _$_TrainDataStation _value, $Res Function(_$_TrainDataStation) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? linkName = null, + Object? km = null, + Object? stoppingTime = freezed, + Object? platform = freezed, + Object? arrival = freezed, + Object? departure = freezed, + Object? notes = null, + }) { + return _then(_$_TrainDataStation( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + linkName: null == linkName + ? _value.linkName + : linkName // ignore: cast_nullable_to_non_nullable + as String, + km: null == km + ? _value.km + : km // ignore: cast_nullable_to_non_nullable + as int, + stoppingTime: freezed == stoppingTime + ? _value.stoppingTime + : stoppingTime // ignore: cast_nullable_to_non_nullable + as int?, + platform: freezed == platform + ? _value.platform + : platform // ignore: cast_nullable_to_non_nullable + as String?, + arrival: freezed == arrival + ? _value.arrival + : arrival // ignore: cast_nullable_to_non_nullable + as StationArrDepTime?, + departure: freezed == departure + ? _value.departure + : departure // ignore: cast_nullable_to_non_nullable + as StationArrDepTime?, + notes: null == notes + ? _value._notes + : notes // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataStation implements _TrainDataStation { + const _$_TrainDataStation( + {required this.name, + required this.linkName, + required this.km, + this.stoppingTime, + this.platform, + this.arrival, + this.departure, + @TrainDataNoteConverter() required final List notes}) + : _notes = notes; + + factory _$_TrainDataStation.fromJson(Map json) => + _$$_TrainDataStationFromJson(json); + + @override + final String name; + @override + final String linkName; + @override + final int km; + @override + final int? stoppingTime; + @override + final String? platform; + @override + final StationArrDepTime? arrival; + @override + final StationArrDepTime? departure; + final List _notes; + @override + @TrainDataNoteConverter() + List get notes { + if (_notes is EqualUnmodifiableListView) return _notes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_notes); + } + + @override + String toString() { + return 'TrainDataStation(name: $name, linkName: $linkName, km: $km, stoppingTime: $stoppingTime, platform: $platform, arrival: $arrival, departure: $departure, notes: $notes)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataStation && + (identical(other.name, name) || other.name == name) && + (identical(other.linkName, linkName) || + other.linkName == linkName) && + (identical(other.km, km) || other.km == km) && + (identical(other.stoppingTime, stoppingTime) || + other.stoppingTime == stoppingTime) && + (identical(other.platform, platform) || + other.platform == platform) && + (identical(other.arrival, arrival) || other.arrival == arrival) && + (identical(other.departure, departure) || + other.departure == departure) && + const DeepCollectionEquality().equals(other._notes, _notes)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + name, + linkName, + km, + stoppingTime, + platform, + arrival, + departure, + const DeepCollectionEquality().hash(_notes)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataStationCopyWith<_$_TrainDataStation> get copyWith => + __$$_TrainDataStationCopyWithImpl<_$_TrainDataStation>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataStationToJson( + this, + ); + } +} + +abstract class _TrainDataStation implements TrainDataStation { + const factory _TrainDataStation( + {required final String name, + required final String linkName, + required final int km, + final int? stoppingTime, + final String? platform, + final StationArrDepTime? arrival, + final StationArrDepTime? departure, + @TrainDataNoteConverter() required final List notes}) = + _$_TrainDataStation; + + factory _TrainDataStation.fromJson(Map json) = + _$_TrainDataStation.fromJson; + + @override + String get name; + @override + String get linkName; + @override + int get km; + @override + int? get stoppingTime; + @override + String? get platform; + @override + StationArrDepTime? get arrival; + @override + StationArrDepTime? get departure; + @override + @TrainDataNoteConverter() + List get notes; + @override + @JsonKey(ignore: true) + _$$_TrainDataStationCopyWith<_$_TrainDataStation> get copyWith => + throw _privateConstructorUsedError; +} + +StationArrDepTime _$StationArrDepTimeFromJson(Map json) { + return _StationArrDepTime.fromJson(json); +} + +/// @nodoc +mixin _$StationArrDepTime { + DateTime get scheduleTime => throw _privateConstructorUsedError; + StationArrDepTimeStatus? get status => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationArrDepTimeCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationArrDepTimeCopyWith<$Res> { + factory $StationArrDepTimeCopyWith( + StationArrDepTime value, $Res Function(StationArrDepTime) then) = + _$StationArrDepTimeCopyWithImpl<$Res, StationArrDepTime>; + @useResult + $Res call({DateTime scheduleTime, StationArrDepTimeStatus? status}); + + $StationArrDepTimeStatusCopyWith<$Res>? get status; +} + +/// @nodoc +class _$StationArrDepTimeCopyWithImpl<$Res, $Val extends StationArrDepTime> + implements $StationArrDepTimeCopyWith<$Res> { + _$StationArrDepTimeCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scheduleTime = null, + Object? status = freezed, + }) { + return _then(_value.copyWith( + scheduleTime: null == scheduleTime + ? _value.scheduleTime + : scheduleTime // ignore: cast_nullable_to_non_nullable + as DateTime, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as StationArrDepTimeStatus?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $StationArrDepTimeStatusCopyWith<$Res>? get status { + if (_value.status == null) { + return null; + } + + return $StationArrDepTimeStatusCopyWith<$Res>(_value.status!, (value) { + return _then(_value.copyWith(status: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_StationArrDepTimeCopyWith<$Res> + implements $StationArrDepTimeCopyWith<$Res> { + factory _$$_StationArrDepTimeCopyWith(_$_StationArrDepTime value, + $Res Function(_$_StationArrDepTime) then) = + __$$_StationArrDepTimeCopyWithImpl<$Res>; + @override + @useResult + $Res call({DateTime scheduleTime, StationArrDepTimeStatus? status}); + + @override + $StationArrDepTimeStatusCopyWith<$Res>? get status; +} + +/// @nodoc +class __$$_StationArrDepTimeCopyWithImpl<$Res> + extends _$StationArrDepTimeCopyWithImpl<$Res, _$_StationArrDepTime> + implements _$$_StationArrDepTimeCopyWith<$Res> { + __$$_StationArrDepTimeCopyWithImpl( + _$_StationArrDepTime _value, $Res Function(_$_StationArrDepTime) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scheduleTime = null, + Object? status = freezed, + }) { + return _then(_$_StationArrDepTime( + scheduleTime: null == scheduleTime + ? _value.scheduleTime + : scheduleTime // ignore: cast_nullable_to_non_nullable + as DateTime, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as StationArrDepTimeStatus?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationArrDepTime implements _StationArrDepTime { + const _$_StationArrDepTime({required this.scheduleTime, this.status}); + + factory _$_StationArrDepTime.fromJson(Map json) => + _$$_StationArrDepTimeFromJson(json); + + @override + final DateTime scheduleTime; + @override + final StationArrDepTimeStatus? status; + + @override + String toString() { + return 'StationArrDepTime(scheduleTime: $scheduleTime, status: $status)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationArrDepTime && + (identical(other.scheduleTime, scheduleTime) || + other.scheduleTime == scheduleTime) && + (identical(other.status, status) || other.status == status)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, scheduleTime, status); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationArrDepTimeCopyWith<_$_StationArrDepTime> get copyWith => + __$$_StationArrDepTimeCopyWithImpl<_$_StationArrDepTime>( + this, _$identity); + + @override + Map toJson() { + return _$$_StationArrDepTimeToJson( + this, + ); + } +} + +abstract class _StationArrDepTime implements StationArrDepTime { + const factory _StationArrDepTime( + {required final DateTime scheduleTime, + final StationArrDepTimeStatus? status}) = _$_StationArrDepTime; + + factory _StationArrDepTime.fromJson(Map json) = + _$_StationArrDepTime.fromJson; + + @override + DateTime get scheduleTime; + @override + StationArrDepTimeStatus? get status; + @override + @JsonKey(ignore: true) + _$$_StationArrDepTimeCopyWith<_$_StationArrDepTime> get copyWith => + throw _privateConstructorUsedError; +} + +StationArrDepTimeStatus _$StationArrDepTimeStatusFromJson( + Map json) { + return _StationArrDepTimeStatus.fromJson(json); +} + +/// @nodoc +mixin _$StationArrDepTimeStatus { + int get delay => throw _privateConstructorUsedError; + bool get real => throw _privateConstructorUsedError; + bool get cancelled => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationArrDepTimeStatusCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationArrDepTimeStatusCopyWith<$Res> { + factory $StationArrDepTimeStatusCopyWith(StationArrDepTimeStatus value, + $Res Function(StationArrDepTimeStatus) then) = + _$StationArrDepTimeStatusCopyWithImpl<$Res, StationArrDepTimeStatus>; + @useResult + $Res call({int delay, bool real, bool cancelled}); +} + +/// @nodoc +class _$StationArrDepTimeStatusCopyWithImpl<$Res, + $Val extends StationArrDepTimeStatus> + implements $StationArrDepTimeStatusCopyWith<$Res> { + _$StationArrDepTimeStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? real = null, + Object? cancelled = null, + }) { + return _then(_value.copyWith( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + real: null == real + ? _value.real + : real // ignore: cast_nullable_to_non_nullable + as bool, + cancelled: null == cancelled + ? _value.cancelled + : cancelled // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_StationArrDepTimeStatusCopyWith<$Res> + implements $StationArrDepTimeStatusCopyWith<$Res> { + factory _$$_StationArrDepTimeStatusCopyWith(_$_StationArrDepTimeStatus value, + $Res Function(_$_StationArrDepTimeStatus) then) = + __$$_StationArrDepTimeStatusCopyWithImpl<$Res>; + @override + @useResult + $Res call({int delay, bool real, bool cancelled}); +} + +/// @nodoc +class __$$_StationArrDepTimeStatusCopyWithImpl<$Res> + extends _$StationArrDepTimeStatusCopyWithImpl<$Res, + _$_StationArrDepTimeStatus> + implements _$$_StationArrDepTimeStatusCopyWith<$Res> { + __$$_StationArrDepTimeStatusCopyWithImpl(_$_StationArrDepTimeStatus _value, + $Res Function(_$_StationArrDepTimeStatus) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? real = null, + Object? cancelled = null, + }) { + return _then(_$_StationArrDepTimeStatus( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + real: null == real + ? _value.real + : real // ignore: cast_nullable_to_non_nullable + as bool, + cancelled: null == cancelled + ? _value.cancelled + : cancelled // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationArrDepTimeStatus implements _StationArrDepTimeStatus { + const _$_StationArrDepTimeStatus( + {required this.delay, required this.real, required this.cancelled}); + + factory _$_StationArrDepTimeStatus.fromJson(Map json) => + _$$_StationArrDepTimeStatusFromJson(json); + + @override + final int delay; + @override + final bool real; + @override + final bool cancelled; + + @override + String toString() { + return 'StationArrDepTimeStatus(delay: $delay, real: $real, cancelled: $cancelled)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationArrDepTimeStatus && + (identical(other.delay, delay) || other.delay == delay) && + (identical(other.real, real) || other.real == real) && + (identical(other.cancelled, cancelled) || + other.cancelled == cancelled)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, delay, real, cancelled); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationArrDepTimeStatusCopyWith<_$_StationArrDepTimeStatus> + get copyWith => + __$$_StationArrDepTimeStatusCopyWithImpl<_$_StationArrDepTimeStatus>( + this, _$identity); + + @override + Map toJson() { + return _$$_StationArrDepTimeStatusToJson( + this, + ); + } +} + +abstract class _StationArrDepTimeStatus implements StationArrDepTimeStatus { + const factory _StationArrDepTimeStatus( + {required final int delay, + required final bool real, + required final bool cancelled}) = _$_StationArrDepTimeStatus; + + factory _StationArrDepTimeStatus.fromJson(Map json) = + _$_StationArrDepTimeStatus.fromJson; + + @override + int get delay; + @override + bool get real; + @override + bool get cancelled; + @override + @JsonKey(ignore: true) + _$$_StationArrDepTimeStatusCopyWith<_$_StationArrDepTimeStatus> + get copyWith => throw _privateConstructorUsedError; +} + +TrainDataStatus _$TrainDataStatusFromJson(Map json) { + return _TrainDataStatus.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataStatus { + int get delay => throw _privateConstructorUsedError; + String get station => throw _privateConstructorUsedError; + TrainDataStatusState get state => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataStatusCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataStatusCopyWith<$Res> { + factory $TrainDataStatusCopyWith( + TrainDataStatus value, $Res Function(TrainDataStatus) then) = + _$TrainDataStatusCopyWithImpl<$Res, TrainDataStatus>; + @useResult + $Res call({int delay, String station, TrainDataStatusState state}); +} + +/// @nodoc +class _$TrainDataStatusCopyWithImpl<$Res, $Val extends TrainDataStatus> + implements $TrainDataStatusCopyWith<$Res> { + _$TrainDataStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? station = null, + Object? state = null, + }) { + return _then(_value.copyWith( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as TrainDataStatusState, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataStatusCopyWith<$Res> + implements $TrainDataStatusCopyWith<$Res> { + factory _$$_TrainDataStatusCopyWith( + _$_TrainDataStatus value, $Res Function(_$_TrainDataStatus) then) = + __$$_TrainDataStatusCopyWithImpl<$Res>; + @override + @useResult + $Res call({int delay, String station, TrainDataStatusState state}); +} + +/// @nodoc +class __$$_TrainDataStatusCopyWithImpl<$Res> + extends _$TrainDataStatusCopyWithImpl<$Res, _$_TrainDataStatus> + implements _$$_TrainDataStatusCopyWith<$Res> { + __$$_TrainDataStatusCopyWithImpl( + _$_TrainDataStatus _value, $Res Function(_$_TrainDataStatus) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? station = null, + Object? state = null, + }) { + return _then(_$_TrainDataStatus( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as TrainDataStatusState, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataStatus extends _TrainDataStatus { + const _$_TrainDataStatus( + {required this.delay, required this.station, required this.state}) + : super._(); + + factory _$_TrainDataStatus.fromJson(Map json) => + _$$_TrainDataStatusFromJson(json); + + @override + final int delay; + @override + final String station; + @override + final TrainDataStatusState state; + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataStatus && + (identical(other.delay, delay) || other.delay == delay) && + (identical(other.station, station) || other.station == station) && + (identical(other.state, state) || other.state == state)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, delay, station, state); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataStatusCopyWith<_$_TrainDataStatus> get copyWith => + __$$_TrainDataStatusCopyWithImpl<_$_TrainDataStatus>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataStatusToJson( + this, + ); + } +} + +abstract class _TrainDataStatus extends TrainDataStatus { + const factory _TrainDataStatus( + {required final int delay, + required final String station, + required final TrainDataStatusState state}) = _$_TrainDataStatus; + const _TrainDataStatus._() : super._(); + + factory _TrainDataStatus.fromJson(Map json) = + _$_TrainDataStatus.fromJson; + + @override + int get delay; + @override + String get station; + @override + TrainDataStatusState get state; + @override + @JsonKey(ignore: true) + _$$_TrainDataStatusCopyWith<_$_TrainDataStatus> get copyWith => + throw _privateConstructorUsedError; +} + +TrainDataNoteTrainNumberChange _$TrainDataNoteTrainNumberChangeFromJson( + Map json) { + return _TrainDataNoteTrainNumberChange.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataNoteTrainNumberChange { +// base + String get kind => throw _privateConstructorUsedError; // impl + String get rank => throw _privateConstructorUsedError; + String get number => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataNoteTrainNumberChangeCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataNoteTrainNumberChangeCopyWith<$Res> { + factory $TrainDataNoteTrainNumberChangeCopyWith( + TrainDataNoteTrainNumberChange value, + $Res Function(TrainDataNoteTrainNumberChange) then) = + _$TrainDataNoteTrainNumberChangeCopyWithImpl<$Res, + TrainDataNoteTrainNumberChange>; + @useResult + $Res call({String kind, String rank, String number}); +} + +/// @nodoc +class _$TrainDataNoteTrainNumberChangeCopyWithImpl<$Res, + $Val extends TrainDataNoteTrainNumberChange> + implements $TrainDataNoteTrainNumberChangeCopyWith<$Res> { + _$TrainDataNoteTrainNumberChangeCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? rank = null, + Object? number = null, + }) { + return _then(_value.copyWith( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataNoteTrainNumberChangeCopyWith<$Res> + implements $TrainDataNoteTrainNumberChangeCopyWith<$Res> { + factory _$$_TrainDataNoteTrainNumberChangeCopyWith( + _$_TrainDataNoteTrainNumberChange value, + $Res Function(_$_TrainDataNoteTrainNumberChange) then) = + __$$_TrainDataNoteTrainNumberChangeCopyWithImpl<$Res>; + @override + @useResult + $Res call({String kind, String rank, String number}); +} + +/// @nodoc +class __$$_TrainDataNoteTrainNumberChangeCopyWithImpl<$Res> + extends _$TrainDataNoteTrainNumberChangeCopyWithImpl<$Res, + _$_TrainDataNoteTrainNumberChange> + implements _$$_TrainDataNoteTrainNumberChangeCopyWith<$Res> { + __$$_TrainDataNoteTrainNumberChangeCopyWithImpl( + _$_TrainDataNoteTrainNumberChange _value, + $Res Function(_$_TrainDataNoteTrainNumberChange) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? rank = null, + Object? number = null, + }) { + return _then(_$_TrainDataNoteTrainNumberChange( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataNoteTrainNumberChange + implements _TrainDataNoteTrainNumberChange { + const _$_TrainDataNoteTrainNumberChange( + {this.kind = "trainNumberChange", + required this.rank, + required this.number}); + + factory _$_TrainDataNoteTrainNumberChange.fromJson( + Map json) => + _$$_TrainDataNoteTrainNumberChangeFromJson(json); + +// base + @override + @JsonKey() + final String kind; +// impl + @override + final String rank; + @override + final String number; + + @override + String toString() { + return 'TrainDataNoteTrainNumberChange(kind: $kind, rank: $rank, number: $number)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataNoteTrainNumberChange && + (identical(other.kind, kind) || other.kind == kind) && + (identical(other.rank, rank) || other.rank == rank) && + (identical(other.number, number) || other.number == number)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, kind, rank, number); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataNoteTrainNumberChangeCopyWith<_$_TrainDataNoteTrainNumberChange> + get copyWith => __$$_TrainDataNoteTrainNumberChangeCopyWithImpl< + _$_TrainDataNoteTrainNumberChange>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataNoteTrainNumberChangeToJson( + this, + ); + } +} + +abstract class _TrainDataNoteTrainNumberChange + implements TrainDataNoteTrainNumberChange, TrainDataNote { + const factory _TrainDataNoteTrainNumberChange( + {final String kind, + required final String rank, + required final String number}) = _$_TrainDataNoteTrainNumberChange; + + factory _TrainDataNoteTrainNumberChange.fromJson(Map json) = + _$_TrainDataNoteTrainNumberChange.fromJson; + + @override // base + String get kind; + @override // impl + String get rank; + @override + String get number; + @override + @JsonKey(ignore: true) + _$$_TrainDataNoteTrainNumberChangeCopyWith<_$_TrainDataNoteTrainNumberChange> + get copyWith => throw _privateConstructorUsedError; +} + +TrainDataNoteDepartsAs _$TrainDataNoteDepartsAsFromJson( + Map json) { + return _TrainDataNoteDepartsAs.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataNoteDepartsAs { +// base + String get kind => throw _privateConstructorUsedError; // impl + String get rank => throw _privateConstructorUsedError; + String get number => throw _privateConstructorUsedError; + DateTime get departureDate => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataNoteDepartsAsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataNoteDepartsAsCopyWith<$Res> { + factory $TrainDataNoteDepartsAsCopyWith(TrainDataNoteDepartsAs value, + $Res Function(TrainDataNoteDepartsAs) then) = + _$TrainDataNoteDepartsAsCopyWithImpl<$Res, TrainDataNoteDepartsAs>; + @useResult + $Res call({String kind, String rank, String number, DateTime departureDate}); +} + +/// @nodoc +class _$TrainDataNoteDepartsAsCopyWithImpl<$Res, + $Val extends TrainDataNoteDepartsAs> + implements $TrainDataNoteDepartsAsCopyWith<$Res> { + _$TrainDataNoteDepartsAsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? rank = null, + Object? number = null, + Object? departureDate = null, + }) { + return _then(_value.copyWith( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + departureDate: null == departureDate + ? _value.departureDate + : departureDate // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataNoteDepartsAsCopyWith<$Res> + implements $TrainDataNoteDepartsAsCopyWith<$Res> { + factory _$$_TrainDataNoteDepartsAsCopyWith(_$_TrainDataNoteDepartsAs value, + $Res Function(_$_TrainDataNoteDepartsAs) then) = + __$$_TrainDataNoteDepartsAsCopyWithImpl<$Res>; + @override + @useResult + $Res call({String kind, String rank, String number, DateTime departureDate}); +} + +/// @nodoc +class __$$_TrainDataNoteDepartsAsCopyWithImpl<$Res> + extends _$TrainDataNoteDepartsAsCopyWithImpl<$Res, + _$_TrainDataNoteDepartsAs> + implements _$$_TrainDataNoteDepartsAsCopyWith<$Res> { + __$$_TrainDataNoteDepartsAsCopyWithImpl(_$_TrainDataNoteDepartsAs _value, + $Res Function(_$_TrainDataNoteDepartsAs) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? rank = null, + Object? number = null, + Object? departureDate = null, + }) { + return _then(_$_TrainDataNoteDepartsAs( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + departureDate: null == departureDate + ? _value.departureDate + : departureDate // ignore: cast_nullable_to_non_nullable + as DateTime, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataNoteDepartsAs implements _TrainDataNoteDepartsAs { + const _$_TrainDataNoteDepartsAs( + {this.kind = "departsAs", + required this.rank, + required this.number, + required this.departureDate}); + + factory _$_TrainDataNoteDepartsAs.fromJson(Map json) => + _$$_TrainDataNoteDepartsAsFromJson(json); + +// base + @override + @JsonKey() + final String kind; +// impl + @override + final String rank; + @override + final String number; + @override + final DateTime departureDate; + + @override + String toString() { + return 'TrainDataNoteDepartsAs(kind: $kind, rank: $rank, number: $number, departureDate: $departureDate)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataNoteDepartsAs && + (identical(other.kind, kind) || other.kind == kind) && + (identical(other.rank, rank) || other.rank == rank) && + (identical(other.number, number) || other.number == number) && + (identical(other.departureDate, departureDate) || + other.departureDate == departureDate)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, kind, rank, number, departureDate); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataNoteDepartsAsCopyWith<_$_TrainDataNoteDepartsAs> get copyWith => + __$$_TrainDataNoteDepartsAsCopyWithImpl<_$_TrainDataNoteDepartsAs>( + this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataNoteDepartsAsToJson( + this, + ); + } +} + +abstract class _TrainDataNoteDepartsAs + implements TrainDataNoteDepartsAs, TrainDataNote { + const factory _TrainDataNoteDepartsAs( + {final String kind, + required final String rank, + required final String number, + required final DateTime departureDate}) = _$_TrainDataNoteDepartsAs; + + factory _TrainDataNoteDepartsAs.fromJson(Map json) = + _$_TrainDataNoteDepartsAs.fromJson; + + @override // base + String get kind; + @override // impl + String get rank; + @override + String get number; + @override + DateTime get departureDate; + @override + @JsonKey(ignore: true) + _$$_TrainDataNoteDepartsAsCopyWith<_$_TrainDataNoteDepartsAs> get copyWith => + throw _privateConstructorUsedError; +} + +TrainDataNoteDetachingWagons _$TrainDataNoteDetachingWagonsFromJson( + Map json) { + return _TrainDataNoteDetachingWagons.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataNoteDetachingWagons { +// base + String get kind => throw _privateConstructorUsedError; // impl + String get station => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataNoteDetachingWagonsCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataNoteDetachingWagonsCopyWith<$Res> { + factory $TrainDataNoteDetachingWagonsCopyWith( + TrainDataNoteDetachingWagons value, + $Res Function(TrainDataNoteDetachingWagons) then) = + _$TrainDataNoteDetachingWagonsCopyWithImpl<$Res, + TrainDataNoteDetachingWagons>; + @useResult + $Res call({String kind, String station}); +} + +/// @nodoc +class _$TrainDataNoteDetachingWagonsCopyWithImpl<$Res, + $Val extends TrainDataNoteDetachingWagons> + implements $TrainDataNoteDetachingWagonsCopyWith<$Res> { + _$TrainDataNoteDetachingWagonsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? station = null, + }) { + return _then(_value.copyWith( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataNoteDetachingWagonsCopyWith<$Res> + implements $TrainDataNoteDetachingWagonsCopyWith<$Res> { + factory _$$_TrainDataNoteDetachingWagonsCopyWith( + _$_TrainDataNoteDetachingWagons value, + $Res Function(_$_TrainDataNoteDetachingWagons) then) = + __$$_TrainDataNoteDetachingWagonsCopyWithImpl<$Res>; + @override + @useResult + $Res call({String kind, String station}); +} + +/// @nodoc +class __$$_TrainDataNoteDetachingWagonsCopyWithImpl<$Res> + extends _$TrainDataNoteDetachingWagonsCopyWithImpl<$Res, + _$_TrainDataNoteDetachingWagons> + implements _$$_TrainDataNoteDetachingWagonsCopyWith<$Res> { + __$$_TrainDataNoteDetachingWagonsCopyWithImpl( + _$_TrainDataNoteDetachingWagons _value, + $Res Function(_$_TrainDataNoteDetachingWagons) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? station = null, + }) { + return _then(_$_TrainDataNoteDetachingWagons( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataNoteDetachingWagons implements _TrainDataNoteDetachingWagons { + const _$_TrainDataNoteDetachingWagons( + {this.kind = "detachingWagons", required this.station}); + + factory _$_TrainDataNoteDetachingWagons.fromJson(Map json) => + _$$_TrainDataNoteDetachingWagonsFromJson(json); + +// base + @override + @JsonKey() + final String kind; +// impl + @override + final String station; + + @override + String toString() { + return 'TrainDataNoteDetachingWagons(kind: $kind, station: $station)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataNoteDetachingWagons && + (identical(other.kind, kind) || other.kind == kind) && + (identical(other.station, station) || other.station == station)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, kind, station); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataNoteDetachingWagonsCopyWith<_$_TrainDataNoteDetachingWagons> + get copyWith => __$$_TrainDataNoteDetachingWagonsCopyWithImpl< + _$_TrainDataNoteDetachingWagons>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataNoteDetachingWagonsToJson( + this, + ); + } +} + +abstract class _TrainDataNoteDetachingWagons + implements TrainDataNoteDetachingWagons, TrainDataNote { + const factory _TrainDataNoteDetachingWagons( + {final String kind, + required final String station}) = _$_TrainDataNoteDetachingWagons; + + factory _TrainDataNoteDetachingWagons.fromJson(Map json) = + _$_TrainDataNoteDetachingWagons.fromJson; + + @override // base + String get kind; + @override // impl + String get station; + @override + @JsonKey(ignore: true) + _$$_TrainDataNoteDetachingWagonsCopyWith<_$_TrainDataNoteDetachingWagons> + get copyWith => throw _privateConstructorUsedError; +} + +TrainDataNoteReceivingWagons _$TrainDataNoteReceivingWagonsFromJson( + Map json) { + return _TrainDataNoteReceivingWagons.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataNoteReceivingWagons { +// base + String get kind => throw _privateConstructorUsedError; // impl + String get station => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataNoteReceivingWagonsCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataNoteReceivingWagonsCopyWith<$Res> { + factory $TrainDataNoteReceivingWagonsCopyWith( + TrainDataNoteReceivingWagons value, + $Res Function(TrainDataNoteReceivingWagons) then) = + _$TrainDataNoteReceivingWagonsCopyWithImpl<$Res, + TrainDataNoteReceivingWagons>; + @useResult + $Res call({String kind, String station}); +} + +/// @nodoc +class _$TrainDataNoteReceivingWagonsCopyWithImpl<$Res, + $Val extends TrainDataNoteReceivingWagons> + implements $TrainDataNoteReceivingWagonsCopyWith<$Res> { + _$TrainDataNoteReceivingWagonsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? station = null, + }) { + return _then(_value.copyWith( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataNoteReceivingWagonsCopyWith<$Res> + implements $TrainDataNoteReceivingWagonsCopyWith<$Res> { + factory _$$_TrainDataNoteReceivingWagonsCopyWith( + _$_TrainDataNoteReceivingWagons value, + $Res Function(_$_TrainDataNoteReceivingWagons) then) = + __$$_TrainDataNoteReceivingWagonsCopyWithImpl<$Res>; + @override + @useResult + $Res call({String kind, String station}); +} + +/// @nodoc +class __$$_TrainDataNoteReceivingWagonsCopyWithImpl<$Res> + extends _$TrainDataNoteReceivingWagonsCopyWithImpl<$Res, + _$_TrainDataNoteReceivingWagons> + implements _$$_TrainDataNoteReceivingWagonsCopyWith<$Res> { + __$$_TrainDataNoteReceivingWagonsCopyWithImpl( + _$_TrainDataNoteReceivingWagons _value, + $Res Function(_$_TrainDataNoteReceivingWagons) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? station = null, + }) { + return _then(_$_TrainDataNoteReceivingWagons( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + station: null == station + ? _value.station + : station // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataNoteReceivingWagons implements _TrainDataNoteReceivingWagons { + const _$_TrainDataNoteReceivingWagons( + {this.kind = "receivingWagons", required this.station}); + + factory _$_TrainDataNoteReceivingWagons.fromJson(Map json) => + _$$_TrainDataNoteReceivingWagonsFromJson(json); + +// base + @override + @JsonKey() + final String kind; +// impl + @override + final String station; + + @override + String toString() { + return 'TrainDataNoteReceivingWagons(kind: $kind, station: $station)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataNoteReceivingWagons && + (identical(other.kind, kind) || other.kind == kind) && + (identical(other.station, station) || other.station == station)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, kind, station); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataNoteReceivingWagonsCopyWith<_$_TrainDataNoteReceivingWagons> + get copyWith => __$$_TrainDataNoteReceivingWagonsCopyWithImpl< + _$_TrainDataNoteReceivingWagons>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataNoteReceivingWagonsToJson( + this, + ); + } +} + +abstract class _TrainDataNoteReceivingWagons + implements TrainDataNoteReceivingWagons, TrainDataNote { + const factory _TrainDataNoteReceivingWagons( + {final String kind, + required final String station}) = _$_TrainDataNoteReceivingWagons; + + factory _TrainDataNoteReceivingWagons.fromJson(Map json) = + _$_TrainDataNoteReceivingWagons.fromJson; + + @override // base + String get kind; + @override // impl + String get station; + @override + @JsonKey(ignore: true) + _$$_TrainDataNoteReceivingWagonsCopyWith<_$_TrainDataNoteReceivingWagons> + get copyWith => throw _privateConstructorUsedError; +} + +TrainDataNoteUnknown _$TrainDataNoteUnknownFromJson(Map json) { + return _TrainDataNoteUnknown.fromJson(json); +} + +/// @nodoc +mixin _$TrainDataNoteUnknown { +// base + String get kind => throw _privateConstructorUsedError; // impl + Map get extra => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainDataNoteUnknownCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainDataNoteUnknownCopyWith<$Res> { + factory $TrainDataNoteUnknownCopyWith(TrainDataNoteUnknown value, + $Res Function(TrainDataNoteUnknown) then) = + _$TrainDataNoteUnknownCopyWithImpl<$Res, TrainDataNoteUnknown>; + @useResult + $Res call({String kind, Map extra}); +} + +/// @nodoc +class _$TrainDataNoteUnknownCopyWithImpl<$Res, + $Val extends TrainDataNoteUnknown> + implements $TrainDataNoteUnknownCopyWith<$Res> { + _$TrainDataNoteUnknownCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? extra = null, + }) { + return _then(_value.copyWith( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + extra: null == extra + ? _value.extra + : extra // ignore: cast_nullable_to_non_nullable + as Map, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainDataNoteUnknownCopyWith<$Res> + implements $TrainDataNoteUnknownCopyWith<$Res> { + factory _$$_TrainDataNoteUnknownCopyWith(_$_TrainDataNoteUnknown value, + $Res Function(_$_TrainDataNoteUnknown) then) = + __$$_TrainDataNoteUnknownCopyWithImpl<$Res>; + @override + @useResult + $Res call({String kind, Map extra}); +} + +/// @nodoc +class __$$_TrainDataNoteUnknownCopyWithImpl<$Res> + extends _$TrainDataNoteUnknownCopyWithImpl<$Res, _$_TrainDataNoteUnknown> + implements _$$_TrainDataNoteUnknownCopyWith<$Res> { + __$$_TrainDataNoteUnknownCopyWithImpl(_$_TrainDataNoteUnknown _value, + $Res Function(_$_TrainDataNoteUnknown) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? kind = null, + Object? extra = null, + }) { + return _then(_$_TrainDataNoteUnknown( + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + extra: null == extra + ? _value._extra + : extra // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainDataNoteUnknown implements _TrainDataNoteUnknown { + const _$_TrainDataNoteUnknown( + {required this.kind, required final Map extra}) + : _extra = extra; + + factory _$_TrainDataNoteUnknown.fromJson(Map json) => + _$$_TrainDataNoteUnknownFromJson(json); + +// base + @override + final String kind; +// impl + final Map _extra; +// impl + @override + Map get extra { + if (_extra is EqualUnmodifiableMapView) return _extra; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_extra); + } + + @override + String toString() { + return 'TrainDataNoteUnknown(kind: $kind, extra: $extra)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainDataNoteUnknown && + (identical(other.kind, kind) || other.kind == kind) && + const DeepCollectionEquality().equals(other._extra, _extra)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, kind, const DeepCollectionEquality().hash(_extra)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainDataNoteUnknownCopyWith<_$_TrainDataNoteUnknown> get copyWith => + __$$_TrainDataNoteUnknownCopyWithImpl<_$_TrainDataNoteUnknown>( + this, _$identity); + + @override + Map toJson() { + return _$$_TrainDataNoteUnknownToJson( + this, + ); + } +} + +abstract class _TrainDataNoteUnknown + implements TrainDataNoteUnknown, TrainDataNote { + const factory _TrainDataNoteUnknown( + {required final String kind, + required final Map extra}) = _$_TrainDataNoteUnknown; + + factory _TrainDataNoteUnknown.fromJson(Map json) = + _$_TrainDataNoteUnknown.fromJson; + + @override // base + String get kind; + @override // impl + Map get extra; + @override + @JsonKey(ignore: true) + _$$_TrainDataNoteUnknownCopyWith<_$_TrainDataNoteUnknown> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/train_data.g.dart b/lib/models/train_data.g.dart new file mode 100644 index 0000000..7c355c9 --- /dev/null +++ b/lib/models/train_data.g.dart @@ -0,0 +1,217 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'train_data.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_TrainData _$$_TrainDataFromJson(Map json) => _$_TrainData( + rank: json['rank'] as String, + number: json['number'] as String, + date: json['date'] as String, + operator: json['operator'] as String, + groups: (json['groups'] as List) + .map((e) => TrainDataGroup.fromJson(e as Map)) + .toList(), + ); + +Map _$$_TrainDataToJson(_$_TrainData instance) => + { + 'rank': instance.rank, + 'number': instance.number, + 'date': instance.date, + 'operator': instance.operator, + 'groups': instance.groups, + }; + +_$_TrainDataGroup _$$_TrainDataGroupFromJson(Map json) => + _$_TrainDataGroup( + route: TrainDataRoute.fromJson(json['route'] as Map), + stations: (json['stations'] as List) + .map((e) => TrainDataStation.fromJson(e as Map)) + .toList(), + status: json['status'] == null + ? null + : TrainDataStatus.fromJson(json['status'] as Map), + ); + +Map _$$_TrainDataGroupToJson(_$_TrainDataGroup instance) => + { + 'route': instance.route, + 'stations': instance.stations, + 'status': instance.status, + }; + +_$_TrainDataRoute _$$_TrainDataRouteFromJson(Map json) => + _$_TrainDataRoute( + from: json['from'] as String, + to: json['to'] as String, + ); + +Map _$$_TrainDataRouteToJson(_$_TrainDataRoute instance) => + { + 'from': instance.from, + 'to': instance.to, + }; + +_$_TrainDataStation _$$_TrainDataStationFromJson(Map json) => + _$_TrainDataStation( + name: json['name'] as String, + linkName: json['linkName'] as String, + km: json['km'] as int, + stoppingTime: json['stoppingTime'] as int?, + platform: json['platform'] as String?, + arrival: json['arrival'] == null + ? null + : StationArrDepTime.fromJson(json['arrival'] as Map), + departure: json['departure'] == null + ? null + : StationArrDepTime.fromJson( + json['departure'] as Map), + notes: (json['notes'] as List) + .map((e) => const TrainDataNoteConverter() + .fromJson(e as Map)) + .toList(), + ); + +Map _$$_TrainDataStationToJson(_$_TrainDataStation instance) => + { + 'name': instance.name, + 'linkName': instance.linkName, + 'km': instance.km, + 'stoppingTime': instance.stoppingTime, + 'platform': instance.platform, + 'arrival': instance.arrival, + 'departure': instance.departure, + 'notes': + instance.notes.map(const TrainDataNoteConverter().toJson).toList(), + }; + +_$_StationArrDepTime _$$_StationArrDepTimeFromJson(Map json) => + _$_StationArrDepTime( + scheduleTime: DateTime.parse(json['scheduleTime'] as String), + status: json['status'] == null + ? null + : StationArrDepTimeStatus.fromJson( + json['status'] as Map), + ); + +Map _$$_StationArrDepTimeToJson( + _$_StationArrDepTime instance) => + { + 'scheduleTime': instance.scheduleTime.toIso8601String(), + 'status': instance.status, + }; + +_$_StationArrDepTimeStatus _$$_StationArrDepTimeStatusFromJson( + Map json) => + _$_StationArrDepTimeStatus( + delay: json['delay'] as int, + real: json['real'] as bool, + cancelled: json['cancelled'] as bool, + ); + +Map _$$_StationArrDepTimeStatusToJson( + _$_StationArrDepTimeStatus instance) => + { + 'delay': instance.delay, + 'real': instance.real, + 'cancelled': instance.cancelled, + }; + +_$_TrainDataStatus _$$_TrainDataStatusFromJson(Map json) => + _$_TrainDataStatus( + delay: json['delay'] as int, + station: json['station'] as String, + state: $enumDecode(_$TrainDataStatusStateEnumMap, json['state']), + ); + +Map _$$_TrainDataStatusToJson(_$_TrainDataStatus instance) => + { + 'delay': instance.delay, + 'station': instance.station, + 'state': _$TrainDataStatusStateEnumMap[instance.state]!, + }; + +const _$TrainDataStatusStateEnumMap = { + TrainDataStatusState.passing: 'passing', + TrainDataStatusState.arrival: 'arrival', + TrainDataStatusState.departure: 'departure', +}; + +_$_TrainDataNoteTrainNumberChange _$$_TrainDataNoteTrainNumberChangeFromJson( + Map json) => + _$_TrainDataNoteTrainNumberChange( + kind: json['kind'] as String? ?? "trainNumberChange", + rank: json['rank'] as String, + number: json['number'] as String, + ); + +Map _$$_TrainDataNoteTrainNumberChangeToJson( + _$_TrainDataNoteTrainNumberChange instance) => + { + 'kind': instance.kind, + 'rank': instance.rank, + 'number': instance.number, + }; + +_$_TrainDataNoteDepartsAs _$$_TrainDataNoteDepartsAsFromJson( + Map json) => + _$_TrainDataNoteDepartsAs( + kind: json['kind'] as String? ?? "departsAs", + rank: json['rank'] as String, + number: json['number'] as String, + departureDate: DateTime.parse(json['departureDate'] as String), + ); + +Map _$$_TrainDataNoteDepartsAsToJson( + _$_TrainDataNoteDepartsAs instance) => + { + 'kind': instance.kind, + 'rank': instance.rank, + 'number': instance.number, + 'departureDate': instance.departureDate.toIso8601String(), + }; + +_$_TrainDataNoteDetachingWagons _$$_TrainDataNoteDetachingWagonsFromJson( + Map json) => + _$_TrainDataNoteDetachingWagons( + kind: json['kind'] as String? ?? "detachingWagons", + station: json['station'] as String, + ); + +Map _$$_TrainDataNoteDetachingWagonsToJson( + _$_TrainDataNoteDetachingWagons instance) => + { + 'kind': instance.kind, + 'station': instance.station, + }; + +_$_TrainDataNoteReceivingWagons _$$_TrainDataNoteReceivingWagonsFromJson( + Map json) => + _$_TrainDataNoteReceivingWagons( + kind: json['kind'] as String? ?? "receivingWagons", + station: json['station'] as String, + ); + +Map _$$_TrainDataNoteReceivingWagonsToJson( + _$_TrainDataNoteReceivingWagons instance) => + { + 'kind': instance.kind, + 'station': instance.station, + }; + +_$_TrainDataNoteUnknown _$$_TrainDataNoteUnknownFromJson( + Map json) => + _$_TrainDataNoteUnknown( + kind: json['kind'] as String, + extra: json['extra'] as Map, + ); + +Map _$$_TrainDataNoteUnknownToJson( + _$_TrainDataNoteUnknown instance) => + { + 'kind': instance.kind, + 'extra': instance.extra, + }; diff --git a/lib/models/trains_result.freezed.dart b/lib/models/trains_result.freezed.dart index a17147a..f478bcb 100644 --- a/lib/models/trains_result.freezed.dart +++ b/lib/models/trains_result.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'trains_result.dart'; diff --git a/lib/pages/station_arrdep_page/view_station/view_station.dart b/lib/pages/station_arrdep_page/view_station/view_station.dart index d81c9e3..95ca5ae 100644 --- a/lib/pages/station_arrdep_page/view_station/view_station.dart +++ b/lib/pages/station_arrdep_page/view_station/view_station.dart @@ -43,8 +43,9 @@ class ViewStationPage extends HookConsumerWidget { class ViewStationArguments { final String stationName; + final DateTime? date; - const ViewStationArguments({required this.stationName}); + const ViewStationArguments({required this.stationName, this.date}); } abstract class ViewStationPageShared extends StatelessWidget { diff --git a/lib/pages/train_info_page/view_train/train_info.dart b/lib/pages/train_info_page/view_train/train_info.dart index a46670e..dcca17f 100644 --- a/lib/pages/train_info_page/view_train/train_info.dart +++ b/lib/pages/train_info_page/view_train/train_info.dart @@ -1,4 +1,7 @@ +import 'dart:async'; + import 'package:flutter/widgets.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:info_tren/api/train_data.dart'; import 'package:info_tren/components/loading/loading.dart'; @@ -9,59 +12,93 @@ import 'package:info_tren/pages/train_info_page/view_train/train_info_fluent.dar import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart'; import 'package:info_tren/providers.dart'; - -class TrainInfo extends ConsumerWidget { +class TrainInfo extends HookConsumerWidget { static String routeName = "/trainInfo/display"; - const TrainInfo({super.key,}); + const TrainInfo({ + super.key, + }); @override Widget build(BuildContext context, WidgetRef ref) { final uiDesign = ref.watch(uiDesignProvider); final args = ref.watch(trainInfoArgumentsProvider); final trainNumber = args.trainNumber; - final date = args.date; - - return RefreshFutureBuilder( - futureCreator: () => getTrain(trainNumber, date: date), - builder: (context, refresh, replaceFutureBuilder, snapshot) { - void onViewYesterdayTrain() { - replaceFutureBuilder(() => getTrain(trainNumber, date: DateTime.now().subtract(const Duration(days: 1)))); - } + final viewYesterday = useState(false); + final date = args.date ?? + DateTime.now().copyWith( + hour: 12, + minute: 0, + second: 0, + millisecond: 0, + microsecond: 0, + ); + final requestDate = + viewYesterday.value ? date.subtract(const Duration(days: 1)) : date; + final trainDataAsync = ref + .watch(trainInfoProvider(trainNumber: trainNumber, date: requestDate)); + + Future refresh() async { + ref.invalidate( + trainInfoProvider(trainNumber: trainNumber, date: requestDate), + ); + await Future.delayed(const Duration(seconds: 1)); + } - if ([RefreshFutureBuilderState.none, RefreshFutureBuilderState.waiting].contains(snapshot.state)) { - return TrainInfoLoading(title: trainNumber.toString(), loadingText: "Se încarcă...",); - } - else if (snapshot.state == RefreshFutureBuilderState.error) { - return TrainInfoError(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); - } + void onViewYesterdayTrain() { + viewYesterday.value = !viewYesterday.value; + } + useEffect(() { + final handle = Timer.periodic(const Duration(minutes: 1), (timer) { + refresh(); + }); + return () { + handle.cancel(); + }; + }); + + return trainDataAsync.when( + data: (data) { switch (uiDesign) { case UiDesign.MATERIAL: return TrainInfoMaterial( - trainData: snapshot.data!, + trainData: data, refresh: refresh, - isRefreshing: snapshot.state == RefreshFutureBuilderState.refreshing, + isRefreshing: trainDataAsync.isRefreshing, onViewYesterdayTrain: onViewYesterdayTrain, ); case UiDesign.CUPERTINO: return TrainInfoCupertino( - trainData: snapshot.data!, - refresh: refresh, - isRefreshing: snapshot.state == RefreshFutureBuilderState.refreshing, + trainData: data, + refresh: refresh, + isRefreshing: trainDataAsync.isRefreshing, onViewYesterdayTrain: onViewYesterdayTrain, ); case UiDesign.FLUENT: return TrainInfoFluent( - trainData: snapshot.data!, + trainData: data, refresh: refresh, - isRefreshing: snapshot.state == RefreshFutureBuilderState.refreshing, + isRefreshing: trainDataAsync.isRefreshing, onViewYesterdayTrain: onViewYesterdayTrain, ); default: throw UnmatchedUiDesignException(uiDesign); } }, + error: (e, st) { + return TrainInfoError( + title: '$trainNumber - Error', + error: e, + refresh: refresh, + ); + }, + loading: () { + return TrainInfoLoading( + title: trainNumber.toString(), + loadingText: "Se încarcă...", + ); + }, ); } } @@ -129,10 +166,12 @@ abstract class TrainInfoLoadingShared extends StatelessWidget { final Widget loadingWidget; TrainInfoLoadingShared({ - required this.title, - String? loadingText, + required this.title, + String? loadingText, super.key, - }) : loadingWidget = Loading(text: loadingText,); + }) : loadingWidget = Loading( + text: loadingText, + ); } class TrainInfoError extends ConsumerWidget { @@ -181,7 +220,12 @@ abstract class TrainInfoErrorShared extends StatelessWidget { final Object error; final Future Function()? refresh; - const TrainInfoErrorShared({required this.title, required this.error, this.refresh, super.key,}); + const TrainInfoErrorShared({ + required this.title, + required this.error, + this.refresh, + super.key, + }); } class TrainInfoBody extends ConsumerWidget { @@ -246,10 +290,15 @@ abstract class TrainInfoBodyShared extends StatelessWidget { } abstract class DisplayTrainYesterdayWarningCommon extends StatelessWidget { - static const trainDidNotDepart = 'Acest tren nu a plecat încă din prima gară.'; - static const seeYesterdayTrain = 'Apasă aici pentru a vedea trenul care a plecat ieri.'; + static const trainDidNotDepart = + 'Acest tren nu a plecat încă din prima gară.'; + static const seeYesterdayTrain = + 'Apasă aici pentru a vedea trenul care a plecat ieri.'; final void Function() onViewYesterdayTrain; - const DisplayTrainYesterdayWarningCommon(this.onViewYesterdayTrain, {super.key,}); + const DisplayTrainYesterdayWarningCommon( + this.onViewYesterdayTrain, { + super.key, + }); } diff --git a/lib/pages/train_info_page/view_train/train_info_cupertino.dart b/lib/pages/train_info_page/view_train/train_info_cupertino.dart index 64dcfbc..fcd783a 100644 --- a/lib/pages/train_info_page/view_train/train_info_cupertino.dart +++ b/lib/pages/train_info_page/view_train/train_info_cupertino.dart @@ -1051,8 +1051,8 @@ class DisplayTrainYesterdayWarningCupertino extends DisplayTrainYesterdayWarning const TextSpan(text: '\n'), TextSpan( text: DisplayTrainYesterdayWarningCommon.seeYesterdayTrain, - style: const TextStyle( - color: CupertinoColors.link, + style: TextStyle( + color: CupertinoTheme.of(context).primaryColor, ), recognizer: TapGestureRecognizer() ..onTap = onViewYesterdayTrain, diff --git a/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart b/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart index 1113503..ab0e541 100644 --- a/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart +++ b/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart @@ -1,13 +1,18 @@ import 'package:flutter/cupertino.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:info_tren/components/badge/badge.dart'; +import 'package:info_tren/components/cupertino_divider.dart'; +import 'package:info_tren/components/train_id_text_span.dart'; import 'package:info_tren/models.dart'; import 'package:info_tren/providers.dart'; class DisplayTrainStation extends StatelessWidget { - final Station station; + final TrainDataStation station; - const DisplayTrainStation({required this.station, super.key,}); + const DisplayTrainStation({ + required this.station, + super.key, + }); @override Widget build(BuildContext context) { @@ -15,6 +20,26 @@ class DisplayTrainStation extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ + if (station.notes.whereType().isNotEmpty) ...[ + Builder( + builder: (context) { + final note = + station.notes.whereType().first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul pleacă cu numărul '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), + ), + ); + }, + ), + const CupertinoDivider(), + ], Row( mainAxisSize: MainAxisSize.max, children: [ @@ -22,42 +47,38 @@ class DisplayTrainStation extends StatelessWidget { flex: 1, child: Align( alignment: Alignment.centerLeft, - child: Builder( - builder: (context) { - final departureStatus = station.departure?.status; - final arrivalStatus = station.arrival?.status; - int delay; - bool real; - if (departureStatus == null) { - delay = arrivalStatus?.delay ?? 0; - real = arrivalStatus?.real ?? false; - } - else if (arrivalStatus == null) { - delay = departureStatus.delay; - real = departureStatus.real; - } - else { - delay = departureStatus.delay; - real = departureStatus.real; - if (!real && arrivalStatus.real) { - delay = arrivalStatus.delay; - real = arrivalStatus.real; - } + child: Builder(builder: (context) { + final departureStatus = station.departure?.status; + final arrivalStatus = station.arrival?.status; + int delay; + bool real; + if (departureStatus == null) { + delay = arrivalStatus?.delay ?? 0; + real = arrivalStatus?.real ?? false; + } else if (arrivalStatus == null) { + delay = departureStatus.delay; + real = departureStatus.real; + } else { + delay = departureStatus.delay; + real = departureStatus.real; + if (!real && arrivalStatus.real) { + delay = arrivalStatus.delay; + real = arrivalStatus.real; } - - final isDelayed = delay > 0 && real == true; - final isOnTime = delay <= 0 && real == true; - const isNotScheduled = false; - - return Badge( - text: station.km.toString(), - caption: 'km', - isNotScheduled: isNotScheduled, - isDelayed: isDelayed, - isOnTime: isOnTime, - ); } - ), + + final isDelayed = delay > 0 && real == true; + final isOnTime = delay <= 0 && real == true; + const isNotScheduled = false; + + return Badge( + text: station.km.toString(), + caption: 'km', + isNotScheduled: isNotScheduled, + isDelayed: isDelayed, + isOnTime: isOnTime, + ); + }), ), ), Title( @@ -67,7 +88,9 @@ class DisplayTrainStation extends StatelessWidget { flex: 1, child: Align( alignment: Alignment.centerRight, - child: station.platform == null ? Container() : Badge(text: station.platform!, caption: 'linia'), + child: station.platform == null + ? Container() + : Badge(text: station.platform!, caption: 'linia'), ), ), ], @@ -75,16 +98,61 @@ class DisplayTrainStation extends StatelessWidget { Time( station: station, ), + if (station.notes.whereType().isNotEmpty) + Builder( + builder: (context) { + final note = + station.notes.whereType().first; + return Text( + 'Trenul detașează vagoane către ${note.station}', + textAlign: TextAlign.center, + ); + }, + ), + if (station.notes.whereType().isNotEmpty) + Builder( + builder: (context) { + final note = + station.notes.whereType().first; + return Text( + 'Trenul primește vagoane de la ${note.station}', + textAlign: TextAlign.center, + ); + }, + ), Delay( station: station, ), + if (station.notes + .whereType() + .isNotEmpty) ...[ + const CupertinoDivider(), + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul își schimbă numărul în '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), + ), + ); + }, + ), + ], ], ); } } class Title extends StatelessWidget { - final Station station; + final TrainDataStation station; const Title({ required this.station, @@ -96,17 +164,19 @@ class Title extends StatelessWidget { return Text( station.name, style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - fontSize: 22, - fontWeight: MediaQuery.of(context).boldText ? FontWeight.w500 : FontWeight.w300, - // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, - ), + fontSize: 22, + fontWeight: MediaQuery.of(context).boldText + ? FontWeight.w500 + : FontWeight.w300, + // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, + ), textAlign: TextAlign.center, ); } } class Time extends StatelessWidget { - final Station station; + final TrainDataStation station; const Time({ required this.station, @@ -137,21 +207,35 @@ class Time extends StatelessWidget { Text( "→", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), + ), + Container( + width: 2, + ), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), + StopTime( + station: station, + ), + Expanded( + child: Container(), + ), + DepartureTime( + station: station, + ), + Container( + width: 2, ), - Container(width: 2,), - ArrivalTime(station: station,), - Expanded(child: Container(),), - StopTime(station: station,), - Expanded(child: Container(),), - DepartureTime(station: station,), - Container(width: 2,), Text( "→", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), ), ], ); @@ -159,7 +243,7 @@ class Time extends StatelessWidget { } class ArrivalTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool finalStation; const ArrivalTime({ @@ -179,24 +263,29 @@ class ArrivalTime extends ConsumerWidget { Text( "→", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), + ), + Container( + width: 2, ), - Container(width: 2,), const Text("sosire la "), - ArrivalTime(station: station,), - Expanded(child: Container(),), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), ], ); - } - else { + } else { final delay = station.arrival!.status?.delay ?? 0; final time = tz.convertDateTime(station.arrival!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, "0")}:${time.minute.toString().padLeft(2, "0")}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, "0")}:${time.minute.toString().padLeft(2, "0")}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -206,19 +295,18 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.destructiveRed, - ), + color: CupertinoColors.destructiveRed, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -228,14 +316,14 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.systemGreen, - ), + color: CupertinoColors.systemGreen, + ), ), ], ); @@ -245,7 +333,7 @@ class ArrivalTime extends ConsumerWidget { } class StopTime extends StatelessWidget { - final Station station; + final TrainDataStation station; const StopTime({ required this.station, @@ -275,14 +363,12 @@ class StopTime extends StatelessWidget { minutes ? '1 minut' : '1 secundă', textAlign: TextAlign.center, ); - } - else if (stopsForInt < 20) { + } else if (stopsForInt < 20) { return Text( - '$stopsForInt ${minutes ? 'minute' : 'seconde'}', + '$stopsForInt ${minutes ? 'minute' : 'seconde'}', textAlign: TextAlign.center, ); - } - else { + } else { return Text( '$stopsForInt de ${minutes ? 'minute' : 'secunde'}', textAlign: TextAlign.center, @@ -296,7 +382,7 @@ class StopTime extends StatelessWidget { } class DepartureTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool firstStation; const DepartureTime({ @@ -312,27 +398,32 @@ class DepartureTime extends ConsumerWidget { return Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded(child: Container(),), + Expanded( + child: Container(), + ), const Text("plecare la "), - DepartureTime(station: station,), - Container(width: 2,), + DepartureTime( + station: station, + ), + Container( + width: 2, + ), Text( "→", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), ), ], ); - } - else { + } else { final delay = station.departure!.status?.delay ?? 0; final time = tz.convertDateTime(station.departure!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, "0")}:${time.minute.toString().padLeft(2, "0")}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, "0")}:${time.minute.toString().padLeft(2, "0")}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -342,19 +433,18 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.destructiveRed, - ), + color: CupertinoColors.destructiveRed, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -364,14 +454,14 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.systemGreen, - ), + color: CupertinoColors.systemGreen, + ), ), ], ); @@ -381,7 +471,7 @@ class DepartureTime extends ConsumerWidget { } class Delay extends StatelessWidget { - final Station station; + final TrainDataStation station; const Delay({ required this.station, @@ -404,20 +494,19 @@ class Delay extends StatelessWidget { return Text( "$delay ${delay == 1 ? 'minut' : 'minute'} întârziere", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.destructiveRed, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + color: CupertinoColors.destructiveRed, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); - } - else if (delay < 0) { + } else if (delay < 0) { return Text( "${-delay} ${delay == -1 ? 'minut' : 'minute'} mai devreme", style: CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.systemGreen, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + color: CupertinoColors.systemGreen, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); } diff --git a/lib/pages/train_info_page/view_train/train_info_fluent.dart b/lib/pages/train_info_page/view_train/train_info_fluent.dart index faf19b7..29ffa2c 100644 --- a/lib/pages/train_info_page/view_train/train_info_fluent.dart +++ b/lib/pages/train_info_page/view_train/train_info_fluent.dart @@ -748,7 +748,7 @@ class DisplayTrainYesterdayWarningFluent TextSpan( text: DisplayTrainYesterdayWarningCommon.seeYesterdayTrain, style: TextStyle( - color: Colors.blue, + color: FluentTheme.of(context).accentColor,// Colors.blue, ), recognizer: TapGestureRecognizer() ..onTap = onViewYesterdayTrain, diff --git a/lib/pages/train_info_page/view_train/train_info_fluent_DisplayTrainStation.dart b/lib/pages/train_info_page/view_train/train_info_fluent_DisplayTrainStation.dart index b860b6a..88c1f6d 100644 --- a/lib/pages/train_info_page/view_train/train_info_fluent_DisplayTrainStation.dart +++ b/lib/pages/train_info_page/view_train/train_info_fluent_DisplayTrainStation.dart @@ -1,37 +1,62 @@ import 'package:fluent_ui/fluent_ui.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:info_tren/components/badge/badge.dart'; +import 'package:info_tren/components/train_id_text_span.dart'; import 'package:info_tren/models.dart'; import 'package:info_tren/providers.dart'; class DisplayTrainStation extends StatelessWidget { - final Station station; + final TrainDataStation station; final void Function()? onTap; - const DisplayTrainStation({required this.station, this.onTap, super.key,}); + const DisplayTrainStation({ + required this.station, + this.onTap, + super.key, + }); @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(2), - child: HoverButton( - onPressed: onTap, - builder: (context, states) { - return Card( - padding: const EdgeInsets.all(2), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisSize: MainAxisSize.max, + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (station.notes.whereType().isNotEmpty) + Builder( + builder: (context) { + final note = + station.notes.whereType().first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul pleacă cu numărul '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), + ), + ); + }, + ), + Padding( + padding: const EdgeInsets.all(2), + child: HoverButton( + onPressed: onTap, + builder: (context, states) { + return Card( + padding: const EdgeInsets.all(2), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - flex: 1, - child: Align( - alignment: Alignment.centerLeft, - child: Builder( - builder: (context) { + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + flex: 1, + child: Align( + alignment: Alignment.centerLeft, + child: Builder(builder: (context) { final departureStatus = station.departure?.status; final arrivalStatus = station.arrival?.status; int delay; @@ -39,12 +64,10 @@ class DisplayTrainStation extends StatelessWidget { if (departureStatus == null) { delay = arrivalStatus?.delay ?? 0; real = arrivalStatus?.real ?? false; - } - else if (arrivalStatus == null) { + } else if (arrivalStatus == null) { delay = departureStatus.delay; real = departureStatus.real; - } - else { + } else { delay = departureStatus.delay; real = departureStatus.real; if (!real && arrivalStatus.real) { @@ -64,41 +87,94 @@ class DisplayTrainStation extends StatelessWidget { isDelayed: isDelayed, isOnTime: isOnTime, ); - } + }), + ), ), - ), + Title( + station: station, + ), + Expanded( + flex: 1, + child: (station.platform == null) + ? Container() + : Align( + alignment: Alignment.centerRight, + child: Badge( + text: station.platform!, + caption: 'linia', + ), + ), + ), + ], ), - Title( + Time( station: station, ), - Expanded( - flex: 1, - child: (station.platform == null) - ? Container() - : Align( - alignment: Alignment.centerRight, - child: Badge(text: station.platform!, caption: 'linia',), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Text( + 'Trenul detașează vagoane către ${note.station}', + textAlign: TextAlign.center, + ); + }, + ), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Text( + 'Trenul primește vagoane de la ${note.station}', + textAlign: TextAlign.center, + ); + }, ), + Delay( + station: station, ), ], ), - Time( - station: station, - ), - Delay( - station: station, + ); + }, + ), + ), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul își schimbă numărul în '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), ), - ], - ), - ); - }, - ), + ); + }, + ), + ], ); } } class Title extends StatelessWidget { - final Station station; + final TrainDataStation station; const Title({ required this.station, @@ -107,20 +183,22 @@ class Title extends StatelessWidget { @override Widget build(BuildContext context) { - return Text( + return Text( station.name, style: FluentTheme.of(context).typography.body?.copyWith( - fontSize: 22, - fontWeight: MediaQuery.of(context).boldText ? FontWeight.w500 : FontWeight.w300, - // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, - ), + fontSize: 22, + fontWeight: MediaQuery.of(context).boldText + ? FontWeight.w500 + : FontWeight.w300, + // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, + ), textAlign: TextAlign.center, ); } } class Time extends StatelessWidget { - final Station station; + final TrainDataStation station; const Time({ required this.station, @@ -151,21 +229,35 @@ class Time extends StatelessWidget { Text( "→", style: FluentTheme.of(context).typography.body?.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), + ), + Container( + width: 2, + ), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), + StopTime( + station: station, + ), + Expanded( + child: Container(), + ), + DepartureTime( + station: station, + ), + Container( + width: 2, ), - Container(width: 2,), - ArrivalTime(station: station,), - Expanded(child: Container(),), - StopTime(station: station,), - Expanded(child: Container(),), - DepartureTime(station: station,), - Container(width: 2,), Text( "→", style: FluentTheme.of(context).typography.body?.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), ), ], ); @@ -173,7 +265,7 @@ class Time extends StatelessWidget { } class ArrivalTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool finalStation; const ArrivalTime({ @@ -195,24 +287,29 @@ class ArrivalTime extends ConsumerWidget { Text( "→", style: FluentTheme.of(context).typography.body?.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), + ), + Container( + width: 2, ), - Container(width: 2,), const Text("sosire la "), - ArrivalTime(station: station,), - Expanded(child: Container(),), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), ], ); - } - else { + } else { final delay = station.arrival!.status?.delay ?? 0; final time = tz.convertDateTime(station.arrival!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -222,20 +319,19 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.red.shade300, - color: Colors.red.lighter, - ), + // color: Colors.red.shade300, + color: Colors.red.lighter, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -245,15 +341,15 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.green.shade300, - color: Colors.green.lighter, - ), + // color: Colors.green.shade300, + color: Colors.green.lighter, + ), ), ], ); @@ -263,7 +359,7 @@ class ArrivalTime extends ConsumerWidget { } class StopTime extends StatelessWidget { - final Station station; + final TrainDataStation station; const StopTime({ required this.station, @@ -292,14 +388,12 @@ class StopTime extends StatelessWidget { "1 ${minutes ? 'minut' : 'secundă'}", textAlign: TextAlign.center, ); - } - else if (stopsForInt < 20) { + } else if (stopsForInt < 20) { return Text( "$stopsForInt ${minutes ? 'minute' : 'secunde'}", textAlign: TextAlign.center, ); - } - else { + } else { return Text( "$stopsForInt de ${minutes ? 'minute' : 'secunde'}", textAlign: TextAlign.center, @@ -313,7 +407,7 @@ class StopTime extends StatelessWidget { } class DepartureTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool firstStation; const DepartureTime({ @@ -332,27 +426,32 @@ class DepartureTime extends ConsumerWidget { return Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded(child: Container(),), + Expanded( + child: Container(), + ), const Text("plecare la "), - DepartureTime(station: station,), - Container(width: 2,), + DepartureTime( + station: station, + ), + Container( + width: 2, + ), Text( "→", style: FluentTheme.of(context).typography.body?.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), ), ], ); - } - else { + } else { final delay = station.departure!.status?.delay ?? 0; final time = tz.convertDateTime(station.departure!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -362,20 +461,19 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.red.shade300, - color: Colors.red.lighter, - ), + // color: Colors.red.shade300, + color: Colors.red.lighter, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -385,15 +483,15 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.green.shade300, - color: Colors.green.lighter, - ), + // color: Colors.green.shade300, + color: Colors.green.lighter, + ), ), ], ); @@ -402,9 +500,8 @@ class DepartureTime extends ConsumerWidget { } } - class Delay extends StatelessWidget { - final Station station; + final TrainDataStation station; const Delay({ required this.station, @@ -427,22 +524,21 @@ class Delay extends StatelessWidget { return Text( "$delay ${delay == 1 ? 'minut' : 'minute'} întârziere", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.red.shade300, - color: Colors.red.lighter, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + // color: Colors.red.shade300, + color: Colors.red.lighter, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); - } - else if (delay < 0) { + } else if (delay < 0) { return Text( "${-delay} ${delay == -1 ? 'minut' : 'minute'} mai devreme", style: FluentTheme.of(context).typography.body?.copyWith( - // color: Colors.green.shade300, - color: Colors.green.lighter, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + // color: Colors.green.shade300, + color: Colors.green.lighter, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); } diff --git a/lib/pages/train_info_page/view_train/train_info_material.dart b/lib/pages/train_info_page/view_train/train_info_material.dart index 4161828..8dc3f54 100644 --- a/lib/pages/train_info_page/view_train/train_info_material.dart +++ b/lib/pages/train_info_page/view_train/train_info_material.dart @@ -9,7 +9,11 @@ import 'package:info_tren/pages/train_info_page/view_train/train_info_material_D import 'package:info_tren/utils/state_to_string.dart'; class TrainInfoLoadingMaterial extends TrainInfoLoadingShared { - TrainInfoLoadingMaterial({required super.title, super.loadingText, super.key,}); + TrainInfoLoadingMaterial({ + required super.title, + super.loadingText, + super.key, + }); @override Widget build(BuildContext context) { @@ -77,13 +81,34 @@ class TrainInfoMaterial extends TrainInfoShared { builder: (context) { return Scaffold( appBar: isSmallScreen(context) - ? null - : AppBar( - centerTitle: true, - title: Text( - "Informații despre ${trainData.rank} ${trainData.number}", + ? null + : AppBar( + centerTitle: true, + title: Text( + 'Informații despre ${trainData.rank} ${trainData.number}', + ), + actions: [ + IconButton( + tooltip: 'Reîncarcă', + icon: (isRefreshing ?? false) + ? const Center( + child: SizedBox( + height: 16, + width: 16, + child: CircularProgressIndicator( + strokeWidth: 2, + ), + ), + ) + : const Icon(Icons.refresh), + onPressed: (isRefreshing ?? false) + ? null + : () { + refresh?.call(); + }, + ), + ], ), - ), body: Column( children: [ if (isSmallScreen(context)) @@ -172,16 +197,15 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { if (onViewYesterdayTrain != null && trainData.stations.first.departure!.scheduleTime .compareTo(DateTime.now()) > - 0) - ...[ - DisplayTrainYesterdayWarningMaterial( - onViewYesterdayTrain!, - ), - Divider( - color: Colors.white70, - height: isSmallScreen(context) ? 8 : 16, - ), - ], + 0) ...[ + DisplayTrainYesterdayWarningMaterial( + onViewYesterdayTrain!, + ), + Divider( + color: Colors.white70, + height: isSmallScreen(context) ? 8 : 16, + ), + ], ], ), ), @@ -193,10 +217,7 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { ), SliverToBoxAdapter( child: Container( - height: MediaQuery - .of(context) - .viewPadding - .bottom, + height: MediaQuery.of(context).viewPadding.bottom, ), ), ], @@ -204,8 +225,7 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { ), ], ); - } - else { + } else { return CustomScrollView( slivers: [ SliverToBoxAdapter( @@ -281,11 +301,11 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { ), if (onViewYesterdayTrain != null && trainData.stations.first.departure!.scheduleTime - .compareTo(DateTime.now()) > + .compareTo(DateTime.now()) > 0) ...[ SliverToBoxAdapter( - child: DisplayTrainYesterdayWarningMaterial( - onViewYesterdayTrain!), + child: + DisplayTrainYesterdayWarningMaterial(onViewYesterdayTrain!), ), SliverToBoxAdapter( child: Divider( @@ -299,10 +319,7 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { ), SliverToBoxAdapter( child: Container( - height: MediaQuery - .of(context) - .viewPadding - .bottom, + height: MediaQuery.of(context).viewPadding.bottom, ), ), ], @@ -314,7 +331,10 @@ class TrainInfoBodyMaterial extends TrainInfoBodyShared { class DisplayTrainID extends StatelessWidget { final TrainData trainData; - const DisplayTrainID({required this.trainData, super.key,}); + const DisplayTrainID({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -335,7 +355,10 @@ class DisplayTrainID extends StatelessWidget { class DisplayTrainOperator extends StatelessWidget { final TrainData trainData; - const DisplayTrainOperator({required this.trainData, super.key,}); + const DisplayTrainOperator({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -353,7 +376,10 @@ class DisplayTrainOperator extends StatelessWidget { class DisplayTrainRoute extends StatelessWidget { final TrainData trainData; - const DisplayTrainRoute({required this.trainData, super.key,}); + const DisplayTrainRoute({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -418,7 +444,10 @@ class DisplayTrainDeparture extends StatelessWidget { class DisplayTrainLastInfo extends StatelessWidget { final TrainData trainData; - const DisplayTrainLastInfo({required this.trainData, super.key,}); + const DisplayTrainLastInfo({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -610,7 +639,10 @@ class DisplayTrainLastInfo extends StatelessWidget { class DisplayTrainDestination extends StatelessWidget { final TrainData trainData; - const DisplayTrainDestination({required this.trainData, super.key,}); + const DisplayTrainDestination({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -714,7 +746,10 @@ class DisplayTrainDestination extends StatelessWidget { class DisplayTrainRouteDistance extends StatelessWidget { final TrainData trainData; - const DisplayTrainRouteDistance({required this.trainData, super.key,}); + const DisplayTrainRouteDistance({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -751,7 +786,10 @@ class DisplayTrainRouteDistance extends StatelessWidget { class DisplayTrainRouteDuration extends StatelessWidget { final TrainData trainData; - const DisplayTrainRouteDuration({required this.trainData, super.key,}); + const DisplayTrainRouteDuration({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -834,7 +872,10 @@ class DisplayTrainRouteDuration extends StatelessWidget { class DisplayTrainYesterdayWarningMaterial extends DisplayTrainYesterdayWarningCommon { - const DisplayTrainYesterdayWarningMaterial(super.onViewYesterdayTrain, {super.key,}); + const DisplayTrainYesterdayWarningMaterial( + super.onViewYesterdayTrain, { + super.key, + }); @override Widget build(BuildContext context) { @@ -870,7 +911,10 @@ class DisplayTrainYesterdayWarningMaterial class DisplayTrainStations extends StatelessWidget { final TrainData trainData; - const DisplayTrainStations({required this.trainData, super.key,}); + const DisplayTrainStations({ + required this.trainData, + super.key, + }); @override Widget build(BuildContext context) { @@ -884,7 +928,8 @@ class DisplayTrainStations extends StatelessWidget { onTap: () { Navigator.of(context).pushNamed( ViewStationPage.routeName, - arguments: ViewStationArguments(stationName: trainData.stations[index].name), + arguments: ViewStationArguments( + stationName: trainData.stations[index].name), ); }, ), diff --git a/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart b/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart index e327b52..ad6a9a2 100644 --- a/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart +++ b/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart @@ -1,102 +1,178 @@ -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Badge; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:info_tren/components/train_id_text_span.dart'; import 'package:info_tren/models.dart'; import 'package:info_tren/components/badge/badge.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart'; import 'package:info_tren/providers.dart'; class DisplayTrainStation extends StatelessWidget { - final Station station; + final TrainDataStation station; final void Function()? onTap; - const DisplayTrainStation({required this.station, this.onTap, super.key,}); + const DisplayTrainStation({ + required this.station, + this.onTap, + super.key, + }); @override Widget build(BuildContext context) { - return Card( - child: InkWell( - onTap: onTap, - child: Padding( - padding: const EdgeInsets.all(2), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisSize: MainAxisSize.max, + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (station.notes.whereType().isNotEmpty) + Builder( + builder: (context) { + final note = + station.notes.whereType().first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul pleacă cu numărul '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), + ), + ); + }, + ), + Card( + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(2), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - flex: 1, - child: Align( - alignment: Alignment.centerLeft, - child: Builder( - builder: (context) { - final departureStatus = station.departure?.status; - final arrivalStatus = station.arrival?.status; - int delay; - bool real; - if (departureStatus == null) { - delay = arrivalStatus?.delay ?? 0; - real = arrivalStatus?.real ?? false; - } - else if (arrivalStatus == null) { - delay = departureStatus.delay; - real = departureStatus.real; - } - else { - delay = departureStatus.delay; - real = departureStatus.real; - if (!real && arrivalStatus.real) { - delay = arrivalStatus.delay; - real = arrivalStatus.real; + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + flex: 1, + child: Align( + alignment: Alignment.centerLeft, + child: Builder(builder: (context) { + final departureStatus = station.departure?.status; + final arrivalStatus = station.arrival?.status; + int delay; + bool real; + if (departureStatus == null) { + delay = arrivalStatus?.delay ?? 0; + real = arrivalStatus?.real ?? false; + } else if (arrivalStatus == null) { + delay = departureStatus.delay; + real = departureStatus.real; + } else { + delay = departureStatus.delay; + real = departureStatus.real; + if (!real && arrivalStatus.real) { + delay = arrivalStatus.delay; + real = arrivalStatus.real; + } } - } - - final isDelayed = delay > 0 && real == true; - final isOnTime = delay <= 0 && real == true; - const isNotScheduled = false; - - return Badge( - text: station.km.toString(), - caption: 'km', - isNotScheduled: isNotScheduled, - isDelayed: isDelayed, - isOnTime: isOnTime, - ); - } + + final isDelayed = delay > 0 && real == true; + final isOnTime = delay <= 0 && real == true; + const isNotScheduled = false; + + return Badge( + text: station.km.toString(), + caption: 'km', + isNotScheduled: isNotScheduled, + isDelayed: isDelayed, + isOnTime: isOnTime, + ); + }), + ), ), - ), + Title( + station: station, + ), + Expanded( + flex: 1, + child: (station.platform == null) + ? Container() + : Align( + alignment: Alignment.centerRight, + child: Badge( + text: station.platform!, + caption: 'linia', + ), + ), + ), + ], ), - Title( + Time( station: station, ), - Expanded( - flex: 1, - child: (station.platform == null) - ? Container() - : Align( - alignment: Alignment.centerRight, - child: Badge(text: station.platform!, caption: 'linia',), - ), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Text( + 'Trenul detașează vagoane către ${note.station}', + textAlign: TextAlign.center, + ); + }, + ), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Text( + 'Trenul primește vagoane de la ${note.station}', + textAlign: TextAlign.center, + ); + }, + ), + Delay( + station: station, ), ], ), - Time( - station: station, - ), - Delay( - station: station, - ), - ], + ), ), ), - ), + if (station.notes + .whereType() + .isNotEmpty) + Builder( + builder: (context) { + final note = station.notes + .whereType() + .first; + return Padding( + padding: const EdgeInsets.all(2.0), + child: Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'Trenul își schimbă numărul în '), + trainIdSpan(rank: note.rank, number: note.number), + ], + ), + ), + ); + }, + ), + ], ); } } class Title extends StatelessWidget { - final Station station; + final TrainDataStation station; const Title({ required this.station, @@ -105,20 +181,22 @@ class Title extends StatelessWidget { @override Widget build(BuildContext context) { - return Text( + return Text( station.name, style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontSize: isSmallScreen(context) ? 18 : 22, - fontWeight: MediaQuery.of(context).boldText ? FontWeight.w500 : FontWeight.w300, - // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, - ), + fontSize: isSmallScreen(context) ? 18 : 22, + fontWeight: MediaQuery.of(context).boldText + ? FontWeight.w500 + : FontWeight.w300, + // fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal, + ), textAlign: TextAlign.center, ); } } class Time extends StatelessWidget { - final Station station; + final TrainDataStation station; const Time({ required this.station, @@ -149,21 +227,35 @@ class Time extends StatelessWidget { Text( "→", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontSize: isSmallScreen(context) ? 18 : 22, - ), + fontSize: isSmallScreen(context) ? 18 : 22, + ), + ), + Container( + width: 2, + ), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), + StopTime( + station: station, + ), + Expanded( + child: Container(), + ), + DepartureTime( + station: station, + ), + Container( + width: 2, ), - Container(width: 2,), - ArrivalTime(station: station,), - Expanded(child: Container(),), - StopTime(station: station,), - Expanded(child: Container(),), - DepartureTime(station: station,), - Container(width: 2,), Text( "→", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontSize: isSmallScreen(context) ? 18 : 22, - ), + fontSize: isSmallScreen(context) ? 18 : 22, + ), ), ], ); @@ -171,7 +263,7 @@ class Time extends StatelessWidget { } class ArrivalTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool finalStation; const ArrivalTime({ @@ -193,24 +285,29 @@ class ArrivalTime extends ConsumerWidget { Text( "→", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontSize: isSmallScreen(context) ? 18 : 22, - ), + fontSize: isSmallScreen(context) ? 18 : 22, + ), + ), + Container( + width: 2, ), - Container(width: 2,), const Text("sosire la "), - ArrivalTime(station: station,), - Expanded(child: Container(),), + ArrivalTime( + station: station, + ), + Expanded( + child: Container(), + ), ], ); - } - else { + } else { final delay = station.arrival!.status?.delay ?? 0; final time = tz.convertDateTime(station.arrival!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -220,19 +317,18 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.red.shade300, - ), + color: Colors.red.shade300, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -242,14 +338,14 @@ class ArrivalTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.green.shade300, - ), + color: Colors.green.shade300, + ), ), ], ); @@ -259,7 +355,7 @@ class ArrivalTime extends ConsumerWidget { } class StopTime extends StatelessWidget { - final Station station; + final TrainDataStation station; const StopTime({ required this.station, @@ -288,14 +384,12 @@ class StopTime extends StatelessWidget { "1 ${minutes ? 'minut' : 'secundă'}", textAlign: TextAlign.center, ); - } - else if (stopsForInt < 20) { + } else if (stopsForInt < 20) { return Text( "$stopsForInt ${minutes ? 'minute' : 'secunde'}", textAlign: TextAlign.center, ); - } - else { + } else { return Text( "$stopsForInt de ${minutes ? 'minute' : 'secunde'}", textAlign: TextAlign.center, @@ -309,7 +403,7 @@ class StopTime extends StatelessWidget { } class DepartureTime extends ConsumerWidget { - final Station station; + final TrainDataStation station; final bool firstStation; const DepartureTime({ @@ -328,27 +422,32 @@ class DepartureTime extends ConsumerWidget { return Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded(child: Container(),), + Expanded( + child: Container(), + ), const Text("plecare la "), - DepartureTime(station: station,), - Container(width: 2,), + DepartureTime( + station: station, + ), + Container( + width: 2, + ), Text( "→", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontSize: 22, - ), + fontSize: 22, + ), ), ], ); - } - else { + } else { final delay = station.departure!.status?.delay ?? 0; final time = tz.convertDateTime(station.departure!.scheduleTime); if (delay == 0) { - return Text("${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); - } - else if (delay > 0) { + return Text( + "${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}"); + } else if (delay > 0) { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -358,19 +457,18 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.red.shade300, - ), + color: Colors.red.shade300, + ), ), ], ); - } - else { + } else { final oldDate = time; final newDate = oldDate.add(Duration(minutes: delay)); @@ -380,14 +478,14 @@ class DepartureTime extends ConsumerWidget { Text( "${oldDate.hour.toString().padLeft(2, '0')}:${oldDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - decoration: TextDecoration.lineThrough, - ), + decoration: TextDecoration.lineThrough, + ), ), Text( "${newDate.hour.toString().padLeft(2, '0')}:${newDate.minute.toString().padLeft(2, '0')}", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.green.shade300, - ), + color: Colors.green.shade300, + ), ), ], ); @@ -396,9 +494,8 @@ class DepartureTime extends ConsumerWidget { } } - class Delay extends StatelessWidget { - final Station station; + final TrainDataStation station; const Delay({ required this.station, @@ -421,20 +518,19 @@ class Delay extends StatelessWidget { return Text( "$delay ${delay == 1 ? 'minut' : 'minute'} întârziere", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.red.shade300, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + color: Colors.red.shade300, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); - } - else if (delay < 0) { + } else if (delay < 0) { return Text( "${-delay} ${delay == -1 ? 'minut' : 'minute'} mai devreme", style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Colors.green.shade300, - fontSize: 14, - fontStyle: FontStyle.italic, - ), + color: Colors.green.shade300, + fontSize: 14, + fontStyle: FontStyle.italic, + ), ); } diff --git a/lib/providers.dart b/lib/providers.dart index b3c0b97..7262ad4 100644 --- a/lib/providers.dart +++ b/lib/providers.dart @@ -3,13 +3,17 @@ import 'dart:developer'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:info_tren/api/station_data.dart'; +import 'package:info_tren/api/train_data.dart'; import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; import 'package:info_tren/utils/default_ui_design.dart'; import 'package:info_tren/utils/iterable_extensions.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:shared_preferences/shared_preferences.dart'; +part 'providers.g.dart'; + final sharedPreferencesProvider = Provider( (_) => throw UnimplementedError('Please override in ProviderScope'), ); @@ -76,8 +80,8 @@ final trainInfoArgumentsProvider = Provider( (_) => throw UnimplementedError('Please override in ProviderScope'), ); -final stationDataProvider = FutureProvider.family((ref, String stationName) async { - final data = await getStationData(stationName); +final stationDataProvider = FutureProvider.family((ref, ViewStationArguments args) async { + final data = await getStationData(args.stationName, args.date); final timer = Timer(const Duration(minutes: 2), () { ref.invalidateSelf(); @@ -93,6 +97,9 @@ final viewStationArgumentsProvider = Provider( ); final viewStationDataProvider = Provider((ref) { final args = ref.watch(viewStationArgumentsProvider); - final data = ref.watch(stationDataProvider(args.stationName)); + final data = ref.watch(stationDataProvider(args)); return data; }, dependencies: [viewStationArgumentsProvider, stationDataProvider]); + +@Riverpod(keepAlive: true) +Future trainInfo(TrainInfoRef ref, {required String trainNumber, DateTime? date}) => getTrain(trainNumber, date: date); diff --git a/lib/providers.g.dart b/lib/providers.g.dart new file mode 100644 index 0000000..be20723 --- /dev/null +++ b/lib/providers.g.dart @@ -0,0 +1,120 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'providers.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$trainInfoHash() => r'd25aabc3ba656acf6497ec6831e11892178b22c9'; + +/// Copied from Dart SDK +class _SystemHash { + _SystemHash._(); + + static int combine(int hash, int value) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + value); + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); + return hash ^ (hash >> 6); + } + + static int finish(int hash) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); + // ignore: parameter_assignments + hash = hash ^ (hash >> 11); + return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + } +} + +typedef TrainInfoRef = FutureProviderRef; + +/// See also [trainInfo]. +@ProviderFor(trainInfo) +const trainInfoProvider = TrainInfoFamily(); + +/// See also [trainInfo]. +class TrainInfoFamily extends Family> { + /// See also [trainInfo]. + const TrainInfoFamily(); + + /// See also [trainInfo]. + TrainInfoProvider call({ + required String trainNumber, + DateTime? date, + }) { + return TrainInfoProvider( + trainNumber: trainNumber, + date: date, + ); + } + + @override + TrainInfoProvider getProviderOverride( + covariant TrainInfoProvider provider, + ) { + return call( + trainNumber: provider.trainNumber, + date: provider.date, + ); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'trainInfoProvider'; +} + +/// See also [trainInfo]. +class TrainInfoProvider extends FutureProvider { + /// See also [trainInfo]. + TrainInfoProvider({ + required this.trainNumber, + this.date, + }) : super.internal( + (ref) => trainInfo( + ref, + trainNumber: trainNumber, + date: date, + ), + from: trainInfoProvider, + name: r'trainInfoProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$trainInfoHash, + dependencies: TrainInfoFamily._dependencies, + allTransitiveDependencies: TrainInfoFamily._allTransitiveDependencies, + ); + + final String trainNumber; + final DateTime? date; + + @override + bool operator ==(Object other) { + return other is TrainInfoProvider && + other.trainNumber == trainNumber && + other.date == date; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, trainNumber.hashCode); + hash = _SystemHash.combine(hash, date.hashCode); + + return _SystemHash.finish(hash); + } +} +// ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions