Skip to content

Commit

Permalink
chore: resolved team testing inputs, mainly rows overlapping bracket …
Browse files Browse the repository at this point in the history
…stations. (#81) (#500)
  • Loading branch information
rawi-coding authored Jan 20, 2025
1 parent 17511ff commit 6ea5b32
Show file tree
Hide file tree
Showing 57 changed files with 494 additions and 292 deletions.
57 changes: 41 additions & 16 deletions das_client/integration_test/test/train_journey_table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void main() {
final countText = find.descendant(of: groupOf5BaliseRow, matching: find.text('5'));
expect(countText, findsOneWidget);

final levelCrossingText = find.descendant(of: groupOf5BaliseRow, matching: find.text(l10n.p_train_journey_table_level_crossing));
final levelCrossingText =
find.descendant(of: groupOf5BaliseRow, matching: find.text(l10n.p_train_journey_table_level_crossing));
expect(levelCrossingText, findsOneWidget);

var detailRowBalise = findDASTableRowByText('41.552');
Expand All @@ -153,7 +154,9 @@ void main() {
expect(detailRowBalise, findsOneWidget);

expect(find.descendant(of: detailRowBalise, matching: find.byKey(BaliseRow.baliseIconKey)), findsOneWidget);
expect(find.descendant(of: detailRowLevelCrossing, matching: find.text(l10n.p_train_journey_table_level_crossing)), findsOneWidget);
expect(
find.descendant(of: detailRowLevelCrossing, matching: find.text(l10n.p_train_journey_table_level_crossing)),
findsOneWidget);

// collapse group
await tapElement(tester, groupOf5BaliseRow);
Expand Down Expand Up @@ -371,7 +374,7 @@ void main() {
it is Container &&
it.decoration is BoxDecoration &&
(it.decoration as BoxDecoration).color == AdditionalSpeedRestrictionRow.additionalSpeedRestrictionColor));
expect(coloredCells, findsNWidgets(12));
expect(coloredCells, findsNWidgets(13));
});

