calendar_view.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import 'dart:ui';
  2. import 'package:get/get.dart';
  3. import 'package:clean/module/calendar/calendar_controller.dart';
  4. import 'package:flutter/Material.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:wechat_assets_picker/wechat_assets_picker.dart';
  7. import '../../base/base_view.dart';
  8. import '../../resource/assets.gen.dart';
  9. import '../people_photo/photo_group.dart';
  10. import 'calendar_state.dart';
  11. class CalendarPage extends BaseView<CalendarController> {
  12. const CalendarPage({super.key});
  13. @override
  14. Color backgroundColor() => const Color(0xFF05050D); // 修正返回类型
  15. @override
  16. double viewHeight() => double.infinity; // 统一返回类型
  17. @override
  18. Widget buildBody(BuildContext context) {
  19. return Stack(
  20. children: [
  21. SafeArea(
  22. child: CustomScrollView(
  23. slivers: [
  24. SliverToBoxAdapter(child: titleCard()),
  25. Obx(() {
  26. return SliverList(
  27. delegate: SliverChildBuilderDelegate(
  28. (context, index) {
  29. return monthCard(controller.monthlyAlbums[index]);
  30. },
  31. childCount: controller.monthlyAlbums.length, // 添加 itemCount
  32. ),
  33. );
  34. }),
  35. SliverToBoxAdapter(child: SizedBox(height: 40.h)),
  36. ],
  37. ),
  38. ),
  39. IgnorePointer(
  40. child: Assets.images.bgHome.image(
  41. width: 360.w,
  42. ),
  43. ),
  44. ],
  45. );
  46. }
  47. Widget titleCard() {
  48. return Padding(
  49. padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.h),
  50. child: Row(
  51. children: [
  52. Text(
  53. 'Memory Lane',
  54. textAlign: TextAlign.center,
  55. style: TextStyle(
  56. color: Colors.white,
  57. fontSize: 24.sp,
  58. fontWeight: FontWeight.w900,
  59. ),
  60. ),
  61. Spacer(),
  62. Assets.images.iconCalendarSort.image(width: 28.w, height: 28.w),
  63. ],
  64. ),
  65. );
  66. }
  67. Widget monthCard(PhotoGroup photoGroup) {
  68. return GestureDetector(
  69. onTap: () => controller.clickMonthCard(photoGroup),
  70. child: Container(
  71. margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 12.h),
  72. width: 328.w,
  73. height: 209.h,
  74. decoration: ShapeDecoration(
  75. color: Colors.white.withValues(alpha: 0.12),
  76. shape: RoundedRectangleBorder(
  77. borderRadius: BorderRadius.circular(14.sp),
  78. ),
  79. ),
  80. child: Column(
  81. crossAxisAlignment: CrossAxisAlignment.start,
  82. children: [
  83. Spacer(),
  84. Padding(
  85. padding: EdgeInsets.only(left: 12.0.w, right: 12.0.w),
  86. child: Row(
  87. children: [
  88. Text(
  89. CalendarState.formatMonth(photoGroup.month ?? ""),
  90. style: TextStyle(
  91. color: Colors.white,
  92. fontSize: 16.sp,
  93. fontWeight: FontWeight.w700,
  94. ),
  95. ),
  96. Spacer(),
  97. Obx(() {
  98. return Text(
  99. '${photoGroup.selectedCount}/${photoGroup.images
  100. .length}',
  101. textAlign: TextAlign.center,
  102. style: TextStyle(
  103. color: Colors.white.withValues(alpha: 0.8),
  104. fontSize: 12.sp,
  105. fontWeight: FontWeight.w500,
  106. ),
  107. );
  108. }),
  109. ],
  110. ),
  111. ),
  112. Spacer(),
  113. Row(
  114. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  115. children: List.generate(2, (index) {
  116. if (index < photoGroup.images.length) {
  117. return GestureDetector(
  118. onTap: controller.clickImage,
  119. child: Container(
  120. width: 146.w,
  121. height: 146.w,
  122. decoration: BoxDecoration(
  123. borderRadius: BorderRadius.circular(12.r),
  124. image: DecorationImage(
  125. image: AssetEntityImageProvider(
  126. photoGroup.images[index],
  127. isOriginal: false),
  128. fit: BoxFit.cover,
  129. ),
  130. ),
  131. ));
  132. } else {
  133. return Container(
  134. width: 146.w,
  135. height: 146.w,
  136. decoration: BoxDecoration(
  137. borderRadius: BorderRadius.circular(12.r),
  138. ),
  139. );
  140. }
  141. }),
  142. ),
  143. Spacer(),
  144. ],
  145. ),
  146. ));
  147. }
  148. }