intro_page.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import 'package:flutter_screenutil/flutter_screenutil.dart';
  2. import 'package:keyboard/base/base_page.dart';
  3. import 'package:keyboard/module/intro/intro_controller.dart';
  4. import 'package:get/get.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:keyboard/resource/string.gen.dart';
  7. import 'package:lottie/lottie.dart';
  8. import 'package:nested_scroll_views/material.dart';
  9. import '../../resource/assets.gen.dart';
  10. import '../../resource/colors.gen.dart';
  11. import '../../router/app_pages.dart';
  12. class IntroPage extends BasePage<IntroController> {
  13. const IntroPage({Key? key}) : super(key: key);
  14. static void start() {
  15. Get.toNamed(RoutePath.intro);
  16. }
  17. @override
  18. bool immersive() {
  19. return true;
  20. }
  21. @override
  22. Widget buildBody(BuildContext context) {
  23. return Stack(
  24. children: [
  25. Assets.images.bgIntro.image(width: double.infinity, fit: BoxFit.fill),
  26. SizedBox(
  27. width: double.infinity,
  28. height: double.infinity,
  29. child: SafeArea(
  30. child: Stack(
  31. children: [
  32. Column(
  33. crossAxisAlignment: CrossAxisAlignment.center,
  34. children: [
  35. SizedBox(height: 42.w),
  36. Assets.images.iconIntroTitle.image(
  37. width: 189.w,
  38. height: 40.6.w,
  39. fit: BoxFit.contain,
  40. ),
  41. SizedBox(height: 20.w),
  42. Flexible(
  43. child:
  44. NestedPageView(
  45. controller: controller.pageController.value,
  46. onPageChanged: (index) {
  47. controller.onPageChanged(index);
  48. },
  49. children: List.generate(
  50. controller.pageList.length,
  51. (index) =>
  52. buildPage(controller.pageList[index], index),
  53. ),
  54. ),
  55. ),
  56. ],
  57. ),
  58. Column(
  59. mainAxisAlignment: MainAxisAlignment.end,
  60. children: [
  61. buildIndicator(),
  62. SizedBox(height: 50.w),
  63. _buildCustomButton(),
  64. SizedBox(height: 25.w),
  65. _buildGoToLoginButton(),
  66. SizedBox(height: 50.w),
  67. ],
  68. ),
  69. ],
  70. ),
  71. ),
  72. ),
  73. ],
  74. );
  75. }
  76. Widget buildIndicator() {
  77. return Obx(() {
  78. int totalPages = controller.pageList.length;
  79. int currentPage = controller.currentPage.value;
  80. return Container(
  81. width: 50.w,
  82. height: 10.h,
  83. decoration: BoxDecoration(
  84. color: const Color(0xF0F4EEFF),
  85. borderRadius: BorderRadius.circular(5.r),
  86. ),
  87. padding: EdgeInsets.all(2.w),
  88. child: Align(
  89. alignment: Alignment.centerLeft,
  90. child: AnimatedContainer(
  91. duration: Duration(milliseconds: 300),
  92. width: (50.w - 4.w) / totalPages,
  93. height: double.infinity,
  94. margin: EdgeInsets.only(
  95. left: ((50.w - 4.w) / totalPages) * currentPage,
  96. ),
  97. decoration: BoxDecoration(
  98. color: const Color(0xffa084ff),
  99. borderRadius: BorderRadius.circular(3.r),
  100. ),
  101. ),
  102. ),
  103. );
  104. });
  105. }
  106. Widget buildPage(PageBean pageBean, int index) {
  107. return Column(
  108. mainAxisSize: MainAxisSize.min,
  109. crossAxisAlignment: CrossAxisAlignment.center,
  110. mainAxisAlignment: MainAxisAlignment.start,
  111. children: [
  112. pageBean.title,
  113. SizedBox(height: 20.h),
  114. Lottie.asset(
  115. pageBean.animUrl,
  116. width: 360.w,
  117. repeat: true,
  118. fit: BoxFit.contain,
  119. ),
  120. ],
  121. );
  122. }
  123. Widget _buildCustomButton() {
  124. return Container(
  125. height: 48.w,
  126. margin: EdgeInsets.only(left: 50.w, right: 50.w),
  127. child: Material(
  128. color: Colors.transparent,
  129. borderRadius: BorderRadius.circular(50.r),
  130. child: InkWell(
  131. borderRadius: BorderRadius.circular(50.r),
  132. onTap: () {
  133. controller.clickCustomButton();
  134. },
  135. child: Ink(
  136. decoration: BoxDecoration(
  137. gradient: LinearGradient(
  138. begin: Alignment.centerLeft,
  139. end: Alignment.centerRight,
  140. transform: GradientRotation(0.5),
  141. colors: [Color(0xFF7D46FC), Color(0xFFBC87FF)],
  142. ),
  143. borderRadius: BorderRadius.circular(50.r),
  144. boxShadow: [
  145. BoxShadow(
  146. color: Color(0x66BDA8C9),
  147. blurRadius: 10.r,
  148. offset: Offset(0, 4),
  149. spreadRadius: 0,
  150. ),
  151. ],
  152. ),
  153. child: Center(
  154. child: Text(
  155. StringName.customLoveKeyboard,
  156. textAlign: TextAlign.center,
  157. style: TextStyle(
  158. color: Colors.white,
  159. fontSize: 16.sp,
  160. fontWeight: FontWeight.w500,
  161. ),
  162. ),
  163. ),
  164. ),
  165. ),
  166. ),
  167. );
  168. }
  169. _buildGoToLoginButton() {
  170. return InkWell(
  171. onTap: controller.clickLogin,
  172. child: Text(
  173. StringName.goToLogin,
  174. style: TextStyle(
  175. color: const Color(0xFF8649FF),
  176. fontSize: 14.sp,
  177. fontWeight: FontWeight.w500,
  178. ),
  179. ),
  180. );
  181. }
  182. }