Compare commits

..

2 Commits

Author SHA1 Message Date
9287e3fc90 🐛 Bug fixes 2024-06-02 23:17:15 +08:00
a8edd26ba2 Large screen sidebar 2024-06-02 22:45:54 +08:00
8 changed files with 91 additions and 13 deletions

View File

@ -82,7 +82,7 @@ class AttachmentProvider extends GetConnect {
}),
);
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
throw Exception('${resp.statusCode}: ${resp.bodyString}');
}
return resp;

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -210,6 +211,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
return InkWell(
child: Container(
child: ChatMessage(
key: Key('m${item.uuid}'),
item: item,
isMerged: isMerged,
).paddingOnly(
@ -327,7 +329,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
],
),
Positioned(
bottom: MediaQuery.of(context).padding.bottom,
bottom: math.max(MediaQuery.of(context).padding.bottom, 16),
left: 16,
right: 16,
child: ChatMessageInput(

View File

@ -6,6 +6,7 @@ import 'package:solian/theme.dart';
import 'package:solian/widgets/prev_page.dart';
import 'package:solian/widgets/navigation/app_navigation_bottom_bar.dart';
import 'package:solian/widgets/navigation/app_navigation_rail.dart';
import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
class NavShell extends StatelessWidget {
final bool showAppBar;
@ -42,7 +43,17 @@ class NavShell extends StatelessWidget {
children: [
const AppNavigationRail(),
const VerticalDivider(thickness: 0.3, width: 1),
Expanded(child: child),
Flexible(
flex: 2,
child: child,
),
if (SolianTheme.isExtraLargeScreen(context))
const VerticalDivider(thickness: 0.3, width: 1),
if (SolianTheme.isExtraLargeScreen(context))
const Flexible(
flex: 1,
child: SidebarPlaceholder(),
),
],
)
: child,

View File

@ -4,11 +4,15 @@ abstract class SolianTheme {
static bool isLargeScreen(BuildContext context) =>
MediaQuery.of(context).size.width > 640;
static bool isExtraLargeScreen(BuildContext context) =>
MediaQuery.of(context).size.width > 720;
static ThemeData build(Brightness brightness) {
return ThemeData(
brightness: brightness,
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(brightness: brightness, seedColor: Colors.indigo),
colorScheme: ColorScheme.fromSeed(
brightness: brightness, seedColor: Colors.indigo),
);
}
}

View File

@ -99,6 +99,9 @@ class SolianMessages extends Translations {
'attachmentAddFile': 'Attach file',
'attachmentSetting': 'Adjust attachment',
'attachmentAlt': 'Alternative text',
'attachmentLoadFailed': 'Load Attachment Failed',
'attachmentLoadFailedCaption':
'Something went wrong during loading the attachment metadata...',
'realm': 'Realm',
'realms': 'Realms',
'realmOrganizing': 'Organize a realm',
@ -182,6 +185,8 @@ class SolianMessages extends Translations {
'callParticipantVideoOff': 'Turn Off Participant Video',
'callParticipantVideoOn': 'Turn On Participant Video',
'callAlreadyOngoing': 'A call is already ongoing',
'sidebarPlaceholder':
'Your screen is really too large, so we had to leave some space here to prevent the layout from being too messy. In the future, we will add some small widgets here for wealthy users like you to enjoy, but for now, it will stay this way.'
},
'zh_CN': {
'hide': '隐藏',
@ -272,6 +277,8 @@ class SolianMessages extends Translations {
'attachmentAddFile': '附加文件',
'attachmentSetting': '调整附件',
'attachmentAlt': '替代文字',
'attachmentLoadFailed': '加载失败',
'attachmentLoadFailedCaption': '有错误发生于加载附件元数据的过程中了…',
'realm': '领域',
'realms': '领域',
'realmOrganizing': '组织领域',
@ -351,6 +358,8 @@ class SolianMessages extends Translations {
'callParticipantVideoOff': '静音参与者',
'callParticipantVideoOn': '解除静音参与者',
'callAlreadyOngoing': '当前正在进行一则通话',
'sidebarPlaceholder':
'你的屏幕真的太大啦,我们只好空出一块地方好让布局不那么混乱,未来我们会在此处加入一下小挂件来供你这样的富人玩乐,但现在就这样吧。'
}
};
}

View File

@ -40,12 +40,15 @@ class _AttachmentListState extends State<AttachmentList> {
for (var idx = 0; idx < widget.attachmentsId.length; idx++) {
provider.getMetadata(widget.attachmentsId[idx]).then((resp) {
progress++;
if (resp.body != null) {
_attachmentsMeta[idx] = Attachment.fromJson(resp.body);
}
if (progress == widget.attachmentsId.length) {
setState(() {
calculateAspectRatio();
_isLoading = false;
});
if (mounted) {
setState(() => _isLoading = false);
}
}
});
}
@ -118,6 +121,31 @@ class _AttachmentListState extends State<AttachmentList> {
itemCount: _attachmentsMeta.length,
itemBuilder: (context, 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(
child: Container(
width: MediaQuery.of(context).size.width,
@ -129,7 +157,7 @@ class _AttachmentListState extends State<AttachmentList> {
children: [
AttachmentItem(
parentId: widget.parentId,
key: Key('a${element!.uuid}'),
key: Key('a${element.uuid}'),
item: element,
badge: _attachmentsMeta.length > 1
? '${idx + 1}/${_attachmentsMeta.length}'

View File

@ -154,7 +154,7 @@ class _AttachmentPublishingPopupState extends State<AttachmentPublishingPopup> {
var result = Attachment.fromJson(resp.body);
setState(() => _attachments.add(result));
widget.onUpdate(_attachments.map((e) => e!.id).toList());
} catch (e) {
} catch (err) {
rethrow;
}
}
@ -239,7 +239,8 @@ class _AttachmentPublishingPopupState extends State<AttachmentPublishingPopup> {
itemCount: _attachments.length,
itemBuilder: (context, index) {
final element = _attachments[index];
final fileType = element!.mimetype.split('/').first;
var fileType = element!.mimetype.split('/').firstOrNull;
fileType ??= 'unknown';
return Container(
padding:
const EdgeInsets.only(left: 16, right: 8, bottom: 16),

View File

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class SidebarPlaceholder extends StatelessWidget {
const SidebarPlaceholder({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 280),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.menu_open, size: 48),
const SizedBox(height: 8),
Text('sidebarPlaceholder'.tr, textAlign: TextAlign.center),
],
),
),
);
}
}