reason

增加了分享

......@@ -63,6 +63,17 @@
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.com.shekarmudaliyar.social_share"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
</application>
<queries>
......
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path
name="image"
path="/" />
</paths>
\ No newline at end of file
......@@ -63,7 +63,7 @@ class _SplashPageState extends State<SplashPage> {
}
///创建 JPush
JPush jpush = new JPush();
JPush jpush = JPush();
///配置应用 Key
jpush.setup(
......@@ -74,6 +74,9 @@ class _SplashPageState extends State<SplashPage> {
/// 设置是否打印 debug 日志
debug: true,
);
jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: true),
);
}
@override
......
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:Parlando/account/account_router.dart';
import 'package:Parlando/events/trans_event.dart';
......@@ -23,8 +25,12 @@ import 'package:Parlando/tiktok/widgets/tiktok_video_button_column.dart';
import 'package:Parlando/tiktok/widgets/tiktok_video_poem.dart';
import 'package:Parlando/widgets/bars/home_types_bar.dart';
import 'package:Parlando/widgets/my_app_bar.dart';
import 'package:flutter/services.dart';
import 'package:getwidget/getwidget.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:screenshot/screenshot.dart';
import 'package:social_share/social_share.dart';
import 'package:video_player/video_player.dart';
import 'poem_detail.dart';
......@@ -48,6 +54,7 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
late StreamSubscription bus;
bool isLoading = false;
int currentId = 0;
String currentPoemId = '';
String currentPoemType = '';
......@@ -97,6 +104,7 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
}
currentPoemId = videoDataList.first.poemId;
currentPoemType = videoDataList.first.poemType;
currentId = videoDataList.first.id;
_videoListController.init(
pageController: _pageController,
initialList: videoDataList
......@@ -157,7 +165,7 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
Widget? currentPage;
double a = MediaQuery.of(context).size.aspectRatio;
bool hasBottomPadding = a < 0.55;
ScreenshotController screenshotController = ScreenshotController();
var detailPage = PoemDetailPage(
onPop: () {
tkController.animateToMiddle();
......@@ -208,7 +216,8 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
_videoListController.currentPlayer.videoInfo!.poemId;
currentPoemType =
_videoListController.currentPlayer.videoInfo!.poemType;
currentId =
_videoListController.currentPlayer.videoInfo!.id;
String url =
'${HttpApi.addView}/${_videoListController.currentPlayer.videoInfo!.id}';
// 统计观看数
......@@ -260,7 +269,9 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
onError: (code, msg) {},
);
},
onShare: () {},
onShare: () async {
showShareView(context);
},
);
Widget poem = TikTokVidePoem(
title: "每日一言",
......@@ -316,7 +327,7 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
buttonColor: Colors.teal,
onPress: () {
String url =
'${PoemRouter.poemRecordVideoPage}?id=$currentPoemId&type=$currentPoemType';
'${PoemRouter.poemRecordVideoPage}?id=$currentId&type=$currentPoemType';
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
......@@ -330,7 +341,7 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
'${PoemRouter.poemRecordAudioPage}?id=$currentPoemId&type=$currentPoemType',
'${PoemRouter.poemRecordAudioPage}?id=$currentId&type=$currentPoemType',
);
}),
],
......@@ -388,4 +399,108 @@ class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
FloatingActionButtonLocation.centerDocked,
);
}
static showShareView(BuildContext context) {
final List buttonTitles = [
"Twitter",
"Facebook",
];
final List buttonImages = [
"jiguang_socialize_twitter.png",
"jiguang_socialize_facebook.png",
];
showModalBottomSheet(
context: context,
backgroundColor: Colors.white.withAlpha(0),
elevation: 2,
builder: (BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)),
child: Container(
width: double.infinity,
height: 180,
color: const Color.fromRGBO(255, 255, 255, 1),
child: Stack(
children: [
Padding(
padding:
const EdgeInsets.only(top: 14, left: 15, right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
Text(
"分享到",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromRGBO(51, 51, 51, 1)),
),
],
)),
Padding(
padding: const EdgeInsets.only(left: 0, right: 0, top: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(buttonTitles.length, (index) {
return Container(
child: buttonWidget(context, buttonTitles[index],
buttonImages[index], index),
);
}).toList(),
),
)
],
),
),
);
});
}
static buttonWidget(
BuildContext context, String title, String imageName, int index) {
return GestureDetector(
onTap: () {
switch (index) {
case 0:
dismiss(context);
SocialShare.shareTwitter(
"This is Social Share twitter example",
hashtags: ["hello", "world", "foo", "bar"],
url: "https://google.com/#/hello",
trailingText: "\nhello",
).then((data) {
print(data);
});
break;
case 1: //Facebook
print("朋友圈");
dismiss(context);
break;
default:
break;
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
"assets/images/share/$imageName",
height: 64,
width: 64,
),
Padding(
padding: const EdgeInsets.only(top: 5),
child: Text(title,
style: const TextStyle(
fontSize: 12, color: Color.fromRGBO(51, 51, 51, 1))),
)
],
),
);
}
static dismiss(BuildContext context) {
Navigator.pop(context);
}
}
......
This diff is collapsed. Click to expand it.
......@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+2
version: 1.0.0+3
environment:
sdk: ">=2.16.2 <3.0.0"
......@@ -119,6 +119,8 @@ dependencies:
flutter_inapp_purchase: ^5.3.0
jpush_flutter: ^2.2.9
social_share: ^2.2.1
screenshot: ^1.2.3
dependency_overrides:
decimal: 1.5.0
......@@ -201,6 +203,7 @@ flutter:
- assets/images/poem/
- assets/images/category/
- assets/images/membership/
- assets/images/share/
- assets/data/
- assets/data/Data.json
- assets/data/friends/
......