refactor: Added and applied require_trailing_commas linter rule
This commit is contained in:
parent
adb3f766e5
commit
ec7acc5385
112 changed files with 3466 additions and 2855 deletions
|
|
@ -150,7 +150,9 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context, future: () => widget.room.leave());
|
||||
context: context,
|
||||
future: () => widget.room.leave(),
|
||||
);
|
||||
if (success.error == null) {
|
||||
VRouter.of(context).to('/rooms');
|
||||
}
|
||||
|
|
@ -158,15 +160,17 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
break;
|
||||
case 'mute':
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room
|
||||
.setPushRuleState(PushRuleState.mentionsOnly));
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.setPushRuleState(PushRuleState.mentionsOnly),
|
||||
);
|
||||
break;
|
||||
case 'unmute':
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.setPushRuleState(PushRuleState.notify));
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.setPushRuleState(PushRuleState.notify),
|
||||
);
|
||||
break;
|
||||
case 'details':
|
||||
_showChatDetails();
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ class ContentBanner extends StatelessWidget {
|
|||
final double opacity;
|
||||
final WidgetBuilder? placeholder;
|
||||
|
||||
const ContentBanner(
|
||||
{this.mxContent,
|
||||
this.height = 400,
|
||||
this.defaultIcon = Icons.account_circle_outlined,
|
||||
this.onEdit,
|
||||
this.client,
|
||||
this.opacity = 0.75,
|
||||
this.placeholder,
|
||||
Key? key})
|
||||
: super(key: key);
|
||||
const ContentBanner({
|
||||
this.mxContent,
|
||||
this.height = 400,
|
||||
this.defaultIcon = Icons.account_circle_outlined,
|
||||
this.onEdit,
|
||||
this.client,
|
||||
this.opacity = 0.75,
|
||||
this.placeholder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ class LoadingView extends StatelessWidget {
|
|||
(_) async {
|
||||
await UpdateCheckerNoStore(context).checkUpdate();
|
||||
VRouter.of(context).to(
|
||||
Matrix.of(context).widget.clients.any((client) =>
|
||||
client.onLoginStateChanged.value == LoginState.loggedIn)
|
||||
Matrix.of(context).widget.clients.any(
|
||||
(client) =>
|
||||
client.onLoginStateChanged.value == LoginState.loggedIn,
|
||||
)
|
||||
? '/rooms'
|
||||
: '/home',
|
||||
queryParameters: VRouter.of(context).queryParameters,
|
||||
|
|
|
|||
|
|
@ -44,12 +44,17 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
removeMarkdown: true,
|
||||
);
|
||||
final icon = event.senderFromMemoryOrFallback.avatarUrl?.getThumbnail(
|
||||
client,
|
||||
width: 64,
|
||||
height: 64,
|
||||
method: ThumbnailMethod.crop) ??
|
||||
room.avatar?.getThumbnail(client,
|
||||
width: 64, height: 64, method: ThumbnailMethod.crop);
|
||||
client,
|
||||
width: 64,
|
||||
height: 64,
|
||||
method: ThumbnailMethod.crop,
|
||||
) ??
|
||||
room.avatar?.getThumbnail(
|
||||
client,
|
||||
width: 64,
|
||||
height: 64,
|
||||
method: ThumbnailMethod.crop,
|
||||
);
|
||||
if (kIsWeb) {
|
||||
html.AudioElement()
|
||||
..src =
|
||||
|
|
@ -73,7 +78,8 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
final avatarDirectory =
|
||||
await Directory('${tempDirectory.path}/notiavatars/').create();
|
||||
appIconFile = File(
|
||||
'${avatarDirectory.path}/${Uri.encodeComponent(appIconUrl.toString())}');
|
||||
'${avatarDirectory.path}/${Uri.encodeComponent(appIconUrl.toString())}',
|
||||
);
|
||||
if (await appIconFile.exists() == false) {
|
||||
final response = await http.get(appIconUrl);
|
||||
await appIconFile.writeAsBytes(response.bodyBytes);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ class LockScreenState extends State<LockScreen> {
|
|||
await ([TargetPlatform.linux]
|
||||
.contains(Theme.of(context).platform)
|
||||
? SharedPreferences.getInstance().then(
|
||||
(prefs) => prefs.getString(SettingKeys.appLockKey))
|
||||
(prefs) => prefs.getString(SettingKeys.appLockKey),
|
||||
)
|
||||
: const FlutterSecureStorage()
|
||||
.read(key: SettingKeys.appLockKey))) {
|
||||
AppLock.of(context)!.didUnlock();
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@ class LogViewerState extends State<LogViewer> {
|
|||
),
|
||||
PopupMenuButton<Level>(
|
||||
itemBuilder: (context) => Level.values
|
||||
.map((level) => PopupMenuItem(
|
||||
value: level,
|
||||
child: Text(level.toString()),
|
||||
))
|
||||
.map(
|
||||
(level) => PopupMenuItem(
|
||||
value: level,
|
||||
child: Text(level.toString()),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onSelected: (Level level) => setState(() => logLevel = level),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -135,18 +135,22 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
continue;
|
||||
}
|
||||
resBundles[bundle.name] ??= [];
|
||||
resBundles[bundle.name]!.add(_AccountBundleWithClient(
|
||||
client: widget.clients[i],
|
||||
bundle: bundle,
|
||||
));
|
||||
resBundles[bundle.name]!.add(
|
||||
_AccountBundleWithClient(
|
||||
client: widget.clients[i],
|
||||
bundle: bundle,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
for (final b in resBundles.values) {
|
||||
b.sort((a, b) => a.bundle!.priority == null
|
||||
? 1
|
||||
: b.bundle!.priority == null
|
||||
? -1
|
||||
: a.bundle!.priority!.compareTo(b.bundle!.priority!));
|
||||
b.sort(
|
||||
(a, b) => a.bundle!.priority == null
|
||||
? 1
|
||||
: b.bundle!.priority == null
|
||||
? -1
|
||||
: a.bundle!.priority!.compareTo(b.bundle!.priority!),
|
||||
);
|
||||
}
|
||||
return resBundles
|
||||
.map((k, v) => MapEntry(k, v.map((vv) => vv.client).toList()));
|
||||
|
|
@ -161,8 +165,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
return client;
|
||||
}
|
||||
final candidate = _loginClientCandidate ??= ClientManager.createClient(
|
||||
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}')
|
||||
..onLoginStateChanged
|
||||
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}',
|
||||
)..onLoginStateChanged
|
||||
.stream
|
||||
.where((l) => l == LoginState.loggedIn)
|
||||
.first
|
||||
|
|
@ -286,16 +290,20 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
final c = getClientByName(name);
|
||||
if (c == null) {
|
||||
Logs().w(
|
||||
'Attempted to register subscriptions for non-existing client $name');
|
||||
'Attempted to register subscriptions for non-existing client $name',
|
||||
);
|
||||
return;
|
||||
}
|
||||
onRoomKeyRequestSub[name] ??=
|
||||
c.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async {
|
||||
if (widget.clients.any(((cl) =>
|
||||
cl.userID == request.requestingDevice.userId &&
|
||||
cl.identityKey == request.requestingDevice.curve25519Key))) {
|
||||
if (widget.clients.any(
|
||||
((cl) =>
|
||||
cl.userID == request.requestingDevice.userId &&
|
||||
cl.identityKey == request.requestingDevice.curve25519Key),
|
||||
)) {
|
||||
Logs().i(
|
||||
'[Key Request] Request is from one of our own clients, forwarding the key...');
|
||||
'[Key Request] Request is from one of our own clients, forwarding the key...',
|
||||
);
|
||||
await request.forwardKey();
|
||||
}
|
||||
});
|
||||
|
|
@ -344,11 +352,13 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
c.onSync.stream.first.then((s) {
|
||||
html.Notification.requestPermission();
|
||||
onNotification[name] ??= c.onEvent.stream
|
||||
.where((e) =>
|
||||
e.type == EventUpdateType.timeline &&
|
||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(e.content['type']) &&
|
||||
e.content['sender'] != c.userID)
|
||||
.where(
|
||||
(e) =>
|
||||
e.type == EventUpdateType.timeline &&
|
||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(e.content['type']) &&
|
||||
e.content['sender'] != c.userID,
|
||||
)
|
||||
.listen(showLocalNotification);
|
||||
});
|
||||
}
|
||||
|
|
@ -448,25 +458,31 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
wallpaper = file;
|
||||
}
|
||||
});
|
||||
store.getItem(SettingKeys.fontSizeFactor).then((value) =>
|
||||
AppConfig.fontSizeFactor =
|
||||
double.tryParse(value ?? '') ?? AppConfig.fontSizeFactor);
|
||||
store.getItem(SettingKeys.bubbleSizeFactor).then((value) =>
|
||||
AppConfig.bubbleSizeFactor =
|
||||
double.tryParse(value ?? '') ?? AppConfig.bubbleSizeFactor);
|
||||
store.getItem(SettingKeys.fontSizeFactor).then(
|
||||
(value) => AppConfig.fontSizeFactor =
|
||||
double.tryParse(value ?? '') ?? AppConfig.fontSizeFactor,
|
||||
);
|
||||
store.getItem(SettingKeys.bubbleSizeFactor).then(
|
||||
(value) => AppConfig.bubbleSizeFactor =
|
||||
double.tryParse(value ?? '') ?? AppConfig.bubbleSizeFactor,
|
||||
);
|
||||
store
|
||||
.getItemBool(SettingKeys.renderHtml, AppConfig.renderHtml)
|
||||
.then((value) => AppConfig.renderHtml = value);
|
||||
store
|
||||
.getItemBool(
|
||||
SettingKeys.hideRedactedEvents, AppConfig.hideRedactedEvents)
|
||||
SettingKeys.hideRedactedEvents,
|
||||
AppConfig.hideRedactedEvents,
|
||||
)
|
||||
.then((value) => AppConfig.hideRedactedEvents = value);
|
||||
store
|
||||
.getItemBool(SettingKeys.hideUnknownEvents, AppConfig.hideUnknownEvents)
|
||||
.then((value) => AppConfig.hideUnknownEvents = value);
|
||||
store
|
||||
.getItemBool(SettingKeys.showDirectChatsInSpaces,
|
||||
AppConfig.showDirectChatsInSpaces)
|
||||
.getItemBool(
|
||||
SettingKeys.showDirectChatsInSpaces,
|
||||
AppConfig.showDirectChatsInSpaces,
|
||||
)
|
||||
.then((value) => AppConfig.showDirectChatsInSpaces = value);
|
||||
store
|
||||
.getItemBool(SettingKeys.separateChatTypes, AppConfig.separateChatTypes)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ extension on PermissionLevel {
|
|||
}
|
||||
}
|
||||
|
||||
Future<int?> showPermissionChooser(BuildContext context,
|
||||
{int currentLevel = 0}) async {
|
||||
Future<int?> showPermissionChooser(
|
||||
BuildContext context, {
|
||||
int currentLevel = 0,
|
||||
}) async {
|
||||
final permissionLevel = await showConfirmationDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.setPermissionsLevel,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
if (result.error == null) {
|
||||
if (client.getRoomById(result.result!) == null) {
|
||||
await client.onSync.stream.firstWhere(
|
||||
(sync) => sync.rooms?.join?.containsKey(result.result) ?? false);
|
||||
(sync) => sync.rooms?.join?.containsKey(result.result) ?? false,
|
||||
);
|
||||
}
|
||||
// don't open the room if the joined room is a space
|
||||
if (!client.getRoomById(result.result!)!.isSpace) {
|
||||
|
|
@ -93,66 +94,69 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
body: FutureBuilder<PublicRoomsChunk>(
|
||||
future: _search(context),
|
||||
builder: (context, snapshot) {
|
||||
final profile = snapshot.data;
|
||||
return ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
if (profile == null)
|
||||
Container(
|
||||
height: 156,
|
||||
alignment: Alignment.center,
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
child: snapshot.hasError
|
||||
? Text(snapshot.error!.toLocalizedString(context))
|
||||
: const CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2),
|
||||
)
|
||||
else
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Avatar(
|
||||
mxContent: profile.avatarUrl,
|
||||
name: profile.name ?? roomAlias,
|
||||
size: Avatar.defaultSize * 3,
|
||||
fontSize: 36,
|
||||
),
|
||||
future: _search(context),
|
||||
builder: (context, snapshot) {
|
||||
final profile = snapshot.data;
|
||||
return ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
if (profile == null)
|
||||
Container(
|
||||
height: 156,
|
||||
alignment: Alignment.center,
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
child: snapshot.hasError
|
||||
? Text(snapshot.error!.toLocalizedString(context))
|
||||
: const CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
else
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Avatar(
|
||||
mxContent: profile.avatarUrl,
|
||||
name: profile.name ?? roomAlias,
|
||||
size: Avatar.defaultSize * 3,
|
||||
fontSize: 36,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(profile?.name ??
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
profile?.name ??
|
||||
roomAlias?.localpart ??
|
||||
chunk!.roomId.localpart ??
|
||||
''),
|
||||
subtitle: Text(
|
||||
'${L10n.of(context)!.participant}: ${profile?.numJoinedMembers ?? 0}',
|
||||
),
|
||||
trailing: const Icon(Icons.account_box_outlined),
|
||||
'',
|
||||
),
|
||||
if (profile?.topic?.isNotEmpty ?? false)
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.groupDescription,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
subtitle: LinkText(
|
||||
text: profile!.topic!,
|
||||
linkStyle: const TextStyle(color: Colors.blueAccent),
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).textTheme.bodyMedium!.color,
|
||||
),
|
||||
onLinkTap: (url) =>
|
||||
UrlLauncher(context, url).launchUrl(),
|
||||
subtitle: Text(
|
||||
'${L10n.of(context)!.participant}: ${profile?.numJoinedMembers ?? 0}',
|
||||
),
|
||||
trailing: const Icon(Icons.account_box_outlined),
|
||||
),
|
||||
if (profile?.topic?.isNotEmpty ?? false)
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.groupDescription,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
subtitle: LinkText(
|
||||
text: profile!.topic!,
|
||||
linkStyle: const TextStyle(color: Colors.blueAccent),
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).textTheme.bodyMedium!.color,
|
||||
),
|
||||
onLinkTap: (url) => UrlLauncher(context, url).launchUrl(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,11 +91,12 @@ class ThemeController extends State<ThemeBuilder> {
|
|||
return Provider(
|
||||
create: (_) => this,
|
||||
child: DynamicColorBuilder(
|
||||
builder: (light, _) => widget.builder(
|
||||
context,
|
||||
themeMode,
|
||||
primaryColor ?? light?.primary,
|
||||
)),
|
||||
builder: (light, _) => widget.builder(
|
||||
context,
|
||||
themeMode,
|
||||
primaryColor ?? light?.primary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,38 +20,39 @@ class UnreadRoomsBadge extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder(
|
||||
stream: Matrix.of(context)
|
||||
stream: Matrix.of(context)
|
||||
.client
|
||||
.onSync
|
||||
.stream
|
||||
.where((syncUpdate) => syncUpdate.hasRoomUpdate),
|
||||
builder: (context, _) {
|
||||
final unreadCount = Matrix.of(context)
|
||||
.client
|
||||
.onSync
|
||||
.stream
|
||||
.where((syncUpdate) => syncUpdate.hasRoomUpdate),
|
||||
builder: (context, _) {
|
||||
final unreadCount = Matrix.of(context)
|
||||
.client
|
||||
.rooms
|
||||
.where(filter)
|
||||
.where((r) => (r.isUnread || r.membership == Membership.invite))
|
||||
.length;
|
||||
return b.Badge(
|
||||
alignment: Alignment.bottomRight,
|
||||
badgeContent: Text(
|
||||
unreadCount.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
fontSize: 12,
|
||||
),
|
||||
.rooms
|
||||
.where(filter)
|
||||
.where((r) => (r.isUnread || r.membership == Membership.invite))
|
||||
.length;
|
||||
return b.Badge(
|
||||
alignment: Alignment.bottomRight,
|
||||
badgeContent: Text(
|
||||
unreadCount.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
fontSize: 12,
|
||||
),
|
||||
showBadge: unreadCount != 0,
|
||||
animationType: b.BadgeAnimationType.scale,
|
||||
badgeColor: Theme.of(context).colorScheme.primary,
|
||||
position: badgePosition,
|
||||
elevation: 4,
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
width: 2,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
});
|
||||
),
|
||||
showBadge: unreadCount != 0,
|
||||
animationType: b.BadgeAnimationType.scale,
|
||||
badgeColor: Theme.of(context).colorScheme.primary,
|
||||
position: badgePosition,
|
||||
elevation: 4,
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
width: 2,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue