Skip to content

Commit 8bc7f48

Browse files
committed
2.3.4
Interactive Widget
1 parent 43e3070 commit 8bc7f48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+734
-353
lines changed

CalendarX.xcodeproj/project.pbxproj

Lines changed: 33 additions & 23 deletions
Large diffs are not rendered by default.

CalendarX/Assets.xcassets/GitHub.imageset/Contents.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

CalendarX/Assets.xcassets/GitHub.imageset/GitHub.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
-29 KB
Loading
-21.5 KB
Loading

CalendarX/Component/ScacleButton.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ struct ScacleImageButton: View {
3131
}
3232

3333
var body: some View {
34-
ScacleButton(action: action, label: { image.font(.title3).appForeground(color) })
34+
ScacleButton(action: action) {
35+
image
36+
.font(.title3)
37+
.appForeground(color)
38+
}
3539
}
3640
}
3741

CalendarX/Model/CalendarPreference.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ struct CalendarPreference {
2424

2525
@AppStorage(CalendarStorageKey.showHolidays, store: .group)
2626
var showHolidays: Bool = true
27-
27+
28+
@AppStorage(CalendarStorageKey.keyboardShortcut, store: .group)
29+
var keyboardShortcut: Bool = true
2830
}
2931

3032
extension CalendarPreference {

CalendarX/CalendarXApp.swift renamed to CalendarX/Module/CalendarXApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct CalendarXApp: App {
3131

3232
class CalendarXDelegate: NSObject & NSApplicationDelegate {
3333

34-
lazy var rootView = RootView()
34+
lazy var rootView = CalendarXView()
3535
lazy var popover = MenubarPopover(rootView)
3636
lazy var controller = MenubarController(popover)
3737

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

4545
}
46-
46+
4747
func applicationDidFinishLaunching(_ notification: Notification) {
4848
_ = controller
4949
}

CalendarX/Module/CalendarXView.swift

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import SwiftUI
2+
import CalendarXShared
3+
4+
struct CalendarXView: View {
5+
6+
@StateObject
7+
private var router = Router.shared
8+
9+
@StateObject
10+
private var alertVM = AlertViewModel.shared
11+
12+
@StateObject
13+
private var settingsVM = SettingsViewModel()
14+
15+
16+
private let mainVM = MainViewModel()
17+
18+
var body: some View {
19+
20+
ZStack {
21+
Color.appBackground.padding(.top, -15)
22+
rootView
23+
detailView
24+
AlertView(viewModel: alertVM)
25+
}
26+
.appForeground(.appPrimary)
27+
.environment(\.locale, settingsVM.locale)
28+
.envTint(settingsVM.color)
29+
.envColorScheme(settingsVM.colorScheme)
30+
.onChange(of: settingsVM.locale, notification: NSLocale.currentLocaleDidChangeNotification)
31+
32+
}
33+
34+
@ViewBuilder
35+
private var rootView: some View {
36+
switch router.root {
37+
case .calendar: MainView(viewModel: mainVM)
38+
case .settings: SettingsView(viewModel: settingsVM)
39+
case .unknown: EmptyView()
40+
}
41+
}
42+
43+
44+
@ViewBuilder
45+
private var detailView: some View {
46+
switch router.path {
47+
case .date(let appDate): DateView(appDate: appDate).fullScreenCover()
48+
case .recommendations: RecommendationsView().fullScreenCover()
49+
case .menubarSettings: MenubarSettingsView().fullScreenCover()
50+
case .appearanceSettings: AppearanceSettingsView(viewModel: settingsVM).fullScreenCover()
51+
case .calendarSettings: CalendarSettingsView().fullScreenCover()
52+
case .about: AboutView().fullScreenCover()
53+
default: EmptyView()
54+
}
55+
}
56+
57+
58+
}
59+

CalendarX/Module/Calender/AlertView.swift

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,32 @@ import Combine
1111
struct AlertView: View {
1212

1313
@ObservedObject
14-
var alert: AlertAction
14+
var viewModel: AlertViewModel
1515

1616
var body: some View {
1717

18-
1918
ZStack(alignment: .bottom) {
2019

2120
Color.black
22-
.opacity(alert.isPresented ? 0.5: 0)
23-
.onTapGesture(perform: alert.dismiss)
24-
21+
.opacity(viewModel.isPresented ? 0.5: 0)
22+
.onTapGesture(perform: viewModel.dismiss)
2523

26-
if alert.isPresented {
24+
if viewModel.isPresented {
2725
VStack {
2826

29-
alert.image.font(.largeTitle).appForeground(.accentColor)
30-
Text(alert.message).font(.title3).multilineTextAlignment(.center).padding(.vertical, 5)
27+
viewModel.image.font(.largeTitle).appForeground(.accentColor)
28+
29+
if let message = viewModel.message {
30+
Text(message).font(.title3).multilineTextAlignment(.center).padding(.vertical, 5)
31+
}
32+
33+
if let yes = viewModel.yes {
34+
ScacleCapsuleButton(title: yes, foregroundColor: .white, backgroundColor: .accentColor, action: viewModel.action)
35+
}
3136

32-
ScacleCapsuleButton(title: alert.yes, foregroundColor: .white, backgroundColor: .accentColor, action: alert.action)
33-
ScacleCapsuleButton(title: alert.no, foregroundColor: .white, backgroundColor: .appSecondary, action: alert.dismiss)
37+
if let no = viewModel.no {
38+
ScacleCapsuleButton(title: no, foregroundColor: .white, backgroundColor: .appSecondary, action: viewModel.dismiss)
39+
}
3440

3541
}
3642
.padding()
@@ -39,5 +45,6 @@ struct AlertView: View {
3945
.padding()
4046
}
4147
}
48+
.zIndex(1)
4249
}
4350
}

0 commit comments

Comments
 (0)