-
Notifications
You must be signed in to change notification settings - Fork 132
Refactors calendar view layout and initialization #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updates the calendar view to use autolayout for flexible size adjustments. The initializer is simplified and the frame is not directly set, allowing autolayout to handle sizing. The timeline view is also updated to use safe area layout guide for bottom constraint.
Removes the SwiftUI example implementation from the project. The example is no longer needed or maintained, and its removal simplifies the project structure. Updates the default selected controller in SceneDelegate. Updates event dates in example json.
Renames ViewController to KVKCalendarVC and adjusts associated files, including the project file and scene delegate, to streamline the example app structure and improve clarity. Updates the example app to initialize the calendar view controller with a flag indicating whether it's being presented from SwiftUI, and adjusts UI setup accordingly. Improves data fetching by implementing async loading of events with an optional delay and updates the UI on the main actor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the calendar view layout and initialization to leverage Auto Layout and safe area guides while simplifying initializer usage for improved flexibility. Key changes include updating content size calculation and constraints in TimelineView, streamlining convenience initializers in KVKCalendarView, and revising SwiftUI example integration.
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/KVKCalendar/TimelineView.swift | Replaces manual height calculation with a bottom offset and updates content size calculation for Auto Layout. |
| Sources/KVKCalendar/Timeline+Extension.swift | Changes bottom constraint to use safeAreaLayoutGuide for improved UI adaptation. |
| Sources/KVKCalendar/KVKCalendarView.swift | Simplifies initializer signatures; adopts default .zero frames and updates layoutIfNeeded override. |
| Sources/KVKCalendar/KVKCalendarView+Extension.swift | Updates left/right constraints to leading/trailing for better i18n support. |
| Sources/KVKCalendar/DayPadCell.swift | Adjusts the horizontal positioning of the date view from 50% to 52% of the frame’s width. |
| Sources/KVKCalendar/DayCell.swift | Modifies the default height for date display from 35 to 30. |
| Sources/KVKCalendar/Calendar+Extension.swift | Simplifies platform interface logic by directly returning the current device. |
| README.md | Updates SwiftUI usage examples and renames classes to reflect the refactored implementation. |
| Example files (SceneDelegate, KVKCalendarVC, etc.) | Update root view controllers, event dates, and project configurations to match the new calendar view structure. |
| Example project configurations | Updates Xcode schemes and project settings to align with new version numbers and identifiers. |
Files not reviewed (1)
- Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/KVKCalendar.xcscheme: Language not supported
Comments suppressed due to low confidence (1)
Sources/KVKCalendar/KVKCalendarSettings.swift:85
- Ensure that all callers of this asynchronous loadEvents function are updated to handle the new async/await pattern, replacing the previous callback approach.
func loadEvents(dateFormat: String, withDelay: Bool = true) async -> [Event] {
This commit introduces a `ScrollWeekView` implemented in SwiftUI. The `ScrollWeekView` provides a scrollable week calendar view, allowing users to navigate through different weeks. It uses `ScrollableWeekView` internally and provides a SwiftUI-compatible wrapper for easy integration.
Refactors code for better performance and responsiveness, especially on iPad devices. Adds `@MainActor` to several methods and properties to ensure UI updates are performed on the main thread, preventing potential concurrency issues. Updates ScrollableWeekView to accept an optional style to allow for more flexibility in how the view is configured. Modifies `loadEvents` to accept a `Style` object instead of a date format string, using the style's time format to load events. Fixes a layout issue in SwiftUI where the calendar view was not properly ignoring safe area insets.
Removes device-specific font variations for year view week and day titles. This change simplifies the style configuration by using a single font property for both week and day titles in the year view, instead of having separate fonts for iPad and iPhone. It removes the platform check and consolidates the font definitions, leading to cleaner and more maintainable code. Also the minimum scale factor is changed from 0.6 to 0.3 in WeekHeaderView. Updates the project configuration.
Allows the calendar view to be initialized and updated with a frame when not using auto layout. This change ensures correct layout behavior in environments where auto layout is not preferred or available.
Updates the calendar view to use autolayout for flexible size adjustments. The initializer is simplified and the frame is not directly set, allowing autolayout to handle sizing. The timeline view is also updated to use safe area layout guide for bottom constraint.