Skip to content

Commit

Permalink
docs: Explain IKIcon sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinperignon committed Nov 29, 2023
1 parent 78b0095 commit f767325
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Mail/Components/Buttons/IKButton/IKButtonLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ extension LabelStyle where Self == IKLabelStyle {
}

struct IKLabelStyle: LabelStyle {
private let size = IKIcon.Size.regular

func makeBody(configuration: Configuration) -> some View {
HStack(spacing: UIPadding.small) {
configuration.icon
Expand Down
28 changes: 13 additions & 15 deletions Mail/Components/IKIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ import MailResources
import SwiftUI

struct IKIcon: View {
enum Size {
case small, regular, large

var heightAndWidth: CGFloat {
switch self {
case .small:
return 12
case .regular:
return 16
case .large:
return 24
}
}
enum Size: CGFloat {
/// 12pt icon
case small = 12
/// 16pt icon
case regular = 16
/// 24pt icon
case large = 24
}

let icon: Image
Expand All @@ -52,10 +46,14 @@ struct IKIcon: View {
icon
.resizable()
.scaledToFit()
.frame(width: size.heightAndWidth, height: size.heightAndWidth)
.frame(width: size.rawValue, height: size.rawValue)
}
}

#Preview {
IKIcon(MailResourcesAsset.folder, size: .large)
HStack(spacing: UIPadding.regular) {
IKIcon(MailResourcesAsset.pencilPlain, size: .small)
IKIcon(MailResourcesAsset.pencilPlain, size: .regular)
IKIcon(MailResourcesAsset.pencilPlain, size: .large)
}
}

0 comments on commit f767325

Please sign in to comment.