|
|
|
@ -2,7 +2,11 @@ import 'dart:math';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:recook/const/resource.dart';
|
|
|
|
|
import 'package:recook/constants/api.dart';
|
|
|
|
|
import 'package:recook/constants/constants.dart';
|
|
|
|
|
import 'package:recook/manager/http_manager.dart';
|
|
|
|
|
import 'package:recook/pages/live/models/video_list_model.dart';
|
|
|
|
|
import 'package:recook/widgets/refresh_widget.dart';
|
|
|
|
|
import 'package:waterfall_flow/waterfall_flow.dart';
|
|
|
|
|
|
|
|
|
|
class VideoPage extends StatefulWidget {
|
|
|
|
@ -12,90 +16,140 @@ class VideoPage extends StatefulWidget {
|
|
|
|
|
_VideoPageState createState() => _VideoPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _VideoPageState extends State<VideoPage> {
|
|
|
|
|
class _VideoPageState extends State<VideoPage>
|
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
|
|
|
|
GSRefreshController _controller = GSRefreshController();
|
|
|
|
|
int _page = 1;
|
|
|
|
|
List<VideoListModel> _videoListModels = [];
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return WaterfallFlow.builder(
|
|
|
|
|
padding: EdgeInsets.all(rSize(15)),
|
|
|
|
|
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
crossAxisSpacing: rSize(15),
|
|
|
|
|
mainAxisSpacing: rSize(15),
|
|
|
|
|
super.build(context);
|
|
|
|
|
return RefreshWidget(
|
|
|
|
|
controller: _controller,
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
_page = 1;
|
|
|
|
|
_getVideoList().then((models) {
|
|
|
|
|
_videoListModels = models;
|
|
|
|
|
if (mounted) setState(() {});
|
|
|
|
|
_controller.refreshCompleted();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onLoadMore: () {
|
|
|
|
|
_page++;
|
|
|
|
|
_getVideoList().then((models) {
|
|
|
|
|
_videoListModels.addAll(models);
|
|
|
|
|
if (mounted) setState(() {});
|
|
|
|
|
_controller.loadComplete();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
body: WaterfallFlow.builder(
|
|
|
|
|
padding: EdgeInsets.all(rSize(15)),
|
|
|
|
|
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
crossAxisSpacing: rSize(15),
|
|
|
|
|
mainAxisSpacing: rSize(15),
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return _buildVideoCard(_videoListModels[index]);
|
|
|
|
|
},
|
|
|
|
|
itemCount: _videoListModels.length,
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
//TODO: TEST ONLY
|
|
|
|
|
final randomHeight = 50 + Random().nextDouble() * 150;
|
|
|
|
|
return ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(rSize(10)),
|
|
|
|
|
child: Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: randomHeight,
|
|
|
|
|
child: Placeholder(),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.all(rSize(10)),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buildVideoCard(VideoListModel model) {
|
|
|
|
|
return ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(rSize(10)),
|
|
|
|
|
child: Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
FadeInImage.assetNetwork(
|
|
|
|
|
placeholder: R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
|
|
|
|
|
image: Api.getImgUrl(model.coverUrl),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.all(rSize(10)),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
model.content,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Color(0xFF333333),
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: rSP(13),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: rSize(6)),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'更有3档风速可调,风大风小随你掌控更有3档风速可调,风大风小随你掌控',
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Color(0xFF333333),
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: rSP(13),
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
|
placeholder: R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
|
|
|
|
|
image: Api.getImgUrl(model.headImgUrl),
|
|
|
|
|
height: rSize(18),
|
|
|
|
|
width: rSize(18),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: rSize(6)),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
CircleAvatar(
|
|
|
|
|
radius: rSize(9),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: rSize(4),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
'NAME NAME NAME',
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Color(0xFF666666),
|
|
|
|
|
fontSize: rSP(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Image.asset(
|
|
|
|
|
R.ASSETS_LIVE_FAVORITE_BLACK_PNG,
|
|
|
|
|
height: rSize(14),
|
|
|
|
|
width: rSize(14),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: rSize(4),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: rSize(2)),
|
|
|
|
|
Text(
|
|
|
|
|
'${Random().nextInt(100)}',
|
|
|
|
|
child: Text(
|
|
|
|
|
model.nickname,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Color(0xFF666666),
|
|
|
|
|
fontSize: rSP(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Image.asset(
|
|
|
|
|
R.ASSETS_LIVE_FAVORITE_BLACK_PNG,
|
|
|
|
|
height: rSize(14),
|
|
|
|
|
width: rSize(14),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: rSize(2)),
|
|
|
|
|
Text(
|
|
|
|
|
model.praise.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Color(0xFF666666),
|
|
|
|
|
fontSize: rSP(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<VideoListModel>> _getVideoList() async {
|
|
|
|
|
ResultData resultData = await HttpManager.post(LiveAPI.videoList, {
|
|
|
|
|
'page': _page,
|
|
|
|
|
'limit': 12,
|
|
|
|
|
});
|
|
|
|
|
if (resultData?.data['data']['list'] == null)
|
|
|
|
|
return [];
|
|
|
|
|
else
|
|
|
|
|
return (resultData.data['data']['list'] as List)
|
|
|
|
|
.map((e) => VideoListModel.fromJson(e))
|
|
|
|
|
.toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
|
}
|
|
|
|
|