TweakContext
@dynamicMemberLookup
public final class TweakContext
extension TweakContext: CustomDebugStringConvertible
The context in which tweaks live.
A TweakContext object provides a facade to interact with tweaks, like showing tweaks and import tweaks.
You can create as many TweakContext objects as you like. But one context is sufficient in most cases.
-
A flag indicates whether the context is showing the tweak window.
Declaration
Swift
public internal(set) var isShowing: Bool { get } -
Creates and initializes a tweak context with the given config, delegate and the tweak lists.
Declaration
Swift
public init(config: Config = .init(), delegate: TweakContextDelegate? = nil, @TweakContainerBuilder<TweakList> _ lists: () -> [TweakList])Parameters
configThe meta data of the context. The default is a default config object.
delegateThe object that acts as the delegate of the context. The delegate is not retained. The default is
nil.listsThe lists of tweaks of the context. The lists and the sections/tweaks in them are sorted by their names in alphabetic order.
-
Undocumented
Declaration
Swift
public subscript<Value>(dynamicMember keyPath: KeyPath<Config, Value>) -> Value { get } -
Shows the tweak widow of the context.
This method will do nothing:
- if there is a showing window.
- If the context has no list at all.
Note
You should only call this method in main thread.
Declaration
Swift
func show(locateAt tweak: AnyTweak? = nil, completion: ((Bool) -> Void)? = nil)Parameters
tweakThe tweak that should be located at when window is shown.
completionA block that TweaKit calls after showing the context window.
-
Dismisses the current showing tweak window of the context.
- This method will do nothing if there is no showing window.
- You cannot dismiss the window when it is floating.
Note
You should only call this method in main thread.
Declaration
Swift
func dismiss(completion: ((Bool) -> Void)? = nil)Parameters
completionA block that TweaKit calls after dismissing the context window.
-
Imports tweaks for the source.
Tweaks that not in the context will be ignored.
Note
You should only call this method in main thread.
Declaration
Swift
func `import`(from source: TweakTradeSource, completion: ((TweakError?) -> Void)? = nil)Parameters
sourceThe source of the tweaks to be imported.
completionA block that TweaKit calls after the source has been import.
-
Reset all the tweaks’ values and info to the default ones.
Declaration
Swift
func reset() -
Search tweaks in the current context.
This method will use the same search strategies specified in
TweakContextDelegate.\ You should get the same results as searching with the tweak UI. Calling this method will also contribute to search history in the tweak UI.
Declaration
Swift
func search(with keyword: String) -> [[AnyTweak]]Parameters
keywordThe keyword to search. An empty keyword means searching nothing.
Return Value
Tweaks that match the given keyord. Tweaks from the same section are grouped together.
-
A model represents the meta data of a
See moreTweakContextobject.Declaration
Swift
struct Config -
Declaration
Swift
public var debugDescription: String { get }
View on GitHub
TweakContext Class Reference