-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add earthquake preview in map view, add link to usgs details page
- Loading branch information
Showing
5 changed files
with
99 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// EarthquakePreviewView.swift | ||
// Epicentral | ||
// | ||
// Created by Brian Sakhuja on 3/7/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct EarthquakePreviewView: View { | ||
|
||
@State private var isShowingDetails: Bool = false | ||
|
||
let earthquake: Earthquake | ||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
Text(earthquake.properties.title) | ||
.font(.headline) | ||
Spacer() | ||
} | ||
HStack { | ||
Text("Magnitude") | ||
Spacer() | ||
Text(preciseRound(earthquake.properties.magnitude, precision: .hundredths)) | ||
} | ||
HStack { | ||
Text("Date & Time") | ||
Spacer() | ||
Text(earthquake.properties.date.formatted(.dateTime)) | ||
} | ||
if let tsunami = earthquake.properties.tsunami { | ||
HStack { | ||
Text("Tsunami warning") | ||
Spacer() | ||
Text(tsunami ? "Yes" : "No") | ||
} | ||
} | ||
Button("Details") { | ||
isShowingDetails = true | ||
} | ||
} | ||
.padding() | ||
.sheet(isPresented: $isShowingDetails) { | ||
EarthquakeDetailView(earthquake: earthquake) | ||
.presentationDragIndicator(.visible) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
EarthquakePreviewView(earthquake: Earthquake.testEarthquake) | ||
} |
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