Skip to content

Commit

Permalink
chore: refactor structure (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grodien authored Nov 5, 2024
1 parent a54eceb commit c35b1e6
Show file tree
Hide file tree
Showing 108 changed files with 508 additions and 385 deletions.
Binary file removed .github/.DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion das_client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ migrate_working_dir/
.idea/
coverage/


# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
Expand Down Expand Up @@ -52,3 +51,6 @@ app.*.map.json
*.gr.dart
*.freezed.dart
*.mocks.dart

# FVM Version Cache
.fvm/
2 changes: 2 additions & 0 deletions das_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ This application uses the code style defined in the [Flutter Wiki][2]. The
recommendations are mandatory and should always be followed unless there is a
good reason not to do so. However, this must be approved by all developers.

Notable difference: Line length is set to 120 characters. Please adapt your IDE configuration accordingly.

## Flutter SDK version

This app uses [FVM][1] to configure the Flutter SDK version.
Expand Down
2 changes: 1 addition & 1 deletion das_client/integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:das_client/flavor.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/main.dart';
import 'package:fimber/fimber.dart';
import 'package:flutter_gen/gen_l10n/app_localizations_de.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/auth/authentication_component.dart';
import 'package:flutter/foundation.dart';
import 'package:sbb_oidc/sbb_oidc.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/service/mqtt/mqtt_client_connector.dart';
import 'package:das_client/mqtt/mqtt_component.dart';
import 'package:fimber/fimber.dart';
import 'package:mqtt_client/mqtt_client.dart';

Expand Down
14 changes: 8 additions & 6 deletions das_client/integration_test/di.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/auth/authentication_component.dart';
import 'package:das_client/di.dart';
import 'package:das_client/flavor.dart';
import 'package:das_client/service/mqtt/mqtt_client_connector.dart';
import 'package:das_client/mqtt/mqtt_component.dart';
import 'package:fimber/fimber.dart';
import 'package:get_it/get_it.dart';

Expand All @@ -10,6 +10,7 @@ import 'auth/mqtt_client_user_connector.dart';

class IntegrationTestDI {
const IntegrationTestDI._();

static bool _initialized = false;

static Future<void> init(Flavor flavor) {
Expand All @@ -21,11 +22,12 @@ class IntegrationTestDI {
GetIt.I.registerTokenSpecProvider();
GetIt.I.registerOidcClient();
_registerIntegrationTestAuthenticator();
GetIt.I.registerSferaAuthService();
GetIt.I.registerSferaComponents();
GetIt.I.registerMqttComponent();

GetIt.I.unregister<MqttClientConnector>();
_registerMqttClientConnector();
GetIt.I.registerMqttService();
GetIt.I.registerRepositories();
GetIt.I.registerSferaService();

_initialized = true;
}
return GetIt.I.allReady();
Expand Down
8 changes: 4 additions & 4 deletions das_client/integration_test/test/navigation_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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';
import 'package:das_client/app/pages/journey/journey_page.dart';
import 'package:das_client/app/pages/links/links_page.dart';
import 'package:das_client/app/pages/profile/profile_page.dart';
import 'package:das_client/app/pages/settings/settings_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
4 changes: 2 additions & 2 deletions das_client/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/app_router.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/app_router.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import 'dart:async';

import 'package:das_client/model/sfera/journey_profile.dart';
import 'package:das_client/model/sfera/otn_id.dart';
import 'package:das_client/model/sfera/segment_profile.dart';
import 'package:das_client/service/sfera/sfera_service.dart';
import 'package:das_client/service/sfera/sfera_service_state.dart';
import 'package:das_client/sfera/sfera_component.dart';
import 'package:das_client/util/error_code.dart';
import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -83,7 +79,8 @@ class TrainJourneyCubit extends Cubit<TrainJourneyState> {
if (state is BaseTrainJourneyState) {
Fimber.i('Reseting TrainJourney cubit in state $state');
emit(SelectingTrainJourneyState(
trainNumber: (state as BaseTrainJourneyState).trainNumber, company: (state as BaseTrainJourneyState).company));
trainNumber: (state as BaseTrainJourneyState).trainNumber,
company: (state as BaseTrainJourneyState).company));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

export 'package:flutter_gen/gen_l10n/app_localizations.dart';
export 'package:das_client/i18n/src/build_context_x.dart';
export 'package:das_client/app/i18n/src/build_context_x.dart';

const localizationDelegates = <LocalizationsDelegate<dynamic>>[
AppLocalizations.delegate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:flutter/widgets.dart';

extension BuildContextX on BuildContext {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/pages/links/links_page.dart';
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/journey/journey_page.dart';
import 'package:das_client/app/pages/links/links_page.dart';
import 'package:das_client/app/pages/profile/profile_page.dart';
import 'package:das_client/app/pages/login/login_page.dart';
import 'package:das_client/app/pages/login/splash_page.dart';
import 'package:das_client/app/pages/settings/settings_page.dart';
import 'package:das_client/app/pages/journey/journey_page.dart';

part 'app_router.gr.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/app_router.dart';
import 'package:das_client/widgets/app_version_text.dart';
import 'package:das_client/widgets/device_id_text.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/app_router.dart';
import 'package:das_client/app/widgets/app_version_text.dart';
import 'package:das_client/app/widgets/device_id_text.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/auth/auth_cubit.dart';
import 'package:das_client/bloc/train_journey_cubit.dart';
import 'package:das_client/auth/authentication_component.dart';
import 'package:das_client/app/bloc/train_journey_cubit.dart';
import 'package:das_client/di.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/app_router.dart';
import 'package:das_client/nav/das_navigation_drawer.dart';
import 'package:das_client/pages/journey/train_journey/train_journey_overview.dart';
import 'package:das_client/pages/journey/train_selection/train_selection.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/app_router.dart';
import 'package:das_client/app/nav/das_navigation_drawer.dart';
import 'package:das_client/app/pages/journey/train_journey/train_journey_overview.dart';
import 'package:das_client/app/pages/journey/train_selection/train_selection.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:das_client/pages/journey/train_journey/widgets/header/adl_notification.dart';
import 'package:das_client/pages/journey/train_journey/widgets/header/header.dart';
import 'package:das_client/pages/journey/train_journey/widgets/train_journey.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/adl_notification.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/header.dart';
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:das_client/pages/journey/train_journey/widgets/header/main_container.dart';
import 'package:das_client/pages/journey/train_journey/widgets/header/time_container.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/main_container.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/time_container.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:das_client/pages/journey/train_journey/widgets/header/departure_authorization.dart';
import 'package:das_client/pages/journey/train_journey/widgets/header/radio_channel.dart';
import 'package:das_client/util/widget_extensions.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/departure_authorization.dart';
import 'package:das_client/app/pages/journey/train_journey/widgets/header/radio_channel.dart';
import 'package:das_client/app/widgets/widget_extensions.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'package:das_client/bloc/train_journey_cubit.dart';
import 'package:das_client/model/sfera/journey_profile.dart';
import 'package:das_client/model/sfera/segment_profile.dart';
import 'package:das_client/model/sfera/timing_point.dart';
import 'package:das_client/model/sfera/timing_point_constraints.dart';
import 'package:das_client/model/sfera/tp_id_reference.dart';
import 'package:das_client/app/bloc/train_journey_cubit.dart';
import 'package:das_client/sfera/sfera_component.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';
Expand All @@ -16,8 +12,7 @@ class TrainJourney extends StatelessWidget {
final bloc = context.trainJourneyCubit;

return StreamBuilder<List<dynamic>>(
stream:
CombineLatestStream.list([bloc.journeyStream, bloc.segmentStream]),
stream: CombineLatestStream.list([bloc.journeyStream, bloc.segmentStream]),
builder: (context, snapshot) {
JourneyProfile? journeyProfile = snapshot.data?[0];
List<SegmentProfile> segmentProfiles = snapshot.data?[1] ?? [];
Expand All @@ -34,23 +29,17 @@ class TrainJourney extends StatelessWidget {
List<SegmentProfile> segmentProfiles,
) {
final timingPoints = journeyProfile.segmentProfilesLists
.expand((it) => it.timingPoints
.toList()
.sublist(it == journeyProfile.segmentProfilesLists.first ? 0 : 1))
.expand((it) => it.timingPoints.toList().sublist(it == journeyProfile.segmentProfilesLists.first ? 0 : 1))
.toList();

final points = segmentProfiles
.expand((it) => it.points?.timingPoints.toList() ?? <TimingPoint>[]);
final points = segmentProfiles.expand((it) => it.points?.timingPoints.toList() ?? <TimingPoint>[]);

return SingleChildScrollView(
child: Column(
children: [
...List.generate(timingPoints.length, (index) {
var timingPoint = timingPoints[index];
var tpId = timingPoint.timingPointReference.children
.whereType<TpIdReference>()
.firstOrNull
?.tpId;
var tpId = timingPoint.timingPointReference.children.whereType<TpIdReference>().firstOrNull?.tpId;
var tp = points.where((point) => point.id == tpId).firstOrNull;
return Padding(
padding: const EdgeInsets.all(sbbDefaultSpacing * 0.5),
Expand All @@ -68,8 +57,7 @@ class TrainJourney extends StatelessWidget {
);
}

Widget _servicePointName(TimingPoint? tp) =>
Text(tp?.names.first.name ?? 'Unknown');
Widget _servicePointName(TimingPoint? tp) => Text(tp?.names.first.name ?? 'Unknown');

Widget _arrivalTime(TimingPointConstraints timingPoint) {
return Text(timingPoint.attributes['TP_PlannedLatestArrivalTime'] ?? '');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:das_client/bloc/train_journey_cubit.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/app/bloc/train_journey_cubit.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/das_navigation_drawer.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/das_navigation_drawer.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/auth/authentication_component.dart';
import 'package:das_client/di.dart';
import 'package:das_client/flavor.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/app_router.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/app_router.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/auth/auth_cubit.dart';
import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/app/nav/app_router.dart';
import 'package:das_client/auth/authentication_component.dart';
import 'package:das_client/di.dart';
import 'package:das_client/nav/app_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/das_navigation_drawer.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/das_navigation_drawer.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:das_client/i18n/i18n.dart';
import 'package:das_client/nav/das_navigation_drawer.dart';
import 'package:das_client/app/i18n/i18n.dart';
import 'package:das_client/app/nav/das_navigation_drawer.dart';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';

Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions das_client/lib/auth/authentication_component.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:das_client/auth/src/authenticator.dart';
import 'package:das_client/auth/src/azure_authenticator.dart';
import 'package:das_client/auth/src/token_spec_provider.dart';
import 'package:sbb_oidc/sbb_oidc.dart';

export 'package:das_client/auth/src/auth_cubit.dart';
export 'package:das_client/auth/src/authenticator.dart';
export 'package:das_client/auth/src/authenticator_config.dart';
export 'package:das_client/auth/src/token_spec_provider.dart';
export 'package:das_client/auth/src/token_spec.dart';

class AuthenticationComponent {
const AuthenticationComponent._();

static Authenticator createAzureAuthenticator(
{required OidcClient oidcClient, required TokenSpecProvider tokenSpecs}) {
return AzureAuthenticator(oidcClient: oidcClient, tokenSpecs: tokenSpecs);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/auth/src/authenticator.dart';
import 'package:das_client/di.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:das_client/auth/token_spec_provider.dart';
import 'package:das_client/auth/src/token_spec_provider.dart';
import 'package:meta/meta.dart';

@sealed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';

import 'package:das_client/auth/authenticator.dart';
import 'package:das_client/auth/token_spec.dart';
import 'package:das_client/auth/token_spec_provider.dart';
import 'package:das_client/auth/src/authenticator.dart';
import 'package:das_client/auth/src/token_spec.dart';
import 'package:das_client/auth/src/token_spec_provider.dart';
import 'package:sbb_oidc/sbb_oidc.dart';

class AzureAuthenticator implements Authenticator {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:collection/collection.dart';
import 'package:das_client/auth/token_spec.dart';
import 'package:das_client/auth/src/token_spec.dart';

class TokenSpecProvider {
const TokenSpecProvider(this._specs);
Expand Down
File renamed without changes.
Loading

0 comments on commit c35b1e6

Please sign in to comment.