Add Device Settings page
This commit is contained in:
parent
9a52e93862
commit
fff216c46c
11 changed files with 310 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ class SimpleDialogs {
|
|||
String labelText,
|
||||
String prefixText,
|
||||
String suffixText,
|
||||
bool password = false,
|
||||
bool multiLine = false,
|
||||
}) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
|
@ -31,6 +32,7 @@ class SimpleDialogs {
|
|||
},
|
||||
minLines: multiLine ? 3 : 1,
|
||||
maxLines: multiLine ? 3 : 1,
|
||||
obscureText: password,
|
||||
textInputAction: multiLine ? TextInputAction.newline : null,
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue