mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-09 18:33:16 -06:00
Refactored WidgetBasicView to improve layout handling for compact and single-column widgets, including max height constraints and dynamic spacing. Moved corner radius logic in TileCardStyleModifier to a computed property for clarity. Updated DesignSystem corner radius constants for better documentation and added missing values. <!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> ## Screenshots <!-- If this is a user-facing change not in the frontend, please include screenshots in light and dark mode. --> <img width="2760" height="2320" alt="CleanShot 2026-01-28 at 14 50 06@2x" src="https://github.com/user-attachments/assets/2045b737-18f7-41a2-b1f7-bafa8093f36c" /> ## Link to pull request in Documentation repository <!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" --> Documentation: home-assistant/companion.home-assistant# ## Any other notes <!-- If there is any other information of note, like if this Pull Request is part of a bigger change, please include it here. --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
46 lines
1.4 KiB
Swift
46 lines
1.4 KiB
Swift
import Shared
|
|
import SwiftUI
|
|
|
|
extension View {
|
|
func tileCardStyle(sizeStyle: WidgetBasicSizeStyle, model: WidgetBasicViewModel, tinted: Bool) -> some View {
|
|
modifier(TileCardStyleModifier(sizeStyle: sizeStyle, tinted: tinted, model: model))
|
|
}
|
|
}
|
|
|
|
struct TileCardStyleModifier: ViewModifier {
|
|
let sizeStyle: WidgetBasicSizeStyle
|
|
let tinted: Bool
|
|
let model: WidgetBasicViewModel
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background({
|
|
if tinted {
|
|
return Color.clear
|
|
}
|
|
if model.useCustomColors {
|
|
return model.backgroundColor
|
|
} else {
|
|
return .tileBackground
|
|
}
|
|
}())
|
|
.clipShape(RoundedRectangle(cornerRadius: cornerRadius))
|
|
.overlay {
|
|
RoundedRectangle(cornerRadius: cornerRadius)
|
|
.stroke(Color.tileBorder, lineWidth: sizeStyle == .single ? 0 : 1)
|
|
.modify { view in
|
|
if #available(iOS 18, *) {
|
|
view.widgetAccentable()
|
|
} else {
|
|
view
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var cornerRadius: CGFloat {
|
|
sizeStyle == .compressed ? .zero : 14
|
|
}
|
|
}
|