Skip to content

Commit

Permalink
Release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenglongMa committed Apr 18, 2024
1 parent db2f5d1 commit 1fd1798
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
*.DS_Store
*.DS_Store

scripts/
8 changes: 4 additions & 4 deletions Waker/Waker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development: [email protected] (6725BGVYMG)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.9;
CURRENT_PROJECT_VERSION = 1.0;
DEVELOPMENT_ASSET_PATHS = "\"Waker/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
Expand All @@ -328,7 +328,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.9;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.chenglongma.waker;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -349,7 +349,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development: [email protected] (6725BGVYMG)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.9;
CURRENT_PROJECT_VERSION = 1.0;
DEVELOPMENT_ASSET_PATHS = "\"Waker/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
Expand All @@ -366,7 +366,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.9;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.chenglongma.waker;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
12 changes: 6 additions & 6 deletions Waker/Waker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import Sparkle
import UserNotifications
import SwiftUI

class AppDelegate: NSObject, NSApplicationDelegate {

func applicationWillFinishLaunching(_ notification: Notification) {
Utils.checkAccessibilityPermission()
}
//class AppDelegate: NSObject, NSApplicationDelegate {
//
// func applicationWillFinishLaunching(_ notification: Notification) {
// Utils.checkAccessibilityPermission()
// }

// func applicationDidFinishLaunching(_ notification: Notification) {
// // Make the app run in the background
// NSApp.setActivationPolicy(.accessory)
// UNUserNotificationCenter.current().delegate = self
// }
}
//}

class UpdaterDelegate: NSObject, UNUserNotificationCenterDelegate, SPUUpdaterDelegate, SPUStandardUserDriverDelegate {

Expand Down
6 changes: 2 additions & 4 deletions Waker/Waker/MenuBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct MenuBar: View {
@State private var isOn: Bool = true
@AppStorage("lanunchAtLogin") private var launchAtLogin: Bool = false
@State private var everyday: Bool = true
@State var selectedDays: Int = 0
@State private var selectedDays: Int = 0

@State private var wakeUpInterval: Double = 5.0
@State private var scheduled: Bool = false
Expand Down Expand Up @@ -47,8 +47,6 @@ struct MenuBar: View {

private let backgroundColor: Color = Color(NSColor.windowBackgroundColor)



var body: some View {

VStack(spacing:15) {
Expand Down Expand Up @@ -137,7 +135,6 @@ struct MenuBar: View {
.onAppear{
print("appear")
updaterController.startUpdater()
// self.updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: self.updaterDelegate, userDriverDelegate: nil)
observer = NSApplication.shared.observe(\.keyWindow) { x, y in
let isVisible = NSApplication.shared.keyWindow != nil
print("Is visible: \(isVisible)")
Expand All @@ -150,6 +147,7 @@ struct MenuBar: View {
scheduled = viewModel.scheduled
allDay = viewModel.allDay
isOn = viewModel.isOn
everyday = selectedDays == Constants.ALL_WEEKDAYS
self.firstWeekdayIndex = Calendar.current.firstWeekday - 1
}
}
Expand Down
4 changes: 3 additions & 1 deletion Waker/Waker/WakerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Sparkle
@main
struct WakerApp: App {

@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
// @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate

@AppStorage("appIcon") private var appIcon = "sun.max.fill"
@AppStorage("appName") private var appName = "Waker - active"
Expand All @@ -26,6 +26,8 @@ struct WakerApp: App {


init() {
Utils.checkAccessibilityPermission()

// If you want to start the updater manually, pass false to startingUpdater and call .startUpdater() later
// This is where you can also pass an updater delegate if you need one
self.updaterController = SPUStandardUpdaterController(startingUpdater: false, updaterDelegate: self.updaterDelegate, userDriverDelegate: self.updaterDelegate)
Expand Down
64 changes: 51 additions & 13 deletions Waker/Waker/WakerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,66 @@ import SwiftUI

class WakerViewModel: ObservableObject {

@AppStorage("isOn") var isOn = true
@AppStorage("wakeUpInterval") var wakeUpInterval: Double = 5.0 //* 60 // unit: seconds
@AppStorage("scheduled") var scheduled: Bool = false
@AppStorage("isOn") private var _isOn = true
@AppStorage("wakeUpInterval") var wakeUpInterval: Double = 5.0 // unit: minutes!
@AppStorage("scheduled") private var _scheduled: Bool = false
@AppStorage("startTime") private var startTimeStr: String = "09:00"
@AppStorage("endTime") private var endTimeStr: String = "17:00"
@AppStorage("allDay") var allDay: Bool = false
@AppStorage("scheduledDays") var selectedDays: Int = Constants.ALL_WEEKDAYS
@AppStorage("allDay") private var _allDay: Bool = false
@AppStorage("scheduledDays") private var _selectedDays: Int = Constants.ALL_WEEKDAYS

var startTime: Date {
get { startTimeStr.toTime() }
set { startTimeStr = newValue.toString() }
set {
startTimeStr = newValue.toString()
_ = self.isStarting()
}
}
var endTime: Date {
get { endTimeStr.toTime() }
set { endTimeStr = newValue.toString() }
set {
endTimeStr = newValue.toString()
_ = self.isStarting()
}
}

var isOn: Bool {
get { _isOn }
set {
_isOn = newValue
_ = self.isStarting()
}
}

var scheduled: Bool {
get { _scheduled }
set {
_scheduled = newValue
_ = self.isStarting()
}
}

var allDay: Bool {
get { _allDay }
set {
_allDay = newValue
_ = self.isStarting()
}
}

var selectedDays: Int {
get { _selectedDays }
set {
_selectedDays = newValue
_ = self.isStarting()
}
}

private let checkInterval: TimeInterval = 2 //* 60 // unit: seconds
private let checkInterval: TimeInterval = 1 * 60 // unit: seconds
private var timer: Timer?

private var awake: Bool = false
@Published var runningStatus: RunningStatus = RunningStatus.running
@Published var runningStatus: RunningStatus = .running

init() {
start()
Expand All @@ -57,13 +95,13 @@ class WakerViewModel: ObservableObject {
let isRunning = self.isOn && todaySelected && nowInRange

if isRunning {
self.runningStatus = RunningStatus.running
self.runningStatus = .running
} else if !self.isOn {
self.runningStatus = RunningStatus.stopped
self.runningStatus = .stopped
} else if scheduled {
self.runningStatus = RunningStatus.scheduled
self.runningStatus = self.selectedDays == 0 ? .stopped : .scheduled
} else {
self.runningStatus = RunningStatus.error
self.runningStatus = .error
}

return isRunning
Expand Down
10 changes: 5 additions & 5 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<channel>
<title>Waker</title>
<item>
<title>0.9</title>
<pubDate>Thu, 18 Apr 2024 16:13:22 +1000</pubDate>
<sparkle:version>0.9</sparkle:version>
<sparkle:shortVersionString>0.9</sparkle:shortVersionString>
<title>1.0</title>
<pubDate>Thu, 18 Apr 2024 17:05:45 +1000</pubDate>
<sparkle:version>1.0</sparkle:version>
<sparkle:shortVersionString>1.0</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
<enclosure url="https://github.com/ChenglongMa/waker-mac/releases/latest/download/Waker.dmg" length="1078348" type="application/octet-stream" sparkle:edSignature="A/rC87odRN6yaG3gdbrajNgAkXfNcm9vKdTYXq5eZa5GJLR+kVL7esK3hzl5nwbhbdYXLCpv0nY+AA9NeoCcDQ=="/>
<enclosure url="https://github.com/ChenglongMa/waker-mac/releases/latest/download/Waker.dmg" length="1075519" type="application/octet-stream" sparkle:edSignature="bbbFodjspKOUr1AsFnHRxfK5wxigYGmNc1ihhCIZShB+FfCZtbTbObNYJl7lIRlusQZiTvwvdd8fIpXlMX9jBg=="/>
</item>
</channel>
</rss>

0 comments on commit 1fd1798

Please sign in to comment.