Skip to content

Commit

Permalink
Add animation of showing filter fields
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed May 3, 2024
1 parent bdf1060 commit 67214e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions XTree/XTree/Modules/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ struct MainView: View {

var body: some View {
VStack(spacing: 0) {
Color(.background).frame(height: 40).zIndex(2)
if state.toolbar.isFiltersBlockShown {
FiltersView(
filtersState: $state.filters,
focusState: _focusState,
onSubmit: update
)
.padding(.horizontal, 12)
.transition(.move(edge: .top).combined(with: .blurReplace))
}
ZStack {
Color.clear
Expand All @@ -36,6 +38,7 @@ struct MainView: View {
.opacity(!state.toolbar.isProcessing && (state.isInDropArea || state.tree == nil) ? 1 : 0)
}
}
.ignoresSafeArea()
.toolbar {
ToolBarView(
state: $state.toolbar,
Expand Down
7 changes: 5 additions & 2 deletions XTree/XTree/Modules/Main/ToolBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ struct ToolBarView: View {
var body: some View {
Button(action: {
if focusState != nil { restore = focusState }
state.isFiltersBlockShown.toggle()
if focusState == nil { focusState = restore ?? .roots }
withAnimation(.easeInOut(duration: 0.3), {
state.isFiltersBlockShown.toggle()
}, completion: {
if focusState == nil { focusState = restore ?? .roots }
})
}, label: {
Image(systemName: "magnifyingglass.circle.fill")
.imageScale(.large)
Expand Down

0 comments on commit 67214e6

Please sign in to comment.