2021-04-24 07:43:47 +02:00
|
|
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2021-05-22 09:08:23 +02:00
|
|
|
import 'views/settings_ignore_list_view.dart';
|
2021-05-22 08:53:52 +02:00
|
|
|
import '../widgets/matrix.dart';
|
2021-04-24 07:43:47 +02:00
|
|
|
|
|
|
|
class SettingsIgnoreList extends StatefulWidget {
|
|
|
|
final String initialUserId;
|
|
|
|
|
|
|
|
SettingsIgnoreList({Key key, this.initialUserId}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
SettingsIgnoreListController createState() => SettingsIgnoreListController();
|
|
|
|
}
|
|
|
|
|
|
|
|
class SettingsIgnoreListController extends State<SettingsIgnoreList> {
|
|
|
|
final TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
if (widget.initialUserId != null) {
|
|
|
|
controller.text = widget.initialUserId.replaceAll('@', '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ignoreUser(BuildContext context) {
|
|
|
|
if (controller.text.isEmpty) return;
|
|
|
|
final userId = '@${controller.text}';
|
|
|
|
|
|
|
|
showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: () => Matrix.of(context).client.ignoreUser(userId),
|
|
|
|
);
|
|
|
|
controller.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2021-05-22 09:13:47 +02:00
|
|
|
Widget build(BuildContext context) => SettingsIgnoreListView(this);
|
2021-04-24 07:43:47 +02:00
|
|
|
}
|