splash_view.dart 7.2 KB

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