@@ -8,14 +8,14 @@ struct ActivityLogDetailView: View {
88
99 enum ViewState : Equatable {
1010 case loading
11- case loaded( String , isSharing: Bool )
11+ case loaded( [ String ] , isSharing: Bool )
1212 case error( Error )
1313
1414 static func == ( lhs: ActivityLogDetailView . ViewState , rhs: ActivityLogDetailView . ViewState ) -> Bool {
1515 return switch ( lhs, rhs) {
1616 case ( . loading, . loading) : true
17- case ( . loaded( let lhscontent , let lhsisSharing) , . loaded( let rhscontent , let rhsisSharing) ) :
18- lhscontent == rhscontent && lhsisSharing == rhsisSharing
17+ case ( . loaded( let lhsLines , let lhsisSharing) , . loaded( let rhsLines , let rhsisSharing) ) :
18+ lhsLines == rhsLines && lhsisSharing == rhsisSharing
1919 case ( . error, . error) : true
2020 default : false
2121 }
@@ -38,8 +38,8 @@ struct ActivityLogDetailView: View {
3838 switch self . state {
3939 case . loading:
4040 self . loadingView
41- case . loaded( let content , _) :
42- self . loadedView ( content : content )
41+ case . loaded( let lines , _) :
42+ self . loadedView ( lines : lines )
4343 case . error( let error) :
4444 self . errorView ( error: error)
4545 }
@@ -54,11 +54,11 @@ struct ActivityLogDetailView: View {
5454 }
5555 }
5656 . sheet ( isPresented: self . $isDisplayingShareSheet, onDismiss: {
57- guard case . loaded( let content , _) = self . state else {
57+ guard case . loaded( let lines , _) = self . state else {
5858 return
5959 }
6060
61- self . state = . loaded( content , isSharing: false )
61+ self . state = . loaded( lines , isSharing: false )
6262 } , content: {
6363 ActivityLogSharingView ( applicationLog: applicationLog) {
6464 AnyView ( erasing: Text ( " TODO: A new support request with the application log attached " ) )
@@ -87,15 +87,21 @@ struct ActivityLogDetailView: View {
8787 }
8888
8989 @ViewBuilder
90- func loadedView( content : String ) -> some View {
90+ func loadedView( lines : [ String ] ) -> some View {
9191 ScrollView {
92- VStack ( alignment: . leading) {
93- TextEditor ( text: . constant( content) )
94- . font ( . system( . body, design: . monospaced) )
95- . fixedSize ( horizontal: false , vertical: true )
96- . scrollDisabled ( true )
97- . padding ( )
92+ LazyVStack ( alignment: . leading, spacing: 0 ) {
93+ logLinesContent ( lines: lines)
9894 }
95+ . font ( . system( . body, design: . monospaced) )
96+ . padding ( )
97+ }
98+ }
99+
100+ @ViewBuilder
101+ private func logLinesContent( lines: [ String ] ) -> some View {
102+ ForEach ( Array ( lines. enumerated ( ) ) , id: \. offset) { _, line in
103+ Text ( line)
104+ . frame ( maxWidth: . infinity, alignment: . leading)
99105 }
100106 }
101107
@@ -110,19 +116,22 @@ struct ActivityLogDetailView: View {
110116 private func loadLogContent( ) async {
111117 do {
112118 let content = try await self . dataProvider. readApplicationLog ( applicationLog)
119+ let lines = content
120+ . split ( separator: " \n " , omittingEmptySubsequences: false )
121+ . map ( String . init)
113122
114- self . state = . loaded( content , isSharing: false )
123+ self . state = . loaded( lines , isSharing: false )
115124 } catch {
116125 self . state = . error( error)
117126 }
118127 }
119128
120129 private func startSharing( ) {
121- guard case . loaded( let content , _) = self . state else {
130+ guard case . loaded( let lines , _) = self . state else {
122131 return
123132 }
124133
125- state = . loaded( content , isSharing: true )
134+ state = . loaded( lines , isSharing: true )
126135 }
127136}
128137
0 commit comments