Skip to content

Conversation

@theboringhumane
Copy link
Member

No description provided.

AlexLemus-Dev and others added 14 commits March 26, 2025 21:34
- Add `openBatterySettings` function in `BatteryMenuView` to open battery settings in System Preferences ⚙️
- Improve `powerSourceText` to handle various battery states including fully charged, charging, and low power mode 🔋
- Refactor code to reduce nested `if` statements and improve readability 🧹
- Ensure text color adapts to light and dark modes 🌗
- Adjust icons for bolt and power plug to ensure proper alignment ⚡🔌

These improvements provide more detailed information about the battery status, beyond just displaying an icon 📊
- Changed `percentage`, `isCharging`, `isInLowPowerMode`, and `isInitialPlugIn` to regular properties in `BatteryView`
- Updated `BatteryMenuView` and `BoringBatteryView` to pass these properties correctly
- Improved code readability and performance by avoiding unnecessary state management: simplifies the data flow from parent to child views.
- Added detailed documentation to explain the purpose of each property and method
- Changed `percentage`, `isCharging`, `isInLowPowerMode`, and `isInitialPlugIn` to regular properties in `BatteryView`
- Updated `BatteryMenuView` and `BoringBatteryView` to pass these properties correctly
- Improved code readability and performance by avoiding unnecessary state management:  simplifies the data flow from parent to child views
🔧 Settings:
- Add battery indicator visibility toggle
- Add battery notifications toggle
- Add battery percentage display option
- Add battery status icon toggle

🏗️ Code Changes:
- Implement BatteryInfo struct for better organization
- Add PowerState enum for status handling
- Improve status text formatting
- Refactor battery monitoring logic

📚 Documentation:
- Document battery-related methods
- Add clear method descriptions
- Document new settings options

♻️ Refactor:
- Improve battery status updates
- Better power state handling
- Clean code organization with MARK comments
This update improves the battery status visualization with the following changes:

## 🔄 Battery Activity Manager
- ✅ Added robust error handling with specific error types
- 📊 Implemented consistent battery status monitoring
- ⚡️ Optimized notification queue for better performance
- 📝 Added comprehensive documentation throughout the module
- 🛡️ Created a more reliable battery data retrieval system

## 🎨 Battery UI Components
- ➕ Added a detailed `BatteryMenuView` component that shows:
  - 📊 Battery percentage and max capacity
  - ⚡️ Charging status with visual indicators
  - 🔋 Low power mode status
  - ⏱️ Time to full charge (when applicable)
  - ⚙️ Direct access to system battery preferences

- 💪 Enhanced `BoringBatteryView` with:
  - 👆 Interactive popover menu triggered by press gestures
  - ✨ Animation feedback on interaction
  - 🔢 Optional battery percentage display (toggleable via preferences)
  - 🎭 Improved visual styling for different battery states

- 🔍 Refined `BatteryView` component with:
  - 🚦 Better visual indicators for charging, plugged-in, and low power states
  - 📱 Responsive layout that adapts to different sizes
  - 🔄 Consistent styling across notification and main UI contexts

## 🧩 Code Quality
- 🏗️ Improved code organization with better separation of concerns
- 🛡️ Enhanced type safety with generics and proper error handling
- 📚 Added comprehensive documentation for all public methods
- 🚀 Optimized performance for battery status monitoring and updates

These improvements provide users with more detailed battery information and better interaction options while maintaining a clean interface, ensuring consistent performance across different system conditions. 🌟
This update improves the battery status visualization with the following changes:

## 🔄 Battery Activity Manager
- ✅ Added robust error handling with specific error types
- 📊 Implemented consistent battery status monitoring
- ⚡️ Optimized notification queue for better performance
- 📝 Added comprehensive documentation throughout the module
- 🛡️ Created a more reliable battery data retrieval system

## 🎨 Battery UI Components
- ➕ Added a detailed `BatteryMenuView` component that shows:
  - 📊 Battery percentage and max capacity
  - ⚡️ Charging status with visual indicators
  - 🔋 Low power mode status
  - ⏱️ Time to full charge (when applicable)
  - ⚙️ Direct access to system battery preferences

- 💪 Enhanced `BoringBatteryView` with:
  - 👆 Interactive popover menu triggered by press gestures
  - ✨ Animation feedback on interaction
  - 🔢 Optional battery percentage display (toggleable via preferences)
  - 🎭 Improved visual styling for different battery states

- 🔍 Refined `BatteryView` component with:
  - 🚦 Better visual indicators for charging, plugged-in, and low power states
  - 📱 Responsive layout that adapts to different sizes
  - 🔄 Consistent styling across notification and main UI contexts

