125 lines
4.3 KiB
Dart
125 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:now_wallpaper/common/components/image_network_widget.dart';
|
|
import 'package:now_wallpaper/common/components/refresh/base_easyrefresh.dart';
|
|
import 'package:now_wallpaper/models/wallpaper_model.dart';
|
|
import 'package:now_wallpaper/modules/discover/discover_controller.dart';
|
|
import 'package:now_wallpaper/res/themes/app_sizes.dart';
|
|
|
|
class DiscoverView extends GetView<DiscoverController> {
|
|
const DiscoverView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Get.lazyPut(() => DiscoverController());
|
|
return GetBuilder<DiscoverController>(
|
|
builder: (controller) {
|
|
return Column(
|
|
children: [
|
|
SizedBox(height: 7.h),
|
|
if (controller.todayNewestList.isNotEmpty) ...[
|
|
_buildTodayNewest(),
|
|
SizedBox(height: 7.h),
|
|
],
|
|
Expanded(
|
|
child: BaseEasyRefresh(
|
|
controller: controller.refreshController,
|
|
onLoad: controller.onLoad,
|
|
viewState: controller.viewState,
|
|
height: discoverListHeight,
|
|
child: MasonryGridView.count(
|
|
itemCount: controller.wallpaperDataList.length,
|
|
crossAxisCount: 2,
|
|
mainAxisSpacing: 10.w,
|
|
crossAxisSpacing: 10.w,
|
|
padding: EdgeInsets.fromLTRB(20.w, 0, 20.w, 7.h),
|
|
itemBuilder: (context, index) {
|
|
return _buildDiscoverItem(controller.wallpaperDataList[index], index);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildDiscoverItem(WallpaperData item, index) {
|
|
return GestureDetector(
|
|
onTap: () => controller.onTapItem(index),
|
|
child: ImageNetworkWidget(
|
|
url: item.previewThumb,
|
|
radius: 8.r,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 今日最新
|
|
Widget _buildTodayNewest() {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20).w,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(12).r,
|
|
child: Material(
|
|
color: Colors.white,
|
|
child: InkWell(
|
|
onTap: controller.onTapTodayNewest,
|
|
child: Container(
|
|
height: todayNewestHeight,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16).w,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: RichText(
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
text: TextSpan(
|
|
text: 'Today',
|
|
style: TextStyle(
|
|
color: const Color(0xFF666666),
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
children: [
|
|
TextSpan(
|
|
text: '\n${controller.clsName}',
|
|
style: TextStyle(
|
|
color: const Color(0xFF333333),
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
...List.generate(controller.todayNewestList.length, (index) {
|
|
final item = controller.todayNewestList[index];
|
|
return Row(
|
|
children: [
|
|
ImageNetworkWidget(
|
|
url: item.previewThumb,
|
|
width: 42.w,
|
|
height: 42.w,
|
|
radius: 4.r,
|
|
),
|
|
if (index != controller.todayNewestList.length - 1) ...[
|
|
SizedBox(width: 8.w),
|
|
],
|
|
],
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|