From 85df149e00d581172a8e8fde57e2a1ed2611d4b1 Mon Sep 17 00:00:00 2001 From: David <1920881@users.noreply.github.com> Date: Thu, 8 Jun 2023 23:29:01 +0200 Subject: [PATCH] Add Logout to nav_bar Add profile_company.dart Add upload_job.dart --- lib/Search/profile_company.dart | 41 ++++++++++++++++++ lib/Widgets/bottom_nav_bar.dart | 71 +++++++++++++++++++++++++++++++- lib/jobs/upload_job.dart | 73 +++++++++++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 lib/Search/profile_company.dart create mode 100644 lib/jobs/upload_job.dart diff --git a/lib/Search/profile_company.dart b/lib/Search/profile_company.dart new file mode 100644 index 0000000..336e174 --- /dev/null +++ b/lib/Search/profile_company.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +import '../Widgets/bottom_nav_bar.dart'; + +class ProfileScreen extends StatefulWidget { + + @override + State createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.deepOrange.shade300, Colors.blueAccent], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + stops: const [0.2, 0.9], + ) + ), + child: Scaffold( + bottomNavigationBar: BottomNavigationBarForApp(indexNum: 3,), + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.cyan, + title: const Text('Profile Screen'), + actions: [ + IconButton( + icon: const Icon(Icons.search), + onPressed: () { + // Action when the search icon is clicked + }, + ), + ], + ), + ), + ); + } +} diff --git a/lib/Widgets/bottom_nav_bar.dart b/lib/Widgets/bottom_nav_bar.dart index a0a5659..e66ccb3 100644 --- a/lib/Widgets/bottom_nav_bar.dart +++ b/lib/Widgets/bottom_nav_bar.dart @@ -1,5 +1,9 @@ +import 'package:cpd_ss23/Search/profile_company.dart'; import 'package:cpd_ss23/Search/search_companies.dart'; +import 'package:cpd_ss23/jobs/upload_job.dart'; +import 'package:cpd_ss23/user_state.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; +import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import '../jobs/jobs_screen.dart'; @@ -9,6 +13,60 @@ class BottomNavigationBarForApp extends StatelessWidget { BottomNavigationBarForApp({required this.indexNum}); + void _logout(context) { + final FirebaseAuth _auth = FirebaseAuth.instance; + + showDialog( + context: context, + builder: (context){ + return AlertDialog( + backgroundColor: Colors.black54, + title: const Row( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Icon( + Icons.logout, + color: Colors.white, + size: 36 + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: Text( + "Sign Out", + style: TextStyle(color: Colors.white, fontSize: 28), + ), + ), + ], + ), + content: const Text( + "Do you want to Log Out?", + style: TextStyle( + color: Colors.white, fontSize: 20 + ), + ), + actions: [ + TextButton( + onPressed: (){ + Navigator.canPop(context) ? Navigator.pop(context) : null; + }, + child: const Text("No", style: TextStyle(color: Colors.green, fontSize: 18),), + ), + TextButton( + onPressed: (){ + _auth.signOut(); + Navigator.canPop(context) ? Navigator.pop(context) : null; + Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => UserState())); + }, + child: const Text("Yes", style: TextStyle(color: Colors.green, fontSize: 18),), + ) + ], + ); + } + ); + } + @override Widget build(BuildContext context) { return CurvedNavigationBar( @@ -16,9 +74,13 @@ class BottomNavigationBarForApp extends StatelessWidget { backgroundColor: Colors.blueAccent, buttonBackgroundColor: Colors.deepOrange.shade300, height: 50, + index: indexNum, items: const [ Icon(Icons.list, size: 19, color: Colors.black,), - Icon(Icons.search, size: 19, color: Colors.black,) + Icon(Icons.search, size: 19, color: Colors.black,), + Icon(Icons.add, size: 19, color: Colors.black,), + Icon(Icons.person_pin, size: 19, color: Colors.black,), + Icon(Icons.exit_to_app, size: 19, color: Colors.black,), ], animationDuration: const Duration( milliseconds: 300, @@ -29,6 +91,13 @@ class BottomNavigationBarForApp extends StatelessWidget { Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => JobScreen())); } else if (index == 1){ Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => AllWorkersScreen())); + } else if (index == 2){ + Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => UploadJobNow())); + } else if (index == 3){ + Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => ProfileScreen())); + } + else if (index == 4){ + _logout(context); } }, ); diff --git a/lib/jobs/upload_job.dart b/lib/jobs/upload_job.dart new file mode 100644 index 0000000..3c54b85 --- /dev/null +++ b/lib/jobs/upload_job.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; + +import '../Widgets/bottom_nav_bar.dart'; + +class UploadJobNow extends StatefulWidget { + + @override + State createState() => _UploadJobNowState(); +} + + +class _UploadJobNowState extends State { + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.deepOrange.shade300, Colors.blueAccent], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + stops: const [0.2, 0.9], + ) + ), + child: Scaffold( + bottomNavigationBar: BottomNavigationBarForApp(indexNum: 2,), + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.cyan, + title: const Text('Upload Job Now'), + actions: [ + IconButton( + icon: const Icon(Icons.search), + onPressed: () { + // Action when the search icon is clicked + }, + ), + ], + ), + body: const Center( + child: Padding( + padding: EdgeInsets.all(7.0), + child: Card( + color: Colors.white10, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 10,), + Align( + alignment: Alignment.center, + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + "Please fill all fields", + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.bold, + fontFamily: "Signatra", + ), + ), + ), + ) + ], + ), + ), + ), + ), + ), + ), + ); + } +}