Skip to content

Commit

Permalink
Move changeBehaviorBasedOnModal function to AppDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
DamascenoRafael committed Jun 28, 2022
1 parent 17aaf55 commit 528f71a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 9 additions & 1 deletion reminders-menu-bar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
popover.behavior = .transient
}

func changeBehaviorToKeepVisible() {
private func changeBehaviorToKeepVisible() {
popover.behavior = .applicationDefined
}

func changeBehaviorBasedOnModal(isShowing: Bool) {
if isShowing {
changeBehaviorToKeepVisible()
} else {
changeBehaviorToDismissIfNeeded()
}
}

private func requestAuthorization() {
let authorization = RemindersService.instance.authorizationStatus()
Expand Down
12 changes: 2 additions & 10 deletions reminders-menu-bar/Views/ReminderItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ struct ReminderItemView: View {
removeReminderAlert()
}
.onChange(of: showingRemoveAlert) { isShowing in
changeBehaviorBasedOnModal(isShowing: isShowing)
AppDelegate.instance.changeBehaviorBasedOnModal(isShowing: isShowing)
}
.sheet(isPresented: $showingRenameSheet) {
renameReminderSheet()
}
.onChange(of: showingRenameSheet) { isShowing in
changeBehaviorBasedOnModal(isShowing: isShowing)
AppDelegate.instance.changeBehaviorBasedOnModal(isShowing: isShowing)
}

if let dateDescription = reminder.relativeDateDescription {
Expand Down Expand Up @@ -131,14 +131,6 @@ struct ReminderItemView: View {
RemindersService.instance.save(reminder: reminder)
}

func changeBehaviorBasedOnModal(isShowing: Bool) {
if isShowing {
AppDelegate.instance.changeBehaviorToKeepVisible()
} else {
AppDelegate.instance.changeBehaviorToDismissIfNeeded()
}
}

func removeReminderAlert() -> Alert {
Alert(title: Text(rmbLocalized(.removeReminderAlertTitle)),
message: Text(rmbLocalized(.removeReminderAlertMessage, arguments: reminder.title)),
Expand Down

0 comments on commit 528f71a

Please sign in to comment.