intro_view.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. onTap: () {
  50. controller.clickContinue();
  51. },
  52. child: Container(
  53. width: 316.w,
  54. height: 48.h,
  55. alignment: Alignment.center,
  56. decoration: ShapeDecoration(
  57. color: Color(0xFF0279FB),
  58. shape: RoundedRectangleBorder(
  59. borderRadius: BorderRadius.circular(24.r),
  60. ),
  61. ),
  62. child: Text(
  63. 'CONTINUE',
  64. style: TextStyle(
  65. color: Colors.white,
  66. fontSize: 16.sp,
  67. fontWeight: FontWeight.w500,
  68. ),
  69. ),
  70. ),
  71. ),
  72. SizedBox(height: 76.h),
  73. ],
  74. ))),
  75. ),
  76. IgnorePointer(
  77. child: Assets.images.bgPhotoSelectedPreviewFinish.image(
  78. width: 360.w,
  79. height: 335.h,
  80. ),
  81. ),
  82. ]);
  83. }
  84. Widget buildIndicator() {
  85. return Obx(() {
  86. return Row(
  87. mainAxisAlignment: MainAxisAlignment.center,
  88. children: List.generate(controller.pageList.length, (index) {
  89. return AnimatedContainer(
  90. duration: const Duration(milliseconds: 500),
  91. margin: EdgeInsets.symmetric(horizontal: 5.h),
  92. height: 10,
  93. width: controller.currentPage.value == index ? 10.w : 10.w,
  94. // width: controller.currentPage.value == index ? 20.w : 10.w, 选中为长方形
  95. decoration: BoxDecoration(
  96. color: controller.currentPage.value == index
  97. ? ColorName.white
  98. : ColorName.white.withValues(alpha: 0.25),
  99. borderRadius: BorderRadius.circular(5.r),
  100. ),
  101. );
  102. }),
  103. );
  104. });
  105. }
  106. Widget buildPage(PageBean pageBean) {
  107. return Column(
  108. crossAxisAlignment: CrossAxisAlignment.center,
  109. mainAxisAlignment: MainAxisAlignment.center,
  110. children: [
  111. Text(
  112. pageBean.title,
  113. textAlign: TextAlign.center,
  114. style: TextStyle(
  115. color: Colors.white,
  116. fontSize: 24,
  117. fontWeight: FontWeight.w500,
  118. height: 1.25,
  119. ),
  120. ),
  121. Lottie.asset(
  122. pageBean.animUrl,
  123. width: 360.w,
  124. height: 329.w,
  125. repeat: true,
  126. ),
  127. ],
  128. );
  129. }
  130. }