add basic functionality to share button

add bottom sheet that opens when clicking
the share button. 2 options are present.
share url and share file
share url works
share file not yet
This commit is contained in:
krawieck 2020-09-11 11:24:06 +02:00
parent a8607fd661
commit c7baa125c4
1 changed files with 33 additions and 1 deletions

View File

@ -1,9 +1,12 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
import 'bottom_modal.dart';
class MediaView extends HookWidget { class MediaView extends HookWidget {
final String url; final String url;
@ -27,6 +30,35 @@ class MediaView extends HookWidget {
SystemChrome.setEnabledSystemUIOverlays([]); SystemChrome.setEnabledSystemUIOverlays([]);
} }
share() {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (context) => BottomModal(
child: Column(
children: [
ListTile(
leading: Icon(Icons.link),
title: Text('Share link'),
onTap: () {
Navigator.of(context).pop();
Share.text('Share image url', url, 'text/plain');
},
),
ListTile(
leading: Icon(Icons.image),
title: Text('Share file'),
onTap: () {
Navigator.of(context).pop();
// TODO: share file
},
),
],
),
),
);
}
return Scaffold( return Scaffold(
appBar: showButtons.value appBar: showButtons.value
? AppBar( ? AppBar(
@ -37,7 +69,7 @@ class MediaView extends HookWidget {
IconButton( IconButton(
icon: Icon(Icons.share), icon: Icon(Icons.share),
tooltip: 'share', tooltip: 'share',
onPressed: () {}, onPressed: share,
), ),
IconButton( IconButton(
icon: Icon(Icons.file_download), icon: Icon(Icons.file_download),