2022-01-27 14:23:39 +01:00
|
|
|
// swiftlint:disable all
|
|
|
|
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
import AppKit
|
|
|
|
#elseif os(iOS)
|
|
|
|
import UIKit
|
|
|
|
#elseif os(tvOS) || os(watchOS)
|
|
|
|
import UIKit
|
|
|
|
#endif
|
2022-11-14 18:44:28 +01:00
|
|
|
#if canImport(SwiftUI)
|
|
|
|
import SwiftUI
|
|
|
|
#endif
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// Deprecated typealiases
|
|
|
|
@available(*, deprecated, renamed: "ColorAsset.Color", message: "This typealias will be removed in SwiftGen 7.0")
|
|
|
|
public typealias AssetColorTypeAlias = ColorAsset.Color
|
|
|
|
@available(*, deprecated, renamed: "ImageAsset.Image", message: "This typealias will be removed in SwiftGen 7.0")
|
|
|
|
public typealias AssetImageTypeAlias = ImageAsset.Image
|
|
|
|
|
|
|
|
// swiftlint:disable superfluous_disable_command file_length implicit_return
|
|
|
|
|
|
|
|
// MARK: - Asset Catalogs
|
|
|
|
|
|
|
|
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
|
|
|
|
public enum Asset {
|
2022-02-11 08:27:29 +01:00
|
|
|
public enum Arrow {
|
|
|
|
public static let `repeat` = ImageAsset(name: "Arrow/repeat")
|
2022-02-11 13:21:28 +01:00
|
|
|
public static let repeatSmall = ImageAsset(name: "Arrow/repeat.small")
|
2022-05-06 09:17:26 +02:00
|
|
|
public static let squareAndArrowUp = ImageAsset(name: "Arrow/square.and.arrow.up")
|
2022-02-11 08:27:29 +01:00
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Asset {
|
|
|
|
public static let email = ImageAsset(name: "Asset/email")
|
|
|
|
public static let friends = ImageAsset(name: "Asset/friends")
|
|
|
|
public static let mastodonTextLogo = ImageAsset(name: "Asset/mastodon.text.logo")
|
|
|
|
}
|
|
|
|
public enum Circles {
|
2022-07-13 11:44:47 +02:00
|
|
|
public static let forbidden20 = ImageAsset(name: "Circles/forbidden.20")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let plusCircleFill = ImageAsset(name: "Circles/plus.circle.fill")
|
|
|
|
public static let plusCircle = ImageAsset(name: "Circles/plus.circle")
|
|
|
|
}
|
|
|
|
public enum Colors {
|
|
|
|
public enum Border {
|
|
|
|
public static let composePoll = ColorAsset(name: "Colors/Border/compose.poll")
|
|
|
|
public static let searchCard = ColorAsset(name: "Colors/Border/searchCard")
|
|
|
|
public static let status = ColorAsset(name: "Colors/Border/status")
|
|
|
|
}
|
2022-12-18 02:08:58 +01:00
|
|
|
public enum Brand {
|
|
|
|
public static let blurple = ColorAsset(name: "Colors/Brand/Blurple")
|
2023-01-24 01:49:41 +01:00
|
|
|
public static let darkBlurple = ColorAsset(name: "Colors/Brand/Dark Blurple")
|
|
|
|
public static let eggplant = ColorAsset(name: "Colors/Brand/Eggplant")
|
2022-12-18 02:08:58 +01:00
|
|
|
public static let lightBlurple = ColorAsset(name: "Colors/Brand/Light Blurple")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Button {
|
|
|
|
public static let actionToolbar = ColorAsset(name: "Colors/Button/action.toolbar")
|
|
|
|
public static let disabled = ColorAsset(name: "Colors/Button/disabled")
|
|
|
|
public static let inactive = ColorAsset(name: "Colors/Button/inactive")
|
2022-11-23 17:54:53 +01:00
|
|
|
public static let tagFollow = ColorAsset(name: "Colors/Button/tagFollow")
|
|
|
|
public static let tagUnfollow = ColorAsset(name: "Colors/Button/tagUnfollow")
|
2023-04-25 12:48:53 +02:00
|
|
|
public static let userBlocked = ColorAsset(name: "Colors/Button/userBlocked")
|
|
|
|
public static let userFollow = ColorAsset(name: "Colors/Button/userFollow")
|
|
|
|
public static let userFollowing = ColorAsset(name: "Colors/Button/userFollowing")
|
2023-05-04 11:56:34 +02:00
|
|
|
public static let userFollowingTitle = ColorAsset(name: "Colors/Button/userFollowingTitle")
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
public enum Icon {
|
|
|
|
public static let plus = ColorAsset(name: "Colors/Icon/plus")
|
|
|
|
}
|
|
|
|
public enum Label {
|
|
|
|
public static let primary = ColorAsset(name: "Colors/Label/primary")
|
|
|
|
public static let primaryReverse = ColorAsset(name: "Colors/Label/primary.reverse")
|
|
|
|
public static let secondary = ColorAsset(name: "Colors/Label/secondary")
|
|
|
|
public static let tertiary = ColorAsset(name: "Colors/Label/tertiary")
|
|
|
|
}
|
|
|
|
public enum Notification {
|
|
|
|
public static let favourite = ColorAsset(name: "Colors/Notification/favourite")
|
|
|
|
public static let mention = ColorAsset(name: "Colors/Notification/mention")
|
|
|
|
public static let reblog = ColorAsset(name: "Colors/Notification/reblog")
|
|
|
|
}
|
|
|
|
public enum Poll {
|
|
|
|
public static let disabled = ColorAsset(name: "Colors/Poll/disabled")
|
|
|
|
}
|
2022-06-02 11:31:23 +02:00
|
|
|
public enum Primary {
|
|
|
|
public static let _300 = ColorAsset(name: "Colors/Primary/300")
|
|
|
|
public static let _700 = ColorAsset(name: "Colors/Primary/700")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Shadow {
|
|
|
|
public static let searchCard = ColorAsset(name: "Colors/Shadow/SearchCard")
|
|
|
|
}
|
|
|
|
public enum Slider {
|
|
|
|
public static let track = ColorAsset(name: "Colors/Slider/track")
|
|
|
|
}
|
|
|
|
public enum TextField {
|
|
|
|
public static let background = ColorAsset(name: "Colors/TextField/background")
|
|
|
|
public static let invalid = ColorAsset(name: "Colors/TextField/invalid")
|
|
|
|
public static let valid = ColorAsset(name: "Colors/TextField/valid")
|
|
|
|
}
|
|
|
|
public static let alertYellow = ColorAsset(name: "Colors/alert.yellow")
|
|
|
|
public static let badgeBackground = ColorAsset(name: "Colors/badge.background")
|
|
|
|
public static let battleshipGrey = ColorAsset(name: "Colors/battleshipGrey")
|
|
|
|
public static let dangerBorder = ColorAsset(name: "Colors/danger.border")
|
|
|
|
public static let danger = ColorAsset(name: "Colors/danger")
|
2022-06-05 10:31:56 +02:00
|
|
|
public enum Deprecated {
|
|
|
|
public static let brandBlue = ColorAsset(name: "Colors/deprecated/brand.blue")
|
|
|
|
public static let brandBlueDarken20 = ColorAsset(name: "Colors/deprecated/brand.blue.darken.20")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let disabled = ColorAsset(name: "Colors/disabled")
|
|
|
|
public static let inactive = ColorAsset(name: "Colors/inactive")
|
|
|
|
public static let mediaTypeIndicotor = ColorAsset(name: "Colors/media.type.indicotor")
|
2023-03-02 11:06:13 +01:00
|
|
|
public static let selectionHighlight = ColorAsset(name: "Colors/selection.highlight")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let successGreen = ColorAsset(name: "Colors/success.green")
|
|
|
|
public static let systemOrange = ColorAsset(name: "Colors/system.orange")
|
|
|
|
}
|
2022-02-11 08:27:29 +01:00
|
|
|
public enum Communication {
|
|
|
|
public static let bubbleLeftAndBubbleRight = ImageAsset(name: "Communication/bubble.left.and.bubble.right")
|
|
|
|
public static let share = ImageAsset(name: "Communication/share")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Connectivity {
|
|
|
|
public static let photoFillSplit = ImageAsset(name: "Connectivity/photo.fill.split")
|
|
|
|
}
|
2022-06-28 13:00:39 +02:00
|
|
|
public enum Editing {
|
2022-07-13 11:44:47 +02:00
|
|
|
public static let checkmark20 = ImageAsset(name: "Editing/checkmark.20")
|
2022-06-28 13:00:39 +02:00
|
|
|
public static let xmark = ImageAsset(name: "Editing/xmark")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Human {
|
2022-01-29 10:02:30 +01:00
|
|
|
public static let eyeCircleFill = ImageAsset(name: "Human/eye.circle.fill")
|
|
|
|
public static let eyeSlashCircleFill = ImageAsset(name: "Human/eye.slash.circle.fill")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let faceSmilingAdaptive = ImageAsset(name: "Human/face.smiling.adaptive")
|
|
|
|
}
|
2022-02-11 08:27:29 +01:00
|
|
|
public enum ObjectsAndTools {
|
2022-07-29 22:31:38 +02:00
|
|
|
public static let bookmarkFill = ImageAsset(name: "ObjectsAndTools/bookmark.fill")
|
|
|
|
public static let bookmark = ImageAsset(name: "ObjectsAndTools/bookmark")
|
2022-05-06 08:29:34 +02:00
|
|
|
public static let gear = ImageAsset(name: "ObjectsAndTools/gear")
|
2022-02-11 08:27:29 +01:00
|
|
|
public static let starFill = ImageAsset(name: "ObjectsAndTools/star.fill")
|
|
|
|
public static let star = ImageAsset(name: "ObjectsAndTools/star")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Scene {
|
2022-10-18 13:01:31 +02:00
|
|
|
public enum Compose {
|
2022-11-08 12:40:58 +01:00
|
|
|
public enum Attachment {
|
|
|
|
public static let indicatorButtonBackground = ColorAsset(name: "Scene/Compose/Attachment/indicator.button.background")
|
|
|
|
public static let retry = ImageAsset(name: "Scene/Compose/Attachment/retry")
|
|
|
|
public static let stop = ImageAsset(name: "Scene/Compose/Attachment/stop")
|
|
|
|
}
|
2022-11-01 07:14:00 +01:00
|
|
|
public static let earth = ImageAsset(name: "Scene/Compose/Earth")
|
|
|
|
public static let mention = ImageAsset(name: "Scene/Compose/Mention")
|
|
|
|
public static let more = ImageAsset(name: "Scene/Compose/More")
|
|
|
|
public static let people = ImageAsset(name: "Scene/Compose/People")
|
2022-10-18 13:01:31 +02:00
|
|
|
public static let buttonTint = ColorAsset(name: "Scene/Compose/button.tint")
|
2022-10-21 13:12:44 +02:00
|
|
|
public static let chatWarningFill = ImageAsset(name: "Scene/Compose/chat.warning.fill")
|
2022-10-18 13:01:31 +02:00
|
|
|
public static let chatWarning = ImageAsset(name: "Scene/Compose/chat.warning")
|
2022-10-21 13:12:44 +02:00
|
|
|
public static let emojiFill = ImageAsset(name: "Scene/Compose/emoji.fill")
|
2022-10-18 13:01:31 +02:00
|
|
|
public static let emoji = ImageAsset(name: "Scene/Compose/emoji")
|
|
|
|
public static let media = ImageAsset(name: "Scene/Compose/media")
|
2022-10-21 13:12:44 +02:00
|
|
|
public static let peopleAdd = ImageAsset(name: "Scene/Compose/people.add")
|
|
|
|
public static let pollFill = ImageAsset(name: "Scene/Compose/poll.fill")
|
2022-10-18 13:01:31 +02:00
|
|
|
public static let poll = ImageAsset(name: "Scene/Compose/poll")
|
2023-02-16 16:23:02 +01:00
|
|
|
public static let questionmarkCircle = ImageAsset(name: "Scene/Compose/questionmark.circle")
|
2022-10-26 12:35:10 +02:00
|
|
|
public static let reorderDot = ImageAsset(name: "Scene/Compose/reorder.dot")
|
2022-10-18 13:01:31 +02:00
|
|
|
}
|
2022-04-14 15:15:21 +02:00
|
|
|
public enum Discovery {
|
|
|
|
public static let profileCardBackground = ColorAsset(name: "Scene/Discovery/profile.card.background")
|
|
|
|
}
|
2023-03-02 11:06:13 +01:00
|
|
|
public enum EditHistory {
|
|
|
|
public static let edit = ImageAsset(name: "Scene/Edit History/Edit")
|
|
|
|
public static let statusBackground = ColorAsset(name: "Scene/Edit History/StatusBackground")
|
|
|
|
public static let statusBackgroundBorder = ColorAsset(name: "Scene/Edit History/StatusBackgroundBorder")
|
|
|
|
}
|
2022-07-13 11:44:47 +02:00
|
|
|
public enum Notification {
|
|
|
|
public static let confirmFollowRequestButtonBackground = ColorAsset(name: "Scene/Notification/confirm.follow.request.button.background")
|
|
|
|
public static let deleteFollowRequestButtonBackground = ColorAsset(name: "Scene/Notification/delete.follow.request.button.background")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Onboarding {
|
|
|
|
public static let avatarPlaceholder = ImageAsset(name: "Scene/Onboarding/avatar.placeholder")
|
2022-02-15 11:15:58 +01:00
|
|
|
public static let background = ColorAsset(name: "Scene/Onboarding/background")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let navigationBackButtonBackground = ColorAsset(name: "Scene/Onboarding/navigation.back.button.background")
|
|
|
|
public static let navigationBackButtonBackgroundHighlighted = ColorAsset(name: "Scene/Onboarding/navigation.back.button.background.highlighted")
|
|
|
|
public static let navigationNextButtonBackground = ColorAsset(name: "Scene/Onboarding/navigation.next.button.background")
|
|
|
|
public static let navigationNextButtonBackgroundHighlighted = ColorAsset(name: "Scene/Onboarding/navigation.next.button.background.highlighted")
|
|
|
|
public static let searchBarBackground = ColorAsset(name: "Scene/Onboarding/search.bar.background")
|
|
|
|
public static let textFieldBackground = ColorAsset(name: "Scene/Onboarding/textField.background")
|
|
|
|
}
|
|
|
|
public enum Profile {
|
2022-11-11 21:34:26 +01:00
|
|
|
public enum About {
|
2023-11-04 23:52:43 +01:00
|
|
|
public static let verifiedCheckmark = ImageAsset(name: "Scene/Profile/About/verified_checkmark")
|
2022-11-11 21:34:26 +01:00
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Banner {
|
|
|
|
public static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray")
|
|
|
|
public static let nameEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/name.edit.background.gray")
|
|
|
|
public static let usernameGray = ColorAsset(name: "Scene/Profile/Banner/username.gray")
|
|
|
|
}
|
2022-02-15 10:13:02 +01:00
|
|
|
public enum RelationshipButton {
|
2023-10-19 13:09:59 +02:00
|
|
|
public static let background = ColorAsset(name: "Scene/Profile/RelationshipButton/background")
|
|
|
|
public static let backgroundHighlighted = ColorAsset(name: "Scene/Profile/RelationshipButton/background.highlighted")
|
2022-02-15 10:13:02 +01:00
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
2022-02-08 05:36:06 +01:00
|
|
|
public enum Report {
|
|
|
|
public static let background = ColorAsset(name: "Scene/Report/background")
|
|
|
|
public static let reportBanner = ColorAsset(name: "Scene/Report/report.banner")
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
public enum Sidebar {
|
|
|
|
public static let logo = ImageAsset(name: "Scene/Sidebar/logo")
|
|
|
|
}
|
|
|
|
public enum Welcome {
|
|
|
|
public enum Illustration {
|
|
|
|
public static let backgroundCyan = ColorAsset(name: "Scene/Welcome/illustration/background.cyan")
|
2023-04-08 23:10:34 +02:00
|
|
|
public static let backgroundGreen = ColorAsset(name: "Scene/Welcome/illustration/background.green")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let cloudBaseExtend = ImageAsset(name: "Scene/Welcome/illustration/cloud.base.extend")
|
|
|
|
public static let cloudBase = ImageAsset(name: "Scene/Welcome/illustration/cloud.base")
|
|
|
|
public static let elephantOnAirplaneWithContrail = ImageAsset(name: "Scene/Welcome/illustration/elephant.on.airplane.with.contrail")
|
|
|
|
public static let elephantThreeOnGrassExtend = ImageAsset(name: "Scene/Welcome/illustration/elephant.three.on.grass.extend")
|
|
|
|
public static let elephantThreeOnGrass = ImageAsset(name: "Scene/Welcome/illustration/elephant.three.on.grass")
|
|
|
|
public static let elephantThreeOnGrassWithTreeThree = ImageAsset(name: "Scene/Welcome/illustration/elephant.three.on.grass.with.tree.three")
|
|
|
|
public static let elephantThreeOnGrassWithTreeTwo = ImageAsset(name: "Scene/Welcome/illustration/elephant.three.on.grass.with.tree.two")
|
|
|
|
}
|
|
|
|
public static let mastodonLogo = ImageAsset(name: "Scene/Welcome/mastodon.logo")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public enum Settings {
|
2023-10-10 13:55:18 +02:00
|
|
|
public static let aboutInstancePlaceholder = ImageAsset(name: "Settings/about_instance_placeholder")
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
public enum Theme {
|
|
|
|
public enum System {
|
2022-10-26 12:35:10 +02:00
|
|
|
public static let composePollRowBackground = ColorAsset(name: "Theme/system/compose.poll.row.background")
|
2022-01-27 14:23:39 +01:00
|
|
|
public static let composeToolbarBackground = ColorAsset(name: "Theme/system/compose.toolbar.background")
|
|
|
|
public static let contentWarningOverlayBackground = ColorAsset(name: "Theme/system/content.warning.overlay.background")
|
|
|
|
public static let navigationBarBackground = ColorAsset(name: "Theme/system/navigation.bar.background")
|
|
|
|
public static let sidebarBackground = ColorAsset(name: "Theme/system/sidebar.background")
|
|
|
|
public static let systemElevatedBackground = ColorAsset(name: "Theme/system/system.elevated.background")
|
|
|
|
public static let tabBarBackground = ColorAsset(name: "Theme/system/tab.bar.background")
|
|
|
|
public static let tableViewCellBackground = ColorAsset(name: "Theme/system/table.view.cell.background")
|
|
|
|
public static let tableViewCellSelectionBackground = ColorAsset(name: "Theme/system/table.view.cell.selection.background")
|
|
|
|
public static let separator = ColorAsset(name: "Theme/system/separator")
|
|
|
|
public static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/system/tab.bar.item.inactive.icon.color")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
|
|
|
|
|
|
|
|
// MARK: - Implementation Details
|
|
|
|
|
|
|
|
public final class ColorAsset {
|
|
|
|
public fileprivate(set) var name: String
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
public typealias Color = NSColor
|
|
|
|
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
|
|
public typealias Color = UIColor
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *)
|
|
|
|
public private(set) lazy var color: Color = {
|
|
|
|
guard let color = Color(asset: self) else {
|
|
|
|
fatalError("Unable to load color asset named \(name).")
|
|
|
|
}
|
|
|
|
return color
|
|
|
|
}()
|
|
|
|
|
2022-11-14 18:44:28 +01:00
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
|
@available(iOS 11.0, tvOS 11.0, *)
|
|
|
|
public func color(compatibleWith traitCollection: UITraitCollection) -> Color {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
guard let color = Color(named: name, in: bundle, compatibleWith: traitCollection) else {
|
|
|
|
fatalError("Unable to load color asset named \(name).")
|
|
|
|
}
|
|
|
|
return color
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if canImport(SwiftUI)
|
|
|
|
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
|
|
|
|
public private(set) lazy var swiftUIColor: SwiftUI.Color = {
|
|
|
|
SwiftUI.Color(asset: self)
|
|
|
|
}()
|
|
|
|
#endif
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
fileprivate init(name: String) {
|
|
|
|
self.name = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public extension ColorAsset.Color {
|
|
|
|
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *)
|
|
|
|
convenience init?(asset: ColorAsset) {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
|
self.init(named: asset.name, in: bundle, compatibleWith: nil)
|
|
|
|
#elseif os(macOS)
|
|
|
|
self.init(named: NSColor.Name(asset.name), bundle: bundle)
|
|
|
|
#elseif os(watchOS)
|
|
|
|
self.init(named: asset.name)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-14 18:44:28 +01:00
|
|
|
#if canImport(SwiftUI)
|
|
|
|
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
|
|
|
|
public extension SwiftUI.Color {
|
|
|
|
init(asset: ColorAsset) {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
self.init(asset.name, bundle: bundle)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
public struct ImageAsset {
|
|
|
|
public fileprivate(set) var name: String
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
public typealias Image = NSImage
|
|
|
|
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
|
|
public typealias Image = UIImage
|
|
|
|
#endif
|
|
|
|
|
2022-11-14 18:44:28 +01:00
|
|
|
@available(iOS 8.0, tvOS 9.0, watchOS 2.0, macOS 10.7, *)
|
2022-01-27 14:23:39 +01:00
|
|
|
public var image: Image {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
|
let image = Image(named: name, in: bundle, compatibleWith: nil)
|
|
|
|
#elseif os(macOS)
|
|
|
|
let name = NSImage.Name(self.name)
|
|
|
|
let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name)
|
|
|
|
#elseif os(watchOS)
|
|
|
|
let image = Image(named: name)
|
|
|
|
#endif
|
|
|
|
guard let result = image else {
|
|
|
|
fatalError("Unable to load image asset named \(name).")
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2022-11-14 18:44:28 +01:00
|
|
|
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
|
@available(iOS 8.0, tvOS 9.0, *)
|
|
|
|
public func image(compatibleWith traitCollection: UITraitCollection) -> Image {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
guard let result = Image(named: name, in: bundle, compatibleWith: traitCollection) else {
|
|
|
|
fatalError("Unable to load image asset named \(name).")
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if canImport(SwiftUI)
|
|
|
|
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
|
|
|
|
public var swiftUIImage: SwiftUI.Image {
|
|
|
|
SwiftUI.Image(asset: self)
|
|
|
|
}
|
|
|
|
#endif
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public extension ImageAsset.Image {
|
2022-11-14 18:44:28 +01:00
|
|
|
@available(iOS 8.0, tvOS 9.0, watchOS 2.0, *)
|
2022-01-27 14:23:39 +01:00
|
|
|
@available(macOS, deprecated,
|
|
|
|
message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
|
|
|
|
convenience init?(asset: ImageAsset) {
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
|
let bundle = Bundle.module
|
|
|
|
self.init(named: asset.name, in: bundle, compatibleWith: nil)
|
|
|
|
#elseif os(macOS)
|
|
|
|
self.init(named: NSImage.Name(asset.name))
|
|
|
|
#elseif os(watchOS)
|
|
|
|
self.init(named: asset.name)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2022-11-14 18:44:28 +01:00
|
|
|
|
|
|
|
#if canImport(SwiftUI)
|
|
|
|
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
|
|
|
|
public extension SwiftUI.Image {
|
|
|
|
init(asset: ImageAsset) {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
self.init(asset.name, bundle: bundle)
|
|
|
|
}
|
|
|
|
|
|
|
|
init(asset: ImageAsset, label: Text) {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
self.init(asset.name, bundle: bundle, label: label)
|
|
|
|
}
|
|
|
|
|
|
|
|
init(decorative asset: ImageAsset) {
|
|
|
|
let bundle = Bundle.module
|
|
|
|
self.init(decorative: asset.name, bundle: bundle)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|