mirror of
https://github.com/home-assistant/iOS.git
synced 2026-04-12 05:08:23 -05:00
<!-- 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="2030" height="494" alt="CleanShot 2026-03-31 at 10 36 48@2x" src="https://github.com/user-attachments/assets/539853f4-f8dc-46d6-a167-25af8ca0b399" /> ## 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. -->
91 lines
2.8 KiB
Swift
91 lines
2.8 KiB
Swift
import SwiftUI
|
|
|
|
public struct LabsLabel: View {
|
|
@Environment(\.openURL) private var openURL
|
|
@State private var showInfo = false
|
|
private let info: String?
|
|
|
|
public init(info: String? = nil) {
|
|
self.info = info
|
|
}
|
|
|
|
public var body: some View {
|
|
HStack(spacing: .zero) {
|
|
Image(uiImage: MaterialDesignIcons.testTubeIcon.image(
|
|
ofSize: .init(width: 15, height: 15),
|
|
color: .white
|
|
))
|
|
.padding(.leading, DesignSystem.Spaces.one)
|
|
Text("Labs")
|
|
.font(.caption2.bold())
|
|
.padding(.leading, DesignSystem.Spaces.half)
|
|
.padding(.trailing, DesignSystem.Spaces.one)
|
|
if info != nil {
|
|
Image(systemSymbol: .infoCircle)
|
|
.resizable()
|
|
.frame(width: 15, height: 15, alignment: .trailing)
|
|
.padding(.trailing, DesignSystem.Spaces.half)
|
|
}
|
|
}
|
|
.foregroundColor(.white)
|
|
.padding(.vertical, DesignSystem.Spaces.half)
|
|
.background(Color.orange)
|
|
.clipShape(Capsule())
|
|
.onTapGesture {
|
|
guard info != nil else { return }
|
|
showInfo = true
|
|
}
|
|
.sheet(isPresented: $showInfo) {
|
|
if #available(iOS 16.0, *) {
|
|
infoSheet
|
|
.presentationDetents([.medium, .large])
|
|
.presentationDragIndicator(.visible)
|
|
} else {
|
|
infoSheet
|
|
}
|
|
}
|
|
}
|
|
|
|
private var infoSheet: some View {
|
|
NavigationView {
|
|
ScrollView {
|
|
VStack {
|
|
Text(info ?? "")
|
|
.padding(DesignSystem.Spaces.two)
|
|
Spacer()
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.navigationTitle("Labs")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.navigationViewStyle(.stack)
|
|
.safeAreaInset(edge: .bottom) {
|
|
Button(action: {
|
|
openURL(AppConstants.WebURLs.issues)
|
|
}, label: {
|
|
Text(L10n.Experimental.Badge.ReportIssueButton.title)
|
|
})
|
|
.buttonStyle(.primaryButton)
|
|
.padding(.horizontal)
|
|
}
|
|
.toolbar {
|
|
ToolbarItem(placement: .topBarLeading) {
|
|
CloseButton {
|
|
showInfo = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview("Without info") {
|
|
LabsLabel()
|
|
}
|
|
|
|
#Preview("Info") {
|
|
LabsLabel(
|
|
info: "This is an information that can be linked to a beta label to describe what are the limitations and or the current state of the feature."
|
|
)
|
|
}
|