Created
July 20, 2021 16:22
-
-
Save uwepries/676ad0847652e65c5a48e997af472a70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_svg/flutter_svg.dart'; | |
import 'package:flutter_whatsapp/Model/ChatModel.dart'; | |
class IndividualPage extends StatefulWidget { | |
final ChatModel chatModel; | |
IndividualPage({Key? key, required this.chatModel}) : super(key: key); | |
@override | |
_IndividualPageState createState() => _IndividualPageState(); | |
} | |
class _IndividualPageState extends State<IndividualPage> { | |
final TextEditingController _controller = TextEditingController(); | |
bool emojiShowing = false; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.blueGrey, | |
appBar: AppBar( | |
leadingWidth: 70, | |
titleSpacing: 0, | |
leading: InkWell( | |
onTap: () { | |
Navigator.pop(context); | |
}, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Icon(Icons.arrow_back, size: 24), | |
CircleAvatar( | |
radius: 20, | |
child: SvgPicture.asset( | |
widget.chatModel.icon, | |
color: Colors.white, | |
height: 37, | |
width: 37, | |
), | |
backgroundColor: Colors.blueGrey, | |
) | |
], | |
), | |
), | |
title: InkWell( | |
onTap: () { | |
print("Title tapped"); | |
}, | |
child: Container( | |
margin: EdgeInsets.all(6), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.start, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
widget.chatModel.name, | |
style: TextStyle(fontSize: 18.5, fontWeight: FontWeight.bold), | |
), | |
Text( | |
"last seen today at 12:05", | |
style: TextStyle( | |
fontSize: 13, | |
), | |
), | |
], | |
), | |
), | |
), | |
actions: [ | |
IconButton(onPressed: () {}, icon: Icon(Icons.video_call)), | |
IconButton(onPressed: () {}, icon: Icon(Icons.call)), | |
PopupMenuButton<String>( | |
onSelected: (value) { | |
print(value); | |
}, | |
itemBuilder: (BuildContext context) { | |
return [ | |
PopupMenuItem( | |
child: Text("View contact"), | |
value: "View contact", | |
), | |
PopupMenuItem( | |
child: Text("Media, links and docs"), | |
value: "Media, links and docs", | |
), | |
PopupMenuItem( | |
child: Text("Chat search"), | |
value: "Chat seatch", | |
), | |
PopupMenuItem( | |
child: Text("Starred Messages"), | |
value: "Starred Messages", | |
), | |
PopupMenuItem( | |
child: Text("Mute notifications"), | |
value: "Mute notifications", | |
), | |
PopupMenuItem( | |
child: Text("Wallpaper"), | |
value: "Wallpaper", | |
), | |
]; | |
}, | |
), | |
], | |
), | |
body: Container( | |
height: MediaQuery.of(context).size.height, | |
width: MediaQuery.of(context).size.width, | |
child: Stack( | |
children: [ | |
ListView(), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.end, | |
children: [ | |
Expanded(child: Container()), // empty space aka chat history | |
Row( | |
children: [ | |
Container( | |
width: MediaQuery.of(context).size.width - 60, | |
child: Card( | |
margin: EdgeInsets.only(left: 2, right: 2, bottom: 8), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(25), | |
), | |
child: TextFormField( | |
controller: _controller, | |
textAlignVertical: TextAlignVertical.center, | |
keyboardType: TextInputType.multiline, | |
maxLines: 5, | |
minLines: 1, | |
decoration: InputDecoration( | |
border: InputBorder.none, | |
hintText: "Type a message", | |
prefixIcon: IconButton( | |
icon: Icon(Icons.emoji_emotions), | |
onPressed: () { | |
setState(() { | |
emojiShowing = !emojiShowing; | |
}); | |
}, | |
), | |
suffixIcon: Row( | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
IconButton( | |
onPressed: () {}, | |
icon: Icon(Icons.attach_file), | |
), | |
IconButton( | |
onPressed: () {}, | |
icon: Icon(Icons.camera_alt), | |
), | |
], | |
), | |
contentPadding: EdgeInsets.all(5), | |
), | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.only( | |
bottom: 8.0, | |
right: 5, | |
left: 2, | |
), | |
child: CircleAvatar( | |
radius: 25, | |
backgroundColor: Color(0xFF128C7E), | |
child: IconButton( | |
icon: Icon( | |
Icons.mic, | |
color: Colors.white, | |
), | |
onPressed: () {}, | |
), | |
), | |
), | |
], | |
), | |
Offstage( | |
offstage: !emojiShowing, | |
child: SizedBox( | |
height: 250, | |
child: EmojiPicker( | |
onEmojiSelected: (Category category, Emoji emoji) { | |
_onEmojiSelected(emoji); | |
}, | |
onBackspacePressed: _onBackspacePressed, | |
config: const Config( | |
columns: 7, | |
emojiSizeMax: 32.0, | |
verticalSpacing: 0, | |
horizontalSpacing: 0, | |
initCategory: Category.RECENT, | |
bgColor: Color(0xFFF2F2F2), | |
indicatorColor: Colors.blue, | |
iconColor: Colors.grey, | |
iconColorSelected: Colors.blue, | |
progressIndicatorColor: Colors.blue, | |
backspaceColor: Colors.blue, | |
showRecentsTab: true, | |
recentsLimit: 28, | |
noRecentsText: 'No Recents', | |
noRecentsStyle: TextStyle( | |
fontSize: 20, color: Colors.black26), | |
categoryIcons: CategoryIcons(), | |
buttonMode: ButtonMode.MATERIAL)), | |
), | |
), | |
], | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
_onEmojiSelected(Emoji emoji) { | |
_controller | |
..text += emoji.emoji | |
..selection = TextSelection.fromPosition( | |
TextPosition(offset: _controller.text.length)); | |
} | |
_onBackspacePressed() { | |
_controller | |
..text = _controller.text.characters.skipLast(1).toString() | |
..selection = TextSelection.fromPosition( | |
TextPosition(offset: _controller.text.length)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment