inserida a fonte, e criada a tela de login_screen.dart
This commit is contained in:
105
lib/main.dart
105
lib/main.dart
@@ -1,115 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_app/screens/login_screen.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// is not restarted.
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Invoke "debug painting" (press "p" in the console, choose the
|
||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
||||
// to see the wireframe for each widget.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: LoginScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
96
lib/screens/login_screen.dart
Normal file
96
lib/screens/login_screen.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/colors.dart';
|
||||
import '../widgets/buttom_custom.dart';
|
||||
import '../widgets/input_text.dart';
|
||||
import '../widgets/snackBars.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
final inputLogin = TextEditingController(text: 'teste');
|
||||
final inputSenha = TextEditingController(text: 'senha123');
|
||||
|
||||
verificacao(){
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
if(inputLogin.text == 'teste'){
|
||||
if(inputSenha.text == 'senha123'){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => HomeScreen()),
|
||||
// );
|
||||
}else{
|
||||
showSnackBar(context, 'E-mail não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'E-mail não cadastrado e/ou senha incorreta', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha seu e-mail', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: PaletteColors.white,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.4,height: height * 0.12)
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputLogin,
|
||||
title: 'Login',
|
||||
width: width>900? width * 0.18:width*0.7,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: width>900? width * 0.18:width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputSenha,
|
||||
title: 'Senha',
|
||||
obscure: true,
|
||||
width: width>900? width * 0.18:width*0.7,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
ButtonCustom(
|
||||
widthCustom: 0.7,
|
||||
heightCustom: 0.07,
|
||||
text: "Entrar",
|
||||
size: 14.0,
|
||||
colorText: PaletteColors.white,
|
||||
colorButton: PaletteColors.primaryColor,
|
||||
colorBorder: PaletteColors.primaryColor,
|
||||
onPressed: ()=>verificacao(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
14
lib/utils/colors.dart
Normal file
14
lib/utils/colors.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PaletteColors{
|
||||
static const Color white = Colors.white;
|
||||
static const Color primaryColor = Color(0xffBB0202);
|
||||
static const Color secundColor = Color(0xffFF9E75);
|
||||
static const Color bgColor = Color(0xff3A3A3A);
|
||||
static const Color grey = Color (0xff757575);
|
||||
static const Color greyInput = Color (0xffE1E1E1);
|
||||
static const Color lightGrey = Color(0xffD0D0D0);
|
||||
static const Color midGrey = Color(0xffC4C4C4);
|
||||
static const Color backGrey = Color(0xffE9E9E9);
|
||||
static const Color green = Color(0xff06790c);
|
||||
}
|
||||
45
lib/widgets/buttom_custom.dart
Normal file
45
lib/widgets/buttom_custom.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ButtonCustom extends StatelessWidget{
|
||||
final VoidCallback onPressed;
|
||||
final String text;
|
||||
final double size;
|
||||
final Color colorButton;
|
||||
final Color colorText;
|
||||
final Color colorBorder;
|
||||
final widthCustom;
|
||||
final heightCustom;
|
||||
|
||||
ButtonCustom({
|
||||
required this.onPressed,
|
||||
required this.text,
|
||||
required this.size,
|
||||
required this.colorButton,
|
||||
required this.colorText,
|
||||
required this.colorBorder,
|
||||
this.widthCustom = 1.0,
|
||||
this.heightCustom = 1.0
|
||||
});
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
double width =MediaQuery.of(context).size.width;
|
||||
double height =MediaQuery.of(context).size.height;
|
||||
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: colorButton,
|
||||
minimumSize: Size(width*widthCustom! , height*heightCustom!),
|
||||
side: BorderSide(width: 2,color : colorBorder,),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(text,
|
||||
style: TextStyle(
|
||||
color: colorText,
|
||||
fontSize: size,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
) ,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
84
lib/widgets/input_text.dart
Normal file
84
lib/widgets/input_text.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../utils/colors.dart';
|
||||
|
||||
class InputText extends StatelessWidget {
|
||||
bool obscure;
|
||||
var controller;
|
||||
double fontSize;
|
||||
String title;
|
||||
double width;
|
||||
TextInputType textInputType;
|
||||
int maxLines;
|
||||
Color colorBorder;
|
||||
var onChanged;
|
||||
bool enable;
|
||||
List<TextInputFormatter> inputFormatters;
|
||||
|
||||
InputText({
|
||||
required this.controller,
|
||||
required this.width,
|
||||
this.obscure = false,
|
||||
this.fontSize = 15.0,
|
||||
this.title = '',
|
||||
this.textInputType = TextInputType.text,
|
||||
this.maxLines = 1,
|
||||
this.colorBorder = PaletteColors.grey,
|
||||
this.onChanged = null,
|
||||
this.enable = true,
|
||||
required this.inputFormatters
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: width,
|
||||
child: Text(title,style: TextStyle(fontWeight: FontWeight.bold,fontFamily: 'Nunito'),)
|
||||
),
|
||||
Container(
|
||||
color:PaletteColors.greyInput,
|
||||
width: width,
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: TextFormField(
|
||||
inputFormatters: inputFormatters,
|
||||
keyboardType: textInputType,
|
||||
maxLines: maxLines,
|
||||
onChanged: onChanged,
|
||||
obscureText: this.obscure,
|
||||
controller: this.controller,
|
||||
enabled: enable,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: this.fontSize,
|
||||
fontFamily: 'Nunito'
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1,color: colorBorder)
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: this.fontSize,
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
20
lib/widgets/snackBars.dart
Normal file
20
lib/widgets/snackBars.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void showSnackBar(BuildContext context, String text,Color colors){
|
||||
|
||||
final snackbar = SnackBar(
|
||||
backgroundColor: colors,
|
||||
content: Row(
|
||||
children: [
|
||||
Icon(Icons.info_outline,color: Colors.white),
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Text(text,
|
||||
style: TextStyle(fontSize: 16),),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackbar);
|
||||
}
|
||||
Reference in New Issue
Block a user