初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
+337
View File
@@ -0,0 +1,337 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hgdj/assets_tool/images.dart';
import 'package:hgdj/tools_base/widget/net_image_widget.dart';
import 'live_detail_page.dart';
import 'live_model.dart';
import 'live_widget.dart';
class LiveItemWidget extends StatelessWidget {
final int showType; //0-九宫格 1-六圆形 2-4宫格 3-六宫格 4-横向滑动 5-list
final int? index; //顺序
final LiveAnchor? anchor; //主播信息
final Function()? action;
const LiveItemWidget({
super.key,
this.showType = 0,
this.anchor,
this.index,
this.action,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (action != null) {
action?.call();
} else {
Get.to(() => LiveDetailPage(anchor: anchor),
preventDuplicates: false);
}
},
child: _buildContent(),
);
}
_buildContent() {
if (showType == 0) return _buildType0();
if (showType == 1) return _buildType1();
if (showType == 2) return _buildType2();
if (showType == 3) return _buildType3();
if (showType == 4) return _buildType4();
if (showType == 5) return _buildType5();
return Container();
}
_buildType0() {
return Stack(
children: [
Positioned.fill(
child: NetworkImageLoader(
imageUrl: anchor?.coverImg ?? '', encrypt: false),
),
Positioned(
left: 4,
right: 4,
bottom: 6,
child: Text(
anchor?.name ?? '',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w400),
)),
Positioned(
left: 0,
top: 0,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 3),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffFFE356),
Color(0xffE11EFB),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(9),
bottomRight: Radius.circular(9),
),
),
child: Text(
'王牌主播',
style: TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.w400),
),
)),
],
);
}
_buildType1() {
return SizedBox(
height: 70,
child: Stack(
children: [
Positioned(
left: 18,
right: 0,
top: 7,
bottom: 0,
child: Image.asset(
'live_six_item_bg.webp'.livePath,
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 62,
height: 62,
child: ClipOval(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffAE06FF),
Color(0xffE538A3),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
)),
padding: EdgeInsets.all(1),
child: Container(
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.all(1),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.8),
shape: BoxShape.circle,
),
padding: EdgeInsets.all(2),
child: ClipOval(
child: NetworkImageLoader(
imageUrl: anchor?.coverImg ?? '', encrypt: false),
),
),
)),
),
Positioned(
bottom: 10,
child: AudioWaveView(
width: 2,
margin: 3,
color: Colors.white,
),
)
],
),
SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
anchor?.name ?? '',
style: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.w400),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 2),
Container(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(999),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0xffFD0563).withValues(alpha: .2),
blurRadius: 15.0, //阴影模糊程度
spreadRadius: 1.0,
),
],
),
child: Text(
'霸占TA>',
style: TextStyle(
fontSize: 10,
color: Color(0xff6A00FF),
fontWeight: FontWeight.w400),
),
),
],
),
)
],
),
],
),
);
}
_buildType2() {
return Stack(
children: [
Positioned.fill(
child: NetworkImageLoader(
imageUrl: anchor?.coverImg ?? '', encrypt: false),
),
Positioned(
left: 6,
bottom: 6,
child: Text(
anchor?.name ?? '',
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w400),
)),
if (index != null && index! < 3)
Positioned(
left: 0,
top: 0,
child: Image.asset(
'cp_${(index ?? 0) + 1}.webp'.livePath,
height: 24,
)),
],
);
}
_buildType3() {
return Stack(
children: [
Positioned.fill(
child: Container(
padding: EdgeInsets.all(2),
child: NetworkImageLoader(
imageUrl: anchor?.coverImg ?? '',
encrypt: false,
borderRadius: 6,
),
),
),
Positioned(
left: 6,
bottom: 6,
child: Text(
anchor?.name ?? '',
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w400),
)),
],
);
}
_buildType4() {
return Container(
padding: EdgeInsets.all(4),
child: _buildType5(),
);
}
_buildType5() {
return Stack(
children: [
Positioned.fill(
child: NetworkImageLoader(
imageUrl: anchor?.coverImg ?? '',
encrypt: false,
borderRadius: 6,
),
),
Positioned(
left: 6,
bottom: 6,
child: Text(
anchor?.name ?? '',
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w400),
)),
Positioned(
right: 6,
top: 6,
height: 16,
child: Row(
children: [
Container(
height: 8,
width: 8,
decoration: BoxDecoration(
color: (anchor?.isOnline ?? false)
? Color(0xff0AEBED)
: Color(0xff656565),
borderRadius: BorderRadius.circular(4),
),
),
SizedBox(width: 4),
Text(
(anchor?.isOnline ?? false) ? '直播中' : '离线',
style: TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.w400),
)
],
)),
Positioned(
left: 6,
top: 6,
child: Container(
height: 16,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 4),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: .3),
borderRadius: BorderRadius.circular(999),
),
child: Text(
'${anchor?.viewCount ?? 0}人观众',
style: TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.w400),
),
)),
],
);
}
}