-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from OneBusAway/presentation-manager
Presentation manager
- Loading branch information
Showing
7 changed files
with
107 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// SearchView.swift | ||
// OTPKit | ||
// | ||
// Created by Aaron Brethorst on 8/11/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A reusable Search control suitable for displaying in the header of a view. | ||
struct SearchView: View { | ||
var placeholder: String | ||
@Binding var searchText: String | ||
@FocusState var isSearchFocused: Bool | ||
|
||
var body: some View { | ||
HStack { | ||
Image(systemName: "magnifyingglass") | ||
TextField(placeholder, text: $searchText) | ||
.autocorrectionDisabled() | ||
.focused($isSearchFocused) | ||
} | ||
.padding(.vertical, 8) | ||
.padding(.horizontal, 12) | ||
.background(Color.gray.opacity(0.2)) | ||
.clipShape(RoundedRectangle(cornerRadius: 12)) | ||
} | ||
} | ||
|
||
// #Preview { | ||
// SearchView() | ||
// } |
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
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,25 @@ | ||
// | ||
// PresentationManager.swift | ||
// OTPKit | ||
// | ||
// Created by Aaron Brethorst on 8/11/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Manages the presentation state of dependent modal sheets. | ||
/// | ||
/// In other words, instead of having to maintain several independent boolean values for determining which | ||
/// sheet is currently visible, you can use `PresentationManager` to DRY up and orchestrate your | ||
/// modal sheet state. | ||
class PresentationManager<PresentationType: Identifiable>: ObservableObject { | ||
@Published var activePresentation: PresentationType? | ||
|
||
func present(_ presentationType: PresentationType) { | ||
activePresentation = presentationType | ||
} | ||
|
||
func dismiss() { | ||
activePresentation = nil | ||
} | ||
} |
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