// SPDX-FileCopyrightText: 2019-Present Christian Kußowski // SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat // // SPDX-License-Identifier: AGPL-3.0-or-later import 'package:async/async.dart'; import 'package:material_ui/material_ui.dart'; import 'package:matrix/matrix.dart' hide Result; import 'package:tatchat/l10n/l10n.dart'; import 'package:tatchat/widgets/avatar.dart'; import 'package:tatchat/widgets/matrix.dart'; import 'package:tatchat/widgets/self_profile_dialog.dart'; import 'chat_list.dart'; /// The header avatar of the active account. Tapping it opens the own profile /// dialog. Account switching and the former avatar popup actions live in the /// navigation drawer (Sidebar). class ClientChooserButton extends StatelessWidget { final ChatListController controller; const ClientChooserButton(this.controller, {super.key}); @override Widget build(BuildContext context) { final matrix = Matrix.of(context); final client = Result(() => matrix.client).asValue?.value; return FutureBuilder( future: client?.isLogged() == true ? client?.fetchOwnProfile() : null, builder: (context, snapshot) => Material( clipBehavior: Clip.hardEdge, borderRadius: BorderRadius.circular(99), color: Colors.transparent, child: Tooltip( message: L10n.of(context).accountsAndSettings, child: InkWell( key: const Key('accounts_and_settings_buttons'), onTap: () => showSelfProfileDialog(context), child: Avatar( mxContent: snapshot.data?.avatarUrl, name: snapshot.data?.displayName ?? client?.userID?.localpart, size: 32, ), ), ), ), ); } }