@@ -48,13 +48,15 @@ protocol Widget: AnyObject {
48
48
}
49
49
50
50
public class OpenHABWidget : NSObject , MKAnnotation , Identifiable {
51
- public enum WidgetType : String {
51
+ public enum WidgetType : String , Decodable , UnknownCaseRepresentable {
52
+ static var unknownCase : OpenHABWidget . WidgetType = . unknown
52
53
case chart = " Chart "
53
54
case colorpicker = " Colorpicker "
54
55
case defaultWidget = " Default "
55
56
case frame = " Frame "
56
57
case group = " Group "
57
58
case image = " Image "
59
+ case input = " Input "
58
60
case mapview = " Mapview "
59
61
case selection = " Selection "
60
62
case setpoint = " Setpoint "
@@ -66,13 +68,18 @@ public class OpenHABWidget: NSObject, MKAnnotation, Identifiable {
66
68
case unknown = " Unknown "
67
69
}
68
70
71
+ public enum InputHint : String , Decodable , UnknownCaseRepresentable {
72
+ static var unknownCase : OpenHABWidget . InputHint = . text
73
+ case text, number, date, time, datetime
74
+ }
75
+
69
76
public var id : String = " "
70
77
71
78
public var sendCommand : ( ( _ item: OpenHABItem , _ command: String ? ) -> Void ) ?
72
79
public var widgetId = " "
73
80
public var label = " "
74
81
public var icon = " "
75
- public var type : WidgetType ?
82
+ public var type : WidgetType = . unknownCase
76
83
public var url = " "
77
84
public var period = " "
78
85
public var minValue = 0.0
@@ -88,6 +95,7 @@ public class OpenHABWidget: NSObject, MKAnnotation, Identifiable {
88
95
public var state = " "
89
96
public var text = " "
90
97
public var legend : Bool ?
98
+ public var inputHint = InputHint . unknownCase
91
99
public var encoding = " "
92
100
public var forceAsItem : Bool ?
93
101
public var item : OpenHABItem ?
@@ -203,15 +211,9 @@ public class OpenHABWidget: NSObject, MKAnnotation, Identifiable {
203
211
}
204
212
}
205
213
206
- extension OpenHABWidget . WidgetType : Decodable { }
207
-
208
- extension OpenHABWidget . WidgetType : UnknownCaseRepresentable {
209
- static var unknownCase : OpenHABWidget . WidgetType = . unknown
210
- }
211
-
212
214
extension OpenHABWidget {
213
215
// This is an ugly initializer
214
- convenience init ( widgetId: String , label: String , icon: String , type: WidgetType , url: String ? , period: String ? , minValue: Double ? , maxValue: Double ? , step: Double ? , refresh: Int ? , height: Double ? , isLeaf: Bool ? , iconColor: String ? , labelColor: String ? , valueColor: String ? , service: String ? , state: String ? , text: String ? , legend: Bool ? , encoding: String ? , item: OpenHABItem ? , linkedPage: OpenHABSitemapPage ? , mappings: [ OpenHABWidgetMapping ] , widgets: [ OpenHABWidget ] , visibility: Bool ? , switchSupport: Bool ? , forceAsItem: Bool ? ) {
216
+ convenience init ( widgetId: String , label: String , icon: String , type: WidgetType , url: String ? , period: String ? , minValue: Double ? , maxValue: Double ? , step: Double ? , refresh: Int ? , height: Double ? , isLeaf: Bool ? , iconColor: String ? , labelColor: String ? , valueColor: String ? , service: String ? , state: String ? , text: String ? , legend: Bool ? , inputHint : InputHint ? , encoding: String ? , item: OpenHABItem ? , linkedPage: OpenHABSitemapPage ? , mappings: [ OpenHABWidgetMapping ] , widgets: [ OpenHABWidget ] , visibility: Bool ? , switchSupport: Bool ? , forceAsItem: Bool ? ) {
215
217
self . init ( )
216
218
id = widgetId
217
219
self . widgetId = widgetId
@@ -238,6 +240,7 @@ extension OpenHABWidget {
238
240
self . state = state ?? " "
239
241
self . text = text ?? " "
240
242
self . legend = legend
243
+ self . inputHint = inputHint ?? . text
241
244
self . encoding = encoding ?? " "
242
245
self . item = item
243
246
self . linkedPage = linkedPage
@@ -275,6 +278,7 @@ public extension OpenHABWidget {
275
278
let state : String ?
276
279
let text : String ?
277
280
let legend : Bool ?
281
+ let inputHint : InputHint ?
278
282
let encoding : String ?
279
283
let groupType : String ?
280
284
let item : OpenHABItem . CodingData ?
@@ -291,7 +295,7 @@ extension OpenHABWidget.CodingData {
291
295
var openHABWidget : OpenHABWidget {
292
296
let mappedWidgets = widgets. map ( \. openHABWidget)
293
297
// swiftlint:disable:next line_length
294
- return OpenHABWidget ( widgetId: widgetId, label: label, icon: icon, type: type, url: url, period: period, minValue: minValue, maxValue: maxValue, step: step, refresh: refresh, height: height, isLeaf: isLeaf, iconColor: iconcolor, labelColor: labelcolor, valueColor: valuecolor, service: service, state: state, text: text, legend: legend, encoding: encoding, item: item? . openHABItem, linkedPage: linkedPage? . openHABSitemapPage, mappings: mappings, widgets: mappedWidgets, visibility: visibility, switchSupport: switchSupport, forceAsItem: forceAsItem)
298
+ return OpenHABWidget ( widgetId: widgetId, label: label, icon: icon, type: type, url: url, period: period, minValue: minValue, maxValue: maxValue, step: step, refresh: refresh, height: height, isLeaf: isLeaf, iconColor: iconcolor, labelColor: labelcolor, valueColor: valuecolor, service: service, state: state, text: text, legend: legend, inputHint : inputHint , encoding: encoding, item: item? . openHABItem, linkedPage: linkedPage? . openHABSitemapPage, mappings: mappings, widgets: mappedWidgets, visibility: visibility, switchSupport: switchSupport, forceAsItem: forceAsItem)
295
299
}
296
300
}
297
301
0 commit comments