Implement image viewer
This commit is contained in:
parent
7d1358228e
commit
0276a81173
6 changed files with 112 additions and 40 deletions
|
|
@ -1,14 +1,15 @@
|
|||
import 'package:bubble/bubble.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/image_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
|
||||
class ImageBubble extends StatefulWidget {
|
||||
final Event event;
|
||||
final bool tapToView;
|
||||
|
||||
const ImageBubble(this.event, {Key key}) : super(key: key);
|
||||
const ImageBubble(this.event, {this.tapToView = true, Key key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_ImageBubbleState createState() => _ImageBubbleState();
|
||||
|
|
@ -50,16 +51,20 @@ class _ImageBubbleState extends State<ImageBubble> {
|
|||
}
|
||||
if (_file != null) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
final MatrixFile matrixFile =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.event.downloadAndDecryptAttachment(),
|
||||
onTap: () {
|
||||
if (!widget.tapToView) return;
|
||||
Navigator.of(context).push(
|
||||
AppRoute(
|
||||
ImageView(widget.event),
|
||||
),
|
||||
);
|
||||
matrixFile.open();
|
||||
},
|
||||
child: Image.memory(
|
||||
_file.bytes,
|
||||
fit: BoxFit.cover,
|
||||
child: Hero(
|
||||
tag: widget.event.eventId,
|
||||
child: Image.memory(
|
||||
_file.bytes,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||
import 'package:fluffychat/utils/event_extension.dart';
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
|
||||
class MessageDownloadContent extends StatelessWidget {
|
||||
final Event event;
|
||||
|
|
@ -20,21 +18,16 @@ class MessageDownloadContent extends StatelessWidget {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
L10n.of(context).downloadFile,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
final MatrixFile matrixFile =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
event.downloadAndDecryptAttachment(),
|
||||
);
|
||||
matrixFile.open();
|
||||
}),
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
L10n.of(context).downloadFile,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () => event.openFile(context),
|
||||
),
|
||||
Text(
|
||||
'- ' +
|
||||
(event.content.containsKey('filename')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue