\LoadClass{article}

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{UiO_profile/UiO_profile}[2022/00/06 My custom CV class]

\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
\usepackage[T1]{fontenc}

\RequirePackage{geometry}
\RequirePackage{graphicx}
\RequirePackage{url}
\RequirePackage{array}
\RequirePackage{hyperref}
\RequirePackage[table,svgnames]{xcolor}
\RequirePackage{afterpage}
\RequirePackage{fix-cm}
\RequirePackage{lipsum}
\RequirePackage{sectsty}
\RequirePackage{tikz}
\RequirePackage{etoolbox}
\RequirePackage{pagecolor}
\RequirePackage{tikzpagenodes}
\RequirePackage{titling}
\RequirePackage{anyfontsize}
\usepackage[export]{adjustbox}

% UiO Brand colors
% Blue
\definecolor{UioBlue}{RGB}{67, 101, 226}
\definecolor{UioDarkBlue}{RGB}{61, 88, 151}
\definecolor{UioLightBlue}{RGB}{209,226,242}
% Green
\definecolor{UioRed}{RGB}{182, 0, 0}
\definecolor{UioDarkRed}{RGB}{61, 88, 151}
\definecolor{UioLightRed}{RGB}{251, 102, 102}
% Red

\definecolor{UiOFrontpageBackground}{RGB}{255, 255, 255}
\definecolor{UiOFrontpagePrimary}{RGB}{220, 221, 223}
\DeclareOption{red}{
  \definecolor{UiOFrontpageBackground}{RGB}{253, 224, 225}
  \definecolor{UiOFrontpagePrimary}{RGB}{251, 102, 102}
}
\DeclareOption{blue}{
  \definecolor{UiOFrontpageBackground}{RGB}{223, 231, 243}
  \definecolor{UiOFrontpagePrimary}{RGB}{124, 155, 206}
}
\DeclareOption{green}{
  \definecolor{UiOFrontpageBackground}{RGB}{197, 228, 207}
  \definecolor{UiOFrontpagePrimary}{RGB}{116, 198, 165}
}
\newif\iflangno
\DeclareOption{no}{\langnotrue}
\ProcessOptions\relax

%\usepackage{fontspec}
%\setromanfont{BaxterSans}[
%    Path=./Baxter/,
%    Extension = .otf,
%    UprightFont=*-Regular,
%    BoldFont=*-Bold,
%    ItalicFont=*-RegularItalic,
%    BoldItalicFont=*-BoldItalic
%    ]

%\sectionfont{\color{UioBlue}}
%\subsectionfont{\color{UioBlue}}

% Titlepage
\newcommand{\deliverabletitle}[2]{
    \def\@shortdeltitle{#1}
    \def\@deltitle{#2}
    \title{\@shortdeltitle}
}
\newcommand{\deliverableversion}[1]{
    \def\@deliverableversion{#1}
}
\newcommand{\programname}[1]{
  \def\@programname{#1}
}
\newcommand{\studypoints}[1]{
  \def\@studypoints{#1}
}
\newcommand{\branch}[2]{
  \def\@institute{#1}
  \def\@faculty{#2}
}
\newcommand{\uiotitlepage}{
  \thispagestyle{empty}
  \begin{titlepage}
    \begin{tikzpicture}[remember picture,overlay]
      % Bakgrunn
      \node (back names) [shape=rectangle, fill=UiOFrontpageBackground, minimum height=\paperheight, minimum width=\paperwidth, anchor=south west] at (current page.south west) {};
      
      % Segl
      \node[inner sep=0pt, anchor=south east] (uioname) at ([shift={(-10mm,10mm)}]back names.south east) {
        \includegraphics[width=23.7mm,right]{UiO_profile/profiles/03_uio_segl_pos.png}
      };

      % Dato
      \node[anchor=south west] (uioname) at ([shift={(10mm,10mm)}]back names.south west) {
        \ifdefined\thedate
          \thedate
        \else
        \fi
      };    
      
      % "Ribbon" bakgrunn
      \node (names) [shape=rectangle, fill=UiOFrontpagePrimary, minimum height=.25\paperheight, minimum width=\paperwidth, anchor=north west] at (current page.north west) {};
    
      % Navnetrekk
      \node[inner sep=0pt, anchor=north west] (uioname) at ([shift={(10mm,-10mm)}]names.north west) {
        \iflangno
          \includegraphics[width=63mm]{UiO_profile/profiles/03_uio_navnetrekk_no_pos.png}
        \else
          \includegraphics[width=63mm]{UiO_profile/profiles/03_uio_navnetrekk_eng_pos.png}
        \fi
      };
    
      % Chip 1
      \node[anchor=north west, fill=black, text=white, inner sep=5pt] (chip1) at ([shift={(10mm,15mm)}]names.south west) {
        \ifdefined\@deliverableversion
          \@deliverableversion
        \else
        \fi
      };
  
      % Tittel  
      \node[anchor=north west] (title) at ([shift={(10mm,-10mm)}]names.south west) {
        \ifdefined\@shortdeltitle
          \Huge\@shortdeltitle
        \else
        \fi
      };

      % Undertittel
      \node[anchor=north west] (subtitle) at ([shift={(0,-5mm)}]title.south west) {
        \ifdefined\@deltitle
          \@deltitle
        \else
        \fi
      };
    
      % Forfatter  
      \node[anchor=north west] (author) at ([shift={(0,-5mm)}]subtitle.south west) {
        \theauthor
      };
    
      % Studieprogram
      \node[anchor=north west] (program) at ([shift={(0,-5mm)}]author.south west) {
        \ifdefined\@programname
          \@programname
        \else
        \fi
      };
    
      % Studiepoeng
      \node[anchor=north west] (points) at ([shift={(0,0)}]program.south west) {
        \ifdefined\@studypoints
          \@studypoints\ \iflangno Studiepoeng\else Study points\fi
        \else
        \fi
      };
    
      % Institutt
      \node[anchor=north west] (institute) at ([shift={(0,-5mm)}]points.south west) {
        \ifdefined\@institute
         \@institute
        \else
        \fi
      };

      % Fakultet
      \node[anchor=north west] (faculty) at ([shift={(0,0)}]institute.south west) {
        \ifdefined\@faculty
          \@faculty
        \else
        \fi
      };

    
    \end{tikzpicture}
    \newpage
  \end{titlepage}
}

%\renewcommand*{\maketitle}{\uiotitlepage}