On branch master
Your branch is up to date with 'origin/master'. Changes to be committed: new file: lib/src/app/auth/screens/login.dart modified: lib/src/app/base/screens/splash.dart modified: lib/src/app/recomendagro_app.dart modified: lib/src/router.dart new file: lib/src/shared/utils/responsive/responsive_metrics.dart
This commit is contained in:
parent
674d219ff3
commit
53da5f69dc
194
lib/src/app/auth/screens/login.dart
Normal file
194
lib/src/app/auth/screens/login.dart
Normal file
@ -0,0 +1,194 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:recomendagro/assets/theme/colors.dart';
|
||||
import 'package:recomendagro/src/shared/utils/enums.dart';
|
||||
import 'package:recomendagro/src/shared/utils/responsive/responsive_metrics.dart';
|
||||
import 'package:recomendagro/src/shared/widgets/buttons/simple_button.dart';
|
||||
import 'package:recomendagro/src/shared/widgets/inputs/password_input.dart';
|
||||
|
||||
import '../../../shared/widgets/inputs/simple_input.dart';
|
||||
|
||||
class LoginScreen extends ConsumerStatefulWidget {
|
||||
static String path = '/login';
|
||||
const LoginScreen({ Key? key }) : super(key: key);
|
||||
|
||||
@override
|
||||
ConsumerState<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
Radius radius = const Radius.circular(40);
|
||||
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
bool showpass = false;
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController senhaController = TextEditingController();
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
bool isloading = false;
|
||||
@override
|
||||
void initState() {
|
||||
// Future.delayed(const Duration(seconds: 1)).then((value)async{
|
||||
// SharedPreferences prefs = ref.watch(sharedPreferencesProvider);
|
||||
// if(prefs.containsKey('token') && prefs.getString('token') != null){
|
||||
// // ref.read(profileController).getInfoProfile().then((value) =>{
|
||||
// // NavigationService.navigateReplacementTo('/homebase', arguments: 0)
|
||||
// // })
|
||||
// context.go('/home/dashboard');
|
||||
// }
|
||||
// });
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return Future.value(false);
|
||||
},
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: const PreferredSize(child: SizedBox(), preferredSize: Size.fromHeight(0)),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('lib/assets/images/bg_ouside_login.png'),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 25),
|
||||
SizedBox(
|
||||
height: Metrics.height(context)/3,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
child: Image.asset(
|
||||
'lib/assets/logos/splash_logo.png',
|
||||
fit: BoxFit.fill,
|
||||
width: 180
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: radius,
|
||||
topRight: radius
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 35),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"Fazer Login",
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorLight.text01Color,
|
||||
fontSize: 21
|
||||
)
|
||||
)
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
SimpleInput(
|
||||
title: 'Email',
|
||||
hintText: 'Informe seu email',
|
||||
typeInput: TypInputText.EMAIL,
|
||||
controller: emailController,
|
||||
validator: true,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
PasswordInput(
|
||||
title: 'Senha',
|
||||
hintText: 'Informe sua senha',
|
||||
controller: senhaController,
|
||||
validator: true,
|
||||
onFieldSubmitted: (value) {
|
||||
// onTapLogin();
|
||||
}
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
InkWell(
|
||||
onTap: (){
|
||||
},
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
'Esqueceu a senha?',
|
||||
textAlign: TextAlign.end,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
decoration: TextDecoration.underline,
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 13
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ButtonWidget(
|
||||
label: 'Fazer login',
|
||||
isloading: isloading,
|
||||
onTap: (){
|
||||
|
||||
}
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ButtonWidget(
|
||||
label: 'Não possui conta? Cadastre-se',
|
||||
type: TypeButton.secondary,
|
||||
onTap: (){
|
||||
// context.push(CadastreseScreen.path);
|
||||
}
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
void doLogin() async {
|
||||
// if(_formKey.currentState!.validate()){
|
||||
// setState(() {
|
||||
// isloading = true;
|
||||
// });
|
||||
// await ref.read(authController.notifier).fazerLogin({
|
||||
// 'email': emailController.text,
|
||||
// 'senha': senhaController.text
|
||||
// });
|
||||
// setState(() {
|
||||
// isloading = false;
|
||||
// });
|
||||
// if(!mounted)return;
|
||||
|
||||
// if((ref.read(authController).hasError == false)){
|
||||
// context.go(ListDocumentosScreen.path);
|
||||
// }else{
|
||||
// dialogToastMessage(
|
||||
// context,
|
||||
// message: 'Usuário ou senha inválidos.',
|
||||
// dialogColorType: DialogColorType.WARNING
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:recomendagro/src/app/auth/screens/login.dart';
|
||||
|
||||
class SlapshScreen extends ConsumerStatefulWidget {
|
||||
static String path = '/';
|
||||
@ -18,6 +20,7 @@ class _SlapshScreenState extends ConsumerState<SlapshScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
Future.delayed(const Duration(seconds: 2)).then((value)async{
|
||||
context.go(LoginScreen.path);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
@ -37,12 +40,12 @@ class _SlapshScreenState extends ConsumerState<SlapshScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
child: Image.asset(
|
||||
'lib/assets/logos/splash_logo.png',
|
||||
fit: BoxFit.fill
|
||||
)
|
||||
),
|
||||
// SizedBox(
|
||||
// child: Image.asset(
|
||||
// 'lib/assets/logos/splash_logo.png',
|
||||
// fit: BoxFit.fill
|
||||
// )
|
||||
// ),
|
||||
]
|
||||
)
|
||||
],
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:recomendagro/src/app/auth/screens/login.dart';
|
||||
import 'package:recomendagro/src/app/base/screens/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -22,11 +23,11 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
// // parentNavigatorKey: _rootNavigatorKey,
|
||||
// // builder: (_, state) => const PageEditProfileMobile()
|
||||
// // ),
|
||||
// GoRoute(
|
||||
// path: LoginScreen.path,
|
||||
// parentNavigatorKey: _rootNavigatorKey,
|
||||
// builder: (_, state) => const LoginScreen()
|
||||
// ),
|
||||
GoRoute(
|
||||
path: LoginScreen.path,
|
||||
parentNavigatorKey: _rootNavigatorKey,
|
||||
builder: (_, state) => const LoginScreen()
|
||||
),
|
||||
// GoRoute(
|
||||
// path: CadastreseScreen.path,
|
||||
// parentNavigatorKey: _rootNavigatorKey,
|
||||
|
27
lib/src/shared/utils/responsive/responsive_metrics.dart
Normal file
27
lib/src/shared/utils/responsive/responsive_metrics.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart' show MediaQuery, BuildContext;
|
||||
|
||||
class Metrics {
|
||||
Metrics._();
|
||||
|
||||
static double width(BuildContext context) => MediaQuery.of(context).size.width;
|
||||
static double height(BuildContext context) => MediaQuery.of(context).size.height;
|
||||
|
||||
static DeviceWidth getScreenWidth(BuildContext context) {
|
||||
if (width(context) >= 1440) {
|
||||
return DeviceWidth.lg;
|
||||
} else if (width(context) >= 976) {
|
||||
return DeviceWidth.md;
|
||||
} else if (width(context) >= 576) {
|
||||
return DeviceWidth.sm;
|
||||
} else {
|
||||
return DeviceWidth.xs;
|
||||
}
|
||||
}
|
||||
|
||||
static bool isDesktop(BuildContext context) => getScreenWidth(context) == DeviceWidth.lg;
|
||||
static bool isTablet(BuildContext context) => getScreenWidth(context) == DeviceWidth.md;
|
||||
static bool isCompact(BuildContext context) => getScreenWidth(context) == DeviceWidth.sm;
|
||||
static bool isMobile(BuildContext context) => getScreenWidth(context) == DeviceWidth.xs;
|
||||
}
|
||||
|
||||
enum DeviceWidth { xs, sm, md, lg }
|
Loading…
x
Reference in New Issue
Block a user