intro_view.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import 'package:clean/base/base_page.dart';
  2. import 'package:clean/module/splash/intro/intro_controller.dart';
  3. import 'package:clean/resource/assets.gen.dart';
  4. import 'package:clean/resource/colors.gen.dart';
  5. import 'package:clean/router/app_pages.dart';
  6. import 'package:flutter/Material.dart';
  7. import 'package:flutter/cupertino.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:get/get.dart';
  10. import 'package:get/get_core/src/get_main.dart';
  11. import 'package:lottie/lottie.dart';
  12. class IntroPage extends BasePage<IntroController> {
  13. IntroPage({Key? key}) : super(key: key);
  14. static void start() {
  15. Get.offNamed(RoutePath.intro);
  16. }
  17. @override
  18. bool immersive() {
  19. return true;
  20. }
  21. @override
  22. bool statusBarDarkFont() {
  23. return false;
  24. }
  25. @override
  26. Widget buildBody(BuildContext context) {
  27. return Stack(children: [
  28. Container(
  29. width: double.infinity,
  30. height: double.infinity,
  31. child: SafeArea(
  32. child: Container(
  33. child: Column(
  34. children: [
  35. Flexible(
  36. child: PageView(
  37. controller: controller.pageController.value,
  38. onPageChanged: (index) {
  39. controller.currentPage.value = index;
  40. },
  41. children: List.generate(controller.pageList.length, (index) {
  42. return buildPage(controller.pageList[index]);
  43. }),
  44. ),
  45. ),
  46. buildIndicator(),
  47. SizedBox(height: 15.h),
  48. GestureDetector(
  49. child: Container(
  50. width: 316.w,
  51. height: 48.h,
  52. alignment: Alignment.center,
  53. decoration: ShapeDecoration(
  54. color: Color(0xFF0279FB),
  55. shape: RoundedRectangleBorder(
  56. borderRadius: BorderRadius.circular(24.r),
  57. ),
  58. ),
  59. child: Text(
  60. 'CONTINUE',
  61. style: TextStyle(
  62. color: Colors.white,
  63. fontSize: 16.sp,
  64. fontWeight: FontWeight.w500,
  65. ),
  66. ),
  67. ),
  68. ),
  69. SizedBox(height: 76.h),
  70. ],
  71. ))),
  72. ),
  73. IgnorePointer(
  74. child: Assets.images.bgPhotoSelectedPreviewFinish.image(
  75. width: 360.w,
  76. height: 335.h,
  77. ),
  78. ),
  79. ]);
  80. }
  81. Widget buildIndicator() {
  82. return Obx(() {
  83. return Row(
  84. mainAxisAlignment: MainAxisAlignment.center,
  85. children: List.generate(controller.pageList.length, (index) {
  86. return AnimatedContainer(
  87. duration: const Duration(milliseconds: 500),
  88. margin: EdgeInsets.symmetric(horizontal: 5.h),
  89. height: 10,
  90. width: controller.currentPage.value == index ? 10.w : 10.w,
  91. // width: controller.currentPage.value == index ? 20.w : 10.w, 选中为长方形
  92. decoration: BoxDecoration(
  93. color: controller.currentPage.value == index
  94. ? ColorName.white
  95. : ColorName.white.withValues(alpha: 0.25),
  96. borderRadius: BorderRadius.circular(5.r),
  97. ),
  98. );
  99. }),
  100. );
  101. });
  102. }
  103. Widget buildPage(PageBean pageBean) {
  104. return Column(
  105. crossAxisAlignment: CrossAxisAlignment.center,
  106. mainAxisAlignment: MainAxisAlignment.center,
  107. children: [
  108. Text(
  109. pageBean.title,
  110. textAlign: TextAlign.center,
  111. style: TextStyle(
  112. color: Colors.white,
  113. fontSize: 24,
  114. fontWeight: FontWeight.w500,
  115. height: 1.25,
  116. ),
  117. ),
  118. Lottie.asset(
  119. pageBean.animUrl,
  120. width: 360.w,
  121. height: 329.w,
  122. repeat: true,
  123. ),
  124. ],
  125. );
  126. }
  127. }