Skip to content

Commit

Permalink
Merge pull request #5 from Aemi-Studio/240901-Interactive
Browse files Browse the repository at this point in the history
Upgrade to version 1.1.0
  • Loading branch information
g-cqd authored Sep 12, 2024
2 parents c525253 + 1ce3c60 commit 3d220f5
Show file tree
Hide file tree
Showing 30 changed files with 756 additions and 122 deletions.
72 changes: 62 additions & 10 deletions Cami.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"originHash" : "51f90653b2c9f9f7064c0d52159b40bf7d222e5f314be23e62fe28520fec03db",
"pins" : [
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
"revision" : "9bf03ff58ce34478e66aaee630e491823326fd06",
"version" : "1.1.3"
}
}
],
"version" : 2
"version" : 3
}
1 change: 1 addition & 0 deletions Cami/CamiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct CamiApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL(perform: Router.shared.handleURL)
.environment(model)
.environment(perms)
}
Expand Down
13 changes: 11 additions & 2 deletions Cami/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<key>NSCalendarsFullAccessUsageDescription</key>
<string>Cami ONLY uses your on-device calendar information to display events in widgets.
Cami DOES NOT edit or delete or send those information away.</string>
<key>NSContactsUsageDescription</key>
<string>Cami ONLY uses your on-device contact information to display birthdays in widgets.</string>
<key>NSRemindersFullAccessUsageDescription</key>
<string>Cami ONLY uses your on-device reminders information to display them in widgets and the application.
Cami DOES NOT edit or delete or send those information away.</string>
Expand All @@ -20,5 +18,16 @@ Cami DOES NOT edit or delete or send those information away.</string>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>camical</string>
</array>
</dict>
</array>
</dict>
</plist>
25 changes: 13 additions & 12 deletions Cami/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,31 @@ struct ContentView: View {
PermissionModel.shared.global == .restricted
}

@AppStorage("accessWorkInProgressFeatures")
@AppStorage(SettingsKeys.accessWorkInProgressFeatures)
private var accessWorkInProgressFeatures: Bool = false

