mirror of
https://github.com/insidegui/VirtualBuddy.git
synced 2026-12-02 06:59:37 +08:00
27 lines
725 B
Swift
27 lines
725 B
Swift
import SwiftUI
|
|
|
|
struct MaskProgressView<Mask: View, Foreground: ShapeStyle, Background: ShapeStyle>: View {
|
|
var progress: Double
|
|
var background: Background
|
|
var foreground: Foreground
|
|
@ViewBuilder var mask: (Double) -> Mask
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
let content = mask(progress)
|
|
|
|
content
|
|
.foregroundStyle(background)
|
|
|
|
content
|
|
.foregroundStyle(foreground)
|
|
.mask {
|
|
GeometryReader { proxy in
|
|
Rectangle().fill(.white)
|
|
.frame(width: proxy.size.width * progress, alignment: .leading)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|