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
extension Sequence { | |
func mapAsync<T>(_ handler: @escaping (Element) async -> T) async -> [T] { | |
return await withTaskGroup(of: (Int, T).self) { group in | |
var results: [Int: T] = [:] | |
for (index, item) in self.enumerated() { | |
group.async { (index, await handler(item)) } | |
} | |
for await (index, transformed) in group { | |
results[index] = transformed |
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
struct TabBar: View { | |
@State private var selectedTab: Tab = .overview | |
@Namespace private var ns | |
enum Tab { | |
case overview, data, graphs, settings | |
} | |
var body: some View { |