mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-24 14:02:53 +01:00
Optimize custom font
This commit is contained in:
parent
b259b6739e
commit
061791f632
@ -88,11 +88,16 @@ public class Theme: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var _cachedChoosenFont: UIFont?
|
||||||
public var chosenFont: UIFont? {
|
public var chosenFont: UIFont? {
|
||||||
get {
|
get {
|
||||||
|
if let _cachedChoosenFont {
|
||||||
|
return _cachedChoosenFont
|
||||||
|
}
|
||||||
guard let chosenFontData,
|
guard let chosenFontData,
|
||||||
let font = try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIFont.self, from: chosenFontData) else { return nil }
|
let font = try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIFont.self, from: chosenFontData) else { return nil }
|
||||||
|
|
||||||
|
_cachedChoosenFont = font
|
||||||
return font
|
return font
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
@ -103,6 +108,7 @@ public class Theme: ObservableObject {
|
|||||||
} else {
|
} else {
|
||||||
chosenFontData = nil
|
chosenFontData = nil
|
||||||
}
|
}
|
||||||
|
_cachedChoosenFont = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user