Revision control

Copy as Markdown

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import UIKit
public struct ToolbarElement {
/// Icon name of the toolbar element
let iconName: String
/// Number of open tabs
let numberOfTabs: Int?
/// Whether the toolbar element can be interacted with
let isEnabled: Bool
/// Indicates if the element should be displayed as highlighted
let shouldDisplayAsHighlighted: Bool
/// Accessibility label of the toolbar element
let a11yLabel: String
/// Accessibility identifier of the toolbar element
let a11yId: String
/// Closure that is executed when the toolbar element is tapped
let onSelected: (() -> Void)?
/// Closure that is executed when the toolbar element is long pressed
let onLongPress: (() -> Void)?
// We need this init as by default the init generated by the compiler for the struct will be internal and
// can therefor not be used outside of the ToolbarKit
public init(iconName: String,
numberOfTabs: Int? = nil,
isEnabled: Bool,
shouldDisplayAsHighlighted: Bool = false,
a11yLabel: String,
a11yId: String,
onSelected: (() -> Void)?,
onLongPress: (() -> Void)? = nil) {
self.iconName = iconName
self.numberOfTabs = numberOfTabs
self.isEnabled = isEnabled
self.shouldDisplayAsHighlighted = shouldDisplayAsHighlighted
self.onSelected = onSelected
self.onLongPress = onLongPress
self.a11yLabel = a11yLabel
self.a11yId = a11yId
}
}