From f0ccf59db980c3d23f7356ac563728198fe03bb4 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Mon, 24 Jul 2023 07:04:51 +0200 Subject: [PATCH] Choose ideal group until selection is implemented --- CHANGELOG.txt | 7 +++++++ lib/models/train_data.dart | 18 +++++++++++++++--- pubspec.yaml | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b4dc773..4d20f3e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +v2.7.11 +Add support for IC trains. +Allow choosing displayed timezone. +Show notes about wagon detachment, receival, or train number changes. +Use system accent color if available. +Use API v3. + v2.7.10 Add about page to Fluent UI. Add settings page, allowing changing between UIs. diff --git a/lib/models/train_data.dart b/lib/models/train_data.dart index 0ba8ea9..cfa9c5b 100644 --- a/lib/models/train_data.dart +++ b/lib/models/train_data.dart @@ -28,9 +28,21 @@ class TrainData with _$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; + TrainDataGroup get idealGroup { + var result = groups.first; + + for (final group in groups) { + if (result.stations.map((s) => s.linkName).toSet().difference(group.stations.map((s) => s.linkName).toSet()).isEmpty) { + result = group; + } + } + + return result; + } + + List get stations => idealGroup.stations; + TrainDataRoute get route => idealGroup.route; + TrainDataStatus? get status => idealGroup.status; } @freezed diff --git a/pubspec.yaml b/pubspec.yaml index 76cfb51..1bb909b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: O aplicație de vizualizare a datelor puse la dispoziție de Inform # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.7.10 +version: 2.7.11 environment: sdk: ">=3.0.0 <4.0.0"