mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
[flutter]:initial version skip login or signup
This commit is contained in:
parent
c90cdb90d7
commit
c21709b36f
5 changed files with 142 additions and 13 deletions
|
@ -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_auth.dart';
|
||||||
import 'package:app_flowy/user/domain/i_splash.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/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/user/presentation/welcome_screen.dart';
|
||||||
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
|
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
||||||
|
@ -46,12 +47,10 @@ class SplashRoute implements ISplashRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void pushHomeScreen(
|
void pushHomeScreen(BuildContext context, UserProfile userProfile, String workspaceId) {
|
||||||
BuildContext context, UserProfile userProfile, String workspaceId) {
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRoutes.fade(() => HomeScreen(userProfile, workspaceId),
|
PageRoutes.fade(() => HomeScreen(userProfile, workspaceId), RouteDurations.slow.inMilliseconds * .001),
|
||||||
RouteDurations.slow.inMilliseconds * .001),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +58,7 @@ class SplashRoute implements ISplashRoute {
|
||||||
void pushSignInScreen(BuildContext context) {
|
void pushSignInScreen(BuildContext context) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRoutes.fade(() => SignInScreen(router: getIt<IAuthRouter>()),
|
PageRoutes.fade(() => SkipLogInScreen(router: getIt<IAuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
||||||
RouteDurations.slow.inMilliseconds * .001),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
131
app_flowy/lib/user/presentation/skip_log_in_screen.dart
Normal file
131
app_flowy/lib/user/presentation/skip_log_in_screen.dart
Normal file
|
@ -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
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,11 +34,11 @@ class QuestionBubble extends StatelessWidget {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case QuestionBubbleAction.whatsNews:
|
case QuestionBubbleAction.whatsNews:
|
||||||
// TODO: annie replace the URL with real ones
|
// TODO: annie replace the URL with real ones
|
||||||
_launchURL("https://www.google.com");
|
_launchURL("https://www.appflowy.io/whatsnew");
|
||||||
break;
|
break;
|
||||||
case QuestionBubbleAction.help:
|
case QuestionBubbleAction.help:
|
||||||
// TODO: annie replace the URL with real ones
|
// TODO: annie replace the URL with real ones
|
||||||
_launchURL("https://www.google.com");
|
_launchURL("https://discord.gg/9Q2xaN37tV");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -165,7 +165,7 @@ extension QuestionBubbleExtension on QuestionBubbleAction {
|
||||||
String get name {
|
String get name {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case QuestionBubbleAction.whatsNews:
|
case QuestionBubbleAction.whatsNews:
|
||||||
return "What's new";
|
return "What's new?";
|
||||||
case QuestionBubbleAction.help:
|
case QuestionBubbleAction.help:
|
||||||
return "Help & Support";
|
return "Help & Support";
|
||||||
}
|
}
|
||||||
|
@ -174,9 +174,9 @@ extension QuestionBubbleExtension on QuestionBubbleAction {
|
||||||
Widget get emoji {
|
Widget get emoji {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case QuestionBubbleAction.whatsNews:
|
case QuestionBubbleAction.whatsNews:
|
||||||
return const Text('😘', style: TextStyle(fontSize: 16));
|
return const Text('⭐️', style: TextStyle(fontSize: 16));
|
||||||
case QuestionBubbleAction.help:
|
case QuestionBubbleAction.help:
|
||||||
return const Text('💁🏻', style: TextStyle(fontSize: 16));
|
return const Text('👥', style: TextStyle(fontSize: 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,7 +934,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0+1"
|
version: "1.0.0+1"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: url_launcher
|
name: url_launcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|
|
@ -64,7 +64,7 @@ dependencies:
|
||||||
flutter_svg: ^0.22.0
|
flutter_svg: ^0.22.0
|
||||||
flutter_colorpicker: ^0.6.0
|
flutter_colorpicker: ^0.6.0
|
||||||
package_info_plus: ^1.3.0
|
package_info_plus: ^1.3.0
|
||||||
|
url_launcher: ^6.0.2
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue