mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
[flutter]: config skip screen ui
This commit is contained in:
parent
55ea9e6cae
commit
b8dcc9414d
10 changed files with 78 additions and 91 deletions
|
@ -8,8 +8,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
part 'sign_in_bloc.freezed.dart';
|
part 'sign_in_bloc.freezed.dart';
|
||||||
|
|
||||||
class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
||||||
final IAuth authImpl;
|
final IAuth authManager;
|
||||||
SignInBloc(this.authImpl) : super(SignInState.initial());
|
SignInBloc(this.authManager) : super(SignInState.initial());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<SignInState> mapEventToState(
|
Stream<SignInState> mapEventToState(
|
||||||
|
@ -33,7 +33,7 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
||||||
Stream<SignInState> _performActionOnSignIn(SignInState state) async* {
|
Stream<SignInState> _performActionOnSignIn(SignInState state) async* {
|
||||||
yield state.copyWith(isSubmitting: true, emailError: none(), passwordError: none(), successOrFail: none());
|
yield state.copyWith(isSubmitting: true, emailError: none(), passwordError: none(), successOrFail: none());
|
||||||
|
|
||||||
final result = await authImpl.signIn(state.email, state.password);
|
final result = await authManager.signIn(state.email, state.password);
|
||||||
yield result.fold(
|
yield result.fold(
|
||||||
(userProfile) => state.copyWith(isSubmitting: false, successOrFail: some(left(userProfile))),
|
(userProfile) => state.copyWith(isSubmitting: false, successOrFail: some(left(userProfile))),
|
||||||
(error) => stateFromCode(error),
|
(error) => stateFromCode(error),
|
||||||
|
|
|
@ -3,10 +3,8 @@ import 'package:dartz/dartz.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
abstract class IAuth {
|
abstract class IAuth {
|
||||||
Future<Either<UserProfile, UserError>> signIn(
|
Future<Either<UserProfile, UserError>> signIn(String? email, String? password);
|
||||||
String? email, String? password);
|
Future<Either<UserProfile, UserError>> signUp(String? name, String? password, String? email);
|
||||||
Future<Either<UserProfile, UserError>> signUp(
|
|
||||||
String? name, String? password, String? email);
|
|
||||||
|
|
||||||
Future<Either<Unit, UserError>> signOut();
|
Future<Either<Unit, UserError>> signOut();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ abstract class ISplashUserWatch {
|
||||||
|
|
||||||
abstract class ISplashRoute {
|
abstract class ISplashRoute {
|
||||||
void pushSignInScreen(BuildContext context);
|
void pushSignInScreen(BuildContext context);
|
||||||
|
void pushSkipLoginScreen(BuildContext context);
|
||||||
|
|
||||||
Future<void> pushWelcomeScreen(BuildContext context, UserProfile profile);
|
Future<void> pushWelcomeScreen(BuildContext context, UserProfile profile);
|
||||||
void pushHomeScreen(
|
void pushHomeScreen(BuildContext context, UserProfile profile, String workspaceId);
|
||||||
BuildContext context, UserProfile profile, String workspaceId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,12 @@ class AuthImpl extends IAuth {
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<UserProfile, UserError>> signIn(
|
Future<Either<UserProfile, UserError>> signIn(String? email, String? password) {
|
||||||
String? email, String? password) {
|
|
||||||
return repo.signIn(email: email, password: password);
|
return repo.signIn(email: email, password: password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<UserProfile, UserError>> signUp(
|
Future<Either<UserProfile, UserError>> signUp(String? name, String? password, String? email) {
|
||||||
String? name, String? password, String? email) {
|
|
||||||
return repo.signUp(name: name, password: password, email: email);
|
return repo.signUp(name: name, password: password, email: email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,20 @@ class SplashRoute implements ISplashRoute {
|
||||||
void pushSignInScreen(BuildContext context) {
|
void pushSignInScreen(BuildContext context) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRoutes.fade(() => SkipLogInScreen(router: getIt<IAuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
PageRoutes.fade(() => SignInScreen(router: getIt<IAuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void pushSkipLoginScreen(BuildContext context) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
PageRoutes.fade(
|
||||||
|
() => SkipLogInScreen(
|
||||||
|
router: getIt<IAuthRouter>(),
|
||||||
|
authManager: getIt<IAuth>(),
|
||||||
|
),
|
||||||
|
RouteDurations.slow.inMilliseconds * .001),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class SignInForm extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: AuthFormContainer(
|
child: AuthFormContainer(
|
||||||
children: [
|
children: [
|
||||||
const AuthFormTitle(
|
const FlowyLogoTitle(
|
||||||
title: 'Login to Appflowy',
|
title: 'Login to Appflowy',
|
||||||
logoSize: Size(60, 60),
|
logoSize: Size(60, 60),
|
||||||
),
|
),
|
||||||
|
|
|
@ -53,7 +53,7 @@ class SignUpForm extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: AuthFormContainer(
|
child: AuthFormContainer(
|
||||||
children: [
|
children: [
|
||||||
const AuthFormTitle(
|
const FlowyLogoTitle(
|
||||||
title: 'Sign Up to Appflowy',
|
title: 'Sign Up to Appflowy',
|
||||||
logoSize: Size(60, 60),
|
logoSize: Size(60, 60),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,47 +1,22 @@
|
||||||
// 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/domain/i_auth.dart';
|
||||||
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
||||||
import 'package:flowy_infra/size.dart';
|
import 'package:flowy_infra/size.dart';
|
||||||
import 'package:flowy_infra/theme.dart';
|
import 'package:flowy_infra/theme.dart';
|
||||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.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/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class SkipLogInScreen extends StatelessWidget {
|
class SkipLogInScreen extends StatelessWidget {
|
||||||
final IAuthRouter router;
|
final IAuthRouter router;
|
||||||
const SkipLogInScreen({Key? key, required this.router}) : super(key: key);
|
final IAuth authManager;
|
||||||
|
const SkipLogInScreen({Key? key, required this.router, required this.authManager}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return Scaffold(
|
||||||
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),
|
body: SignInForm(router: router),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleSuccessOrFail(Either<UserProfile, UserError> result, BuildContext context) {
|
|
||||||
result.fold(
|
|
||||||
(user) => router.pushWelcomeScreen(context, user),
|
|
||||||
(error) => showSnapBar(context, error.msg),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,25 +32,23 @@ class SignInForm extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 600,
|
width: 400,
|
||||||
height: 600,
|
height: 600,
|
||||||
child: Expanded(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
// ignore: prefer_const_literals_to_create_immutables
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const AuthFormTitle(
|
const FlowyLogoTitle(
|
||||||
title: 'Welcome to AppFlowy',
|
title: 'Welcome to AppFlowy',
|
||||||
logoSize: Size(60, 60),
|
logoSize: Size.square(60),
|
||||||
),
|
),
|
||||||
const VSpace(80),
|
const VSpace(80),
|
||||||
const GoButton(),
|
GoButton(onPressed: _autoRegister),
|
||||||
const VSpace(30),
|
const VSpace(30),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
// ignore: prefer_const_constructors
|
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: const Text(
|
||||||
'Star on Github',
|
'Star on Github',
|
||||||
style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
|
style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
|
||||||
),
|
),
|
||||||
|
@ -83,21 +56,21 @@ class SignInForm extends StatelessWidget {
|
||||||
_launchURL('https://github.com/AppFlowy-IO/appflowy');
|
_launchURL('https://github.com/AppFlowy-IO/appflowy');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
HSpace(60),
|
const Spacer(),
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: const Text(
|
||||||
'Subscribe to Newsletter',
|
'Subscribe to Newsletter',
|
||||||
style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
|
style: TextStyle(decoration: TextDecoration.underline, color: Colors.blue),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_launchURL('https://www.appflowy.io/blog');
|
_launchURL('https://www.appflowy.io/blog');
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,11 +81,15 @@ class SignInForm extends StatelessWidget {
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _autoRegister() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GoButton extends StatelessWidget {
|
class GoButton extends StatelessWidget {
|
||||||
|
final VoidCallback onPressed;
|
||||||
const GoButton({
|
const GoButton({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.onPressed,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -120,12 +97,10 @@ class GoButton extends StatelessWidget {
|
||||||
final theme = context.watch<AppTheme>();
|
final theme = context.watch<AppTheme>();
|
||||||
return RoundedTextButton(
|
return RoundedTextButton(
|
||||||
title: 'Let\'s Go',
|
title: 'Let\'s Go',
|
||||||
height: 60,
|
height: 50,
|
||||||
borderRadius: Corners.s10Border,
|
borderRadius: Corners.s10Border,
|
||||||
color: theme.main1,
|
color: theme.main1,
|
||||||
onPressed: () {
|
onPressed: onPressed,
|
||||||
//to do: direct to the workspace
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ class SplashScreen extends StatelessWidget {
|
||||||
|
|
||||||
void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
|
void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
|
||||||
Log.error(result.error);
|
Log.error(result.error);
|
||||||
getIt<ISplashRoute>().pushSignInScreen(context);
|
// getIt<ISplashRoute>().pushSignInScreen(context);
|
||||||
|
|
||||||
|
getIt<ISplashRoute>().pushSkipLoginScreen(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ class AuthFormContainer extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthFormTitle extends StatelessWidget {
|
class FlowyLogoTitle extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final Size logoSize;
|
final Size logoSize;
|
||||||
const AuthFormTitle({
|
const FlowyLogoTitle({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.logoSize,
|
this.logoSize = const Size.square(40),
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -43,7 +43,7 @@ class AuthFormTitle extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox.fromSize(
|
SizedBox.fromSize(
|
||||||
size: const Size.square(40),
|
size: logoSize,
|
||||||
child: svg("flowy_logo"),
|
child: svg("flowy_logo"),
|
||||||
),
|
),
|
||||||
const VSpace(30),
|
const VSpace(30),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue