criada alguns widgets padrões e ajustada a tela de login

This commit is contained in:
Reginaldo
2023-03-21 18:13:54 -03:00
parent 02b9468422
commit 25a5cb6f15
10 changed files with 233 additions and 76 deletions

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rkm/screens/login_screen.dart'; import 'package:rkm/utils/color_palette.dart';
import 'package:rkm/utils/routes.dart'; import 'package:rkm/utils/routes.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
@@ -10,8 +10,13 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
theme: ThemeData(
primaryColor: ColorPalette.primary,
appBarTheme: AppBarTheme(
color: ColorPalette.primary
)
),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
home: LoginScreen(),
initialRoute: '/login', initialRoute: '/login',
routes: routes, routes: routes,
); );

View File

@@ -11,6 +11,7 @@ class _HomeScreenState extends State<HomeScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('Home')),
body: Container( body: Container(
child: Center( child: Center(
child: Text('home') child: Text('home')

View File

@@ -1,5 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:rkm/utils/color_palette.dart';
import 'package:rkm/utils/const_variable.dart';
import 'package:rkm/widgets/button_default.dart'; import 'package:rkm/widgets/button_default.dart';
import 'package:rkm/widgets/input_text.dart';
import 'package:rkm/widgets/text_default.dart';
class LoginScreen extends StatefulWidget { class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key); const LoginScreen({Key? key}) : super(key: key);
@@ -9,19 +14,112 @@ class LoginScreen extends StatefulWidget {
} }
class _LoginScreenState extends State<LoginScreen> { class _LoginScreenState extends State<LoginScreen> {
var inputUser = TextEditingController();
var inputPassword = TextEditingController();
String error = '';
String? now;
String? selectCity;
checkLogin(){
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text == 'teste' && inputPassword.text == '123'){
if(selectCity!=null){
if(selectCity=='Piracicaba'){
setState(() {
error = '';
inputPassword.clear();
inputUser.clear();
selectCity = null;
});
Navigator.pushNamed(context, '/home');
}else{
setState(() {
error = 'Unidade Inválida';
});
}
}else{
setState(() {
error = 'Selecione sua unidade';
});
}
}else{
setState(() {
error = 'Usuário/senha inválido(s)';
});
}
}
@override
void initState() {
super.initState();
setState(() {
now = DateFormat('dd/MM/yyyy kk:mm:ss').format(DateTime.now());
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold( return Scaffold(
appBar: AppBar(
title: TextDefault(text: 'Login',fontSize: 30,color: ColorPalette.white),
),
bottomSheet: Padding(
padding: const EdgeInsets.all(8.0),
child: TextDefault(
text: 'Última sincronização $now',
fontSize: 20,
color: ColorPalette.black54,
),
),
body: Container( body: Container(
child: Center( child: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text('Login'), TextDefault(text: 'Login',fontSize: 30),
SizedBox(height: 10),
Container(
width: width*0.6,
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: TextDefault(text: 'Selecione a cidade'),
value: selectCity,
items: ConstVariable().itensCity.map((value) => DropdownMenuItem(
value: value,
child: TextDefault(
text: value,
),
)
).toList(),
onChanged: (value){
setState(() {
selectCity = value!;
});
}
),
),
),
InputText(
hint: 'Usuário',
controller: inputUser,
width: width*0.6
),
SizedBox(height: 10),
InputText(
hint: 'Senha',
obscure: true,
controller: inputPassword,
width: width*0.6
),
SizedBox(height: 10),
TextDefault(text: error,color: ColorPalette.red),
ButtonDefault( ButtonDefault(
onPressed: ()=>Navigator.pushNamed(context, '/home'), onPressed: ()=>checkLogin(),
title: 'Entrar' title: 'Entrar'
) ),
], ],
) )
), ),

View File

@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
class ColorPalette{
static const Color white = Colors.white;
static const Color red = Colors.red;
static const Color primary = Color(0xff408CB3);
static const Color border = Color(0xff86B6CD);
static const Color black54 = Colors.black54;
}

View File

@@ -0,0 +1,31 @@
class ConstVariable{
List<String> itensCity = [
'Anhembi',
'Aparecida',
'Batatais',
'Cabreúva',
'Casa Branca',
'Descalvado',
'Extrema',
'Francisco Morato',
'Franco da Rocha',
'Igaraçu do Tiete',
'Itápolis',
'Itirapina',
'Ituverava',
'Jardinópolis',
'Laranjal Paulista',
'Macatuba',
'Mairiporã',
'Mococa',
'Morro Agudo',
'Pardinho',
'Pederneiras',
'Piracicaba',
'Porto Ferreira',
'Santa Rita',
'Santo Antonio da Alegria',
'Tapiratiba'
];
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rkm/utils/color_palette.dart';
class ButtonDefault extends StatelessWidget { class ButtonDefault extends StatelessWidget {
var onPressed; var onPressed;
String title; String title;
@@ -8,8 +9,8 @@ class ButtonDefault extends StatelessWidget {
ButtonDefault({ ButtonDefault({
required this.onPressed, required this.onPressed,
required this.title, required this.title,
this.background = Colors.black38, this.background = ColorPalette.primary,
this.textColor = Colors.white this.textColor = ColorPalette.white
}); });
@override @override

View File

@@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:rkm/utils/color_palette.dart';
class InputText extends StatelessWidget {
bool obscure;
var controller;
double fontSize;
String hint;
double width;
InputText({
required this.controller,
required this.width,
this.obscure = false,
this.fontSize = 20.0,
this.hint = '',
});
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: ColorPalette.border
),
width: width,
child: TextFormField(
obscureText: this.obscure,
controller: this.controller,
style: TextStyle(
color: ColorPalette.white,
fontSize: this.fontSize,
),
decoration: InputDecoration(
border: InputBorder.none,
hintText: this.hint,
hintStyle: TextStyle(
color: ColorPalette.white,
fontSize: this.fontSize,
)
)
),
);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:rkm/utils/color_palette.dart';
class TextDefault extends StatelessWidget {
String text;
double fontSize;
Color color;
TextDefault({
required this.text,
this.fontSize = 20.0,
this.color = ColorPalette.border
});
@override
Widget build(BuildContext context) {
return Text(
text,
style: TextStyle(
fontSize: fontSize,
color: color
),
);
}
}

View File

@@ -67,6 +67,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.18.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:

View File

@@ -1,91 +1,25 @@
name: rkm name: rkm
description: RKM AB 2.0. description: RKM AB 2.0.
# The following line prevents the package from being accidentally published to publish_to: 'none'
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: '>=2.18.6 <3.0.0' sdk: '>=2.18.6 <3.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
intl:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter: flutter:
# The following line ensures that the Material Icons font is uses-material-design: true
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages