2022-10-31 17:15:05 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2022-08-26 15:31:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-21 10:42:32 +02:00
|
|
|
import 'package:flutter_profile/src/models/user.dart';
|
2022-10-21 10:53:38 +02:00
|
|
|
import 'package:flutter_profile/src/widgets/avatar/avatar.dart';
|
2022-08-26 15:31:42 +02:00
|
|
|
|
2022-11-24 14:56:21 +01:00
|
|
|
class AvatarWrapper extends StatelessWidget {
|
|
|
|
const AvatarWrapper({
|
2022-10-21 10:42:32 +02:00
|
|
|
required this.user,
|
2024-02-02 11:07:55 +01:00
|
|
|
super.key,
|
2022-11-24 14:56:21 +01:00
|
|
|
this.showName = false,
|
|
|
|
this.padding = const EdgeInsets.only(top: 16),
|
|
|
|
this.size = 100,
|
|
|
|
this.textStyle,
|
|
|
|
this.customAvatar,
|
2023-10-06 10:33:02 +02:00
|
|
|
this.avatarBackgroundColor,
|
2024-02-02 11:07:55 +01:00
|
|
|
});
|
2022-08-26 15:31:42 +02:00
|
|
|
|
2022-10-21 10:42:32 +02:00
|
|
|
final User user;
|
2022-11-24 14:56:21 +01:00
|
|
|
final Widget? customAvatar;
|
2023-10-06 10:33:02 +02:00
|
|
|
final Color? avatarBackgroundColor;
|
2022-11-24 14:56:21 +01:00
|
|
|
final bool showName;
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final TextStyle? textStyle;
|
|
|
|
final double size;
|
2022-08-26 15:31:42 +02:00
|
|
|
|
|
|
|
@override
|
2022-10-21 10:53:38 +02:00
|
|
|
Widget build(BuildContext context) {
|
2022-11-24 14:56:21 +01:00
|
|
|
var avatar = customAvatar ??
|
2022-10-21 10:53:38 +02:00
|
|
|
Avatar(
|
|
|
|
user: user,
|
2022-11-24 14:56:21 +01:00
|
|
|
size: size,
|
2023-10-06 10:33:02 +02:00
|
|
|
avatarBackgroundColor: avatarBackgroundColor,
|
2022-10-21 10:53:38 +02:00
|
|
|
);
|
|
|
|
|
2022-11-24 14:56:21 +01:00
|
|
|
return showName
|
|
|
|
? Column(
|
|
|
|
children: [
|
|
|
|
avatar,
|
|
|
|
Padding(
|
|
|
|
padding: padding,
|
|
|
|
child: Flexible(
|
|
|
|
child: Text(
|
|
|
|
style: textStyle,
|
|
|
|
user.displayName,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-10-21 10:53:38 +02:00
|
|
|
)
|
2022-11-24 14:56:21 +01:00
|
|
|
: avatar;
|
2022-08-26 15:31:42 +02:00
|
|
|
}
|
|
|
|
}
|