feat: 整体常用控件封装,常用工具类。首页数据对接
This commit is contained in:
1 parent
d90d023e85
commit
fbcd33ea2b
50 files changed
+4558
-264
No files matched your search
@@ -1,8 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:skywood/global/client/play_client.dart';
|
||||
import 'package:skywood/global/client/user_client.dart';
|
||||
import 'package:skywood/main/lib_file.dart';
|
||||
import 'package:skywood/pages/home/widgets/daily_quest_widget.dart';
|
||||
import 'package:skywood/pages/widgets/common_bg_page.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_home.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
@@ -13,18 +17,107 @@ class HomePage extends StatefulWidget {
|
||||
|
||||
class _MainRootState extends State<HomePage> {
|
||||
|
||||
List<SkywoodHome> _homeData = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_getHomeData();
|
||||
}
|
||||
|
||||
void _getHomeData() {
|
||||
// home_v3_recommand
|
||||
// new_recommand
|
||||
// week_ranking
|
||||
// week_highest_recommend
|
||||
// marquee
|
||||
// home_banner
|
||||
// get_details_recommand
|
||||
PlayClient.getHomeData().then((value) {
|
||||
for (SkywoodHome element in value) {
|
||||
print('lele: ${element.moduleKey} : ${element.dataList.length}');
|
||||
}
|
||||
setState(() {
|
||||
_homeData = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonBgPage(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
child: SafeArea(
|
||||
child: _homeData.isEmpty ? SizedBox() : CustomScrollView(
|
||||
slivers: [
|
||||
_buildTopTwoImgs(),
|
||||
_buildSpace(),
|
||||
DailyQuestWidget(
|
||||
dramaList: _homeData.firstWhere((element) => element.moduleKey == 'home_v3_recommand').dataList,
|
||||
),
|
||||
_buildSpace(height: 10),
|
||||
_buildTitleImg(ConstImg.homeTitleMystery),
|
||||
_buildSpace(),
|
||||
// 345 355
|
||||
_buildTitleImg(
|
||||
ConstImg.homeOpenNowBox,
|
||||
padding: EdgeInsets.symmetric(horizontal: 15.w),
|
||||
height: 355.h,
|
||||
),
|
||||
_buildSpace(height: 10),
|
||||
_buildTitleImg(ConstImg.homeTitleHot),
|
||||
_buildSpace(height: 300),
|
||||
_buildTitleImg(ConstImg.homeTitleWeekly),
|
||||
_buildSpace(height: 300),
|
||||
_buildTitleImg(ConstImg.homeTitleHotCate),
|
||||
_buildSpace(height: 300),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
SliverToBoxAdapter _buildTopTwoImgs() {
|
||||
// 104-76
|
||||
return SliverToBoxAdapter(
|
||||
child: Stack(
|
||||
children: [
|
||||
SizedBox(width: double.infinity, height: (204 + 104 - 28).h),
|
||||
Container(
|
||||
height: 204.h,
|
||||
padding: EdgeInsets.only(left: 25.w, top: 3.h, right: 25.w),
|
||||
child: HelpImg.asset(ConstImg.homeTopBg, fit: BoxFit.fill),
|
||||
),
|
||||
Positioned(
|
||||
top: (204 - 28).h,
|
||||
height: 104.h,
|
||||
width: AppScreen.screenWidth,
|
||||
child: HelpImg.asset(ConstImg.homeTitleDaily, fit: BoxFit.fill),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTitleImg() {
|
||||
return Container();
|
||||
SliverToBoxAdapter _buildSpace({double height = 20}) {
|
||||
return SliverToBoxAdapter(child: SizedBox(height: height.h));
|
||||
}
|
||||
}
|
||||
|
||||
SliverToBoxAdapter _buildTitleImg(
|
||||
String imgName, {
|
||||
double? height,
|
||||
double? width,
|
||||
EdgeInsets? padding,
|
||||
}) {
|
||||
// 104-76
|
||||
return SliverToBoxAdapter(
|
||||
child: Container(
|
||||
padding: padding ?? EdgeInsets.zero,
|
||||
width: width ?? double.infinity,
|
||||
height: height ?? 104.h,
|
||||
child: HelpImg.asset(imgName, fit: BoxFit.fill),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:skywood/global/const/common_color.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_drama.dart';
|
||||
import 'package:skywood/utils/tools/sky_time_tool.dart';
|
||||
import 'package:skywood/utils/tools/widgets/sky_common_widget.dart';
|
||||
|
||||
import '../../../utils/tools/help_img.dart';
|
||||
|
||||
class DailyQuestWidget extends StatelessWidget {
|
||||
|
||||
const DailyQuestWidget({super.key,
|
||||
required this.dramaList,
|
||||
});
|
||||
|
||||
final List<SkywoodDrama> dramaList;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double height = 281.h;
|
||||
double width = 345.w;
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: Stack(
|
||||
children: [
|
||||
HelpImg.asset(ConstImg.homeCardBg, height: height, width: width,fit: BoxFit.fill),
|
||||
Positioned(
|
||||
top: 20.h, bottom: 19.h, left: 22.5.w,
|
||||
width: 300.w,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildFirstDrama(),
|
||||
_buildDramaList()
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDramaList() {
|
||||
if (dramaList.length < 2) return SizedBox.shrink();
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
spacing: 5.w,
|
||||
children: List.generate(dramaList.length-1, (index) {
|
||||
return HelpImg.network(dramaList[index+1].imageUrl, width: 95.w, height: 50.h, fit: BoxFit.cover);
|
||||
})
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFirstDrama() {
|
||||
if (dramaList.isEmpty) return SizedBox.shrink();
|
||||
SkywoodDrama drama = dramaList[0];
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: CommonColor.black, width: 1),
|
||||
),
|
||||
child: HelpImg.network(drama.imageUrl, width: 300.w, height: 160.h, fit: BoxFit.cover),
|
||||
),
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: SkyText(text: drama.name,
|
||||
fontSize: 14,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
)),
|
||||
Row(
|
||||
children: [
|
||||
// Icon(Icons.heart_broken, size: 15, color: Colors.redAccent,),
|
||||
HelpImg.asset(ConstImg.heart, width: 18.w, height: 18.w),
|
||||
const SizedBox(width: 3),
|
||||
SkyText(text: SkyTimeTool.formatNum(drama.watchTotal),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user