Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 22, 2023
1 parent 7507f9e commit 5cf4d20
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sources/DarkMode/Color+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Color {
#if os(macOS)
if #available(macOS 10.15, *) {
// For macOS 10.15 and later, the color is determined based on the current appearance mode
self.init(name: nil) { _ in
self.init(name: nil) { _/*: NSApperance*/ in
Apperance().inDarkMode ? dark : light
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion Sources/DarkMode/UIImageAsset+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ extension UIImageAsset {
*/
public convenience init(lightModeImage: UIImage?, darkModeImage: UIImage?) {
self.init() // Initialize a new instance of UIImageAsset
register(lightModeImage: lightModeImage, darkModeImage: darkModeImage) // Register the light mode image and dark mode image for the UIImageAsset instance
register(
lightModeImage: lightModeImage, // The image to use in light mode
darkModeImage: darkModeImage // The image to use in dark mode
) // Register the light mode image and dark mode image for the UIImageAsset instance
}
/**
* Method to register images for light and dark user interface styles.
Expand Down
4 changes: 2 additions & 2 deletions Sources/DarkMode/common/Apperance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension Apperance {
* - Example: Use `Apperance().inDarkMode` to check if the OS is in dark mode.
*/
public var inDarkMode: Bool {
let currentStyle = Apperance() // Create an instance of the Appearance enum
let currentStyle: Apperance = .init() // Create an instance of the Appearance enum
if case .dark = currentStyle { // Check if the current appearance is dark
return true // Return true if the current appearance is dark
} else if case .light = currentStyle { // Check if the current appearance is light
Expand Down Expand Up @@ -72,6 +72,6 @@ public final class ChangeDetector {
* This extension adds a type for DarkMode support.
*/
extension Notification.Name {
static let AppleInterfaceThemeChangedNotification = Notification.Name("AppleInterfaceThemeChangedNotification")
static let AppleInterfaceThemeChangedNotification: Notification.Name = .init("AppleInterfaceThemeChangedNotification")
}
#endif
1 change: 0 additions & 1 deletion Sources/DarkMode/common/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public typealias Color = NSColor

#if os(macOS)
import AppKit.NSColor

// Extend NSColor to add a convenience initializer
extension NSColor {
/**
Expand Down
9 changes: 4 additions & 5 deletions Sources/DarkMode/common/Swatches.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension Color {
/**
* Represents a light yellow color with hex value #F9EFB1.
*/
static let xF9EFB1 = #colorLiteral(
static let xF9EFB1: NSColor = #colorLiteral(
red: 0.976_470_588_235_294_1, // red component
green: 0.937_254_901_960_784_3, // green component
blue: 0.694_117_647_058_823_5, // blue component
Expand All @@ -20,7 +20,7 @@ extension Color {
/**
* Represents a gray color with hex value #6A6A6A.
*/
static let x6A6A6A = #colorLiteral(
static let x6A6A6A: NSColor = #colorLiteral(
red: 0.415_686_274_509_803_9, // red component
green: 0.415_686_274_509_803_9, // green component
blue: 0.415_686_274_509_803_9, // blue component
Expand All @@ -29,17 +29,16 @@ extension Color {
/**
* Represents a near white color with hex value #FEFEFE.
*/
static let xFEFEFE = #colorLiteral(
static let xFEFEFE: NSColor = #colorLiteral(
red: 0.996_078_431_372_549_0, // red component
green: 0.996_078_431_372_549_0, // green component
blue: 0.996_078_431_372_549_0, // blue component
alpha: 1 // alpha component
)

/**
* Represents a dark gray color with hex value #202020.
*/
static let x202020 = #colorLiteral(
static let x202020: NSColor = #colorLiteral(
red: 0.125_490_196_078_431_4, // red component
green: 0.125_490_196_078_431_4, // green component
blue: 0.125_490_196_078_431_4, // blue component
Expand Down
81 changes: 74 additions & 7 deletions Sources/DarkMode/common/Theme.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation

/**
* App-color-scheme
* This file defines the color scheme for the entire application.
Expand All @@ -18,32 +17,100 @@ internal final class Theme {
/**
* Represents the title color, light gray in light mode and white in dark mode.
*/
static let title: Color = .init(light: #colorLiteral(red: 0.2605174184, green: 0.2605243921, blue: 0.260520637, alpha: 1), dark: #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1))
static let title: Color = .init(
light: #colorLiteral( // The color of the title in light mode
red: 0.2605174184, // The color red component of the title in light mode
green: 0.2605243921, // The color green component of the title in light mode
blue: 0.260520637, // The color blue component of the title in light mode
alpha: 1 // The alpha value of the title in light mode
),
dark: #colorLiteral( // The color of the title in dark mode
red: 0.8039215803, // The color red component of the title in dark mode
green: 0.8039215803, // The color green component of the title in dark mode
blue: 0.8039215803, // The color blue component of the title in dark mode
alpha: 1 // The alpha value of the title in dark mode
)
)
/**
* Represents the header color, gray in light mode and near white in dark mode.
*/
static let header: Color = .init(light: .x6A6A6A, dark: .init(hex: 0xFEFEFE))
static let header: Color = .init(
light: .x6A6A6A, // The color of the header in light mode
dark: .init(hex: 0xFEFEFE) // The color of the header in dark mode
)
}
// Button color definitions
struct Button {
/**
* Represents the accessory button color, blue in light mode and dark blue in dark mode.
*/
static let accessory: Color = .init(light: #colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1), dark: #colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1))
static let accessory: Color = .init(
light: #colorLiteral(
red: 0.1764705926, // The color red component of the accessory color in light mode
green: 0.4980392158, // The color green component of the accessory color in light mode
blue: 0.7568627596, // The color blue component of the accessory color in light mode
alpha: 1 // The alpha value of the accessory color in light mode
),
dark: #colorLiteral(
red: 0.1019607857, // The color red component of the accessory color in dark mode
green: 0.2784313858, // The color green component of the accessory color in dark mode
blue: 0.400000006, // The color blue component of the accessory color in dark mode
alpha: 1 // The alpha value of the accessory color in dark mode
)
)
}
// Background color definitions
struct Background {
/**
* Represents the primary background color, white in light mode and dark gray in dark mode.
*/
static let primary: Color = .init(light: #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0), dark: #colorLiteral(red: 0.08450166136, green: 0.08400709182, blue: 0.08488682657, alpha: 1))
static let primary: Color = .init(
light: #colorLiteral(
red: 1.0, // The color red component of the primary color in light mode
green: 1.0, // The color green component of the primary color in light mode
blue: 1.0, // The color blue component of the primary color in light mode
alpha: 1.0 // The alpha value of the primary color in light mode
),
dark: #colorLiteral(
red: 0.08450166136, // The color red component of the primary color in dark mode
green: 0.08400709182, // The color green component of the primary color in dark mode
blue: 0.08488682657, // The color blue component of the primary color in dark mode
alpha: 1 // The alpha value of the primary color in dark mode
)
)
/**
* Represents the secondary background color, light gray in light mode and #212121 in dark mode.
*/
static let secondary: Color = .init(light: #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1), dark: #colorLiteral(red: 0.1298420429, green: 0.1298461258, blue: 0.1298439503, alpha: 1))
static let secondary: Color = .init(
light: #colorLiteral(
red: 0.8039215803, // The color red component of the secondary color in light mode
green: 0.8039215803, // The color green component of the secondary color in light mode
blue: 0.8039215803, // The color blue component of the secondary color in light mode
alpha: 1 // The alpha value of the secondary color in light mode
),
dark: #colorLiteral(
red: 0.1298420429, // The color red component of the secondary color in dark mode
green: 0.1298461258, // The color green component of the secondary color in dark mode
blue: 0.1298439503, // The color blue component of the secondary color in dark mode
alpha: 1 // The alpha value of the secondary color in dark mode
)
)
/**
* Represents the tertiary background color, gray in light mode and #424242 in dark mode.
*/
static let tertiary: Color = .init(light: #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1), dark: #colorLiteral(red: 0.2605174184, green: 0.2605243921, blue: 0.260520637, alpha: 1))
static let tertiary: Color = .init(
light: #colorLiteral(
red: 0.6, // The color red component of the tertiary color in light mode
green: 0.6, // The color green component of the tertiary color in light mode
blue: 0.6, // The color blue component of the tertiary color in light mode
alpha: 1 // The alpha value of the tertiary color in light mode
),
dark: #colorLiteral(
red: 0.2605174184, // The color red component of the tertiary color in dark mode
green: 0.2605243921, // The color green component of the tertiary color in dark mode
blue: 0.260520637, // The color blue component of the tertiary color in dark mode
alpha: 1 // The alpha value of the tertiary color in dark mode
)
)
}
}

0 comments on commit 5cf4d20

Please sign in to comment.