2020-09-19 15:29:12 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
2021-05-22 08:53:52 +02:00
|
|
|
import '../../widgets/matrix.dart';
|
2021-11-09 21:32:16 +01:00
|
|
|
import 'settings_ignore_list.dart';
|
2020-09-19 15:29:12 +02:00
|
|
|
|
2021-05-22 09:13:47 +02:00
|
|
|
class SettingsIgnoreListView extends StatelessWidget {
|
2021-04-24 07:43:47 +02:00
|
|
|
final SettingsIgnoreListController controller;
|
2021-02-02 09:00:06 +01:00
|
|
|
|
2022-01-29 12:35:03 +01:00
|
|
|
const SettingsIgnoreListView(this.controller, {Key? key}) : super(key: key);
|
2020-09-19 15:29:12 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final client = Matrix.of(context).client;
|
|
|
|
return Scaffold(
|
2021-01-16 14:24:52 +01:00
|
|
|
appBar: AppBar(
|
2021-10-14 18:09:30 +02:00
|
|
|
leading: const BackButton(),
|
2022-01-29 12:35:03 +01:00
|
|
|
title: Text(L10n.of(context)!.ignoredUsers),
|
2021-01-16 14:24:52 +01:00
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
body: MaxWidthBody(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
TextField(
|
2021-04-24 07:43:47 +02:00
|
|
|
controller: controller.controller,
|
2021-04-09 18:26:44 +02:00
|
|
|
autocorrect: false,
|
|
|
|
textInputAction: TextInputAction.done,
|
2021-04-24 07:43:47 +02:00
|
|
|
onSubmitted: (_) => controller.ignoreUser(context),
|
2021-04-09 18:26:44 +02:00
|
|
|
decoration: InputDecoration(
|
2021-10-14 18:09:30 +02:00
|
|
|
border: const OutlineInputBorder(),
|
2021-04-09 18:26:44 +02:00
|
|
|
hintText: 'bad_guy:domain.abc',
|
|
|
|
prefixText: '@',
|
2022-01-29 12:35:03 +01:00
|
|
|
labelText: L10n.of(context)!.ignoreUsername,
|
2021-04-09 18:26:44 +02:00
|
|
|
suffixIcon: IconButton(
|
2022-01-29 12:35:03 +01:00
|
|
|
tooltip: L10n.of(context)!.ignore,
|
2021-10-14 18:09:30 +02:00
|
|
|
icon: const Icon(Icons.done_outlined),
|
2021-04-24 07:43:47 +02:00
|
|
|
onPressed: () => controller.ignoreUser(context),
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
2020-09-19 15:29:12 +02:00
|
|
|
),
|
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
const SizedBox(height: 16),
|
2021-04-09 18:26:44 +02:00
|
|
|
Text(
|
2022-01-29 12:35:03 +01:00
|
|
|
L10n.of(context)!.ignoreListDescription,
|
2021-10-14 18:09:30 +02:00
|
|
|
style: const TextStyle(color: Colors.orange),
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-09-19 15:29:12 +02:00
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
const Divider(height: 1),
|
2021-04-09 18:26:44 +02:00
|
|
|
Expanded(
|
|
|
|
child: StreamBuilder<Object>(
|
2023-03-02 10:57:52 +01:00
|
|
|
stream: client.onAccountData.stream
|
|
|
|
.where((a) => a.type == 'm.ignored_user_list'),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: client.ignoredUsers.length,
|
|
|
|
itemBuilder: (c, i) => FutureBuilder<Profile>(
|
|
|
|
future:
|
|
|
|
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],
|
|
|
|
),
|
|
|
|
trailing: IconButton(
|
|
|
|
tooltip: L10n.of(context)!.delete,
|
|
|
|
icon: const Icon(Icons.delete_forever_outlined),
|
|
|
|
onPressed: () => showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: () =>
|
|
|
|
client.unignoreUser(client.ignoredUsers[i]),
|
2020-09-19 15:29:12 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-03-02 10:57:52 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-09-19 15:29:12 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|