chore: Improve ignore list UX
This commit is contained in:
parent
24475fbb86
commit
21a1ceb19e
2 changed files with 62 additions and 74 deletions
|
|
@ -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,7 +23,19 @@ class SettingsIgnoreListView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
body: MaxWidthBody(
|
body: MaxWidthBody(
|
||||||
withScrolling: false,
|
withScrolling: false,
|
||||||
child: Column(
|
child: StreamBuilder(
|
||||||
|
stream: client.onSync.stream.where(
|
||||||
|
(syncUpdate) =>
|
||||||
|
syncUpdate.accountData?.any(
|
||||||
|
(accountData) => accountData.type == 'm.ignored_user_list',
|
||||||
|
) ??
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (client.prevBatch == null) {
|
||||||
|
return const Center(child: CircularProgressIndicator.adaptive());
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
|
|
@ -63,31 +72,10 @@ class SettingsIgnoreListView extends StatelessWidget {
|
||||||
color: theme.dividerColor,
|
color: theme.dividerColor,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: StreamBuilder<Object>(
|
child: ListView.builder(
|
||||||
stream: client.onSync.stream.where(
|
|
||||||
(syncUpdate) =>
|
|
||||||
syncUpdate.accountData?.any(
|
|
||||||
(accountData) =>
|
|
||||||
accountData.type == 'm.ignored_user_list',
|
|
||||||
) ??
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return 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]),
|
|
||||||
builder: (c, s) => ListTile(
|
|
||||||
leading: Avatar(
|
|
||||||
mxContent: s.data?.avatarUrl ?? Uri.parse(''),
|
|
||||||
name: s.data?.displayName ?? client.ignoredUsers[i],
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
s.data?.displayName ?? client.ignoredUsers[i],
|
|
||||||
),
|
|
||||||
subtitle:
|
|
||||||
Text(s.data?.userId ?? client.ignoredUsers[i]),
|
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
tooltip: L10n.of(context).delete,
|
tooltip: L10n.of(context).delete,
|
||||||
icon: const Icon(Icons.delete_outlined),
|
icon: const Icon(Icons.delete_outlined),
|
||||||
|
|
@ -99,13 +87,12 @@ class SettingsIgnoreListView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue