108 lines
5.0 KiB
Swift
108 lines
5.0 KiB
Swift
|
|
enum PageIcon: CaseIterable {
|
|
|
|
case time
|
|
|
|
case elevationUp
|
|
|
|
case elevationDown
|
|
|
|
case distance
|
|
|
|
case calories
|
|
|
|
case download
|
|
|
|
case externalLink
|
|
|
|
case gitLink
|
|
|
|
var icon: String {
|
|
switch self {
|
|
case .time: return PageIcon.timeIcon
|
|
case .elevationUp: return PageIcon.elevationUpIcon
|
|
case .elevationDown: return PageIcon.elevationDownIcon
|
|
case .distance: return PageIcon.distanceIcon
|
|
case .calories: return PageIcon.caloriesIcon
|
|
case .download: return PageIcon.downloadIcon
|
|
case .externalLink: return PageIcon.externalLinkIcon
|
|
case .gitLink: return PageIcon.gitLinkIcon
|
|
}
|
|
}
|
|
|
|
var name: String {
|
|
switch self {
|
|
case .time: return "icon-clock"
|
|
case .elevationUp: return "icon-arrow-up"
|
|
case .elevationDown: return "icon-arrow-down"
|
|
case .distance: return "icon-sign"
|
|
case .calories: return "icon-flame"
|
|
case .download: return "icon-download"
|
|
case .externalLink: return "icon-external"
|
|
case .gitLink: return "icon-git"
|
|
}
|
|
}
|
|
}
|
|
|
|
extension PageIcon {
|
|
|
|
|
|
private static let timeIcon =
|
|
"""
|
|
<svg id="icon-clock" width="16" height="16" viewBox="0 0 16 16">
|
|
<path fill="currentColor" d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .3.4l3.5 2a.5.5 0 0 0 .4-.8L8 8.7V3.5z"/>
|
|
<path fill="currentColor" d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let elevationUpIcon =
|
|
"""
|
|
<svg id="icon-arrow-up" width="16" height="16">
|
|
<path fill="currentColor" d="m14 2.5a.5.5 0 0 0 -.5-.5h-6a.5.5 0 0 0 0 1h4.8l-10.16 10.15a.5.5 0 0 0 .7.7l10.16-10.14v4.79a.5.5 0 0 0 1 0z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let elevationDownIcon =
|
|
"""
|
|
<svg id="icon-arrow-down" width="16" height="16">
|
|
<path fill="currentColor" fill-rule="evenodd" d="M14 13.5a.5.5 0 0 1-.5.5h-6a.5.5 0 0 1 0-1h4.8L2.14 2.85a.5.5 0 1 1 .7-.7L13 12.29V7.5a.5.5 0 0 1 1 0v6z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let distanceIcon =
|
|
"""
|
|
<svg id="icon-sign" width="16" height="16">
|
|
<path fill="currentColor" d="M7 1.4V4H2a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h5v6h2v-6h3.5a1 1 0 0 0 .8-.4l2-2.3a.5.5 0 0 0 0-.6l-2-2.3a1 1 0 0 0-.8-.4H9V1.4a1 1 0 0 0-2 0zM12.5 5l1.7 2-1.7 2H2V5h10.5z"/>
|
|
</svg>
|
|
|
|
"""
|
|
|
|
private static let caloriesIcon =
|
|
"""
|
|
<svg id="icon-flame" width="16" height="16">
|
|
<path fill="currentColor" d="M8 16c3.3 0 6-2 6-5.5 0-1.5-.5-4-2.5-6 .3 1.5-1.3 2-1.3 2C11 4 9 .5 6 0c.4 2 .5 4-2 6-1.3 1-2 2.7-2 4.5C2 14 4.7 16 8 16Zm0-1c-1.7 0-3-1-3-2.8 0-.7.3-2 1.3-3-.2.8.7 1.3.7 1.3-.4-1.3.5-3.3 2-3.5-.2 1-.3 2 1 3a3 3 0 0 1 1 2.3C11 14 9.7 15 8 15Z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let downloadIcon: String =
|
|
"""
|
|
<svg id="icon-download" viewBox="0 0 40 40">
|
|
<path fill="currentColor" fill-rule="evenodd" stroke="none" d="M20 40a20 20 0 1 1 20-20 20 20 0 0 1-20 20zm0-36.8A16.8 16.8 0 1 0 36.8 20 16.8 16.8 0 0 0 20 3.2zm.8 27a1 1 0 0 1-1.6 0L12.1 21c-.4-.4 0-1 .7-1H17v-8.7a.8.8 0 0 1 .8-.8h4.4a.8.8 0 0 1 .8.8V20h4.2c.6 0 1.1.5.7 1l-7.1 9.2z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let externalLinkIcon: String =
|
|
"""
|
|
<svg id="icon-external" viewBox="0 0 16 16">
|
|
<path fill="currentColor" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m7.5-6.923c-.67.204-1.335.82-1.887 1.855A8 8 0 0 0 5.145 4H7.5zM4.09 4a9.3 9.3 0 0 1 .64-1.539 7 7 0 0 1 .597-.933A7.03 7.03 0 0 0 2.255 4zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a7 7 0 0 0-.656 2.5zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5zM8.5 5v2.5h2.99a12.5 12.5 0 0 0-.337-2.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5zM5.145 12q.208.58.468 1.068c.552 1.035 1.218 1.65 1.887 1.855V12zm.182 2.472a7 7 0 0 1-.597-.933A9.3 9.3 0 0 1 4.09 12H2.255a7 7 0 0 0 3.072 2.472M3.82 11a13.7 13.7 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5zm6.853 3.472A7 7 0 0 0 13.745 12H11.91a9.3 9.3 0 0 1-.64 1.539 7 7 0 0 1-.597.933M8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855q.26-.487.468-1.068zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.7 13.7 0 0 1-.312 2.5m2.802-3.5a7 7 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7 7 0 0 0-3.072-2.472c.218.284.418.598.597.933M10.855 4a8 8 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4z"/>
|
|
</svg>
|
|
"""
|
|
|
|
private static let gitLinkIcon: String =
|
|
"""
|
|
<svg id="icon-git" viewBox="0 0 16 16">
|
|
<path fill="currentColor" d="M15.698 7.287 8.712.302a1.03 1.03 0 0 0-1.457 0l-1.45 1.45 1.84 1.84a1.223 1.223 0 0 1 1.55 1.56l1.773 1.774a1.224 1.224 0 0 1 1.267 2.025 1.226 1.226 0 0 1-2.002-1.334L8.58 5.963v4.353a1.226 1.226 0 1 1-1.008-.036V5.887a1.226 1.226 0 0 1-.666-1.608L5.093 2.465l-4.79 4.79a1.03 1.03 0 0 0 0 1.457l6.986 6.986a1.03 1.03 0 0 0 1.457 0l6.953-6.953a1.03 1.03 0 0 0 0-1.457"/>
|
|
</svg>
|
|
"""
|
|
}
|