skip_log_in_screen.dart 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import 'package:app_flowy/user/domain/i_auth.dart';
  2. import 'package:app_flowy/user/presentation/widgets/background.dart';
  3. import 'package:flowy_infra/size.dart';
  4. import 'package:flowy_infra/theme.dart';
  5. import 'package:flowy_infra/uuid.dart';
  6. import 'package:flowy_infra_ui/widget/rounded_button.dart';
  7. import 'package:flowy_infra_ui/widget/spacing.dart';
  8. import 'package:flowy_log/flowy_log.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter_bloc/flutter_bloc.dart';
  11. import 'package:url_launcher/url_launcher.dart';
  12. class SkipLogInScreen extends StatelessWidget {
  13. final IAuthRouter router;
  14. final IAuth authManager;
  15. const SkipLogInScreen({Key? key, required this.router, required this.authManager}) : super(key: key);
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. body: Center(
  20. child: SizedBox(
  21. width: 400,
  22. height: 600,
  23. child: _renderBody(context),
  24. ),
  25. ),
  26. );
  27. }
  28. Widget _renderBody(BuildContext context) {
  29. return Column(
  30. mainAxisAlignment: MainAxisAlignment.center,
  31. children: [
  32. const FlowyLogoTitle(
  33. title: 'Welcome to AppFlowy',
  34. logoSize: Size.square(60),
  35. ),
  36. const VSpace(80),
  37. GoButton(onPressed: () => _autoRegister(context)),
  38. const VSpace(30),
  39. Row(
  40. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  41. children: [
  42. InkWell(
  43. child: const Text(
  44. 'Star on Github',
  45. style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
  46. ),
  47. onTap: () {
  48. _launchURL('https://github.com/AppFlowy-IO/appflowy');
  49. },
  50. ),
  51. InkWell(
  52. child: const Text(
  53. 'Subscribe to Newsletter',
  54. style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
  55. ),
  56. onTap: () {
  57. _launchURL('https://www.appflowy.io/blog');
  58. },
  59. ),
  60. ],
  61. )
  62. ],
  63. );
  64. }
  65. _launchURL(String url) async {
  66. if (await canLaunch(url)) {
  67. await launch(url);
  68. } else {
  69. throw 'Could not launch $url';
  70. }
  71. }
  72. void _autoRegister(BuildContext context) async {
  73. const password = "AppFlowy123@";
  74. final uid = uuid();
  75. final userEmail = "[email protected]";
  76. final result = await authManager.signUp("FlowyUser", password, userEmail);
  77. result.fold(
  78. (newUser) {
  79. router.pushHomeScreen(context, newUser.profile, newUser.workspaceId);
  80. },
  81. (error) {
  82. Log.error(error);
  83. },
  84. );
  85. }
  86. }
  87. class GoButton extends StatelessWidget {
  88. final VoidCallback onPressed;
  89. const GoButton({
  90. Key? key,
  91. required this.onPressed,
  92. }) : super(key: key);
  93. @override
  94. Widget build(BuildContext context) {
  95. final theme = context.watch<AppTheme>();
  96. return RoundedTextButton(
  97. title: 'Let\'s Go',
  98. height: 50,
  99. borderRadius: Corners.s10Border,
  100. color: theme.main1,
  101. onPressed: onPressed,
  102. );
  103. }
  104. }