🐛 Bug fixes
This commit is contained in:
parent
a8edd26ba2
commit
9287e3fc90
@ -82,7 +82,7 @@ class AttachmentProvider extends GetConnect {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw Exception(resp.bodyString);
|
throw Exception('${resp.statusCode}: ${resp.bodyString}');
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
|
@ -99,6 +99,9 @@ class SolianMessages extends Translations {
|
|||||||
'attachmentAddFile': 'Attach file',
|
'attachmentAddFile': 'Attach file',
|
||||||
'attachmentSetting': 'Adjust attachment',
|
'attachmentSetting': 'Adjust attachment',
|
||||||
'attachmentAlt': 'Alternative text',
|
'attachmentAlt': 'Alternative text',
|
||||||
|
'attachmentLoadFailed': 'Load Attachment Failed',
|
||||||
|
'attachmentLoadFailedCaption':
|
||||||
|
'Something went wrong during loading the attachment metadata...',
|
||||||
'realm': 'Realm',
|
'realm': 'Realm',
|
||||||
'realms': 'Realms',
|
'realms': 'Realms',
|
||||||
'realmOrganizing': 'Organize a realm',
|
'realmOrganizing': 'Organize a realm',
|
||||||
@ -274,6 +277,8 @@ class SolianMessages extends Translations {
|
|||||||
'attachmentAddFile': '附加文件',
|
'attachmentAddFile': '附加文件',
|
||||||
'attachmentSetting': '调整附件',
|
'attachmentSetting': '调整附件',
|
||||||
'attachmentAlt': '替代文字',
|
'attachmentAlt': '替代文字',
|
||||||
|
'attachmentLoadFailed': '加载失败',
|
||||||
|
'attachmentLoadFailedCaption': '有错误发生于加载附件元数据的过程中了…',
|
||||||
'realm': '领域',
|
'realm': '领域',
|
||||||
'realms': '领域',
|
'realms': '领域',
|
||||||
'realmOrganizing': '组织领域',
|
'realmOrganizing': '组织领域',
|
||||||
|
@ -40,12 +40,15 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
for (var idx = 0; idx < widget.attachmentsId.length; idx++) {
|
for (var idx = 0; idx < widget.attachmentsId.length; idx++) {
|
||||||
provider.getMetadata(widget.attachmentsId[idx]).then((resp) {
|
provider.getMetadata(widget.attachmentsId[idx]).then((resp) {
|
||||||
progress++;
|
progress++;
|
||||||
|
if (resp.body != null) {
|
||||||
_attachmentsMeta[idx] = Attachment.fromJson(resp.body);
|
_attachmentsMeta[idx] = Attachment.fromJson(resp.body);
|
||||||
|
}
|
||||||
if (progress == widget.attachmentsId.length) {
|
if (progress == widget.attachmentsId.length) {
|
||||||
setState(() {
|
|
||||||
calculateAspectRatio();
|
calculateAspectRatio();
|
||||||
_isLoading = false;
|
|
||||||
});
|
if (mounted) {
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -118,6 +121,31 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
itemCount: _attachmentsMeta.length,
|
itemCount: _attachmentsMeta.length,
|
||||||
itemBuilder: (context, idx, _) {
|
itemBuilder: (context, idx, _) {
|
||||||
final element = _attachmentsMeta[idx];
|
final element = _attachmentsMeta[idx];
|
||||||
|
|
||||||
|
if (element == null) {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 280),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.close, size: 32),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'attachmentLoadFailed'.tr,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold, fontSize: 16),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'attachmentLoadFailedCaption'.tr,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
@ -129,7 +157,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
children: [
|
children: [
|
||||||
AttachmentItem(
|
AttachmentItem(
|
||||||
parentId: widget.parentId,
|
parentId: widget.parentId,
|
||||||
key: Key('a${element!.uuid}'),
|
key: Key('a${element.uuid}'),
|
||||||
item: element,
|
item: element,
|
||||||
badge: _attachmentsMeta.length > 1
|
badge: _attachmentsMeta.length > 1
|
||||||
? '${idx + 1}/${_attachmentsMeta.length}'
|
? '${idx + 1}/${_attachmentsMeta.length}'
|
||||||
|
@ -154,7 +154,7 @@ class _AttachmentPublishingPopupState extends State<AttachmentPublishingPopup> {
|
|||||||
var result = Attachment.fromJson(resp.body);
|
var result = Attachment.fromJson(resp.body);
|
||||||
setState(() => _attachments.add(result));
|
setState(() => _attachments.add(result));
|
||||||
widget.onUpdate(_attachments.map((e) => e!.id).toList());
|
widget.onUpdate(_attachments.map((e) => e!.id).toList());
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +239,8 @@ class _AttachmentPublishingPopupState extends State<AttachmentPublishingPopup> {
|
|||||||
itemCount: _attachments.length,
|
itemCount: _attachments.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final element = _attachments[index];
|
final element = _attachments[index];
|
||||||
final fileType = element!.mimetype.split('/').first;
|
var fileType = element!.mimetype.split('/').firstOrNull;
|
||||||
|
fileType ??= 'unknown';
|
||||||
return Container(
|
return Container(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(left: 16, right: 8, bottom: 16),
|
const EdgeInsets.only(left: 16, right: 8, bottom: 16),
|
||||||
|
Loading…
Reference in New Issue
Block a user