flutter_profile/lib/src/widgets/avatar/avatar_wrapper.dart

49 lines
1.1 KiB
Dart
Raw Normal View History

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';
import 'package:flutter_profile/src/widgets/avatar/avatar.dart';
2022-09-21 14:37:16 +02:00
import 'package:flutter_profile/src/widgets/avatar/avatar_style.dart';
2022-08-26 15:31:42 +02:00
2022-10-21 10:42:32 +02:00
class AvaterWrapper extends StatelessWidget {
const AvaterWrapper({
2022-08-26 15:31:42 +02:00
Key? key,
2022-10-21 10:42:32 +02:00
required this.user,
2022-08-26 15:31:42 +02:00
this.avatar,
this.style = const AvatarStyle(),
}) : super(key: key);
2022-10-21 10:42:32 +02:00
final User user;
2022-08-26 15:31:42 +02:00
final Widget? avatar;
final AvatarStyle style;
@override
Widget build(BuildContext context) {
var avatar = this.avatar ??
Avatar(
user: user,
style: style,
);
if (!style.displayName) {
return avatar;
2022-08-26 15:31:42 +02:00
}
return Column(
children: [
avatar,
if (user.firstName != null || user.firstName != null)
Padding(
padding: style.displayNamePadding,
child: Text(
user.displayName,
style: style.displayNameStyle,
),
)
],
);
2022-08-26 15:31:42 +02:00
}
}