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

29 lines
566 B
Swift

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