Skip to content

Minimalistic and customizable date picker framework for iOS, designed with Swift

Notifications You must be signed in to change notification settings

samroman3/YummyDate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YummyDate

YummyDate is a highly customizable SwiftUI date picker framework designed to make it easy to add stylish date selection functionality to iOS applications.

Features

  • 1.0.0:
  • Easy Integration: Seamlessly integrates with SwiftUI applications.
  • Customizable Themes: Includes predefined themes and supports custom themes.
  • Date Selection Manager: Leverages DateSelectionManager for easy date management within your app.

Getting Started

Requirements

iOS 14.0+

Xcode 11+

Swift 5.1+

Installation

To add YummyDate to your SwiftUI project, simply add it as a dependency to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/samroman3/YummyDate.git", .upToNextMajor(from: "1.0.0"))
]

Or add it via Xcode by selecting File > Swift Packages > Add Package Dependency and enter the package repository URL.

Usage

Import YummyDate in the file you'd like to use it:

import YummyDate

DateSelectionManager

Initialize the DateSelectionManager and bind it to YummyDateBar and DateSelectorView:

@StateObject private var dateSelectionManager = BaseDateSelectionManager()

YummyDateBar(selectionManager: dateSelectionManager,
             selectedDate: $dateSelectionManager.selectedDate,
             onDateTapped: { /* Your code here */ },
             onCalendarTapped: { /* Your code here */ },
             theme: .limeTheme)

DateSelectionManaging Protocol

If you would like further date handling you can extend BaseDateSelectionManager or directly conform to DateSelectionManaging if you prefer implementing the ObservableObject requirements yourself.

class CustomDateSelectionManager: BaseDateSelectionManager {
    override func updateSelectedDate(to newDate: Date) {
        // Custom logic here
        super.updateSelectedDate(to: newDate)
    }
}

Or, for full custom implementations:

class AnotherCustomManager: DateSelectionManaging {
    var objectWillChange = ObservableObjectPublisher()
    private var _selectedDate: Date = Date()

    var selectedDate: Date {
        get { _selectedDate }
        set {
            _selectedDate = newValue
            objectWillChange.send()
        }
    }

    func updateSelectedDate(to newDate: Date) {
        selectedDate = newDate
    }
}

And in your views:

struct MyView {
@StateObject private var dateSelectionManager = AnotherCustomManager()
@State private var selectedDate = Date()

var body: some View {
    NavigationSplitView {
        YummyDateBar(selectionManager: dateSelectionManager,
        selectedDate: $selectedDate,
        onDateTapped: {},
        onCalendarTapped: {},
        theme: currentTheme)
        }
    }
}

Themes

YummyDate comes with three built-in themes.

SunsetTheme

IMG_1630

LimeTheme

IMG_1629

OceanTheme

IMG_1628

Creating custom themes:

let customTheme = YummyTheme(primaryColor: .blue,
                             secondaryColor: .gray,
                             tertiaryColor: .white,
                             primaryTextColor: .white,
                             secondaryTextColor: .black,
                             primaryFont: .title,
                             secondaryFont: .body,
                             barAlignment: .center,
                             animation: .default,
                             scrollBehavior: .staticScroll)

//Note: only .staticScroll is available at the moment

Using themes:

In YummyDateBar, pass in your theme on initialization.

YummyDateBar(selectionManager: dateSelectionManager,
             selectedDate: $dateSelectionManager.selectedDate,
             theme: customTheme)

Sample Application

To see YummyDate in action, check out the YummyDateSampleApp included in this package. Make sure to switch the target and build on a compatible (iOS) device or simulator.

Future versions:

  • More customization: custom scroll behavior, custom behavior for all components (Text, Icons, DateButtons)
  • Use DateSelectorView without YummyDateBar
  • Custom DateBar styles
  • Expanded calendar methods

Contributing

Contributions to YummyDate are welcome! If you have any suggestions or run into issues with YummyDate feel free to open a pull request or create an issue.

About

Minimalistic and customizable date picker framework for iOS, designed with Swift

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published