Skip to content

Commit

Permalink
2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zm committed Nov 3, 2022
1 parent 6dbe938 commit 2f91f84
Show file tree
Hide file tree
Showing 46 changed files with 438 additions and 101 deletions.
20 changes: 18 additions & 2 deletions CalendarX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
98BE991827A0F75900306061 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BE991727A0F75900306061 /* MainView.swift */; };
98BE991C27A1397500306061 /* Calendar+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BE991B27A1397500306061 /* Calendar+.swift */; };
98BE991E27A1415F00306061 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BE991D27A1415F00306061 /* SettingsView.swift */; };
98C9BD0A290999F600F645AD /* MenuBarSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C9BD09290999F600F645AD /* MenuBarSettingsView.swift */; };
98CE8BDB27BBAA93009E5674 /* tiaoxiu.json in Resources */ = {isa = PBXBuildFile; fileRef = 98CE8BDA27BBAA93009E5674 /* tiaoxiu.json */; };
98CE8BE027BDEF1D009E5674 /* chuxi.json in Resources */ = {isa = PBXBuildFile; fileRef = 98CE8BDF27BDEF1D009E5674 /* chuxi.json */; };
98CE8BE427BDFA12009E5674 /* terms.json in Resources */ = {isa = PBXBuildFile; fileRef = 98CE8BE327BDFA12009E5674 /* terms.json */; };
Expand Down Expand Up @@ -78,6 +79,7 @@
98BE991727A0F75900306061 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
98BE991B27A1397500306061 /* Calendar+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+.swift"; sourceTree = "<group>"; };
98BE991D27A1415F00306061 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
98C9BD09290999F600F645AD /* MenuBarSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarSettingsView.swift; sourceTree = "<group>"; };
98CE8BDA27BBAA93009E5674 /* tiaoxiu.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = tiaoxiu.json; sourceTree = "<group>"; };
98CE8BDF27BDEF1D009E5674 /* chuxi.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = chuxi.json; sourceTree = "<group>"; };
98CE8BE327BDFA12009E5674 /* terms.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = terms.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,7 +142,6 @@
98BE991527A0F6AB00306061 /* RootView.swift */,
98BE991727A0F75900306061 /* MainView.swift */,
98ED365427A288E500AF578A /* DateView.swift */,
98BE991D27A1415F00306061 /* SettingsView.swift */,
);
path = Calender;
sourceTree = "<group>";
Expand Down Expand Up @@ -171,6 +172,15 @@
path = Model;
sourceTree = "<group>";
};
98C9BD0B29099A2C00F645AD /* Settings */ = {
isa = PBXGroup;
children = (
98BE991D27A1415F00306061 /* SettingsView.swift */,
98C9BD09290999F600F645AD /* MenuBarSettingsView.swift */,
);
path = Settings;
sourceTree = "<group>";
};
98CE8BDC27BBABF2009E5674 /* Resource */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -203,6 +213,7 @@
isa = PBXGroup;
children = (
988A82CB279F8674000899B5 /* Calender */,
98C9BD0B29099A2C00F645AD /* Settings */,
98D2479227842CC500F2B278 /* MenuBar */,
);
path = Module;
Expand Down Expand Up @@ -308,7 +319,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1330;
LastUpgradeCheck = 1330;
LastUpgradeCheck = 1400;
TargetAttributes = {
98D573CD27571EB3001C2D8C = {
CreatedOnToolsVersion = 13.1;
Expand Down Expand Up @@ -397,6 +408,7 @@
982DABC627C33343002891A3 /* Bundle+.swift in Sources */,
98F4347727A24297009F18CC /* ScacleButton.swift in Sources */,
98BE991E27A1415F00306061 /* SettingsView.swift in Sources */,
98C9BD0A290999F600F645AD /* MenuBarSettingsView.swift in Sources */,
982DABC427C332E1002891A3 /* Date+.swift in Sources */,
98ED367427BB468700AF578A /* XDay.swift in Sources */,
988A82DE279FEC9D000899B5 /* Language.swift in Sources */,
Expand Down Expand Up @@ -481,6 +493,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -543,6 +556,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -573,6 +587,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"CalendarX/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -604,6 +619,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"CalendarX/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down
1 change: 0 additions & 1 deletion CalendarX/Component/RotationArrow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ struct RotationArrow: View {
var isPresented: Bool
var body: some View {
Image.rightArrow
.imageScale(.small)
.foregroundColor(.secondary)
.rotationEffect(.degrees(isPresented ? 90 : 0))
.animation(.spring(), value: isPresented)
Expand Down
3 changes: 1 addition & 2 deletions CalendarX/Component/ScacleButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ struct ScacleTagButton: View {
var body: some View {
ScacleButton(action: action) {
Text(title)
.font(.subheadline)
.padding(.horizontal, 5)
.padding(.vertical, 3)
.padding(.vertical, 5)
.background(Color.accentColor.opacity(0.1))
.foregroundColor(.accentColor)
.clipShape(Capsule())
Expand Down
7 changes: 5 additions & 2 deletions CalendarX/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ enum AppStorageKey {
static let weekday = "\(AppInfo.name).storageKey.weekday"
static let showSchedule = "\(AppInfo.name).storageKey.showSchedule"
static let menuBarStyle = "\(AppInfo.name).storageKey.menuBarStyle"
static let menuBarText = "\(AppInfo.name).storageKey.menuBarText"
static let menuBarDateFormat = "\(AppInfo.name).storageKey.menuBarDateFormat"
}

extension NSImage {

static let menubarIcon = NSImage(named: "MenubarIcon")

}
Expand All @@ -55,6 +57,7 @@ extension Image {
static let rightArrow = Image(systemName: "chevron.right")
static let circle = Image(systemName: "circle")
static let link = Image(systemName: "link")
static let calendar = Image(nsImage: .menubarIcon!)
}


Expand All @@ -72,7 +75,7 @@ extension Locale {

extension Color {

static let background = Color(light: "F5F7FA", dark: "323133")
static let background = Color(light: "F7F7F7", dark: "2B2D2E")
static let workdayBackground = Color(light: "E6E9ED", dark: "3C3B3D")

static let primary = Color(light: "323133", dark: "F5F7FA")
Expand Down
3 changes: 1 addition & 2 deletions CalendarX/Extension/AppKit+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ extension NSStatusBarButton {
if let _image = image {
_image.size = .init(width: 16, height: 16)
_image.isTemplate = true
self.attributedTitle = NSAttributedString(string: title, attributes: [.baselineOffset: -1,
.font: NSFont.systemFont(ofSize: 8.5)])
self.attributedTitle = NSAttributedString(string: title, attributes: [.baselineOffset: -1,.font: NSFont.systemFont(ofSize: 8.5)])
} else {
self.title = title
}
Expand Down
27 changes: 21 additions & 6 deletions CalendarX/Extension/Date+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ extension Date {
Calendar.gregorian.component(.day, from: self)
}

var yesterday: Date {
adding(component: .day, value: -1)
}

var tomorrow: Date {
adding(component: .day, value: 1)
}


mutating func lastMonth() {
added(component: .month, value: -1)
}
Expand All @@ -96,23 +105,29 @@ extension Date {
return Calendar.gregorian.date(from: components) ?? self
}

func endOfMonth() -> Date {
Calendar.gregorian.date(byAdding: DateComponents(month: 1, day: -1), to: startOfMonth) ?? self
}


var nextMinute: Date {
var after1min: Date {
var components = Calendar.gregorian.dateComponents([.year, .month, .day, .hour, .minute], from: self)
components.minute! += 1
return Calendar.gregorian.date(from: components) ?? self
}

var after2sec: Date {
var components = Calendar.gregorian.dateComponents([.year, .month, .day, .hour, .minute, .second], from: self)
components.second! += 2
return Calendar.gregorian.date(from: components) ?? self
}

private func adding(_ calendar: Calendar = .gregorian, component: Calendar.Component, value: Int) -> Date {
calendar.date(byAdding: component, value: value, to: self) ?? self
}

private mutating func added(_ calendar: Calendar = .gregorian, component: Calendar.Component, value: Int) {
if let date = calendar.date(byAdding: component, value: value, to: self) {
self = date
}
}


}

extension Date {
Expand Down
5 changes: 3 additions & 2 deletions CalendarX/Extension/View+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ struct CheckboxStyle: ToggleStyle {

ZStack {
Capsule()
.frame(width: 30, height: 15)
.frame(width: 35, height: 20)
.foregroundColor(configuration.isOn ? .accentColor : .secondary)
Circle()
.square(8)
.square(10)
.foregroundColor(.white)
.offset(x: configuration.isOn ? offsetX : -offsetX)
}
Expand Down Expand Up @@ -118,6 +118,7 @@ extension View {
onChange(of: value) { _ in
NotificationCenter.default.post(name: name, object: .none)
}

}

func xTint(_ tint: Color) -> some View {
Expand Down
1 change: 1 addition & 0 deletions CalendarX/Model/AppInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct AppInfo {
Bundle.main.infoDictionary?[key.rawValue] as? String ?? "none"
}

static let dateFormat = "yyyy-MM-dd HH:mm:ss"
static let name = Self[.name]
static let version = Self[.version]
static let commitHash = Self[.commitHash]
Expand Down
17 changes: 14 additions & 3 deletions CalendarX/Model/MenuBarStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@
import SwiftUI

enum MenuBarStyle: String, CaseIterable {
case style1, style2, style3, style4, `default`
// 2.2.0 or earlier
// case style1, style2, style3, style4,

// 2.2.1 or later
case `default`, text, date

var title: LocalizedStringKey {
isDefault ? L10n.MenubarStyle.default:
L10n.statusBarTitle(style: self).l10nKey

switch self {
case .text: return L10n.MenubarStyle.text
case .date: return L10n.MenubarStyle.date
default: return L10n.MenubarStyle.default
}
// isDefault ? L10n.MenubarStyle.default:
// L10n.statusBarTitle(style: self).l10nKey
}

var isDefault: Bool { self == .default }
var isDate: Bool { self == .date }
}
1 change: 1 addition & 0 deletions CalendarX/Model/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import SwiftUI

enum Theme: String, CaseIterable {

case system, light, dark

var colorScheme: ColorScheme? {
Expand Down
1 change: 1 addition & 0 deletions CalendarX/Model/XDay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct XDay: Identifiable {
stateDesc = state.description
self.date = date
self.events = events

}
}

Expand Down
29 changes: 15 additions & 14 deletions CalendarX/Module/Calender/DateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct DateView: View {
}
}

Text(day.lunarDate).font(.caption2).foregroundColor(.accentColor)
Text(day.lunarDate).font(.footnote).foregroundColor(.secondary)
}


Expand All @@ -52,7 +52,7 @@ struct FestivalsView: View {

Section(content: {
if isExpanded, festivals.isNotEmpty {
WrappingHStack(festivals,spacing: .constant(5), lineSpacing: 5) { festival in
WrappingHStack(festivals,spacing: .constant(8), lineSpacing: 8) { festival in
ScacleTagButton(title: festival.l10nKey) {
NSWorkspace.searching(festival)
}
Expand Down Expand Up @@ -109,18 +109,20 @@ struct SchedulesView: View {

HStack {
event.color.width(5)

VStack(alignment: .leading) {
Group {
Text(L10n.timeline(from: event.startDate)) +
Text(" - ") +
Text(L10n.timeline(from: event.endDate))
}
.font(.subheadline)
.foregroundColor(.secondary)
Divider()

Text(event.title)

}.padding(5)

Divider()

Text(L10n.timeline(from: event.startDate) +
" - " +
L10n.timeline(from: event.endDate))
.font(.footnote)

}
.padding(5)
Spacer()
}
.background(event.color.opacity(0.1))
Expand All @@ -136,7 +138,6 @@ struct GroupEmptyRow: View {
Text(title)
Spacer()
}
.font(.subheadline)
.foregroundColor(.secondary)
}
}
Expand All @@ -150,7 +151,7 @@ struct GroupHeader<Label: View>: View {

var body: some View {
HStack() {
Text(title).font(.headline)
Text(title).font(.title3)
Spacer()
label()
}
Expand Down
4 changes: 3 additions & 1 deletion CalendarX/Module/Calender/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ struct MainView: View {
.equatable()
.opacity(isShown ? 0:1)
.height(.mainHeight)

}

}

private func header() -> some View {

HStack {
Expand Down Expand Up @@ -199,6 +200,7 @@ struct CalendarView<Day: View, Header: View, Week: View>: View {
calendar.firstWeekday = firstWeekday.rawValue
let dates = calendar.generateDates(for: date)
let events = Event.fetchEvents(with: dates.first!, end: dates.last!)

return dates.map { date in
XDay(date, events: events.filter{$0.startDate.isSameDay(as: date)})
}
Expand Down
Loading

0 comments on commit 2f91f84

Please sign in to comment.