-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tassilo Karge <[email protected]>
- Loading branch information
Showing
4 changed files
with
111 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2010-2024 Contributors to the openHAB project | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
|
||
import OpenHABCore | ||
import UIKit | ||
|
||
class DatePickerUITableViewCell: GenericUITableViewCell { | ||
override var widget: OpenHABWidget! { | ||
get { | ||
super.widget | ||
} | ||
set(widget) { | ||
super.widget = widget | ||
switch widget.inputHint { | ||
case .date: | ||
datePicker.datePickerMode = .date | ||
case .time: | ||
datePicker.datePickerMode = .time | ||
case .datetime: | ||
datePicker.datePickerMode = .dateAndTime | ||
default: | ||
fatalError("Must not use this cell for input other than date and time") | ||
} | ||
datePicker.date = ISO8601DateFormatter().date(from: widget.state) ?? Date.now | ||
} | ||
} | ||
|
||
weak var controller: OpenHABSitemapViewController! | ||
|
||
@IBOutlet private(set) var datePicker: UIDatePicker! { | ||
didSet { | ||
datePicker.addAction(UIAction { [weak self] _ in | ||
guard let self else { return } | ||
controller?.sendCommand(widget.item, commandToSend: datePicker.date.ISO8601Format()) | ||
}, for: .valueChanged) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters