|
| 1 | +// Copyright © 2021 Saleem Abdulrasool < [email protected]> |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +import class Foundation.NSAttributedString |
| 5 | + |
| 6 | +/// An abstract superclass for items that you can add to a bar that appears at |
| 7 | +/// the bottom of the screen. |
| 8 | +open class BarItem { |
| 9 | + // MARK - Initializing a Bar Item |
| 10 | + |
| 11 | + /// Initializes the bar item to its default state. |
| 12 | + public init() { |
| 13 | + } |
| 14 | + |
| 15 | + // MARK - Getting and Setting Properties |
| 16 | + |
| 17 | + /// The title displayed on the item. |
| 18 | + /// |
| 19 | + /// You should set this property before adding the item to a bar. The default |
| 20 | + /// value is `nil`. |
| 21 | + open var title: String? |
| 22 | + |
| 23 | + /// The image used to represent the item. |
| 24 | + /// |
| 25 | + /// This image can be used to create other images to represent this item on |
| 26 | + /// the bar — for example, a selected and unselected image may be derived from |
| 27 | + /// this image. You should set this property before adding the item to a bar. |
| 28 | + /// The default value is `nil`. |
| 29 | + open var image: Image? |
| 30 | + |
| 31 | + /// The image to use to represent the item in landscape orientation. |
| 32 | + /// |
| 33 | + /// This image can be used to create other images to represent this item on |
| 34 | + /// the bar — for example, a selected and unselected image may be derived from |
| 35 | + /// this image. You should set this property before adding the item to a bar. |
| 36 | + /// The default value is `nil`. |
| 37 | + open var landscapeImage: Image? |
| 38 | + |
| 39 | + /// The image to display for assistive interfaces. |
| 40 | + /// |
| 41 | + /// Use this property to specify a high-resolution version of the item's |
| 42 | + /// image. When displaying an assistive interface, the framework displays this |
| 43 | + /// image instead of the standard image. The default value of this property is |
| 44 | + /// `nil`. |
| 45 | + /// |
| 46 | + /// If you do not specify an image for this property, the framework scales the |
| 47 | + /// image that you specified in the image property. |
| 48 | + open var largeContentSizeImage: Image? |
| 49 | + |
| 50 | + /// The image inset or outset for each edge. |
| 51 | + /// |
| 52 | + /// The default value is `zero`. |
| 53 | + open var imageInsets: EdgeInsets = .zero |
| 54 | + |
| 55 | + /// The image inset or outset for each edge of the image in landscape |
| 56 | + /// orientation. |
| 57 | + /// |
| 58 | + /// The default value is `zero`. |
| 59 | + open var landscapeImageInsets: EdgeInsets = .zero |
| 60 | + |
| 61 | + /// The insets to apply to the bar item's large image when displaying the |
| 62 | + /// image in an assistive UI. |
| 63 | + /// |
| 64 | + /// The default value of this property is `zero`. |
| 65 | + open var largeContentSizeImageInsets: EdgeInsets = .zero |
| 66 | + |
| 67 | + /// A boolean value indicating whether the item is enabled. |
| 68 | + /// |
| 69 | + /// If `false`, the item is drawn partially dimmed to indicate it is disabled. |
| 70 | + /// The default value is `true`. |
| 71 | + open var isEnabled: Bool = true |
| 72 | + |
| 73 | + /// The receiver’s tag, an application-supplied integer that you can use to |
| 74 | + /// identify bar item objects in your application. |
| 75 | + /// |
| 76 | + /// The default value is `0`. |
| 77 | + open var tag: Int = 0 |
| 78 | + |
| 79 | + // MARK - Customizing Appearance |
| 80 | + |
| 81 | + /// Sets the title’s text attributes for a given control state. |
| 82 | + open func setTitleTextAttributes(_ attributes: [NSAttributedString.Key:Any]?, |
| 83 | + for state: Control.State) { |
| 84 | + fatalError("\(#function) not yet implemnted") |
| 85 | + } |
| 86 | + |
| 87 | + /// Returns the title’s text attributes for a given control state. |
| 88 | + /// |
| 89 | + /// The dictionary may contain key-value pairs for text attributes for the |
| 90 | + /// font, text color, text shadow color, and text shadow offset using the keys |
| 91 | + /// listed in NSString Additions Reference. |
| 92 | + open func titleTextAttributes(for state: Control.State) |
| 93 | + -> [NSAttributedString.Key:Any]? { |
| 94 | + fatalError("\(#function) not yet implemnted") |
| 95 | + } |
| 96 | +} |
0 commit comments