-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve serivceConfigurationKey
- Loading branch information
Showing
5 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Easydict/Swift/Feature/Configuration/WindowConfigurationKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// DefaultsStoredKey.swift | ||
// Easydict | ||
// | ||
// Created by tisfeng on 2024/4/28. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Defaults | ||
import Foundation | ||
|
||
func windowConfigurationKey<T: _DefaultsSerializable>( | ||
_ key: WindowConfigurationKey, | ||
windowType: EZWindowType, | ||
defaultValue: T | ||
) | ||
-> Defaults.Key<T> { | ||
let key = "EZConfiguration_\(key.stringValue)_Window\(windowType.rawValue)_Key" | ||
return .init(key, default: defaultValue) | ||
} | ||
|
||
// MARK: - WindowConfigurationKey | ||
|
||
@objc | ||
enum WindowConfigurationKey: Int { | ||
case inputFieldCellVisible | ||
case selectLanguageCellVisible | ||
|
||
// MARK: Internal | ||
|
||
var stringValue: String { | ||
switch self { | ||
case .inputFieldCellVisible: "InputFieldCellVisible" | ||
case .selectLanguageCellVisible: "SelectLanguageCellVisible" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters