mod: 首页直播&推荐响应式
This commit is contained in:
@ -60,7 +60,8 @@ class VideoCardH extends StatelessWidget {
|
|||||||
builder: (context, boxConstraints) {
|
builder: (context, boxConstraints) {
|
||||||
double width =
|
double width =
|
||||||
(boxConstraints.maxWidth - StyleString.cardSpace * 6) / 2;
|
(boxConstraints.maxWidth - StyleString.cardSpace * 6) / 2;
|
||||||
return SizedBox(
|
return Container(
|
||||||
|
constraints: const BoxConstraints(minHeight: 88),
|
||||||
height: width / StyleString.aspectRatio,
|
height: width / StyleString.aspectRatio,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|||||||
@ -78,8 +78,11 @@ class _LivePageState extends State<LivePage> {
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
|
return SliverLayoutBuilder(
|
||||||
|
builder: (context, boxConstraints) {
|
||||||
return Obx(() => contentGrid(
|
return Obx(() => contentGrid(
|
||||||
_liveController, _liveController.liveList));
|
_liveController, _liveController.liveList));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
@ -116,6 +119,14 @@ class _LivePageState extends State<LivePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget contentGrid(ctr, liveList) {
|
Widget contentGrid(ctr, liveList) {
|
||||||
|
double maxWidth = Get.size.width;
|
||||||
|
int baseWidth = 500;
|
||||||
|
int step = 300;
|
||||||
|
int crossAxisCount =
|
||||||
|
maxWidth > baseWidth ? 2 + ((maxWidth - baseWidth) / step).ceil() : 2;
|
||||||
|
if (maxWidth < 300) {
|
||||||
|
crossAxisCount = 1;
|
||||||
|
}
|
||||||
return SliverGrid(
|
return SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
// 行间距
|
// 行间距
|
||||||
@ -123,9 +134,9 @@ class _LivePageState extends State<LivePage> {
|
|||||||
// 列间距
|
// 列间距
|
||||||
crossAxisSpacing: StyleString.cardSpace + 4,
|
crossAxisSpacing: StyleString.cardSpace + 4,
|
||||||
// 列数
|
// 列数
|
||||||
crossAxisCount: ctr.crossAxisCount,
|
crossAxisCount: crossAxisCount,
|
||||||
mainAxisExtent:
|
mainAxisExtent:
|
||||||
Get.size.width / ctr.crossAxisCount / StyleString.aspectRatio + 64,
|
Get.size.width / crossAxisCount / StyleString.aspectRatio + 66,
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
|
|||||||
@ -84,8 +84,11 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
|
return SliverLayoutBuilder(
|
||||||
|
builder: (context, boxConstraints) {
|
||||||
return Obx(() => contentGrid(
|
return Obx(() => contentGrid(
|
||||||
_rcmdController, _rcmdController.videoList));
|
_rcmdController, _rcmdController.videoList));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
@ -121,6 +124,14 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget contentGrid(ctr, videoList) {
|
Widget contentGrid(ctr, videoList) {
|
||||||
|
double maxWidth = Get.size.width;
|
||||||
|
int baseWidth = 500;
|
||||||
|
int step = 300;
|
||||||
|
int crossAxisCount =
|
||||||
|
maxWidth > baseWidth ? 2 + ((maxWidth - baseWidth) / step).ceil() : 2;
|
||||||
|
if (maxWidth < 300) {
|
||||||
|
crossAxisCount = 1;
|
||||||
|
}
|
||||||
return SliverGrid(
|
return SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
// 行间距
|
// 行间距
|
||||||
@ -128,16 +139,14 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
// 列间距
|
// 列间距
|
||||||
crossAxisSpacing: StyleString.cardSpace + 4,
|
crossAxisSpacing: StyleString.cardSpace + 4,
|
||||||
// 列数
|
// 列数
|
||||||
crossAxisCount: ctr.crossAxisCount,
|
crossAxisCount: crossAxisCount,
|
||||||
mainAxisExtent:
|
mainAxisExtent:
|
||||||
Get.size.width / ctr.crossAxisCount / StyleString.aspectRatio + 64,
|
Get.size.width / crossAxisCount / StyleString.aspectRatio + 66,
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
return videoList!.isNotEmpty
|
return videoList!.isNotEmpty
|
||||||
?
|
? VideoCardV(
|
||||||
// VideoCardV(videoItem: videoList![index])
|
|
||||||
VideoCardV(
|
|
||||||
videoItem: videoList[index],
|
videoItem: videoList[index],
|
||||||
longPress: () {
|
longPress: () {
|
||||||
_rcmdController.popupDialog =
|
_rcmdController.popupDialog =
|
||||||
|
|||||||
Reference in New Issue
Block a user