Skip to main content

Blink/Views/Thumbnails/ReviewStateIcon.swift

1import SwiftUI
3/// Renders a small icon to show the review state, e.g. a green circled tick
4/// for "Approved" images.
5struct ReviewStateIcon: ViewModifier {
6 let state: ReviewState?
7 let isFocused: Bool
8
9 init(_ state: ReviewState?, _ isFocused: Bool) {
10 self.state = state
11 self.isFocused = isFocused
12 }
14 func body(content: Content) -> some View {
15 if let thisState = state {
16 content.overlay(alignment: Alignment(horizontal: .leading, vertical: .top)) {
17 thisState.icon()
18 .foregroundStyle(.white, thisState.color())
19 .symbolRenderingMode(.palette)
20 .padding(2)
21 .font(isFocused ? .title2 : .title3)
22 .shadow(radius: 2.0)
23 }
24 } else {
25 content
26 }
27 }
30extension View {
31 func reviewStateIcon(for state: ReviewState?, _ isFocused: Bool) -> some View {
32 modifier(ReviewStateIcon(state, isFocused))
33 }