113 lines
4.4 KiB
Dart
113 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:lba/gen/assets.gen.dart';
|
|
import 'package:lba/res/colors.dart';
|
|
|
|
class ChatTextInputField extends StatelessWidget {
|
|
final TextEditingController textController;
|
|
final VoidCallback onSendMessage;
|
|
final VoidCallback onShowAttachmentOptions;
|
|
final VoidCallback onStartRecording;
|
|
final VoidCallback onStopRecording;
|
|
final bool isRecording;
|
|
final Animation<double> micPulseAnimation;
|
|
final GlobalKey attachIconKey;
|
|
final String hintText;
|
|
|
|
const ChatTextInputField({
|
|
super.key,
|
|
required this.textController,
|
|
required this.onSendMessage,
|
|
required this.onShowAttachmentOptions,
|
|
required this.onStartRecording,
|
|
required this.onStopRecording,
|
|
required this.isRecording,
|
|
required this.micPulseAnimation,
|
|
required this.attachIconKey,
|
|
this.hintText = "Type your request here and let's plan it!",
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
top: false,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.nearbyPopup,
|
|
borderRadius: BorderRadius.circular(35),
|
|
border: Border.all(color: AppColors.divider),
|
|
),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
IconButton(
|
|
key: attachIconKey,
|
|
onPressed: onShowAttachmentOptions,
|
|
icon: SvgPicture.asset(Assets.icons.link2.path,color: AppColors.isDarkMode?Colors.grey:null,),
|
|
),
|
|
Expanded(
|
|
child: TextField(
|
|
controller: textController,
|
|
decoration: InputDecoration(
|
|
hintText: hintText,
|
|
hintStyle: TextStyle(color: AppColors.textSecondary, fontSize: 14),
|
|
border: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(vertical: 0, horizontal: 3),
|
|
),
|
|
onSubmitted: (_) => onSendMessage(),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onLongPressStart: (_) => onStartRecording(),
|
|
onLongPressEnd: (_) => onStopRecording(),
|
|
child: AnimatedBuilder(
|
|
animation: micPulseAnimation,
|
|
builder: (context, child) {
|
|
return Transform.scale(
|
|
scale: isRecording ? micPulseAnimation.value : 1.0,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: isRecording
|
|
? AppColors.errorColor
|
|
: Colors.transparent,
|
|
shape: BoxShape.circle,
|
|
boxShadow: isRecording
|
|
? [
|
|
BoxShadow(
|
|
color: AppColors.errorColor.withOpacity(0.3),
|
|
blurRadius: 8,
|
|
spreadRadius: 2,
|
|
),
|
|
]
|
|
: null,
|
|
),
|
|
child: SvgPicture.asset(
|
|
Assets.icons.microphone2.path,
|
|
color: AppColors.isDarkMode?Colors.grey:null,
|
|
colorFilter: isRecording
|
|
? ColorFilter.mode(
|
|
AppColors.surface, BlendMode.srcIn)
|
|
: null,
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
IconButton(
|
|
icon: SvgPicture.asset(Assets.icons.arrowUp.path,color: AppColors.isDarkMode?const Color.fromARGB(255, 47, 122, 184):null),
|
|
onPressed: onSendMessage,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |