veilidchat/lib/account_manager/views/profile_widget.dart

71 lines
2.2 KiB
Dart
Raw Normal View History

2023-08-05 01:00:46 -04:00
import 'package:awesome_extensions/awesome_extensions.dart';
2023-07-28 20:36:05 -04:00
import 'package:flutter/material.dart';
2024-01-30 14:14:11 -05:00
import '../../proto/proto.dart' as proto;
2024-01-08 21:37:08 -05:00
import '../../theme/theme.dart';
2023-08-05 01:00:46 -04:00
2024-01-08 21:37:08 -05:00
class ProfileWidget extends StatelessWidget {
2023-07-28 20:36:05 -04:00
const ProfileWidget({
2024-01-30 14:14:11 -05:00
required proto.Profile profile,
2024-07-08 21:29:52 -04:00
required bool showPronouns,
2023-07-28 20:36:05 -04:00
super.key,
2024-07-08 21:29:52 -04:00
}) : _profile = profile,
_showPronouns = showPronouns;
2024-01-30 14:14:11 -05:00
//
final proto.Profile _profile;
2024-07-08 21:29:52 -04:00
final bool _showPronouns;
2024-01-30 14:14:11 -05:00
//
2023-07-28 20:36:05 -04:00
@override
// ignore: prefer_expression_function_bodies
2024-01-08 21:37:08 -05:00
Widget build(BuildContext context) {
2023-08-05 01:00:46 -04:00
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
2024-07-06 20:09:18 -04:00
final scaleConfig = theme.extension<ScaleConfig>()!;
2023-08-05 01:00:46 -04:00
final textTheme = theme.textTheme;
2023-07-28 20:36:05 -04:00
2023-09-23 12:56:54 -04:00
return DecoratedBox(
decoration: ShapeDecoration(
2024-07-06 20:09:18 -04:00
color: scaleConfig.preferBorders
? scale.primaryScale.elementBackground
: scale.primaryScale.border,
shape: RoundedRectangleBorder(
side: !scaleConfig.useVisualIndicators
? BorderSide.none
: BorderSide(
strokeAlign: BorderSide.strokeAlignCenter,
color: scaleConfig.preferBorders
? scale.primaryScale.border
: scale.primaryScale.borderText,
width: 2),
borderRadius: BorderRadius.all(
Radius.circular(16 * scaleConfig.borderRadiusScale))),
),
2024-07-08 21:29:52 -04:00
child: Row(children: [
const Spacer(),
2023-09-23 12:56:54 -04:00
Text(
2024-01-30 14:14:11 -05:00
_profile.name,
2024-07-08 21:29:52 -04:00
style: textTheme.titleMedium!.copyWith(
2024-07-06 20:09:18 -04:00
color: scaleConfig.preferBorders
? scale.primaryScale.border
: scale.primaryScale.borderText),
2023-09-23 12:56:54 -04:00
textAlign: TextAlign.left,
2024-07-08 21:29:52 -04:00
).paddingAll(12),
if (_profile.pronouns.isNotEmpty && _showPronouns)
Text('(${_profile.pronouns})',
textAlign: TextAlign.right,
style: textTheme.bodySmall!.copyWith(
2024-07-06 20:09:18 -04:00
color: scaleConfig.preferBorders
? scale.primaryScale.border
2024-07-08 21:29:52 -04:00
: scale.primaryScale.primary))
.paddingAll(12),
const Spacer()
2023-09-23 12:56:54 -04:00
]),
);
2023-07-28 20:36:05 -04:00
}
}