Files
Mauro 6160c44d67 Update copyright holding and dates (#4640)
* Update copyright holding and dates

* compound IDE Macros updated

* update copyright

* update copyrights done

* update templates and README
2025-10-21 14:34:56 +02:00

47 lines
1.7 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Compound
import SwiftUI
extension Label {
/// Creates a label using a local asset as a Compound icon and a title generated from a string.
/// The icon size will be 24pt, scaling relative to the `bodyLG` with Dynamic Type.
/// - Parameters:
/// - title: A string used as the labels title.
/// - iconAsset: The asset to use as the custom Compound icon.
///
/// The supplied asset should have a square frame or it may end up distorted.
init(_ title: some StringProtocol, iconAsset: ImageAsset) where Title == Text, Icon == CompoundIcon {
self.init {
Text(title)
} icon: {
CompoundIcon(customImage: iconAsset.swiftUIImage)
}
}
/// Creates a label using a local asset as a Compound icon and a title generated from a string.
/// - Parameters:
/// - title: A string used as the labels title.
/// - iconAsset: The asset to use as the custom Compound icon.
/// - size: The size of the icon.
/// - font: The font that the icon will scale relative to for Dynamic Type.
///
/// The supplied asset should have a square frame or it may end up distorted.
init(_ title: some StringProtocol,
iconAsset: ImageAsset,
iconSize: CompoundIcon.Size,
relativeTo font: Font) where Title == Text, Icon == CompoundIcon {
self.init {
Text(title)
} icon: {
CompoundIcon(customImage: iconAsset.swiftUIImage, size: iconSize, relativeTo: font)
}
}
}