feature 5.0.0

This commit is contained in:
v7lin
2023-02-24 15:09:45 +08:00
parent b32b842132
commit 7e8e4ac90a
6 changed files with 44 additions and 44 deletions

View File

@ -101,7 +101,7 @@ class _HomeState extends State<Home> {
title: Text('登录'), title: Text('登录'),
onTap: () { onTap: () {
TencentKitPlatform.instance.login( TencentKitPlatform.instance.login(
scope: <String>[TencentScope.GET_SIMPLE_USERINFO], scope: <String>[TencentScope.kGetSimpleUserInfo],
); );
}, },
), ),
@ -147,7 +147,7 @@ class _HomeState extends State<Home> {
title: Text('分享说说'), title: Text('分享说说'),
onTap: () { onTap: () {
TencentKitPlatform.instance.shareMood( TencentKitPlatform.instance.shareMood(
scene: TencentScene.SCENE_QZONE, scene: TencentScene.kScene_QZone,
summary: '分享测试', summary: '分享测试',
); );
}, },
@ -156,7 +156,7 @@ class _HomeState extends State<Home> {
title: Text('文本分享'), title: Text('文本分享'),
onTap: () { onTap: () {
TencentKitPlatform.instance.shareText( TencentKitPlatform.instance.shareText(
scene: TencentScene.SCENE_QQ, scene: TencentScene.kScene_QQ,
summary: '分享测试', summary: '分享测试',
); );
}, },
@ -167,7 +167,7 @@ class _HomeState extends State<Home> {
final File file = await DefaultCacheManager().getSingleFile( final File file = await DefaultCacheManager().getSingleFile(
'https://www.baidu.com/img/bd_logo1.png?where=super'); 'https://www.baidu.com/img/bd_logo1.png?where=super');
await TencentKitPlatform.instance.shareImage( await TencentKitPlatform.instance.shareImage(
scene: TencentScene.SCENE_QQ, scene: TencentScene.kScene_QQ,
imageUri: Uri.file(file.path), imageUri: Uri.file(file.path),
); );
}, },
@ -176,7 +176,7 @@ class _HomeState extends State<Home> {
title: Text('网页分享'), title: Text('网页分享'),
onTap: () { onTap: () {
TencentKitPlatform.instance.shareWebpage( TencentKitPlatform.instance.shareWebpage(
scene: TencentScene.SCENE_QQ, scene: TencentScene.kScene_QQ,
title: 'title', title: 'title',
targetUrl: 'https://www.baidu.com/', targetUrl: 'https://www.baidu.com/',
); );

View File

@ -2,67 +2,67 @@ class TencentScope {
const TencentScope._(); const TencentScope._();
/// 发表一条说说到QQ空间(需要申请权限) /// 发表一条说说到QQ空间(需要申请权限)
static const String OPEN_PERMISSION_ADD_TOPIC = 'add_topic'; static const String kAddTopic = 'add_topic';
/// 发表一篇日志到QQ空间(需要申请权限) /// 发表一篇日志到QQ空间(需要申请权限)
static const String OPEN_PERMISSION_ADD_ONE_BLOG = 'add_one_blog'; static const String kAddOneBlog = 'add_one_blog';
/// 创建一个QQ空间相册(需要申请权限) /// 创建一个QQ空间相册(需要申请权限)
static const String OPEN_PERMISSION_ADD_ALBUM = 'add_album'; static const String kAddAlbum = 'add_album';
/// 上传一张照片到QQ空间相册(需要申请权限) /// 上传一张照片到QQ空间相册(需要申请权限)
static const String OPEN_PERMISSION_UPLOAD_PIC = 'upload_pic'; static const String kUploadPic = 'upload_pic';
/// 获取用户QQ空间相册列表(需要申请权限) /// 获取用户QQ空间相册列表(需要申请权限)
static const String OPEN_PERMISSION_LIST_ALBUM = 'list_album'; static const String kListAlbum = 'list_album';
/// 同步分享到QQ空间、腾讯微博 /// 同步分享到QQ空间、腾讯微博
static const String OPEN_PERMISSION_ADD_SHARE = 'add_share'; static const String kAddShare = 'add_share';
/// 验证是否认证空间粉丝 /// 验证是否认证空间粉丝
static const String OPEN_PERMISSION_CHECK_PAGE_FANS = 'check_page_fans'; static const String kCheckPageFans = 'check_page_fans';
/// 获取登录用户自己的详细信息 /// 获取登录用户自己的详细信息
static const String OPEN_PERMISSION_GET_INFO = 'get_info'; static const String kGetInfo = 'get_info';
/// 获取其他用户的详细信息 /// 获取其他用户的详细信息
static const String OPEN_PERMISSION_GET_OTHER_INFO = 'get_other_info'; static const String kGetOtherInfo = 'get_other_info';
/// 获取会员用户基本信息 /// 获取会员用户基本信息
static const String OPEN_PERMISSION_GET_VIP_INFO = 'get_vip_info'; static const String kGetVipInfo = 'get_vip_info';
/// 获取会员用户详细信息 /// 获取会员用户详细信息
static const String OPEN_PERMISSION_GET_VIP_RICH_INFO = 'get_vip_rich_info'; static const String kGetVipRichInfo = 'get_vip_rich_info';
/// 获取用户信息 /// 获取用户信息
static const String GET_USER_INFO = 'get_user_info'; static const String kGetUserInfo = 'get_user_info';
/// 移动端获取用户信息 /// 移动端获取用户信息
static const String GET_SIMPLE_USERINFO = 'get_simple_userinfo'; static const String kGetSimpleUserInfo = 'get_simple_userinfo';
/// 所有权限 /// 所有权限
static const String ALL = 'all'; static const String kAll = 'all';
} }
class TencentScene { class TencentScene {
const TencentScene._(); const TencentScene._();
/// QQ /// QQ
static const int SCENE_QQ = 0; static const int kScene_QQ = 0;
/// QZone /// QZone
static const int SCENE_QZONE = 1; static const int kScene_QZone = 1;
} }
class TencentQZoneFlag { class TencentQZoneFlag {
const TencentQZoneFlag._(); const TencentQZoneFlag._();
/// 默认是不隐藏分享到QZone按钮且不自动打开分享到QZone的对话框 /// 默认是不隐藏分享到QZone按钮且不自动打开分享到QZone的对话框
static const int DEFAULT = 0; static const int kDefault = 0;
/// 分享时自动打开分享到QZone的对话框 /// 分享时自动打开分享到QZone的对话框
static const int AUTO_OPEN = 1; static const int kAutoOpen = 1;
/// 分享时隐藏分享到QZone按钮 /// 分享时隐藏分享到QZone按钮
static const int ITEM_HIDE = 2; static const int kItemHide = 2;
} }

View File

@ -12,24 +12,24 @@ abstract class TencentResp {
/// 网络请求成功发送至服务器,并且服务器返回数据格式正确 /// 网络请求成功发送至服务器,并且服务器返回数据格式正确
/// 这里包括所请求业务操作失败的情况,例如没有授权等原因导致 /// 这里包括所请求业务操作失败的情况,例如没有授权等原因导致
static const int RET_SUCCESS = 0; static const int kRetSuccess = 0;
/// 网络异常,或服务器返回的数据格式不正确导致无法解析 /// 网络异常,或服务器返回的数据格式不正确导致无法解析
static const int RET_FAILED = 1; static const int kRetFailed = 1;
static const int RET_COMMON = -1; static const int kRetCommon = -1;
static const int RET_USERCANCEL = -2; static const int kRetUserCancel = -2;
@JsonKey( @JsonKey(
defaultValue: RET_SUCCESS, defaultValue: kRetSuccess,
) )
final int ret; final int ret;
final String? msg; final String? msg;
bool get isSuccessful => ret == RET_SUCCESS; bool get isSuccessful => ret == kRetSuccess;
bool get isCancelled => ret == RET_USERCANCEL; bool get isCancelled => ret == kRetUserCancel;
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();

View File

@ -97,7 +97,7 @@ class MethodChannelTencentKit extends TencentKitPlatform {
List<Uri>? imageUris, List<Uri>? imageUris,
Uri? videoUri, Uri? videoUri,
}) { }) {
assert(scene == TencentScene.SCENE_QZONE); assert(scene == TencentScene.kScene_QZone);
assert((summary?.isNotEmpty ?? false) || assert((summary?.isNotEmpty ?? false) ||
((imageUris?.isNotEmpty ?? false) && ((imageUris?.isNotEmpty ?? false) &&
imageUris!.every((Uri element) => element.isScheme('file'))) || imageUris!.every((Uri element) => element.isScheme('file'))) ||
@ -120,7 +120,7 @@ class MethodChannelTencentKit extends TencentKitPlatform {
required int scene, required int scene,
required String summary, required String summary,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.kScene_QQ);
return methodChannel.invokeMethod<void>( return methodChannel.invokeMethod<void>(
'shareText', 'shareText',
<String, dynamic>{ <String, dynamic>{
@ -135,9 +135,9 @@ class MethodChannelTencentKit extends TencentKitPlatform {
required int scene, required int scene,
required Uri imageUri, required Uri imageUri,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.kScene_QQ);
assert(imageUri.isScheme('file')); assert(imageUri.isScheme('file'));
return methodChannel.invokeMethod<void>( return methodChannel.invokeMethod<void>(
'shareImage', 'shareImage',
@ -159,9 +159,9 @@ class MethodChannelTencentKit extends TencentKitPlatform {
required String musicUrl, required String musicUrl,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
assert(scene == TencentScene.SCENE_QQ); assert(scene == TencentScene.kScene_QQ);
return methodChannel.invokeMethod<void>( return methodChannel.invokeMethod<void>(
'shareMusic', 'shareMusic',
<String, dynamic>{ <String, dynamic>{
@ -185,7 +185,7 @@ class MethodChannelTencentKit extends TencentKitPlatform {
Uri? imageUri, Uri? imageUri,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
return methodChannel.invokeMethod<void>( return methodChannel.invokeMethod<void>(
'shareWebpage', 'shareWebpage',

View File

@ -95,7 +95,7 @@ abstract class TencentKitPlatform extends PlatformInterface {
required int scene, required int scene,
required Uri imageUri, required Uri imageUri,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError( throw UnimplementedError(
'shareImage({required scene, required imageUri, appName, extInt}) has not been implemented.'); 'shareImage({required scene, required imageUri, appName, extInt}) has not been implemented.');
@ -110,7 +110,7 @@ abstract class TencentKitPlatform extends PlatformInterface {
required String musicUrl, required String musicUrl,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError( throw UnimplementedError(
'shareMusic({required scene, required title, summary, imageUri, required musicUrl, required targetUrl, appName, extInt}) has not been implemented.'); 'shareMusic({required scene, required title, summary, imageUri, required musicUrl, required targetUrl, appName, extInt}) has not been implemented.');
@ -124,7 +124,7 @@ abstract class TencentKitPlatform extends PlatformInterface {
Uri? imageUri, Uri? imageUri,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError( throw UnimplementedError(
'shareWebpage({required scene, required title, summary, imageUri, required targetUrl, appName, extInt}) has not been implemented.'); 'shareWebpage({required scene, required title, summary, imageUri, required targetUrl, appName, extInt}) has not been implemented.');

View File

@ -58,7 +58,7 @@ class MockTencentKitPlatform
required int scene, required int scene,
required Uri imageUri, required Uri imageUri,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }
@ -82,7 +82,7 @@ class MockTencentKitPlatform
required String musicUrl, required String musicUrl,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }
@ -103,7 +103,7 @@ class MockTencentKitPlatform
Uri? imageUri, Uri? imageUri,
required String targetUrl, required String targetUrl,
String? appName, String? appName,
int extInt = TencentQZoneFlag.DEFAULT, int extInt = TencentQZoneFlag.kDefault,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }