41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pweb/generated/i18n/app_localizations.dart';
|
|
|
|
|
|
class ProfileAvatar extends StatelessWidget {
|
|
const ProfileAvatar({super.key, this.avatarUrl, this.onLogout});
|
|
|
|
final String? avatarUrl;
|
|
final Future<void> Function()? onLogout;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => PopupMenuButton<int>(
|
|
tooltip: AppLocalizations.of(context)!.profile,
|
|
onSelected: (value) {
|
|
if (value == 1) onLogout?.call();
|
|
},
|
|
itemBuilder: (_) => [
|
|
PopupMenuItem<int>(
|
|
value: 1,
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.logout,
|
|
size: 20,
|
|
color: Theme.of(context).iconTheme.color,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(AppLocalizations.of(context)!.logout),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
child: CircleAvatar(
|
|
radius: 16,
|
|
foregroundImage: avatarUrl != null ? NetworkImage(avatarUrl!) : null,
|
|
child: avatarUrl == null ? const Icon(Icons.person, size: 24) : null,
|
|
),
|
|
);
|
|
}
|