%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
% Lxsameer's CV Latex class
% Copyright (C) 2022 Sameer Rahmani <lxsameer@gnu.org>
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

% This is a work based on Murat Can Karacabey's work

\author{Sameer Rahmani}
% moved here I guess article class causes option clash with xcolor if used after loading the class
\RequirePackage[dvipsnames]{xcolor}
\LoadClass[11pt]{article}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{lxsameer_cv}[2022/03/22 lxsameer's CV Class]
%\RequirePackage[sfdefault]{noto}

\RequirePackage[default]{sourcesanspro}
\setsansfont{Source Sans Pro}
\RequirePackage{multicol}
\RequirePackage{etoolbox}
\RequirePackage{pgffor}
\RequirePackage{titlesec}
\RequirePackage{tikz}
\RequirePackage{fontspec}
\RequirePackage[left=0.75in,top=0.3in,right=0.75in,bottom=0.6in]{geometry} % Document margins
\RequirePackage{hyperref}
\RequirePackage{fontawesome5}
\RequirePackage{mfirstuc}
\RequirePackage{ifthen}
\RequirePackage{array}
\RequirePackage{xcolor}
\RequirePackage{scrextend}
\edef\restoreparindent{\parindent=\the\parindent\relax}
\RequirePackage{parskip}
\restoreparindent{}
\pagestyle{empty}



\makeatletter
\newcommand{\globalcolor}[1]{%
  \color{#1}\global\let\default@color\current@color{}
}

%Setup
\parskip=0.15cm
\changefontsizes{11pt}
\newcommand*{\setname}[2]{\def\@firstname{#1}\def\@lastname{#2}}
\newcommand*{\setjobtitle}[1]{\def\@jobtitle{#1}}
\newcommand*{\setaddress}[1]{\def\@address{#1}}
\newcommand*{\setmobile}[1]{\def\@mobile{#1}}
\newcommand*{\setposition}[1]{\def\@position{#1}}
\newcommand*{\setmail}[1]{\def\@mail{#1}}
\newcommand*{\setfirstcolor}[1]{\def\@firstcolor{#1}}
\newcommand*{\setsecondcolor}[1]{\def\secondcolor{#1}}
\newcommand*{\setthirdcolor}[1]{\def\@thirdcolor{#1}}
\newcommand*{\setfourthcolor}[1]{\def\@fourthcolor{#1}}
\newcommand*{\setlinkedinaccount}[1]{\def\@linkedinaccount{#1}}
\newcommand*{\setgit}[1]{\def\@git{#1}}
\newcommand*{\setwebsite}[1]{\def\@website{#1}}
\newcommand*{\setgithubaccount}[1]{\def\@githubaccount{#1}}

% Color pallet
\definecolor{firstcolor}{rgb}{0.94,0.28,0.33}
\definecolor{color1}{HTML}{6d597a}
\definecolor{color2}{HTML}{355070}
\definecolor{color3}{HTML}{e56b6f}
\definecolor{color4}{HTML}{eaac8b}
\definecolor{color5}{HTML}{eeeeec}
\definecolor{color5}{HTML}{aaaaa5}


% Color aliases
\colorlet{headercolor}{color2}
\colorlet{linkcolor}{color1}
\colorlet{highlightcolor}{color3}
\colorlet{highlightcolor}{color3}
\colorlet{pbemptycolor}{color5} % progress bar empty part
\colorlet{pbfullcolor}{color3} % progress bar full part
\colorlet{xpheadercolor}{color2}
\colorlet{awardcolor}{color4}
\colorlet{bulletcolor}{color1}
\colorlet{jobtitlecolor}{color5}
%Setup for coverletter

\newcommand*{\setcompanyname}[1]{\def\@companyname{#1}}
\newcommand*{\setcontactperson}[1]{\def\@contactperson{#1}}
\newcommand*{\setclaimedposition}[1]{\def\@claimedposition{#1}}


\hypersetup{
    colorlinks=true,
    urlcolor=linkcolor,
}

% View commands
% Header

\newcommand\headerview{
    \hspace{-2.2em}
    \begin{minipage}{0.18\linewidth}
        \profpic{0.4}{images/avatar}
    \end{minipage}%
    \name{}
    \hfill
    \mbox{
    \begin{minipage}{0.2\linewidth}
      \contact{}
    \end{minipage}
  }
}

%profilpicture

\newsavebox{\picbox}
\newcommand{\profpic}[2]{%
    \savebox{\picbox}{%
    \includegraphics[scale=#1]{#2}}%
    \tikz\node [draw, circle,%
    line width=4pt, color=white,%
    minimum width=\wd\picbox,minimum height=\ht\picbox,%
    path picture={ \node at (path picture bounding box.center)%
    {\usebox{\picbox}};}]%
    {};}

%contactsubviews

\newcommand{\name}{%
  \begin{minipage}{0.4\linewidth}
    {\huge \@firstname{} \@lastname{}} \\[0cm]
    {\small \color{jobtitlecolor} \@jobtitle}
  \end{minipage}
}

\newcommand{\contact}{%
  {\color{headercolor} \scriptsize \faIcon{map-marker-alt} \@address} \\
  {\color{headercolor} \scriptsize \faIcon{phone-alt} \@mobile} \\
  {\color{headercolor} \scriptsize \faIcon{envelope} \@mail} \\
  {\color{headercolor} \scriptsize \faIcon{link} \href{\@website}{\@website}} \\
}

% Covverletterview

\newcommand\coverletter[1]{
\\  \coverlettersubview
\section{} \vspace{1ex}
\textbf{ Dear \@contactperson, \\[0.1cm]}
  #1
}

\newcommand\coverlettersubview{
\begin{tabular}{>{\scshape \bfseries \color{firstcolor}}l  >{\small }l}
Company: & \@companyname \\
Position: & \@claimedposition \\
\end{tabular}
}

% Helper commands
\newcommand\ruleafter[1]{#1~{\color{headercolor}\hrulefill}} % a trick to put the line with <before> parameter in \titleformat

\newcommand{\hl}[1]{%
  {\color{highlightcolor} #1}
}

%colorfulpipeseperator

\newcommand{\cps}{{\color{firstcolor} \quad\textbar\quad}}
\newcommand{\cpshalf}{{\color{firstcolor} \hspace{0.2em}\textbar\hspace{0.2em}}}

\newcommand{\coloredbullet}{{\color{bulletcolor} \textbullet}}

% Edit section styles
% Customise the \section command
\titleformat{\section}
  {\large\bfseries\raggedright\color{headercolor}} % Make the \section headers large (\Large),
                               % small capitals (\scshape) and left aligned (\raggedright)
  {\color{headercolor}}{0em}                      % Can be used to give a prefix to all sections, like 'Section ...'
  {\color{headercolor} \ruleafter}                           % Can be used to insert code before the heading

\titlespacing*{\section}{-1pt}{0pt}{0pt}

\newcommand{\volunteer}[1]{
  \begin{small}
    \indent \coloredbullet{} \scriptsize #1
  \end{small}
}
% Textview commands

%% \newcommand{\experience}[2]{%
%%   \mbox{\hspace{1em} \scshape \textbf{#1} }%
%% }

\newcommand{\datetext}[1]{%
  {\textit{\scriptsize \mdseries  \color{gray} #1 }}
}

\newcommand{\award}[2]{%
  \hspace{0.2cm}
  \begin{small}
    {\large{\color{awardcolor} \faIcon{medal}}}
    #1
  \end{small}
  \hfill
  \datetext{#2}\\[0cm]
}

\newcommand{\project}[3]{%
  {\small{\href{#2}{\faIcon{link}~#1}}} \\
  \vbox{\vspace{0.05cm}
    \sectiondesc{#3}
  }
}


\newcommand{\experience}[2]{%
  \begin{small}
    {\hspace{1em} \textbf{\scshape \color{color1} #1}}
  \end{small}
  \hfill
  \datetext{#2}\\[0cm]
}
%
\newcommand{\role}[4]{%
  \vbox{
  \begin{small}
    {\noindent \hspace{1em} \textbf{\color{xpheadercolor} #1} \jobtitle{#2}}
  \end{small}
  \hfill
  \datetext{#3}\\[0.2cm]
  \begin{small}
    #4
  \end{small}
  }
}

\newcommand{\jobtitle}[1]{%
  {\tiny \color{jobtitlecolor} #1}
}

\newcommand{\desc}[1]{%
  \begin{minipage}{0.96\linewidth} \scriptsize #1 \end{minipage} \\[0.1cm]
}


% returns minipage width minus two times \fboxsep
% to keep padding included in width calculations
% can also be used for other boxes / environments
\newcommand{\mpwidth}{\linewidth-\fboxsep-\fboxsep}

\newcommand{\skill}[2] {
  \mbox{#1} \\
  \begin{tikzpicture}[scale=1]
    \fill [pbemptycolor] (0,0) rectangle (1\mpwidth, 0.15);
    \fill [pbfullcolor] (0,0) rectangle (#2\mpwidth, 0.15);
  \end{tikzpicture} \\[0.1cm]
}

\newcommand{\sectiondesc}[1]{%
  \scriptsize{#1} \\[0.1cm]
}

\newcommand{\jobdesc}[1]{%
  \mbox{\hspace{1.2em} \scriptsize \desc{#1}}\\[0.3cm]
}

\newcommand{\explanation}[1]{%
  \mbox{\scshape \hspace{1.2em} \footnotesize #1}\\[0.05cm]
}


\newcommand{\explanationdetail}[1]{%
    \indent \begin{minipage}{0.96\linewidth} \footnotesize #1 \end{minipage} \\[0.1cm]
}

\newcommand{\itemwithtext}[1]{%
    \begin{minipage}{\linewidth} \footnotesize \item #1 \end{minipage}
}

\newcommand{\addblocktext}[2]{%
  \section{#1}
  \indent \explanationdetail{\hspace{4ex} #2}
}

\newcommand{\summary}[1]{%
  \section{Summary}
  \sectiondesc{#1}
}

\newcommand\createskill[2]{%
    \textsc{\textbf{#1}} & #2
}

\newcommand\createtablecontent[1]{%
    \foreach \x [count=\xi] in {#1} {\ifthenelse{\xi=1}{\x}{\\ \x}}
}

\newcommand\createskillsanothertry[1]{%not used
  \begin{tabular}{r|l}
      \createtablecontent{#1}
  \end{tabular}
}

\newcommand\createskills[1]{%
\explanationdetail{
  \begin{tabular}{rl}
    \makeatletter
    \@for\thisitem:=#1\do{\thisitem\\[0.1cm]}
    \makeatother
    \end{tabular}
}
}

\newcommand\createbullets[1]{%
  \renewcommand{\labelitemi}{\coloredbullet}
  \begin{itemize}
    \makeatletter
    \@for\thisitem:=#1\do{\itemwithtext{\thisitem}}
    \makeatother
  \end{itemize}
}

\newcommand\createfootnote{%
  \renewcommand{\footnotesize}{\fontsize{7pt}{11pt}\selectfont}
    \renewcommand\footnoterule{\rule{0.3\linewidth}{0.5pt}}
    \let\thefootnote\relax\footnote{\today\ / \href{https://github.com/muratcankaracabey/latex_cv}{source code}}}
