2023-06-08 23:29:01 +02:00
|
|
|
import 'package:cpd_ss23/Search/profile_company.dart';
|
2023-06-08 21:30:25 +02:00
|
|
|
import 'package:cpd_ss23/Search/search_companies.dart';
|
2023-06-08 23:29:01 +02:00
|
|
|
import 'package:cpd_ss23/jobs/upload_job.dart';
|
|
|
|
import 'package:cpd_ss23/user_state.dart';
|
2023-06-08 21:30:25 +02:00
|
|
|
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
|
2023-06-08 23:29:01 +02:00
|
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
2023-06-08 21:30:25 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../jobs/jobs_screen.dart';
|
|
|
|
|
|
|
|
class BottomNavigationBarForApp extends StatelessWidget {
|
|
|
|
|
|
|
|
int indexNum = 0;
|
|
|
|
|
|
|
|
BottomNavigationBarForApp({required this.indexNum});
|
|
|
|
|
2023-06-08 23:29:01 +02:00
|
|
|
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),),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-06-08 21:30:25 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return CurvedNavigationBar(
|
2023-06-09 20:38:31 +02:00
|
|
|
color: Colors.cyan,
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
buttonBackgroundColor: Colors.white,
|
2023-06-08 21:30:25 +02:00
|
|
|
height: 50,
|
2023-06-08 23:29:01 +02:00
|
|
|
index: indexNum,
|
2023-06-08 21:30:25 +02:00
|
|
|
items: const [
|
|
|
|
Icon(Icons.list, size: 19, color: Colors.black,),
|
2023-06-08 23:29:01 +02:00
|
|
|
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,),
|
2023-06-08 21:30:25 +02:00
|
|
|
],
|
|
|
|
animationDuration: const Duration(
|
|
|
|
milliseconds: 300,
|
|
|
|
),
|
|
|
|
animationCurve: Curves.bounceInOut,
|
|
|
|
onTap: (index){
|
|
|
|
if(index == 0){
|
|
|
|
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => JobScreen()));
|
|
|
|
} else if (index == 1){
|
|
|
|
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => AllWorkersScreen()));
|
2023-06-08 23:29:01 +02:00
|
|
|
} else if (index == 2){
|
|
|
|
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => UploadJobNow()));
|
|
|
|
} else if (index == 3){
|
2023-06-18 16:56:38 +02:00
|
|
|
final FirebaseAuth _auth=FirebaseAuth.instance;
|
|
|
|
final User? user = _auth.currentUser;
|
|
|
|
final String uid = user!.uid;
|
|
|
|
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => ProfileScreen(userId: uid)));
|
2023-06-08 23:29:01 +02:00
|
|
|
}
|
|
|
|
else if (index == 4){
|
|
|
|
_logout(context);
|
2023-06-08 21:30:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|