Skip to content

Commit

Permalink
Merge pull request #1113 from Infomaniak/refactor-icons
Browse files Browse the repository at this point in the history
refactor: Icons
  • Loading branch information
valentinperignon authored Nov 14, 2023
2 parents 971bcf2 + ab4640a commit 1853383
Show file tree
Hide file tree
Showing 32 changed files with 148 additions and 149 deletions.
4 changes: 1 addition & 3 deletions Mail/Components/AttachmentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ struct AttachmentView<Content: View>: View {
var body: some View {
VStack(spacing: 0) {
HStack {
attachment.icon.swiftUIImage
.resizable()
.frame(width: 24, height: 24)
IKIcon(size: .large, image: attachment.icon, shapeStyle: MailResourcesAsset.textSecondaryColor.swiftUIColor)

HStack(spacing: UIPadding.small) {
VStack(alignment: .leading, spacing: 0) {
Expand Down
5 changes: 1 addition & 4 deletions Mail/Components/Buttons/MenuDrawerButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ struct MenuDrawerButton: View {
matomo.track(eventWithCategory: .menuDrawer, name: "openByButton")
navigationDrawerState.open()
} label: {
MailResourcesAsset.burger.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: UIConstants.navbarIconSize, height: UIConstants.navbarIconSize)
IKIcon(size: .large, image: MailResourcesAsset.burger)
}
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonMenu)
}
Expand Down
5 changes: 1 addition & 4 deletions Mail/Components/Buttons/SearchButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ struct SearchButton: View {
Button {
mainViewState.isShowingSearch = true
} label: {
MailResourcesAsset.search.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: UIConstants.navbarIconSize, height: UIConstants.navbarIconSize)
IKIcon(size: .large, image: MailResourcesAsset.search)
}
}
}
54 changes: 54 additions & 0 deletions Mail/Components/IKIcon.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import MailCore
import MailResources
import SwiftUI

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

var heightAndWidth: CGFloat {
switch self {
case .small:
return 12
case .medium:
return 16
case .large:
return 24
}
}
}

let size: Size
var image: MailResourcesImages
var shapeStyle: any ShapeStyle = Color.accentColor

var body: some View {
image.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: size.heightAndWidth, height: size.heightAndWidth)
.foregroundStyle(AnyShapeStyle(shapeStyle))
}
}

