@@ -5,6 +5,7 @@ struct CodeBlockSuggestionPanel: View {
55 @ObservedObject var suggestion : SuggestionProvider
66 @Environment ( \. colorScheme) var colorScheme
77 @AppStorage ( \. suggestionCodeFontSize) var fontSize
8+ @AppStorage ( \. suggestionDisplayCompactMode) var suggestionDisplayCompactMode
89
910 struct ToolBar : View {
1011 @ObservedObject var suggestion : SuggestionProvider
@@ -48,6 +49,37 @@ struct CodeBlockSuggestionPanel: View {
4849 }
4950 }
5051
52+ struct CompactToolBar : View {
53+ @ObservedObject var suggestion : SuggestionProvider
54+
55+ var body : some View {
56+ HStack {
57+ Button ( action: {
58+ suggestion. selectPreviousSuggestion ( )
59+ } ) {
60+ Image ( systemName: " chevron.left " )
61+ } . buttonStyle ( . plain)
62+
63+ Text (
64+ " \( suggestion. currentSuggestionIndex + 1 ) / \( suggestion. suggestionCount) "
65+ )
66+ . monospacedDigit ( )
67+
68+ Button ( action: {
69+ suggestion. selectNextSuggestion ( )
70+ } ) {
71+ Image ( systemName: " chevron.right " )
72+ } . buttonStyle ( . plain)
73+
74+ Spacer ( )
75+ }
76+ . padding ( 4 )
77+ . font ( . caption)
78+ . foregroundColor ( . secondary)
79+ . background ( . regularMaterial)
80+ }
81+ }
82+
5183 var body : some View {
5284 VStack ( spacing: 0 ) {
5385 CustomScrollView {
@@ -62,7 +94,11 @@ struct CodeBlockSuggestionPanel: View {
6294 }
6395 . background ( Color . contentBackground)
6496
65- ToolBar ( suggestion: suggestion)
97+ if suggestionDisplayCompactMode {
98+ CompactToolBar ( suggestion: suggestion)
99+ } else {
100+ ToolBar ( suggestion: suggestion)
101+ }
66102 }
67103 . xcodeStyleFrame ( )
68104 }
@@ -126,6 +162,44 @@ struct CodeBlockSuggestionPanel_Bright_Preview: PreviewProvider {
126162 }
127163}
128164
165+ struct CodeBlockSuggestionPanel_CompactToolBar_Preview : PreviewProvider {
166+ static let userDefault = {
167+ let userDefault = UserDefaults ( suiteName: " CodeBlockSuggestionPanel_CompactToolBar_Preview " )
168+ userDefault? . set ( true , for: \. suggestionDisplayCompactMode)
169+ return userDefault!
170+ } ( )
171+
172+ static var previews : some View {
173+ CodeBlockSuggestionPanel ( suggestion: SuggestionProvider (
174+ code: """
175+ LazyVGrid(columns: [GridItem(.fixed(30)), GridItem(.flexible())]) {
176+ ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in // lkjaskldjalksjdlkasjdlkajslkdjas
177+ Text(viewModel.suggestion[index])
178+ .frame(maxWidth: .infinity, alignment: .leading)
179+ .multilineTextAlignment(.leading)
180+ }
181+ """ ,
182+ language: " swift " ,
183+ startLineIndex: 8 ,
184+ suggestionCount: 2 ,
185+ currentSuggestionIndex: 0
186+ ) , suggestionDisplayCompactMode: . init(
187+ wrappedValue: true ,
188+ " suggestionDisplayCompactMode " ,
189+ store: Self . userDefault
190+ ) )
191+ . preferredColorScheme ( . light)
192+ . frame ( width: 450 , height: 400 )
193+ . background {
194+ HStack {
195+ Color . red
196+ Color . green
197+ Color . blue
198+ }
199+ }
200+ }
201+ }
202+
129203struct CodeBlockSuggestionPanel_Dark_Objc_Preview : PreviewProvider {
130204 static var previews : some View {
131205 CodeBlockSuggestionPanel ( suggestion: SuggestionProvider (
0 commit comments