@@ -19,7 +19,7 @@ extension CGFloat {
1919}
2020
2121struct EmbedView : View , Equatable {
22- weak var embed : Embed ?
22+ @ Binding var embed : Embed
2323
2424 static func == ( _: EmbedView , _: EmbedView ) -> Bool {
2525 true
@@ -29,7 +29,7 @@ struct EmbedView: View, Equatable {
2929
3030 var body : some View {
3131 HStack ( spacing: 0 ) {
32- if let color = embed? . color {
32+ if let color = embed. color {
3333 if #available( macOS 13 . 0 , * ) {
3434 RoundedRectangle ( cornerRadius: 1 )
3535 . fill ( Color ( int: color) . gradient)
@@ -48,7 +48,7 @@ struct EmbedView: View, Equatable {
4848 . padding ( . trailing, 5 )
4949 }
5050 VStack ( alignment: . leading) {
51- if let author = embed? . author {
51+ if let author = embed. author {
5252 HStack {
5353 if let iconURL = author. proxy_icon_url ?? author. icon_url {
5454 Attachment ( iconURL, size: CGSize ( width: 48 , height: 48 ) )
@@ -75,42 +75,42 @@ struct EmbedView: View, Equatable {
7575 }
7676 . padding ( . vertical, 2 )
7777 }
78- if let title = embed? . title {
78+ if let title = embed. title {
7979 Text ( title)
8080 . fontWeight ( . semibold)
8181 . font ( . system( size: 13.5 ) )
8282 . padding ( . vertical, 2 )
8383 }
84- if let description = embed? . description {
84+ if let description = embed. description {
8585 AsyncMarkdown ( description)
8686 . lineSpacing ( 3 )
8787 . padding ( . vertical, 2 )
8888 }
89- if let image = embed? . image {
89+ if let image = embed. image {
9090 Attachment ( image. url, size: CGSize ( width: image. width ?? 400 , height: image. width ?? 300 ) )
9191 . equatable ( )
9292 . cornerRadius ( 5 )
9393 . maxFrame ( width: 380 , height: 300 , originalWidth: image. width ?? 0 , originalHeight: image. height ?? 0 )
9494 . padding ( . vertical, 2 )
9595 }
96- if let video = embed? . video,
96+ if let video = embed. video,
9797 let urlString = video. proxy_url ?? video. url,
9898 let url = URL ( string: urlString)
9999 {
100100 VideoPlayer ( player: AVPlayer ( url: url) )
101101 . cornerRadius ( 5 )
102102 . maxFrame ( width: 380 , height: 300 , originalWidth: video. width ?? 0 , originalHeight: video. height ?? 0 )
103103 . padding ( . vertical, 2 )
104- } else if let image = embed? . thumbnail {
104+ } else if let image = embed. thumbnail {
105105 Attachment ( image. url)
106106 . equatable ( )
107107 . scaledToFit ( )
108- . frame ( width: CGFloat ( optional: image. width) , height : CGFloat ( optional : image . height ) )
108+ . frame ( width: min ( 380 , CGFloat ( optional: image. width) ?? 100.0 ) )
109109 . frame ( idealWidth: Double ( image. width ?? 100 ) , maxWidth: 380 , maxHeight: 300 )
110110 . cornerRadius ( 5 )
111111 . padding ( . vertical, 2 )
112112 }
113- if let fields = embed? . fields {
113+ if let fields = embed. fields {
114114 GridStack ( fields, rowAlignment: . leading, columns: 4 ) { field in
115115 VStack ( alignment: . leading) {
116116 Text ( field. name)
0 commit comments