Compare commits

..

3 Commits

Author SHA1 Message Date
a75083d916 ♻️ Improve the attachment item gesture 2025-04-01 23:48:45 +08:00
919ff5e464 💄 Optimized unread indicator 2025-04-01 22:40:43 +08:00
00863b94e8 🐛 Fix remain bugs 2025-04-01 22:36:06 +08:00
7 changed files with 78 additions and 79 deletions

View File

@ -255,8 +255,9 @@ class PostWriteController extends ChangeNotifier {
List.from(post.categories.map((ele) => ele.alias), growable: true);
attachments.addAll(
post.body['attachments']
?.where((ele) => SnAttachment.fromJson(ele))
?.map(PostWriteMedia) ??
?.map((ele) => SnAttachment.fromJson(ele))
?.map((ele) => PostWriteMedia(ele))
?.cast<PostWriteMedia>() ??
[],
);
poll = post.poll;

View File

@ -171,7 +171,18 @@ class _ChatScreenState extends State<ChatScreen> {
}
void _onTapChannel(SnChannel channel) {
setState(() => _unreadCounts?[channel.id] = 0);
setState(() {
_unreadCounts?[channel.id] = 0;
if (channel.realmId != null) {
_unreadCountsGrouped?[channel.realmId!] =
(_unreadCountsGrouped?[channel.realmId!] ?? 0) -
(_unreadCounts?[channel.id] ?? 0);
}
if (channel.type == 1) {
_unreadCountsGrouped?[0] =
(_unreadCountsGrouped?[0] ?? 0) - (_unreadCounts?[channel.id] ?? 0);
}
});
if (ResponsiveScaffold.getIsExpand(context)) {
GoRouter.of(context).pushReplacementNamed(
'chatRoom',
@ -180,9 +191,8 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias,
},
).then((value) {
if (mounted) {
setState(() => _unreadCounts?[channel.id] = 0);
_refreshChannels(noRemote: true);
if (mounted && value == true) {
_refreshChannels();
}
});
} else {
@ -193,9 +203,8 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias,
},
).then((value) {
if (mounted) {
setState(() => _unreadCounts?[channel.id] = 0);
_refreshChannels(noRemote: true);
if (mounted && value == true) {
_refreshChannels();
}
});
}

View File

@ -11,7 +11,6 @@ import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/notification.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/notification.dart';
import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
import 'package:surface/widgets/markdown_content.dart';
@ -156,7 +155,7 @@ class _NotificationScreenState extends State<NotificationScreen> {
return AppScaffold(
appBar: AppBar(
leading: AutoAppBarLeading(),
leading: PageBackButton(),
title: Text('screenNotification').tr(),
actions: [
IconButton(

View File

@ -60,7 +60,7 @@ class AccountPopoverCard extends StatelessWidget {
IconButton(
onPressed: () {
Navigator.pop(context);
GoRouter.of(context).pushNamed(
GoRouter.of(context).pushReplacementNamed(
'accountProfilePage',
pathParameters: {'name': data.name},
);

View File

@ -25,6 +25,7 @@ class AttachmentItem extends StatelessWidget {
final String? heroTag;
final BoxFit fit;
final FilterQuality? filterQuality;
final Function? onZoom;
const AttachmentItem({
super.key,
@ -32,6 +33,7 @@ class AttachmentItem extends StatelessWidget {
required this.data,
required this.heroTag,
this.filterQuality,
this.onZoom,
});
Widget _buildContent(BuildContext context) {
@ -94,7 +96,14 @@ class AttachmentItem extends StatelessWidget {
});
}
return _buildContent(context);
return GestureDetector(
child: _buildContent(context),
onTap: () {
if (data?.mimetype.startsWith('image') ?? false) {
onZoom?.call();
}
},
);
}
}

View File

@ -74,40 +74,35 @@ class _AttachmentListState extends State<AttachmentList> {
return Container(
padding: widget.padding ?? EdgeInsets.zero,
constraints: constraints,
child: GestureDetector(
child: AspectRatio(
aspectRatio: singleAspectRatio,
child: Container(
decoration: BoxDecoration(
color: backgroundColor,
border: Border.fromBorderSide(borderSide),
borderRadius: AttachmentList.kDefaultRadius,
),
child: ClipRRect(
borderRadius: AttachmentList.kDefaultRadius,
child: AttachmentItem(
data: widget.data[0],
heroTag: heroTags[0],
fit: widget.fit,
filterQuality: widget.filterQuality,
),
child: AspectRatio(
aspectRatio: singleAspectRatio,
child: Container(
decoration: BoxDecoration(
color: backgroundColor,
border: Border.fromBorderSide(borderSide),
borderRadius: AttachmentList.kDefaultRadius,
),
child: ClipRRect(
borderRadius: AttachmentList.kDefaultRadius,
child: AttachmentItem(
data: widget.data[0],
heroTag: heroTags[0],
fit: widget.fit,
filterQuality: widget.filterQuality,
onZoom: () {
context.pushTransparentRoute(
AttachmentZoomView(
data: widget.data.where((ele) => ele != null).cast(),
initialIndex: 0,
heroTags: heroTags,
),
backgroundColor: Colors.black.withOpacity(0.7),
rootNavigator: true,
);
},
),
),
),
onTap: () {
if (widget.data.firstOrNull?.mediaType != SnMediaType.image) {
return;
}
context.pushTransparentRoute(
AttachmentZoomView(
data: widget.data.where((ele) => ele != null).cast(),
initialIndex: 0,
heroTags: heroTags,
),
backgroundColor: Colors.black.withOpacity(0.7),
rootNavigator: true,
);
},
),
);
}
@ -133,33 +128,27 @@ class _AttachmentListState extends State<AttachmentList> {
mainAxisSpacing: 4,
children: widget.data
.mapIndexed(
(idx, ele) => GestureDetector(
child: Container(
constraints: constraints,
child: AttachmentItem(
data: ele,
heroTag: heroTags[idx],
fit: BoxFit.cover,
filterQuality: widget.filterQuality,
),
(idx, ele) => Container(
constraints: constraints,
child: AttachmentItem(
data: ele,
heroTag: heroTags[idx],
fit: BoxFit.cover,
filterQuality: widget.filterQuality,
onZoom: () {
context.pushTransparentRoute(
AttachmentZoomView(
data: widget.data
.where((ele) => ele != null)
.cast(),
initialIndex: idx,
heroTags: heroTags,
),
backgroundColor: Colors.black.withOpacity(0.7),
rootNavigator: true,
);
},
),
onTap: () {
if (widget.data[idx]!.mediaType !=
SnMediaType.image) {
return;
}
context.pushTransparentRoute(
AttachmentZoomView(
data: widget.data
.where((ele) => ele != null)
.cast(),
initialIndex: idx,
heroTags: heroTags,
),
backgroundColor: Colors.black.withOpacity(0.7),
rootNavigator: true,
);
},
),
)
.toList(),

View File

@ -100,6 +100,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
contentPadding: EdgeInsets.symmetric(horizontal: 24),
leading: AccountImage(
content: ua.user?.avatar,
backgroundColor: Colors.transparent,
fallbackWidget:
ua.isAuthorized ? null : const Icon(Symbols.login),
),
@ -122,15 +123,6 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
Scaffold.of(context).closeDrawer();
},
),
IconButton(
icon: const Icon(Symbols.settings, fill: 1),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
onPressed: () {
GoRouter.of(context).pushNamed('settings');
Scaffold.of(context).closeDrawer();
},
),
],
),
onTap: () {