-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8450aa1
commit 04fbfc3
Showing
2 changed files
with
38 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// FontSizeKey.swift | ||
// Notes | ||
// | ||
// Created by Muhammad Khubaib Imtiaz on 16/12/2024. | ||
// | ||
|
||
import SwiftUICore | ||
|
||
struct FontSizeKey: EnvironmentKey { | ||
static let defaultValue: CGFloat = 12 | ||
} | ||
|
||
extension EnvironmentValues { | ||
var fontSize: CGFloat { | ||
get { self[FontSizeKey.self] } | ||
set { self[FontSizeKey.self] = newValue} | ||
} | ||
} | ||
|
||
|
||
struct DynamicFontModifier: ViewModifier { | ||
|
||
@Environment(\.fontSize) var fontSize | ||
|
||
func body(content: Content) -> some View { | ||
content.font(.system(size: fontSize)) | ||
} | ||
} | ||
|
||
extension View { | ||
func dynamicFont() -> some View { | ||
self.modifier(DynamicFontModifier()) | ||
} | ||
} |
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