#Preview {
IKIcon(size: .large, image: MailResourcesAsset.folder)
}
9 changes: 5 additions & 4 deletions Mail/Components/MailboxListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ struct MailboxListView: View {
NavigationLink {
AddMailboxView()
} label: {
MailResourcesAsset.addCircle.swiftUIImage
.resizable()
.foregroundStyle(.tint)
.frame(width: 16, height: 16)
IKIcon(
size: .medium,
image: MailResourcesAsset.addCircle,
shapeStyle: MailResourcesAsset.textSecondaryColor.swiftUIColor
)
}
}
.padding(value: .regular)
Expand Down
18 changes: 10 additions & 8 deletions Mail/Components/SearchTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ struct SearchTextField: View {
var body: some View {
HStack(spacing: UIPadding.small) {
Button(action: onSubmit) {
MailResourcesAsset.search.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
IKIcon(
size: .medium,
image: MailResourcesAsset.search,
shapeStyle: MailResourcesAsset.textTertiaryColor.swiftUIColor
)
}
.foregroundStyle(MailResourcesAsset.textTertiaryColor)
TextField(MailResourcesStrings.Localizable.searchFieldPlaceholder, text: $value)
.autocorrectionDisabled()
.submitLabel(.search)
Expand All @@ -55,11 +56,12 @@ struct SearchTextField: View {
.padding(.vertical, value: .intermediate)

Button(action: onDelete) {
MailResourcesAsset.remove.swiftUIImage
.resizable()
.frame(width: 18, height: 18)
IKIcon(
size: .medium,
image: MailResourcesAsset.remove,
shapeStyle: MailResourcesAsset.textTertiaryColor.swiftUIColor
)
}
.foregroundStyle(MailResourcesAsset.textTertiaryColor)
.opacity(value.isEmpty ? 0 : 1)
}
.padding(.horizontal, value: .intermediate)
Expand Down
16 changes: 6 additions & 10 deletions Mail/Components/ThreadCellDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ struct ThreadCellDetailsView: View {
var body: some View {
HStack(spacing: UIPadding.small) {
if hasAttachments {
MailResourcesAsset.attachment.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.textPrimaryColor)
.scaledToFit()
.frame(height: 16)
IKIcon(
size: .medium,
image: MailResourcesAsset.attachment,
shapeStyle: MailResourcesAsset.textPrimaryColor.swiftUIColor
)
}
if isFlagged {
MailResourcesAsset.starFull.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.yellowColor)
.scaledToFit()
.frame(width: 16, height: 16)
IKIcon(size: .medium, image: MailResourcesAsset.starFull, shapeStyle: MailResourcesAsset.yellowColor.swiftUIColor)
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions Mail/Utils/CheckmarkToggleStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ struct CheckmarkToggleStyle: ToggleStyle {
RoundedRectangle(cornerRadius: 2)
.fill(.tint)

MailResourcesAsset.check.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.backgroundColor)
.padding(2)
IKIcon(
size: .medium,
image: MailResourcesAsset.check,
shapeStyle: MailResourcesAsset.backgroundColor.swiftUIColor
)
.padding(2)
}
.opacity(configuration.isOn ? 1 : 0)
}
Expand Down
5 changes: 1 addition & 4 deletions Mail/Views/AI Writer/AIHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ struct AIHeaderView: View {
var body: some View {
HStack(spacing: UIPadding.small) {
if style == .bottomSheet {
MailResourcesAsset.aiWriter.swiftUIImage
.resizable()
.frame(width: 24, height: 24)
.foregroundStyle(MailResourcesAsset.aiColor)
IKIcon(size: .large, image: MailResourcesAsset.aiWriter, shapeStyle: MailResourcesAsset.aiColor.swiftUIColor)
}

Text(MailResourcesStrings.Localizable.aiPromptTitle)
Expand Down
9 changes: 5 additions & 4 deletions Mail/Views/AI Writer/Proposition/AIPropositionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ struct AIPropositionMenu: View {
}
} label: {
HStack(spacing: UIPadding.small) {
MailResourcesAsset.pencil.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
IKIcon(
size: .large,
image: MailResourcesAsset.pencil,
shapeStyle: MailResourcesAsset.textSecondaryColor.swiftUIColor
)
Text(MailResourcesStrings.Localizable.aiButtonRefine)
}
}
Expand Down
5 changes: 1 addition & 4 deletions Mail/Views/Attachment/AttachmentPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ struct AttachmentPreview: View {
Text(MailResourcesStrings.Localizable.buttonDownload)
.font(MailTextStyle.labelSecondary.font)
} icon: {
MailResourcesAsset.download.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 22, height: 22)
IKIcon(size: .large, image: MailResourcesAsset.download)
}
.dynamicLabelStyle(sizeClass: sizeClass ?? .regular)
}
Expand Down
4 changes: 1 addition & 3 deletions Mail/Views/Menu Drawer/Folders/FolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ struct FolderCellContent: View {
}
}
} else if isCurrentFolder {
MailResourcesAsset.check.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
IKIcon(size: .medium, image: MailResourcesAsset.check)
}
}

