intro_page.dart 5.8 KB

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