-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from kvyatkovskys/feature/v_0.6.12
Bugs fixes and improvements ver. 0.6.12
- Loading branch information
Showing
46 changed files
with
1,334 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// ContentView.swift | ||
// KVKCalendar_Example | ||
// | ||
// Created by Sergei Kviatkovskii on 4/16/22. | ||
// Copyright © 2022 CocoaPods. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import KVKCalendar | ||
|
||
@available(iOS 14.0, *) | ||
struct CalendarView: View { | ||
|
||
@State private var typeCalendar = CalendarType.day | ||
@State private var events: [Event] = [] | ||
@State private var updatedDate: Date? | ||
@State private var orientation: UIInterfaceOrientation = .unknown | ||
@ObservedObject private var viewModel = CalendarViewModel() | ||
|
||
var body: some View { | ||
kvkHandleNavigationView(calendarView) | ||
} | ||
|
||
private var calendarView: some View { | ||
CalendarViewDisplayable(events: $events, | ||
type: $typeCalendar, | ||
updatedDate: $updatedDate, | ||
orientation: $orientation) | ||
.kvkOnRotate(action: { (newOrientation) in | ||
orientation = newOrientation | ||
}) | ||
.onAppear { | ||
viewModel.loadEvents { (items) in | ||
events = items | ||
} | ||
} | ||
.navigationBarTitle("KVKCalendar", displayMode: .inline) | ||
.edgesIgnoringSafeArea(.bottom) | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarLeading) { | ||
HStack { | ||
ItemsMenu<CalendarType>(type: $typeCalendar, | ||
items: CalendarType.allCases, | ||
showCheckmark: true, | ||
showDropDownIcon: true) | ||
|
||
Button { | ||
updatedDate = Date() | ||
} label: { | ||
Text("Today") | ||
.font(.headline) | ||
.foregroundColor(.red) | ||
} | ||
} | ||
} | ||
ToolbarItem(placement: .navigationBarTrailing) { | ||
Button { | ||
if let event = viewModel.addNewEvent() { | ||
events.append(event) | ||
} | ||
} label: { | ||
Image(systemName: "plus") | ||
.foregroundColor(.red) | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
@available(iOS 14.0, *) | ||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
CalendarView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// CalendarViewModel.swift | ||
// KVKCalendar | ||
// | ||
// Created by Sergei Kviatkovskii on 11/17/22. | ||
// Copyright © 2022 CocoaPods. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import KVKCalendar | ||
|
||
final class CalendarViewModel: ObservableObject, KVKCalendarSettings, KVKCalendarDataModel { | ||
|
||
// 🤔👹🍻😬🥸 | ||
// only for example | ||
var events: [Event] = [] | ||
|
||
var style: KVKCalendar.Style { | ||
createCalendarStyle() | ||
} | ||
|
||
func loadEvents(completion: @escaping ([Event]) -> Void) { | ||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 3) { | ||
self.loadEvents(dateFormat: self.style.timeSystem.format, completion: completion) | ||
} | ||
} | ||
|
||
func addNewEvent() -> Event? { | ||
handleNewEvent(Event(ID: "-1"), date: Date()) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.