Skip to content

Commit d2c4a57

Browse files
committed
resolves #6
1 parent 1a1f0d5 commit d2c4a57

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Flitro/ContextManager.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ class ContextManager: ObservableObject {
201201
}
202202
}
203203

204+
// MARK: - Context Reordering
205+
/// Reorder contexts and persist the new order
206+
func reorderContexts(fromOffsets: IndexSet, toOffset: Int) {
207+
contexts.move(fromOffsets: fromOffsets, toOffset: toOffset)
208+
saveContexts()
209+
}
210+
204211
// MARK: - Application Management
205212

206213
func closeContextApplications(_ context: Context) {

Flitro/ContextSidebarView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct ContextSidebarView: View {
4848
.tag(context.id as UUID?)
4949
.listRowBackground(EmptyView())
5050
}
51+
.onMove { indices, newOffset in
52+
contextManager.reorderContexts(fromOffsets: indices, toOffset: newOffset)
53+
}
5154
}
5255
.listStyle(.sidebar)
5356
.frame(maxWidth: .infinity, alignment: .leading)

0 commit comments

Comments
 (0)