chore: Follow up paddings in room input row

pull/1654/head
Krille 6 months ago
parent 8da9ef06ff
commit 2e7eea9308
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -114,99 +114,104 @@ class ChatInputRow extends StatelessWidget {
curve: FluffyThemes.animationCurve, curve: FluffyThemes.animationCurve,
child: controller.sendController.text.isNotEmpty child: controller.sendController.text.isNotEmpty
? null ? null
: PopupMenuButton<String>( : Center(
icon: const Icon(Icons.add_circle_outline), child: PopupMenuButton<String>(
iconColor: theme.colorScheme.onPrimaryContainer, icon: const Icon(Icons.add_circle_outline),
onSelected: controller.onAddPopupMenuButtonSelected, iconColor: theme.colorScheme.onPrimaryContainer,
itemBuilder: (BuildContext context) => onSelected: controller.onAddPopupMenuButtonSelected,
<PopupMenuEntry<String>>[ itemBuilder: (BuildContext context) =>
if (PlatformInfos.isMobile) <PopupMenuEntry<String>>[
PopupMenuItem<String>( if (PlatformInfos.isMobile)
value: 'location', PopupMenuItem<String>(
child: ListTile( value: 'location',
leading: CircleAvatar( child: ListTile(
backgroundColor: leading: CircleAvatar(
theme.colorScheme.onPrimaryContainer, backgroundColor:
foregroundColor: theme.colorScheme.onPrimaryContainer,
theme.colorScheme.primaryContainer, foregroundColor:
child: const Icon(Icons.gps_fixed_outlined), theme.colorScheme.primaryContainer,
child: const Icon(Icons.gps_fixed_outlined),
),
title: Text(L10n.of(context).shareLocation),
contentPadding: const EdgeInsets.all(0),
), ),
title: Text(L10n.of(context).shareLocation),
contentPadding: const EdgeInsets.all(0),
), ),
),
PopupMenuItem<String>(
value: 'image',
child: ListTile(
leading: CircleAvatar(
backgroundColor:
theme.colorScheme.onPrimaryContainer,
foregroundColor:
theme.colorScheme.primaryContainer,
child: const Icon(Icons.photo_album_outlined),
),
title: Text(L10n.of(context).openGallery),
contentPadding: const EdgeInsets.all(0),
),
),
PopupMenuItem<String>(
value: 'file',
child: ListTile(
leading: CircleAvatar(
backgroundColor:
theme.colorScheme.onPrimaryContainer,
foregroundColor:
theme.colorScheme.primaryContainer,
child: const Icon(Icons.attachment_outlined),
),
title: Text(L10n.of(context).sendFile),
contentPadding: const EdgeInsets.all(0),
),
),
],
),
),
if (PlatformInfos.isMobile)
AnimatedSize(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: controller.sendController.text.isNotEmpty
? null
: PopupMenuButton(
icon: const Icon(Icons.camera_alt_outlined),
onSelected: controller.onAddPopupMenuButtonSelected,
iconColor: theme.colorScheme.onPrimaryContainer,
itemBuilder: (context) => [
PopupMenuItem<String>( PopupMenuItem<String>(
value: 'camera-video', value: 'image',
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:
theme.colorScheme.onPrimaryContainer, theme.colorScheme.onPrimaryContainer,
foregroundColor: foregroundColor:
theme.colorScheme.primaryContainer, theme.colorScheme.primaryContainer,
child: const Icon(Icons.videocam_outlined), child: const Icon(Icons.photo_album_outlined),
), ),
title: Text(L10n.of(context).recordAVideo), title: Text(L10n.of(context).openGallery),
contentPadding: const EdgeInsets.all(0), contentPadding: const EdgeInsets.all(0),
), ),
), ),
PopupMenuItem<String>( PopupMenuItem<String>(
value: 'camera', value: 'file',
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:
theme.colorScheme.onPrimaryContainer, theme.colorScheme.onPrimaryContainer,
foregroundColor: foregroundColor:
theme.colorScheme.primaryContainer, theme.colorScheme.primaryContainer,
child: const Icon(Icons.camera_alt_outlined), child: const Icon(Icons.attachment_outlined),
), ),
title: Text(L10n.of(context).takeAPhoto), title: Text(L10n.of(context).sendFile),
contentPadding: const EdgeInsets.all(0), contentPadding: const EdgeInsets.all(0),
), ),
), ),
], ],
), ),
),
),
if (PlatformInfos.isMobile)
AnimatedSize(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: controller.sendController.text.isNotEmpty
? null
: Center(
child: PopupMenuButton(
icon: const Icon(Icons.camera_alt_outlined),
onSelected: controller.onAddPopupMenuButtonSelected,
iconColor: theme.colorScheme.onPrimaryContainer,
itemBuilder: (context) => [
PopupMenuItem<String>(
value: 'camera-video',
child: ListTile(
leading: CircleAvatar(
backgroundColor:
theme.colorScheme.onPrimaryContainer,
foregroundColor:
theme.colorScheme.primaryContainer,
child: const Icon(Icons.videocam_outlined),
),
title: Text(L10n.of(context).recordAVideo),
contentPadding: const EdgeInsets.all(0),
),
),
PopupMenuItem<String>(
value: 'camera',
child: ListTile(
leading: CircleAvatar(
backgroundColor:
theme.colorScheme.onPrimaryContainer,
foregroundColor:
theme.colorScheme.primaryContainer,
child:
const Icon(Icons.camera_alt_outlined),
),
title: Text(L10n.of(context).takeAPhoto),
contentPadding: const EdgeInsets.all(0),
),
),
],
),
),
), ),
Container( Container(
height: height, height: height,

@ -202,63 +202,45 @@ class SendFileDialogState extends State<SendFileDialog> {
title: Text(sendStr), title: Text(sendStr),
content: SizedBox( content: SizedBox(
width: 256, width: 256,
child: ListView( child: SingleChildScrollView(
shrinkWrap: true, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
const SizedBox(height: 12), children: [
if (uniqueFileType == 'image') const SizedBox(height: 12),
Padding( if (uniqueFileType == 'image')
padding: const EdgeInsets.only(bottom: 16.0), Padding(
child: SizedBox( padding: const EdgeInsets.only(bottom: 16.0),
height: 256, child: SizedBox(
child: Center( height: 256,
child: ListView.builder( child: Center(
shrinkWrap: true, child: ListView.builder(
itemCount: widget.files.length, shrinkWrap: true,
scrollDirection: Axis.horizontal, itemCount: widget.files.length,
itemBuilder: (context, i) => Padding( scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(right: 8.0), itemBuilder: (context, i) => Padding(
child: Material( padding: const EdgeInsets.only(right: 8.0),
borderRadius: BorderRadius.circular( child: Material(
AppConfig.borderRadius / 2, borderRadius: BorderRadius.circular(
), AppConfig.borderRadius / 2,
color: Colors.black, ),
clipBehavior: Clip.hardEdge, color: Colors.black,
child: FutureBuilder( clipBehavior: Clip.hardEdge,
future: widget.files[i].readAsBytes(), child: FutureBuilder(
builder: (context, snapshot) { future: widget.files[i].readAsBytes(),
final bytes = snapshot.data; builder: (context, snapshot) {
if (bytes == null) { final bytes = snapshot.data;
return const Center( if (bytes == null) {
child: return const Center(
CircularProgressIndicator.adaptive(), child: CircularProgressIndicator
); .adaptive(),
} );
if (snapshot.error != null) { }
Logs().w( if (snapshot.error != null) {
'Unable to preview image', Logs().w(
snapshot.error, 'Unable to preview image',
snapshot.stackTrace, snapshot.error,
); snapshot.stackTrace,
return const Center( );
child: SizedBox(
width: 256,
height: 256,
child: Icon(
Icons.broken_image_outlined,
size: 64,
),
),
);
}
return Image.memory(
bytes,
height: 256,
width:
widget.files.length == 1 ? 256 : null,
fit: BoxFit.contain,
errorBuilder: (context, e, s) {
Logs().w('Unable to preview image', e, s);
return const Center( return const Center(
child: SizedBox( child: SizedBox(
width: 256, width: 256,
@ -269,115 +251,136 @@ class SendFileDialogState extends State<SendFileDialog> {
), ),
), ),
); );
}, }
); return Image.memory(
}, bytes,
height: 256,
width:
widget.files.length == 1 ? 256 : null,
fit: BoxFit.contain,
errorBuilder: (context, e, s) {
Logs()
.w('Unable to preview image', e, s);
return const Center(
child: SizedBox(
width: 256,
height: 256,
child: Icon(
Icons.broken_image_outlined,
size: 64,
),
),
);
},
);
},
),
), ),
), ),
), ),
), ),
), ),
), ),
), if (uniqueFileType != 'image')
if (uniqueFileType != 'image') Padding(
Padding( padding: const EdgeInsets.only(bottom: 16.0),
padding: const EdgeInsets.only(bottom: 16.0), child: Row(
child: Row( children: [
Icon(
uniqueFileType == null
? Icons.description_outlined
: uniqueFileType == 'video'
? Icons.video_file_outlined
: uniqueFileType == 'audio'
? Icons.audio_file_outlined
: Icons.description_outlined,
size: 32,
),
const SizedBox(width: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
fileName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'$sizeString - $fileTypes',
style: theme.textTheme.labelSmall,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
if (widget.files.length == 1)
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: DialogTextField(
controller: _labelTextController,
labelText: L10n.of(context).optionalMessage,
minLines: 1,
maxLines: 3,
maxLength: 255,
counterText: '',
),
),
// Workaround for SwitchListTile.adaptive crashes in CupertinoDialog
if ({'image', 'video'}.contains(uniqueFileType))
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Icon( if ({TargetPlatform.iOS, TargetPlatform.macOS}
uniqueFileType == null .contains(theme.platform))
? Icons.description_outlined CupertinoSwitch(
: uniqueFileType == 'video' value: compress,
? Icons.video_file_outlined onChanged: uniqueFileType == 'video' &&
: uniqueFileType == 'audio' !PlatformInfos.isMobile
? Icons.audio_file_outlined ? null
: Icons.description_outlined, : (v) => setState(() => compress = v),
size: 32, )
), else
const SizedBox(width: 8), Switch.adaptive(
value: compress,
onChanged: uniqueFileType == 'video' &&
!PlatformInfos.isMobile
? null
: (v) => setState(() => compress = v),
),
const SizedBox(width: 16),
Expanded( Expanded(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Row(
fileName, mainAxisSize: MainAxisSize.min,
maxLines: 1, children: [
overflow: TextOverflow.ellipsis, Text(
), L10n.of(context).compress,
Text( style: theme.textTheme.titleMedium,
'$sizeString - $fileTypes', textAlign: TextAlign.left,
style: theme.textTheme.labelSmall, ),
maxLines: 1, ],
overflow: TextOverflow.ellipsis,
), ),
if (!compress)
Text(
' ($sizeString)',
style: theme.textTheme.labelSmall,
),
], ],
), ),
), ),
], ],
), ),
), ],
if (widget.files.length == 1) ),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: DialogTextField(
controller: _labelTextController,
labelText: L10n.of(context).optionalMessage,
minLines: 1,
maxLines: 3,
maxLength: 255,
counterText: '',
),
),
// Workaround for SwitchListTile.adaptive crashes in CupertinoDialog
if ({'image', 'video'}.contains(uniqueFileType))
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if ({TargetPlatform.iOS, TargetPlatform.macOS}
.contains(theme.platform))
CupertinoSwitch(
value: compress,
onChanged: uniqueFileType == 'video' &&
!PlatformInfos.isMobile
? null
: (v) => setState(() => compress = v),
)
else
Switch.adaptive(
value: compress,
onChanged: uniqueFileType == 'video' &&
!PlatformInfos.isMobile
? null
: (v) => setState(() => compress = v),
),
const SizedBox(width: 16),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
L10n.of(context).compress,
style: theme.textTheme.titleMedium,
textAlign: TextAlign.left,
),
],
),
if (!compress)
Text(
' ($sizeString)',
style: theme.textTheme.labelSmall,
),
],
),
),
],
),
],
), ),
), ),
actions: <Widget>[ actions: <Widget>[

Loading…
Cancel
Save