chore: Follow up push rule settings
This commit is contained in:
parent
0106c0f6f6
commit
07fdfd1649
1 changed files with 102 additions and 98 deletions
|
|
@ -43,117 +43,121 @@ class SettingsNotificationsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
builder: (BuildContext context, _) {
|
builder: (BuildContext context, _) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
return Column(
|
return SelectionArea(
|
||||||
children: [
|
child: Column(
|
||||||
if (pushRules != null)
|
children: [
|
||||||
for (final category in pushCategories) ...[
|
if (pushRules != null)
|
||||||
ListTile(
|
for (final category in pushCategories) ...[
|
||||||
title: Text(
|
ListTile(
|
||||||
category.kind.localized(L10n.of(context)),
|
title: Text(
|
||||||
style: TextStyle(
|
category.kind.localized(L10n.of(context)),
|
||||||
color: theme.colorScheme.secondary,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
color: theme.colorScheme.secondary,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
),
|
|
||||||
),
|
|
||||||
for (final rule in category.rules)
|
|
||||||
SwitchListTile.adaptive(
|
|
||||||
title: Text(rule.getPushRuleName(L10n.of(context))),
|
|
||||||
subtitle: Text.rich(
|
|
||||||
TextSpan(
|
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: rule.getPushRuleDescription(
|
|
||||||
L10n.of(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const TextSpan(text: ' '),
|
|
||||||
WidgetSpan(
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => controller.editPushRule(
|
|
||||||
rule,
|
|
||||||
category.kind,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
L10n.of(context).more,
|
|
||||||
style: TextStyle(
|
|
||||||
color: theme.colorScheme.primary,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
decorationColor:
|
|
||||||
theme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
value: rule.enabled,
|
|
||||||
onChanged: controller.isLoading
|
|
||||||
? null
|
|
||||||
: rule.ruleId != '.m.rule.master' &&
|
|
||||||
Matrix.of(context)
|
|
||||||
.client
|
|
||||||
.allPushNotificationsMuted
|
|
||||||
? null
|
|
||||||
: (_) => controller.togglePushRule(
|
|
||||||
category.kind,
|
|
||||||
rule,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Divider(color: theme.dividerColor),
|
for (final rule in category.rules)
|
||||||
],
|
ListTile(
|
||||||
ListTile(
|
title: Text(rule.getPushRuleName(L10n.of(context))),
|
||||||
title: Text(
|
subtitle: Text.rich(
|
||||||
L10n.of(context).devices,
|
TextSpan(
|
||||||
style: TextStyle(
|
children: [
|
||||||
color: theme.colorScheme.secondary,
|
TextSpan(
|
||||||
fontWeight: FontWeight.bold,
|
text: rule.getPushRuleDescription(
|
||||||
|
L10n.of(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
WidgetSpan(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => controller.editPushRule(
|
||||||
|
rule,
|
||||||
|
category.kind,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
L10n.of(context).more,
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
decorationColor:
|
||||||
|
theme.colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: Switch.adaptive(
|
||||||
|
value: rule.enabled,
|
||||||
|
onChanged: controller.isLoading
|
||||||
|
? null
|
||||||
|
: rule.ruleId != '.m.rule.master' &&
|
||||||
|
Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.allPushNotificationsMuted
|
||||||
|
? null
|
||||||
|
: (_) => controller.togglePushRule(
|
||||||
|
category.kind,
|
||||||
|
rule,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(color: theme.dividerColor),
|
||||||
|
],
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
L10n.of(context).devices,
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.secondary,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
FutureBuilder<List<Pusher>?>(
|
||||||
FutureBuilder<List<Pusher>?>(
|
future: controller.pusherFuture ??=
|
||||||
future: controller.pusherFuture ??=
|
Matrix.of(context).client.getPushers(),
|
||||||
Matrix.of(context).client.getPushers(),
|
builder: (context, snapshot) {
|
||||||
builder: (context, snapshot) {
|
if (snapshot.hasError) {
|
||||||
if (snapshot.hasError) {
|
Center(
|
||||||
Center(
|
child: Text(
|
||||||
child: Text(
|
snapshot.error!.toLocalizedString(context),
|
||||||
snapshot.error!.toLocalizedString(context),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
|
const Center(
|
||||||
|
child: CircularProgressIndicator.adaptive(
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final pushers = snapshot.data ?? [];
|
||||||
|
if (pushers.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 16.0),
|
||||||
|
child: Text(L10n.of(context).noOtherDevicesFound),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
),
|
||||||
const Center(
|
],
|
||||||
child: CircularProgressIndicator.adaptive(
|
),
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final pushers = snapshot.data ?? [];
|
|
||||||
if (pushers.isEmpty) {
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
|
||||||
child: Text(L10n.of(context).noOtherDevicesFound),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
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]),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue