diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 479b5e9e..00152673 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -24,19 +24,18 @@ class CommunityChildPage extends StatefulWidget { class _CommunityChildPage extends State { RefreshController refreshController = RefreshController(); ApiService apiService; - int pageNum = 1; + int pageNum = 0; List comments = []; @override void initState() { super.initState(); - _onRefresh(); } _onRefresh() async { - pageNum = 1; + pageNum = 0; setState(() {}); } @@ -50,7 +49,7 @@ class _CommunityChildPage extends State { token: value.getString("token"), ); } - + pageNum += 1; BaseData> baseData = await apiService.trendList({ "onlyFollow": widget.typeStr == "关注" ? true:false, "onlyMe": false, @@ -69,6 +68,7 @@ class _CommunityChildPage extends State { comments.clear(); } comments.addAll(baseData.data.list); + // comments.sort((a,b)=>b.createTime.compareTo(a.createTime)); print("comments: ${comments.length}"); if (int.tryParse(baseData.data.total) < (pageNum * 10)) { refreshController.loadNoData(); @@ -100,7 +100,9 @@ class _CommunityChildPage extends State { physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return InkWell( - child: CommunityDynamic(comments[position],0), + child: CommunityDynamic(comments[position],0,exitFull: (){setState(() { + + });},), onTap: () { Navigator.of(context).pushNamed( '/router/community_details', diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 467ef9b0..d657e54b 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -16,7 +16,6 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/comment_menu.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/tips_dialog.dart'; -import 'package:huixiang/web/web_view/comment_list.dart'; import 'package:huixiang/web/web_view/input_comment.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -143,14 +142,16 @@ class _CommunityDetails extends State ), color: Colors.white, child: CommunityDynamic( - comunity,0, + comunity,0,exitFull: (){setState(() { + + });}, itemCount: 3, isDetails: true, heightFun: (height) { this.height = height + MediaQuery.of(context).padding.top + kToolbarHeight + - 68; + 24; setState(() {}); }, ), @@ -199,8 +200,7 @@ class _CommunityDetails extends State body: Container( height: MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top + - kToolbarHeight - - 68, + kToolbarHeight - 68, margin: EdgeInsets.only(top: 50 + kToolbarHeight), child: Column( children: [ @@ -231,6 +231,7 @@ class _CommunityDetails extends State Container( width: double.infinity, alignment: Alignment.topCenter, + margin: EdgeInsets.only(top:40), padding: EdgeInsets.all(22.h), child: Text( S.of(context).zanwupinglun, diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index b6c679e0..1d8a41f0 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -36,10 +36,14 @@ class _CommunityPage extends State } _toRelease() async { + int tmpIndex = tabcontroller.index; + setState(() { + tabcontroller.index = (tabcontroller.index == lables.length -1)?0:tabcontroller.index+1; + }); var result = await Navigator.of(context).pushNamed('/router/release_dynamic'); - if (result != null && result) { - setState(() {}); - } + setState(() { + tabcontroller.index = tmpIndex; + }); } @override diff --git a/lib/community/community_view/community_comment.dart b/lib/community/community_view/community_comment.dart index 123a9c3c..1ea7bc0c 100644 --- a/lib/community/community_view/community_comment.dart +++ b/lib/community/community_view/community_comment.dart @@ -206,7 +206,7 @@ class _CommunityComment extends State { ], ), alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 22.h), + padding: EdgeInsets.only(top: 22.h,bottom: 22), child: Text( S.of(context).yixiansquanbupinglun, style: TextStyle( diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 87742550..bfca430e 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -1,8 +1,10 @@ +import 'package:chewie/chewie.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; +import 'package:chewie/src/chewie_progress_colors.dart' as chewie; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/border_text.dart'; @@ -11,6 +13,7 @@ import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:video_player/video_player.dart'; class CommunityDynamic extends StatefulWidget { final int itemCount; @@ -18,6 +21,7 @@ class CommunityDynamic extends StatefulWidget { final bool isDetails; final int commentType; final Function removalDynamic; + final Function exitFull; final ComunityComment comment; @@ -29,6 +33,7 @@ class CommunityDynamic extends StatefulWidget { this.heightFun, this.isDetails = false, this.removalDynamic, + this.exitFull }) : super(key: key); @override @@ -106,9 +111,7 @@ class _CommunityDynamic extends State { child: Row( children: [ MImage( - widget.comment != null - ? widget.comment.memberInfo.avatar - : "", + widget?.comment?.memberInfo?.avatar??"", width: 44, height: 44, isCircle: true, @@ -124,9 +127,7 @@ class _CommunityDynamic extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.comment != null - ? widget.comment.memberInfo.nickname - : "", + widget?.comment?.memberInfo?.nickname??"", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -134,9 +135,7 @@ class _CommunityDynamic extends State { ), ), Text( - widget.comment != null - ? widget.comment.createTime - : "", + widget?.comment?.createTime??"", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -199,7 +198,7 @@ class _CommunityDynamic extends State { ), Text( widget.comment.subject ?? "", - // maxLines: 5, + maxLines: 5, overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xFF1A1A1A), @@ -221,7 +220,6 @@ class _CommunityDynamic extends State { (widget.comment != null) ? "${widget.comment.viewers}" : "", - // "${widget.comment.viewers ?? 0}", space: 4.w, leftImage: "assets/svg/liulanliang.svg", iconSize: 16, @@ -264,7 +262,7 @@ class _CommunityDynamic extends State { subjectInfo.images[0], fit: BoxFit.cover, width: MediaQuery.of(context).size.width / 2, - height: MediaQuery.of(context).size.width / 2, + height: MediaQuery.of(context).size.width /1, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), @@ -286,7 +284,7 @@ class _CommunityDynamic extends State { itemBuilder: (context, position) { return Container( child: MImage( - subjectInfo.images[0], + subjectInfo.images[position], fit: BoxFit.cover, aspectRatio: 1, errorSrc: "assets/image/default_2_1.png", @@ -298,13 +296,11 @@ class _CommunityDynamic extends State { ); } } else if (subjectInfo.type == "video" && - subjectInfo.video != null && - subjectInfo.video != "") { - widget = Container( - width: MediaQuery.of(context).size.width - 32, - height: MediaQuery.of(context).size.width / 2, - color: Colors.blue.withAlpha(123), - ); + subjectInfo.video.isNotEmpty) { + widget = videoWidget( + MediaQuery.of(context).size.width - 32, + MediaQuery.of(context).size.width /2, + subjectInfo.video); } return Column( @@ -320,6 +316,65 @@ class _CommunityDynamic extends State { ); } + VideoPlayerController videoPlayerController; + ChewieController chewieAudioController; + Chewie chewies; + + Widget videoWidget(double width, double height, src) { + print("src : $src"); + chewieAudioController = ChewieController( + videoPlayerController: videoPlayerController = + VideoPlayerController.network( + src, + ), + aspectRatio: width / height, + //宽高比 + autoPlay: false, + //自动播放 + looping: false, + //循环播放 + allowFullScreen: true, + // systemOverlaysAfterFullScreen: [], + // systemOverlaysOnEnterFullScreen: [], + // deviceOrientationsAfterFullScreen: [], + // deviceOrientationsOnEnterFullScreen: [], + // 拖动条样式颜色 + materialProgressColors: chewie.ChewieProgressColors( + playedColor: Colors.white, + handleColor: Colors.white, + backgroundColor: Colors.grey, + bufferedColor: Colors.transparent, + ), + autoInitialize: true, + ); + + chewieAudioController.addListener(_fullScreenListener); + + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaleFactor: 0.9, + ), + child: Container( + width: MediaQuery.of(context).size.width - 17, + height: (MediaQuery.of(context).size.width) / (width / height), + child: chewies = Chewie( + controller: chewieAudioController, + ), + ), + ); + } + + Future _fullScreenListener() async { + print("object: isPlaying: ${videoPlayerController.value.isPlaying}"); + print("object: isFullScreen: ${chewieAudioController.isFullScreen}"); + + if (!chewieAudioController.isFullScreen) { + Future.delayed(Duration(seconds: 1), () { + widget.exitFull(); + }); + } + } + ///删除动态弹窗 showDeleteDialog() { showDialog( diff --git a/lib/community/release_dynamic.dart b/lib/community/release_dynamic.dart index 19146dc1..144a6ac6 100644 --- a/lib/community/release_dynamic.dart +++ b/lib/community/release_dynamic.dart @@ -155,6 +155,7 @@ class _ReleaseDynamic extends State { if (baseData.isSuccess) { SmartDialog.showToast("发布成功!"); Future.delayed(Duration(seconds: 1), () { + Navigator.of(context).pop(true); }); } diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index 94a2718c..1eed9d6e 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -1,10 +1,16 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/mine/follow_page.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/social_info.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../fans_page.dart'; @@ -18,14 +24,34 @@ class CommunityFollow extends StatefulWidget { class _CommunityFollow extends State with SingleTickerProviderStateMixin { - + ApiService apiService; + SocialInfo infoNumber; @override void initState() { super.initState(); - + querySocialInfo(); } + ///个人社交信息(粉丝/关注数量) + querySocialInfo() async { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + showLoading: false, + ); + + BaseData baseData = + await apiService.socialInfo().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + infoNumber = baseData.data; + }); + } + EasyLoading.dismiss(); + } @override Widget build(BuildContext context) { @@ -56,8 +82,8 @@ class _CommunityFollow extends State indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: [ - MyTab(text:"关注(0)",), - MyTab(text: "粉丝(0)"), + MyTab(text:"关注(${infoNumber?.follow??"0"})",), + MyTab(text: "粉丝(${infoNumber?.fans??"0"})"), ], ), ), diff --git a/lib/mine/release_page.dart b/lib/mine/release_page.dart index 01c7dff0..1e3e809a 100644 --- a/lib/mine/release_page.dart +++ b/lib/mine/release_page.dart @@ -23,7 +23,7 @@ class ReleasePage extends StatefulWidget { class _ReleasePage extends State { RefreshController refreshController = RefreshController(); ApiService apiService; - int pageNum = 1; + int pageNum = 0; List comments = []; @@ -35,7 +35,7 @@ class _ReleasePage extends State { } _onRefresh() async { - pageNum = 1; + pageNum = 0; setState(() {}); } @@ -48,7 +48,7 @@ class _ReleasePage extends State { token: value.getString("token"), ); } - + pageNum += 1; BaseData> baseData = await apiService.trendList({ "onlyFollow": false, "onlyMe": true, @@ -108,7 +108,9 @@ class _ReleasePage extends State { return InkWell( child: CommunityDynamic( comments[position], - 1, + 1,exitFull: (){setState(() { + + });}, removalDynamic: () { _onRefresh(); },