parent
e24ff355fb
commit
bf6608d576
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:feet/notifications/tasks.dart';
|
import 'package:feet/notifications/tasks.dart';
|
||||||
|
import 'package:feet/util.dart';
|
||||||
import 'package:feet/widgets/centered_page_hint.dart';
|
import 'package:feet/widgets/centered_page_hint.dart';
|
||||||
import 'package:feet/widgets/filter_menu.dart';
|
import 'package:feet/widgets/filter_menu.dart';
|
||||||
import 'package:feet/widgets/homepage_post.dart';
|
import 'package:feet/widgets/homepage_post.dart';
|
||||||
|
@ -285,6 +286,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: "feedback",
|
||||||
|
child: const Text("Feedback"),
|
||||||
|
onTap: () async {
|
||||||
|
await openUrl(context, "https://git.amogus.cloud/Lea/feet/issues");
|
||||||
|
},
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import 'package:feet/api/api.dart';
|
import 'package:feet/api/api.dart';
|
||||||
import 'package:feet/pages/image_view.dart';
|
import 'package:feet/pages/image_view.dart';
|
||||||
|
import 'package:feet/util.dart';
|
||||||
import 'package:feet/widgets/homepage_post.dart';
|
import 'package:feet/widgets/homepage_post.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_html/flutter_html.dart';
|
import 'package:flutter_html/flutter_html.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class ArticlePage extends StatefulWidget {
|
class ArticlePage extends StatefulWidget {
|
||||||
final Item article;
|
final Item article;
|
||||||
|
@ -23,11 +22,9 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||||
title: Text(widget.article.title),
|
title: Text(widget.article.title),
|
||||||
content: Text(
|
content: Text(
|
||||||
// The dart formatter insists of writing this like this
|
// The dart formatter insists of writing this like this
|
||||||
'By ${widget.article.author.isEmpty ? '(Unknown author)' : widget.article.author}\nPublished on ${formatDate(widget.article.createdOnTime)}${debugInfo
|
'By ${widget.article.author.isEmpty ? '(Unknown author)' : widget.article.author}\nPublished on ${formatDate(widget.article.createdOnTime)}${debugInfo ? '\nID: ${widget.article.id}\n'
|
||||||
? '\nID: ${widget.article.id}\n'
|
|
||||||
'Is read: ${widget.article.isRead ? 'Yes' : 'No'}\n'
|
'Is read: ${widget.article.isRead ? 'Yes' : 'No'}\n'
|
||||||
'Is saved: ${widget.article.isSaved ? 'Yes' : 'No'}'
|
'Is saved: ${widget.article.isSaved ? 'Yes' : 'No'}' : ''}',
|
||||||
: ''}',
|
|
||||||
),
|
),
|
||||||
actions: debugInfo
|
actions: debugInfo
|
||||||
? []
|
? []
|
||||||
|
@ -63,41 +60,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) => [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
try {
|
await openUrl(context, widget.article.url);
|
||||||
if (await canLaunchUrl(Uri.parse(widget.article.url))) {
|
|
||||||
await launchUrl(
|
|
||||||
Uri.parse(widget.article.url),
|
|
||||||
mode: LaunchMode.externalApplication,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw 'No application available to open URL';
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: const Text('Cannot open this URL'),
|
|
||||||
content: Text(e.toString()),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Clipboard.setData(
|
|
||||||
ClipboardData(
|
|
||||||
text: widget.article.url,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Copy URL'),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: const Text('Got it!'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
value: 'open_in_browser',
|
value: 'open_in_browser',
|
||||||
child: const Text('Open in browser'),
|
child: const Text('Open in browser'),
|
||||||
|
@ -113,7 +76,8 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||||
child: SelectionArea(
|
child: SelectionArea(
|
||||||
child: Html(
|
child: Html(
|
||||||
data: widget.article.html,
|
data: widget.article.html,
|
||||||
onImageTap: (url, ctx, attributes, element) => Navigator.of(context).push(
|
onImageTap: (url, ctx, attributes, element) =>
|
||||||
|
Navigator.of(context).push(
|
||||||
PageRouteBuilder(
|
PageRouteBuilder(
|
||||||
opaque: false,
|
opaque: false,
|
||||||
pageBuilder: (context, _, __) => ImageView(url: url!),
|
pageBuilder: (context, _, __) => ImageView(url: url!),
|
||||||
|
|
41
lib/util.dart
Normal file
41
lib/util.dart
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
Future<void> openUrl(BuildContext context, String url) async {
|
||||||
|
try {
|
||||||
|
if (await canLaunchUrl(Uri.parse(url))) {
|
||||||
|
await launchUrl(
|
||||||
|
Uri.parse(url),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw 'No application available to open URL';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Cannot open this URL'),
|
||||||
|
content: Text(e.toString()),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Clipboard.setData(
|
||||||
|
ClipboardData(
|
||||||
|
text: url,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Copy URL'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Got it!'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue