-
Notifications
You must be signed in to change notification settings - Fork 21
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
5c7982f
commit 84d2290
Showing
44 changed files
with
418 additions
and
29 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
DemoApp/Sources/Components/MemoryLeaksViewer/MemoryLeaksViewer.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,66 @@ | ||
// | ||
// MemoryLeaksViewer.swift | ||
// DemoApp | ||
// | ||
// Created by Ilias Pavlidakis on 27/9/23. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import StreamVideo | ||
|
||
struct MemoryLeaksViewer: View { | ||
|
||
@Injected(\.appearance) var appearance | ||
|
||
@StateObject private var snapshot = MemorySnapshot( | ||
includeDeallocatedObjects: false, | ||
includeNotLeaked: false | ||
) | ||
@State private var entries: [MemorySnapshot.Entry] = [] | ||
|
||
var body: some View { | ||
List { | ||
ForEach(entries, id: \.typeName) { entry in | ||
makeEntryView(for: entry) | ||
} | ||
} | ||
.onReceive(snapshot.$items) { entries = $0 } | ||
.navigationTitle("MemoryLeaks Viewer") | ||
.modifier( | ||
SearchableModifier { query in | ||
if query.isEmpty { | ||
entries = snapshot.items | ||
} else { | ||
entries = snapshot | ||
.items | ||
.filter { $0.typeName.contains(query) } | ||
} | ||
}) | ||
} | ||
|
||
@ViewBuilder | ||
func makeEntryView(for entry: MemorySnapshot.Entry) -> some View { | ||
Label { | ||
HStack { | ||
Text(entry.typeName) | ||
.font(appearance.fonts.body) | ||
.foregroundColor(appearance.colors.text) | ||
.lineLimit(1) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
|
||
Text("\(entry.refCount)/\(entry.maxCount)") | ||
.font(appearance.fonts.caption1) | ||
.foregroundColor(appearance.colors.text) | ||
.lineLimit(1) | ||
} | ||
} icon: { | ||
if entry.refCount > entry.maxCount { | ||
Image(systemName: "exclamationmark.triangle") | ||
.foregroundColor(appearance.colors.accentRed) | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.