Commit e65ec0b1 by yenisleydi

formulario, definicion de rutas y navegacion

parent 39733683
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:primer_practica/src/pages/login_page.dart'; import 'package:primer_practica/src/config/routes.dart';
import 'package:primer_practica/src/pages/home_page.dart';
import 'package:primer_practica/src/pages/articles_page.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Primer practica',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: 'login', // Establece la ruta inicial
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
title: 'Primera practica', routes: getApplicationRoutes(), // Usa las rutas definidas
routes: {
'login' : (_) => ArticlesPage(),
},
initialRoute: 'login',
); );
} }
} }
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:primer_practica/src/pages/login_page.dart';
import 'package:primer_practica/src/pages/home_page.dart';
import 'package:primer_practica/src/pages/articles_page.dart';
Map<String, WidgetBuilder> getApplicationRoutes() {
return <String, WidgetBuilder>{
'login': (BuildContext context) => const LoginPage(),
'home': (BuildContext context) => const HomePage(),
'articles': (BuildContext context) => const ArticlesPage(),
};
}
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ArticlesPage extends StatelessWidget { class ArticlesPage extends StatelessWidget {
const ArticlesPage ({Key? key}) : super(key: key); const ArticlesPage({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -10,7 +10,7 @@ class ArticlesPage extends StatelessWidget { ...@@ -10,7 +10,7 @@ class ArticlesPage extends StatelessWidget {
title: const Text('Articles Page'), title: const Text('Articles Page'),
), ),
body: const Center( body: const Center(
child: Text('Hola articles_page'), child: Text('Hola articles page'),
), ),
); );
} }
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class HomePage extends StatelessWidget { class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key); // Constructor
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar( // Barra de aplicaciones
title: const Text('Home Page'), title: const Text('Home Page'), // Título de la barra
), ),
body: const Center( body: Center( // Centra el contenido
child: Text('Hola home_page'), child: Column( // Dispone los hijos en una columna
mainAxisAlignment: MainAxisAlignment.center, // Centra verticalmente
children: [ // Lista de hijos
const Text('Hola home page'), // Texto
const SizedBox(height: 20), // Tamaño del texto
ElevatedButton( // Botón
onPressed: () { // Acción al presionar
Navigator.pushNamed(context, 'articles'); // Navega a 'articles'
},
child: const Text('Ir a Articles Page'), // Texto del botón
),
],
),
), ),
); );
} }
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class LoginPage extends StatelessWidget { class LoginPage extends StatelessWidget {
const LoginPage({Key? key}) : super(key: key); const LoginPage({Key? key}) : super(key: key); // Constructor
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar( // Barra de aplicaciones en la parte superior
title: const Text('Login Page'), title: const Text('Login Page'), // Título de la barra
), ),
body: const Center( body: Padding( // Espacia el contenido del cuerpo
child: Text('Hola login_page'), padding: const EdgeInsets.all(180.0), // Padding alrededor del contenido
child: Center( // Centra el contenido en la pantalla
child: Column( // Organiza los widgets en una columna vertical
mainAxisAlignment: MainAxisAlignment.center, // Centra verticalmente
children: [ // Lista de widgets en la columna
Image.asset('assets/img/logo_visorus.jpg', height: 100), // Muestra el logo con altura de 100
const SizedBox(height: 80), // Espacio de 80 píxeles entre el logo y el primer campo de texto
TextField( // Campo de texto para el usuario
decoration: const InputDecoration(
labelText: 'Usuario', // Etiqueta del campo de texto
border: OutlineInputBorder(), // Borde del campo de texto
),
),
const SizedBox(height: 20), // Espacio de 20 píxeles entre los campos de texto
TextField( // Campo de texto para la contraseña
obscureText: true, // Oculta el texto introducido
decoration: const InputDecoration(
labelText: 'Contraseña', // Etiqueta del campo de texto
border: OutlineInputBorder(), // Borde del campo de texto
),
),
const SizedBox(height: 20), // Espacio de 20 píxeles antes del botón
ElevatedButton(
onPressed: () { // Acción al presionar el botón
Navigator.pushNamed(context, 'home'); // Navega a la página 'home'
},
child: const Text('Acceder'), // Texto del botón
),
],
),
),
), ),
); );
} }
......
...@@ -57,7 +57,8 @@ flutter: ...@@ -57,7 +57,8 @@ flutter:
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
assets:
- assets/img/
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment