Add Device Settings page

This commit is contained in:
Christian Pauly 2020-02-19 16:23:13 +01:00
commit fff216c46c
11 changed files with 310 additions and 10 deletions

View file

@ -60,16 +60,30 @@ class MatrixState extends State<Matrix> {
BuildContext _loadingDialogContext;
Future<dynamic> tryRequestWithLoadingDialog(Future<dynamic> request) async {
Future<dynamic> tryRequestWithLoadingDialog(Future<dynamic> request,
{Function(MatrixException) onAdditionalAuth}) async {
showLoadingDialog(context);
final dynamic = await tryRequestWithErrorToast(request);
final dynamic = await tryRequestWithErrorToast(request,
onAdditionalAuth: onAdditionalAuth);
hideLoadingDialog();
return dynamic;
}
Future<dynamic> tryRequestWithErrorToast(Future<dynamic> request) async {
Future<dynamic> tryRequestWithErrorToast(Future<dynamic> request,
{Function(MatrixException) onAdditionalAuth}) async {
try {
return await request;
} on MatrixException catch (exception) {
if (exception.requireAdditionalAuthentication &&
onAdditionalAuth != null) {
return await tryRequestWithErrorToast(onAdditionalAuth(exception));
} else {
Toast.show(
exception.errorMessage,
context,
duration: Toast.LENGTH_LONG,
);
}
} catch (exception) {
Toast.show(
exception.toString(),
@ -302,6 +316,17 @@ class MatrixState extends State<Matrix> {
}
}
Map<String, dynamic> getAuthByPassword(String password, String session) => {
"type": "m.login.password",
"identifier": {
"type": "m.id.user",
"user": client.userID,
},
"user": client.userID,
"password": password,
"session": session,
};
@override
void initState() {
if (widget.client == null) {