Skip to content

Commit

Permalink
feat: renamed to english terms and implemented code review inputs. (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawi-coding committed Nov 4, 2024
1 parent a29a8ad commit 1904db5
Show file tree
Hide file tree
Showing 23 changed files with 228 additions and 192 deletions.
4 changes: 2 additions & 2 deletions das_client/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'di.dart';
import 'test/fahrbild_test.dart' as fahrbild_tests;
import 'test/train_journey_test.dart' as train_journey_tests;
import 'test/navigation_test.dart' as navigation_tests;

AppLocalizations l10n = AppLocalizationsDe();
Expand All @@ -16,7 +16,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Fimber.plantTree(DebugTree());

fahrbild_tests.main();
train_journey_tests.main();
navigation_tests.main();
}

Expand Down
6 changes: 3 additions & 3 deletions das_client/integration_test/test/navigation_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/pages/fahrt/fahrt_page.dart';
import 'package:das_client/pages/journey/journey_page.dart';
import 'package:das_client/pages/links/links_page.dart';
import 'package:das_client/pages/profile/profile_page.dart';
import 'package:das_client/pages/settings/settings_page.dart';
Expand Down Expand Up @@ -93,7 +93,7 @@ void main() {
expect(find.byType(ProfilePage), findsOneWidget);
});

