36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../model/account_data.dart';
|
|
import '../../../../widget/centered_leading.dart';
|
|
import '../../../../widget/confirm_dialog.dart';
|
|
|
|
class AccountSection extends StatelessWidget {
|
|
const AccountSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListTile(
|
|
leading: const CenteredLeading(Icon(Icons.logout_outlined)),
|
|
title: const Text('Konto abmelden'),
|
|
subtitle: Text('Angemeldet als ${AccountData().getUsername()}'),
|
|
onTap: () => _showLogoutDialog(context),
|
|
);
|
|
|
|
void _showLogoutDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (dialogContext) => ConfirmDialog(
|
|
title: 'Abmelden?',
|
|
content: 'Möchtest du dich wirklich abmelden?',
|
|
confirmButton: 'Abmelden',
|
|
// Cleanup of caches, hydrated bloc storage and bloc in-memory state is
|
|
// handled by the AccountBloc listener in main.dart on the loggedOut
|
|
// transition. Doing the cleanup *before* setting loggedOut caused
|
|
// rebuilds in the still-mounted App tree (TimetableBloc/ChatListBloc
|
|
// emitting empty states) which raced with the home-route swap and
|
|
// produced a black screen.
|
|
onConfirmAsync: () => AccountData().removeData(context: context),
|
|
),
|
|
);
|
|
}
|
|
}
|