mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
db8ea40c0a
- Fix 80 SwiftLint warnings (159 -> 79): vertical_whitespace, prefer_self_in_static_references, modifier_order, trailing_newline, trailing_whitespace, prefer_for_where, unneeded_synthesized_initializer, redundant_type_annotation, implicit_optional_initialization, superfluous_disable_command, shorthand_optional_binding, syntactic_sugar, empty_string, vertical_whitespace_closing_braces, identifier_name in BadgeModifier - Refactor StatusBar from direct Renderable to _StatusBarCore pattern (public View with real body wrapping private Renderable core)
37 lines
1.2 KiB
Swift
37 lines
1.2 KiB
Swift
// 🖥️ TUIKit — Terminal UI Kit for Swift
|
||
// ContentMode.swift
|
||
//
|
||
// Created by LAYERED.work
|
||
// License: MIT
|
||
|
||
// MARK: - ContentMode
|
||
|
||
/// Constants that define how a view's content fills the available space.
|
||
///
|
||
/// Use `ContentMode` with the ``View/aspectRatio(_:contentMode:)`` modifier
|
||
/// to control how an image or other content is scaled within its bounds.
|
||
///
|
||
/// - ``fit``: Scales content to fit within the bounds while preserving
|
||
/// the aspect ratio. The content may not fill the entire available space.
|
||
/// - ``fill``: Scales content to fill the bounds while preserving
|
||
/// the aspect ratio. The content may extend beyond the available space.
|
||
///
|
||
/// ## Usage
|
||
///
|
||
/// ```swift
|
||
/// Image(.file("photo.png"))
|
||
/// .aspectRatio(contentMode: .fit)
|
||
///
|
||
/// Image(.url("https://example.com/photo.png"))
|
||
/// .aspectRatio(16.0/9.0, contentMode: .fill)
|
||
/// ```
|
||
public enum ContentMode: Sendable, Equatable {
|
||
/// Scales content to fit within the parent by maintaining the
|
||
/// aspect ratio. The resulting dimensions are always within bounds.
|
||
case fit
|
||
|
||
/// Scales content to fill the parent by maintaining the aspect ratio.
|
||
/// The content may extend beyond the bounds along one dimension.
|
||
case fill
|
||
}
|