import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:intl/intl.dart'; import 'package:job_app/config/palette.dart'; import 'package:job_app/models/APiResponse.dart'; import 'package:job_app/models/CvModel.dart'; import 'package:job_app/models/employmentoffer.dart'; import 'package:job_app/services/cv/fonts.dart'; import 'package:job_app/services/cv/submit%20cv/get_user_cv.dart'; import 'package:job_app/services/cv/submit%20cv/get_user_cv_models.dart'; import 'package:job_app/singletons/categories.dart'; import 'package:job_app/singletons/user_info.dart'; import 'package:job_app/views/apply.dart'; import 'package:job_app/widgets/loading_screen.dart'; class CompanyDetails extends StatefulWidget { final int offerIndex; final EmploymentofferModel passedOffer; CompanyDetails({this.offerIndex,this.passedOffer}); @override _CompanyDetailsState createState() => _CompanyDetailsState(); } class _CompanyDetailsState extends State { bool isCompanyInfo = true; bool isLoading =false; @override Widget build(BuildContext context) { EmploymentofferModel offer=this.widget.passedOffer; DateTime now = DateTime.fromMicrosecondsSinceEpoch(offer.company.timestmp); String time = DateFormat.yMd().format(now); String imageUrl = "https://server.thejob.net"; return Scaffold( backgroundColor: Colors.white, body: Stack( children: [ SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ /** ************************Top Container*********************** **/ Container( decoration: BoxDecoration( color: Palette.secendary, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(39), bottomRight: Radius.circular(39)), ), height: 250, width: double.maxFinite, child: Column( children: [ Padding( padding: const EdgeInsets.fromLTRB(18, 18, 18, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ IconButton( onPressed: () { Navigator.pop(context); }, icon: SvgPicture.asset( "assets/icons/arrow_left.svg", height: 20, )), IconButton( onPressed: () {}, icon: SvgPicture.asset( "assets/icons/empty_heart.svg", color: Colors.white, height: 20, )), ], ), ), Column( children: [ Container( height: 60, width: 90, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image( image: NetworkImage(imageUrl + offer.company.image.url), fit: BoxFit.fill, ), )), SizedBox( height: 20, ), Text( offer.company.expeditorname, style: TextStyle( fontFamily: "MontserratSemiBold", color: Colors.white, fontSize: 22), ), ], ), Padding( padding: const EdgeInsets.fromLTRB(0, 30, 0, 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( "assets/icons/minibag.svg", height: 12, ), SizedBox( width: 5, ), Text( "${offer.company.employeecount} EMPLOYEE", style: TextStyle( color: Colors.white, fontFamily: 'MontserratExtraLight', fontSize: 12, ), ), SizedBox( width: 10, ), SvgPicture.asset( "assets/icons/location_pin.svg", height: 14, color: Colors.white, ), SizedBox( width: 5, ), Text( offer.company.country, style: TextStyle( color: Colors.white, fontFamily: 'MontserratExtraLight', fontSize: 12, ), ), SizedBox( width: 10, ), SvgPicture.asset( "assets/icons/work_time.svg", height: 14, color: Colors.white, ), SizedBox( width: 5, ), Text( offer.schedule.toString(), style: TextStyle( color: Colors.white, fontFamily: 'MontserratExtraLight', fontSize: 12, ), ), ], ), ), ], ), ), /** ************************Details Switcher Texts************** **/ Padding( padding: const EdgeInsets.fromLTRB(50, 25, 50, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () { setState(() { isCompanyInfo = true; }); }, child: Text( "Company Info", style: TextStyle( fontFamily: "MontserratSemiBold", color: isCompanyInfo ? Colors.black : Color.fromRGBO(0, 0, 0, 0.5), fontSize: 18, decoration: isCompanyInfo ? TextDecoration.underline : TextDecoration.none, decorationThickness: isCompanyInfo ? 2 : 0, ), ), ), GestureDetector( onTap: () { setState(() { isCompanyInfo = false; }); }, child: Text( "Overview", style: TextStyle( fontFamily: "MontserratSemiBold", color: !isCompanyInfo ? Colors.black : Color.fromRGBO(0, 0, 0, 0.5), fontSize: 18, decoration: !isCompanyInfo ? TextDecoration.underline : TextDecoration.none, decorationThickness: !isCompanyInfo ? 2 : 0, ), ), ), ], ), ), SizedBox( height: 10, ), Divider(), /** ************************Company Info Container************** **/ if (isCompanyInfo) Padding( padding: const EdgeInsets.fromLTRB(25, 10, 25, 10), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Flexible( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ buildRichText( title: 'Incorporation', details: time, isHighlighted: false), buildRichText( title: 'Location', details: offer.location, isHighlighted: false), buildRichText( title: 'Type', details: offer.type, isHighlighted: false), buildRichText( title: 'Key information', details: offer.company.description, isHighlighted: false), ], ), ), ], ), ), /** ************************Company OverView Container********** **/ if (!isCompanyInfo) Padding( padding: const EdgeInsets.fromLTRB(25, 10, 25, 10), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Flexible( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ buildRichText( title: "Overview", details: offer.overview, isHighlighted: true), buildRichText( title: "Job Type", details: "No such field", isHighlighted: false), buildRichText( title: "Job Schedule", details: offer.schedule.toLowerCase(), isHighlighted: false), buildRichText( title: "Career Level", details: "Manager", isHighlighted: false), buildRichText( title: "Education Level", details: offer.educationlevel, isHighlighted: false), buildRichText( title: "Accolades", details: offer.accolades, isHighlighted: false), buildRichText( title: "Salary & Benefits", details: offer.salary, isHighlighted: false), buildRichText( title: "Summary of Responsibilities", details: offer.summary, isHighlighted: true), buildRichText( title: "Skills", details: offer.skills, isHighlighted: true), ], ), ), ], ), ), /** ************************Ad Container************************ **/ Container( width: MediaQuery.of(context).size.width, child: Image( fit: BoxFit.fill, image: AssetImage("assets/images/company_banner.png"), )), /** ************************Apply Button*********************** **/ Padding( padding: const EdgeInsets.fromLTRB(0, 30, 0, 40), child: Container( width: 180, height: 40, decoration: BoxDecoration( color: Palette.primary, borderRadius: BorderRadius.circular(8)), child: TextButton( onPressed: ()async { setState(() { isLoading=true; }); GetUserCVModelsService userCVsModel = GetUserCVModelsService(); ApiResponseModel response =await userCVsModel.getUserCvModels(); GetUserCvsService userCvs = GetUserCvsService(); ApiResponseModel response2 =await userCvs.getUserCvs(); if(response2.data.length==1){ FontService fontById = FontService(); ApiResponseModel response3 =await fontById.getFontById(response2.data.first.font); setState(() { isLoading=false; }); Navigator.pushNamed(context, '/apply',arguments: { "cvModels" :response.data, "cv" :response2.data.first, "font":response3.data }); Navigator.push( context, MaterialPageRoute(builder: (context) => Apply(font: response3.data,cv: response2.data.first,cvModels: response.data,)), ); }else if(response2.data.length>1){ setState(() { isLoading=false; }); Navigator.pushNamed(context, '/select_cv',arguments: { "cvs" :response2.data, "cvModels" :response.data, "offerId" : offer.id, }); }else if(response2.data.length==0){ setState(() { isLoading=false; }); Navigator.pushNamed(context, '/build_cv_general',arguments: { "firstName" :userInfo.user.firstName, "lastName":userInfo.user.lastName, "phoneNumber" :userInfo.user.phonenumber, "jobTitle" :userInfo.user.jobtitle }); } }, child: Text( "Apply now", style: TextStyle( color: Colors.white, fontFamily: 'MontserratSemiBold'), )), ), ) ], ), ), if(isLoading) LoadingScreen(), ], ), ); } Widget buildRichText({String title, String details, bool isHighlighted}) { return Column( children: [ RichText( text: TextSpan( text: "$title${!isHighlighted ? ": " : "\n\n"}", style: TextStyle( color: Colors.black, fontFamily: "MontserratSemiBold", fontSize: 15, ), children: [ TextSpan( text: details, style: TextStyle( fontSize: 14, fontFamily: 'MontserratRegular', height: 1.5), ), ])), SizedBox( height: 15, ), ], ); } }