Expand Down
4 changes: 1 addition & 3 deletions Mail/Views/Menu Drawer/Folders/UserFoldersListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ struct UserFoldersListView: View {
matomo.track(eventWithCategory: .createFolder, name: "fromMenuDrawer")
isShowingCreateFolderAlert.toggle()
} label: {
MailResourcesAsset.addCircle.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
IKIcon(size: .medium, image: MailResourcesAsset.addCircle)
}
.accessibilityLabel(MailResourcesStrings.Localizable.newFolderDialogTitle)
.customAlert(isPresented: $isShowingCreateFolderAlert) {
Expand Down
6 changes: 1 addition & 5 deletions Mail/Views/Menu Drawer/Items/MenuDrawerItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ struct MenuDrawerItemCell: View {
action()
} label: {
HStack(spacing: UIPadding.menuDrawerCellSpacing) {
icon.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
.foregroundStyle(.tint)
IKIcon(size: .large, image: icon)

Text(label)
.textStyle(.bodyMedium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ struct MailboxesManagementView: View {
}
} label: {
HStack(spacing: UIPadding.menuDrawerCellSpacing) {
MailResourcesAsset.envelope.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
.foregroundStyle(.tint)
IKIcon(size: .large, image: MailResourcesAsset.envelope)

Text(mailboxManager.mailbox.email)
.textStyle(navigationDrawerState.showMailboxes ? .bodyMediumAccent : .bodyMedium)
Expand Down
6 changes: 1 addition & 5 deletions Mail/Views/Menu Drawer/MailboxQuotaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ private struct QuotaCircularProgressViewStyle: ProgressViewStyle {
.rotationEffect(.degrees(-90))
.frame(width: UIConstants.menuDrawerQuotaSize)

MailResourcesAsset.drawer.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 16, height: 16)
.foregroundStyle(.tint)
IKIcon(size: .medium, image: MailResourcesAsset.drawer)
}
.frame(height: UIConstants.menuDrawerQuotaSize)
}
Expand Down
5 changes: 1 addition & 4 deletions Mail/Views/Menu Drawer/MenuHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ struct MenuHeaderView: View {
Button {
isShowingSettings.toggle()
} label: {
MailResourcesAsset.cog.swiftUIImage
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
IKIcon(size: .large, image: MailResourcesAsset.cog)
}
.buttonStyle(.borderless)
.accessibilityLabel(MailResourcesStrings.Localizable.settingsTitle)
Expand Down
9 changes: 5 additions & 4 deletions Mail/Views/New Message/Attachments/AttachmentUploadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ struct AttachmentUploadCell: View {
attachmentRemoved(attachment)
}
} label: {
MailResourcesAsset.close.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.textSecondaryColor)
.frame(width: 12, height: 12)
IKIcon(
size: .small,
image: MailResourcesAsset.close,
shapeStyle: MailResourcesAsset.textSecondaryColor.swiftUIColor
)
}
.buttonStyle(.borderless)
}
Expand Down
9 changes: 5 additions & 4 deletions Mail/Views/New Message/AutocompletionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ struct AutocompletionCell: View {
.opacity(alreadyAppend && !unknownRecipient ? 0.5 : 1)

if alreadyAppend && !unknownRecipient {
MailResourcesAsset.checked.swiftUIImage
.resizable()
.frame(width: 24, height: 24)
.foregroundStyle(MailResourcesAsset.textTertiaryColor)
IKIcon(
size: .large,
image: MailResourcesAsset.checked,
shapeStyle: MailResourcesAsset.textTertiaryColor.swiftUIColor
)
}
}
.padding(.horizontal, value: .regular)
Expand Down
18 changes: 10 additions & 8 deletions Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,22 @@ struct ComposeMessageView: View {
matomo.track(eventWithCategory: .externals, name: "bannerInfo")
alert.state = .externalRecipient(state: externalTag)
} label: {
MailResourcesAsset.info.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.onTagExternalColor)
.frame(width: 16, height: 16)
IKIcon(
size: .medium,
image: MailResourcesAsset.info,
shapeStyle: MailResourcesAsset.onTagExternalColor.swiftUIColor
)
}

Button {
matomo.track(eventWithCategory: .externals, name: "bannerManuallyClosed")
isShowingExternalTag = false
} label: {
MailResourcesAsset.close.swiftUIImage
.resizable()
.foregroundStyle(MailResourcesAsset.onTagExternalColor)
.frame(width: 16, height: 16)
IKIcon(
size: .medium,
image: MailResourcesAsset.close,
shapeStyle: MailResourcesAsset.onTagExternalColor.swiftUIColor
)
}
}
.frame(maxWidth: .infinity)
Expand Down
8 changes: 5 additions & 3 deletions Mail/Views/New Message/RecipientField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ struct RecipientField: View {
Button {
currentText = ""
} label: {
MailResourcesAsset.remove.swiftUIImage
.resizable()
.frame(width: 18, height: 18)
IKIcon(
size: .medium,
image: MailResourcesAsset.remove,
shapeStyle: MailResourcesAsset.textTertiaryColor.swiftUIColor
)
}
.foregroundStyle(MailResourcesAsset.textTertiaryColor)
.opacity(shouldDisplayEmptyButton ? 1 : 0)
Expand Down
4 changes: 1 addition & 3 deletions Mail/Views/Search/SearchFilterCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ struct SearchFilterCell: View {
var body: some View {
HStack(spacing: UIPadding.searchFolderCellSpacing) {
if isSelected {
MailResourcesAsset.check.swiftUIImage
.resizable()
.frame(width: 12, height: 12)
IKIcon(size: .small, image: MailResourcesAsset.check, shapeStyle: HierarchicalShapeStyle.primary)
}
Text(title)
.font(MailTextStyle.bodyMedium.font)
Expand Down
4 changes: 1 addition & 3 deletions Mail/Views/Search/SearchFilterFolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ struct SearchFilterFolderCell: View {
} label: {
HStack(spacing: UIPadding.searchFolderCellSpacing) {
if isSelected {
MailResourcesAsset.check.swiftUIImage
.resizable()
.frame(width: 12, height: 12)
IKIcon(size: .small, image: MailResourcesAsset.check, shapeStyle: HierarchicalShapeStyle.primary)
}
Text(selectedFolderName)
.font(MailTextStyle.bodyMedium.font)
Expand Down
Loading

0 comments on commit 1853383

Please sign in to comment.