0% found this document useful (0 votes)
10 views10 pages

Adviksha (1) - Copy

The document contains a Flutter application for an admin dashboard that includes login, rickshaw registration, and business registration functionalities. It features a user interface with forms for entering data, validation checks, and navigation between different pages. The application utilizes Material Design components and provides feedback through SnackBars for user actions.

Uploaded by

prachi naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

Adviksha (1) - Copy

The document contains a Flutter application for an admin dashboard that includes login, rickshaw registration, and business registration functionalities. It features a user interface with forms for entering data, validation checks, and navigation between different pages. The application utilizes Material Design components and provides feedback through SnackBars for user actions.

Uploaded by

prachi naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

main.

dart

import 'package:flutter/material.dart';
import 'rickshaw_registration.dart';
import 'business_registration.dart';

void main() {
runApp(RickshawAdminApp());
}

class RickshawAdminApp extends StatelessWidget {


@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AdViksha Admin',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal),
useMaterial3: true,
),
home: AdminLoginPage(),
debugShowCheckedModeBanner: false,
);
}
}

// -------------------- ADMIN LOGIN PAGE --------------------


class AdminLoginPage extends StatefulWidget {
@override
_AdminLoginPageState createState() => _AdminLoginPageState();
}

class _AdminLoginPageState extends State<AdminLoginPage> {


final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
bool _isPasswordVisible = false;

void _login() {
if (_emailController.text.trim() == "[email protected]" &&
_passwordController.text.trim() == "admin123") {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Welcome Admin!')),
);

Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => AdminDashboardPage()),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Invalid email or password!')),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green[50],
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/adviksha logo.png', height: 150),
SizedBox(height: 10),
Text(
'Admin Login',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold,
color: Colors.teal),
),
SizedBox(height: 10),
_buildTextField(_emailController, 'Email', Icons.email),
SizedBox(height: 10),
_buildTextField(_passwordController, 'Password', Icons.lock,
obscure: true),
SizedBox(height: 10),
// Login Button
ElevatedButton(
onPressed: _login,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white70,
shape: RoundedRectangleBorder(borderRadius:
BorderRadius.circular(8)),
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 40),
),
child: Text('Login', style: TextStyle(fontSize: 14)),
),
//Forgot Password Button
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Forgot Password clicked! Implement
reset logic here.')),
);
// You can navigate to a password reset page here instead
},
child: Text(
'Forgot Password?',
style: TextStyle(color: Colors.red, fontSize: 14, fontWeight:
FontWeight.bold),
),
),
],
),
),
),
),
),
);
}

Widget _buildTextField(TextEditingController controller, String label, IconData


icon, {bool obscure = false}) {
return TextField(
controller: controller,
obscureText: obscure && !_isPasswordVisible,
decoration: InputDecoration(
labelText: label,
prefixIcon: Icon(icon, color: Colors.black26),
suffixIcon: obscure
? IconButton(
icon: Icon(_isPasswordVisible ? Icons.visibility : Icons.visibility_off,
color: Colors.black26),
onPressed: () {
setState(() {
_isPasswordVisible = !_isPasswordVisible;
});
},
)
: null,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
),
);
}
}

// -------------------- ADMIN DASHBOARD PAGE --------------------


class AdminDashboardPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlueAccent[50],
drawer: _buildDrawer(context),
appBar: AppBar(
backgroundColor: Colors.teal,
title: Image.asset('assets/images/adviksha logo.png', height: 100),
actions: [
IconButton(
icon: Icon(Icons.logout, color: Colors.white),
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => AdminLoginPage()),
);
},
),
],
),
body: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_buildDashboardBox('Campaigning', Icons.campaign),
SizedBox(height: 15),
_buildDashboardBox('Registered Businesses', Icons.business),
SizedBox(height: 15),
_buildDashboardBox('Registered Rickshaw', Icons.electric_rickshaw),
],
),
),
);
}

Widget _buildDrawer(BuildContext context) {


return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(color: Colors.teal),
child: Text('Admin Menu', style: TextStyle(fontSize: 24, color:
Colors.white)),
),
ListTile(
leading: Icon(Icons.electric_rickshaw),
title: Text('Rickshaw'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) =>
RickshawRegistrationPage()));
},
),
ListTile(
leading: Icon(Icons.business),
title: Text('Business'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) =>
BusinessRegistrationPage()));
},
),
],
),
);
}

Widget _buildDashboardBox(String title, IconData icon) {


return Container(
height: 100,
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.black),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 3,
offset: Offset(2, 2),
),
],
),
child: Row(
children: [
Icon(icon, size: 40, color: Colors.teal),
SizedBox(width: 16),
Text(title, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
],
),
);
}
}

***********************************************************************************
****************************************************

rickshaw registration.dart

import 'package:flutter/material.dart';
import 'main.dart'; // Import the Dashboard page

class RickshawRegistrationPage extends StatefulWidget {


@override
_RickshawRegistrationPageState createState() => _RickshawRegistrationPageState();
}

