Compare commits

..

1 Commits

Author SHA1 Message Date
c2b66d29c3 add sharing option. (#131) 2023-02-04 18:46:04 -08:00
2 changed files with 40 additions and 6 deletions

View File

@ -119,11 +119,45 @@ extension StateExtension on State {
} }
} }
void onShareTapped(Item item, Rect? rect) { Future<void> onShareTapped(Item item, Rect? rect) async {
Share.share( late final String? linkToShare;
'https://news.ycombinator.com/item?id=${item.id}', if (item.url.isNotEmpty) {
sharePositionOrigin: rect, linkToShare = await showModalBottomSheet<String>(
); context: context,
builder: (BuildContext context) {
return Container(
height: 140,
color: Theme.of(context).canvasColor,
child: Material(
child: Column(
children: <Widget>[
ListTile(
onTap: () => Navigator.pop(context, item.url),
title: const Text('Link to article'),
),
ListTile(
onTap: () => Navigator.pop(
context,
'https://news.ycombinator.com/item?id=${item.id}',
),
title: const Text('Link to HN'),
),
],
),
),
);
},
);
} else {
linkToShare = 'https://news.ycombinator.com/item?id=${item.id}';
}
if (linkToShare != null) {
await Share.share(
linkToShare,
sharePositionOrigin: rect,
);
}
} }
void onFlagTapped(Item item) { void onFlagTapped(Item item) {

View File

@ -1,6 +1,6 @@
name: hacki name: hacki
description: A Hacker News reader. description: A Hacker News reader.
version: 1.0.6+84 version: 1.0.7+85
publish_to: none publish_to: none
environment: environment: