Files
iOS/Sources/Shared/DesignSystem/Components/ModalCloseButton.swift
Bruno Pantaleão Gonçalves cbaac4acf9 Improve mac empty state UI (#4813)
<!-- 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="2542" height="1494" alt="CleanShot 2026-06-23 at 15 37
01@2x"
src="https://github.com/user-attachments/assets/02570900-d21f-4f56-9ad5-396e19f20c4f"
/>

## 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 Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-23 16:35:51 +02:00

41 lines
915 B
Swift

#if !os(watchOS)
import SwiftUI
public struct ModalCloseButton: View {
@Environment(\.dismiss) private var dismiss
private let alternativeAction: (() -> Void)?
private let tint: Color
/// When alternative action is set, the button will execute this action instead of dismissing the view.
public init(
tint: Color = Color.secondary,
alternativeAction: (() -> Void)? = nil
) {
self.alternativeAction = alternativeAction
self.tint = tint
}
public var body: some View {
ModalReusableButton(
tint: tint,
icon: .sfSymbol(.xmark),
action: tapAction
)
}
private func tapAction() {
if let alternativeAction {
alternativeAction()
} else {
dismiss()
}
}
}
#Preview {
ModalCloseButton(alternativeAction: {
/* no-op */
})
}
#endif