refactor: wrap chat bubble content in IntrinsicWidth to prevent unnecessary stretching for short messages
This commit is contained in:
@@ -480,46 +480,51 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
|||||||
color: AppColors.primaryDark.withValues(alpha: 0.1),
|
color: AppColors.primaryDark.withValues(alpha: 0.1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
// IntrinsicWidth shrinks the bubble to the widest child (content or
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// time), so short messages like "hi" don't stretch to maxWidth.
|
||||||
children: [
|
child: IntrinsicWidth(
|
||||||
if (!isOwn)
|
child: Column(
|
||||||
const Padding(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
padding: EdgeInsets.only(bottom: 4),
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (!isOwn)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: 4),
|
||||||
|
child: Text(
|
||||||
|
'Support Team',
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'Fractul',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.accentOrange,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
msg.content,
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'SourceSerif4',
|
||||||
|
fontSize: 14,
|
||||||
|
color: isOwn ? Colors.white : AppColors.primaryDark,
|
||||||
|
height: 1.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Support Team',
|
_formatTime(msg.createdAt),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontFamily: 'Fractul',
|
fontFamily: 'SourceSerif4',
|
||||||
fontSize: 12,
|
fontSize: 11,
|
||||||
fontWeight: FontWeight.w600,
|
color: isOwn
|
||||||
color: AppColors.accentOrange,
|
? Colors.white.withValues(alpha: 0.5)
|
||||||
|
: AppColors.primaryDark.withValues(alpha: 0.4),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
],
|
||||||
msg.content,
|
),
|
||||||
style: TextStyle(
|
|
||||||
fontFamily: 'SourceSerif4',
|
|
||||||
fontSize: 14,
|
|
||||||
color: isOwn ? Colors.white : AppColors.primaryDark,
|
|
||||||
height: 1.4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: Text(
|
|
||||||
_formatTime(msg.createdAt),
|
|
||||||
style: TextStyle(
|
|
||||||
fontFamily: 'SourceSerif4',
|
|
||||||
fontSize: 11,
|
|
||||||
color: isOwn
|
|
||||||
? Colors.white.withValues(alpha: 0.5)
|
|
||||||
: AppColors.primaryDark.withValues(alpha: 0.4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user