Skip to content

Commit 9638941

Browse files
committed
Move xcodeStyleFrame to shared UI components
1 parent b335e96 commit 9638941

2 files changed

Lines changed: 38 additions & 29 deletions

File tree

Core/Sources/SuggestionWidget/Styles.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,6 @@ extension NSAppearance {
4545
}
4646
}
4747

48-
struct XcodeLikeFrame<Content: View>: View {
49-
@Environment(\.colorScheme) var colorScheme
50-
let content: Content
51-
let cornerRadius: Double
52-
53-
var body: some View {
54-
content.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
55-
.background(
56-
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
57-
.fill(Material.bar)
58-
)
59-
.overlay(
60-
RoundedRectangle(cornerRadius: max(0, cornerRadius), style: .continuous)
61-
.stroke(Color.black.opacity(0.1), style: .init(lineWidth: 1))
62-
) // Add an extra border just incase the background is not displayed.
63-
.overlay(
64-
RoundedRectangle(cornerRadius: max(0, cornerRadius - 1), style: .continuous)
65-
.stroke(Color.white.opacity(0.2), style: .init(lineWidth: 1))
66-
.padding(1)
67-
)
68-
}
69-
}
70-
71-
extension View {
72-
func xcodeStyleFrame(cornerRadius: Double? = nil) -> some View {
73-
XcodeLikeFrame(content: self, cornerRadius: cornerRadius ?? 10)
74-
}
75-
}
76-
7748
extension MarkdownUI.Theme {
7849
static func custom(fontSize: Double) -> MarkdownUI.Theme {
7950
.gitHub.text {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Foundation
2+
import SwiftUI
3+
4+
public struct XcodeLikeFrame<Content: View>: View {
5+
@Environment(\.colorScheme) var colorScheme
6+
let content: Content
7+
let cornerRadius: Double
8+
9+
public init(cornerRadius: Double, content: Content) {
10+
self.content = content
11+
self.cornerRadius = cornerRadius
12+
}
13+
14+
public var body: some View {
15+
content
16+
.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
17+
.background(
18+
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
19+
.fill(Material.bar)
20+
)
21+
.overlay(
22+
RoundedRectangle(cornerRadius: max(0, cornerRadius), style: .continuous)
23+
.stroke(Color.black.opacity(0.1), style: .init(lineWidth: 1))
24+
) // Add an extra border just incase the background is not displayed.
25+
.overlay(
26+
RoundedRectangle(cornerRadius: max(0, cornerRadius - 1), style: .continuous)
27+
.stroke(Color.white.opacity(0.2), style: .init(lineWidth: 1))
28+
.padding(1)
29+
)
30+
}
31+
}
32+
33+
public extension View {
34+
func xcodeStyleFrame(cornerRadius: Double? = nil) -> some View {
35+
XcodeLikeFrame(cornerRadius: cornerRadius ?? 10, content: self)
36+
}
37+
}
38+

0 commit comments

Comments
 (0)