mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-04 11:42:39 -06: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. --> ## 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>
54 lines
2.2 KiB
Swift
54 lines
2.2 KiB
Swift
import Foundation
|
|
import SFSafeSymbols
|
|
import Shared
|
|
import UIKit
|
|
|
|
enum WebViewControllerButtons {
|
|
static var openInSafariButton: UIButton {
|
|
let openInSafariButton = UIButton(type: .custom)
|
|
let image = UIImage(resource: .compass).scaledToSize(.init(width: 7, height: 7))
|
|
.withTintColor(.haPrimary)
|
|
openInSafariButton.setImage(image, for: .normal)
|
|
openInSafariButton.backgroundColor = .white
|
|
openInSafariButton.tintColor = .white
|
|
openInSafariButton.layer.cornerRadius = 6
|
|
openInSafariButton.layer.shadowColor = UIColor.black.cgColor
|
|
openInSafariButton.layer.shadowRadius = 0.5
|
|
openInSafariButton.layer.shadowOpacity = 0.7
|
|
openInSafariButton.layer.shadowOffset = .init(width: 0, height: 0)
|
|
openInSafariButton.layer.masksToBounds = false
|
|
return openInSafariButton
|
|
}
|
|
|
|
private static func navigationButton(symbol: SFSymbol, accessibilityLabel: String) -> UIButton {
|
|
let button = UIButton(type: .system)
|
|
let image = UIImage(systemSymbol: symbol).withRenderingMode(.alwaysTemplate)
|
|
button.setImage(image, for: .normal)
|
|
button.tintColor = .label
|
|
button.accessibilityLabel = accessibilityLabel
|
|
// Add white shadow to improve visibility on dark backgrounds
|
|
button.layer.shadowColor = UIColor.gray.cgColor
|
|
button.layer.shadowRadius = 1.5
|
|
button.layer.shadowOpacity = 0.8
|
|
button.layer.shadowOffset = CGSize(width: 0, height: 0)
|
|
button.layer.masksToBounds = false
|
|
return button
|
|
}
|
|
|
|
static var backButton: UIButton {
|
|
navigationButton(symbol: .chevronLeft, accessibilityLabel: L10n.Mac.Navigation.GoBack.accessibilityLabel)
|
|
}
|
|
|
|
static var forwardButton: UIButton {
|
|
navigationButton(symbol: .chevronRight, accessibilityLabel: L10n.Mac.Navigation.GoForward.accessibilityLabel)
|
|
}
|
|
|
|
static var copyButton: UIButton {
|
|
navigationButton(symbol: .docOnDoc, accessibilityLabel: L10n.Mac.Copy.accessibilityLabel)
|
|
}
|
|
|
|
static var pasteButton: UIButton {
|
|
navigationButton(symbol: .docOnClipboard, accessibilityLabel: L10n.Mac.Paste.accessibilityLabel)
|
|
}
|
|
}
|