Skip to content

Commit

Permalink
Replaced Github jobs with Adzuna jobs
Browse files Browse the repository at this point in the history
Disabled search mechanism and saving jobs temporarily
  • Loading branch information
mohammadkamal committed Jun 30, 2021
1 parent f2549a1 commit 1b0e8c3
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 46 deletions.
85 changes: 85 additions & 0 deletions lib/adzuna_job_posting_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:wazeefa/adzuna_job_posting_page.dart';
import 'package:wazeefa/adzuna_jobs/adzuna_job.dart';

class AdzunaJobPostingItem extends StatelessWidget {
final AdzunaJob adzunaJob;

const AdzunaJobPostingItem({Key key, this.adzunaJob}) : super(key: key);

Widget _titleWidget() {
return Container(
padding: EdgeInsets.only(top: 3, bottom: 3),
width: 200,
child: Text(
adzunaJob.jobTitle,
style: TextStyle(fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
),
);
}

Widget _companyNameWidget() {
return Container(
padding: EdgeInsets.only(top: 3, bottom: 3),
width: 200,
child: Text(
'at ' + adzunaJob.jobCompany.companyDisplayName,
softWrap: true,
style: TextStyle(color: Colors.grey),
));
}

Widget _locationWidget() {
return Container(
padding: EdgeInsets.only(top: 3, bottom: 3),
child: Row(
children: [
Icon(
Icons.location_on,
color: Colors.red[400],
),
Container(
width: 150,
child: Text(
adzunaJob.jobLocation.displayName,
overflow: TextOverflow.ellipsis,
))
],
),
);
}

Widget _infoWidget() {
return Container(
padding: EdgeInsets.only(left: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [_titleWidget(), _companyNameWidget(), _locationWidget()],
));
}

@override
Widget build(BuildContext context) {
return GestureDetector(
child: Container(
padding: EdgeInsets.only(top: 8, bottom: 8),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(color: Colors.grey.withOpacity(0.5), spreadRadius: 1.5)
]),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [_infoWidget()],
),
),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AdzunaJobPostingPage(job: adzunaJob))),
);
}
}
156 changes: 156 additions & 0 deletions lib/adzuna_job_posting_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:wazeefa/adzuna_jobs/adzuna_job.dart';
import 'package:wazeefa/link_web_view.dart';

class AdzunaJobPostingPage extends StatefulWidget {
final AdzunaJob job;

const AdzunaJobPostingPage({Key key, @required this.job}) : super(key: key);

_AdzunaJobPostingPageState createState() => _AdzunaJobPostingPageState();
}

class _AdzunaJobPostingPageState extends State<AdzunaJobPostingPage> {
BoxDecoration _boxDecoration() {
return BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.white,
boxShadow: [
BoxShadow(color: Colors.grey.withOpacity(0.5), spreadRadius: 1.5)
]);
}

Widget _titleWidget() {
return Container(
alignment: Alignment.center,
padding: EdgeInsets.all(8),
child: Text(
widget.job.jobTitle,
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
softWrap: true,
),
);
}

Widget _companyNameTopWidget() {
return Container(
padding: EdgeInsets.all(8),
child: Text(
widget.job.jobCompany.companyDisplayName,
style: TextStyle(fontSize: 15, color: Colors.blue),
),
);
}

Widget _locationWidget() {
return Container(
padding: EdgeInsets.all(8),
child: Text(
widget.job.jobLocation.displayName,
style: TextStyle(color: Colors.grey),
));
}

Widget _timeWidget() {
return Container(
padding: EdgeInsets.all(8),
child: Text('Posted at ' + widget.job.dateOfcreation),
);
}

Widget _typeLocationWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_locationWidget(),
],
);
}

Widget _topInfoCard() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_titleWidget(),
_typeLocationWidget(),
_companyNameTopWidget(),
_timeWidget(),
],
);
}

Widget _descriptionCard() {
return Container(
decoration: _boxDecoration(),
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.all(8),
child: Text(
'Description',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
color: Colors.blue[300]),
),
),
Container(
child: Html(
data: widget.job.jobDescription,
),
)
],
));
}

Widget _bottomLink() {
return Container(
alignment: Alignment.bottomCenter,
child: ElevatedButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
LinkWebView(link: widget.job.redirectURL))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('View Posting at website'),
Icon(CupertinoIcons.globe)
],
)),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(CupertinoIcons.back),
onPressed: () => Navigator.pop(context),
),
title: Text('Job details'),
),
body: Container(
color: Colors.grey[100],
child: Stack(
children: [
SingleChildScrollView(
padding: EdgeInsets.only(bottom: 50),
child: Column(
children: [
_topInfoCard(),
_descriptionCard(),
],
)),
_bottomLink()
],
)));
}
}
77 changes: 77 additions & 0 deletions lib/adzuna_jobs/adzuna_job.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'package:json_annotation/json_annotation.dart';

import 'adzuna_job_category.dart';
import 'adzuna_job_company.dart';
import 'adzuna_job_location.dart';

