veilidchat/lib/components/profile_widget.dart

57 lines
1.8 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/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
2023-08-17 18:10:24 -04:00
import 'package:flutter_translate/flutter_translate.dart';
import 'package:go_router/go_router.dart';
2023-07-28 20:36:05 -04:00
2023-08-05 01:00:46 -04:00
import '../tools/tools.dart';
2023-07-28 20:36:05 -04:00
class ProfileWidget extends ConsumerWidget {
const ProfileWidget({
required this.name,
this.title,
super.key,
});
final String name;
final String? title;
@override
// ignore: prefer_expression_function_bodies
Widget build(BuildContext context, WidgetRef ref) {
2023-08-05 01:00:46 -04:00
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
final textTheme = theme.textTheme;
2023-07-28 20:36:05 -04:00
2023-08-05 01:00:46 -04:00
return Container(
width: double.infinity,
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: scale.primaryScale.border))),
2023-08-17 18:10:24 -04:00
child: Row(children: [
Column(mainAxisSize: MainAxisSize.min, children: [
Text(name, style: textTheme.headlineSmall).paddingAll(8),
if (title != null && title!.isNotEmpty)
Text(title!, style: textTheme.bodyMedium).paddingLTRB(8, 0, 8, 8),
]).expanded(),
IconButton(
icon: const Icon(Icons.settings),
tooltip: translate('app_bar.settings_tooltip'),
onPressed: () async {
context.go('/home/settings');
})
2023-08-05 01:00:46 -04:00
])).paddingAll(8);
2023-07-28 20:36:05 -04:00
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(StringProperty('name', name))
..add(StringProperty('title', title));
}
}