Enhance settings
This commit is contained in:
parent
10fc137435
commit
2eb8828841
|
@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:toast/toast.dart';
|
import 'package:toast/toast.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class SettingsView extends StatelessWidget {
|
class SettingsView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
|
@ -67,8 +68,7 @@ class _SettingsState extends State<Settings> {
|
||||||
maxHeight: 1600);
|
maxHeight: 1600);
|
||||||
if (tempFile == null) return;
|
if (tempFile == null) return;
|
||||||
final MatrixState matrix = Matrix.of(context);
|
final MatrixState matrix = Matrix.of(context);
|
||||||
final Map<String, dynamic> success =
|
final success = await matrix.tryRequestWithLoadingDialog(
|
||||||
await matrix.tryRequestWithLoadingDialog(
|
|
||||||
matrix.client.setAvatar(
|
matrix.client.setAvatar(
|
||||||
MatrixFile(
|
MatrixFile(
|
||||||
bytes: await tempFile.readAsBytes(),
|
bytes: await tempFile.readAsBytes(),
|
||||||
|
@ -76,7 +76,8 @@ class _SettingsState extends State<Settings> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (success != null && success.isEmpty) {
|
print(success);
|
||||||
|
if (success != false) {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
"Avatar has been changed",
|
"Avatar has been changed",
|
||||||
context,
|
context,
|
||||||
|
@ -105,15 +106,24 @@ class _SettingsState extends State<Settings> {
|
||||||
defaultIcon: Icons.account_circle,
|
defaultIcon: Icons.account_circle,
|
||||||
loading: profile == null,
|
loading: profile == null,
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
"Profile",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
kIsWeb
|
kIsWeb
|
||||||
? Container()
|
? Container()
|
||||||
: ListTile(
|
: ListTile(
|
||||||
title: Text("Upload avatar"),
|
title: Text("Upload avatar"),
|
||||||
trailing: Icon(Icons.file_upload),
|
leading: Icon(Icons.camera),
|
||||||
onTap: () => setAvatarAction(context),
|
onTap: () => setAvatarAction(context),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
trailing: Icon(Icons.edit),
|
leading: Icon(Icons.edit),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
readOnly: profile == null,
|
readOnly: profile == null,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
|
@ -127,7 +137,40 @@ class _SettingsState extends State<Settings> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
trailing: Icon(Icons.exit_to_app),
|
title: Text(
|
||||||
|
"About",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.help),
|
||||||
|
title: Text("Help"),
|
||||||
|
onTap: () => launch(
|
||||||
|
"https://gitlab.com/ChristianPauly/fluffychat-flutter/issues")),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.link),
|
||||||
|
title: Text("License"),
|
||||||
|
onTap: () => launch(
|
||||||
|
"https://gitlab.com/ChristianPauly/fluffychat-flutter/raw/master/LICENSE")),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.code),
|
||||||
|
title: Text("Source code"),
|
||||||
|
onTap: () => launch(
|
||||||
|
"https://gitlab.com/ChristianPauly/fluffychat-flutter")),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
"Logout",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.exit_to_app),
|
||||||
title: Text("Logout"),
|
title: Text("Logout"),
|
||||||
onTap: () => logoutAction(context),
|
onTap: () => logoutAction(context),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue