124 lines
3.3 KiB
Dart
124 lines
3.3 KiB
Dart
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
|
|
State<StatefulWidget> createState() {
|
|
return _MainRootState();
|
|
}
|
|
}
|
|
|
|
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: 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),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
}
|