refactor: Update to Dart 3.10 with . shorthands
This commit is contained in:
parent
75a37f3f7c
commit
1ea649f01e
167 changed files with 3351 additions and 3912 deletions
|
|
@ -11,10 +11,8 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|||
class ChatSearchFilesTab extends StatelessWidget {
|
||||
final Room room;
|
||||
final Stream<(List<Event>, String?)>? searchStream;
|
||||
final void Function({
|
||||
String? prevBatch,
|
||||
List<Event>? previousSearchResult,
|
||||
}) startSearch;
|
||||
final void Function({String? prevBatch, List<Event>? previousSearchResult})
|
||||
startSearch;
|
||||
|
||||
const ChatSearchFilesTab({
|
||||
required this.room,
|
||||
|
|
@ -32,15 +30,13 @@ class ChatSearchFilesTab extends StatelessWidget {
|
|||
final events = snapshot.data?.$1;
|
||||
if (searchStream == null || events == null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
L10n.of(context).searchIn(
|
||||
room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context)),
|
||||
),
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -49,7 +45,7 @@ class ChatSearchFilesTab extends StatelessWidget {
|
|||
|
||||
if (events.isEmpty) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const Icon(Icons.file_present_outlined, size: 64),
|
||||
const SizedBox(height: 8),
|
||||
|
|
@ -68,9 +64,7 @@ class ChatSearchFilesTab extends StatelessWidget {
|
|||
return const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -90,35 +84,35 @@ class ChatSearchFilesTab extends StatelessWidget {
|
|||
prevBatch: nextBatch,
|
||||
previousSearchResult: events,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.arrow_downward_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.arrow_downward_outlined),
|
||||
label: Text(L10n.of(context).searchMore),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final event = events[i];
|
||||
final filename = event.content.tryGet<String>('filename') ??
|
||||
final filename =
|
||||
event.content.tryGet<String>('filename') ??
|
||||
event.content.tryGet<String>('body') ??
|
||||
L10n.of(context).unknownEvent('File');
|
||||
final filetype = (filename.contains('.')
|
||||
? filename.split('.').last.toUpperCase()
|
||||
: event.content
|
||||
.tryGetMap<String, dynamic>('info')
|
||||
?.tryGet<String>('mimetype')
|
||||
?.toUpperCase() ??
|
||||
'UNKNOWN');
|
||||
.tryGetMap<String, dynamic>('info')
|
||||
?.tryGet<String>('mimetype')
|
||||
?.toUpperCase() ??
|
||||
'UNKNOWN');
|
||||
final sizeString = event.sizeString;
|
||||
final prevEvent = i > 0 ? events[i - 1] : null;
|
||||
final sameEnvironment = prevEvent == null
|
||||
? false
|
||||
: prevEvent.originServerTs
|
||||
.sameEnvironment(event.originServerTs);
|
||||
: prevEvent.originServerTs.sameEnvironment(
|
||||
event.originServerTs,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
if (!sameEnvironment) ...[
|
||||
Row(
|
||||
|
|
@ -148,8 +142,9 @@ class ChatSearchFilesTab extends StatelessWidget {
|
|||
const SizedBox(height: 4),
|
||||
],
|
||||
Material(
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConfig.borderRadius),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConfig.borderRadius,
|
||||
),
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: ListTile(
|
||||
|
|
|
|||
|
|
@ -13,10 +13,8 @@ import 'package:fluffychat/widgets/mxc_image.dart';
|
|||
class ChatSearchImagesTab extends StatelessWidget {
|
||||
final Room room;
|
||||
final Stream<(List<Event>, String?)>? searchStream;
|
||||
final void Function({
|
||||
String? prevBatch,
|
||||
List<Event>? previousSearchResult,
|
||||
}) startSearch;
|
||||
final void Function({String? prevBatch, List<Event>? previousSearchResult})
|
||||
startSearch;
|
||||
|
||||
const ChatSearchImagesTab({
|
||||
required this.room,
|
||||
|
|
@ -35,15 +33,13 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
final events = snapshot.data?.$1;
|
||||
if (searchStream == null || events == null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
L10n.of(context).searchIn(
|
||||
room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context)),
|
||||
),
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -51,7 +47,7 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
}
|
||||
if (events.isEmpty) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const Icon(Icons.photo_outlined, size: 64),
|
||||
const SizedBox(height: 8),
|
||||
|
|
@ -80,9 +76,7 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
return const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -102,9 +96,7 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
prevBatch: nextBatch,
|
||||
previousSearchResult: events,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.arrow_downward_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.arrow_downward_outlined),
|
||||
label: Text(L10n.of(context).searchMore),
|
||||
),
|
||||
),
|
||||
|
|
@ -113,16 +105,13 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
|
||||
final monthEvents = eventsByMonthList[i].value;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: theme.dividerColor,
|
||||
),
|
||||
child: Container(height: 1, color: theme.dividerColor),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
|
@ -135,10 +124,7 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: theme.dividerColor,
|
||||
),
|
||||
child: Container(height: 1, color: theme.dividerColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
@ -150,39 +136,35 @@ class ChatSearchImagesTab extends StatelessWidget {
|
|||
clipBehavior: Clip.hardEdge,
|
||||
padding: const EdgeInsets.all(padding),
|
||||
crossAxisCount: 3,
|
||||
children: monthEvents.map(
|
||||
(event) {
|
||||
if (event.messageType == MessageTypes.Video) {
|
||||
return Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: borderRadius,
|
||||
child: EventVideoPlayer(event),
|
||||
);
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (_) => ImageViewer(
|
||||
event,
|
||||
outerContext: context,
|
||||
),
|
||||
),
|
||||
children: monthEvents.map((event) {
|
||||
if (event.messageType == MessageTypes.Video) {
|
||||
return Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: borderRadius,
|
||||
child: Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: borderRadius,
|
||||
child: MxcImage(
|
||||
event: event,
|
||||
width: 128,
|
||||
height: 128,
|
||||
fit: BoxFit.cover,
|
||||
animated: true,
|
||||
isThumbnail: true,
|
||||
),
|
||||
),
|
||||
child: EventVideoPlayer(event),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (_) =>
|
||||
ImageViewer(event, outerContext: context),
|
||||
),
|
||||
borderRadius: borderRadius,
|
||||
child: Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: borderRadius,
|
||||
child: MxcImage(
|
||||
event: event,
|
||||
width: 128,
|
||||
height: 128,
|
||||
fit: BoxFit.cover,
|
||||
animated: true,
|
||||
isThumbnail: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@ class ChatSearchMessageTab extends StatelessWidget {
|
|||
final String searchQuery;
|
||||
final Room room;
|
||||
final Stream<(List<Event>, String?)>? searchStream;
|
||||
final void Function({
|
||||
String? prevBatch,
|
||||
List<Event>? previousSearchResult,
|
||||
}) startSearch;
|
||||
final void Function({String? prevBatch, List<Event>? previousSearchResult})
|
||||
startSearch;
|
||||
|
||||
const ChatSearchMessageTab({
|
||||
required this.searchQuery,
|
||||
|
|
@ -36,15 +34,13 @@ class ChatSearchMessageTab extends StatelessWidget {
|
|||
final theme = Theme.of(context);
|
||||
if (searchStream == null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const Icon(Icons.search_outlined, size: 64),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
L10n.of(context).searchIn(
|
||||
room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context)),
|
||||
),
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -55,19 +51,15 @@ class ChatSearchMessageTab extends StatelessWidget {
|
|||
return SelectionArea(
|
||||
child: ListView.separated(
|
||||
itemCount: events.length + 1,
|
||||
separatorBuilder: (context, _) => Divider(
|
||||
color: theme.dividerColor,
|
||||
height: 1,
|
||||
),
|
||||
separatorBuilder: (context, _) =>
|
||||
Divider(color: theme.dividerColor, height: 1),
|
||||
itemBuilder: (context, i) {
|
||||
if (i == events.length) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -87,9 +79,7 @@ class ChatSearchMessageTab extends StatelessWidget {
|
|||
prevBatch: nextBatch,
|
||||
previousSearchResult: events,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.arrow_downward_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.arrow_downward_outlined),
|
||||
label: Text(L10n.of(context).searchMore),
|
||||
),
|
||||
),
|
||||
|
|
@ -134,15 +124,9 @@ class _MessageSearchResultListTile extends StatelessWidget {
|
|||
return ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Avatar(
|
||||
mxContent: sender.avatarUrl,
|
||||
name: displayname,
|
||||
size: 16,
|
||||
),
|
||||
Avatar(mxContent: sender.avatarUrl, name: displayname, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
displayname,
|
||||
),
|
||||
Text(displayname),
|
||||
Expanded(
|
||||
child: Text(
|
||||
' | ${event.originServerTs.localizedTimeShort(context)}',
|
||||
|
|
@ -164,23 +148,16 @@ class _MessageSearchResultListTile extends StatelessWidget {
|
|||
.calcLocalizedBodyFallback(
|
||||
plaintextBody: true,
|
||||
removeMarkdown: true,
|
||||
MatrixLocals(
|
||||
L10n.of(context),
|
||||
),
|
||||
MatrixLocals(L10n.of(context)),
|
||||
)
|
||||
.trim(),
|
||||
maxLines: 7,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.chevron_right_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.chevron_right_outlined),
|
||||
onPressed: () => context.go(
|
||||
'/${Uri(
|
||||
pathSegments: ['rooms', room.id],
|
||||
queryParameters: {'event': event.eventId},
|
||||
)}',
|
||||
'/${Uri(pathSegments: ['rooms', room.id], queryParameters: {'event': event.eventId})}',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ class ChatSearchView extends StatelessWidget {
|
|||
if (FluffyThemes.isThreeColumnMode(context))
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextField(
|
||||
controller: controller.searchController,
|
||||
onSubmitted: (_) => controller.restartSearch(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue