msg
unknown
dart
3 years ago
6.2 kB
2
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[MessageModel.messages.length - index - 1]; return (message.sender == GlobalV.user.driver.sId) ? ChatBubble( clipper: ChatBubbleClipper1(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('@${message.sender}', style: TextStyle( color: Colors.grey, fontSize: 10)), Text(message.message, style: TextStyle( color: Colors.black, fontSize: 16)) ], ), ), ) : ChatBubble( clipper: ChatBubbleClipper1(type: BubbleType.receiverBubble), alignment: Alignment.topLeft, margin: EdgeInsets.only(top: 5, bottom: 5), backGroundColor: Colors.grey[100], child: Container( constraints: BoxConstraints(maxWidth: width * 0.7), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${message.sender} @${message.timeStamp}', style: TextStyle( color: Colors.grey, fontSize: 10)), Text(message.message, style: TextStyle( color: Colors.black, fontSize: 16)) ], ), ), ); }, ), ), 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: 7, 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: 1, child: IconButton( 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...