Skip to content

Commit

Permalink
Change trash icon with sync one
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed May 5, 2024
1 parent 50dbc16 commit 2d9f4ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion XTree/XTree/Modules/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct MainView: View {
.toolbar {
ToolBarView(
state: $state.toolbar,
onTrash: { state.tree = nil },
onUpdate: update,
focusState: _focusState
)
.disabled(state.tree == nil)
Expand Down
77 changes: 40 additions & 37 deletions XTree/XTree/Modules/ToolBar/ToolBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,55 @@ struct ToolBarState {

struct ToolBarView: View {
@Binding var state: ToolBarState
var onTrash: () -> Void
var onUpdate: () -> Void

@FocusState var focusState: FocusField?
@State private var restore: FocusField?

var body: some View {
Button(action: {
if focusState != nil { restore = focusState }
withAnimation(.easeInOut(duration: 0.3), {
state.isFiltersBlockShown.toggle()
}, completion: {
if focusState == nil { focusState = restore ?? .roots }
HStack(spacing: 0) {
Button(action: {
if focusState != nil { restore = focusState }
withAnimation(.easeInOut(duration: 0.3), {
state.isFiltersBlockShown.toggle()
}, completion: {
if focusState == nil { focusState = restore ?? .roots }
})
}, label: {
Image(systemName: "magnifyingglass.circle.fill")
.imageScale(.large)
.offset(y: 1)
})
}, label: {
Image(systemName: "magnifyingglass.circle.fill")
.keyboardShortcut(.init(.init("F"), modifiers: .command))
.help(state.isFiltersBlockShown ? "Hide filters" : "Show filters")

IconsMenu(state: $state.icons)
.help("Show or hide nodes by icon type")

Button(action: {
state.isCompressed.toggle()
}, label: {
Image(
systemName: state.isCompressed
? "arrow.up.backward.and.arrow.down.forward.circle.fill"
: "arrow.down.right.and.arrow.up.left.circle.fill"
)
.rotationEffect(.degrees(45))
.imageScale(.large)
.offset(y: 1)
})
.keyboardShortcut(.init(.init("F"), modifiers: .command))
.help(state.isFiltersBlockShown ? "Hide filters" : "Show filters")
})
.help(state.isCompressed ? "Show redundant explicit dependencies" : "Hide redundant explicit dependencies")

IconsMenu(state: $state.icons)
Button(action: {
state.isFiltersBlockShown = false
onUpdate()
}, label: {
Image(systemName: "arrow.triangle.2.circlepath.circle.fill")
.imageScale(.large)
.offset(y: 1)
})
.help("Read again the current tree input file")
}

Picker("", selection: $state.sorting) {
ForEach(state.sortingValues, id: \.self) { value in
Expand All @@ -44,30 +71,6 @@ struct ToolBarView: View {
}
.help("Sorting by")

Button(action: {
state.isCompressed.toggle()
}, label: {
Image(
systemName: state.isCompressed
? "arrow.up.backward.and.arrow.down.forward.circle.fill"
: "arrow.down.right.and.arrow.up.left.circle.fill"
)
.rotationEffect(.degrees(45))
.imageScale(.large)
.offset(y: 1)
})
.help(state.isCompressed ? "Show redundant explicit dependencies" : "Hide redundant explicit dependencies")

Button(action: {
state.isFiltersBlockShown = false
onTrash()
}, label: {
Image(systemName: "trash.circle.fill")
.imageScale(.large)
.offset(y: 1)
})
.help("Close the current tree input file")

Spacer()

if state.isProcessing {
Expand Down

0 comments on commit 2d9f4ee

Please sign in to comment.