898 lines
32 KiB
Dart
898 lines
32 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../../beans/epg_bean.dart';
|
|
import '../../beans/home_info_bean.dart';
|
|
import '../../common/EventBusUtil.dart';
|
|
import '../../network/NetworkConfig.dart';
|
|
import '../game/game_info_page.dart';
|
|
import '../me/set/agreement_page.dart';
|
|
|
|
class HomeRecommendPage extends StatefulWidget {
|
|
final HomeInfoBean homeInfoBean;
|
|
|
|
HomeRecommendPage(Key key, {required this.homeInfoBean});
|
|
|
|
@override
|
|
State<HomeRecommendPage> createState() => _HomeRecommendState();
|
|
}
|
|
|
|
class _HomeRecommendState extends State<HomeRecommendPage> with AutomaticKeepAliveClientMixin {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _recommendItem(context);
|
|
}
|
|
|
|
_recommendItem(context) {
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
final l15 = size.width / 24;
|
|
// final t30 = size.width / 12;
|
|
final s16 = size.width / 22.5;
|
|
final h170 = size.width / 2.1176470588235;
|
|
final t20 = size.width / 18;
|
|
final h160 = size.width / 2.25;
|
|
final w99 = size.width / 3.6363636363636;
|
|
final h140 = size.width / 2.5714285714285;
|
|
final h125 = size.width / 2.88;
|
|
final w57 = size.width / 6.3157894736842;
|
|
final w75 = size.width / 4.8;
|
|
final h29 = size.width / 12.413793103448;
|
|
final c18 = size.width / 20;
|
|
final t10 = size.width / 36;
|
|
final c11 = size.width / 32.727272727272;
|
|
final t9 = size.width / 40;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s13 = size.width / 27.692307692307;
|
|
|
|
switch (widget.homeInfoBean.categoryType) {
|
|
case "Popular":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
width: size.width,
|
|
height: h170,
|
|
margin: EdgeInsets.only(top: t20),
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
itemCount: widget.homeInfoBean.epgList?.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _item(index, widget.homeInfoBean.epgList![index], context);
|
|
},
|
|
scrollDirection: Axis.horizontal,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
|
|
case "NewlyReleased":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
width: size.width,
|
|
height: h160,
|
|
// color: Colors.green,
|
|
margin: EdgeInsets.only(left: l15, right: l15, top: t10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(widget.homeInfoBean.epgList![0]);
|
|
},
|
|
child: SizedBox(
|
|
width: w99,
|
|
height: h140,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Container(
|
|
width: w99,
|
|
height: h125,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(c11)),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFFFBB259),
|
|
Color(0xFFF99559),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w57,
|
|
height: w57,
|
|
imageUrl: '${widget.homeInfoBean.epgList?[0].imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t9),
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[0].title}",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_playGame(widget.homeInfoBean.epgList?[0].resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h29,
|
|
margin: EdgeInsets.only(top: t10),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
|
),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Color(0xFFFA9D59)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(widget.homeInfoBean.epgList![1]);
|
|
},
|
|
child: SizedBox(
|
|
width: w99,
|
|
height: h140,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Container(
|
|
width: w99,
|
|
height: h125,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(c11)),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFF63D98F),
|
|
Color(0xFF31A47D),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w57,
|
|
height: w57,
|
|
imageUrl: '${widget.homeInfoBean.epgList?[1].imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t9),
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[1].title}",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_playGame(widget.homeInfoBean.epgList?[1].resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h29,
|
|
margin: EdgeInsets.only(top: t10),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
|
),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Color(0xFF3CAF81)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(widget.homeInfoBean.epgList![2]);
|
|
},
|
|
child: SizedBox(
|
|
width: w99,
|
|
height: h140,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Container(
|
|
width: w99,
|
|
height: h125,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(c11)),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFF39ADFE),
|
|
Color(0xFF0877FF),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w57,
|
|
height: w57,
|
|
imageUrl: '${widget.homeInfoBean.epgList?[2].imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t9),
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[2].title}",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_playGame(widget.homeInfoBean.epgList?[2].resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h29,
|
|
margin: EdgeInsets.only(top: t10),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
|
),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Color(0xFF1383FF)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
|
|
case "MustPlay":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: size.width,
|
|
child: Column(
|
|
children: _mustPlayItem(context),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
case "Fighting":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t20, left: l15, right: l15),
|
|
child: GridView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: widget.homeInfoBean.epgList!.length,
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 3, // 两列
|
|
mainAxisSpacing: 18.0,
|
|
crossAxisSpacing: 10.0,
|
|
childAspectRatio: 0.495,
|
|
),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return _fightingItem(index, widget.homeInfoBean.epgList![index], context);
|
|
}),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
case "GameSeries":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t20, left: l15, right: l15),
|
|
child: GridView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: widget.homeInfoBean.epgList!.length,
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2, // 两列
|
|
mainAxisSpacing: 18.0,
|
|
crossAxisSpacing: 10.0,
|
|
childAspectRatio: 0.98125,
|
|
),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return _gameSeriesItem(index, widget.homeInfoBean.epgList![index], context);
|
|
}),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
case "Sports":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
width: size.width,
|
|
margin: EdgeInsets.only(left: l15, right: l15),
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: widget.homeInfoBean.epgList!.length,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return _sportsItem(index, widget.homeInfoBean.epgList![index], context);
|
|
}),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
|
|
case "Activity":
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: l15, top: t20),
|
|
child: Text(
|
|
"${widget.homeInfoBean.categoryName}",
|
|
style: TextStyle(color: const Color(0xFFD6D6D7), fontSize: s16),
|
|
),
|
|
),
|
|
Container(
|
|
width: size.width,
|
|
margin: EdgeInsets.only(left: l15, right: l15),
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: widget.homeInfoBean.epgList!.length,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return _activityItem(index, widget.homeInfoBean.epgList![index], context);
|
|
}),
|
|
),
|
|
],
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
|
|
_item(index, EpgBean data, context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final w90 = size.width / 4;
|
|
final w75 = size.width / 4.8;
|
|
final h32 = size.width / 11.25;
|
|
final c18 = size.width / 20;
|
|
final l15 = size.width / 24;
|
|
final t11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s13 = size.width / 27.692307692307;
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(data);
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(left: index == 0 ? 0 : c18),
|
|
padding: EdgeInsets.only(left: index == 0 ? l15 : 0),
|
|
child: Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w90,
|
|
height: w90,
|
|
imageUrl: '${data.imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t11),
|
|
child: Text(
|
|
"${data.title}",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFF909090)),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_playGame(data.resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h32,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: t11),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
|
),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_mustPlayItem(context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h140 = size.width / 2.5714285714285;
|
|
final t18 = size.width / 20;
|
|
final l15 = size.width / 24;
|
|
final w331 = size.width / 1.0876132930513;
|
|
final h122 = size.width / 2.9508196721311;
|
|
final l133 = size.width / 2.7067669172932;
|
|
final t34 = size.width / 10.588235294117;
|
|
final w160 = size.width / 2.25;
|
|
final s16 = size.width / 22.5;
|
|
final w133 = size.width / 2.7067669172932;
|
|
final h67 = size.width / 5.3731343283582;
|
|
final r18 = size.width / 20;
|
|
final s21 = size.width / 17.142857142857;
|
|
final w99 = size.width / 3.6363636363636;
|
|
final h125 = size.width / 2.88;
|
|
final s13 = size.width / 27.692307692307;
|
|
final c11 = size.width / 32.727272727272;
|
|
|
|
return List.generate(
|
|
widget.homeInfoBean.epgList!.length,
|
|
(index) => GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(widget.homeInfoBean.epgList![index]);
|
|
},
|
|
child: Container(
|
|
height: h140,
|
|
margin: EdgeInsets.only(top: t18, left: l15, right: l15),
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Container(
|
|
width: w331,
|
|
height: h122,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(c11)),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: l133,
|
|
top: t34,
|
|
child: SizedBox(
|
|
width: w160,
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[index].title}",
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: s16, color: const Color(0xFFD6D6D7)),
|
|
),
|
|
)),
|
|
Positioned(
|
|
left: w133,
|
|
top: h67,
|
|
child: SizedBox(
|
|
width: w160,
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[index].subTitle}",
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: s13, color: Color(0xFFA6A6A6)),
|
|
),
|
|
)),
|
|
Positioned(
|
|
right: r18,
|
|
child: Text(
|
|
"${widget.homeInfoBean.epgList?[index].score}",
|
|
style: TextStyle(fontSize: s21, color: const Color(0xFFD6AF4A)),
|
|
)),
|
|
],
|
|
),
|
|
)),
|
|
Positioned(
|
|
top: 0,
|
|
left: r18,
|
|
child: CachedNetworkImage(
|
|
width: w99,
|
|
height: h125,
|
|
imageUrl: '${widget.homeInfoBean.epgList?[index].imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
).toList();
|
|
}
|
|
|
|
_fightingItem(index, EpgBean data, context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final w99 = size.width / 3.636363636363636;
|
|
final h125 = size.width / 2.88;
|
|
final w75 = size.width / 4.8;
|
|
final h32 = size.width / 11.25;
|
|
final r18 = size.width / 20;
|
|
final t11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s13 = size.width / 27.692307692307;
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(data);
|
|
},
|
|
child: Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w99,
|
|
height: h125,
|
|
imageUrl: '${data.imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
width: w99,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: t11),
|
|
child: Text(
|
|
'${data.title}',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: s14, color: Color(0xFF909090)),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
_playGame(data.resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h32,
|
|
margin: EdgeInsets.only(top: t11),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(color: const Color(0xFF074CE7), borderRadius: BorderRadius.all(Radius.circular(r18))),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
_gameSeriesItem(index, EpgBean data, context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final w157 = size.width / 2.292993630573248;
|
|
final h125 = size.width / 2.88;
|
|
final t11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(data);
|
|
},
|
|
child: Column(
|
|
children: [
|
|
CachedNetworkImage(
|
|
width: w157,
|
|
height: h125,
|
|
imageUrl: '${data.imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
Container(
|
|
width: w157,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: t11),
|
|
child: Text(
|
|
'${data.title}',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: s14, color: Color(0xFF909090)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
_sportsItem(index, EpgBean data, context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h70 = size.width / 5.142857142857143;
|
|
final w68 = size.width / 5.294117647058824;
|
|
final t18 = size.width / 20;
|
|
final l83 = size.width / 4.337349397590361;
|
|
final w150 = size.width / 2.4;
|
|
final w75 = size.width / 4.8;
|
|
final h32 = size.width / 11.25;
|
|
final c18 = size.width / 20;
|
|
final t11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s13 = size.width / 27.692307692307;
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(data);
|
|
},
|
|
child: Container(
|
|
height: h70,
|
|
margin: EdgeInsets.only(top: t18),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 0,
|
|
child: CachedNetworkImage(
|
|
width: w68,
|
|
height: w68,
|
|
imageUrl: '${data.imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: t11,
|
|
left: l83,
|
|
child: SizedBox(
|
|
width: w150,
|
|
child: Text(
|
|
"${data.title}",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 10,
|
|
left: l83,
|
|
child: SizedBox(
|
|
width: w150,
|
|
child: Text(
|
|
"${data.subTitle}",
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: s13, color: Color(0xFFA6A6A6)),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
_playGame(data.resId);
|
|
},
|
|
child: Container(
|
|
width: w75,
|
|
height: h32,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
|
),
|
|
child: Text(
|
|
"打开",
|
|
style: TextStyle(fontSize: s13, color: Colors.white),
|
|
),
|
|
),
|
|
))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_activityItem(index, EpgBean data, context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h206 = size.width / 1.747572815533981;
|
|
final t18 = size.width / 20;
|
|
final w331 = size.width / 1.08761329305136;
|
|
final h137 = size.width / 2.627737226277372;
|
|
final w313 = size.width / 1.150159744408946;
|
|
final b38 = size.width / 9.473684210526316;
|
|
final w150 = size.width / 2.4;
|
|
final t11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s13 = size.width / 27.692307692307;
|
|
final t10 = size.width / 36;
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
_jumpToPage(data);
|
|
},
|
|
child: Container(
|
|
height: h206,
|
|
margin: EdgeInsets.only(top: t18),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Container(
|
|
width: w331,
|
|
height: h137,
|
|
decoration: BoxDecoration(color: Color(0xFF202530), borderRadius: BorderRadius.all(Radius.circular(t11))),
|
|
)),
|
|
Positioned(
|
|
top: 0,
|
|
child: CachedNetworkImage(
|
|
width: w313,
|
|
height: h137,
|
|
imageUrl: '${data.imageUrl}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: b38,
|
|
left: t10,
|
|
child: SizedBox(
|
|
width: w150,
|
|
child: Text(
|
|
"${data.title}",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: t10,
|
|
left: t10,
|
|
child: SizedBox(
|
|
width: w150,
|
|
child: Text(
|
|
"${data.subTitle}",
|
|
style: TextStyle(fontSize: s13, color: Color(0xFFA6A6A6)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
///开始游戏
|
|
_playGame(gameId) {
|
|
if (NetworkConfig.isChecking) {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
//导航打开新视图
|
|
builder: (context) => GameInfoPage(
|
|
gameId: "$gameId",
|
|
),
|
|
));
|
|
} else {
|
|
EventBusUtil.fire(StartGames(gameId));
|
|
}
|
|
}
|
|
|
|
Future<void> _launchUrl(url) async {
|
|
if (!await launchUrl(url)) {
|
|
throw Exception('Could not launch $url');
|
|
}
|
|
}
|
|
|
|
///跳转页面
|
|
_jumpToPage(EpgBean value) {
|
|
if (NetworkConfig.token == "") {
|
|
Navigator.pushNamed(context, "/LoginPage");
|
|
return;
|
|
}
|
|
switch (value.resType) {
|
|
case 1: //游戏详情
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
//导航打开新视图
|
|
builder: (context) => GameInfoPage(
|
|
gameId: "${value.resId}",
|
|
),
|
|
));
|
|
break;
|
|
case 2: //app页面
|
|
switch (value.resId) {
|
|
case "Shop": //商城
|
|
EventBusUtil.fire(TabSwitch(2));
|
|
break;
|
|
case "Task": //任务中心
|
|
break;
|
|
}
|
|
break;
|
|
case 3: //内部H5
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => AgreementPage(
|
|
title: "活动",
|
|
url: "${value.resId}",
|
|
)),
|
|
);
|
|
break;
|
|
case 4: //外部H5
|
|
_launchUrl(Uri.parse('${value.resId}'));
|
|
break;
|
|
}
|
|
}
|
|
|
|
@override
|
|
// TODO: implement wantKeepAlive
|
|
bool get wantKeepAlive => true;
|
|
}
|