@@ -11,17 +11,18 @@ struct NoteItemView: View {
1111 let item : NoteletVersionNoteItem
1212 let isCurrent : Bool
1313 let configuration : NoteletConfiguration
14-
14+
1515 @State private var containerSize : CGSize = . zero
16-
16+ @State private var mediaLoadState : MediaNoteItemLoadState = . loading
17+
1718 private var clipShapeRadius : Double {
1819 if #available( iOS 26 , * ) {
1920 24
2021 } else {
2122 12
2223 }
2324 }
24-
25+
2526 var body : some View {
2627 VStack ( alignment: . leading, spacing: 0 ) {
2728 switch item {
@@ -35,17 +36,19 @@ struct NoteItemView: View {
3536 * iPads and iPhones in landscape orientation.
3637 */
3738 let containerWidth = min ( max ( containerSize. width, 300 ) , 440 )
38-
39+
3940 ZStack {
4041 switch mediaKind {
4142 case . image:
4243 MediaNoteItemImageView (
43- imageUrl: url
44+ imageUrl: url,
45+ onLoadStateChange: { mediaLoadState = $0 }
4446 )
4547 case . video:
4648 MediaNoteItemVideoView (
4749 videoURL: url,
48- isPlaying: isCurrent
50+ isPlaying: isCurrent,
51+ onLoadStateChange: { mediaLoadState = $0 }
4952 )
5053 }
5154 }
@@ -56,14 +59,23 @@ struct NoteItemView: View {
5659 . clipShape ( . rect( cornerRadius: clipShapeRadius) )
5760 . shadow ( color: . black. opacity ( 0.15 ) , radius: 20 , x: 0 , y: 0 )
5861 . padding ( mediaPadding)
59-
62+
6063 MediaNoteItemDetailsView (
6164 title: title,
6265 description: description
6366 )
64-
67+
6568 Spacer ( )
6669 }
70+ . accessibilityElement ( children: . ignore)
71+ . accessibilityLabel (
72+ mediaAccessibilityLabel (
73+ kind: mediaKind,
74+ loadState: mediaLoadState,
75+ title: title,
76+ description: description
77+ )
78+ )
6779 case . list( let title, let rows) :
6880 BulletListNoteItemView (
6981 title: title,
@@ -79,4 +91,26 @@ struct NoteItemView: View {
7991 containerSize = newSize
8092 }
8193 }
94+
95+ private func mediaAccessibilityLabel(
96+ kind: NoteletVersionNoteItem . MediaKind ,
97+ loadState: MediaNoteItemLoadState ,
98+ title: LocalizedStringResource ,
99+ description: LocalizedStringResource
100+ ) -> Text {
101+ switch ( kind, loadState) {
102+ case ( . image, . loading) :
103+ Text ( " Loading image. \( title) . \( description) " )
104+ case ( . image, . loaded) :
105+ Text ( " Image. \( title) . \( description) " )
106+ case ( . image, . failed) :
107+ Text ( " Image failed to load. \( title) . \( description) " )
108+ case ( . video, . loading) :
109+ Text ( " Loading video. \( title) . \( description) " )
110+ case ( . video, . loaded) :
111+ Text ( " Video. \( title) . \( description) " )
112+ case ( . video, . failed) :
113+ Text ( " Video failed to load. \( title) . \( description) " )
114+ }
115+ }
82116}
0 commit comments