-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularized root view in iOS application.
- Loading branch information
Showing
6 changed files
with
205 additions
and
150 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,52 @@ | ||
import SwiftUI | ||
|
||
struct ActionButtonsView: View { | ||
@ObservedObject var viewModel: ContentViewModel | ||
@Binding var searchText: String | ||
@Binding var destination: ContentView.Destination? | ||
|
||
var body: some View { | ||
VStack { | ||
// Share Location Button | ||
Button(action: { | ||
viewModel.requestLocation() | ||
print("Requesting location...") | ||
}) { | ||
Label("Share Location", systemImage: "location.fill") | ||
.frame(maxWidth: .infinity) | ||
} | ||
.padding() | ||
.background(Color.blue) | ||
.foregroundColor(.white) | ||
.cornerRadius(10) | ||
.shadow(color: .black.opacity(0.5), radius: 5, x: 2, y: 2) | ||
|
||
Text("OR") | ||
.foregroundColor(.black) | ||
.padding(.vertical, 8) | ||
|
||
// Search Bar | ||
SearchBarView( | ||
searchText: $searchText, | ||
onSearch: { text in | ||
print("Setting navigationTarget to .search with \(searchText)") | ||
destination = .search(text) | ||
} | ||
) | ||
.frame(maxWidth: .infinity) // Make search bar fill available width | ||
.padding(.horizontal, 16) | ||
.padding(.vertical, 8) | ||
.background(Color.white) | ||
.cornerRadius(8) | ||
.shadow(color: .gray.opacity(0.5), radius: 5, x: 2, y: 2) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
ActionButtonsView( | ||
viewModel: ContentViewModel(), | ||
searchText: .constant(""), | ||
destination: .constant(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
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 |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import SwiftUI | ||
|
||
struct PlaceholderView: View { | ||
var location: GeoLocation? = nil | ||
var searchString: String? = nil | ||
|
||
var location: GeoLocation? | ||
var searchString: String? | ||
var onDisappear: () -> Void // Closure to reset location | ||
|
||
var body: some View { | ||
VStack { | ||
if let location = location { | ||
Text("Latitude: \(location.latitude)") | ||
Text("Longitude: \(location.longitude)") | ||
Text("Location: \(location.latitude), \(location.longitude)") | ||
.font(.title) | ||
.padding() | ||
} else if let searchString = searchString { | ||
Text("Search Query: \(searchString)") | ||
.font(.title) | ||
.padding() | ||
} else { | ||
Text("No data available.") | ||
.font(.title) | ||
.padding() | ||
} | ||
} | ||
.padding() | ||
.navigationTitle("Results") | ||
.onDisappear { | ||
onDisappear() // Call the closure when the view disappears | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
PlaceholderView(location: GeoLocation(latitude: 37.7749, longitude: -122.4194), searchString: nil, onDisappear: {}) | ||
} |
Oops, something went wrong.