Tusker/Packages/TuskerPreferences/Sources/TuskerPreferences/AvatarStyle.swift

29 lines
566 B
Swift
Raw Normal View History

2018-08-28 23:16:17 +00:00
//
// AvatarStyle.swift
2023-04-18 23:47:49 +00:00
// TuskerPreferences
2018-08-28 23:16:17 +00:00
//
// Created by Shadowfacts on 8/28/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
2018-08-28 23:49:31 +00:00
import UIKit
2018-08-28 23:16:17 +00:00
2023-04-18 23:47:49 +00:00
public enum AvatarStyle: String, Codable {
2018-08-28 23:16:17 +00:00
case roundRect, circle
}
2018-08-28 23:49:31 +00:00
extension AvatarStyle {
2023-04-18 23:47:49 +00:00
public var cornerRadiusFraction: CGFloat {
2018-08-28 23:49:31 +00:00
switch self {
case .roundRect:
return 0.1
case .circle:
return 0.5
}
}
2023-04-18 23:47:49 +00:00
public func cornerRadius(for view: UIView) -> CGFloat {
2018-08-28 23:49:31 +00:00
return cornerRadiusFraction * view.frame.width
}
}