Compare commits

..

No commits in common. "a75083d916dd246ccc691142bb2408d66cf9ad1b" and "00863b94e82462cd57853dc6d012285e4a7ea95d" have entirely different histories.

4 changed files with 66 additions and 73 deletions

View File

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

View File

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

View File

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

View File

@ -74,35 +74,40 @@ class _AttachmentListState extends State<AttachmentList> {
return Container( return Container(
padding: widget.padding ?? EdgeInsets.zero, padding: widget.padding ?? EdgeInsets.zero,
constraints: constraints, constraints: constraints,
child: AspectRatio( child: GestureDetector(
aspectRatio: singleAspectRatio, child: AspectRatio(
child: Container( aspectRatio: singleAspectRatio,
decoration: BoxDecoration( child: Container(
color: backgroundColor, decoration: BoxDecoration(
border: Border.fromBorderSide(borderSide), color: backgroundColor,
borderRadius: AttachmentList.kDefaultRadius, border: Border.fromBorderSide(borderSide),
), borderRadius: AttachmentList.kDefaultRadius,
child: ClipRRect( ),
borderRadius: AttachmentList.kDefaultRadius, child: ClipRRect(
child: AttachmentItem( borderRadius: AttachmentList.kDefaultRadius,
data: widget.data[0], child: AttachmentItem(
heroTag: heroTags[0], data: widget.data[0],
fit: widget.fit, heroTag: heroTags[0],
filterQuality: widget.filterQuality, fit: widget.fit,
onZoom: () { filterQuality: widget.filterQuality,
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,
);
},
), ),
); );
} }
@ -128,27 +133,33 @@ class _AttachmentListState extends State<AttachmentList> {
mainAxisSpacing: 4, mainAxisSpacing: 4,
children: widget.data children: widget.data
.mapIndexed( .mapIndexed(
(idx, ele) => Container( (idx, ele) => GestureDetector(
constraints: constraints, child: Container(
child: AttachmentItem( constraints: constraints,
data: ele, child: AttachmentItem(
heroTag: heroTags[idx], data: ele,
fit: BoxFit.cover, heroTag: heroTags[idx],
filterQuality: widget.filterQuality, fit: BoxFit.cover,
onZoom: () { filterQuality: widget.filterQuality,
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(), .toList(),