chore: Improve ignore list UX

pull/2219/head
Christian Kußowski 2 months ago
parent 24475fbb86
commit 21a1ceb19e
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -47,6 +47,7 @@ class SettingsIgnoreListController extends State<SettingsIgnoreList> {
context: context, context: context,
future: () => Matrix.of(context).client.ignoreUser(userId), future: () => Matrix.of(context).client.ignoreUser(userId),
); );
setState(() {});
controller.clear(); controller.clear();
} }

@ -1,9 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart';
import 'package:fluffychat/widgets/layouts/max_width_body.dart'; import 'package:fluffychat/widgets/layouts/max_width_body.dart';
import '../../widgets/matrix.dart'; import '../../widgets/matrix.dart';
@ -26,84 +23,74 @@ class SettingsIgnoreListView extends StatelessWidget {
), ),
body: MaxWidthBody( body: MaxWidthBody(
withScrolling: false, withScrolling: false,
child: Column( child: StreamBuilder(
mainAxisSize: MainAxisSize.min, stream: client.onSync.stream.where(
children: [ (syncUpdate) =>
Padding( syncUpdate.accountData?.any(
padding: const EdgeInsets.all(16.0), (accountData) => accountData.type == 'm.ignored_user_list',
child: Column( ) ??
mainAxisSize: MainAxisSize.min, false,
children: [ ),
TextField( builder: (context, asyncSnapshot) {
controller: controller.controller, if (client.prevBatch == null) {
autocorrect: false, return const Center(child: CircularProgressIndicator.adaptive());
textInputAction: TextInputAction.done, }
onSubmitted: (_) => controller.ignoreUser(context), return Column(
decoration: InputDecoration( mainAxisSize: MainAxisSize.min,
errorText: controller.errorText, children: [
hintText: '@bad_guy:domain.abc', Padding(
floatingLabelBehavior: FloatingLabelBehavior.always, padding: const EdgeInsets.all(16.0),
labelText: L10n.of(context).blockUsername, child: Column(
suffixIcon: IconButton( mainAxisSize: MainAxisSize.min,
tooltip: L10n.of(context).block, children: [
icon: const Icon(Icons.add), TextField(
onPressed: () => controller.ignoreUser(context), controller: controller.controller,
autocorrect: false,
textInputAction: TextInputAction.done,
onSubmitted: (_) => controller.ignoreUser(context),
decoration: InputDecoration(
errorText: controller.errorText,
hintText: '@bad_guy:domain.abc',
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: L10n.of(context).blockUsername,
suffixIcon: IconButton(
tooltip: L10n.of(context).block,
icon: const Icon(Icons.add),
onPressed: () => controller.ignoreUser(context),
),
),
), ),
), const SizedBox(height: 16),
), Text(
const SizedBox(height: 16), L10n.of(context).blockListDescription,
Text( style: const TextStyle(color: Colors.orange),
L10n.of(context).blockListDescription, ),
style: const TextStyle(color: Colors.orange), ],
), ),
],
),
),
Divider(
color: theme.dividerColor,
),
Expanded(
child: StreamBuilder<Object>(
stream: client.onSync.stream.where(
(syncUpdate) =>
syncUpdate.accountData?.any(
(accountData) =>
accountData.type == 'm.ignored_user_list',
) ??
false,
), ),
builder: (context, snapshot) { Divider(
return ListView.builder( color: theme.dividerColor,
),
Expanded(
child: ListView.builder(
itemCount: client.ignoredUsers.length, itemCount: client.ignoredUsers.length,
itemBuilder: (c, i) => FutureBuilder<Profile>( itemBuilder: (c, i) => ListTile(
future: title: Text(client.ignoredUsers[i]),
client.getProfileFromUserId(client.ignoredUsers[i]), trailing: IconButton(
builder: (c, s) => ListTile( tooltip: L10n.of(context).delete,
leading: Avatar( icon: const Icon(Icons.delete_outlined),
mxContent: s.data?.avatarUrl ?? Uri.parse(''), onPressed: () => showFutureLoadingDialog(
name: s.data?.displayName ?? client.ignoredUsers[i], context: context,
), future: () =>
title: Text( client.unignoreUser(client.ignoredUsers[i]),
s.data?.displayName ?? client.ignoredUsers[i],
),
subtitle:
Text(s.data?.userId ?? client.ignoredUsers[i]),
trailing: IconButton(
tooltip: L10n.of(context).delete,
icon: const Icon(Icons.delete_outlined),
onPressed: () => showFutureLoadingDialog(
context: context,
future: () =>
client.unignoreUser(client.ignoredUsers[i]),
),
), ),
), ),
), ),
); ),
}, ),
), ],
), );
], },
), ),
), ),
); );

Loading…
Cancel
Save