1import 'package:flutter/material.dart';
2import 'package:grain/api.dart';
3import 'package:grain/app_icons.dart';
4import 'package:grain/widgets/app_image.dart';
5
6class AddCommentButton extends StatelessWidget {
7 final VoidCallback onPressed;
8 final Color? backgroundColor;
9 final Color? foregroundColor;
10 const AddCommentButton({
11 super.key,
12 required this.onPressed,
13 this.backgroundColor,
14 this.foregroundColor,
15 });
16
17 @override
18 Widget build(BuildContext context) {
19 final theme = Theme.of(context);
20 final bgColor =
21 backgroundColor ??
22 (theme.brightness == Brightness.light ? Colors.grey[200] : Colors.grey[900]);
23 final fgColor =
24 foregroundColor ?? (theme.brightness == Brightness.light ? Colors.black : Colors.white);
25 return SizedBox(
26 width: double.infinity,
27 child: ElevatedButton(
28 style: ElevatedButton.styleFrom(
29 backgroundColor: bgColor,
30 foregroundColor: fgColor,
31 shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
32 padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
33 textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16),
34 elevation: 0,
35 ),
36 onPressed: onPressed,
37 child: Row(
38 mainAxisAlignment: MainAxisAlignment.start,
39 children: [
40 if (apiService.currentUser?.avatar != null &&
41 (apiService.currentUser?.avatar?.isNotEmpty ?? false))
42 ClipOval(
43 child: AppImage(
44 url: apiService.currentUser!.avatar!,
45 width: 32,
46 height: 32,
47 fit: BoxFit.cover,
48 ),
49 )
50 else
51 CircleAvatar(
52 radius: 16,
53 backgroundColor: Colors.grey[800],
54 child: Icon(AppIcons.person, size: 16, color: Colors.white),
55 ),
56 const SizedBox(width: 12),
57 const Text(
58 'Add a comment',
59 style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16),
60 ),
61 ],
62 ),
63 ),
64 );
65 }
66}