@@ -10,70 +10,76 @@ import UIKit
1010import YMatterType
1111
1212extension StepperControl {
13- /// Appearance for stepper that contains typography and color properties
13+ /// Appearance for stepper that contains typography and color properties.
1414 public struct Appearance {
15- /// Typography of stepper value label
15+ /// Typography of stepper value label.
1616 public var textStyle : ( textColor: UIColor , typography: Typography )
17- /// Background color for stepper view
17+ /// Background color for stepper view.
1818 public var backgroundColor : UIColor
19- /// Border color for stepper view
19+ /// Border color for stepper view.
2020 public var borderColor : UIColor
21- /// Border width for stepper view
21+ /// Border width for stepper view.
2222 public var borderWidth : CGFloat
23- /// Delete button image. Nil means no delete button
24- public var deleteImage : UIImage ?
23+ /// Delete button image
24+ public var deleteImage : UIImage
2525 /// Increment button image
2626 public var incrementImage : UIImage
2727 /// Decrement button image
2828 public var decrementImage : UIImage
29- /// Stepper's layout properties such as spacing between views. Default is `.default`
29+ /// Stepper's layout properties such as spacing between views. Default is `.default`.
3030 public var layout : Layout
31- /// Whether to show delete button or not
32- var hasDeleteButton : Bool { deleteImage != nil }
31+ /// Whether to show delete image or not.
32+ var showDeleteImage : Bool
3333
34- /// Initializer for appearance
34+ /// Initializer for appearance.
3535 /// - Parameters:
3636 /// - textStyle: Typography and text color for valueText label.
37- /// Default is `(UIColor.label, Typography.systemLabel)`
38- /// - foregroundColor: Foreground color for valueText. Default is `.label`
39- /// - backgroundColor: Background color for stepper view. Default is `.systemBackground`
40- /// - borderColor: Border color for stepper view. Default is `UIColor.label`
41- /// - borderWidth: Border width for day view. Default is `1.0`
42- /// - deleteImage: Delete button image. Default is `Appearance.defaultDeleteImage`
43- /// - incrementImage: Increment button image. Default is `Appearance.defaultIncrementImage`
44- /// - decrementImage: Decrement button image. Default is `Appearance.defaultDecrementImage`
45- /// - layout: Stepper's layout properties like spacing between views
46-
37+ /// Default is `(UIColor.label, Typography.systemLabel)`.
38+ /// - foregroundColor: Foreground color for valueText. Default is `.label`.
39+ /// - backgroundColor: Background color for stepper view. Default is `.systemBackground`.
40+ /// - borderColor: Border color for stepper view. Default is `UIColor.label`.
41+ /// - borderWidth: Border width for day view. Default is `1.0`.
42+ /// - deleteImage: Delete button image. Default is `nil`.
43+ /// Passing `nil` means to use the default delete image.
44+ /// - incrementImage: Increment button image. Default is `nil`.
45+ /// Passing `nil` means to use the default increment image.
46+ /// - decrementImage: Decrement button image. Default is `nil`.
47+ /// Passing `nil` means to use the default decrement image.
48+ /// - layout: Stepper's layout properties like spacing between views.
49+ /// - showDeleteImage: Whether to show delete button or not. Default is`true`.
50+
4751 public init (
4852 textStyle: ( textColor: UIColor , typography: Typography ) = ( . label, . systemLabel) ,
4953 foregroundColor: UIColor = . label,
5054 backgroundColor: UIColor = . systemBackground,
5155 borderColor: UIColor = . label,
5256 borderWidth: CGFloat = 1.0 ,
53- deleteImage: UIImage ? = Appearance . defaultDeleteImage,
54- incrementImage: UIImage = Appearance . defaultIncrementImage,
55- decrementImage: UIImage = Appearance . defaultDecrementImage,
56- layout: Layout = . default
57+ deleteImage: UIImage ? = nil ,
58+ incrementImage: UIImage ? = nil ,
59+ decrementImage: UIImage ? = nil ,
60+ layout: Layout = . default,
61+ showDeleteImage: Bool = true
5762 ) {
5863 self . textStyle = textStyle
5964 self . backgroundColor = backgroundColor
6065 self . borderColor = borderColor
6166 self . borderWidth = borderWidth
62- self . deleteImage = deleteImage
63- self . incrementImage = incrementImage
64- self . decrementImage = decrementImage
67+ self . deleteImage = deleteImage ?? Appearance . defaultDeleteImage
68+ self . incrementImage = incrementImage ?? Appearance . defaultIncrementImage
69+ self . decrementImage = decrementImage ?? Appearance . defaultDecrementImage
6570 self . layout = layout
71+ self . showDeleteImage = showDeleteImage
6672 }
6773 }
6874}
6975
7076extension StepperControl . Appearance {
7177 /// Default stepper appearance
7278 public static let `default` = StepperControl . Appearance ( )
73- /// Default image for delete button. Is a `trash` from SF Symbols in template rendering mode
74- public static let defaultDeleteImage = StepperControl . Images. delete. image
75- /// Default image for increment button. Is a `plus` from SF Symbols in template rendering mode
76- public static let defaultIncrementImage = StepperControl . Images. increment. image
77- /// Default image for decrement button. Is a `minus` from SF Symbols in template rendering mode
78- public static let defaultDecrementImage = StepperControl . Images. decrement. image
79+ /// Default image for delete button. Is a `trash` from SF Symbols in template rendering mode.
80+ public static let defaultDeleteImage = StepperControl . Images. delete. image. withRenderingMode ( . alwaysTemplate )
81+ /// Default image for increment button. Is a `plus` from SF Symbols in template rendering mode.
82+ public static let defaultIncrementImage = StepperControl . Images. increment. image. withRenderingMode ( . alwaysTemplate )
83+ /// Default image for decrement button. Is a `minus` from SF Symbols in template rendering mode.
84+ public static let defaultDecrementImage = StepperControl . Images. decrement. image. withRenderingMode ( . alwaysTemplate )
7985}
0 commit comments