testWidgets('test navigate to fahrbild', (tester) async {
testWidgets('test navigate to train journey', (tester) async {
// Load app widget.
await prepareAndStartApp(tester);

Expand All @@ -119,7 +119,7 @@ void main() {
await tapElement(tester, find.text(l10n.w_navigation_drawer_fahrtinfo_title));

// Check on FahrtPage
expect(find.byType(FahrtPage), findsOneWidget);
expect(find.byType(JourneyPage), findsOneWidget);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../app_test.dart';

void main() {
group('home screen test', () {
testWidgets('load fahrbild company=1085, train=7839', (tester) async {
testWidgets('load train journey company=1085, train=7839', (tester) async {
// Load app widget.
await prepareAndStartApp(tester);

Expand All @@ -24,7 +24,7 @@ void main() {
// press load Fahrordnung button
await tester.tap(primaryButton);

// wait for fahrbild to load
// wait for train journey to load
await tester.pumpAndSettle(const Duration(seconds: 1));

// check if station is present
Expand Down
4 changes: 2 additions & 2 deletions das_client/l10n/strings_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"p_train_selection_trainnumber_placeholder": "z.B. 711",
"p_train_selection_company_description": "Company code",
"p_train_selection_company_placeholder": "z.B. 0085",
"p_fahrbild_header_button_dark_theme": "Nachtmodus",
"p_fahrbild_header_button_pause": "Pause",
"p_train_journey_header_button_dark_theme": "Nachtmodus",
"p_train_journey_header_button_pause": "Pause",
"w_navigation_drawer_fahrtinfo_title": "Fahrtinfo",
"w_navigation_drawer_links_title": "Links",
"w_navigation_drawer_settings_title": "Einstellungen",
Expand Down
35 changes: 0 additions & 35 deletions das_client/lib/bloc/fahrbild_state.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

part 'fahrbild_state.dart';
part 'train_journey_state.dart';

class FahrbildCubit extends Cubit<FahrbildState> {
FahrbildCubit({
class TrainJourneyCubit extends Cubit<TrainJourneyState> {
TrainJourneyCubit({
required SferaService sferaService,
}) : _sferaService = sferaService,
super(SelectingFahrbildState());
super(SelectingTrainJourneyState());

final SferaService _sferaService;

Expand All @@ -26,9 +26,9 @@ class FahrbildCubit extends Cubit<FahrbildState> {

StreamSubscription? _stateSubscription;

void loadFahrbild() async {
void loadTrainJourney() async {
final currentState = state;
if (currentState is SelectingFahrbildState) {
if (currentState is SelectingTrainJourneyState) {
final now = DateTime.now();
final company = currentState.company;
final trainNumber = currentState.trainNumber;
Expand All @@ -42,7 +42,7 @@ class FahrbildCubit extends Cubit<FahrbildState> {
_stateSubscription = _sferaService.stateStream.listen((state) {
switch (state) {
case SferaServiceState.connected:
emit(FahrbildLoadedState(company, trainNumber, now));
emit(TrainJourneyLoadedState(company, trainNumber, now));
break;
case SferaServiceState.connecting:
case SferaServiceState.handshaking:
Expand All @@ -52,7 +52,7 @@ class FahrbildCubit extends Cubit<FahrbildState> {
break;
case SferaServiceState.disconnected:
case SferaServiceState.offline:
emit(SelectingFahrbildState(
emit(SelectingTrainJourneyState(
company: company, trainNumber: trainNumber, errorCode: _sferaService.lastErrorCode));
break;
}
Expand All @@ -62,32 +62,32 @@ class FahrbildCubit extends Cubit<FahrbildState> {
}

void updateTrainNumber(String? trainNumber) {
if (state is SelectingFahrbildState) {
emit(SelectingFahrbildState(
if (state is SelectingTrainJourneyState) {
emit(SelectingTrainJourneyState(
trainNumber: trainNumber,
company: (state as SelectingFahrbildState).company,
errorCode: (state as SelectingFahrbildState).errorCode));
company: (state as SelectingTrainJourneyState).company,
errorCode: (state as SelectingTrainJourneyState).errorCode));
}
}

void updateCompany(String? company) {
if (state is SelectingFahrbildState) {
emit(SelectingFahrbildState(
trainNumber: (state as SelectingFahrbildState).trainNumber,
if (state is SelectingTrainJourneyState) {
emit(SelectingTrainJourneyState(
trainNumber: (state as SelectingTrainJourneyState).trainNumber,
company: company,
errorCode: (state as SelectingFahrbildState).errorCode));
errorCode: (state as SelectingTrainJourneyState).errorCode));
}
}

void reset() {
if (state is BaseFahrbildState) {
Fimber.i('Reseting fahrbild cubit in state $state');
emit(SelectingFahrbildState(
trainNumber: (state as BaseFahrbildState).trainNumber, company: (state as BaseFahrbildState).company));
if (state is BaseTrainJourneyState) {
Fimber.i('Reseting TrainJourney cubit in state $state');
emit(SelectingTrainJourneyState(
trainNumber: (state as BaseTrainJourneyState).trainNumber, company: (state as BaseTrainJourneyState).company));
}
}
}

extension ContextBlocExtension on BuildContext {
FahrbildCubit get fahrbildCubit => read<FahrbildCubit>();
TrainJourneyCubit get trainJourneyCubit => read<TrainJourneyCubit>();
}
35 changes: 35 additions & 0 deletions das_client/lib/bloc/train_journey_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
part of 'train_journey_cubit.dart';

@immutable
sealed class TrainJourneyState {}

final class SelectingTrainJourneyState extends TrainJourneyState {
SelectingTrainJourneyState({this.company, this.trainNumber, this.errorCode});

final String? trainNumber;
final String? company;
final ErrorCode? errorCode;
}

abstract class BaseTrainJourneyState extends TrainJourneyState {
BaseTrainJourneyState(this.company, this.trainNumber, this.date);

final String company;
final String trainNumber;
final DateTime date;

@override
String toString() {
return '${runtimeType.toString()}(company=$company, trainNumber=$trainNumber, date=$date)';
}
}

final class ConnectingState extends BaseTrainJourneyState {
ConnectingState(super.company, super.trainNumber, super.date);
}

final class TrainJourneyLoadedState extends BaseTrainJourneyState {
TrainJourneyLoadedState(super.company, super.trainNumber, super.date);
}


10 changes: 5 additions & 5 deletions das_client/lib/nav/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:das_client/pages/profile/profile_page.dart';
import 'package:das_client/pages/login/login_page.dart';
import 'package:das_client/pages/login/splash_page.dart';
import 'package:das_client/pages/settings/settings_page.dart';
import 'package:das_client/pages/fahrt/fahrt_page.dart';
import 'package:das_client/pages/journey/journey_page.dart';

part 'app_router.gr.dart';

Expand All @@ -14,7 +14,7 @@ class AppRouter extends RootStackRouter {
List<AutoRoute> get routes => [
_splash,
_login,
_fahrt,
_journey,
_links,
_settings,
_profile,
Expand All @@ -37,9 +37,9 @@ final _login = AutoRoute(
page: LoginRoute.page,
);

final _fahrt = AutoRoute(
path: '/fahrt',
page: FahrtRoute.page,
final _journey = AutoRoute(
path: '/journey',
page: JourneyRoute.page,
);

final _links = AutoRoute(
Expand Down
2 changes: 1 addition & 1 deletion das_client/lib/nav/das_navigation_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DASNavigationDrawer extends StatelessWidget {
context,
icon: SBBIcons.route_circle_start_small,
title: context.l10n.w_navigation_drawer_fahrtinfo_title,
route: const FahrtRoute(),
route: const JourneyRoute(),
),
_navigationTile(
context,
Expand Down
56 changes: 0 additions & 56 deletions das_client/lib/pages/fahrt/fahrbild/widgets/train_journey.dart

This file was deleted.

Loading

0 comments on commit 1904db5

Please sign in to comment.