Skip to content

Commit

Permalink
refactor: Use custom Label init instead of IKLabelView
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed Apr 23, 2024
1 parent 5ddb510 commit 7928cac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import MailResources
import SwiftUI

struct IKLabelView: View {
private let title: String
private let image: Image

init(_ title: String, image: Image) {
self.title = title
self.image = image
}

var body: some View {
Label {
extension Label where Title == Text, Icon == Image {
init(_ title: String, asset: Image) {
self.init {
Text(title)
} icon: {
image
asset
}
}
}

#Preview {
IKLabelView(MailResourcesStrings.Localizable.calendarNotInvited, image: MailResourcesAsset.socialMedia.swiftUIImage)
}
2 changes: 1 addition & 1 deletion Mail/Views/AI Writer/Proposition/AIPropositionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct AIPropositionMenu: View {
await aiModel.executeShortcut(action)
}
} label: {
IKLabelView(action.label, image: action.icon.swiftUIImage)
Label(action.label, asset: action.icon.swiftUIImage)
}
.disabled(aiModel.error != nil && action != .regenerate)
}
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct ComposeMessageView: View {
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: didTouchSend) {
IKLabelView(MailResourcesStrings.Localizable.send, image: MailResourcesAsset.send.swiftUIImage)
Label(MailResourcesStrings.Localizable.send, asset: MailResourcesAsset.send.swiftUIImage)
}
.disabled(isSendButtonDisabled)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,12 @@ struct CalendarBodyDetailsView: View {
}

Group {
IKLabelView(event.formattedDateTime, image: MailResourcesAsset.calendarBadgeClock.swiftUIImage)
Label(event.formattedDateTime, asset: MailResourcesAsset.calendarBadgeClock.swiftUIImage)
if let location = event.location, !location.isEmpty {
IKLabelView(location, image: MailResourcesAsset.pin.swiftUIImage)
Label(location, asset: MailResourcesAsset.pin.swiftUIImage)
}
if !iAmInvited && !event.attendees.isEmpty {
IKLabelView(
MailResourcesStrings.Localizable.calendarNotInvited,
image: MailResourcesAsset.socialMedia.swiftUIImage
)
Label(MailResourcesStrings.Localizable.calendarNotInvited, asset: MailResourcesAsset.socialMedia.swiftUIImage)
}
}
.labelStyle(.calendar())
Expand Down

0 comments on commit 7928cac

Please sign in to comment.