Skip to content

Commit 81926f1

Browse files
authored
feat: allow for not filled sf symbols (#98)
1 parent 6dc2f3e commit 81926f1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

example/src/Examples/SFSymbols.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function SFSymbols() {
1818
: { sfSymbol: 'document.fill' },
1919
unfocusedIcon: isAndroid
2020
? require('../../assets/icons/chat_dark.png')
21-
: { sfSymbol: 'bubble.left.fill' },
21+
: { sfSymbol: 'document' },
2222
badge: '!',
2323
},
2424
{

ios/TabViewImpl.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct TabViewImpl: View {
7575
.tag(tabData?.key)
7676
.tabBadge(tabData?.badge)
7777
}
78+
7879
}
7980
.onTabItemLongPress({ index in
8081
if let key = props.items[safe: index]?.key {
@@ -163,6 +164,7 @@ struct TabItem: View {
163164
Image(uiImage: icon)
164165
} else if let sfSymbol, !sfSymbol.isEmpty {
165166
Image(systemName: sfSymbol)
167+
.noneSymbolVariant()
166168
}
167169
if (labeled != false) {
168170
Text(title ?? "")
@@ -190,11 +192,11 @@ extension View {
190192
func tabBadge(_ data: String?) -> some View {
191193
if #available(iOS 15.0, macOS 15.0, visionOS 2.0, tvOS 15.0, *) {
192194
if let data = data, !data.isEmpty {
193-
#if !os(tvOS)
195+
#if !os(tvOS)
194196
self.badge(data)
195-
#else
197+
#else
196198
self
197-
#endif
199+
#endif
198200
} else {
199201
self
200202
}
@@ -256,4 +258,16 @@ extension View {
256258
self
257259
}
258260
}
261+
262+
// Allows TabView to use unfilled SFSymbols.
263+
// By default they are always filled.
264+
@ViewBuilder
265+
func noneSymbolVariant() -> some View {
266+
if #available(iOS 15.0, *) {
267+
self
268+
.environment(\.symbolVariants, .none)
269+
} else {
270+
self
271+
}
272+
}
259273
}

0 commit comments

Comments
 (0)