Untitled
unknown
dart
4 years ago
7.6 kB
15
Indexable
Widget messageDialogWidget(height, width) {
return Stack(
children: [
Positioned(
top: 0,
bottom: height * 0.11,
width: width,
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
reverse: true,
cacheExtent: 1000,
itemCount: MessageModel.messages.length,
itemBuilder: (BuildContext context, int index) {
var message = MessageModel.messages[index];
return (message.sender == GlobalV.user.driver.sId)
? ChatBubble(
clipper: ChatBubbleClipper4(type: BubbleType.sendBubble),
alignment: Alignment.topRight,
margin: EdgeInsets.only(top: 5, bottom: 5),
backGroundColor: Colors.yellow[100],
child: Container(
constraints: BoxConstraints(maxWidth: width * 0.7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
DateFormat('dd/MM/yyy - kk:mm').format(
DateTime.fromMillisecondsSinceEpoch(message
.timeStamp
.toLocal()
.millisecondsSinceEpoch)),
style: TextStyle(
color: Colors.grey, fontSize: 15)),
Padding(
padding: const EdgeInsets.only(top: 5, bottom: 5),
child: Text(message.message,
style: TextStyle(
color: Colors.black, fontSize: 20)),
)
],
),
),
)
: ChatBubble(
clipper:
ChatBubbleClipper4(type: BubbleType.receiverBubble),
alignment: Alignment.topLeft,
margin: EdgeInsets.only(top: 3, bottom: 3),
backGroundColor: Colors.grey[100],
child: Container(
constraints: BoxConstraints(maxWidth: width * 0.7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'$customerName @${DateFormat('dd/MM/yyy - kk:mm').format(DateTime.fromMillisecondsSinceEpoch(message.timeStamp.toLocal().millisecondsSinceEpoch))}',
style: TextStyle(
color: Colors.grey, fontSize: 15)),
Padding(
padding: const EdgeInsets.only(top: 3, bottom: 3),
child: Text(message.message,
style: TextStyle(
color: Colors.black, fontSize: 20)),
)
],
),
),
);
},
),
),
isFocusOn
? Material(
color: Colors.transparent,
child: InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
color: Colors.black38,
height: height,
width: width,
)),
)
: SizedBox(),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: height * 0.11,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40),
),
),
padding: EdgeInsets.only(
bottom: height * 0.02,
left: width * 0.01,
top: height * 0.02,
right: width * 0.01),
child: Row(
children: [
Expanded(
flex: 8,
child: FocusScope(
child: Focus(
onFocusChange: (value) {
setState(() {
(isFocusOn) ? isFocusOn = false : isFocusOn = true;
});
},
child: TextFormField(
onFieldSubmitted: (asd) => print(asd),
controller: _messageController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(40)),
),
),
),
),
),
Expanded(
flex: 2,
child: FittedBox(
fit: BoxFit.cover,
child: IconButton(
color: Colors.blue[900],
icon: Icon(Icons.send),
onPressed: () {
if (_messageController.text.isNotEmpty) {
print(_messageController.text);
_sendMessage();
}
},
),
),
)
],
),
)),
Align(
alignment: Alignment.topLeft,
child: InkWell(
onTap: isFocusOn
? null
: () {
setState(() {
isMessageOpened = false;
});
},
child: SizedBox(
width: width * 0.3,
height: xxWidthEqualsHeight(0.1),
child: Row(
children: [
SizedBox(
width: width * 0.080,
height: xxWidthEqualsHeight(0.085),
child: FittedBox(
fit: BoxFit.contain,
child: Icon(
Icons.arrow_back,
color: isFocusOn ? Colors.grey : Colors.amber,
),
),
),
SizedBox(
width: width * 0.220,
height: xxWidthEqualsHeight(0.1),
child: FittedBox(
fit: BoxFit.contain,
child: Text(
"Tüm Mesajlar",
style: TextStyle(
color: isFocusOn ? Colors.grey : Colors.amber,
),
),
),
),
],
),
),
),
)
],
);
}Editor is loading...