From 868ac401d5e0a45d6b66bea813dda4241d93dbcc Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Mon, 20 Nov 2023 13:45:39 +0200 Subject: Added login and routes page --- lib/login.dart | 48 ++++++++++++++++++++++++++++++++++++++++++++ lib/main.dart | 62 ++++++++++----------------------------------------------- lib/routes.dart | 47 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 51 deletions(-) create mode 100644 lib/routes.dart diff --git a/lib/login.dart b/lib/login.dart index e69de29..cae97a3 100644 --- a/lib/login.dart +++ b/lib/login.dart @@ -0,0 +1,48 @@ +import 'package:flutter/material.dart'; + +class LoginPage extends StatelessWidget { + final TextEditingController emailController = TextEditingController(); + final TextEditingController passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Login')), + body: Padding( + padding: EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextField( + controller: emailController, + keyboardType: TextInputType.emailAddress, + decoration: InputDecoration( + labelText: 'Email', + border: OutlineInputBorder(), + ), + ), + SizedBox(height: 12.0), + TextField( + controller: passwordController, + obscureText: true, + decoration: InputDecoration( + labelText: 'Password', + border: OutlineInputBorder(), + ), + ), + SizedBox(height: 20.0), + ElevatedButton( + onPressed: () { + // Perform the login action here + // For now, let's just print the credentials + print('Email: ${emailController.text.trim()}'); + print('Password: ${passwordController.text.trim()}'); + }, + child: Text('Login'), + ), + ], + ), + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index d5f9762..dc8ba74 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,10 @@ import 'package:flutter/material.dart'; +import 'routes.dart'; +import 'login.dart'; -void main() => runApp(MyApp()); +void main() { + runApp(MyApp()); +} class MyApp extends StatelessWidget { @override @@ -9,57 +13,13 @@ class MyApp extends StatelessWidget { title: 'Carpool App', theme: ThemeData( primarySwatch: Colors.blue, + visualDensity: VisualDensity.adaptivePlatformDensity, ), - home: LoginPage(), - ); - } -} - -class LoginPage extends StatelessWidget { - final TextEditingController emailController = TextEditingController(); - final TextEditingController passwordController = TextEditingController(); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('Login'), - ), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextField( - controller: emailController, - keyboardType: TextInputType.emailAddress, - decoration: InputDecoration(labelText: 'Email'), - ), - SizedBox(height: 16.0), - TextField( - controller: passwordController, - obscureText: true, - decoration: InputDecoration(labelText: 'Password'), - ), - SizedBox(height: 32.0), - ElevatedButton( - onPressed: () { - // Handle login button press - // Add your authentication logic here - }, - child: Text('Login'), - ), - SizedBox(height: 16.0), - TextButton( - onPressed: () { - // Navigate to the sign-up page - // Add your navigation logic here - }, - child: Text('Don\'t have an account? Sign up'), - ), - ], - ), - ), + initialRoute: '/routes', // Set the initial route to the login page + routes: { + '/login': (context) => LoginPage(), + '/routes': (context) => RoutesPage(), + }, ); } } diff --git a/lib/routes.dart b/lib/routes.dart new file mode 100644 index 0000000..8898922 --- /dev/null +++ b/lib/routes.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; + +class Route { + final String name; + final String startLocation; + final String endLocation; + + Route( + {required this.name, + required this.startLocation, + required this.endLocation}); +} + +class RoutesPage extends StatelessWidget { + final List dummyRoutes = [ + Route( + name: 'Morning Ride - Gate 3 to Abdu-Basha', + startLocation: 'Gate 3', + endLocation: 'Abdu-Basha'), + Route( + name: 'Afternoon Ride - Abdu-Basha to Gate 3', + startLocation: 'Abdu-Basha', + endLocation: 'Gate 3'), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Routes')), + body: ListView.builder( + itemCount: dummyRoutes.length, + itemBuilder: (BuildContext context, int index) { + final Route route = dummyRoutes[index]; + return ListTile( + title: Text(route.name), + subtitle: + Text('From: ${route.startLocation} - To: ${route.endLocation}'), + onTap: () { + // Handle route selection here, if needed + print('Selected route: ${route.name}'); + }, + ); + }, + ), + ); + } +} -- cgit v1.2.3