Remove class acting as a namespace

This commit is contained in:
shilangyu 2021-03-20 15:50:49 +01:00
parent 5db7a8e509
commit 048e347e43
8 changed files with 29 additions and 32 deletions

View File

@ -108,7 +108,7 @@ class CommunityPage extends HookWidget {
} }
// FUNCTIONS // FUNCTIONS
void _share() => Share.share(community.community.actorId, context: context); void _share() => share(community.community.actorId, context: context);
void _openMoreMenu() { void _openMoreMenu() {
showBottomModal( showBottomModal(

View File

@ -84,7 +84,7 @@ class FullPostPage extends HookWidget {
} }
} }
sharePost() => Share.share(post.post.apId, context: context); sharePost() => share(post.post.apId, context: context);
comment() async { comment() async {
final newComment = await showCupertinoModalPopup<CommentView>( final newComment = await showCupertinoModalPopup<CommentView>(

View File

@ -67,7 +67,7 @@ class InstancePage extends HookWidget {
final site = siteSnap.data; final site = siteSnap.data;
void _share() => Share.share('https://$instanceHost', context: context); void _share() => share('https://$instanceHost', context: context);
void _openMoreMenu(BuildContext c) { void _openMoreMenu(BuildContext c) {
showBottomModal( showBottomModal(

View File

@ -35,7 +35,7 @@ class MediaViewPage extends HookWidget {
// TODO: hide navbar and topbar on android without a content jump // TODO: hide navbar and topbar on android without a content jump
share() { sharePhoto() {
showBottomModal( showBottomModal(
context: context, context: context,
builder: (context) => Column( builder: (context) => Column(
@ -45,7 +45,7 @@ class MediaViewPage extends HookWidget {
title: const Text('Share link'), title: const Text('Share link'),
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Share.share(url, context: context); share(url, context: context);
}, },
), ),
ListTile( ListTile(
@ -77,7 +77,7 @@ class MediaViewPage extends HookWidget {
IconButton( IconButton(
icon: const Icon(Icons.share), icon: const Icon(Icons.share),
tooltip: 'share', tooltip: 'share',
onPressed: share, onPressed: sharePhoto,
), ),
IconButton( IconButton(
icon: const Icon(Icons.file_download), icon: const Icon(Icons.file_download),

View File

@ -49,7 +49,7 @@ class UserPage extends HookWidget {
SendMessageButton(userDetailsSnap.data.userView.user), SendMessageButton(userDetailsSnap.data.userView.user),
IconButton( IconButton(
icon: const Icon(Icons.share), icon: const Icon(Icons.share),
onPressed: () => Share.share( onPressed: () => share(
userDetailsSnap.data.userView.user.actorId, userDetailsSnap.data.userView.user.actorId,
context: context, context: context,
), ),

View File

@ -1,20 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:share/share.dart' as flutter_share; import 'package:share/share.dart';
/// A `package:share` wrapper that fallbacks to copying contents to the clipboard /// A `package:share` wrapper that fallbacks to copying contents to the clipboard
/// on platforms that do not support native sharing /// on platforms that do not support native sharing
abstract class Share { Future<void> share(
static Future<void> share(
String text, { String text, {
String subject, String subject,
Rect sharePositionOrigin, Rect sharePositionOrigin,
@required BuildContext context, @required BuildContext context,
}) async { }) async {
assert(context != null); assert(context != null);
try { try {
return await flutter_share.Share.share( return await Share.share(
text, text,
subject: subject, subject: subject,
sharePositionOrigin: sharePositionOrigin, sharePositionOrigin: sharePositionOrigin,
@ -25,5 +24,4 @@ abstract class Share {
const SnackBar(content: Text('Copied data to clipboard!')), const SnackBar(content: Text('Copied data to clipboard!')),
); );
} }
}
} }

View File

@ -149,12 +149,12 @@ class CommentWidget extends HookWidget {
ListTile( ListTile(
leading: const Icon(Icons.share), leading: const Icon(Icons.share),
title: const Text('Share url'), title: const Text('Share url'),
onTap: () => Share.share(com.comment.link, context: context), onTap: () => share(com.comment.link, context: context),
), ),
ListTile( ListTile(
leading: const Icon(Icons.share), leading: const Icon(Icons.share),
title: const Text('Share text'), title: const Text('Share text'),
onTap: () => Share.share(com.comment.content, context: context), onTap: () => share(com.comment.content, context: context),
), ),
ListTile( ListTile(
leading: leading:

View File

@ -384,8 +384,7 @@ class PostWidget extends HookWidget {
if (!fullPost) if (!fullPost)
IconButton( IconButton(
icon: const Icon(Icons.share), icon: const Icon(Icons.share),
onPressed: () => onPressed: () => share(post.post.apId, context: context),
Share.share(post.post.apId, context: context),
), ),
if (!fullPost) SavePostButton(post), if (!fullPost) SavePostButton(post),
_Voting(post), _Voting(post),