-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
176 additions
and
132 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// ToolbarSearchBar.swift | ||
// RedditOs | ||
// | ||
// Created by Thomas Ricouard on 28/07/2020. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct QuickSearchBar: View { | ||
@EnvironmentObject private var searchState: QuickSearchState | ||
@State private var isFocused = false | ||
@State private var isPopoverPresented = false | ||
|
||
let showSuggestionPopover: Bool | ||
let onCommit: () -> Void | ||
let onCancel: () -> Void | ||
|
||
var body: some View { | ||
SearchBarView(searchText: $searchState.searchText) { editing in | ||
if showSuggestionPopover { | ||
isPopoverPresented = editing | ||
} | ||
} onCommit: { | ||
onCommit() | ||
} onCancel: { | ||
onCancel() | ||
} | ||
.keyboardShortcut("f", modifiers: .command) | ||
.popover(isPresented: $isPopoverPresented) { | ||
ScrollView { | ||
VStack(alignment: .leading) { | ||
QuickSearchResultsView() | ||
}.padding() | ||
}.frame(width: 300, height: 500) | ||
} | ||
} | ||
} | ||
|
||
struct QuickSearchBar_Previews: PreviewProvider { | ||
static var previews: some View { | ||
QuickSearchBar(showSuggestionPopover: true, | ||
onCommit: { }, | ||
onCancel: { }).environmentObject(QuickSearchState()) | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.