DurationPicker icon indicating copy to clipboard operation
DurationPicker copied to clipboard

Adding SwiftUI wrapper for `DurationPicker`

Open GabRoyer opened this issue 10 months ago • 1 comments

Description

Added a SwiftUI wrapper for DurationPicker called DurationPickerView. I added it under a new library since very rarely do UIKit users want to use a SwiftUI component (and vice-versa) if there is a component that works natively with their framework.

I've renamed Mode to Components as it better aligns with SwiftUI's DatePicker terminology. Though I thought "displayedComponents" would be a misnomer as it's a bit more than what's being display since changing, say, the Hour component in .hour mode also sets the minutes and seconds to 0.

Usage

See preview for usage example, but it behaves pretty much like any SwiftUI view. For example, one can simply use it as such:

DurationPickerView(
  $duration,
  components: components,
  hourInterval: hourInterval,
  minuteInterval: minuteInterval,
  secondInterval: secondInterval,
  minumumDuration: minimumDuration,
  maximumDuration: maximumDuration
)

GabRoyer avatar Feb 12 '25 18:02 GabRoyer

@GabRoyer Bump :)

sindresorhus avatar Sep 07 '25 13:09 sindresorhus