Skip to content

Commit

Permalink
Make textfield dismissable on tap
Browse files Browse the repository at this point in the history
  • Loading branch information
conrad-mo committed Aug 13, 2023
1 parent d0dbc1c commit 8cd90b2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 40 deletions.
19 changes: 1 addition & 18 deletions lib/components/text_bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ class _TextBubbleState extends State<TextBubble> {
@override
Widget build(BuildContext context) {
return Row(
// padding: EdgeInsets.only(
// top: 4,
// bottom: 4,
// left: widget.amISender ? 0 : 24,
// right: widget.amISender ? 24 : 0),
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment:
widget.amISender ? MainAxisAlignment.end : MainAxisAlignment.start,
// alignment:
// widget.amISender ? Alignment.centerRight : Alignment.centerLeft,
children: [
const SizedBox(
height: 50,
Expand All @@ -41,13 +34,10 @@ class _TextBubbleState extends State<TextBubble> {
: Container(),
!widget.amISender
? const SizedBox(
width: 10,
width: 5,
)
: Container(),
Container(
// margin: widget.amISender
// ? const EdgeInsets.only(left: 30)
// : const EdgeInsets.only(right: 30),
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 15, right: 15),
decoration: BoxDecoration(
Expand All @@ -63,13 +53,6 @@ class _TextBubbleState extends State<TextBubble> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
// Text(
// widget.sender,
// style: const TextStyle(
// fontWeight: FontWeight.bold,
// ),
// textAlign: TextAlign.center,
// ),
Text(
widget.message,
textAlign: TextAlign.center,
Expand Down
51 changes: 29 additions & 22 deletions lib/states/chatscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,35 @@ class _ChatScreenState extends State<ChatScreen> {

textMessages() {
//print(Theme.of(context).brightness == Brightness.dark);
return SingleChildScrollView(
reverse: true,
//physics: ScrollPhysics(),
child: StreamBuilder(
stream: texts,
builder: (context, AsyncSnapshot snapshot) {
return snapshot.hasData
? ListView.builder(
physics: const NeverScrollableScrollPhysics(),
//scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
return TextBubble(
message: snapshot.data.docs[index]['message'],
sender: snapshot.data.docs[index]['sender'],
amISender: widget.username ==
snapshot.data.docs[index]['sender']);
},
)
: Container();
},

return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: SingleChildScrollView(
reverse: true,
//physics: ScrollPhysics(),
child: StreamBuilder(
stream: texts,
builder: (context, AsyncSnapshot snapshot) {
return snapshot.hasData
? ListView.builder(
physics: const NeverScrollableScrollPhysics(),
//scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
return TextBubble(
message: snapshot.data.docs[index]['message'],
sender: snapshot.data.docs[index]['sender'],
amISender: widget.username ==
snapshot.data.docs[index]['sender']);
},
)
: Container();
},
),
),
);
}
Expand Down

0 comments on commit 8cd90b2

Please sign in to comment.