Просмотр исходного кода

[flutter]:initial version skip login or signup

annie 3 лет назад
Родитель
Сommit
c21709b36f

+ 4 - 6
app_flowy/lib/user/infrastructure/i_splash_impl.dart

@@ -3,6 +3,7 @@ import 'package:app_flowy/user/domain/auth_state.dart';
 import 'package:app_flowy/user/domain/i_auth.dart';
 import 'package:app_flowy/user/domain/i_splash.dart';
 import 'package:app_flowy/user/presentation/sign_in_screen.dart';
+import 'package:app_flowy/user/presentation/skip_log_in_screen.dart';
 import 'package:app_flowy/user/presentation/welcome_screen.dart';
 import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
 import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
@@ -46,12 +47,10 @@ class SplashRoute implements ISplashRoute {
   }
 
   @override
-  void pushHomeScreen(
-      BuildContext context, UserProfile userProfile, String workspaceId) {
+  void pushHomeScreen(BuildContext context, UserProfile userProfile, String workspaceId) {
     Navigator.push(
       context,
-      PageRoutes.fade(() => HomeScreen(userProfile, workspaceId),
-          RouteDurations.slow.inMilliseconds * .001),
+      PageRoutes.fade(() => HomeScreen(userProfile, workspaceId), RouteDurations.slow.inMilliseconds * .001),
     );
   }
 
@@ -59,8 +58,7 @@ class SplashRoute implements ISplashRoute {
   void pushSignInScreen(BuildContext context) {
     Navigator.push(
       context,
-      PageRoutes.fade(() => SignInScreen(router: getIt<IAuthRouter>()),
-          RouteDurations.slow.inMilliseconds * .001),
+      PageRoutes.fade(() => SkipLogInScreen(router: getIt<IAuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
     );
   }
 }

+ 131 - 0
app_flowy/lib/user/presentation/skip_log_in_screen.dart

@@ -0,0 +1,131 @@
+// ignore_for_file: prefer_const_constructors
+
+import 'package:app_flowy/startup/startup.dart';
+import 'package:app_flowy/user/application/sign_in_bloc.dart';
+import 'package:app_flowy/user/domain/i_auth.dart';
+import 'package:app_flowy/user/presentation/widgets/background.dart';
+import 'package:flowy_infra/size.dart';
+import 'package:flowy_infra/theme.dart';
+import 'package:flowy_infra_ui/widget/rounded_button.dart';
+import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
+import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:dartz/dartz.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+class SkipLogInScreen extends StatelessWidget {
+  final IAuthRouter router;
+  const SkipLogInScreen({Key? key, required this.router}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return BlocProvider(
+      create: (context) => getIt<SignInBloc>(),
+      child: BlocListener<SignInBloc, SignInState>(
+        listener: (context, state) {
+          state.successOrFail.fold(
+            () => null,
+            (result) => _handleSuccessOrFail(result, context),
+          );
+        },
+        child: Scaffold(
+          body: SignInForm(router: router),
+        ),
+      ),
+    );
+  }
+
+  void _handleSuccessOrFail(Either<UserProfile, UserError> result, BuildContext context) {
+    result.fold(
+      (user) => router.pushWelcomeScreen(context, user),
+      (error) => showSnapBar(context, error.msg),
+    );
+  }
+}
+
+class SignInForm extends StatelessWidget {
+  final IAuthRouter router;
+  const SignInForm({
+    Key? key,
+    required this.router,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Center(
+      child: SizedBox(
+        width: 600,
+        height: 600,
+        child: Expanded(
+          child: Column(
+            // ignore: prefer_const_literals_to_create_immutables
+            children: [
+              const AuthFormTitle(
+                title: 'Welcome to AppFlowy',
+                logoSize: Size(60, 60),
+              ),
+              const VSpace(80),
+              const GoButton(),
+              const VSpace(30),
+              Row(
+                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+                children: [
+                  // ignore: prefer_const_constructors
+                  InkWell(
+                    child: Text(
+                      'Star on Github',
+                      style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
+                    ),
+                    onTap: () {
+                      _launchURL('https://github.com/AppFlowy-IO/appflowy');
+                    },
+                  ),
+                  HSpace(60),
+                  InkWell(
+                      child: Text(
+                        'Subscribe to Newsletter',
+                        style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
+                      ),
+                      onTap: () {
+                        _launchURL('https://www.appflowy.io/blog');
+                      }),
+                ],
+              )
+            ],
+          ),
+        ),
+      ),
+    );
+  }
+
+  _launchURL(String url) async {
+    if (await canLaunch(url)) {
+      await launch(url);
+    } else {
+      throw 'Could not launch $url';
+    }
+  }
+}
+
+class GoButton extends StatelessWidget {
+  const GoButton({
+    Key? key,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    final theme = context.watch<AppTheme>();
+    return RoundedTextButton(
+      title: 'Let\'s Go',
+      height: 60,
+      borderRadius: Corners.s10Border,
+      color: theme.main1,
+      onPressed: () {
+        //to do: direct to the workspace
+      },
+    );
+  }
+}

+ 5 - 5
app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart

@@ -34,11 +34,11 @@ class QuestionBubble extends StatelessWidget {
               switch (action) {
                 case QuestionBubbleAction.whatsNews:
                   // TODO: annie replace the URL with real ones
-                  _launchURL("https://www.google.com");
+                  _launchURL("https://www.appflowy.io/whatsnew");
                   break;
                 case QuestionBubbleAction.help:
                   // TODO: annie replace the URL with real ones
-                  _launchURL("https://www.google.com");
+                  _launchURL("https://discord.gg/9Q2xaN37tV");
                   break;
               }
             });
@@ -165,7 +165,7 @@ extension QuestionBubbleExtension on QuestionBubbleAction {
   String get name {
     switch (this) {
       case QuestionBubbleAction.whatsNews:
-        return "What's new";
+        return "What's new?";
       case QuestionBubbleAction.help:
         return "Help & Support";
     }
@@ -174,9 +174,9 @@ extension QuestionBubbleExtension on QuestionBubbleAction {
   Widget get emoji {
     switch (this) {
       case QuestionBubbleAction.whatsNews:
-        return const Text('😘', style: TextStyle(fontSize: 16));
+        return const Text('⭐️', style: TextStyle(fontSize: 16));
       case QuestionBubbleAction.help:
-        return const Text('💁🏻', style: TextStyle(fontSize: 16));
+        return const Text('👥', style: TextStyle(fontSize: 16));
     }
   }
 }

+ 1 - 1
app_flowy/pubspec.lock

@@ -934,7 +934,7 @@ packages:
     source: hosted
     version: "1.0.0+1"
   url_launcher:
-    dependency: transitive
+    dependency: "direct main"
     description:
       name: url_launcher
       url: "https://pub.dartlang.org"

+ 1 - 1
app_flowy/pubspec.yaml

@@ -64,7 +64,7 @@ dependencies:
   flutter_svg: ^0.22.0
   flutter_colorpicker: ^0.6.0
   package_info_plus: ^1.3.0
-
+  url_launcher: ^6.0.2
 
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.