splash_view.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import 'package:animate_do/animate_do.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_spinkit/flutter_spinkit.dart';
  5. import 'package:get/get.dart';
  6. import 'package:nomo/app/base/base_view.dart';
  7. import 'package:nomo/app/widgets/ix_image.dart';
  8. import 'package:nomo/app/widgets/submit_btn.dart';
  9. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  10. import '../../../constants/assets.dart';
  11. import '../../../routes/app_pages.dart';
  12. import '../../../widgets/privacy_agreement.dart';
  13. import '../controllers/splash_controller.dart';
  14. class SplashView extends BaseView<SplashController> {
  15. const SplashView({super.key});
  16. @override
  17. bool get resizeToAvoidBottomInset => false;
  18. @override
  19. Widget buildContent(BuildContext context) {
  20. return SafeArea(
  21. child: Column(
  22. children: [
  23. Expanded(child: _buildContent()),
  24. // 底部内容
  25. _buildBottomContent(),
  26. ],
  27. ),
  28. );
  29. }
  30. // 已登录状态的内容
  31. Widget _buildContent() {
  32. return Center(
  33. child: Stack(
  34. alignment: Alignment.topCenter,
  35. children: [
  36. // 背景世界地图
  37. Obx(
  38. () => AnimatedContainer(
  39. duration: const Duration(milliseconds: 500),
  40. curve: Curves.easeInOut,
  41. transform: Matrix4.translationValues(
  42. 0,
  43. !controller.hasLogin ? -120.w : 0,
  44. 0,
  45. ),
  46. child: Container(
  47. margin: EdgeInsets.only(top: 250.w),
  48. child: IXImage(
  49. source: Assets.splashCenterBg,
  50. width: 356.w,
  51. height: 356.w,
  52. sourceType: ImageSourceType.asset,
  53. ),
  54. ),
  55. ),
  56. ),
  57. // Logo
  58. Obx(
  59. () => AnimatedContainer(
  60. duration: const Duration(milliseconds: 500),
  61. curve: Curves.easeInOut,
  62. transform: Matrix4.translationValues(
  63. 0,
  64. !controller.hasLogin ? -120.w : 0,
  65. 0,
  66. ),
  67. child: Container(
  68. margin: EdgeInsets.only(top: 172.w),
  69. child: IXImage(
  70. source: Assets.splashLogo,
  71. width: 104.w,
  72. height: 148.w,
  73. sourceType: ImageSourceType.asset,
  74. ),
  75. ),
  76. ),
  77. ),
  78. // 文字内容 - 根据 hasLogin 状态渐变显示
  79. Obx(
  80. () => AnimatedOpacity(
  81. opacity: !controller.hasLogin ? 1.0 : 0.0,
  82. duration: const Duration(milliseconds: 1000),
  83. child: FadeIn(
  84. duration: const Duration(milliseconds: 1000),
  85. delay: const Duration(milliseconds: 1500),
  86. child: Container(
  87. margin: EdgeInsets.only(top: 240.w),
  88. child: Text(
  89. 'Secure Your Connection',
  90. style: TextStyle(
  91. fontSize: 28.sp,
  92. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  93. ),
  94. ),
  95. ),
  96. ),
  97. ),
  98. ),
  99. Obx(
  100. () => AnimatedOpacity(
  101. opacity: !controller.hasLogin ? 1.0 : 0.0,
  102. duration: const Duration(milliseconds: 1000),
  103. child: FadeIn(
  104. duration: const Duration(milliseconds: 1000),
  105. delay: const Duration(milliseconds: 1500),
  106. child: Container(
  107. width: 327.w,
  108. margin: EdgeInsets.only(top: 298.w),
  109. padding: EdgeInsets.symmetric(horizontal: 14.w),
  110. child: Text(
  111. 'You can log in or register an account to share membership across different devices.',
  112. textAlign: TextAlign.center,
  113. style: TextStyle(
  114. fontSize: 16.sp,
  115. height: 1.4,
  116. color: Get.reactiveTheme.hintColor,
  117. ),
  118. ),
  119. ),
  120. ),
  121. ),
  122. ),
  123. // 按钮区域
  124. Obx(
  125. () => AnimatedOpacity(
  126. opacity: !controller.hasLogin ? 1.0 : 0.0,
  127. duration: const Duration(milliseconds: 1000),
  128. child: FadeInUp(
  129. duration: const Duration(milliseconds: 1000),
  130. delay: const Duration(milliseconds: 1500),
  131. child: Container(
  132. margin: EdgeInsets.only(top: 420.w),
  133. padding: EdgeInsets.symmetric(horizontal: 14.w),
  134. child: Column(
  135. children: [
  136. // 登录按钮
  137. SubmitButton(
  138. text: 'Log In',
  139. bgColor: Get.reactiveTheme.highlightColor,
  140. onPressed: () => Get.toNamed(Routes.LOGIN),
  141. ),
  142. 20.verticalSpaceFromWidth,
  143. SubmitButton(
  144. text: 'Sign Up',
  145. onPressed: () => Get.toNamed(Routes.SIGNUP),
  146. ),
  147. ],
  148. ),
  149. ),
  150. ),
  151. ),
  152. ),
  153. ],
  154. ),
  155. );
  156. }
  157. // 构建底部内容
  158. Widget _buildBottomContent() {
  159. return Container(
  160. height: 100.w,
  161. alignment: Alignment.bottomCenter,
  162. child: Obx(
  163. () => !controller.hasLogin
  164. ? FadeInUp(
  165. duration: const Duration(milliseconds: 700),
  166. delay: const Duration(milliseconds: 800),
  167. child: PrivacyAgreement(
  168. textColor: Get.reactiveTheme.textTheme.bodyLarge!.color,
  169. linkColor: Get.reactiveTheme.primaryColor,
  170. height: 1.8,
  171. ),
  172. )
  173. : FadeInUp(
  174. duration: const Duration(milliseconds: 600),
  175. child: Column(
  176. mainAxisAlignment: MainAxisAlignment.end,
  177. children: [
  178. Obx(
  179. () => controller.showLoading
  180. ? SpinKitRing(
  181. size: 24.w,
  182. lineWidth: 2.w,
  183. color: Get.reactiveTheme.primaryColor,
  184. )
  185. : const SizedBox.shrink(),
  186. ),
  187. 16.verticalSpaceFromWidth,
  188. Text(
  189. 'V${controller.versionName}',
  190. textAlign: TextAlign.center,
  191. style: TextStyle(
  192. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  193. fontSize: 14.sp,
  194. ),
  195. ),
  196. ],
  197. ),
  198. ),
  199. ),
  200. );
  201. }
  202. }