Fix login and toasts
This commit is contained in:
parent
8cde337a58
commit
ab45d0960f
12 changed files with 165 additions and 239 deletions
|
|
@ -17,6 +17,7 @@ import 'package:fluffychat/utils/room_extension.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
|
|
@ -176,13 +177,7 @@ class _ChatState extends State<_Chat> {
|
|||
|
||||
void sendFileAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).notSupportedInWeb,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).notSupportedInWeb);
|
||||
return;
|
||||
}
|
||||
File file = await FilePicker.getFile();
|
||||
|
|
@ -196,13 +191,7 @@ class _ChatState extends State<_Chat> {
|
|||
|
||||
void sendImageAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).notSupportedInWeb,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).notSupportedInWeb);
|
||||
return;
|
||||
}
|
||||
File file = await ImagePicker.pickImage(
|
||||
|
|
@ -220,13 +209,7 @@ class _ChatState extends State<_Chat> {
|
|||
|
||||
void openCameraAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).notSupportedInWeb,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).notSupportedInWeb);
|
||||
return;
|
||||
}
|
||||
File file = await ImagePicker.pickImage(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import 'package:fluffychat/views/invitation_selection.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:link_text/link_text.dart';
|
||||
|
||||
|
|
@ -43,13 +44,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
widget.room.setName(displayname),
|
||||
);
|
||||
if (success != false) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).displaynameHasBeenChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).displaynameHasBeenChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,13 +105,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
widget.room.setDescription(displayname),
|
||||
);
|
||||
if (success != false) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).groupDescriptionHasBeenChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).groupDescriptionHasBeenChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,13 +126,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
),
|
||||
);
|
||||
if (success != false) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).avatarHasBeenChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).avatarHasBeenChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,13 +184,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
Clipboard.setData(
|
||||
ClipboardData(text: widget.room.canonicalAlias),
|
||||
);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).copiedToClipboard,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).copiedToClipboard);
|
||||
},
|
||||
),
|
||||
ChatSettingsPopupMenu(widget.room, false)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:fluffychat/components/avatar.dart';
|
|||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
|
||||
import 'chat_list.dart';
|
||||
|
||||
|
|
@ -56,13 +57,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
|
|||
widget.room.invite(id),
|
||||
);
|
||||
if (success != false) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).contactHasBeenInvitedToTheGroup,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).contactHasBeenInvitedToTheGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,82 +104,86 @@ class _LoginState extends State<Login> {
|
|||
labelText: serverError == null ? "Homeserver" : serverError),
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: max((MediaQuery.of(context).size.width - 600) / 2, 0)),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 150,
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.vpn_key,
|
||||
size: 60,
|
||||
body: Builder(builder: (context) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
max((MediaQuery.of(context).size.width - 600) / 2, 0)),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 150,
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.vpn_key,
|
||||
size: 60,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
child: Icon(Icons.account_box,
|
||||
color: Theme.of(context).primaryColor),
|
||||
),
|
||||
title: TextField(
|
||||
readOnly: loading,
|
||||
autocorrect: false,
|
||||
controller: usernameController,
|
||||
decoration: InputDecoration(
|
||||
hintText:
|
||||
"@${I18n.of(context).username.toLowerCase()}:domain",
|
||||
errorText: usernameError,
|
||||
labelText: I18n.of(context).username),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).brightness == Brightness.dark
|
||||
? Color(0xff121212)
|
||||
: Colors.white,
|
||||
child: Icon(Icons.lock, color: Theme.of(context).primaryColor),
|
||||
),
|
||||
title: TextField(
|
||||
readOnly: loading,
|
||||
autocorrect: false,
|
||||
controller: passwordController,
|
||||
obscureText: !showPassword,
|
||||
onSubmitted: (t) => login(context),
|
||||
decoration: InputDecoration(
|
||||
hintText: "****",
|
||||
errorText: passwordError,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
showPassword ? Icons.visibility_off : Icons.visibility),
|
||||
onPressed: () =>
|
||||
setState(() => showPassword = !showPassword),
|
||||
),
|
||||
labelText: I18n.of(context).password),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
height: 50,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: RaisedButton(
|
||||
elevation: 7,
|
||||
color: Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
child: Icon(Icons.account_box,
|
||||
color: Theme.of(context).primaryColor),
|
||||
),
|
||||
child: loading
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
I18n.of(context).login.toUpperCase(),
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
title: TextField(
|
||||
readOnly: loading,
|
||||
autocorrect: false,
|
||||
controller: usernameController,
|
||||
decoration: InputDecoration(
|
||||
hintText:
|
||||
"@${I18n.of(context).username.toLowerCase()}:domain",
|
||||
errorText: usernameError,
|
||||
labelText: I18n.of(context).username),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).brightness == Brightness.dark
|
||||
? Color(0xff121212)
|
||||
: Colors.white,
|
||||
child: Icon(Icons.lock, color: Theme.of(context).primaryColor),
|
||||
),
|
||||
title: TextField(
|
||||
readOnly: loading,
|
||||
autocorrect: false,
|
||||
controller: passwordController,
|
||||
obscureText: !showPassword,
|
||||
onSubmitted: (t) => login(context),
|
||||
decoration: InputDecoration(
|
||||
hintText: "****",
|
||||
errorText: passwordError,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(showPassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility),
|
||||
onPressed: () =>
|
||||
setState(() => showPassword = !showPassword),
|
||||
),
|
||||
onPressed: () => loading ? null : login(context),
|
||||
labelText: I18n.of(context).password),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
height: 50,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: RaisedButton(
|
||||
elevation: 7,
|
||||
color: Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: loading
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
I18n.of(context).login.toUpperCase(),
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
onPressed: () => loading ? null : login(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/i18n/i18n.dart';
|
|||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/auth_web_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
|
||||
import 'chat_list.dart';
|
||||
|
||||
|
|
@ -95,13 +96,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
try {
|
||||
await matrix.client.setDisplayname(widget.displayname);
|
||||
} catch (exception) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).couldNotSetDisplayname,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).couldNotSetDisplayname);
|
||||
}
|
||||
if (widget.avatar != null) {
|
||||
try {
|
||||
|
|
@ -112,13 +107,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
),
|
||||
);
|
||||
} catch (exception) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).couldNotSetAvatar,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).couldNotSetAvatar);
|
||||
}
|
||||
}
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue