Add Logout to nav_bar

Add profile_company.dart
Add upload_job.dart
main
David 2023-06-08 23:29:01 +02:00
parent 67b5ce90b2
commit 85df149e00
3 changed files with 184 additions and 1 deletions

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import '../Widgets/bottom_nav_bar.dart';
class ProfileScreen extends StatefulWidget {
@override
State<ProfileScreen> createState() => _ProfileScreenState();
}
class _ProfileScreenState extends State<ProfileScreen> {
@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
},
),
],
),
),
);
}
}

View File

@ -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);
}
},
);

View File

@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import '../Widgets/bottom_nav_bar.dart';
class UploadJobNow extends StatefulWidget {
@override
State<UploadJobNow> createState() => _UploadJobNowState();
}
class _UploadJobNowState extends State<UploadJobNow> {
@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",
),
),
),
)
],
),
),
),
),
),
),
);
}
}