-
Notifications
You must be signed in to change notification settings - Fork 0
[#179] iOS 17의 TodoListView의 searchable이 포커싱 될 때 툴바가 보이는 현상을 해결한다 #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -251,9 +251,6 @@ | |
| }, | ||
| "검색어를 입력해 저장한 앱 컨텐츠를 찾아보세요." : { | ||
|
|
||
| }, | ||
| "검색어를 입력해주세요." : { | ||
|
|
||
| }, | ||
| "계정 삭제" : { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,28 @@ struct TodoListView: View { | |
|
|
||
| var body: some View { | ||
| Group { | ||
| if viewModel.state.isSearching { | ||
| todoSearchContent | ||
| if #available(iOS 18, *) { | ||
| if viewModel.state.isSearching { | ||
| todoSearchContent | ||
| } else { | ||
| todoListContent | ||
| } | ||
| } else { | ||
| todoListContent | ||
| Group { | ||
| if viewModel.state.searchText.isEmpty { | ||
| todoListContent | ||
| } else { | ||
| searchResultsContent | ||
| } | ||
| } | ||
| .searchable( | ||
| text: Binding( | ||
| get: { viewModel.state.searchText }, | ||
| set: { viewModel.send(.setSearchText($0)) } | ||
| ), | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "\(viewModel.state.kind.localizedName) 검색" | ||
| ) | ||
| } | ||
| } | ||
| .navigationDestination(for: Path.self) { path in | ||
|
|
@@ -74,11 +92,13 @@ struct TodoListView: View { | |
| if #available(iOS 26.0, *) { | ||
| ToolbarSpacer(.fixed, placement: .topBarTrailing) | ||
| } | ||
| ToolbarItem(placement: .topBarTrailing) { | ||
| Button { | ||
| viewModel.send(.setIsSearching(true)) | ||
| } label: { | ||
| Image(systemName: "magnifyingglass") | ||
| if #available(iOS 18, *) { | ||
| ToolbarItem(placement: .topBarTrailing) { | ||
| Button { | ||
| viewModel.send(.setIsSearching(true)) | ||
| } label: { | ||
| Image(systemName: "magnifyingglass") | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+95
to
103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
@@ -152,31 +172,33 @@ struct TodoListView: View { | |
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| @available(iOS 18, *) | ||
| private var todoSearchContent: some View { | ||
| let searchTextBinding = Binding( | ||
| get: { viewModel.state.searchText }, | ||
| set: { viewModel.send(.setSearchText($0)) } | ||
| ) | ||
| let isSearchingBinding = Binding( | ||
| get: { viewModel.state.isSearching }, | ||
| set: { viewModel.send(.setIsSearching($0)) } | ||
| ) | ||
| searchResultsContent | ||
| .searchable( | ||
| text: Binding( | ||
| get: { viewModel.state.searchText }, | ||
| set: { viewModel.send(.setSearchText($0)) } | ||
| ), | ||
| isPresented: Binding( | ||
| get: { viewModel.state.isSearching }, | ||
| set: { viewModel.send(.setIsSearching($0)) } | ||
| ), | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "\(viewModel.state.kind.localizedName) 검색" | ||
| ) | ||
| } | ||
|
|
||
| private var searchResultsContent: some View { | ||
| let searchResults = viewModel.state.searchResults | ||
| let limit = viewModel.searchResultsLimit | ||
| let displayedTodos = viewModel.state.showAllSearchResults | ||
| ? searchResults | ||
| : Array(searchResults.prefix(limit)) | ||
|
|
||
| let content = ScrollView { | ||
| return ScrollView { | ||
| LazyVStack(spacing: 0) { | ||
| if viewModel.state.searchText.isEmpty { | ||
| Text("검색어를 입력해주세요.") | ||
| .foregroundStyle(Color.gray) | ||
| .frame(maxWidth: .infinity) | ||
| .padding(.top, 40) | ||
| } else if viewModel.state.isLoading { | ||
| if viewModel.state.isLoading { | ||
| LoadingView() | ||
| .padding(.top, 40) | ||
| } else if searchResults.isEmpty { | ||
|
|
@@ -209,28 +231,6 @@ struct TodoListView: View { | |
| } | ||
| } | ||
| } | ||
|
|
||
| Group { | ||
| if #available(iOS 17.0, *) { | ||
| content.searchable( | ||
| text: searchTextBinding, | ||
| isPresented: isSearchingBinding, | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "\(viewModel.state.kind.localizedName) 검색" | ||
| ) | ||
| } else { | ||
| content.searchable( | ||
| text: searchTextBinding, | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "\(viewModel.state.kind.localizedName) 검색" | ||
| ) | ||
| } | ||
| } | ||
| .onAppear { | ||
| DispatchQueue.main.async { | ||
| viewModel.send(.setIsSearching(true)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private var headerView: some View { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,16 +59,7 @@ struct SearchView: View { | |
|
|
||
| @ViewBuilder | ||
| private var searchableContent: some View { | ||
| let searchQueryBinding = Binding( | ||
| get: { viewModel.state.searchQuery }, | ||
| set: { viewModel.send(.setSearchQuery($0)) } | ||
| ) | ||
| let searchingBinding = Binding( | ||
| get: { viewModel.state.isSearching }, | ||
| set: { viewModel.send(.setSearching($0)) } | ||
| ) | ||
|
|
||
| let scrollContent = ScrollView { | ||
| ScrollView { | ||
| LazyVStack(alignment: .leading, spacing: 0) { | ||
| if viewModel.state.isLoading { | ||
| LoadingView() | ||
|
|
@@ -86,23 +77,18 @@ struct SearchView: View { | |
| } | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| } | ||
|
|
||
| Group { | ||
| if #available(iOS 17.0, *) { | ||
| scrollContent.searchable( | ||
| text: searchQueryBinding, | ||
| isPresented: searchingBinding, | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "검색" | ||
| ) | ||
| } else { | ||
| scrollContent.searchable( | ||
| text: searchQueryBinding, | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "검색" | ||
| ) | ||
| } | ||
| } | ||
| .searchable( | ||
| text: Binding( | ||
| get: { viewModel.state.searchQuery }, | ||
| set: { viewModel.send(.setSearchQuery($0)) } | ||
| ), | ||
| isPresented: Binding( | ||
| get: { viewModel.state.isSearching }, | ||
| set: { viewModel.send(.setSearching($0)) } | ||
| ), | ||
| placement: .navigationBarDrawer(displayMode: .always), | ||
| prompt: "검색" | ||
| ) | ||
|
Comment on lines
+80
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .onSubmit(of: .search) { | ||
| viewModel.send(.addRecentQuery(viewModel.state.searchQuery)) | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if #available(iOS 26.0, *)구문은 오타인 것 같습니다.ToolbarSpacer는 iOS 16.0부터 사용 가능하므로iOS 16.0으로 수정해야 합니다. 현재 코드는 의도한 대로 동작하지 않을 수 있습니다.