intro_page.dart 5.8 KB

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