💄 Optimized for navigation drawer

This commit is contained in:
2024-07-13 18:54:08 +08:00
parent 201c38800b
commit a68a78597e
15 changed files with 143 additions and 93 deletions

View File

@ -5,8 +5,13 @@ import 'package:url_launcher/url_launcher_string.dart';
class MarkdownTextContent extends StatelessWidget {
final String content;
final bool isSelectable;
const MarkdownTextContent({super.key, required this.content});
const MarkdownTextContent({
super.key,
required this.content,
this.isSelectable = false,
});
@override
Widget build(BuildContext context) {
@ -15,6 +20,7 @@ class MarkdownTextContent extends StatelessWidget {
physics: const NeverScrollableScrollPhysics(),
data: content,
padding: EdgeInsets.zero,
selectable: isSelectable,
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
horizontalRuleDecoration: BoxDecoration(
border: Border(

View File

@ -8,16 +8,16 @@ abstract class AppNavigation {
label: 'home'.tr,
page: 'home',
),
AppNavigationDestination(
icon: const Icon(Icons.forum),
label: 'chat'.tr,
page: 'chat',
),
AppNavigationDestination(
icon: const Icon(Icons.workspaces),
label: 'realms'.tr,
page: 'realms',
),
AppNavigationDestination(
icon: const Icon(Icons.forum),
label: 'channelTypeDirect'.tr,
page: 'chat',
),
];
static List<String> get destinationPages =>

View File

@ -86,8 +86,18 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
FutureBuilder(
future: auth.getProfileWithCheck(),
builder: (context, snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const SizedBox();
if (snapshot.data == null) {
return ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 28),
leading: const Icon(Icons.account_circle),
title: Text('guest'.tr),
subtitle: Text('unsignedIn'.tr),
onTap: () {
AppRouter.instance.goNamed('account');
setState(() => _selectedIndex = null);
closeDrawer();
},
);
}
return ListTile(
@ -147,11 +157,12 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
),
onTap: () {
AppRouter.instance.goNamed('account');
setState(() => _selectedIndex = null);
closeDrawer();
},
).paddingOnly(top: 8);
);
},
),
).paddingOnly(top: 8),
const Divider(thickness: 0.3, height: 1).paddingOnly(
bottom: 12,
top: 8,
@ -176,25 +187,33 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
return Column(
children: [
ExpansionTile(
title: Text('chat'.tr),
tilePadding: const EdgeInsets.symmetric(horizontal: 24),
children: [
Obx(
() => SizedBox(
height: 360,
child: ChannelListWidget(
channels: _channels.groupChannels,
selfId: selfId,
isDense: true,
useReplace: true,
onSelected: (_) {
closeDrawer();
},
Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
title: Text('channels'.tr),
tilePadding: const EdgeInsets.symmetric(horizontal: 24),
children: [
Obx(
() => SizedBox(
height: 360,
child: RefreshIndicator(
onRefresh: () =>
_channels.refreshAvailableChannel(),
child: ChannelListWidget(
channels: _channels.groupChannels,
selfId: selfId,
isDense: true,
useReplace: true,
onSelected: (_) {
setState(() => _selectedIndex = null);
closeDrawer();
},
),
),
),
),
),
],
],
),
),
],
);

View File

@ -20,6 +20,7 @@ class PostItem extends StatefulWidget {
final bool isShowReply;
final bool isShowEmbed;
final bool isFullDate;
final bool isContentSelectable;
final String? overrideAttachmentParent;
const PostItem({
@ -31,6 +32,7 @@ class PostItem extends StatefulWidget {
this.isShowReply = true,
this.isShowEmbed = true,
this.isFullDate = false,
this.isContentSelectable = false,
this.overrideAttachmentParent,
});
@ -41,6 +43,9 @@ class PostItem extends StatefulWidget {
class _PostItemState extends State<PostItem> {
late final Post item;
Color get _unFocusColor =>
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
@override
void initState() {
item = widget.item;
@ -96,7 +101,7 @@ class _PostItemState extends State<PostItem> {
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
color: _unFocusColor,
),
));
}
@ -119,17 +124,14 @@ class _PostItemState extends State<PostItem> {
FaIcon(
FontAwesomeIcons.reply,
size: 16,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
color: _unFocusColor,
),
Expanded(
child: Text(
'postRepliedNotify'.trParams(
{'username': '@${widget.item.replyTo!.author.name}'},
),
style: TextStyle(
color:
Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
),
style: TextStyle(color: _unFocusColor),
).paddingOnly(left: 6),
),
],
@ -154,17 +156,14 @@ class _PostItemState extends State<PostItem> {
FaIcon(
FontAwesomeIcons.retweet,
size: 16,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
color: _unFocusColor,
),
Expanded(
child: Text(
'postRepostedNotify'.trParams(
{'username': '@${widget.item.repostTo!.author.name}'},
),
style: TextStyle(
color:
Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
),
style: TextStyle(color: _unFocusColor),
).paddingOnly(left: 6),
),
],
@ -190,18 +189,32 @@ class _PostItemState extends State<PostItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildHeader().paddingSymmetric(horizontal: 12),
MarkdownTextContent(content: item.content).paddingOnly(
MarkdownTextContent(
content: item.content,
isSelectable: widget.isContentSelectable,
).paddingOnly(
left: 16,
right: 12,
top: 2,
bottom: hasAttachment ? 4 : 0,
),
buildFooter().paddingOnly(left: 16),
AttachmentList(
parentId: widget.overrideAttachmentParent ?? widget.item.alias,
attachmentsId: item.attachments ?? List.empty(),
divided: true,
),
if (item.attachments?.isNotEmpty ?? false)
Row(
children: [
Icon(
Icons.attachment,
size: 18,
color: _unFocusColor,
).paddingOnly(right: 6),
Text(
'postAttachmentTip'.trParams(
{'count': item.attachments!.length.toString()},
),
style: TextStyle(color: _unFocusColor),
)
],
).paddingOnly(left: 16, top: 4),
],
);
}
@ -231,8 +244,10 @@ class _PostItemState extends State<PostItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildHeader(),
MarkdownTextContent(content: item.content)
.paddingOnly(left: 12, right: 8),
MarkdownTextContent(
content: item.content,
isSelectable: widget.isContentSelectable,
).paddingOnly(left: 12, right: 8),
if (widget.item.replyTo != null && widget.isShowEmbed)
GestureDetector(
child: buildReply(context).paddingOnly(top: 4),