feat: Cute animation for hiding the + button in inputbar

This commit is contained in:
Christian Pauly 2021-05-20 13:33:06 +02:00
parent 301eecb53c
commit 37c40a2cb5
2 changed files with 56 additions and 59 deletions

View File

@ -652,10 +652,7 @@ class ChatController extends State<Chat> {
room.sendTypingNotification(true, room.sendTypingNotification(true,
timeout: Duration(seconds: 30).inMilliseconds); timeout: Duration(seconds: 30).inMilliseconds);
} }
// Workaround for a current desktop bug setState(() => inputText = text);
if (!PlatformInfos.isBetaDesktop) {
setState(() => inputText = text);
}
} }
void cancelReplyEventAction() => setState(() { void cancelReplyEventAction() => setState(() {

View File

@ -571,80 +571,80 @@ class ChatUI extends StatelessWidget {
: Container(), : Container(),
] ]
: <Widget>[ : <Widget>[
if (controller.inputText.isEmpty) AnimatedContainer(
Container( duration: Duration(milliseconds: 200),
height: 56, height: 56,
alignment: Alignment.center, width:
child: PopupMenuButton<String>( controller.inputText.isEmpty ? 56 : 0,
icon: Icon(Icons.add_outlined), alignment: Alignment.center,
onSelected: controller clipBehavior: Clip.hardEdge,
.onAddPopupMenuButtonSelected, decoration: BoxDecoration(),
itemBuilder: (BuildContext context) => child: PopupMenuButton<String>(
<PopupMenuEntry<String>>[ icon: Icon(Icons.add_outlined),
onSelected: controller
.onAddPopupMenuButtonSelected,
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'file',
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.green,
foregroundColor: Colors.white,
child: Icon(
Icons.attachment_outlined),
),
title:
Text(L10n.of(context).sendFile),
contentPadding: EdgeInsets.all(0),
),
),
PopupMenuItem<String>(
value: 'image',
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
child: Icon(Icons.image_outlined),
),
title: Text(
L10n.of(context).sendImage),
contentPadding: EdgeInsets.all(0),
),
),
if (PlatformInfos.isMobile)
PopupMenuItem<String>( PopupMenuItem<String>(
value: 'file', value: 'camera',
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.green, backgroundColor: Colors.purple,
foregroundColor: Colors.white, foregroundColor: Colors.white,
child: Icon( child: Icon(
Icons.attachment_outlined), Icons.camera_alt_outlined),
), ),
title: Text( title: Text(
L10n.of(context).sendFile), L10n.of(context).openCamera),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
if (PlatformInfos.isMobile)
PopupMenuItem<String>( PopupMenuItem<String>(
value: 'image', value: 'voice',
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.blue, backgroundColor: Colors.red,
foregroundColor: Colors.white, foregroundColor: Colors.white,
child: child: Icon(
Icon(Icons.image_outlined), Icons.mic_none_outlined),
), ),
title: Text( title: Text(L10n.of(context)
L10n.of(context).sendImage), .voiceMessage),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
if (PlatformInfos.isMobile) ],
PopupMenuItem<String>(
value: 'camera',
child: ListTile(
leading: CircleAvatar(
backgroundColor:
Colors.purple,
foregroundColor: Colors.white,
child: Icon(Icons
.camera_alt_outlined),
),
title: Text(L10n.of(context)
.openCamera),
contentPadding:
EdgeInsets.all(0),
),
),
if (PlatformInfos.isMobile)
PopupMenuItem<String>(
value: 'voice',
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
child: Icon(
Icons.mic_none_outlined),
),
title: Text(L10n.of(context)
.voiceMessage),
contentPadding:
EdgeInsets.all(0),
),
),
],
),
), ),
),
Container( Container(
height: 56, height: 56,
alignment: Alignment.center, alignment: Alignment.center,