refactor: Added and applied require_trailing_commas linter rule

This commit is contained in:
Malin Errenst 2023-03-02 10:57:52 +01:00
commit ec7acc5385
112 changed files with 3466 additions and 2855 deletions

View file

@ -25,90 +25,94 @@ class SettingsNotificationsView extends StatelessWidget {
body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder(
stream: Matrix.of(context)
.client
.onAccountData
.stream
.where((event) => event.type == 'm.push_rules'),
builder: (BuildContext context, _) {
return Column(
children: [
SwitchListTile.adaptive(
value: !Matrix.of(context).client.allPushNotificationsMuted,
title: Text(
L10n.of(context)!.notificationsEnabledForThisAccount),
onChanged: (_) => showFutureLoadingDialog(
context: context,
future: () =>
Matrix.of(context).client.setMuteAllPushNotifications(
!Matrix.of(context)
.client
.allPushNotificationsMuted,
),
),
stream: Matrix.of(context)
.client
.onAccountData
.stream
.where((event) => event.type == 'm.push_rules'),
builder: (BuildContext context, _) {
return Column(
children: [
SwitchListTile.adaptive(
value: !Matrix.of(context).client.allPushNotificationsMuted,
title: Text(
L10n.of(context)!.notificationsEnabledForThisAccount,
),
if (!Matrix.of(context).client.allPushNotificationsMuted) ...{
const Divider(thickness: 1),
ListTile(
title: Text(
L10n.of(context)!.pushRules,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
onChanged: (_) => showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context)
.client
.setMuteAllPushNotifications(
!Matrix.of(context).client.allPushNotificationsMuted,
),
),
),
for (var item in NotificationSettingsItem.items)
SwitchListTile.adaptive(
value: controller.getNotificationSetting(item) ?? true,
title: Text(item.title(context)),
onChanged: (bool enabled) =>
controller.setNotificationSetting(item, enabled),
),
},
),
),
if (!Matrix.of(context).client.allPushNotificationsMuted) ...{
const Divider(thickness: 1),
ListTile(
title: Text(
L10n.of(context)!.devices,
L10n.of(context)!.pushRules,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
FutureBuilder<List<Pusher>?>(
future: controller.pusherFuture ??=
Matrix.of(context).client.getPushers(),
builder: (context, snapshot) {
if (snapshot.hasError) {
Center(
child: Text(
snapshot.error!.toLocalizedString(context),
),
);
}
if (snapshot.connectionState != ConnectionState.done) {
const Center(
child: CircularProgressIndicator.adaptive(
strokeWidth: 2));
}
final pushers = snapshot.data ?? [];
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: pushers.length,
itemBuilder: (_, i) => ListTile(
title: Text(
'${pushers[i].appDisplayName} - ${pushers[i].appId}'),
subtitle: Text(pushers[i].data.url.toString()),
onTap: () => controller.onPusherTap(pushers[i]),
for (var item in NotificationSettingsItem.items)
SwitchListTile.adaptive(
value: controller.getNotificationSetting(item) ?? true,
title: Text(item.title(context)),
onChanged: (bool enabled) =>
controller.setNotificationSetting(item, enabled),
),
},
const Divider(thickness: 1),
ListTile(
title: Text(
L10n.of(context)!.devices,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
FutureBuilder<List<Pusher>?>(
future: controller.pusherFuture ??=
Matrix.of(context).client.getPushers(),
builder: (context, snapshot) {
if (snapshot.hasError) {
Center(
child: Text(
snapshot.error!.toLocalizedString(context),
),
);
},
),
],
);
}),
}
if (snapshot.connectionState != ConnectionState.done) {
const Center(
child: CircularProgressIndicator.adaptive(
strokeWidth: 2,
),
);
}
final pushers = snapshot.data ?? [];
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: pushers.length,
itemBuilder: (_, i) => ListTile(
title: Text(
'${pushers[i].appDisplayName} - ${pushers[i].appId}',
),
subtitle: Text(pushers[i].data.url.toString()),
onTap: () => controller.onPusherTap(pushers[i]),
),
);
},
),
],
);
},
),
),
);
}