Add upload_job.dart job functions
Add Delete Job Funtion Changed avatar > userImagemain
parent
85df149e00
commit
c4117427a6
|
@ -0,0 +1,13 @@
|
||||||
|
class Persistent{
|
||||||
|
static List<String> jobCategoryList = [
|
||||||
|
"Architecture and Construction",
|
||||||
|
"Education and Training",
|
||||||
|
"Development - Programming",
|
||||||
|
"Business",
|
||||||
|
"Information Technology",
|
||||||
|
"Human Resources",
|
||||||
|
"Marketing",
|
||||||
|
"Design",
|
||||||
|
"Accounting"
|
||||||
|
];
|
||||||
|
}
|
|
@ -12,19 +12,18 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Colors.deepOrange.shade300, Colors.blueAccent],
|
colors: [Colors.cyan, Colors.white60],
|
||||||
begin: Alignment.centerLeft,
|
begin: Alignment.centerLeft,
|
||||||
end: Alignment.centerRight,
|
end: Alignment.centerRight,
|
||||||
stops: const [0.2, 0.9],
|
stops: [0.2, 0.9],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
bottomNavigationBar: BottomNavigationBarForApp(indexNum: 3,),
|
bottomNavigationBar: BottomNavigationBarForApp(indexNum: 3,),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.cyan,
|
|
||||||
title: const Text('Profile Screen'),
|
title: const Text('Profile Screen'),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SearchScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<SearchScreen> createState() => _SearchScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchScreenState extends State<SearchScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Colors.cyan, Colors.white60],
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
stops: [0.2, 0.9])),
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text("Search Job Screen"),
|
||||||
|
centerTitle: true,
|
||||||
|
flexibleSpace: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Colors.cyan, Colors.black],
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
stops: [0.2, 0.9])),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,9 +70,9 @@ class BottomNavigationBarForApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CurvedNavigationBar(
|
return CurvedNavigationBar(
|
||||||
color: Colors.deepOrange.shade400,
|
color: Colors.cyan,
|
||||||
backgroundColor: Colors.blueAccent,
|
backgroundColor: Colors.black,
|
||||||
buttonBackgroundColor: Colors.deepOrange.shade300,
|
buttonBackgroundColor: Colors.white,
|
||||||
height: 50,
|
height: 50,
|
||||||
index: indexNum,
|
index: indexNum,
|
||||||
items: const [
|
items: const [
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:cpd_ss23/services/global_methods.dart';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
class JobWidget extends StatefulWidget {
|
||||||
|
final String jobTitle;
|
||||||
|
final String jobDescription;
|
||||||
|
final String jobId;
|
||||||
|
final String uploadedBy;
|
||||||
|
final String userImage;
|
||||||
|
final String name;
|
||||||
|
final bool recruitment;
|
||||||
|
final String email;
|
||||||
|
final String location;
|
||||||
|
|
||||||
|
const JobWidget({
|
||||||
|
required this.jobTitle,
|
||||||
|
required this.jobDescription,
|
||||||
|
required this.jobId,
|
||||||
|
required this.uploadedBy,
|
||||||
|
required this.userImage,
|
||||||
|
required this.name,
|
||||||
|
required this.recruitment,
|
||||||
|
required this.email,
|
||||||
|
required this.location,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<JobWidget> createState() => _JobWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _JobWidgetState extends State<JobWidget> {
|
||||||
|
final FirebaseAuth _auth = FirebaseAuth.instance;
|
||||||
|
|
||||||
|
_deleteDialog() {
|
||||||
|
User? user = _auth.currentUser;
|
||||||
|
final _uid = user!.uid;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) {
|
||||||
|
return AlertDialog(
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async{
|
||||||
|
try{
|
||||||
|
if(widget.uploadedBy == _uid){
|
||||||
|
await FirebaseFirestore.instance.collection("jobs").doc(widget.jobId).delete();
|
||||||
|
await Fluttertoast.showToast(msg: "Job has been deleted", toastLength: Toast.LENGTH_LONG, backgroundColor: Colors.grey, fontSize: 18.0);
|
||||||
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
|
} else {
|
||||||
|
GlobalMethod.showErrorDialog(error: "You cannot perform this action!", ctx: ctx);
|
||||||
|
}
|
||||||
|
} catch (error){
|
||||||
|
//TODO Error kommt immer beim löschen fon Job aber funktioniert trotzdem
|
||||||
|
GlobalMethod.showErrorDialog(error: "This task cannot be deleted", ctx: ctx);
|
||||||
|
} finally{}
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.delete,
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Delete",
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Card(
|
||||||
|
color: Colors.white24,
|
||||||
|
elevation: 8,
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||||
|
child: ListTile(
|
||||||
|
onTap: () {},
|
||||||
|
onLongPress: () {
|
||||||
|
_deleteDialog();
|
||||||
|
},
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
|
leading: Container(
|
||||||
|
padding: const EdgeInsets.only(right: 12),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
right: BorderSide(width: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
//Debuging for userImage
|
||||||
|
//width: 100,
|
||||||
|
//height: 100,
|
||||||
|
child: Image.network(widget.userImage),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
widget.jobTitle,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.amber,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.name,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.jobDescription,
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: const Icon(
|
||||||
|
Icons.keyboard_arrow_right,
|
||||||
|
size: 30,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,7 +63,7 @@ class ForgetPasswort extends StatelessWidget {
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _emailController,
|
controller: _emailController,
|
||||||
style: TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'E-Mail',
|
labelText: 'E-Mail',
|
||||||
filled: true,
|
filled: true,
|
||||||
|
@ -90,7 +90,7 @@ class ForgetPasswort extends StatelessWidget {
|
||||||
borderRadius: BorderRadius.circular(13),
|
borderRadius: BorderRadius.circular(13),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 14),
|
padding: EdgeInsets.symmetric(vertical: 14),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Reset Passwort',
|
'Reset Passwort',
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:cpd_ss23/Search/search_job.dart';
|
||||||
import 'package:cpd_ss23/Widgets/bottom_nav_bar.dart';
|
import 'package:cpd_ss23/Widgets/bottom_nav_bar.dart';
|
||||||
|
import 'package:cpd_ss23/Widgets/job_widget.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../Persistent/persistent.dart';
|
||||||
import '../services/global_variables.dart';
|
import '../services/global_variables.dart';
|
||||||
import '../user_state.dart';
|
import '../user_state.dart';
|
||||||
|
|
||||||
|
@ -10,9 +14,87 @@ class JobScreen extends StatefulWidget {
|
||||||
State<JobScreen> createState() => _JobScreenState();
|
State<JobScreen> createState() => _JobScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
final _auth = FirebaseAuth.instance;
|
|
||||||
|
|
||||||
class _JobScreenState extends State<JobScreen> {
|
class _JobScreenState extends State<JobScreen> {
|
||||||
|
String? jobCategoryFilter;
|
||||||
|
|
||||||
|
final FirebaseAuth _auth = FirebaseAuth.instance;
|
||||||
|
|
||||||
|
_showTaskCategoriesDialog({required Size size}) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) {
|
||||||
|
return AlertDialog(
|
||||||
|
backgroundColor: Colors.black54,
|
||||||
|
title: const Text(
|
||||||
|
"Job Category",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 20, color: Colors.white),
|
||||||
|
),
|
||||||
|
content: Container(
|
||||||
|
width: size.width * 0.9,
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: Persistent.jobCategoryList.length,
|
||||||
|
itemBuilder: (ctx, index) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
jobCategoryFilter = Persistent.jobCategoryList[index];
|
||||||
|
});
|
||||||
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
|
print(
|
||||||
|
"jobCategoryList[index], ${Persistent.jobCategoryList[index]}");
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_right_alt_outlined,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
Persistent.jobCategoryList[index],
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
"Close",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
jobCategoryFilter = null;
|
||||||
|
});
|
||||||
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
|
},
|
||||||
|
child: const Text("Cancel Filter",
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
|
@ -33,22 +115,37 @@ class _JobScreenState extends State<JobScreen> {
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
AppBar(
|
AppBar(
|
||||||
backgroundColor: Colors.cyan,
|
backgroundColor: Colors.transparent,
|
||||||
title: const Text('Job Screen'),
|
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.search),
|
icon: const Icon(Icons.search_outlined,
|
||||||
|
color: Colors.white),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Action when the search icon is clicked
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (c) => SearchScreen()));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.filter_list_rounded,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_showTaskCategoriesDialog(size: size);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 80),
|
const SizedBox(height: 80),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_auth.signOut();
|
_auth.signOut();
|
||||||
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
Navigator.canPop(context)
|
||||||
|
? Navigator.pop(context)
|
||||||
|
: null;
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (_) => UserState()),
|
MaterialPageRoute(builder: (_) => UserState()),
|
||||||
|
@ -60,6 +157,46 @@ class _JobScreenState extends State<JobScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
|
||||||
|
stream: FirebaseFirestore.instance.collection("jobs").where("jobCategory", isEqualTo: jobCategoryFilter).where("recruitment", isEqualTo: true).orderBy("createdAt", descending: false).snapshots(),
|
||||||
|
builder: (context, AsyncSnapshot snapshot){
|
||||||
|
if(snapshot.connectionState == ConnectionState.waiting){
|
||||||
|
return const Center (child: CircularProgressIndicator(),);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.active){
|
||||||
|
if(snapshot.data?.docs.isNotEmpty == true){
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: snapshot.data?.docs.length,
|
||||||
|
itemBuilder: (BuildContext context, int index){
|
||||||
|
return JobWidget(
|
||||||
|
jobTitle: snapshot.data?.docs[index]["jobTitle"],
|
||||||
|
jobDescription: snapshot.data!.docs[index]["jobDescription"],
|
||||||
|
jobId: snapshot.data?.docs[index]["jobId"],
|
||||||
|
uploadedBy: snapshot.data?.docs[index]["uploadedBy"],
|
||||||
|
userImage: snapshot.data?.docs[index]["userImage"],
|
||||||
|
name: snapshot.data?.docs[index]["name"],
|
||||||
|
recruitment: snapshot.data?.docs[index]["recruitment"],
|
||||||
|
email: snapshot.data?.docs[index]["email"],
|
||||||
|
location: snapshot.data?.docs[index]["location"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const Center(
|
||||||
|
child: Text("There is no jobs"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
"Something went wrong",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 30
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,52 +1,294 @@
|
||||||
import 'package:flutter/material.dart';
|
// ignore_for_file: use_key_in_widget_constructors
|
||||||
|
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
|
import '../Persistent/persistent.dart';
|
||||||
import '../Widgets/bottom_nav_bar.dart';
|
import '../Widgets/bottom_nav_bar.dart';
|
||||||
|
import '../services/global_methods.dart';
|
||||||
|
import '../services/global_variables.dart';
|
||||||
|
|
||||||
class UploadJobNow extends StatefulWidget {
|
class UploadJobNow extends StatefulWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<UploadJobNow> createState() => _UploadJobNowState();
|
State<UploadJobNow> createState() => _UploadJobNowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _UploadJobNowState extends State<UploadJobNow> {
|
class _UploadJobNowState extends State<UploadJobNow> {
|
||||||
|
final TextEditingController _jobCategoryController =
|
||||||
|
TextEditingController(text: "Select Job Category");
|
||||||
|
final TextEditingController _jobTitleController = TextEditingController();
|
||||||
|
final TextEditingController _jobDescriptionController =
|
||||||
|
TextEditingController();
|
||||||
|
final TextEditingController _deadlineDateController =
|
||||||
|
TextEditingController(text: "Job Deadline Date");
|
||||||
|
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
DateTime? picked;
|
||||||
|
Timestamp? deadlineDateTimeStamp;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
void dispose(){
|
||||||
return Container(
|
super.dispose();
|
||||||
decoration: BoxDecoration(
|
_jobCategoryController.dispose();
|
||||||
gradient: LinearGradient(
|
_jobTitleController.dispose();
|
||||||
colors: [Colors.deepOrange.shade300, Colors.blueAccent],
|
_jobDescriptionController.dispose();
|
||||||
begin: Alignment.centerLeft,
|
_deadlineDateController.dispose();
|
||||||
end: Alignment.centerRight,
|
}
|
||||||
stops: const [0.2, 0.9],
|
|
||||||
)
|
Widget _textTitles({required String label}) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(5.0),
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
child: Scaffold(
|
);
|
||||||
bottomNavigationBar: BottomNavigationBarForApp(indexNum: 2,),
|
}
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
appBar: AppBar(
|
Widget _textFormFields({
|
||||||
backgroundColor: Colors.cyan,
|
required String valueKey,
|
||||||
title: const Text('Upload Job Now'),
|
required TextEditingController controller,
|
||||||
actions: [
|
required bool enabled,
|
||||||
IconButton(
|
required Function fct,
|
||||||
icon: const Icon(Icons.search),
|
required int maxLength,
|
||||||
onPressed: () {
|
}) {
|
||||||
// Action when the search icon is clicked
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(5.0),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
fct();
|
||||||
},
|
},
|
||||||
|
child: TextFormField(
|
||||||
|
validator: (values) {
|
||||||
|
if (values!.isEmpty) {
|
||||||
|
return "Value is missing";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
controller: controller,
|
||||||
|
enabled: enabled,
|
||||||
|
key: ValueKey(valueKey),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
|
maxLines: valueKey == "JobDescription" ? 3 : 1,
|
||||||
|
maxLength: maxLength,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.black54,
|
||||||
|
enabledBorder: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black54),
|
||||||
|
),
|
||||||
|
errorBorder: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black54),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_showTaskCategoriesDialog({required Size size}) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) {
|
||||||
|
return AlertDialog(
|
||||||
|
backgroundColor: Colors.black54,
|
||||||
|
title: const Text(
|
||||||
|
"Job Category",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 20, color: Colors.white),
|
||||||
|
),
|
||||||
|
content: Container(
|
||||||
|
width: size.width * 0.9,
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: Persistent.jobCategoryList.length,
|
||||||
|
itemBuilder: (ctx, index) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
_jobCategoryController.text =
|
||||||
|
Persistent.jobCategoryList[index];
|
||||||
|
});
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_right_alt_outlined,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
Persistent.jobCategoryList[index],
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: const Center(
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
"Cancel",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _pickDateDialog() async {
|
||||||
|
picked = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate: DateTime.now(),
|
||||||
|
firstDate: DateTime.now().subtract(
|
||||||
|
const Duration(days: 0),
|
||||||
|
),
|
||||||
|
lastDate: DateTime(2100),
|
||||||
|
);
|
||||||
|
if (picked != null) {
|
||||||
|
setState(() {
|
||||||
|
_deadlineDateController.text =
|
||||||
|
"${picked!.year} - ${picked!.month} - ${picked!.day}";
|
||||||
|
deadlineDateTimeStamp = Timestamp.fromMicrosecondsSinceEpoch(
|
||||||
|
picked!.microsecondsSinceEpoch);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _uploadTask() async {
|
||||||
|
final jobId = const Uuid().v4();
|
||||||
|
User? user = FirebaseAuth.instance.currentUser;
|
||||||
|
final _uid = user!.uid;
|
||||||
|
final isValid = _formKey.currentState!.validate();
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
if (_deadlineDateController.text == "Choose job Deadline date" ||
|
||||||
|
_jobCategoryController.text == "Choose job category") {
|
||||||
|
GlobalMethod.showErrorDialog(
|
||||||
|
error: "Please pick everything", ctx: context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await FirebaseFirestore.instance.collection("jobs").doc(jobId).set({
|
||||||
|
"jobId": jobId,
|
||||||
|
"uploadedBy": _uid,
|
||||||
|
"email": user.email,
|
||||||
|
"jobTitle": _jobTitleController.text,
|
||||||
|
"jobDescription": _jobDescriptionController.text,
|
||||||
|
"deadlineDate": _deadlineDateController.text,
|
||||||
|
"deadlineDateTimeStamp": deadlineDateTimeStamp,
|
||||||
|
"jobCategory": _jobCategoryController.text,
|
||||||
|
"jobComments": [],
|
||||||
|
"recruitment": true,
|
||||||
|
"createdAt": Timestamp.now(),
|
||||||
|
"name": name,
|
||||||
|
"userImage": userImage,
|
||||||
|
"location": location,
|
||||||
|
"applicants": 0,
|
||||||
|
});
|
||||||
|
await Fluttertoast.showToast(
|
||||||
|
msg: "The task has been uploaded",
|
||||||
|
toastLength: Toast.LENGTH_LONG,
|
||||||
|
backgroundColor: Colors.grey,
|
||||||
|
fontSize: 18.0,
|
||||||
|
);
|
||||||
|
_jobTitleController.clear();
|
||||||
|
_jobDescriptionController.clear();
|
||||||
|
setState(() {
|
||||||
|
_jobDescriptionController.text = "Choose job category";
|
||||||
|
_deadlineDateController.text = "Choose job Deadline date";
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
GlobalMethod.showErrorDialog(error: error.toString(), ctx: context);
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("Its not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getMyData() async{
|
||||||
|
final DocumentSnapshot userDoc = await FirebaseFirestore.instance.collection("users").doc(FirebaseAuth.instance.currentUser!.uid)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
name = userDoc.get("name");
|
||||||
|
userImage = userDoc.get("userImage");
|
||||||
|
location = userDoc.get("location");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
super.initState();
|
||||||
|
getMyData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Colors.cyan, Colors.white60],
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
stops: [0.2, 0.9],
|
||||||
|
)),
|
||||||
|
child: Scaffold(
|
||||||
|
bottomNavigationBar: BottomNavigationBarForApp(
|
||||||
|
indexNum: 2,
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(7.0),
|
padding: const EdgeInsets.all(7.0),
|
||||||
child: Card(
|
child: Card(
|
||||||
color: Colors.white10,
|
color: Colors.white10,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 10,),
|
const SizedBox(
|
||||||
Align(
|
height: 10,
|
||||||
|
),
|
||||||
|
const Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
|
@ -60,6 +302,101 @@ class _UploadJobNowState extends State<UploadJobNow> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
thickness: 1,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_textTitles(label: "Job Category:"),
|
||||||
|
_textFormFields(
|
||||||
|
valueKey: "JobCategory",
|
||||||
|
controller: _jobCategoryController,
|
||||||
|
enabled: false,
|
||||||
|
fct: () {
|
||||||
|
_showTaskCategoriesDialog(size: size);
|
||||||
|
},
|
||||||
|
maxLength: 100,
|
||||||
|
),
|
||||||
|
_textTitles(label: "Job Title:"),
|
||||||
|
_textFormFields(
|
||||||
|
valueKey: "JobTitle",
|
||||||
|
controller: _jobTitleController,
|
||||||
|
enabled: true,
|
||||||
|
fct: () {},
|
||||||
|
maxLength: 100,
|
||||||
|
),
|
||||||
|
_textTitles(label: "Job Description:"),
|
||||||
|
_textFormFields(
|
||||||
|
valueKey: "JobDescription",
|
||||||
|
controller: _jobDescriptionController,
|
||||||
|
enabled: true,
|
||||||
|
fct: () {},
|
||||||
|
maxLength: 100,
|
||||||
|
),
|
||||||
|
_textTitles(label: "Job Deadline:"),
|
||||||
|
_textFormFields(
|
||||||
|
valueKey: "Deadline",
|
||||||
|
controller: _deadlineDateController,
|
||||||
|
enabled: false,
|
||||||
|
fct: () {
|
||||||
|
_pickDateDialog();
|
||||||
|
},
|
||||||
|
maxLength: 100,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 30),
|
||||||
|
child: _isLoading
|
||||||
|
? const CircularProgressIndicator()
|
||||||
|
: MaterialButton(
|
||||||
|
onPressed: () {
|
||||||
|
_uploadTask();
|
||||||
|
},
|
||||||
|
color: Colors.black,
|
||||||
|
elevation: 8,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(13),
|
||||||
|
),
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 14),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Post Now",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 28,
|
||||||
|
fontFamily: "Signatra",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 9,
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.upload_file,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -136,7 +136,7 @@ class _LoginState extends State<Login> with TickerProviderStateMixin {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: 'Email',
|
hintText: 'Email',
|
||||||
hintStyle: TextStyle(color: Colors.white),
|
hintStyle: TextStyle(color: Colors.white),
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
String loginUrlImage = "https://images.unsplash.com/photo-1523050854058-8df90110c9f1?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dW5pdmVyc2l0eXxlbnwwfHwwfHw%3D&w=1000&q=80";
|
String loginUrlImage = "https://images.unsplash.com/photo-1523050854058-8df90110c9f1?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dW5pdmVyc2l0eXxlbnwwfHwwfHw%3D&w=1000&q=80";
|
||||||
String signupUrlImage= 'https://images.unsplash.com/photo-1575330734740-21b22ac7bf5e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8fA%3D%3D&w=1000&q=80';
|
String signupUrlImage= 'https://images.unsplash.com/photo-1575330734740-21b22ac7bf5e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8fA%3D%3D&w=1000&q=80';
|
||||||
String signupGenericImage = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeqUFP0nU4pUnNncq4dy7M6X6xYRYwUQduFcLkQ9yEAYMzORlw5eHddyCPMUY4yK2PBJ8&usqp=CAU';
|
String signupGenericImage = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeqUFP0nU4pUnNncq4dy7M6X6xYRYwUQduFcLkQ9yEAYMzORlw5eHddyCPMUY4yK2PBJ8&usqp=CAU';
|
||||||
|
String? name = "";
|
||||||
|
String? userImage = "";
|
||||||
|
String? location = "";
|
|
@ -103,7 +103,7 @@ class _SignUpState extends State<SignUp> {
|
||||||
'id': _uid,
|
'id': _uid,
|
||||||
'name': _nameTextController.text,
|
'name': _nameTextController.text,
|
||||||
'email': _emailTextController.text,
|
'email': _emailTextController.text,
|
||||||
'avatar':imageUrl,
|
'userImage':imageUrl,
|
||||||
'phone':_phoneNumberTextController.text,
|
'phone':_phoneNumberTextController.text,
|
||||||
'location': _cityTextController.text,
|
'location': _cityTextController.text,
|
||||||
'createdAt': Timestamp.now(),
|
'createdAt': Timestamp.now(),
|
||||||
|
|
Loading…
Reference in New Issue