Version 0.10.0
This commit is contained in:
parent
d6e1594a6f
commit
67eedc4a77
16 changed files with 313 additions and 126 deletions
|
|
@ -5,7 +5,6 @@ import 'package:fluffychat/i18n/i18n.dart';
|
|||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat_encryption_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
import 'matrix.dart';
|
||||
|
|
@ -22,8 +21,11 @@ class _EncryptionButtonState extends State<EncryptionButton> {
|
|||
|
||||
void _enableEncryptionAction() async {
|
||||
if (widget.room.encrypted) {
|
||||
Toast.show(I18n.of(context).warningEncryptionInBeta, context,
|
||||
duration: 5);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(I18n.of(context).warningEncryptionInBeta),
|
||||
),
|
||||
);
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
|
|
@ -33,7 +35,13 @@ class _EncryptionButtonState extends State<EncryptionButton> {
|
|||
return;
|
||||
}
|
||||
if (!widget.room.client.encryptionEnabled) {
|
||||
Toast.show(I18n.of(context).needPantalaimonWarning, context, duration: 8);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).needPantalaimonWarning,
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (await SimpleDialogs(context).askConfirmation(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import 'package:fluffychat/views/chat.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
import '../../i18n/i18n.dart';
|
||||
import '../../utils/app_route.dart';
|
||||
|
|
@ -32,8 +31,13 @@ class ChatListItem extends StatelessWidget {
|
|||
}
|
||||
|
||||
if (room.membership == Membership.ban) {
|
||||
Toast.show(I18n.of(context).youHaveBeenBannedFromThisChat, context,
|
||||
duration: 5);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).youHaveBeenBannedFromThisChat,
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -139,19 +143,26 @@ class ChatListItem extends StatelessWidget {
|
|||
leading: Avatar(room.avatar, room.displayname),
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
room.getLocalizedDisplayname(context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
room.pushRuleState == PushRuleState.notify
|
||||
? Container()
|
||||
: Icon(
|
||||
Icons.notifications_off,
|
||||
color: Colors.grey[400],
|
||||
size: 16,
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
room.getLocalizedDisplayname(context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
room.pushRuleState == PushRuleState.notify
|
||||
? Container()
|
||||
: Icon(
|
||||
Icons.notifications_off,
|
||||
color: Colors.grey[400],
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Text(
|
||||
room.timeCreated.localizedTimeShort(context),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
import '../i18n/i18n.dart';
|
||||
import '../utils/app_route.dart';
|
||||
|
|
@ -80,17 +79,21 @@ class MatrixState extends State<Matrix> {
|
|||
onAdditionalAuth != null) {
|
||||
return await tryRequestWithErrorToast(onAdditionalAuth(exception));
|
||||
} else {
|
||||
Toast.show(
|
||||
exception.errorMessage,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
exception.errorMessage,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (exception) {
|
||||
Toast.show(
|
||||
exception.toString(),
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
exception.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -141,10 +144,12 @@ class MatrixState extends State<Matrix> {
|
|||
|
||||
final String token = await _firebaseMessaging.getToken();
|
||||
if (token?.isEmpty ?? true) {
|
||||
return Toast.show(
|
||||
I18n.of(context).noGoogleServicesWarning,
|
||||
context,
|
||||
duration: 10,
|
||||
return Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).noGoogleServicesWarning,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
await client.setPushers(
|
||||
|
|
@ -175,7 +180,13 @@ class MatrixState extends State<Matrix> {
|
|||
),
|
||||
(r) => r.isFirst);
|
||||
} catch (_) {
|
||||
Toast.show("Failed to open chat...", context);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"Failed to open chat...",
|
||||
),
|
||||
),
|
||||
);
|
||||
debugPrint(_);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:bubble/bubble.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
|
|
@ -8,7 +10,9 @@ import 'package:fluffychat/views/image_viewer.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:link_text/link_text.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:open_file/open_file.dart';
|
||||
|
||||
import 'matrix.dart';
|
||||
|
||||
|
|
@ -20,11 +24,21 @@ class MessageContent extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var messageType = event.messageType;
|
||||
if (event.room.encrypted &&
|
||||
[
|
||||
MessageTypes.Image,
|
||||
MessageTypes.Sticker,
|
||||
MessageTypes.Audio,
|
||||
MessageTypes.Video,
|
||||
].contains(messageType)) {
|
||||
messageType = MessageTypes.File;
|
||||
}
|
||||
switch (event.type) {
|
||||
case EventTypes.Message:
|
||||
case EventTypes.Encrypted:
|
||||
case EventTypes.Sticker:
|
||||
switch (event.messageType) {
|
||||
switch (messageType) {
|
||||
case MessageTypes.Image:
|
||||
case MessageTypes.Sticker:
|
||||
final int size = 400;
|
||||
|
|
@ -72,19 +86,41 @@ class MessageContent extends StatelessWidget {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
I18n.of(context).downloadFile,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () => launch(
|
||||
MxContent(event.content["url"])
|
||||
.getDownloadLink(event.room.client),
|
||||
),
|
||||
),
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
I18n.of(context).downloadFile,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (kIsWeb) {
|
||||
if (event.room.encrypted) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text(I18n.of(context).notSupportedInWeb),
|
||||
),
|
||||
);
|
||||
}
|
||||
await launch(
|
||||
MxContent(event.content["url"])
|
||||
.getDownloadLink(event.room.client),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final matrixFile = await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
event.downloadAndDecryptAttachment(),
|
||||
);
|
||||
Directory tempDir = await getTemporaryDirectory();
|
||||
final file = File(tempDir.path +
|
||||
"/" +
|
||||
matrixFile.path.split("/").last);
|
||||
file.writeAsBytesSync(matrixFile.bytes);
|
||||
await OpenFile.open(file.path);
|
||||
}),
|
||||
Text(
|
||||
"- " +
|
||||
(event.content.containsKey("filename")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ final ThemeData lightTheme = ThemeData(
|
|||
backgroundColor: Colors.white,
|
||||
secondaryHeaderColor: Color(0xFFECECF2),
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
behavior: kIsWeb ? SnackBarBehavior.floating : SnackBarBehavior.fixed,
|
||||
),
|
||||
dialogTheme: DialogTheme(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
|
|
@ -47,6 +50,9 @@ final ThemeData darkTheme = ThemeData.dark().copyWith(
|
|||
scaffoldBackgroundColor: Color(0xff121212),
|
||||
accentColor: Color(0xFFF5B4D2),
|
||||
secondaryHeaderColor: Color(0xff1D1D1D),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
behavior: kIsWeb ? SnackBarBehavior.floating : SnackBarBehavior.fixed,
|
||||
),
|
||||
dialogTheme: DialogTheme(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
|
|
@ -78,6 +84,9 @@ final ThemeData amoledTheme = ThemeData.dark().copyWith(
|
|||
scaffoldBackgroundColor: Colors.black,
|
||||
accentColor: Color(0xFFF5B4D2),
|
||||
secondaryHeaderColor: Color(0xff1D1D1D),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
behavior: kIsWeb ? SnackBarBehavior.floating : SnackBarBehavior.fixed,
|
||||
),
|
||||
dialogTheme: DialogTheme(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue