Browse Source

Merge branches 'dev' and 'master' of https://git.lotus-wallet.com/fmk/huixiang_app

master
fmk 3 years ago
parent
commit
cf56007586
  1. 12
      lib/community/community_child_page.dart
  2. 11
      lib/community/community_details.dart
  3. 10
      lib/community/community_page.dart
  4. 2
      lib/community/community_view/community_comment.dart
  5. 95
      lib/community/community_view/community_dynamic.dart
  6. 1
      lib/community/release_dynamic.dart
  7. 34
      lib/mine/mine_view/community_follow.dart
  8. 10
      lib/mine/release_page.dart

12
lib/community/community_child_page.dart

@ -24,19 +24,18 @@ class CommunityChildPage extends StatefulWidget {
class _CommunityChildPage extends State<CommunityChildPage> { class _CommunityChildPage extends State<CommunityChildPage> {
RefreshController refreshController = RefreshController(); RefreshController refreshController = RefreshController();
ApiService apiService; ApiService apiService;
int pageNum = 1; int pageNum = 0;
List<ComunityComment> comments = []; List<ComunityComment> comments = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_onRefresh(); _onRefresh();
} }
_onRefresh() async { _onRefresh() async {
pageNum = 1; pageNum = 0;
setState(() {}); setState(() {});
} }
@ -50,7 +49,7 @@ class _CommunityChildPage extends State<CommunityChildPage> {
token: value.getString("token"), token: value.getString("token"),
); );
} }
pageNum += 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"onlyFollow": widget.typeStr == "关注" ? true:false, "onlyFollow": widget.typeStr == "关注" ? true:false,
"onlyMe": false, "onlyMe": false,
@ -69,6 +68,7 @@ class _CommunityChildPage extends State<CommunityChildPage> {
comments.clear(); comments.clear();
} }
comments.addAll(baseData.data.list); comments.addAll(baseData.data.list);
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime));
print("comments: ${comments.length}"); print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { if (int.tryParse(baseData.data.total) < (pageNum * 10)) {
refreshController.loadNoData(); refreshController.loadNoData();
@ -100,7 +100,9 @@ class _CommunityChildPage extends State<CommunityChildPage> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return InkWell( return InkWell(
child: CommunityDynamic(comments[position],0), child: CommunityDynamic(comments[position],0,exitFull: (){setState(() {
});},),
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
'/router/community_details', '/router/community_details',

11
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/comment_menu.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:huixiang/view_widget/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:huixiang/web/web_view/input_comment.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -143,14 +142,16 @@ class _CommunityDetails extends State<CommunityDetails>
), ),
color: Colors.white, color: Colors.white,
child: CommunityDynamic( child: CommunityDynamic(
comunity,0, comunity,0,exitFull: (){setState(() {
});},
itemCount: 3, itemCount: 3,
isDetails: true, isDetails: true,
heightFun: (height) { heightFun: (height) {
this.height = height + this.height = height +
MediaQuery.of(context).padding.top + MediaQuery.of(context).padding.top +
kToolbarHeight + kToolbarHeight +
68; 24;
setState(() {}); setState(() {});
}, },
), ),
@ -199,8 +200,7 @@ class _CommunityDetails extends State<CommunityDetails>
body: Container( body: Container(
height: MediaQuery.of(context).size.height - height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top + MediaQuery.of(context).padding.top +
kToolbarHeight - kToolbarHeight - 68,
68,
margin: EdgeInsets.only(top: 50 + kToolbarHeight), margin: EdgeInsets.only(top: 50 + kToolbarHeight),
child: Column( child: Column(
children: [ children: [
@ -231,6 +231,7 @@ class _CommunityDetails extends State<CommunityDetails>
Container( Container(
width: double.infinity, width: double.infinity,
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
margin: EdgeInsets.only(top:40),
padding: EdgeInsets.all(22.h), padding: EdgeInsets.all(22.h),
child: Text( child: Text(
S.of(context).zanwupinglun, S.of(context).zanwupinglun,

10
lib/community/community_page.dart

@ -36,10 +36,14 @@ class _CommunityPage extends State<CommunityPage>
} }
_toRelease() async { _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'); var result = await Navigator.of(context).pushNamed('/router/release_dynamic');
if (result != null && result) { setState(() {
setState(() {}); tabcontroller.index = tmpIndex;
} });
} }
@override @override

2
lib/community/community_view/community_comment.dart

@ -206,7 +206,7 @@ class _CommunityComment extends State<CommunityComment> {
], ],
), ),
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
padding: EdgeInsets.only(top: 22.h), padding: EdgeInsets.only(top: 22.h,bottom: 22),
child: Text( child: Text(
S.of(context).yixiansquanbupinglun, S.of(context).yixiansquanbupinglun,
style: TextStyle( style: TextStyle(

95
lib/community/community_view/community_dynamic.dart

@ -1,8 +1,10 @@
import 'package:chewie/chewie.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/comunity_comment.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/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/border_text.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:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:video_player/video_player.dart';
class CommunityDynamic extends StatefulWidget { class CommunityDynamic extends StatefulWidget {
final int itemCount; final int itemCount;
@ -18,6 +21,7 @@ class CommunityDynamic extends StatefulWidget {
final bool isDetails; final bool isDetails;
final int commentType; final int commentType;
final Function removalDynamic; final Function removalDynamic;
final Function exitFull;
final ComunityComment comment; final ComunityComment comment;
@ -29,6 +33,7 @@ class CommunityDynamic extends StatefulWidget {
this.heightFun, this.heightFun,
this.isDetails = false, this.isDetails = false,
this.removalDynamic, this.removalDynamic,
this.exitFull
}) : super(key: key); }) : super(key: key);
@override @override
@ -106,9 +111,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
child: Row( child: Row(
children: [ children: [
MImage( MImage(
widget.comment != null widget?.comment?.memberInfo?.avatar??"",
? widget.comment.memberInfo.avatar
: "",
width: 44, width: 44,
height: 44, height: 44,
isCircle: true, isCircle: true,
@ -124,9 +127,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
widget.comment != null widget?.comment?.memberInfo?.nickname??"",
? widget.comment.memberInfo.nickname
: "",
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
@ -134,9 +135,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
), ),
), ),
Text( Text(
widget.comment != null widget?.comment?.createTime??"",
? widget.comment.createTime
: "",
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
@ -199,7 +198,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
), ),
Text( Text(
widget.comment.subject ?? "", widget.comment.subject ?? "",
// maxLines: 5, maxLines: 5,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Color(0xFF1A1A1A), color: Color(0xFF1A1A1A),
@ -221,7 +220,6 @@ class _CommunityDynamic extends State<CommunityDynamic> {
(widget.comment != null) (widget.comment != null)
? "${widget.comment.viewers}" ? "${widget.comment.viewers}"
: "", : "",
// "${widget.comment.viewers ?? 0}",
space: 4.w, space: 4.w,
leftImage: "assets/svg/liulanliang.svg", leftImage: "assets/svg/liulanliang.svg",
iconSize: 16, iconSize: 16,
@ -264,7 +262,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
subjectInfo.images[0], subjectInfo.images[0],
fit: BoxFit.cover, fit: BoxFit.cover,
width: MediaQuery.of(context).size.width / 2, 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", errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png",
), ),
@ -286,7 +284,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
itemBuilder: (context, position) { itemBuilder: (context, position) {
return Container( return Container(
child: MImage( child: MImage(
subjectInfo.images[0], subjectInfo.images[position],
fit: BoxFit.cover, fit: BoxFit.cover,
aspectRatio: 1, aspectRatio: 1,
errorSrc: "assets/image/default_2_1.png", errorSrc: "assets/image/default_2_1.png",
@ -298,13 +296,11 @@ class _CommunityDynamic extends State<CommunityDynamic> {
); );
} }
} else if (subjectInfo.type == "video" && } else if (subjectInfo.type == "video" &&
subjectInfo.video != null && subjectInfo.video.isNotEmpty) {
subjectInfo.video != "") { widget = videoWidget(
widget = Container( MediaQuery.of(context).size.width - 32,
width: MediaQuery.of(context).size.width - 32, MediaQuery.of(context).size.width /2,
height: MediaQuery.of(context).size.width / 2, subjectInfo.video);
color: Colors.blue.withAlpha(123),
);
} }
return Column( return Column(
@ -320,6 +316,65 @@ class _CommunityDynamic extends State<CommunityDynamic> {
); );
} }
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<void> _fullScreenListener() async {
print("object: isPlaying: ${videoPlayerController.value.isPlaying}");
print("object: isFullScreen: ${chewieAudioController.isFullScreen}");
if (!chewieAudioController.isFullScreen) {
Future.delayed(Duration(seconds: 1), () {
widget.exitFull();
});
}
}
/// ///
showDeleteDialog() { showDeleteDialog() {
showDialog( showDialog(

1
lib/community/release_dynamic.dart

@ -155,6 +155,7 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
if (baseData.isSuccess) { if (baseData.isSuccess) {
SmartDialog.showToast("发布成功!"); SmartDialog.showToast("发布成功!");
Future.delayed(Duration(seconds: 1), () { Future.delayed(Duration(seconds: 1), () {
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
}); });
} }

34
lib/mine/mine_view/community_follow.dart

@ -1,10 +1,16 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/mine/follow_page.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/utils/font_weight.dart';
import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/my_tab.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../fans_page.dart'; import '../fans_page.dart';
@ -18,14 +24,34 @@ class CommunityFollow extends StatefulWidget {
class _CommunityFollow extends State<CommunityFollow> class _CommunityFollow extends State<CommunityFollow>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
ApiService apiService;
SocialInfo infoNumber;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
querySocialInfo();
} }
///(/)
querySocialInfo() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
showLoading: false,
);
BaseData<SocialInfo> baseData =
await apiService.socialInfo().catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
setState(() {
infoNumber = baseData.data;
});
}
EasyLoading.dismiss();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -56,8 +82,8 @@ class _CommunityFollow extends State<CommunityFollow>
indicatorSize: TabBarIndicatorSize.label, indicatorSize: TabBarIndicatorSize.label,
// //
tabs: <Widget>[ tabs: <Widget>[
MyTab(text:"关注(0)",), MyTab(text:"关注(${infoNumber?.follow??"0"})",),
MyTab(text: "粉丝(0)"), MyTab(text: "粉丝(${infoNumber?.fans??"0"})"),
], ],
), ),
), ),

10
lib/mine/release_page.dart

@ -23,7 +23,7 @@ class ReleasePage extends StatefulWidget {
class _ReleasePage extends State<ReleasePage> { class _ReleasePage extends State<ReleasePage> {
RefreshController refreshController = RefreshController(); RefreshController refreshController = RefreshController();
ApiService apiService; ApiService apiService;
int pageNum = 1; int pageNum = 0;
List<ComunityComment> comments = []; List<ComunityComment> comments = [];
@ -35,7 +35,7 @@ class _ReleasePage extends State<ReleasePage> {
} }
_onRefresh() async { _onRefresh() async {
pageNum = 1; pageNum = 0;
setState(() {}); setState(() {});
} }
@ -48,7 +48,7 @@ class _ReleasePage extends State<ReleasePage> {
token: value.getString("token"), token: value.getString("token"),
); );
} }
pageNum += 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"onlyFollow": false, "onlyFollow": false,
"onlyMe": true, "onlyMe": true,
@ -108,7 +108,9 @@ class _ReleasePage extends State<ReleasePage> {
return InkWell( return InkWell(
child: CommunityDynamic( child: CommunityDynamic(
comments[position], comments[position],
1, 1,exitFull: (){setState(() {
});},
removalDynamic: () { removalDynamic: () {
_onRefresh(); _onRefresh();
}, },

Loading…
Cancel
Save