Skip to content

Commit

Permalink
2.3.4
Browse files Browse the repository at this point in the history
Interactive Widget
  • Loading branch information
ZzzM committed Jan 10, 2024
1 parent 43e3070 commit 8bc7f48
Show file tree
Hide file tree
Showing 50 changed files with 734 additions and 353 deletions.
56 changes: 33 additions & 23 deletions CalendarX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions CalendarX/Assets.xcassets/GitHub.imageset/Contents.json

This file was deleted.

1 change: 0 additions & 1 deletion CalendarX/Assets.xcassets/GitHub.imageset/GitHub.svg

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion CalendarX/Component/ScacleButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ struct ScacleImageButton: View {
}

var body: some View {
ScacleButton(action: action, label: { image.font(.title3).appForeground(color) })
ScacleButton(action: action) {
image
.font(.title3)
.appForeground(color)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion CalendarX/Model/CalendarPreference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ struct CalendarPreference {

@AppStorage(CalendarStorageKey.showHolidays, store: .group)
var showHolidays: Bool = true


@AppStorage(CalendarStorageKey.keyboardShortcut, store: .group)
var keyboardShortcut: Bool = true
}

extension CalendarPreference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct CalendarXApp: App {

class CalendarXDelegate: NSObject & NSApplicationDelegate {

lazy var rootView = RootView()
lazy var rootView = CalendarXView()
lazy var popover = MenubarPopover(rootView)
lazy var controller = MenubarController(popover)

Expand All @@ -43,7 +43,7 @@ class CalendarXDelegate: NSObject & NSApplicationDelegate {
.forEach { $0.terminate() }

}

func applicationDidFinishLaunching(_ notification: Notification) {
_ = controller
}
Expand Down
59 changes: 59 additions & 0 deletions CalendarX/Module/CalendarXView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import SwiftUI
import CalendarXShared

struct CalendarXView: View {

@StateObject
private var router = Router.shared

@StateObject
private var alertVM = AlertViewModel.shared

@StateObject
private var settingsVM = SettingsViewModel()


private let mainVM = MainViewModel()

var body: some View {

ZStack {
Color.appBackground.padding(.top, -15)
rootView
detailView
AlertView(viewModel: alertVM)
}
.appForeground(.appPrimary)
.environment(\.locale, settingsVM.locale)
.envTint(settingsVM.color)
.envColorScheme(settingsVM.colorScheme)
.onChange(of: settingsVM.locale, notification: NSLocale.currentLocaleDidChangeNotification)

}

@ViewBuilder
private var rootView: some View {
switch router.root {
case .calendar: MainView(viewModel: mainVM)
case .settings: SettingsView(viewModel: settingsVM)
case .unknown: EmptyView()
}
}


@ViewBuilder
private var detailView: some View {
switch router.path {
case .date(let appDate): DateView(appDate: appDate).fullScreenCover()
case .recommendations: RecommendationsView().fullScreenCover()
case .menubarSettings: MenubarSettingsView().fullScreenCover()
case .appearanceSettings: AppearanceSettingsView(viewModel: settingsVM).fullScreenCover()
case .calendarSettings: CalendarSettingsView().fullScreenCover()
case .about: AboutView().fullScreenCover()
default: EmptyView()
}
}


}

27 changes: 17 additions & 10 deletions CalendarX/Module/Calender/AlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,32 @@ import Combine
struct AlertView: View {

@ObservedObject
var alert: AlertAction
var viewModel: AlertViewModel

var body: some View {


ZStack(alignment: .bottom) {

Color.black
.opacity(alert.isPresented ? 0.5: 0)
.onTapGesture(perform: alert.dismiss)

.opacity(viewModel.isPresented ? 0.5: 0)
.onTapGesture(perform: viewModel.dismiss)

if alert.isPresented {
if viewModel.isPresented {
VStack {

alert.image.font(.largeTitle).appForeground(.accentColor)
Text(alert.message).font(.title3).multilineTextAlignment(.center).padding(.vertical, 5)
viewModel.image.font(.largeTitle).appForeground(.accentColor)

if let message = viewModel.message {
Text(message).font(.title3).multilineTextAlignment(.center).padding(.vertical, 5)
}

if let yes = viewModel.yes {
ScacleCapsuleButton(title: yes, foregroundColor: .white, backgroundColor: .accentColor, action: viewModel.action)
}

ScacleCapsuleButton(title: alert.yes, foregroundColor: .white, backgroundColor: .accentColor, action: alert.action)
ScacleCapsuleButton(title: alert.no, foregroundColor: .white, backgroundColor: .appSecondary, action: alert.dismiss)
if let no = viewModel.no {
ScacleCapsuleButton(title: no, foregroundColor: .white, backgroundColor: .appSecondary, action: viewModel.dismiss)
}

}
.padding()
Expand All @@ -39,5 +45,6 @@ struct AlertView: View {
.padding()
}
}
.zIndex(1)
}
}
1 change: 1 addition & 0 deletions CalendarX/Module/Calender/DateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct DateView: View {
FestivalsView(festivals: appDate.festivals)
EventsView(events: appDate.events, showEvents: showEvents)
}
.padding()
}


Expand Down
35 changes: 20 additions & 15 deletions CalendarX/Module/Calender/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct MainView: View {
dayView: dayView)
.equatable()
.frame(height: .mainHeight)

.padding()
}

private func header() -> some View {
Expand All @@ -32,22 +32,27 @@ struct MainView: View {
MonthYearPicker(date: $viewModel.date, colorScheme: viewModel.colorScheme, tint: viewModel.tint)

Spacer()


if viewModel.keyboardShortcut {
Group {
Button(action: viewModel.lastMonth) { }.keyboardShortcut(.leftArrow, modifiers: [])
Button(action: viewModel.reset) {}.keyboardShortcut(.space, modifiers: [])
Button(action: viewModel.nextMonth) {}.keyboardShortcut(.rightArrow, modifiers: [])
Button(action: viewModel.lastYear) {}.keyboardShortcut(.upArrow, modifiers: [])
Button(action: viewModel.nextYear) {}.keyboardShortcut(.downArrow, modifiers: [])
}
.buttonStyle(.borderless)
}


Group {
Button(action: viewModel.lastMonth) {}.keyboardShortcut(.leftArrow, modifiers: [])
Button(action: viewModel.reset) {}.keyboardShortcut(.space, modifiers: [])
Button(action: viewModel.nextMonth) {}.keyboardShortcut(.rightArrow, modifiers: [])
Button(action: viewModel.lastYear) {}.keyboardShortcut(.upArrow, modifiers: [])
Button(action: viewModel.nextYear) {}.keyboardShortcut(.downArrow, modifiers: [])
ScacleImageButton(image: .leftArrow, action: viewModel.lastMonth)
ScacleImageButton(image: .circle, action: viewModel.reset)
ScacleImageButton(image: .rightArrow, action: viewModel.nextMonth)
}
.frame(maxWidth: 1)
.opacity(.zero)

ScacleImageButton(image: .leftArrow, action: viewModel.lastMonth)
.frame(width: .buttonWidth)
ScacleImageButton(image: .circle, action: viewModel.reset)
.frame(width: .buttonWidth)
ScacleImageButton(image: .rightArrow, action: viewModel.nextMonth)
.frame(width: .buttonWidth)
.frame(width: .buttonWidth)


}

Expand Down
3 changes: 1 addition & 2 deletions CalendarX/Module/MenuBar/MenuBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ extension MenubarController {

private func showPopover(_ sender: Any?) {
guard let event = NSApp.currentEvent else { return }

Router.to(event.isRightClicked)
Router.set(event.isRightClicked ? .settings: .calendar)
popover.show(sender)
monitor.start()
}
Expand Down
18 changes: 10 additions & 8 deletions CalendarX/Module/MenuBar/MenubarItemController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ extension MenubarItemController {
extension MenubarItemController {
private var icon: NSImage? { style == .default ? calendarIcon : .none }
private var title: NSAttributedString {
var attributes: [NSAttributedString.Key : Any] = [.font: NSFont.statusItem], title = ""
if style == .default {
attributes[.baselineOffset] = -1
attributes[.font] = NSFont.statusIcon
title = Date().day.description
} else if style == .text {
title = pref.text

let title = switch style {
case .default: Date().day.description
case .text: pref.text
case .date: pref.dateItemTitle
}

let attributes: [NSAttributedString.Key : Any] = if style == .default {
[.font: NSFont.statusIcon, .baselineOffset: -1]
} else {
title = pref.dateItemTitle
[.font: NSFont.statusItem]
}
return NSAttributedString(string: title, attributes: attributes)
}
Expand Down
2 changes: 2 additions & 0 deletions CalendarX/Module/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ struct AboutView: View {

}
.frame(height: .mainHeight, alignment: .top)
.padding()

}
}
3 changes: 2 additions & 1 deletion CalendarX/Module/Settings/AppearanceSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct AppearanceSettingsView: View {

}
.frame(maxHeight: .infinity, alignment: .top)

.padding()

}

}
Expand Down
21 changes: 17 additions & 4 deletions CalendarX/Module/Settings/CalendarSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct CalendarSettingsView: View {

@StateObject
private var viewModel = CalendarViewModel()

var body: some View {
VStack(spacing: 20) {

Expand All @@ -26,17 +26,18 @@ struct CalendarSettingsView: View {
EmptyView()
}



Section {
weekRow
eventsRow
lunarRow
holidaysRow
keyboardShortcutRow
}

}
.frame(maxHeight: .infinity, alignment: .top)
.padding()

}
}

Expand All @@ -50,7 +51,10 @@ extension CalendarSettingsView {

@ViewBuilder
private var eventsRow: some View {
let isOn = Binding(get: viewModel.getEventStatut, set: viewModel.setEventStatut)
let isOn = Binding(
get: viewModel.getEventStatut,
set: viewModel.setEventStatut
)
Toggle(isOn: isOn) { Text(L10n.Calendar.showEvents).font(.title3) }
.checkboxStyle()

Expand All @@ -66,6 +70,15 @@ extension CalendarSettingsView {
.checkboxStyle()
}

private var keyboardShortcutRow: some View {
Toggle(isOn: $viewModel.keyboardShortcut) {
HStack {
Text(L10n.Calendar.keyboardShortcut).font(.title3)
ScacleImageButton(image: .tips, action: AlertViewModel.keyboardShortcut)
}
}
.checkboxStyle()
}
}


Expand Down
3 changes: 2 additions & 1 deletion CalendarX/Module/Settings/MenuBarSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct MenubarSettingsView: View {

}
.focusable(false)

.padding()

}


Expand Down

0 comments on commit 8bc7f48

Please sign in to comment.