diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5d82591..140bfde 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -529,4 +529,6 @@ class LiveAPI { ///当前用户直播信息获取 static const String getLiveInfo = '/v1/live/live/info'; + + static const String liveLicense = '/v1/live/live/license'; } diff --git a/lib/main.dart b/lib/main.dart index 9ee2f2b..a026cc4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,8 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:oktoast/oktoast.dart'; +import 'package:recook/constants/api.dart'; +import 'package:recook/manager/http_manager.dart'; import 'package:recook/manager/user_manager.dart'; import 'package:recook/models/user_brief_info_model.dart'; import 'package:recook/models/user_model.dart'; @@ -39,20 +41,13 @@ void main() async { //初始化腾讯im TencentImPlugin.init(appid: '1400435566'); - //初始化腾讯直播 - TencentLive.instance.init( - licenseUrl: - 'http://license.vod2.myqcloud.com/license/v1/9bc083b7b7c2101699499d193c40921b/TXLiveSDK.licence', - licenseKey: 'cf903ae78afbb05b5128f8961bf08f64', - ); - AppConfig.initial(useEncrypt: false /// 网络请求加密功能 // useEncrypt: true ); // 设置当前是否为测试环境 - bool isDebug = true; + bool isDebug = false; AppConfig.setDebug(isDebug); bool inTest = Test.test(); @@ -122,6 +117,16 @@ class MyAppState extends State { // ShareSDKRegister register = ShareSDKRegister(); // register.setupQQ("1109724223", "UGWklum7WWI03ll9"); // SharesdkPlugin.regist(register); + + HttpManager.post(LiveAPI.liveLicense, {}).then((resultData) { + String key = resultData.data['data']['key']; + String licenseURL = resultData.data['data']['licenseUrl']; + //初始化腾讯直播 + TencentLive.instance.init( + licenseUrl: licenseURL, + licenseKey: key, + ); + }); } Future initPlatformState() async { diff --git a/lib/pages/live/live_stream/live_stream_view_page.dart b/lib/pages/live/live_stream/live_stream_view_page.dart index 661a16c..0b64a05 100644 --- a/lib/pages/live/live_stream/live_stream_view_page.dart +++ b/lib/pages/live/live_stream/live_stream_view_page.dart @@ -61,6 +61,8 @@ class _LiveStreamViewPageState extends State { List _groupMembers = []; + int _praise = 0; + @override void initState() { super.initState(); @@ -78,6 +80,7 @@ class _LiveStreamViewPageState extends State { else { setState(() { _streamInfoModel = model; + _praise = model.praise; isAttention = _streamInfoModel.isFollow == 1; }); TencentImPlugin.applyJoinGroup( @@ -158,6 +161,12 @@ class _LiveStreamViewPageState extends State { showDetailWindow = false; }); break; + case 'Praise': + int extra = customParams['data']['addPraise']; + // int nowPraise = customParams['data']['praise']; + _praise += extra; + setState(() {}); + break; case 'Explain': int goodsId = customParams['data']['goodsId']; nowGoodList = _streamInfoModel.goodsLists.where((element) { @@ -184,6 +193,7 @@ class _LiveStreamViewPageState extends State { )); } break; + case 'Notice': chatObjects.insertAll( 0, @@ -345,7 +355,7 @@ class _LiveStreamViewPageState extends State { ); }, title: _streamInfoModel.nickname, - subTitle: '点赞数 ${_streamInfoModel.praise}', + subTitle: '点赞数 $_praise', avatar: _streamInfoModel.headImgUrl, ), Spacer(), diff --git a/lib/pages/live/live_stream/show_goods_list.dart b/lib/pages/live/live_stream/show_goods_list.dart index 6bd9470..ba81362 100644 --- a/lib/pages/live/live_stream/show_goods_list.dart +++ b/lib/pages/live/live_stream/show_goods_list.dart @@ -51,8 +51,11 @@ class _GoodsListDialogState extends State { return DraggableScrollableSheet( minChildSize: 0.5, maxChildSize: 0.9, + initialChildSize: 0.5, + expand: false, builder: (context, scrollController) { return Column( + mainAxisSize: MainAxisSize.max, children: [ Material( color: Colors.transparent, @@ -85,6 +88,7 @@ class _GoodsListDialogState extends State { child: ListView.separated( padding: EdgeInsets.zero, controller: scrollController, + physics: BouncingScrollPhysics(), itemBuilder: (context, index) { return _buildGoodsCard(widget.models[index], index); }, @@ -417,33 +421,46 @@ showGoodsListDialog( int initExplain, int id, }) { - showGeneralDialog( + showModalBottomSheet( context: context, - pageBuilder: (context, animation, secondaryAnimation) { - return Align( - alignment: Alignment.bottomCenter, - child: GoodsListDialog( - models: models, - isLive: isLive, - onExplain: onExplain, - initExplain: initExplain, - id: id, - onLive: onLive, - ), + builder: (context) { + return GoodsListDialog( + models: models, + isLive: isLive, + onExplain: onExplain, + initExplain: initExplain, + id: id, + onLive: onLive, ); }, - transitionBuilder: (context, animation, secondaryAnimation, child) { - return Transform.translate( - offset: Offset( - 0, (1 - Curves.easeInOutCubic.transform(animation.value)) * 500), - child: child, - ); - }, - barrierColor: Colors.black26, - barrierLabel: 'label', - barrierDismissible: true, - transitionDuration: Duration(milliseconds: 500), ); + // showGeneralDialog( + // context: context, + // pageBuilder: (context, animation, secondaryAnimation) { + // return Align( + // alignment: Alignment.bottomCenter, + // child: GoodsListDialog( + // models: models, + // isLive: isLive, + // onExplain: onExplain, + // initExplain: initExplain, + // id: id, + // onLive: onLive, + // ), + // ); + // }, + // transitionBuilder: (context, animation, secondaryAnimation, child) { + // return Transform.translate( + // offset: Offset( + // 0, (1 - Curves.easeInOutCubic.transform(animation.value)) * 500), + // child: child, + // ); + // }, + // barrierColor: Colors.black26, + // barrierLabel: 'label', + // barrierDismissible: true, + // transitionDuration: Duration(milliseconds: 500), + // ); } /**