welcome_page.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_auth/models/config.dart';
  3. import 'package:flutter_auth/pages/welcome/welcome_image.dart';
  4. import 'package:flutter_auth/pages/background.dart';
  5. import 'package:flutter_auth/routes.dart';
  6. import 'package:flutter_auth/views/responsive.dart';
  7. /// Description: welcome page
  8. /// Time : 08/24/2023 Thursday
  9. /// Author : liuyuqi.gov@msn.cn
  10. class WelcomePage extends StatefulWidget {
  11. const WelcomePage({super.key});
  12. @override
  13. State<WelcomePage> createState() => _WelcomePageState();
  14. }
  15. class _WelcomePageState extends State<WelcomePage> {
  16. @override
  17. Widget build(BuildContext context) {
  18. return Background(
  19. child: SingleChildScrollView(
  20. child: SafeArea(
  21. child: Responsive(
  22. mobile: buildWelcomeMobile(), desktop: buildWelcomeDesktop()),
  23. ),
  24. ));
  25. }
  26. Widget buildWelcomeMobile() {
  27. return Column(
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. children: [
  30. const WelcomeImage(),
  31. Row(
  32. children: [
  33. const Spacer(),
  34. Expanded(
  35. flex: 8,
  36. child: buildLoginAndSignupBtn(),
  37. ),
  38. const Spacer()
  39. ],
  40. )
  41. ],
  42. );
  43. }
  44. Widget buildWelcomeDesktop() {
  45. return Row(
  46. mainAxisAlignment: MainAxisAlignment.end,
  47. children: [
  48. const Expanded(child: WelcomeImage()),
  49. Expanded(
  50. child: Row(
  51. mainAxisAlignment: MainAxisAlignment.center,
  52. children: [
  53. SizedBox(
  54. width: 450,
  55. child: buildLoginAndSignupBtn(),
  56. )
  57. ],
  58. ))
  59. ],
  60. );
  61. }
  62. Widget buildLoginAndSignupBtn() {
  63. return Column(
  64. children: [
  65. Hero(
  66. tag: "login_btn",
  67. child: ElevatedButton(
  68. child: const Text("登录"),
  69. onPressed: () {
  70. // Navigator.push(context, MaterialPageRoute(builder: (context) {
  71. // return const LoginPage();
  72. // }));
  73. Routes.go(context, Routes.login);
  74. },
  75. ),
  76. ),
  77. const SizedBox(
  78. height: 16,
  79. ),
  80. ElevatedButton(
  81. onPressed: () {
  82. Routes.go(context, Routes.register);
  83. },
  84. style: ElevatedButton.styleFrom(
  85. backgroundColor: kPrimaryLightColor, elevation: 0),
  86. child: const Text(
  87. "注册",
  88. style: TextStyle(color: Colors.black),
  89. ),
  90. ),
  91. ],
  92. );
  93. }
  94. }