var body: some View {

@Bindable var perms = perms
@Bindable var model = model

Group {
if accessWorkInProgressFeatures {
NavigationStack(path: $model.path) {
NavigationStack(path: $model.path) {

Group {
if accessWorkInProgressFeatures {
CalendarView(
areSettingsPresented: $areSettingsPresented
)
.navigationDestination(for: Day.self, destination: DayView.init)
.navigationDestination(for: EKEvent.self, destination: EventView.init)
} else {
OnboardingView(
areSettingsPresented: $areSettingsPresented,
areInformationsPresented: $areInformationsPresented
)
.frame(maxWidth: 720)
}
} else {
OnboardingView(
areSettingsPresented: $areSettingsPresented,
areInformationsPresented: $areInformationsPresented
)
.frame(maxWidth: 720)
}
.navigationDestination(for: Day.self, destination: DayView.init)
.navigationDestination(for: EKEvent.self, destination: EventView.init)
}
.onChange(of: scenePhase) { _, _ in
WidgetCenter.shared.reloadAllTimelines()
Expand Down
2 changes: 1 addition & 1 deletion Cami/View/OnboardingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct OnboardingView: View {
@Binding
var areInformationsPresented: Bool

@AppStorage("accessWorkInProgressFeatures")
@AppStorage(SettingsKeys.accessWorkInProgressFeatures)
private var accessWorkInProgressFeatures = false

private var authorized: Bool {
Expand Down
2 changes: 1 addition & 1 deletion Cami/View/Settings/PermissionAccessSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct PermissionAccessSection: View {
var restrictedDescription: String
var radius: Double = 12

@AppStorage("accessWorkInProgressFeatures")
@AppStorage(SettingsKeys.accessWorkInProgressFeatures)
private var accessWorkInProgressFeatures: Bool = false

private var consideringReminders: Bool {
Expand Down
2 changes: 1 addition & 1 deletion Cami/View/Settings/PermissionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct PermissionsView: View {
@State
private var conInfo: Bool = false

@AppStorage("accessWorkInProgressFeatures")
@AppStorage(SettingsKeys.accessWorkInProgressFeatures)
private var accessWorkInProgressFeatures = false

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion CamiWidget/CamiWidgetEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class CamiWidgetEntry: TimelineEntry {
inlineCalendars: (intent.inlineCalendars.map { $0.calendar }).asEKCalendars(),
events: CamiHelper.events(from: intent.calendars, relativeTo: date),
inlineEvents: CamiHelper.events(from: intent.inlineCalendars, where: { $0.isAllDay }, relativeTo: date),
birthdays: intent.displayBirthdays
birthdays: intent.cornerComplication == .birthdays
? CamiHelper.birthdays(from: date)
: []
)
Expand Down
11 changes: 11 additions & 0 deletions CamiWidget/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>camical</string>
</array>
</dict>
</array>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>Cami ONLY uses your on-device calendar information to display events in widgets.
Cami DOES NOT edit or delete or send those information away.</string>
Expand Down
6 changes: 3 additions & 3 deletions CamiWidget/Intents/CamiWidgetConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import Foundation
final class CamiWidgetConfiguration {

let allDayStyle: AllDayStyleEnum
let displayBirthdays: Bool
let cornerComplication: CornerComplicationEnum
let displayOngoingEvents: Bool
let groupEvents: Bool

init() {
self.allDayStyle = .event
self.displayBirthdays = true
self.cornerComplication = .birthdays
self.displayOngoingEvents = true
self.groupEvents = true
}

init(from intent: CamiWidgetIntent) {
self.allDayStyle = intent.allDayStyle
self.displayBirthdays = intent.displayBirthdays
self.cornerComplication = intent.cornerComplication
self.displayOngoingEvents = intent.displayOngoingEvents
self.groupEvents = intent.groupEvents
}
Expand Down
8 changes: 6 additions & 2 deletions CamiWidget/Intents/CamiWidgetIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ struct CamiWidgetIntent: WidgetConfigurationIntent {
@Parameter(title: "Group Similar Events", default: true)
var groupEvents: Bool

@Parameter(title: "Display Birthdays", default: true)
var displayBirthdays: Bool
@Parameter(
title: "Corner Complication",
default: .birthdays,
optionsProvider: CornerComplicationOptionsProvider()
)
var cornerComplication: CornerComplicationEnum

@Parameter(title: "Display Ongoing Events", default: true)
var displayOngoingEvents: Bool
Expand Down
35 changes: 35 additions & 0 deletions CamiWidget/Intents/Intents Parameters/CornerComplicationEnum.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// CornerComplicationEnum.swift
// Cami
//
// Created by Guillaume Coquard on 11/09/24.
//

import Foundation
import AppIntents

enum CornerComplicationEnum: String, CaseIterable, AppEnum {
typealias RawValue = String

case hidden = "Hidden"
case birthdays = "Birthdays"
case summary = "Summary"

static var typeDisplayRepresentation: TypeDisplayRepresentation = .init(stringLiteral: "Style")

static var caseDisplayRepresentations: [CornerComplicationEnum: DisplayRepresentation] = [
.hidden: .init(stringLiteral: "Hidden"),
.birthdays: .init(stringLiteral: "Birthdays"),
.summary: .init(stringLiteral: "Summary")
]

var title: String {
self.rawValue
}
}

struct CornerComplicationOptionsProvider: DynamicOptionsProvider {
func results() async throws -> [CornerComplicationEnum] {
CornerComplicationEnum.allCases
}
}
63 changes: 34 additions & 29 deletions CamiWidget/Views/Content/Events/CamiWidgetEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ struct CamiWidgetEvent: View {
@Environment(CamiWidgetEntry.self)
private var entry: CamiWidgetEntry

@AppStorage(SettingsKeys.openInCami)
private var openInPlace: Bool = UserDefaults.standard.bool(forKey: SettingsKeys.openInCami)

var event: (EKEvent, Events)

private var _event: EKEvent {
Expand All @@ -25,42 +28,44 @@ struct CamiWidgetEvent: View {

var body: some View {

HStack(alignment: .center) {
Link(destination: CamiHelper.destination(for: _event, inPlace: openInPlace)) {
HStack(alignment: .center) {

VStack(alignment: .leading) {
Text(_event.title)
.font(.caption)
.fontDesign(.rounded)
.fontWeight(.medium)
.lineLimit(1)
.foregroundStyle(Color(cgColor: _event.calendar.cgColor))
.accessibilityLabel("You have an event titled: \(_event.title).")
}
VStack(alignment: .leading) {
Text(_event.title)
.font(.caption)
.fontDesign(.rounded)
.fontWeight(.medium)
.lineLimit(1)
.foregroundStyle(Color(cgColor: _event.calendar.cgColor))
.accessibilityLabel("You have an event titled: \(_event.title).")
}

Spacer(minLength: 8)
Spacer(minLength: 8)

if !_event.isAllDay || entry.config.displayOngoingEvents && _event.spansMore(than: entry.date) {
VStack(alignment: .trailing, spacing: 1) {
Group {
ForEach(_other, id: \.self) { otherEvent in
RemainingTimeComponent(
from: otherEvent.startDate,
to: otherEvent.endDate,
accuracy: otherEvent.spansMore(than: entry.date)
? [.day, .hour]
: [.day, .hour, .minute]
)
.font(.caption)
.foregroundStyle(Color(cgColor: otherEvent.calendar.cgColor))
if !_event.isAllDay || entry.config.displayOngoingEvents && _event.spansMore(than: entry.date) {
VStack(alignment: .trailing, spacing: 1) {
Group {
ForEach(_other, id: \.self) { otherEvent in
RemainingTimeComponent(
from: otherEvent.startDate,
to: otherEvent.endDate,
accuracy: otherEvent.spansMore(than: entry.date)
? [.day, .hour]
: [.day, .hour, .minute]
)
.font(.caption)
.foregroundStyle(Color(cgColor: otherEvent.calendar.cgColor))
}
}
.accessibilityLabel(
_other.count > 1
? "This event happens \(_other.count) times in your day." : "")
}
.accessibilityLabel(
_other.count > 1
? "This event happens \(_other.count) times in your day." : "")
}
}

}
.roundedBorder( _event.calendar.cgColor, bordered: entry.config.allDayStyle == .bordered && _event.isAllDay )
}
.roundedBorder( _event.calendar.cgColor, bordered: entry.config.allDayStyle == .bordered && _event.isAllDay )
}
}
7 changes: 5 additions & 2 deletions CamiWidget/Views/Content/Events/CamiWidgetEventsByDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ struct CamiWidgetEventsByDate: View {
HStack {
Group {
if ongoingEvents {
Text("Ongoing Events")
Text(
NSLocalizedString("ongoingEvents.Title", comment: "")
)
} else if isUpToTomorrow {
Text(date.formattedUntilTomorrow)
.accessibilityLabel(
"Events for \(date.formattedUntilTomorrow)"
)
} else {
Group {
Text(date.formattedAfterTomorrow) +
Text(date.formattedAfterTomorrow.capitalized(with: .prefered)) +
Text("") +
Text(date.relativeToNow)
}
Expand All @@ -80,6 +82,7 @@ struct CamiWidgetEventsByDate: View {
.fontWeight(.medium)
.foregroundStyle(.white.opacity(0.25))
.lineLimit(1)

Spacer()
if !ongoingEvents && inlineEvents.count > 0 {
HStack {
Expand Down
23 changes: 13 additions & 10 deletions CamiWidget/Views/Header/CamiWidgetHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ struct CamiWidgetHeader: View {
@Environment(CamiWidgetEntry.self)
private var entry: CamiWidgetEntry

@AppStorage(SettingsKeys.openInCami)
private var openInPlace: Bool = UserDefaults.standard.bool(forKey: SettingsKeys.openInCami)

var body: some View {

@Bindable var entry = entry

HStack(spacing: 0) {

CamiWidgetHeaderDate()
.accessibilityLabel("Today's date is " + entry.date.formatter {
$0.dateStyle = .full
$0.timeStyle = .none
$0.formattingContext = .standalone
})
Link(destination: CamiHelper.destination(for: entry.date, inPlace: openInPlace)) {
CamiWidgetHeaderDate()
.accessibilityLabel("Today's date is " + entry.date.formatter {
$0.dateStyle = .full
$0.timeStyle = .none
$0.formattingContext = .standalone
})
}

Spacer()

if entry.config.displayBirthdays && !entry.birthdays.isEmpty {
CamiWidgetHeaderBirthdays()
}
CamiWidgetHeaderCornerComplication()
}
.padding(.init(top: 4, leading: 8, bottom: 4, trailing: 4))
.padding(.init(top: 4, leading: 8, bottom: 4, trailing: 5))
.background(.black.opacity(0.2))
.rounded([ .all: .init( top: 16, bottom: 8 ) ])
.lineLimit(1)
Expand Down
Loading

0 comments on commit 3d220f5

Please sign in to comment.