Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed doneButton enabled variable and added option to avoid auto-selection of day when releasing scrolling #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DateTimePickerDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- DateTimePicker (2.5.1)
- DateTimePicker (2.5.3)

DEPENDENCIES:
- DateTimePicker (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
DateTimePicker: f7d3305252c1d7a67c9cca58ce8592f8396841ca
DateTimePicker: 52701ddf656a50856d3510955933f767cd2c947c

PODFILE CHECKSUM: a26e66cb94802972f6430185232278dc132b5b0e

COCOAPODS: 1.9.3
COCOAPODS: 1.11.2
8 changes: 6 additions & 2 deletions Source/DateTimePicker+CollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ extension DateTimePicker: UICollectionViewDataSource, UICollectionViewDelegate {
}

public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
alignScrollView(scrollView)
if self.autoSelectDayOnStopScroll {
alignScrollView(scrollView)
}
}

public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
alignScrollView(scrollView)
if self.autoSelectDayOnStopScroll {
alignScrollView(scrollView)
}
}

func alignScrollView(_ scrollView: UIScrollView) {
Expand Down
9 changes: 9 additions & 0 deletions Source/DateTimePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public protocol DateTimePickerDelegate: AnyObject {

@objc public class DateTimePicker: UIView {

public var doneButtonIsEnabled: Bool = true {
didSet {
doneButton.isEnabled = doneButtonIsEnabled
}
}
Comment on lines +17 to +21
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits:

  • I think it's nicer if we use a method instead of this long awkward variable name. So instead we can have something like: func enableDoneButton(_ enabled: Bool).
  • The indenting doesn't quite match with the rest of the file, can you please update it?
  • When the done button is disabled, I find that it still looks the same as when it's enabled so it doesn't look obvious and can be mistaken with an issue. How about updating the button's look (i.e make it grey) when it's disabled?


var contentHeight: CGFloat = 330

public struct CustomFontSetting {
Expand Down Expand Up @@ -260,6 +266,9 @@ public protocol DateTimePickerDelegate: AnyObject {
timeZone = calendar.timeZone
}
}

public var autoSelectDayOnStopScroll: Bool = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite fond of this feature, as although someone requested it I find it looks buggy and not what I intended for the library. I think it's fine if someone wants it for their app, they can maybe tweak it to their need; but I'd prefer to leave it off the library for now. WDYT?


public var hapticFeedbackEnabled: Bool = true

public var completionHandler: ((Date)->Void)?
Expand Down