5/// Renders a small icon to show the review state, e.g. a green circled tick
6/// for "Approved" images.
7struct ReviewStateBorder: ViewModifier {
8 let state: ReviewState?
9 let cornerRadius: CGFloat
11 init(_ state: ReviewState?, _ cornerRadius: CGFloat) {
13 self.cornerRadius = cornerRadius
16 func body(content: Content) -> some View {
18 // This technique for drawing a coloured border with rounded corners
19 // comes from an article by Simon Ng:
20 // https://www.appcoda.com/swiftui-border/
21 RoundedRectangle(cornerRadius: cornerRadius)
23 state?.color() ?? .gray.opacity(0.7),
24 lineWidth: state != nil ? 3.0 : 3.0 * 5.0 / 7.0
31 func reviewStateBorder(for state: ReviewState?, with cornerRadius: CGFloat) -> some View {
32 modifier(ReviewStateBorder(state, cornerRadius))