Make sliders should be quantized. Issue #1342
This commit is contained in:
parent
e05fdc99dd
commit
88707517e8
|
@ -123,6 +123,8 @@ class ArticleViewController: UIViewController {
|
|||
webView.navigationDelegate = self
|
||||
webView.uiDelegate = self
|
||||
|
||||
webView.addInteraction(UIContextMenuInteraction(delegate: self))
|
||||
|
||||
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasClicked)
|
||||
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasShown)
|
||||
|
||||
|
@ -340,6 +342,44 @@ class ArticleViewController: UIViewController {
|
|||
|
||||
}
|
||||
|
||||
// MARK: InteractiveNavigationControllerTappable
|
||||
|
||||
extension ArticleViewController: InteractiveNavigationControllerTappable {
|
||||
func didTapNavigationBar() {
|
||||
hideBars()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: UIContextMenuInteractionDelegate
|
||||
|
||||
extension ArticleViewController: UIContextMenuInteractionDelegate {
|
||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
|
||||
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
|
||||
let action1 = UIAction(title: "Action 1", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action2 = UIAction(title: "Action 2", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action3 = UIAction(title: "Action 3", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action4 = UIAction(title: "Action 4", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action5 = UIAction(title: "Action 5", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action6 = UIAction(title: "Action 6", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
let action7 = UIAction(title: "Action 7", image: AppAssets.infoImage) { [weak self] action in
|
||||
}
|
||||
return UIMenu(title: "", children: [action1, action2, action3, action4, action5, action6, action7])
|
||||
}
|
||||
}
|
||||
|
||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
||||
return UITargetedPreview(view: webView, parameters: CroppingPreviewParameters(view: webView, size: CGSize(width: webView.bounds.width, height: 200)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: WKNavigationDelegate
|
||||
|
||||
extension ArticleViewController: WKNavigationDelegate {
|
||||
|
@ -376,14 +416,6 @@ extension ArticleViewController: WKNavigationDelegate {
|
|||
|
||||
}
|
||||
|
||||
// MARK: InteractiveNavigationControllerTappable
|
||||
|
||||
extension ArticleViewController: InteractiveNavigationControllerTappable {
|
||||
func didTapNavigationBar() {
|
||||
hideBars()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: WKUIDelegate
|
||||
|
||||
extension ArticleViewController: WKUIDelegate {
|
||||
|
|
|
@ -17,4 +17,11 @@ class CroppingPreviewParameters: UIPreviewParameters {
|
|||
self.visiblePath = visiblePath
|
||||
}
|
||||
|
||||
init(view: UIView, size: CGSize) {
|
||||
super.init()
|
||||
let newBounds = CGRect(x: 0, y: 0, width: size.width, height: size.height)
|
||||
let visiblePath = UIBezierPath(roundedRect: newBounds, cornerRadius: 10)
|
||||
self.visiblePath = visiblePath
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ class TickMarkSlider: UISlider {
|
|||
private var enableFeedback = false
|
||||
private let feedbackGenerator = UISelectionFeedbackGenerator()
|
||||
|
||||
private var roundedValue: Float?
|
||||
override var value: Float {
|
||||
didSet {
|
||||
if enableFeedback && value.truncatingRemainder(dividingBy: 1) == 0 {
|
||||
let testValue = value.rounded()
|
||||
if testValue != roundedValue && enableFeedback && value.truncatingRemainder(dividingBy: 1) == 0 {
|
||||
roundedValue = testValue
|
||||
feedbackGenerator.selectionChanged()
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +69,12 @@ class TickMarkSlider: UISlider {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
|
||||
let result = super.continueTracking(touch, with: event)
|
||||
value = value.rounded()
|
||||
return result
|
||||
}
|
||||
|
||||
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
|
||||
value = value.rounded()
|
||||
|
|
Loading…
Reference in New Issue