class _RickshawRegistrationPageState extends State<RickshawRegistrationPage> {


final TextEditingController _driverNameController = TextEditingController();
final TextEditingController _licenseNumberController = TextEditingController();
final TextEditingController _phoneNumberController = TextEditingController();
final TextEditingController _vehicleNumberController = TextEditingController();

String? _selectedArea; // Dropdown value

void _registerRickshaw() {
if (_driverNameController.text.isNotEmpty &&
_licenseNumberController.text.isNotEmpty &&
_phoneNumberController.text.isNotEmpty &&
_vehicleNumberController.text.isNotEmpty &&
_selectedArea != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Rickshaw Registered Successfully!')),
);

// Clear fields after successful registration


_driverNameController.clear();
_licenseNumberController.clear();
_phoneNumberController.clear();
_vehicleNumberController.clear();
setState(() {
_selectedArea = null; // Reset dropdown
});
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Please fill all fields')),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF006A4E),
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white), // Back arrow
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => AdminDashboardPage()),
);
},
),
title: Text('Rickshaw Registration', style: TextStyle(color:
Colors.white)),
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF006A4E), Color(0xFFDAA520)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(borderRadius:
BorderRadius.circular(12)),
margin: EdgeInsets.symmetric(horizontal: 30),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/adviksha logo.png', height: 150),
SizedBox(height: 10),
Text(
'Register Your Rickshaw',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold,
color: Color(0xFF006A4E)),
),
SizedBox(height: 20),
_buildTextField(_driverNameController, 'Driver Name',
Icons.person),
SizedBox(height: 16),
_buildTextField(_licenseNumberController, 'License Number',
Icons.card_membership),
SizedBox(height: 16),
_buildTextField(_phoneNumberController, 'Phone Number',
Icons.phone),
SizedBox(height: 16),
_buildTextField(_vehicleNumberController, 'Vehicle Number',
Icons.directions_car),
SizedBox(height: 16),
_buildDropdownField(),
SizedBox(height: 20),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _registerRickshaw,
child: Text('Register', style: TextStyle(fontSize: 18,
color: Colors.white)), // White text
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFF006A4E),
shape: RoundedRectangleBorder(borderRadius:
BorderRadius.circular(12)),
),
),
),
],
),
),
),
),
),
),
);
}

Widget _buildTextField(TextEditingController controller, String label, IconData


icon) {
return TextField(
controller: controller,
decoration: InputDecoration(
labelText: label,
prefixIcon: Icon(icon, color: Color(0xFF006A4E)),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
),
);
}

Widget _buildDropdownField() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(10),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: _selectedArea,
hint: Text('Select Choice Area'),
isExpanded: true,
icon: Icon(Icons.arrow_drop_down, color: Color(0xFF006A4E)),
items: ['Nashik Road', 'Satpur', 'Pathardi Phata', 'Gangapur road',
'CBS', 'Adgaon']
.map((area) => DropdownMenuItem<String>(
value: area,
child: Text(area),
))
.toList(),
onChanged: (value) {
setState(() {
_selectedArea = value;
});
},
),
),
);
}
}
***********************************************************************************
*************************************************
business registration.dart

import 'package:flutter/material.dart';
import 'main.dart'; // Import the file where AdminDashboardPage is defined

class BusinessRegistrationPage extends StatelessWidget {


final TextEditingController _businessNameController = TextEditingController();
final TextEditingController _businessTypeController = TextEditingController();

void _registerBusiness(BuildContext context) {


if (_businessNameController.text.isNotEmpty &&
_businessTypeController.text.isNotEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Business Registered Successfully!'),
backgroundColor: Colors.green,
),
);
_businessNameController.clear();
_businessTypeController.clear();
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Please fill all fields'),
backgroundColor: Colors.red,
),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.green.shade700,
title: Text('Business Registration', style: TextStyle(color:
Colors.white)),
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => AdminDashboardPage()),
);
},
),
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.green.shade700, Color(0xFFC89D3C)], // Green to Gold
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 30),
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(borderRadius:
BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ---------- LOGO ----------
Image.asset(
'assets/images/adviksha logo.png', // Change path to your
logo image
height: 100,
),
SizedBox(height: 10),
Text(
'Register Your Business',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold,
color: Colors.green.shade700),
),
SizedBox(height: 20),
_buildTextField(_businessNameController, 'Business Name',
Icons.business),
SizedBox(height: 10),
_buildTextField(_businessTypeController, 'Business Type',
Icons.category),
SizedBox(height: 20),
ElevatedButton(
onPressed: () => _registerBusiness(context),
child: Text('Register', style: TextStyle(fontSize: 18, color:
Colors.white)),
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFC89D3C), // Gold Button
shape: RoundedRectangleBorder(borderRadius:
BorderRadius.circular(12)),
padding: EdgeInsets.symmetric(vertical: 14, horizontal:
40),
),
),
],
),
),
),
),
),
),
);
}

Widget _buildTextField(TextEditingController controller, String label, IconData


icon) {
return TextField(
controller: controller,
decoration: InputDecoration(
labelText: label,
prefixIcon: Icon(icon, color: Colors.green),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
),
);
}
}

You might also like