## 🧩 Code Quality
- 🏗️ Improved code organization with better separation of concerns
- 🛡️ Enhanced type safety with generics and proper error handling
- 📚 Added comprehensive documentation for all public methods
- 🚀 Optimized performance for battery status monitoring and updates

These improvements provide users with more detailed battery information and better interaction options while maintaining a clean interface, ensuring consistent performance across different system conditions. 🌟
- Adjust `BatteryMenuView` to display "charging on hold" status when applicable.
- Update images for plug and bolt, add new assets, and adjust icons to match macOS design.
Delete the Sidebar icon folder as it is no longer needed.
- Modified condition to display battery percentage when it is equal to or greater than 80%
Ensure ci/cd uses latest version of setup-xcode to resolve errors
@cori-ai cori-ai bot added the cori-ai-review Cori AI review label Mar 26, 2025
theboringhumane and others added 6 commits March 26, 2025 13:05
…d safety

- Enhanced deinit method with semaphore to ensure safe session stopping
- Improved session setup and teardown with more robust thread management
- Added main thread dispatching for preview layer operations
- Simplified session start and stop methods with better error handling
- Removed redundant state updates and improved device connection handling
- Changed `checkCameraAvailability()` from private to public access
- Removed automatic session start and state update from setup method
- Provides more flexibility for external control of camera session lifecycle
Fixes to Fullscreen Detection, Playback Management, Elapsed Time Calculations, and Webcam Management
struct PlaybackState {
var bundleIdentifier: String
var isPlaying: Bool = false
var title: String = "I'm Handsome"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 Consider using a more descriptive title instead of "I'm Handsome" for better clarity in the context of playback. For example:

var title: String = "Unknown Title"

var currentTime: Double = 0
var duration: Double = 0
var playbackRate: Double = 1
var isShuffled: Bool? = nil
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 The optional properties isShuffled and isRepeating could be initialized to false instead of nil for better clarity on their default state:

var isShuffled: Bool = false
var isRepeating: Bool = false

var playbackRate: Double = 1
var isShuffled: Bool? = nil
var isRepeating: Bool? = nil
var lastUpdated: Date = Date.distantPast
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕒 Consider using Date() instead of Date.distantPast for lastUpdated to reflect the current time when a new PlaybackState is created:

var lastUpdated: Date = Date()

import SwiftUI

class FullscreenMediaDetector: ObservableObject {
static let shared = FullscreenMediaDetector()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Consider adding a comment explaining the purpose of the shared instance for clarity. This helps other developers understand its usage.

static let shared = FullscreenMediaDetector()

class FullscreenMediaDetector: ObservableObject {
static let shared = FullscreenMediaDetector()
let detector: MacroVisionKit
let musicManager: MusicManager
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Ensure that MusicManager.shared is thread-safe if accessed from multiple threads. Consider using a dispatch queue or other synchronization mechanisms if necessary.

let musicManager: MusicManager

var nowPlaying: NowPlaying = .init()

init() {
private init() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 The init method is private, which is good for singleton patterns. Ensure that this is documented to clarify its intended use.

private init() {

DispatchQueue.main.async {
if let frontmostApp = NSWorkspace.shared.frontmostApplication {
let sameAsNowPlaying = !Defaults[.alwaysHideInFullscreen] ? frontmostApp.bundleIdentifier == self.nowPlaying.appBundleIdentifier : true
let sameAsNowPlaying = !Defaults[.alwaysHideInFullscreen] ? frontmostApp.bundleIdentifier == self.musicManager.bundleIdentifier : true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔄 The change from self.nowPlaying.appBundleIdentifier to self.musicManager.bundleIdentifier is appropriate. Ensure that musicManager is initialized before this method is called to avoid potential nil issues.

let sameAsNowPlaying = !Defaults[.alwaysHideInFullscreen] ? frontmostApp.bundleIdentifier == self.musicManager.bundleIdentifier : true

// Created by Alexander Greco on 2024-10-27.
//

import AppKit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Consider adding a comment explaining why AppKit is imported here, especially if it's not immediately clear how it's used in the class. This helps maintain clarity for future developers. 📝


// Check if the Mac has a notch
if screen.safeAreaInsets.top > 0 {
// This is a display WITH a notch - use notch height settings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 This comment is clear and relevant, indicating that the following logic applies to displays with a notch. Keep it! ✅

notchHeight = screen.frame.maxY - screen.visibleFrame.maxY
}
} else {
// This is a display WITHOUT a notch - use non-notch height settings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 This comment effectively clarifies that the following logic applies to displays without a notch. Keep it! ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cori-ai-review Cori AI review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants