From 25a5cb6f15c507716502223e812e5e05794c44a9 Mon Sep 17 00:00:00 2001 From: Reginaldo Date: Tue, 21 Mar 2023 18:13:54 -0300 Subject: [PATCH] =?UTF-8?q?criada=20alguns=20widgets=20padr=C3=B5es=20e=20?= =?UTF-8?q?ajustada=20a=20tela=20de=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 9 ++- lib/screens/home_screen.dart | 1 + lib/screens/login_screen.dart | 104 +++++++++++++++++++++++++++++++- lib/utils/color_palette.dart | 8 +++ lib/utils/const_variable.dart | 31 ++++++++++ lib/widgets/button_default.dart | 5 +- lib/widgets/input_text.dart | 46 ++++++++++++++ lib/widgets/text_default.dart | 26 ++++++++ pubspec.lock | 7 +++ pubspec.yaml | 72 +--------------------- 10 files changed, 233 insertions(+), 76 deletions(-) create mode 100644 lib/utils/color_palette.dart create mode 100644 lib/utils/const_variable.dart create mode 100644 lib/widgets/input_text.dart create mode 100644 lib/widgets/text_default.dart diff --git a/lib/main.dart b/lib/main.dart index 153b58b..b3e0528 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ 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'; void main() { runApp(const MyApp()); @@ -10,8 +10,13 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( + theme: ThemeData( + primaryColor: ColorPalette.primary, + appBarTheme: AppBarTheme( + color: ColorPalette.primary + ) + ), debugShowCheckedModeBanner: false, - home: LoginScreen(), initialRoute: '/login', routes: routes, ); diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 01ab135..3dce65f 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -11,6 +11,7 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( + appBar: AppBar(title: Text('Home')), body: Container( child: Center( child: Text('home') diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index c668efd..b6f39ef 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -1,5 +1,10 @@ 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/input_text.dart'; +import 'package:rkm/widgets/text_default.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @@ -9,19 +14,112 @@ class LoginScreen extends StatefulWidget { } class _LoginScreenState extends State { + + 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 Widget build(BuildContext context) { + + double width = MediaQuery.of(context).size.width; + 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( child: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text('Login'), + TextDefault(text: 'Login',fontSize: 30), + SizedBox(height: 10), + Container( + width: width*0.6, + child: DropdownButtonHideUnderline( + child: DropdownButton( + 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( - onPressed: ()=>Navigator.pushNamed(context, '/home'), + onPressed: ()=>checkLogin(), title: 'Entrar' - ) + ), ], ) ), diff --git a/lib/utils/color_palette.dart b/lib/utils/color_palette.dart new file mode 100644 index 0000000..8e1364a --- /dev/null +++ b/lib/utils/color_palette.dart @@ -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; +} \ No newline at end of file diff --git a/lib/utils/const_variable.dart b/lib/utils/const_variable.dart new file mode 100644 index 0000000..3f08034 --- /dev/null +++ b/lib/utils/const_variable.dart @@ -0,0 +1,31 @@ + +class ConstVariable{ + List 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' + ]; +} \ No newline at end of file diff --git a/lib/widgets/button_default.dart b/lib/widgets/button_default.dart index 3c502d8..9744faf 100644 --- a/lib/widgets/button_default.dart +++ b/lib/widgets/button_default.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:rkm/utils/color_palette.dart'; class ButtonDefault extends StatelessWidget { var onPressed; String title; @@ -8,8 +9,8 @@ class ButtonDefault extends StatelessWidget { ButtonDefault({ required this.onPressed, required this.title, - this.background = Colors.black38, - this.textColor = Colors.white + this.background = ColorPalette.primary, + this.textColor = ColorPalette.white }); @override diff --git a/lib/widgets/input_text.dart b/lib/widgets/input_text.dart new file mode 100644 index 0000000..2a55042 --- /dev/null +++ b/lib/widgets/input_text.dart @@ -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, + ) + ) + ), + ); + } +} diff --git a/lib/widgets/text_default.dart b/lib/widgets/text_default.dart new file mode 100644 index 0000000..5c4bde4 --- /dev/null +++ b/lib/widgets/text_default.dart @@ -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 + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 0f3a736..eea8c42 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -67,6 +67,13 @@ packages: description: flutter source: sdk version: "0.0.0" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.18.0" lints: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d1bdc49..298dd5b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,91 +1,25 @@ name: rkm description: RKM AB 2.0. -# The following line prevents the package from being accidentally published to -# 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. +publish_to: 'none' version: 1.0.0+1 environment: 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: 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 + intl: dev_dependencies: flutter_test: 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 -# 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: - # The following line ensures that the Material Icons font is - # 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 + uses-material-design: true \ No newline at end of file