@JsonSerializable()
class AdzunaJob {
AdzunaJob(
{this.salaryMinimum,
this.jobTitle,
this.jobLocation,
this.redirectURL,
this.jobCategory,
this.adRef,
this.dateOfcreation,
this.jobCompany,
this.jobDescription,
this.jobID,
this.salaryIsPredicted,
this.salaryMaximum,
this.latitude,
this.longitude});

dynamic salaryMinimum;
String jobTitle;
AdzunaJobLocation jobLocation;
String redirectURL;
AdzunaJobCategory jobCategory;
String adRef;
String salaryIsPredicted; // as integers 0, 1
String dateOfcreation;
String jobDescription;
dynamic salaryMaximum;
AdzunaJobCompany jobCompany;
int jobID;
dynamic latitude;
dynamic longitude;

factory AdzunaJob.fromJson(Map<String, dynamic> json) =>
_$AdzunaJobFromJson(json);
Map<String, dynamic> toJson() => _$AdzunaJobToJson(this);
}

AdzunaJob _$AdzunaJobFromJson(Map<String, dynamic> json) => AdzunaJob(
redirectURL: json['redirect_url'],
adRef: json['adref'],
jobTitle: json['title'],
jobID: int.tryParse(json['id']),
salaryIsPredicted: json['salary_is_predicted'],
dateOfcreation: json['created'],
salaryMaximum: json['salary_max'],
salaryMinimum: json['salary_min'],
jobDescription: json['description'],
longitude: json['longitude'],
latitude: json['latitude'],
jobCategory: AdzunaJobCategory.fromJson(json['category']),
jobCompany: AdzunaJobCompany.fromJson(json['company']),
jobLocation: AdzunaJobLocation.fromJson(json['location']));

Map<String, dynamic> _$AdzunaJobToJson(AdzunaJob adzunaJob) =>
<String, dynamic>{
'redirect_url': adzunaJob.redirectURL,
'adref': adzunaJob.adRef,
'title': adzunaJob.jobTitle,
'id': adzunaJob.jobID,
'salary_is_predicted': adzunaJob.salaryIsPredicted,
'created': adzunaJob.dateOfcreation,
'salary_max': adzunaJob.salaryMaximum,
'salary_min': adzunaJob.salaryMinimum,
'description': adzunaJob.jobDescription,
'latitude': adzunaJob.latitude,
'longitude': adzunaJob.longitude,
'category': adzunaJob.jobCategory.toJson(),
'company': adzunaJob.jobCompany.toJson(),
'location': adzunaJob.jobLocation.toJson()
};
23 changes: 23 additions & 0 deletions lib/adzuna_jobs/adzuna_job_category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class AdzunaJobCategory {
AdzunaJobCategory({this.jobCategoryLabel, this.jobCategoryTag});
String jobCategoryLabel;
String jobCategoryTag;

factory AdzunaJobCategory.fromJson(Map<String, dynamic> json) =>
_$AdzunaJobCategoryFromJson(json);
Map<String, dynamic> toJson() => _$AdzunaJobCategoryToJson(this);
}

AdzunaJobCategory _$AdzunaJobCategoryFromJson(Map<String, dynamic> json) =>
AdzunaJobCategory(
jobCategoryLabel: json['label'], jobCategoryTag: json['tag']);

Map<String, dynamic> _$AdzunaJobCategoryToJson(
AdzunaJobCategory adzunaJobCategory) =>
<String, dynamic>{
'label': adzunaJobCategory.jobCategoryLabel,
'tag': adzunaJobCategory.jobCategoryTag
};
18 changes: 18 additions & 0 deletions lib/adzuna_jobs/adzuna_job_company.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class AdzunaJobCompany {
AdzunaJobCompany({this.companyDisplayName});
String companyDisplayName;

factory AdzunaJobCompany.fromJson(Map<String, dynamic> json) =>
_$AdzunaJobCompanyFromJson(json);
Map<String, dynamic> toJson() => _$AdzunaJobCompanyToJson(this);
}

AdzunaJobCompany _$AdzunaJobCompanyFromJson(Map<String, dynamic> json) =>
AdzunaJobCompany(companyDisplayName: json['display_name']);

Map<String, dynamic> _$AdzunaJobCompanyToJson(
AdzunaJobCompany adzunaJobCompany) =>
<String, dynamic>{'display_name': adzunaJobCompany.companyDisplayName};
23 changes: 23 additions & 0 deletions lib/adzuna_jobs/adzuna_job_location.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class AdzunaJobLocation {
String displayName;
List<dynamic> area;
AdzunaJobLocation({this.displayName, this.area});

factory AdzunaJobLocation.fromJson(Map<String, dynamic> json) =>
_$AdzunaJobLocationFromJson(json);
Map<String, dynamic> toJson() => _$AdzunaJobLocationToJson(this);
}

AdzunaJobLocation _$AdzunaJobLocationFromJson(Map<String, dynamic> json) =>
AdzunaJobLocation(displayName: json['display_name'], area: json['area']
);

Map<String, dynamic> _$AdzunaJobLocationToJson(
AdzunaJobLocation adzunaJobLocation) =>
<String, dynamic>{
'display_name': adzunaJobLocation.displayName,
'area': adzunaJobLocation.area
};
Loading

0 comments on commit 1b0e8c3

Please sign in to comment.