From f7673256724036b4034de97854bf6b0cd44fa606 Mon Sep 17 00:00:00 2001 From: Valentin Perignon Date: Wed, 29 Nov 2023 11:38:14 +0100 Subject: [PATCH] docs: Explain IKIcon sizes --- .../Buttons/IKButton/IKButtonLabel.swift | 2 -- Mail/Components/IKIcon.swift | 28 +++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Mail/Components/Buttons/IKButton/IKButtonLabel.swift b/Mail/Components/Buttons/IKButton/IKButtonLabel.swift index f015375f9..816bcfd66 100644 --- a/Mail/Components/Buttons/IKButton/IKButtonLabel.swift +++ b/Mail/Components/Buttons/IKButton/IKButtonLabel.swift @@ -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 diff --git a/Mail/Components/IKIcon.swift b/Mail/Components/IKIcon.swift index 4fc3f218b..af83ca121 100644 --- a/Mail/Components/IKIcon.swift +++ b/Mail/Components/IKIcon.swift @@ -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 @@ -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) + } }