Auth
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../application/auth/auth_bloc.dart';
|
||||
import '../common/theme/theme.dart';
|
||||
import '../common/constant/app_constant.dart';
|
||||
import '../injection.dart';
|
||||
@@ -18,12 +20,15 @@ class _AppWidgetState extends State<AppWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: AppConstant.appName,
|
||||
theme: ThemeApp.theme,
|
||||
routerConfig: _appRouter.config(
|
||||
navigatorObservers: () => <NavigatorObserver>[AppRouteObserver()],
|
||||
return MultiBlocProvider(
|
||||
providers: [BlocProvider(create: (context) => getIt<AuthBloc>())],
|
||||
child: MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: AppConstant.appName,
|
||||
theme: ThemeApp.theme,
|
||||
routerConfig: _appRouter.config(
|
||||
navigatorObservers: () => <NavigatorObserver>[AppRouteObserver()],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../common/extension/extension.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../application/auth/auth_bloc.dart';
|
||||
import '../../../../application/auth/set_password/set_password_form_bloc.dart';
|
||||
import '../../../../injection.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
@@ -27,6 +28,7 @@ class CreatePasswordPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
(data) {
|
||||
AppFlushbar.showSuccess(context, data.message);
|
||||
Future.delayed(Duration(milliseconds: 1000), () {
|
||||
context.read<AuthBloc>().add(AuthEvent.fetchCurrentUser());
|
||||
context.router.replaceAll([MainRoute()]);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../application/auth/auth_bloc.dart';
|
||||
import '../../../../application/auth/login_form/login_form_bloc.dart';
|
||||
import '../../../../injection.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
@@ -26,6 +27,7 @@ class PasswordPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
(data) {
|
||||
AppFlushbar.showSuccess(context, data.message);
|
||||
Future.delayed(Duration(milliseconds: 1000), () {
|
||||
context.read<AuthBloc>().add(AuthEvent.fetchCurrentUser());
|
||||
context.router.replaceAll([MainRoute()]);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../application/auth/auth_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../components/assets/assets.gen.dart';
|
||||
import '../../router/app_router.gr.dart';
|
||||
@@ -54,7 +56,9 @@ class _SplashPageState extends State<SplashPage>
|
||||
|
||||
void _navigateToHome() {
|
||||
Timer(const Duration(milliseconds: 2500), () {
|
||||
context.router.push(OnboardingRoute());
|
||||
if (mounted) {
|
||||
context.read<AuthBloc>().add(const AuthEvent.fetchCurrentUser());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,53 +70,63 @@ class _SplashPageState extends State<SplashPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [AppColor.backgroundLight, AppColor.background],
|
||||
return BlocListener<AuthBloc, AuthState>(
|
||||
listenWhen: (previous, current) => previous.status != current.status,
|
||||
listener: (context, state) {
|
||||
if (state.isAuthenticated) {
|
||||
context.router.replace(const MainRoute());
|
||||
} else {
|
||||
context.router.replace(const OnboardingRoute());
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [AppColor.backgroundLight, AppColor.background],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _logoController,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _logoScaleAnimation.value,
|
||||
child: Opacity(
|
||||
opacity: _logoOpacityAnimation.value,
|
||||
child: Container(
|
||||
width: 140,
|
||||
height: 140,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: AppColor.primaryGradient,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
child: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _logoController,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _logoScaleAnimation.value,
|
||||
child: Opacity(
|
||||
opacity: _logoOpacityAnimation.value,
|
||||
child: Container(
|
||||
width: 140,
|
||||
height: 140,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: AppColor.primaryGradient,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primaryWithOpacity(0.4),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(0, 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primaryWithOpacity(0.4),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(0, 12),
|
||||
child: ClipOval(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Assets.images.logo.image(fit: BoxFit.contain),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipOval(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Assets.images.logo.image(fit: BoxFit.contain),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user