cofounderella/lib/components/chat_bubble.dart

37 lines
1.1 KiB
Dart

import 'package:cofounderella/themes/theme_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ChatBubble extends StatelessWidget {
final String message;
final bool isCurrentUser;
const ChatBubble({
super.key,
required this.message,
required this.isCurrentUser,
});
@override
Widget build(BuildContext context) {
// control bubble color according to light or dark mode
bool isDarkMode =
Provider.of<ThemeProvider>(context, listen: false).isDarkMode;
return Container(
decoration: BoxDecoration(
color: isCurrentUser
? (isDarkMode ? Colors.blue.shade700 : Colors.lightBlue.shade200)
: (isDarkMode ? Colors.grey.shade800 : Colors.grey.shade400),
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.all(16.0),
margin: const EdgeInsets.symmetric(vertical: 2.5, horizontal: 25),
child: Text(
message,
style: TextStyle(color: isDarkMode ? Colors.white : Colors.black),
),
);
}
}