refactor: Migrate to null safety
This commit is contained in:
parent
5269f04a99
commit
55f0300f9f
163 changed files with 1759 additions and 1903 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
|
|
@ -19,38 +20,38 @@ class NotificationSettingsItem {
|
|||
NotificationSettingsItem(
|
||||
PushRuleKind.underride,
|
||||
'.m.rule.room_one_to_one',
|
||||
(c) => L10n.of(c).directChats,
|
||||
(c) => L10n.of(c)!.directChats,
|
||||
),
|
||||
NotificationSettingsItem(
|
||||
PushRuleKind.override,
|
||||
'.m.rule.contains_display_name',
|
||||
(c) => L10n.of(c).containsDisplayName,
|
||||
(c) => L10n.of(c)!.containsDisplayName,
|
||||
),
|
||||
NotificationSettingsItem(
|
||||
PushRuleKind.content,
|
||||
'.m.rule.contains_user_name',
|
||||
(c) => L10n.of(c).containsUserName,
|
||||
(c) => L10n.of(c)!.containsUserName,
|
||||
),
|
||||
NotificationSettingsItem(
|
||||
PushRuleKind.override,
|
||||
'.m.rule.invite_for_me',
|
||||
(c) => L10n.of(c).inviteForMe,
|
||||
(c) => L10n.of(c)!.inviteForMe,
|
||||
),
|
||||
NotificationSettingsItem(
|
||||
PushRuleKind.override,
|
||||
'.m.rule.member_event',
|
||||
(c) => L10n.of(c).memberChanges,
|
||||
(c) => L10n.of(c)!.memberChanges,
|
||||
),
|
||||
NotificationSettingsItem(
|
||||
PushRuleKind.override,
|
||||
'.m.rule.suppress_notices',
|
||||
(c) => L10n.of(c).botMessages,
|
||||
(c) => L10n.of(c)!.botMessages,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
class SettingsNotifications extends StatefulWidget {
|
||||
const SettingsNotifications({Key key}) : super(key: key);
|
||||
const SettingsNotifications({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
SettingsNotificationsController createState() =>
|
||||
|
|
@ -71,31 +72,30 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
return NotificationSetting.open();
|
||||
}
|
||||
|
||||
bool getNotificationSetting(NotificationSettingsItem item) {
|
||||
bool? getNotificationSetting(NotificationSettingsItem item) {
|
||||
final pushRules = Matrix.of(context).client.globalPushRules;
|
||||
switch (item.type) {
|
||||
case PushRuleKind.content:
|
||||
return pushRules.content
|
||||
?.singleWhere((r) => r.ruleId == item.key, orElse: () => null)
|
||||
return pushRules!.content
|
||||
?.singleWhereOrNull((r) => r.ruleId == item.key)
|
||||
?.enabled;
|
||||
case PushRuleKind.override:
|
||||
return pushRules.override
|
||||
?.singleWhere((r) => r.ruleId == item.key, orElse: () => null)
|
||||
return pushRules!.override
|
||||
?.singleWhereOrNull((r) => r.ruleId == item.key)
|
||||
?.enabled;
|
||||
case PushRuleKind.room:
|
||||
return pushRules.room
|
||||
?.singleWhere((r) => r.ruleId == item.key, orElse: () => null)
|
||||
return pushRules!.room
|
||||
?.singleWhereOrNull((r) => r.ruleId == item.key)
|
||||
?.enabled;
|
||||
case PushRuleKind.sender:
|
||||
return pushRules.sender
|
||||
?.singleWhere((r) => r.ruleId == item.key, orElse: () => null)
|
||||
return pushRules!.sender
|
||||
?.singleWhereOrNull((r) => r.ruleId == item.key)
|
||||
?.enabled;
|
||||
case PushRuleKind.underride:
|
||||
return pushRules.underride
|
||||
?.singleWhere((r) => r.ruleId == item.key, orElse: () => null)
|
||||
return pushRules!.underride
|
||||
?.singleWhereOrNull((r) => r.ruleId == item.key)
|
||||
?.enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setNotificationSetting(NotificationSettingsItem item, bool enabled) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue