Skip to content

Commit

Permalink
fixed long message bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RamyBouchareb25 committed Sep 6, 2023
1 parent 5400702 commit 5df412d
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 164 deletions.
255 changes: 93 additions & 162 deletions lib/Pages/conversation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,97 @@ class _ConversationState extends State<Conversation> {
return await resp;
}

Widget thisBottomAppBar() {
return BottomAppBar(
padding: const EdgeInsets.symmetric(vertical: 15),
elevation: 0,
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icomoon.Clip,
color: black,
size: 20,
),
onPressed: () {
// Navigator.push(context, MaterialPageRoute(
// builder: (context) {
// return const Test();
// },
// ));
},
),
Expanded(
child: TextField(
controller: messageController,
onChanged: (value) {
setState(() {
isWriting = value.isNotEmpty;
});
},
focusNode: _textFieldFocus,
decoration: InputDecoration(
suffixIcon: IconButton(
onPressed: () {},
icon: const Icon(
Icomoon.files,
color: black,
)),
filled: true,
fillColor: Colors.grey[200],
hintText: "your message...",
contentPadding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 15.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide.none,
)),
),
),
IconButton(
icon: Container(
height: 40,
width: 40,
decoration: isWriting
? BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.circular(20),
)
: null,
child: Icon(
!isWriting ? Icomoon.Camera : Icomoon.Send,
color: !isWriting ? black : Colors.white,
size: !isWriting ? 20 : 15,
),
),
onPressed: send,
),
!isWriting
? IconButton(
icon: const Icon(
Icomoon.Mic,
color: black,
size: 20,
),
onPressed: () {
if (record.isStopped) {
startRecord();
} else if (record.isRecording) {
stopRecord();
}
},
)
: const SizedBox(),
],
),
),
);
}

void send() async {
if (isWriting) {
var now = DateTime.now().toString();
Expand Down Expand Up @@ -395,87 +486,7 @@ class _ConversationState extends State<Conversation> {
);
}),
),
BottomAppBar(
padding: const EdgeInsets.symmetric(vertical: 15),
elevation: 0,
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icomoon.Clip,
color: black,
size: 20,
),
onPressed: () {
// Navigator.push(context, MaterialPageRoute(
// builder: (context) {
// return const Test();
// },
// ));
},
),
Expanded(
child: TextField(
controller: messageController,
onChanged: (value) {
setState(() {
isWriting = value.isNotEmpty;
});
},
focusNode: _textFieldFocus,
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey[200],
hintText: "Write your message...",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide.none,
),
),
),
),
IconButton(
icon: Container(
height: 40,
width: 40,
decoration: isWriting
? BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.circular(20),
)
: null,
child: Icon(
!isWriting ? Icomoon.Camera : Icomoon.Send,
color: !isWriting ? black : Colors.white,
size: !isWriting ? 20 : 15,
),
),
onPressed: send,
),
!isWriting
? IconButton(
icon: const Icon(
Icomoon.Mic,
color: black,
size: 20,
),
onPressed: () {
if (record.isStopped) {
startRecord();
} else if (record.isRecording) {
stopRecord();
}
},
)
: const SizedBox(),
],
),
),
)
thisBottomAppBar()
],
);
} else if (snapshot.hasError) {
Expand All @@ -491,87 +502,7 @@ class _ConversationState extends State<Conversation> {
child: Text(
"Send Your first Message to ${widget.user.name}!"),
),
BottomAppBar(
padding: const EdgeInsets.symmetric(vertical: 15),
elevation: 0,
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icomoon.Clip,
color: black,
size: 20,
),
onPressed: () {
// Navigator.push(context, MaterialPageRoute(
// builder: (context) {
// return const Test();
// },
// ));
},
),
Expanded(
child: TextField(
controller: messageController,
onChanged: (value) {
setState(() {
isWriting = value.isNotEmpty;
});
},
focusNode: _textFieldFocus,
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey[200],
hintText: "Write your message...",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide.none,
),
),
),
),
IconButton(
icon: Container(
height: 40,
width: 40,
decoration: isWriting
? BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.circular(20),
)
: null,
child: Icon(
!isWriting ? Icomoon.Camera : Icomoon.Send,
color: !isWriting ? black : Colors.white,
size: !isWriting ? 20 : 15,
),
),
onPressed: send,
),
!isWriting
? IconButton(
icon: const Icon(
Icomoon.Mic,
color: black,
size: 20,
),
onPressed: () {
if (record.isStopped) {
startRecord();
} else if (record.isRecording) {
stopRecord();
}
},
)
: const SizedBox(),
],
),
),
)
thisBottomAppBar(),
],
);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (kDebugMode) {
print("token : \n${token}");
print("token : \n$token");
}
if (Auth().currentUser != null) {
addToken(token);
Expand All @@ -132,6 +132,8 @@ class MyApp extends StatelessWidget {
),
brightness: Brightness.dark,
),
home: WidgetTree(token: token,));
home: WidgetTree(
token: token,
));
}
}

0 comments on commit 5df412d

Please sign in to comment.