Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow to close fahrbild #154

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion das_client/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp.router(
themeMode: ThemeMode.system,
theme: SBBTheme.light(baseStyle: SBBBaseStyle(primaryColor: SBBColors.blue)),
theme: SBBTheme.light(
baseStyle: SBBBaseStyle(
primaryColor: SBBColors.royal,
primaryColorDark: SBBColors.royal125,
)),
//darkTheme: SBBTheme.dark(),
localizationsDelegates: localizationDelegates,
supportedLocales: supportedLocales,
Expand Down
18 changes: 16 additions & 2 deletions das_client/lib/bloc/fahrbild_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,27 @@ class FahrbildCubit extends Cubit<FahrbildState> {

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

void updateCompany(String? company) {
if (state is SelectingFahrbildState) {
emit(SelectingFahrbildState(trainNumber: (state as SelectingFahrbildState).trainNumber, company: company, errorCode: (state as SelectingFahrbildState).errorCode));
emit(SelectingFahrbildState(
trainNumber: (state as SelectingFahrbildState).trainNumber,
company: company,
errorCode: (state as SelectingFahrbildState).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));
}
}

Expand Down
5 changes: 5 additions & 0 deletions das_client/lib/bloc/fahrbild_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ abstract class BaseFahrbildState extends FahrbildState {
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 BaseFahrbildState {
Expand Down
8 changes: 6 additions & 2 deletions das_client/lib/pages/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ class HomePage extends StatelessWidget {
title: context.l10n.c_app_name,
actions: [
IconButton(icon: const Icon(SBBIcons.exit_small), onPressed: () {
context.authCubit.logout();
context.router.replace(const LoginRoute());
if (context.fahrbildCubit.state is SelectingFahrbildState) {
context.authCubit.logout();
context.router.replace(const LoginRoute());
} else {
context.fahrbildCubit.reset();
}
},)
],
);
Expand Down
Loading