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