Repository: GGJJack/SwiftUICalendar
Branch: master
Commit: 1ba690274212
Files: 33
Total size: 117.6 KB
Directory structure:
gitextract_wog129te/
├── .gitignore
├── .travis.yml
├── Example/
│ ├── Podfile
│ ├── SwiftUICalendar/
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj/
│ │ │ └── LaunchScreen.xib
│ │ ├── BasicUseView.swift
│ │ ├── CalendarScrollView.swift
│ │ ├── EmbedHeaderView.swift
│ │ ├── Images.xcassets/
│ │ │ └── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── InformationView.swift
│ │ ├── InformationWithSelectionView.swift
│ │ ├── SelectionView.swift
│ │ ├── StartWithMonday.swift
│ │ └── ViewController.swift
│ ├── SwiftUICalendar.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── xcschemes/
│ │ └── SwiftUICalendar-Example.xcscheme
│ ├── SwiftUICalendar.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── IDEWorkspaceChecks.plist
│ └── Tests/
│ ├── Info.plist
│ └── Tests.swift
├── LICENSE
├── Package.swift
├── README.md
├── Sources/
│ └── SwiftUICalendar/
│ ├── Assets/
│ │ └── .gitkeep
│ └── Classes/
│ ├── .gitkeep
│ ├── CalendarController.swift
│ ├── CalendarView.swift
│ ├── Global.swift
│ ├── InfinitePagerView.swift
│ └── Struct.swift
└── SwiftUICalendar.podspec
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# macOS
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa
# Bundler
.bundle
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
# Pods/
Example/Pods/
================================================
FILE: .travis.yml
================================================
# references:
# * https://www.objc.io/issues/6-build-tools/travis-ci/
# * https://github.com/supermarin/xcpretty#usage
osx_image: xcode7.3
language: objective-c
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/SwiftUICalendar.xcworkspace -scheme SwiftUICalendar-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
================================================
FILE: Example/Podfile
================================================
use_frameworks!
platform :ios, '14.0'
target 'SwiftUICalendar_Example' do
pod 'SwiftUICalendar', :path => '../'
target 'SwiftUICalendar_Tests' do
inherit! :search_paths
end
end
================================================
FILE: Example/SwiftUICalendar/AppDelegate.swift
================================================
//
// AppDelegate.swift
// SwiftUICalendar
//
// Created by ggaljjak on 10/21/2021.
// Copyright (c) 2021 ggaljjak. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow()
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example/SwiftUICalendar/Base.lproj/LaunchScreen.xib
================================================
================================================
FILE: Example/SwiftUICalendar/BasicUseView.swift
================================================
//
// BasicUseView.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/21.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import Foundation
import SwiftUI
import SwiftUICalendar
struct BasicUseView: View {
@ObservedObject var controller: CalendarController = CalendarController(orientation: .vertical)
var body: some View {
GeometryReader { reader in
VStack(alignment: .center, spacing: 0) {
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[i])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller) { date in
GeometryReader { geometry in
ZStack(alignment: .center) {
if date.isToday {
Circle()
.padding(4)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.foregroundColor(.orange)
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .bold, design: .default))
.foregroundColor(.white)
} else {
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.foregroundColor(getColor(date))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
.navigationBarTitle("Basic use")
}
}
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
struct BasicUseView_Previews: PreviewProvider {
static var previews: some View {
BasicUseView()
}
}
================================================
FILE: Example/SwiftUICalendar/CalendarScrollView.swift
================================================
//
// HorizontalView.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/21.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import SwiftUI
import SwiftUICalendar
struct CalendarScrollView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack(alignment: .center, spacing: 0) {
HStack(alignment: .center, spacing: 0) {
Spacer()
Button("Drag Lock") {
controller.isLocked = true
}
Spacer()
Button("Drag Unlock") {
controller.isLocked = false
}
Spacer()
}
HStack(alignment: .center, spacing: 0) {
Spacer()
Button("Older") {
controller.scrollTo(YearMonth(year: 1000, month: 1), isAnimate: true)
}
Spacer()
Button("Today Fast") {
controller.scrollTo(YearMonth.current, isAnimate: false)
}
Spacer()
Button("Today Scroll") {
controller.scrollTo(YearMonth.current, isAnimate: true)
}
Spacer()
Button("Future") {
controller.scrollTo(YearMonth(year: 3000, month: 1), isAnimate: true)
}
Spacer()
}
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[i])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller) { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
.navigationBarTitle("Calendar Scroll")
// .onChange(of: controller.yearMonth) { yearMonth in // If you want to detect date change
// print(yearMonth)
// }
}
}
}
}
struct CalendarScrollView_Previews: PreviewProvider {
static var previews: some View {
CalendarScrollView()
}
}
================================================
FILE: Example/SwiftUICalendar/EmbedHeaderView.swift
================================================
//
// VerticalView.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/21.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import SwiftUI
import SwiftUICalendar
struct EmbedHeaderView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack {
HStack(alignment: .center, spacing: 0) {
Button("Prev") {
controller.scrollTo(controller.yearMonth.addMonth(value: -1), isAnimate: true)
}
.padding(8)
Spacer()
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
Spacer()
Button("Next") {
controller.scrollTo(controller.yearMonth.addMonth(value: 1), isAnimate: true)
}
.padding(8)
}
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
})
}
}
.navigationBarTitle("Embed header")
}
}
struct EmbedHeaderView_Previews: PreviewProvider {
static var previews: some View {
EmbedHeaderView()
}
}
================================================
FILE: Example/SwiftUICalendar/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example/SwiftUICalendar/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
================================================
FILE: Example/SwiftUICalendar/InformationView.swift
================================================
//
// InformationView.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/26.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import SwiftUI
import SwiftUICalendar
struct InformationView: View {
var informations = [YearMonthDay: [(String, Color)]]()
init() {
var date = YearMonthDay.current
informations[date] = []
informations[date]?.append(("Hello", Color.orange))
informations[date]?.append(("World", Color.blue))
date = date.addDay(value: 3)
informations[date] = []
informations[date]?.append(("Test", Color.pink))
date = date.addDay(value: 8)
informations[date] = []
informations[date]?.append(("Jack", Color.green))
date = date.addDay(value: 5)
informations[date] = []
informations[date]?.append(("Home", Color.red))
date = date.addDay(value: -23)
informations[date] = []
informations[date]?.append(("Meet at 8, Home", Color.purple))
date = date.addDay(value: -5)
informations[date] = []
informations[date]?.append(("Home", Color.yellow))
date = date.addDay(value: -10)
informations[date] = []
informations[date]?.append(("Baseball", Color.green))
}
var body: some View {
GeometryReader { reader in
CalendarView(header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
VStack(alignment: .leading, spacing: 2) {
if date.isToday {
Text("\(date.day)")
.font(.system(size: 10, weight: .bold, design: .default))
.padding(4)
.foregroundColor(.white)
.background(Color.red.opacity(0.95))
.cornerRadius(14)
} else {
Text("\(date.day)")
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.foregroundColor(getColor(date))
.padding(4)
}
if let infos = informations[date] {
ForEach(infos.indices, id: \.self) { index in
let info = infos[index]
Text(info.0)
.lineLimit(1)
.foregroundColor(.white)
.font(.system(size: 8, weight: .bold, design: .default))
.padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4))
.frame(width: geometry.size.width, alignment: .center)
.background(info.1.opacity(0.75))
.cornerRadius(4)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading)
}
})
}
.navigationBarTitle("Information")
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
struct InformationView_Previews: PreviewProvider {
static var previews: some View {
InformationView()
}
}
================================================
FILE: Example/SwiftUICalendar/InformationWithSelectionView.swift
================================================
//
// InformationWithSelection.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/26.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import SwiftUI
import SwiftUICalendar
struct InformationWithSelectionView: View {
let controller = CalendarController()
var informations = [YearMonthDay: [(String, Color)]]()
@State var focusDate: YearMonthDay? = nil
@State var focusInfo: [(String, Color)]? = nil
init() {
var date = YearMonthDay.current
informations[date] = []
informations[date]?.append(("Hello", Color.orange))
informations[date]?.append(("World", Color.blue))
date = date.addDay(value: 3)
informations[date] = []
informations[date]?.append(("Test", Color.pink))
date = date.addDay(value: 8)
informations[date] = []
informations[date]?.append(("Jack", Color.green))
date = date.addDay(value: 5)
informations[date] = []
informations[date]?.append(("Home", Color.red))
date = date.addDay(value: -23)
informations[date] = []
informations[date]?.append(("Meet at 8, Home", Color.purple))
date = date.addDay(value: -5)
informations[date] = []
informations[date]?.append(("Home", Color.yellow))
date = date.addDay(value: -10)
informations[date] = []
informations[date]?.append(("Baseball", Color.green))
}
var body: some View {
GeometryReader { reader in
VStack {
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
VStack(alignment: .leading, spacing: 2) {
if date.isToday {
Text("\(date.day)")
.font(.system(size: 10, weight: .bold, design: .default))
.padding(4)
.foregroundColor(.white)
.background(Color.red.opacity(0.95))
.cornerRadius(14)
} else {
Text("\(date.day)")
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.foregroundColor(getColor(date))
.padding(4)
}
if let infos = informations[date] {
ForEach(infos.indices, id: \.self) { index in
let info = infos[index]
if focusInfo != nil {
Rectangle()
.fill(info.1.opacity(0.75))
.frame(width: geometry.size.width, height: 4, alignment: .center)
.cornerRadius(2)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
} else {
Text(info.0)
.lineLimit(1)
.foregroundColor(.white)
.font(.system(size: 8, weight: .bold, design: .default))
.padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4))
.frame(width: geometry.size.width, alignment: .center)
.background(info.1.opacity(0.75))
.cornerRadius(4)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading)
.border(.green.opacity(0.8), width: (focusDate == date ? 1 : 0))
.cornerRadius(2)
.contentShape(Rectangle())
.onTapGesture {
withAnimation {
if focusDate == date {
focusDate = nil
focusInfo = nil
} else {
focusDate = date
focusInfo = informations[date]
}
}
}
}
})
if let infos = focusInfo {
List(infos.indices, id: \.self) { index in
let info = infos[index]
HStack(alignment: .center, spacing: 0) {
Circle()
.fill(info.1.opacity(0.75))
.frame(width: 12, height: 12)
Text(info.0)
.padding(.leading, 8)
}
}
.frame(width: reader.size.width, height: 160, alignment: .center)
}
}
}
.navigationBarTitle("Info + Select")
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
struct InformationWithSelectionView_Previews: PreviewProvider {
static var previews: some View {
InformationWithSelectionView()
}
}
================================================
FILE: Example/SwiftUICalendar/SelectionView.swift
================================================
//
// SelectionView.swift
// SwiftUICalendar_Example
//
// Created by GGJJack on 2021/10/26.
// Copyright © 2021 CocoaPods. All rights reserved.
//
import SwiftUI
import SwiftUICalendar
struct SelectionView: View {
@ObservedObject var controller: CalendarController = CalendarController()
@State var focusDate: YearMonthDay? = YearMonthDay.current
var body: some View {
GeometryReader { reader in
VStack {
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.border(.green.opacity(0.8), width: (focusDate == date ? 1 : 0))
.cornerRadius(2)
.contentShape(Rectangle())
.onTapGesture {
focusDate = (date != focusDate ? date : nil)
}
}
})
}
}
.navigationBarTitle("Selection")
}
}
struct SelectionView_Previews: PreviewProvider {
static var previews: some View {
SelectionView()
}
}
================================================
FILE: Example/SwiftUICalendar/StartWithMonday.swift
================================================
//
// StartWithMonday.swift
// SwiftUICalendar_Example
//
// Created by Jack on 2023/04/19.
// Copyright © 2023 CocoaPods. All rights reserved.
//
import Foundation
import SwiftUI
import SwiftUICalendar
struct StartWithMondayView: View {
@ObservedObject var controller: CalendarController = CalendarController(orientation: .vertical)
var body: some View {
GeometryReader { reader in
VStack(alignment: .center, spacing: 0) {
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[(i + 1) % 7])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller, startWithMonday: true) { date in
GeometryReader { geometry in
ZStack(alignment: .center) {
if date.isToday {
Circle()
.padding(4)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.foregroundColor(.orange)
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .bold, design: .default))
.foregroundColor(.white)
} else {
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.foregroundColor(getColor(date))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
.navigationBarTitle("Start With Monday")
}
}
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
struct StartWithMondayView_Previews: PreviewProvider {
static var previews: some View {
StartWithMondayView()
}
}
================================================
FILE: Example/SwiftUICalendar/ViewController.swift
================================================
//
// ViewController.swift
// SwiftUICalendar
//
// Created by ggaljjak on 10/21/2021.
// Copyright (c) 2021 ggaljjak. All rights reserved.
//
import UIKit
import SwiftUI
import SwiftUICalendar
struct MainView: View {
@State var defaultProgress: CGFloat = 0
var body: some View {
NavigationView {
List {
NavigationLink(destination: BasicUseView()) {
Text("Basic use")
}
NavigationLink(destination: StartWithMondayView()) {
Text("Start With Monday")
}
NavigationLink(destination: CalendarScrollView()) {
Text("Calendar Scroll")
}
NavigationLink(destination: EmbedHeaderView()) {
Text("Embed Header")
}
NavigationLink(destination: InformationView()) {
Text("Information")
}
NavigationLink(destination: SelectionView()) {
Text("Selection")
}
NavigationLink(destination: InformationWithSelectionView()) {
Text("Information + Selection")
}
}
.navigationBarTitle("Home")
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
.previewDevice(PreviewDevice(rawValue: "iPod touch (7th generation)"))
MainView()
.previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro"))
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let contentViewController = UIHostingController(rootView: MainView())
self.addChildViewController(contentViewController)
self.view.addSubview(contentViewController.view)
contentViewController.view.translatesAutoresizingMaskIntoConstraints = false
contentViewController.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
contentViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentViewController.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
contentViewController.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example/SwiftUICalendar.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0497427029EFC72800146307 /* StartWithMonday.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0497426F29EFC72800146307 /* StartWithMonday.swift */; };
2F1877712727964400A6987F /* InformationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F1877702727964400A6987F /* InformationView.swift */; };
2F1877812727E8E300A6987F /* InformationWithSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F1877802727E8E300A6987F /* InformationWithSelectionView.swift */; };
2F41278A2721092300336C8C /* BasicUseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4127892721092300336C8C /* BasicUseView.swift */; };
2F41278C2721092F00336C8C /* CalendarScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F41278B2721092F00336C8C /* CalendarScrollView.swift */; };
2F41278E2721093800336C8C /* EmbedHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F41278D2721093800336C8C /* EmbedHeaderView.swift */; };
2F8BE219272787B500410651 /* SelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F8BE218272787B500410651 /* SelectionView.swift */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
70CF4A532162E518B75370AB /* Pods_SwiftUICalendar_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58AFC65DC1653690BF0B4F96 /* Pods_SwiftUICalendar_Tests.framework */; };
F9DEDA2240F94F1B2C25BE97 /* Pods_SwiftUICalendar_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D9008D491DE126083E4B2C8 /* Pods_SwiftUICalendar_Example.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 607FACC81AFB9204008FA782 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 607FACCF1AFB9204008FA782;
remoteInfo = SwiftUICalendar;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0497426F29EFC72800146307 /* StartWithMonday.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartWithMonday.swift; sourceTree = ""; };
1529C6D412355F8136F54624 /* SwiftUICalendar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwiftUICalendar.podspec; path = ../SwiftUICalendar.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
1D9008D491DE126083E4B2C8 /* Pods_SwiftUICalendar_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftUICalendar_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2F1877702727964400A6987F /* InformationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationView.swift; sourceTree = ""; };
2F1877802727E8E300A6987F /* InformationWithSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationWithSelectionView.swift; sourceTree = ""; };
2F4127892721092300336C8C /* BasicUseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicUseView.swift; sourceTree = ""; };
2F41278B2721092F00336C8C /* CalendarScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarScrollView.swift; sourceTree = ""; };
2F41278D2721093800336C8C /* EmbedHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbedHeaderView.swift; sourceTree = ""; };
2F8BE218272787B500410651 /* SelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectionView.swift; sourceTree = ""; };
38EF59E86D83726E53E33DAB /* Pods-SwiftUICalendar_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUICalendar_Example.debug.xcconfig"; path = "Target Support Files/Pods-SwiftUICalendar_Example/Pods-SwiftUICalendar_Example.debug.xcconfig"; sourceTree = ""; };
49E4341B7693DD4DF7DF8F8B /* Pods-SwiftUICalendar_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUICalendar_Tests.release.xcconfig"; path = "Target Support Files/Pods-SwiftUICalendar_Tests/Pods-SwiftUICalendar_Tests.release.xcconfig"; sourceTree = ""; };
4BE1B68D119981658B8F8880 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; };
58AFC65DC1653690BF0B4F96 /* Pods_SwiftUICalendar_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftUICalendar_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5B3059F75A3DE1A9D86D0BDB /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; };
5B5E9923C3A984B6A955ABFA /* Pods-SwiftUICalendar_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUICalendar_Example.release.xcconfig"; path = "Target Support Files/Pods-SwiftUICalendar_Example/Pods-SwiftUICalendar_Example.release.xcconfig"; sourceTree = ""; };
607FACD01AFB9204008FA782 /* SwiftUICalendar_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUICalendar_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
607FACE51AFB9204008FA782 /* SwiftUICalendar_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftUICalendar_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; };
C61EDE4455EFAA021752CF52 /* Pods-SwiftUICalendar_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUICalendar_Tests.debug.xcconfig"; path = "Target Support Files/Pods-SwiftUICalendar_Tests/Pods-SwiftUICalendar_Tests.debug.xcconfig"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
607FACCD1AFB9204008FA782 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F9DEDA2240F94F1B2C25BE97 /* Pods_SwiftUICalendar_Example.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
607FACE21AFB9204008FA782 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
70CF4A532162E518B75370AB /* Pods_SwiftUICalendar_Tests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2F4127882721091100336C8C /* Samples */ = {
isa = PBXGroup;
children = (
2F4127892721092300336C8C /* BasicUseView.swift */,
0497426F29EFC72800146307 /* StartWithMonday.swift */,
2F41278B2721092F00336C8C /* CalendarScrollView.swift */,
2F41278D2721093800336C8C /* EmbedHeaderView.swift */,
2F1877702727964400A6987F /* InformationView.swift */,
2F8BE218272787B500410651 /* SelectionView.swift */,
2F1877802727E8E300A6987F /* InformationWithSelectionView.swift */,
);
name = Samples;
sourceTree = "";
};
607FACC71AFB9204008FA782 = {
isa = PBXGroup;
children = (
607FACF51AFB993E008FA782 /* Podspec Metadata */,
607FACD21AFB9204008FA782 /* Example for SwiftUICalendar */,
607FACE81AFB9204008FA782 /* Tests */,
607FACD11AFB9204008FA782 /* Products */,
D735737FD2A73A6B1F22FC49 /* Pods */,
A4AA3BEDF5C84869028017DD /* Frameworks */,
);
sourceTree = "";
};
607FACD11AFB9204008FA782 /* Products */ = {
isa = PBXGroup;
children = (
607FACD01AFB9204008FA782 /* SwiftUICalendar_Example.app */,
607FACE51AFB9204008FA782 /* SwiftUICalendar_Tests.xctest */,
);
name = Products;
sourceTree = "";
};
607FACD21AFB9204008FA782 /* Example for SwiftUICalendar */ = {
isa = PBXGroup;
children = (
2F4127882721091100336C8C /* Samples */,
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
607FACD71AFB9204008FA782 /* ViewController.swift */,
607FACDC1AFB9204008FA782 /* Images.xcassets */,
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
607FACD31AFB9204008FA782 /* Supporting Files */,
);
name = "Example for SwiftUICalendar";
path = SwiftUICalendar;
sourceTree = "";
};
607FACD31AFB9204008FA782 /* Supporting Files */ = {
isa = PBXGroup;
children = (
607FACD41AFB9204008FA782 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
607FACEB1AFB9204008FA782 /* Tests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
sourceTree = "";
};
607FACE91AFB9204008FA782 /* Supporting Files */ = {
isa = PBXGroup;
children = (
607FACEA1AFB9204008FA782 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
isa = PBXGroup;
children = (
1529C6D412355F8136F54624 /* SwiftUICalendar.podspec */,
5B3059F75A3DE1A9D86D0BDB /* README.md */,
4BE1B68D119981658B8F8880 /* LICENSE */,
);
name = "Podspec Metadata";
sourceTree = "";
};
A4AA3BEDF5C84869028017DD /* Frameworks */ = {
isa = PBXGroup;
children = (
1D9008D491DE126083E4B2C8 /* Pods_SwiftUICalendar_Example.framework */,
58AFC65DC1653690BF0B4F96 /* Pods_SwiftUICalendar_Tests.framework */,
);
name = Frameworks;
sourceTree = "";
};
D735737FD2A73A6B1F22FC49 /* Pods */ = {
isa = PBXGroup;
children = (
38EF59E86D83726E53E33DAB /* Pods-SwiftUICalendar_Example.debug.xcconfig */,
5B5E9923C3A984B6A955ABFA /* Pods-SwiftUICalendar_Example.release.xcconfig */,
C61EDE4455EFAA021752CF52 /* Pods-SwiftUICalendar_Tests.debug.xcconfig */,
49E4341B7693DD4DF7DF8F8B /* Pods-SwiftUICalendar_Tests.release.xcconfig */,
);
path = Pods;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
607FACCF1AFB9204008FA782 /* SwiftUICalendar_Example */ = {
isa = PBXNativeTarget;
buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUICalendar_Example" */;
buildPhases = (
04D346863701023EAABBF89E /* [CP] Check Pods Manifest.lock */,
607FACCC1AFB9204008FA782 /* Sources */,
607FACCD1AFB9204008FA782 /* Frameworks */,
607FACCE1AFB9204008FA782 /* Resources */,
1396D50E1BE49F9EF6FD06BA /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = SwiftUICalendar_Example;
productName = SwiftUICalendar;
productReference = 607FACD01AFB9204008FA782 /* SwiftUICalendar_Example.app */;
productType = "com.apple.product-type.application";
};
607FACE41AFB9204008FA782 /* SwiftUICalendar_Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUICalendar_Tests" */;
buildPhases = (
06EB312F70CEF94784EC9BB4 /* [CP] Check Pods Manifest.lock */,
607FACE11AFB9204008FA782 /* Sources */,
607FACE21AFB9204008FA782 /* Frameworks */,
607FACE31AFB9204008FA782 /* Resources */,
);
buildRules = (
);
dependencies = (
607FACE71AFB9204008FA782 /* PBXTargetDependency */,
);
name = SwiftUICalendar_Tests;
productName = Tests;
productReference = 607FACE51AFB9204008FA782 /* SwiftUICalendar_Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
607FACC81AFB9204008FA782 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftUICalendar" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = 607FACC71AFB9204008FA782;
productRefGroup = 607FACD11AFB9204008FA782 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
607FACCF1AFB9204008FA782 /* SwiftUICalendar_Example */,
607FACE41AFB9204008FA782 /* SwiftUICalendar_Tests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
607FACCE1AFB9204008FA782 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
607FACE31AFB9204008FA782 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
04D346863701023EAABBF89E /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-SwiftUICalendar_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
06EB312F70CEF94784EC9BB4 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-SwiftUICalendar_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
1396D50E1BE49F9EF6FD06BA /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-SwiftUICalendar_Example/Pods-SwiftUICalendar_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/SwiftUICalendar/SwiftUICalendar.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftUICalendar.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftUICalendar_Example/Pods-SwiftUICalendar_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
607FACCC1AFB9204008FA782 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2F1877712727964400A6987F /* InformationView.swift in Sources */,
2F1877812727E8E300A6987F /* InformationWithSelectionView.swift in Sources */,
2F41278E2721093800336C8C /* EmbedHeaderView.swift in Sources */,
2F41278C2721092F00336C8C /* CalendarScrollView.swift in Sources */,
0497427029EFC72800146307 /* StartWithMonday.swift in Sources */,
2F41278A2721092300336C8C /* BasicUseView.swift in Sources */,
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
2F8BE219272787B500410651 /* SelectionView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
607FACE11AFB9204008FA782 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
607FACE71AFB9204008FA782 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 607FACCF1AFB9204008FA782 /* SwiftUICalendar_Example */;
targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
607FACDF1AFB9204008FA782 /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
607FACED1AFB9204008FA782 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
607FACEE1AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
607FACF01AFB9204008FA782 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 38EF59E86D83726E53E33DAB /* Pods-SwiftUICalendar_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SwiftUICalendar/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
607FACF11AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5B5E9923C3A984B6A955ABFA /* Pods-SwiftUICalendar_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SwiftUICalendar/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
607FACF31AFB9204008FA782 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C61EDE4455EFAA021752CF52 /* Pods-SwiftUICalendar_Tests.debug.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICalendar_Example.app/SwiftUICalendar_Example";
};
name = Debug;
};
607FACF41AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 49E4341B7693DD4DF7DF8F8B /* Pods-SwiftUICalendar_Tests.release.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICalendar_Example.app/SwiftUICalendar_Example";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftUICalendar" */ = {
isa = XCConfigurationList;
buildConfigurations = (
607FACED1AFB9204008FA782 /* Debug */,
607FACEE1AFB9204008FA782 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUICalendar_Example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
607FACF01AFB9204008FA782 /* Debug */,
607FACF11AFB9204008FA782 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUICalendar_Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
607FACF31AFB9204008FA782 /* Debug */,
607FACF41AFB9204008FA782 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 607FACC81AFB9204008FA782 /* Project object */;
}
================================================
FILE: Example/SwiftUICalendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example/SwiftUICalendar.xcodeproj/xcshareddata/xcschemes/SwiftUICalendar-Example.xcscheme
================================================
================================================
FILE: Example/SwiftUICalendar.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example/SwiftUICalendar.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example/Tests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: Example/Tests/Tests.swift
================================================
import XCTest
import SwiftUICalendar
class Tests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: LICENSE
================================================
Copyright (c) 2021 ggaljjak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Package.swift
================================================
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SwiftUICalendar",
platforms: [.iOS(.v14)],
//, .macOS(???)
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "SwiftUICalendar",
targets: ["SwiftUICalendar"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "SwiftUICalendar",
dependencies: [],
path: "Sources/SwiftUICalendar/Classes"
),
//.testTarget(
// name: "SwiftUICalendarTests",
// dependencies: ["SwiftUICalendar"]),
]
)
================================================
FILE: README.md
================================================
# SwiftUICalendar
[](https://cocoapods.org/pods/SwiftUICalendar)
[](https://cocoapods.org/pods/SwiftUICalendar)
[](https://cocoapods.org/pods/SwiftUICalendar)
SwiftUICalendar is calendar view for SwiftUI
## Installation
### [Swift Package Manager](https://swift.org/package-manager/)
- From url : `https://github.com/GGJJack/SwiftUICalendar`
or
- Package.swift
```swift
.package(name: "SwiftUICalendar", url: "https://github.com/GGJJack/SwiftUICalendar", from: "0.1.14")
```
### [CocoaPods](https://cocoapods.org)
```ruby
pod 'SwiftUICalendar'
```
### import
```swift
import SwiftUICalendar
```
## Features
- Infinite scroll
- Support horizontal and vertical scroll
- Full custom calendar cell
- Pager lock
- Starting the week with Sunday or Monday
## Example
### Basic
```swift
CalendarView() { date in
Text("\(date.day)")
}
```
### Basic use

Show example code
```swift
struct BasicUseView: View {
@ObservedObject var controller: CalendarController = CalendarController(orientation: .vertical)
var body: some View {
GeometryReader { reader in
VStack(alignment: .center, spacing: 0) {
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[i])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller) { date in
GeometryReader { geometry in
ZStack(alignment: .center) {
if date.isToday {
Circle()
.padding(4)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.foregroundColor(.orange)
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .bold, design: .default))
.foregroundColor(.white)
} else {
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.foregroundColor(getColor(date))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
}
}
}
}
```
### Calendar scroll

Show example code
```swift
struct CalendarScrollView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack(alignment: .center, spacing: 0) {
HStack(alignment: .center, spacing: 0) {
Spacer()
Button("Older") {
controller.scrollTo(YearMonth(year: 1500, month: 1), isAnimate: true)
}
Spacer()
Button("Today") {
controller.scrollTo(YearMonth.current, isAnimate: false)
}
Spacer()
Button("Today Scroll") {
controller.scrollTo(YearMonth.current, isAnimate: true)
}
Spacer()
Button("Future") {
controller.scrollTo(YearMonth(year: 2500, month: 1), isAnimate: true)
}
Spacer()
}
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[i])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller) { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
.navigationBarTitle("Calendar Scroll")
// .onChange(of: controller.yearMonth) { yearMonth in // If you want to detect date change
// print(yearMonth)
// }
}
}
}
}
```
### Embed Header

Show example code
```swift
struct EmbedHeaderView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack {
HStack(alignment: .center, spacing: 0) {
Button("Prev") {
controller.scrollTo(controller.yearMonth.addMonth(value: -1), isAnimate: true)
}
.padding(8)
Spacer()
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
Spacer()
Button("Next") {
controller.scrollTo(controller.yearMonth.addMonth(value: 1), isAnimate: true)
}
.padding(8)
}
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
})
}
}
.navigationBarTitle("Embed header")
}
}
```
### Information

Show example code
```swift
extension YearMonthDay: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.year)
hasher.combine(self.month)
hasher.combine(self.day)
}
}
struct InformationView: View {
var informations = [YearMonthDay: [(String, Color)]]()
init() {
var date = YearMonthDay.current
informations[date] = []
informations[date]?.append(("Hello", Color.orange))
informations[date]?.append(("World", Color.blue))
date = date.addDay(value: 3)
informations[date] = []
informations[date]?.append(("Test", Color.pink))
date = date.addDay(value: 8)
informations[date] = []
informations[date]?.append(("Jack", Color.green))
date = date.addDay(value: 5)
informations[date] = []
informations[date]?.append(("Home", Color.red))
date = date.addDay(value: -23)
informations[date] = []
informations[date]?.append(("Meet at 8, Home", Color.purple))
date = date.addDay(value: -5)
informations[date] = []
informations[date]?.append(("Home", Color.yellow))
date = date.addDay(value: -10)
informations[date] = []
informations[date]?.append(("Baseball", Color.green))
}
var body: some View {
GeometryReader { reader in
VStack {
CalendarView(header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
VStack(alignment: .leading, spacing: 2) {
if date.isToday {
Text("\(date.day)")
.font(.system(size: 10, weight: .bold, design: .default))
.padding(4)
.foregroundColor(.white)
.background(Color.red.opacity(0.95))
.cornerRadius(14)
} else {
Text("\(date.day)")
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.foregroundColor(getColor(date))
.padding(4)
}
if let infos = informations[date] {
ForEach(infos.indices) { index in
let info = infos[index]
Text(info.0)
.lineLimit(1)
.foregroundColor(.white)
.font(.system(size: 8, weight: .bold, design: .default))
.padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4))
.frame(width: geometry.size.width, alignment: .center)
.background(info.1.opacity(0.75))
.cornerRadius(4)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading)
}
})
}
}
.navigationBarTitle("Information")
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
```
### Selection

Show example code
```swift
struct SelectionView: View {
@ObservedObject var controller: CalendarController = CalendarController()
@State var focusDate: YearMonthDay? = YearMonthDay.current
var body: some View {
GeometryReader { reader in
VStack {
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.border(.green.opacity(0.8), width: (focusDate == date ? 1 : 0))
.cornerRadius(2)
.contentShape(Rectangle())
.onTapGesture {
focusDate = (date != focusDate ? date : nil)
}
}
})
}
}
.navigationBarTitle("Selection")
}
}
```
### Information + Selection

Show example code
```swift
struct InformationWithSelectionView: View {
let controller = CalendarController()
var informations = [YearMonthDay: [(String, Color)]]()
@State var focusDate: YearMonthDay? = nil
@State var focusInfo: [(String, Color)]? = nil
init() {
var date = YearMonthDay.current
informations[date] = []
informations[date]?.append(("Hello", Color.orange))
informations[date]?.append(("World", Color.blue))
date = date.addDay(value: 3)
informations[date] = []
informations[date]?.append(("Test", Color.pink))
date = date.addDay(value: 8)
informations[date] = []
informations[date]?.append(("Jack", Color.green))
date = date.addDay(value: 5)
informations[date] = []
informations[date]?.append(("Home", Color.red))
date = date.addDay(value: -23)
informations[date] = []
informations[date]?.append(("Meet at 8, Home", Color.purple))
date = date.addDay(value: -5)
informations[date] = []
informations[date]?.append(("Home", Color.yellow))
date = date.addDay(value: -10)
informations[date] = []
informations[date]?.append(("Baseball", Color.green))
}
var body: some View {
GeometryReader { reader in
VStack {
CalendarView(controller, header: { week in
GeometryReader { geometry in
Text(week.shortString)
.font(.subheadline)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}, component: { date in
GeometryReader { geometry in
VStack(alignment: .leading, spacing: 2) {
if date.isToday {
Text("\(date.day)")
.font(.system(size: 10, weight: .bold, design: .default))
.padding(4)
.foregroundColor(.white)
.background(Color.red.opacity(0.95))
.cornerRadius(14)
} else {
Text("\(date.day)")
.font(.system(size: 10, weight: .light, design: .default))
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
.foregroundColor(getColor(date))
.padding(4)
}
if let infos = informations[date] {
ForEach(infos.indices) { index in
let info = infos[index]
if focusInfo != nil {
Rectangle()
.fill(info.1.opacity(0.75))
.frame(width: geometry.size.width, height: 4, alignment: .center)
.cornerRadius(2)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
} else {
Text(info.0)
.lineLimit(1)
.foregroundColor(.white)
.font(.system(size: 8, weight: .bold, design: .default))
.padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4))
.frame(width: geometry.size.width, alignment: .center)
.background(info.1.opacity(0.75))
.cornerRadius(4)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading)
.border(.green.opacity(0.8), width: (focusDate == date ? 1 : 0))
.cornerRadius(2)
.contentShape(Rectangle())
.onTapGesture {
withAnimation {
if focusDate == date {
focusDate = nil
focusInfo = nil
} else {
focusDate = date
focusInfo = informations[date]
}
}
}
}
})
if let infos = focusInfo {
List(infos.indices, id: \.self) { index in
let info = infos[index]
HStack(alignment: .center, spacing: 0) {
Circle()
.fill(info.1.opacity(0.75))
.frame(width: 12, height: 12)
Text(info.0)
.padding(.leading, 8)
}
}
.frame(width: reader.size.width, height: 160, alignment: .center)
}
}
}
.navigationBarTitle("Info + Select")
}
private func getColor(_ date: YearMonthDay) -> Color {
if date.dayOfWeek == .sun {
return Color.red
} else if date.dayOfWeek == .sat {
return Color.blue
} else {
return Color.black
}
}
}
```
### Date change detection
```Swift
CalendarView(controller) { date in
....
}
.onChange(of: controller.yearMonth) { yearMonth in
print(yearMonth)
}
```
### Start with Monday

Show example code
```swift
struct StartMondayView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack {
Text("\(controller.yearMonth.monthShortString), \(String(controller.yearMonth.year))")
.font(.title)
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
CalendarView(controller, startWithMonday: true, headerSize: .fixHeight(50.0)) { week in
Text("\(week.shortString)")
.font(.headline)
.frame(width: reader.size.width / 7)
} component: { date in
GeometryReader { geometry in
if date.isToday {
Circle()
.padding(4)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.foregroundColor(.orange)
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .bold, design: .default))
.foregroundColor(.white)
} else {
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.foregroundColor(.black)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
}
}
}
```
Show example code
```swift
struct StartMondayView: View {
@ObservedObject var controller: CalendarController = CalendarController()
var body: some View {
GeometryReader { reader in
VStack {
HStack(alignment: .center, spacing: 0) {
ForEach(0..<7, id: \.self) { i in
Text(DateFormatter().shortWeekdaySymbols[i < 6 ? i + 1 : 0])
.font(.headline)
.frame(width: reader.size.width / 7)
}
}
CalendarView(controller, startWithMonday: true, headerSize: .fixHeight(50.0)) { week in
Text("\(week.shortString)")
.font(.headline)
.frame(width: reader.size.width / 7)
} component: { date in
GeometryReader { geometry in
if date.isToday {
Circle()
.padding(4)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.foregroundColor(.orange)
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .bold, design: .default))
.foregroundColor(.white)
} else {
Text("\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
.font(.system(size: 10, weight: .light, design: .default))
.foregroundColor(.black)
.opacity(date.isFocusYearMonth == true ? 1 : 0.4)
}
}
}
}
}
}
}
```
## Struct
### CalendarView
```Swift
public struct CalendarView: View {
public init(
_ controller: CalendarController = CalendarController(),
startWithMonday: Bool = false,
@ViewBuilder component: @escaping (YearMonthDay) -> CalendarCell
) {
...
}
public init(
_ controller: CalendarController = CalendarController(),
startWithMonday: Bool = false,
headerSize: HeaderSize = .fixHeight(40),
@ViewBuilder header: @escaping (Week) -> HeaderCell,
@ViewBuilder component: @escaping (YearMonthDay) -> CalendarCell
) {
...
}
...
}
```
### HeaderSize
```Swift
public enum HeaderSize {
case zero
case ratio
case fixHeight(CGFloat)
}
```
### CalendarController
```Swift
public class CalendarController: ObservableObject {
public init(
_ yearMonth: YearMonth = .current,
orientation: Orientation = .horizontal,
isLocked: Bool = false
)
...
}
var verticalController = CalendarController(
YearMonth.current,
orientation: .vertical,
isLocked: true
)
var controller = CalendarController()
// Scroll with animate
controller.scrollTo(year: 1991, month: 2, isAnimate: true)
// Scroll without animate
controller.scrollTo(YearMonth.current, isAnimate: false)
// Lock Pager
controller.isLocked = true
```
### YearMonth
```Swift
public struct YearMonth: Equatable {
public let year: Int
public let month: Int
public init(year: Int, month: Int) { ... }
...
}
let date = YearMonth(year: 2021, month: 10)
let now = YearMonth.current // Now
print(date.monthShortString) // Oct // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
let nextMonth = date.addMonth(value: 1) // {year: 2021, month: 11}
let diff = nextMonth.diffMonth(value: date) // 2021/11 - 2021/10 = 1
let components: DateComponents = nextMonth.toDateComponents()
```
### YearMonthDay
```Swift
public struct YearMonthDay: Equatable {
public let year: Int
public let month: Int
public let day: Int
public let isFocusYearMonth: Bool?
public init(year: Int, month: Int, day: Int) { ... }
public init(year: Int, month: Int, day: Int, isFocusYearMonth: Bool) { ... }
...
}
let date = YearMonthDay(year: 2021, month: 10, day: 26)
let now = YearMonthDay.current
let isToday = now.isToday // true
let dayOfWeek: Week = date.dayOfWeek // Tue // Sun, Mon, Tue, Wed, Thu, Fri, Sat
let toDate = date.date! // { 2021/10/26 }
let components: DateComponents = date.toDateComponents()
let tomorrow = date.addDay(value: 1) // {year: 2021, month: 10, day: 27}
let diff = tomorrow.diffDay(value: date) // 2021/10/27 - 2021/10/26 = 1
```
### Week
```Swift
public enum Week: Int, CaseIterable {
case sun = 0
case mon = 1
case tue = 2
case wed = 3
case thu = 4
case fri = 5
case sat = 6
public var shortString: String // Sun, Mon, Tue, Wed, Thu, Fri, Sat
}
```
## Contributors
Thank you very much for your contribution! 🙏
| [
](https://github.com/aaron25mt) |[
](https://github.com/NSRover) | [
](https://github.com/sanhee16) |
|:---:|:---:|:---:|
| [@aaron25mt](https://github.com/aaron25mt) | [@NSRover](https://github.com/NSRover) |[@sanhee16](https://github.com/sanhee16) |
## Author
GGJJack, ggaljjak.choi@gmail.com
## License
SwiftUICalendar is available under the MIT license. See the LICENSE file for more info.
================================================
FILE: Sources/SwiftUICalendar/Assets/.gitkeep
================================================
================================================
FILE: Sources/SwiftUICalendar/Classes/.gitkeep
================================================
================================================
FILE: Sources/SwiftUICalendar/Classes/CalendarController.swift
================================================
//
// CalendarProxy.swift
// SwiftUICalendar
//
// Created by GGJJack on 2021/10/25.
//
import SwiftUI
import Combine
public class CalendarController: ObservableObject {
@Published public var yearMonth: YearMonth
@Published public var isLocked: Bool
@Published internal var position: Int = Global.CENTER_PAGE
@Published internal var internalYearMonth: YearMonth
internal let orientation: Orientation
internal let columnCount = 7
internal let rowCount = 6
internal let max: Int = Global.MAX_PAGE
internal let center: Int = Global.CENTER_PAGE
internal let scrollDetector: CurrentValueSubject
internal var cancellables = Set()
public init(_ yearMonth: YearMonth = .current, orientation: Orientation = .horizontal, isLocked: Bool = false) {
let detector = CurrentValueSubject(0)
self.scrollDetector = detector
self.internalYearMonth = yearMonth
self.yearMonth = yearMonth
self.orientation = orientation
self.isLocked = isLocked
detector
.debounce(for: .seconds(0.2), scheduler: DispatchQueue.main)
.dropFirst()
.sink { [weak self] value in
if let self = self {
let move = self.position - self.center
self.internalYearMonth = self.internalYearMonth.addMonth(value: move)
self.yearMonth = self.internalYearMonth
self.position = self.center
self.objectWillChange.send()
}
}
.store(in: &cancellables)
}
public func setYearMonth(year: Int, month: Int) {
self.setYearMonth(YearMonth(year: year, month: month))
}
public func setYearMonth(_ yearMonth: YearMonth) {
self.yearMonth = yearMonth
self.internalYearMonth = yearMonth
self.position = self.center
self.objectWillChange.send()
}
public func scrollTo(year: Int, month: Int, isAnimate: Bool = true) {
self.scrollTo(YearMonth(year: year, month: month), isAnimate: isAnimate)
}
public func scrollTo(_ yearMonth: YearMonth, isAnimate: Bool = true) {
if isAnimate {
var diff = self.position - yearMonth.diffMonth(value: self.yearMonth)
if diff < 0 {
self.internalYearMonth = yearMonth.addMonth(value: self.center)
diff = 0
// 4 * 12 + 2 50
} else if self.max <= diff {
self.internalYearMonth = yearMonth.addMonth(value: -self.center + 1)
diff = self.max - 1
}
self.objectWillChange.send()
withAnimation { [weak self] in
if let self = self {
self.position = diff
self.objectWillChange.send()
}
}
} else {
self.internalYearMonth = yearMonth
self.yearMonth = yearMonth
self.objectWillChange.send()
}
}
}
================================================
FILE: Sources/SwiftUICalendar/Classes/CalendarView.swift
================================================
//
// CalendarView.swift
// SwiftUICalendar
//
// Created by GGJJack on 2021/10/26.
//
import SwiftUI
import Combine
public struct CalendarView: View {
private var gridItem: [GridItem] = Array(repeating: .init(.flexible(), spacing: 0), count: 7) // columnCount
private let component: (YearMonthDay) -> CalendarCell
private let header: (Week) -> HeaderCell?
private var headerSize: HeaderSize
@ObservedObject private var controller: CalendarController
private let isHasHeader: Bool
private var startWithMonday: Bool
public init(
_ controller: CalendarController = CalendarController(),
startWithMonday: Bool = false,
@ViewBuilder component: @escaping (YearMonthDay) -> CalendarCell
) where HeaderCell == EmptyView {
self.controller = controller
self.startWithMonday = startWithMonday
self.header = { _ in nil }
self.component = component
self.isHasHeader = false
self.headerSize = .zero
}
public init(
_ controller: CalendarController = CalendarController(),
startWithMonday: Bool = false,
headerSize: HeaderSize = .fixHeight(40),
@ViewBuilder header: @escaping (Week) -> HeaderCell,
@ViewBuilder component: @escaping (YearMonthDay) -> CalendarCell
) {
self.controller = controller
self.startWithMonday = startWithMonday
self.header = header
self.component = component
self.isHasHeader = true
self.headerSize = headerSize
}
public var body: some View {
GeometryReader { proxy in
InfinitePagerView(controller, orientation: controller.orientation) { yearMonth, i in
LazyVGrid(columns: gridItem, alignment: .center, spacing: 0) {
ForEach(0..<(controller.columnCount * (controller.rowCount + (isHasHeader ? 1 : 0))), id: \.self) { j in
GeometryReader { geometry in
if isHasHeader && j < controller.columnCount {
header(Week.allCases[!self.startWithMonday ? j : j < 6 ? j + 1 : 0])
} else {
let date = yearMonth.cellToDate(j - (isHasHeader ? 7 : 0), startWithMonday: startWithMonday)
self.component(date)
}
}
.frame(height: calculateCellHeight(j, geometry: proxy))
}
}
.frame(width: proxy.size.width, height: proxy.size.height, alignment: .center)
}
}
}
func calculateCellHeight(_ index: Int, geometry: GeometryProxy) -> CGFloat {
if !isHasHeader {
return geometry.size.height / CGFloat(controller.rowCount)
}
var headerHeight: CGFloat = 0
switch headerSize {
case .zero:
headerHeight = 0
case .ratio:
headerHeight = geometry.size.height / CGFloat(controller.rowCount + 1)
case .fixHeight(let value):
headerHeight = value
}
if index < controller.columnCount {
return headerHeight
} else {
return (geometry.size.height - headerHeight) / CGFloat(controller.rowCount)
}
}
}
struct CalendarView_Previews: PreviewProvider {
static var previews: some View {
CalendarView(CalendarController()) { date in
GeometryReader { geometry in
Text("\(String(date.year))/\(date.month)/\(date.day)")
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading)
.border(.black, width: 1)
.font(.system(size: 8))
.opacity(date.isFocusYearMonth == true ? 1 : 0.6)
}
}
}
}
================================================
FILE: Sources/SwiftUICalendar/Classes/Global.swift
================================================
//
// Global.swift
// SwiftUICalendar
//
// Created by GGJJack on 2021/10/22.
//
import Foundation
import SwiftUI
class Global {
static let MAX_PAGE = 100
static let CENTER_PAGE = 100 / 2
}
================================================
FILE: Sources/SwiftUICalendar/Classes/InfinitePagerView.swift
================================================
//
// InfinitePagerView.swift
// SwiftUICalendar
//
// Created by GGJJack on 2021/10/22.
//
import Foundation
import SwiftUI
import Combine
internal struct InfinitePagerView: View {
private let content: (YearMonth, Int) -> Content
private let flippingAngle: Angle = Angle(degrees: 0)
@ObservedObject private var controller: CalendarController
private var _onMoveCenter: ((Int) -> Void)? = nil
init(_ controller: CalendarController, orientation: Orientation, @ViewBuilder content: @escaping (YearMonth, Int) -> Content) {
self.controller = controller
self.content = content
}
var body: some View {
drawTabView { geometry in
ForEach(0..(@ViewBuilder content: @escaping (GeometryProxy) -> V) -> some View {
return GeometryReader { proxy in
if controller.orientation == .horizontal {
TabView(selection: $controller.position) {
content(proxy)
.contentShape(Rectangle())
.gesture(controller.isLocked ? DragGesture() : nil)
}
.frame(width: proxy.size.width, height: proxy.size.height)
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.coordinateSpace(name: "scroll")
} else {
TabView(selection: $controller.position) {
content(proxy)
.frame(width: proxy.size.width, height: proxy.size.height)
.rotationEffect(.degrees(-90))
.rotation3DEffect(flippingAngle, axis: (x: 1, y: 0, z: 0))
.contentShape(Rectangle())
.gesture(controller.isLocked ? DragGesture() : nil)
}
.frame(width: proxy.size.height, height: proxy.size.width)
.rotation3DEffect(flippingAngle, axis: (x: 1, y: 0, z: 0))
.rotationEffect(.degrees(90), anchor: .topLeading)
.offset(x: proxy.size.width)
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.coordinateSpace(name: "scroll")
}
}
}
func onMoveCenter(callback: ((Int) -> Void)?) -> Self {
var ret = self
ret._onMoveCenter = callback
return ret
}
}
fileprivate struct ScrollOffsetKey: PreferenceKey {
typealias Value = CGFloat
static var defaultValue = CGFloat.zero
static func reduce(value: inout Value, nextValue: () -> Value) {
value += nextValue()
}
}
================================================
FILE: Sources/SwiftUICalendar/Classes/Struct.swift
================================================
//
// Struct.swift
// SwiftUICalendar
//
// Created by GGJJack on 2021/10/21.
//
import Foundation
import SwiftUI
public enum Week: Int, CaseIterable {
case sun = 0
case mon = 1
case tue = 2
case wed = 3
case thu = 4
case fri = 5
case sat = 6
public var shortString: String {
get {
return DateFormatter().shortWeekdaySymbols[self.rawValue]
}
}
public func shortString(locale: Locale) -> String {
let formatter = DateFormatter()
formatter.locale = locale
return formatter.shortWeekdaySymbols[self.rawValue]
}
}
public enum Orientation {
case horizontal
case vertical
}
public enum HeaderSize {
case zero
case ratio
case fixHeight(CGFloat)
}
public struct YearMonth: Equatable, Hashable {
public let year: Int
public let month: Int
public init(year: Int, month: Int) {
self.year = year
self.month = month
}
public static var current: YearMonth {
get {
let today = Date()
return YearMonth(year: Calendar.current.component(.year, from: today), month: Calendar.current.component(.month, from: today))
}
}
public static func ==(lhs: Self, rhs: Self) -> Bool {
return lhs.year == rhs.year && lhs.month == rhs.month
}
public var monthShortString: String {
get {
var components = toDateComponents()
components.day = 1
components.hour = 0
components.minute = 0
components.second = 0
let formatter = DateFormatter()
formatter.dateFormat = "MMM"
return formatter.string(from: Calendar.current.date(from: components)!)
}
}
public func addMonth(value: Int) -> YearMonth {
let gregorianCalendar = NSCalendar(calendarIdentifier: .gregorian)!
let toDate = self.toDateComponents()
var components = DateComponents()
components.month = value
let addedDate = Calendar.current.date(byAdding: components, to: gregorianCalendar.date(from: toDate)!)!
let ret = YearMonth(year: Calendar.current.component(.year, from: addedDate), month: Calendar.current.component(.month, from: addedDate))
return ret
}
public func diffMonth(value: YearMonth) -> Int {
var origin = self.toDateComponents()
origin.day = 1
origin.hour = 0
origin.minute = 0
origin.second = 0
var new = value.toDateComponents()
new.day = 1
new.hour = 0
new.minute = 0
new.second = 0
return Calendar.current.dateComponents([.month], from: Calendar.current.date(from: origin)!, to: Calendar.current.date(from: new)!).month!
}
public func toDateComponents() -> DateComponents {
var components = DateComponents()
components.year = self.year
components.month = self.month
return components
}
public func hash(into hasher: inout Hasher) {
hasher.combine(self.year)
hasher.combine(self.month)
}
internal func cellToDate(_ cellIndex: Int, startWithMonday: Bool) -> YearMonthDay {
let gregorianCalendar = NSCalendar(calendarIdentifier: .gregorian)!
var toDateComponent = DateComponents()
toDateComponent.year = self.year
toDateComponent.month = self.month
toDateComponent.day = 1
let toDate = gregorianCalendar.date(from: toDateComponent)!
let weekday = Calendar.current.component(.weekday, from: toDate) // 1Sun, 2Mon, 3Tue, 4Wed, 5Thu, 6Fri, 7Sat
var components = DateComponents()
components.day = cellIndex - weekday + (!startWithMonday ? 1 : weekday == 1 ? (-5) : 2)
let addedDate = Calendar.current.date(byAdding: components, to: toDate)!
let year = Calendar.current.component(.year, from: addedDate)
let month = Calendar.current.component(.month, from: addedDate)
let day = Calendar.current.component(.day, from: addedDate)
let isFocusYaerMonth = year == self.year && month == self.month
let ret = YearMonthDay(year: year, month: month, day: day, isFocusYearMonth: isFocusYaerMonth)
return ret
}
}
public struct YearMonthDay: Equatable, Hashable {
public let year: Int
public let month: Int
public let day: Int
public let isFocusYearMonth: Bool?
public init(year: Int, month: Int, day: Int) {
self.year = year
self.month = month
self.day = day
self.isFocusYearMonth = nil
}
public init(year: Int, month: Int, day: Int, isFocusYearMonth: Bool) {
self.year = year
self.month = month
self.day = day
self.isFocusYearMonth = isFocusYearMonth
}
public static var current: YearMonthDay {
get {
let today = Date()
return YearMonthDay(
year: Calendar.current.component(.year, from: today),
month: Calendar.current.component(.month, from: today),
day: Calendar.current.component(.day, from: today)
)
}
}
public static func ==(lhs: Self, rhs: Self) -> Bool {
return lhs.year == rhs.year && lhs.month == rhs.month && lhs.day == rhs.day
}
public var isToday: Bool {
let today = Date()
let year = Calendar.current.component(.year, from: today)
let month = Calendar.current.component(.month, from: today)
let day = Calendar.current.component(.day, from: today)
return self.year == year && self.month == month && self.day == day
}
public var dayOfWeek: Week {
let weekday = Calendar.current.component(.weekday, from: self.date!)
return Week.allCases[weekday - 1]
}
public var date: Date? {
let gregorianCalendar = NSCalendar(calendarIdentifier: .gregorian)!
return gregorianCalendar.date(from: self.toDateComponents())
}
public func toDateComponents() -> DateComponents {
var components = DateComponents()
components.year = self.year
components.month = self.month
components.day = self.day
return components
}
public func addDay(value: Int) -> YearMonthDay {
let gregorianCalendar = NSCalendar(calendarIdentifier: .gregorian)!
let toDate = self.toDateComponents()
var components = DateComponents()
components.day = value
let addedDate = Calendar.current.date(byAdding: components, to: gregorianCalendar.date(from: toDate)!)!
let ret = YearMonthDay(
year: Calendar.current.component(.year, from: addedDate),
month: Calendar.current.component(.month, from: addedDate),
day: Calendar.current.component(.day, from: addedDate)
)
return ret
}
public func diffDay(value: YearMonthDay) -> Int {
var origin = self.toDateComponents()
origin.hour = 0
origin.minute = 0
origin.second = 0
var new = value.toDateComponents()
new.hour = 0
new.minute = 0
new.second = 0
return Calendar.current.dateComponents([.day], from: Calendar.current.date(from: origin)!, to: Calendar.current.date(from: new)!).month!
}
public func hash(into hasher: inout Hasher) {
hasher.combine(self.year)
hasher.combine(self.month)
hasher.combine(self.day)
}
}
================================================
FILE: SwiftUICalendar.podspec
================================================
#
# Be sure to run `pod lib lint SwiftUICalendar.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'SwiftUICalendar'
s.version = '0.1.14'
s.summary = 'SwiftUI Simple calendar view'
s.swift_version = '4.0'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
SwiftUI Simple Calendar View
Installation
DESC
s.homepage = 'https://github.com/GGJJack/SwiftUICalendar'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'ggaljjak' => 'ggaljjak.choi@gmail.com' }
s.source = { :git => 'https://github.com/GGJJack/SwiftUICalendar.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/'
s.ios.deployment_target = '14.0'
s.source_files = 'Sources/SwiftUICalendar/Classes/**/*'
# s.resource_bundles = {
# 'SwiftUICalendar' => ['SwiftUICalendar/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end