From f26c56ff15dbbba1f798a4b0e1ef7a39924b83c5 Mon Sep 17 00:00:00 2001 From: RaffiKian <52611259+RaffiKian@users.noreply.github.com> Date: Wed, 5 Feb 2020 22:32:35 +0200 Subject: [PATCH] Revert "Basic SwiftPM support (#10)" (#11) This reverts commit e228c06797b1763ac62ddf1ad94712f27a99899f. --- .gitignore | 118 ------------------ Package.swift | 31 ----- .../Manager}/RKCell.swift | 0 RKCalendar/Manager/RKColorSettings.swift | 33 +++++ .../Manager}/RKDate.swift | 0 RKCalendar/Manager/RKManager.swift | 56 +++++++++ .../Manager}/RKMonth.swift | 0 .../Manager}/RKViewController.swift | 13 +- .../Manager}/RKWeekdayHeader.swift | 0 Sources/RKCalendar/RKColorSettings.swift | 33 ----- Sources/RKCalendar/RKManager.swift | 56 --------- 11 files changed, 93 insertions(+), 247 deletions(-) delete mode 100644 .gitignore delete mode 100644 Package.swift rename {Sources/RKCalendar => RKCalendar/Manager}/RKCell.swift (100%) create mode 100644 RKCalendar/Manager/RKColorSettings.swift rename {Sources/RKCalendar => RKCalendar/Manager}/RKDate.swift (100%) create mode 100644 RKCalendar/Manager/RKManager.swift rename {Sources/RKCalendar => RKCalendar/Manager}/RKMonth.swift (100%) rename {Sources/RKCalendar => RKCalendar/Manager}/RKViewController.swift (81%) rename {Sources/RKCalendar => RKCalendar/Manager}/RKWeekdayHeader.swift (100%) delete mode 100644 Sources/RKCalendar/RKColorSettings.swift delete mode 100644 Sources/RKCalendar/RKManager.swift diff --git a/.gitignore b/.gitignore deleted file mode 100644 index da54006..0000000 --- a/.gitignore +++ /dev/null @@ -1,118 +0,0 @@ - -# Created by https://www.gitignore.io/api/macos,swift,swiftpackagemanager -# Edit at https://www.gitignore.io/?templates=macos,swift,swiftpackagemanager - -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Swift ### -# Xcode -# -# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore - -## Build generated -build/ -DerivedData/ - -## Various settings -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata/ - -## Other -*.moved-aside -*.xccheckout -*.xcscmblueprint - -## Obj-C/Swift specific -*.hmap -*.ipa -*.dSYM.zip -*.dSYM - -## Playgrounds -timeline.xctimeline -playground.xcworkspace - -# Swift Package Manager -# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. -# Packages/ -# Package.pins -# Package.resolved -.build/ -# Add this line if you want to avoid checking in Xcode SPM integration. -# .swiftpm/xcode - -# CocoaPods -# 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-check-the-pods-directory-into-source-control -# Pods/ -# Add this line if you want to avoid checking in source code from the Xcode workspace -# *.xcworkspace - -# Carthage -# Add this line if you want to avoid checking in source code from Carthage dependencies. -# Carthage/Checkouts - -Carthage/Build - -# Accio dependency management -Dependencies/ -.accio/ - -# fastlane -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the -# screenshots whenever they are needed. -# For more information about the recommended setup visit: -# https://docs.fastlane.tools/best-practices/source-control/#source-control - -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots/**/*.png -fastlane/test_output - -# Code Injection -# After new code Injection tools there's a generated folder /iOSInjectionProject -# https://github.com/johnno1962/injectionforxcode - -iOSInjectionProject/ - -### SwiftPackageManager ### -Packages -xcuserdata -*.xcodeproj - - -# End of https://www.gitignore.io/api/macos,swift,swiftpackagemanager \ No newline at end of file diff --git a/Package.swift b/Package.swift deleted file mode 100644 index 512cb05..0000000 --- a/Package.swift +++ /dev/null @@ -1,31 +0,0 @@ -// swift-tools-version:5.1 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "RKCalendar", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries produced by a package, and make them visible to other packages. - .library( - name: "RKCalendar", - targets: ["RKCalendar"]), - ], - 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 which this package depends on. - .target( - name: "RKCalendar", - dependencies: []), - // .testTarget( - // name: "RKCalendarTests", - // dependencies: ["RKCalendar"]), - ] -) diff --git a/Sources/RKCalendar/RKCell.swift b/RKCalendar/Manager/RKCell.swift similarity index 100% rename from Sources/RKCalendar/RKCell.swift rename to RKCalendar/Manager/RKCell.swift diff --git a/RKCalendar/Manager/RKColorSettings.swift b/RKCalendar/Manager/RKColorSettings.swift new file mode 100644 index 0000000..7631ff8 --- /dev/null +++ b/RKCalendar/Manager/RKColorSettings.swift @@ -0,0 +1,33 @@ +// +// RKColorSettings.swift +// RKCalendar +// +// Copyright © 2019 Raffi Kian. All rights reserved. +// + +import Foundation +import Combine +import SwiftUI + +class RKColorSettings : ObservableObject { + + // foreground colors + @Published var textColor: Color = Color.primary + @Published var todayColor: Color = Color.white + @Published var selectedColor: Color = Color.white + @Published var disabledColor: Color = Color.gray + @Published var betweenStartAndEndColor: Color = Color.white + // background colors + @Published var textBackColor: Color = Color.clear + @Published var todayBackColor: Color = Color.gray + @Published var selectedBackColor: Color = Color.red + @Published var disabledBackColor: Color = Color.clear + @Published var betweenStartAndEndBackColor: Color = Color.blue + // headers foreground colors + @Published var weekdayHeaderColor: Color = Color.primary + @Published var monthHeaderColor: Color = Color.primary + // headers background colors + @Published var weekdayHeaderBackColor: Color = Color.clear + @Published var monthBackColor: Color = Color.clear + +} diff --git a/Sources/RKCalendar/RKDate.swift b/RKCalendar/Manager/RKDate.swift similarity index 100% rename from Sources/RKCalendar/RKDate.swift rename to RKCalendar/Manager/RKDate.swift diff --git a/RKCalendar/Manager/RKManager.swift b/RKCalendar/Manager/RKManager.swift new file mode 100644 index 0000000..ea97da7 --- /dev/null +++ b/RKCalendar/Manager/RKManager.swift @@ -0,0 +1,56 @@ +// +// RKManager.swift +// RKCalendar +// +// Created by Raffi Kian on 7/14/19. +// Copyright © 2019 Raffi Kian. All rights reserved. +// + +import SwiftUI + +class RKManager : ObservableObject { + + @Published var calendar = Calendar.current + @Published var minimumDate: Date = Date() + @Published var maximumDate: Date = Date() + @Published var disabledDates: [Date] = [Date]() + @Published var selectedDates: [Date] = [Date]() + @Published var selectedDate: Date! = nil + @Published var startDate: Date! = nil + @Published var endDate: Date! = nil + + @Published var mode: Int = 0 + + var colors = RKColorSettings() + + init(calendar: Calendar, minimumDate: Date, maximumDate: Date, selectedDates: [Date] = [Date](), mode: Int) { + self.calendar = calendar + self.minimumDate = minimumDate + self.maximumDate = maximumDate + self.selectedDates = selectedDates + self.mode = mode + } + + func selectedDatesContains(date: Date) -> Bool { + if let _ = self.selectedDates.first(where: { calendar.isDate($0, inSameDayAs: date) }) { + return true + } + return false + } + + func selectedDatesFindIndex(date: Date) -> Int? { + return self.selectedDates.firstIndex(where: { calendar.isDate($0, inSameDayAs: date) }) + } + + func disabledDatesContains(date: Date) -> Bool { + if let _ = self.disabledDates.first(where: { calendar.isDate($0, inSameDayAs: date) }) { + return true + } + return false + } + + func disabledDatesFindIndex(date: Date) -> Int? { + return self.disabledDates.firstIndex(where: { calendar.isDate($0, inSameDayAs: date) }) + } + +} diff --git a/Sources/RKCalendar/RKMonth.swift b/RKCalendar/Manager/RKMonth.swift similarity index 100% rename from Sources/RKCalendar/RKMonth.swift rename to RKCalendar/Manager/RKMonth.swift diff --git a/Sources/RKCalendar/RKViewController.swift b/RKCalendar/Manager/RKViewController.swift similarity index 81% rename from Sources/RKCalendar/RKViewController.swift rename to RKCalendar/Manager/RKViewController.swift index d163c47..f421501 100644 --- a/Sources/RKCalendar/RKViewController.swift +++ b/RKCalendar/Manager/RKViewController.swift @@ -8,24 +8,19 @@ import SwiftUI -public struct RKViewController: View { +struct RKViewController: View { - var isPresented: Binding + @Binding var isPresented: Bool @ObservedObject var rkManager: RKManager - public init (isPresented: Binding, rkManager: RKManager) { - self.isPresented = isPresented - self.rkManager = rkManager - } - - public var body: some View { + var body: some View { Group { RKWeekdayHeader(rkManager: self.rkManager) Divider() List { ForEach(0.. Bool { - if let _ = self.selectedDates.first(where: { calendar.isDate($0, inSameDayAs: date) }) { - return true - } - return false - } - - public func selectedDatesFindIndex(date: Date) -> Int? { - return self.selectedDates.firstIndex(where: { calendar.isDate($0, inSameDayAs: date) }) - } - - public func disabledDatesContains(date: Date) -> Bool { - if let _ = self.disabledDates.first(where: { calendar.isDate($0, inSameDayAs: date) }) { - return true - } - return false - } - - public func disabledDatesFindIndex(date: Date) -> Int? { - return self.disabledDates.firstIndex(where: { calendar.isDate($0, inSameDayAs: date) }) - } - -}