testWidgets('test other rows are displayed correctly', (tester) async {
Expand Down Expand Up @@ -594,21 +597,33 @@ void main() {
await tester.dragUntilVisible(find.text('Klammerbahnhof D1'), scrollableFinder, const Offset(0, -50));

final bracketStationD = findDASTableRowByText('Klammerbahnhof D');
final zahnstangenEnde = findDASTableRowByText('Zahnstangen Ende');
final deckungssignal = findDASTableRowByText('Deckungssignal');
final bracketStationD1 = findDASTableRowByText('Klammerbahnhof D1');
expect(bracketStationD, findsOneWidget);
expect(zahnstangenEnde, findsOneWidget);
expect(deckungssignal, findsOneWidget);
expect(bracketStationD1, findsOneWidget);

// check if the bracket station widget is displayed
final bracketStationDWidget =
find.descendant(of: bracketStationD, matching: find.byKey(BracketStationCellBody.bracketStationKey));
final zahnstangenEndeWidget =
find.descendant(of: zahnstangenEnde, matching: find.byKey(BracketStationCellBody.bracketStationKey));
final deckungssignalWidget =
find.descendant(of: deckungssignal, matching: find.byKey(BracketStationCellBody.bracketStationKey));
final bracketStationD1Widget =
find.descendant(of: bracketStationD1, matching: find.byKey(BracketStationCellBody.bracketStationKey));
expect(bracketStationDWidget, findsOneWidget);
expect(zahnstangenEndeWidget, findsOneWidget);
expect(deckungssignalWidget, findsOneWidget);
expect(bracketStationD1Widget, findsOneWidget);

// check that the abbreviation is displayed correctly
expect(find.descendant(of: bracketStationDWidget, matching: find.text('D')), findsNothing);
expect(find.descendant(of: bracketStationD1Widget, matching: find.text('D')), findsOneWidget);
expect(find.descendant(of: bracketStationDWidget, matching: find.text('D')), findsOneWidget);
expect(find.descendant(of: zahnstangenEndeWidget, matching: find.text('D')), findsNothing);
expect(find.descendant(of: deckungssignalWidget, matching: find.text('D')), findsNothing);
expect(find.descendant(of: bracketStationD1Widget, matching: find.text('D')), findsNothing);
});

testWidgets('test halt on request is displayed correctly', (tester) async {
Expand All @@ -620,7 +635,7 @@ void main() {
final scrollableFinder = find.byType(ListView);
expect(scrollableFinder, findsOneWidget);

await tester.dragUntilVisible(find.text('Halt auf Verlangen C'), scrollableFinder, const Offset(0, -50));
await tester.dragUntilVisible(find.text('Klammerbahnhof D'), scrollableFinder, const Offset(0, -50));

final stopOnDemandRow = findDASTableRowByText('Halt auf Verlangen C');
expect(stopOnDemandRow, findsOneWidget);
Expand Down Expand Up @@ -837,48 +852,58 @@ void main() {

final bernStationRow = findDASTableRowByText('Bern');
expect(bernStationRow, findsOneWidget);
final bernIncomingSpeeds = find.descendant(of: bernStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
final bernIncomingSpeeds =
find.descendant(of: bernStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
expect(bernIncomingSpeeds, findsNWidgets(2));
final bernIncomingSpeedsText = find.descendant(of: bernStationRow, matching: find.text('75-70-60'));
expect(bernIncomingSpeedsText, findsOneWidget);
final bernOutgoingSpeeds = find.descendant(of: bernStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
final bernOutgoingSpeeds =
find.descendant(of: bernStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
expect(bernOutgoingSpeeds, findsNothing);

// check station speeds for Wankdorf, no station speeds given

final wankdorfStationRow = findDASTableRowByText('Wankdorf');
expect(wankdorfStationRow, findsOneWidget);
final wankdorfIncomingSpeeds = find.descendant(of: wankdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
final wankdorfIncomingSpeeds =
find.descendant(of: wankdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
expect(wankdorfIncomingSpeeds, findsNothing);
final wankdorfOutgoingSpeeds = find.descendant(of: wankdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
final wankdorfOutgoingSpeeds =
find.descendant(of: wankdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
expect(wankdorfOutgoingSpeeds, findsNothing);

// check station speeds for Burgdorf

final burgdorfStationRow = findDASTableRowByText('Burgdorf');
expect(burgdorfStationRow, findsOneWidget);
final burgdorfIncomingSpeeds = find.descendant(of: burgdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
final burgdorfIncomingSpeeds =
find.descendant(of: burgdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
expect(burgdorfIncomingSpeeds, findsNWidgets(2));
final burgdorfIncomingSpeeds75 = find.descendant(of: burgdorfIncomingSpeeds, matching: find.text('75'));
expect(burgdorfIncomingSpeeds75, findsOneWidget);
final burgdorfIncomingSpeeds70 = find.descendant(of: burgdorfIncomingSpeeds, matching: find.text('70'));
expect(burgdorfIncomingSpeeds70, findsOneWidget);
final burgdorfIncomingSpeeds70Circled = find.ancestor(of: burgdorfIncomingSpeeds70, matching: find.byKey(GraduatedSpeedsCellBody.circledSpeedKey));
final burgdorfIncomingSpeeds70Circled =
find.ancestor(of: burgdorfIncomingSpeeds70, matching: find.byKey(GraduatedSpeedsCellBody.circledSpeedKey));
expect(burgdorfIncomingSpeeds70Circled, findsOneWidget);
final burgdorfOutgoingSpeeds = find.descendant(of: burgdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
final burgdorfOutgoingSpeeds =
find.descendant(of: burgdorfStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
expect(burgdorfOutgoingSpeeds, findsOneWidget);
final burgdorfOutgoingSpeeds60 = find.descendant(of: burgdorfOutgoingSpeeds, matching: find.text('60'));
expect(burgdorfOutgoingSpeeds60, findsOneWidget);
final burgdorfOutgoingSpeeds60Squared = find.ancestor(of: burgdorfOutgoingSpeeds60, matching: find.byKey(GraduatedSpeedsCellBody.squaredSpeedKey));
final burgdorfOutgoingSpeeds60Squared =
find.ancestor(of: burgdorfOutgoingSpeeds60, matching: find.byKey(GraduatedSpeedsCellBody.squaredSpeedKey));
expect(burgdorfOutgoingSpeeds60Squared, findsOneWidget);

// check station speeds for Olten, no graduated speed for train series R

final oltenStationRow = findDASTableRowByText('Olten');
expect(oltenStationRow, findsOneWidget);
final oltenIncomingSpeeds = find.descendant(of: oltenStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
final oltenIncomingSpeeds =
find.descendant(of: oltenStationRow, matching: find.byKey(GraduatedSpeedsCellBody.incomingSpeedsKey));
expect(oltenIncomingSpeeds, findsOneWidget);
final oltenOutgoingSpeeds = find.descendant(of: oltenStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
final oltenOutgoingSpeeds =
find.descendant(of: oltenStationRow, matching: find.byKey(GraduatedSpeedsCellBody.outgoingSpeedsKey));
expect(oltenOutgoingSpeeds, findsNothing);

});
Expand Down
2 changes: 1 addition & 1 deletion das_client/lib/app/bloc/train_journey_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

import 'package:das_client/app/model/ru.dart';
import 'package:das_client/app/model/train_journey_settings.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/config/train_journey_settings.dart';
import 'package:das_client/model/journey/break_series.dart';
import 'package:das_client/model/journey/journey.dart';
import 'package:das_client/sfera/sfera_component.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:das_client/app/pages/journey/train_journey/widgets/header/header
import 'package:das_client/app/pages/journey/train_journey/widgets/train_journey.dart';
import 'package:flutter/material.dart';

// TODO: handle extraLarge font sizes (diff to figma) globally.
class TrainJourneyOverview extends StatelessWidget {
const TrainJourneyOverview({super.key});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ class AdditionalSpeedRestrictionRow extends BaseRowBuilder<AdditionalSpeedRestri
static const Key additionalSpeedRestrictionIconKey = Key('addition_speed_restriction_icon_key');
static const Color additionalSpeedRestrictionColor = SBBColors.orange;

AdditionalSpeedRestrictionRow({
const AdditionalSpeedRestrictionRow({
required super.metadata,
required super.data,
required super.settings,
super.trackEquipmentRenderData,
super.config,
}) : super(rowColor: additionalSpeedRestrictionColor);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';
class BaliseLevelCrossingGroupRow extends BaseRowBuilder<BaliseLevelCrossingGroup> {
static const Key baliseIconKey = Key('balise_icon_key');

BaliseLevelCrossingGroupRow({
const BaliseLevelCrossingGroupRow({
required super.metadata,
required super.data,
required super.settings,
super.trackEquipmentRenderData,
super.config,
super.onTap,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';
class BaliseRow extends BaseRowBuilder<Balise> {
static const Key baliseIconKey = Key('balise_icon_key');

BaliseRow({
const BaliseRow({
required super.metadata,
required super.data,
required super.settings,
super.trackEquipmentRenderData,
super.config,
super.isGrouped,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:das_client/app/model/train_journey_settings.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/additional_speed_restriction_row.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/graduated_speeds_cell_body.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/bracket_station_cell_body.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/route_cell_body.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/track_equipment_cell_body.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/track_equipment_render_data.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/config/train_journey_config.dart';
import 'package:das_client/app/widgets/table/das_table_cell.dart';
import 'package:das_client/app/widgets/table/das_table_row.dart';
import 'package:das_client/model/journey/additional_speed_restriction.dart';
Expand All @@ -19,9 +19,8 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
const BaseRowBuilder({
required this.metadata,
required this.data,
required this.settings,
super.height = rowHeight,
this.trackEquipmentRenderData = const TrackEquipmentRenderData(),
this.config = const TrainJourneyConfig(),
this.defaultAlignment = Alignment.bottomCenter,
this.rowColor,
this.onTap,
Expand All @@ -32,8 +31,7 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
final Color? rowColor;
final Metadata metadata;
final T data;
final TrackEquipmentRenderData trackEquipmentRenderData;
final TrainJourneySettings settings;
final TrainJourneyConfig config;
final VoidCallback? onTap;
final bool isGrouped;

Expand All @@ -49,6 +47,7 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
routeCell(context),
trackEquipment(context),
iconsCell1(context),
bracketStation(context),
informationCell(context),
iconsCell2(context),
iconsCell3(context),
Expand Down Expand Up @@ -93,12 +92,16 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
}

DASTableCell trackEquipment(BuildContext context) {
if (config.trackEquipmentRenderData == null) {
return DASTableCell.empty(color: specialCellColor);
}

return DASTableCell(
color: specialCellColor,
padding: EdgeInsets.all(0.0),
alignment: null,
child: TrackEquipmentCellBody(
renderData: trackEquipmentRenderData,
renderData: config.trackEquipmentRenderData!,
),
);
}
Expand Down Expand Up @@ -128,8 +131,10 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
return DASTableCell.empty();
}

final currentTrainSeries = settings.selectedBreakSeries?.trainSeries ?? metadata.breakSeries?.trainSeries;
final currentBreakSeries = settings.selectedBreakSeries?.breakSeries ?? metadata.breakSeries?.breakSeries;
final currentTrainSeries =
config.settings.selectedBreakSeries?.trainSeries ?? metadata.breakSeries?.trainSeries;
final currentBreakSeries =
config.settings.selectedBreakSeries?.breakSeries ?? metadata.breakSeries?.breakSeries;

final graduatedSpeeds = speedData.speedsFor(currentTrainSeries, currentBreakSeries);
if (graduatedSpeeds == null) {
Expand All @@ -150,6 +155,21 @@ class BaseRowBuilder<T extends BaseData> extends DASTableRowBuilder {
return DASTableCell.empty();
}

DASTableCell bracketStation(BuildContext context) {
final bracketStationRenderData = config.bracketStationRenderData;
if (bracketStationRenderData == null) return DASTableCell.empty();

return DASTableCell(
padding: EdgeInsets.all(0.0),
clipBehaviour: Clip.none,
child: BracketStationCellBody(
stationAbbreviation:
config.bracketStationRenderData!.isStart ? bracketStationRenderData.stationAbbreviation : null,
height: height,
),
);
}

DASTableCell iconsCell2(BuildContext context) {
return DASTableCell.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class CABSignalingRow extends BaseRowBuilder<CABSignaling> {
static const Key cabSignalingStartIconKey = Key('cab_signaling_start_icon_key');
static const Key cabSignalingEndIconKey = Key('cab_signaling_end_icon_key');

CABSignalingRow({
const CABSignalingRow({
required super.metadata,
required super.data,
required super.settings,
super.trackEquipmentRenderData,
super.config,
});

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
import 'package:das_client/app/widgets/das_text_styles.dart';
import 'package:das_client/model/journey/bracket_station.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';
import 'package:das_client/app/widgets/table/das_table_theme.dart';
import 'package:flutter/material.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';

class BracketStationCellBody extends StatelessWidget {
static const Key bracketStationKey = Key('bracketStationKey');
static const double _bracketStationWidth = 16.0;
static const double _bracketStationFontSize = 12.0;

const BracketStationCellBody({
required this.bracketStation,
required this.stationAbbreviation,
required this.height,
super.key,
});

final BracketStation bracketStation;
final String? stationAbbreviation;
final double height;

@override
Widget build(BuildContext context) {
return Positioned(
top: -sbbDefaultSpacing,
bottom: -sbbDefaultSpacing,
right: 0,
child: Container(
key: bracketStationKey,
height: height,
width: _bracketStationWidth,
color: SBBColors.black,
child: Align(
alignment: Alignment.center,
child: RotatedBox(
quarterTurns: -1,
child: Text(
bracketStation.mainStationAbbreviation ?? '',
style: DASTextStyles.extraSmallBold.copyWith(
color: SBBColors.white,
fontSize: _bracketStationFontSize,
height: _bracketStationWidth / _bracketStationFontSize,
final tableBorder = DASTableTheme.of(context)?.data.tableBorder;
final bottomBorder = -(tableBorder?.horizontalInside.width ?? 0);
return Stack(
clipBehavior: Clip.none,
children: [
Positioned(
top: 0,
bottom: bottomBorder,
left: -_bracketStationWidth,
child: Container(
key: bracketStationKey,
height: height,
width: _bracketStationWidth,
color: SBBColors.black,
child: Align(
alignment: Alignment.center,
child: RotatedBox(
quarterTurns: -1,
child: Text(
stationAbbreviation ?? '',
style: DASTextStyles.extraSmallBold.copyWith(
color: SBBColors.white,
fontSize: _bracketStationFontSize,
height: _bracketStationWidth / _bracketStationFontSize,
),
),
),
),
),
),
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:das_client/app/pages/journey/train_journey/widgets/table/cells/track_equipment_render_data.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/table/config/track_equipment_render_data.dart';
import 'package:das_client/app/widgets/table/das_table_theme.dart';
import 'package:das_client/model/journey/track_equipment.dart';
import 'package:das_client/model/journey/track_equipment_segment.dart';
import 'package:flutter/material.dart';

class TrackEquipmentCellBody extends StatelessWidget {
Expand Down
Loading

0 comments on commit 6ea5b32

Please sign in to comment.