Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions berkeley-mobile/Data/BMEventManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ class BMEventManager {
private(set) var doesEventsExistInCalendarDict: [String: Bool] = [:]

func addEventToCalendar(calendarEvent: BMCalendarEvent) async throws {
if #available(iOS 17.0, *) {
try await eventStore.requestFullAccessToEvents()
} else {
try await eventStore.requestAccess(to: .event)
}
try await eventStore.requestAccess(to: .event)

try await saveEvent(calendarEvent)

Expand Down Expand Up @@ -110,11 +106,10 @@ class BMEventManager {

do {
try eventStore.save(event, span: .thisEvent)
if #available(iOS 17.0, *) {
let authStatus = EKEventStore.authorizationStatus(for: .event)
if authStatus == .writeOnly {
throw BMError.mayExistedInCalendarAlready
}

let authStatus = EKEventStore.authorizationStatus(for: .event)
if authStatus == .writeOnly {
throw BMError.mayExistedInCalendarAlready
}
} catch {
if let ekError = error as? EKError, ekError.errorCode == 1 {
Expand Down
9 changes: 1 addition & 8 deletions berkeley-mobile/Home/BMHomeSectionListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ struct BMHomeSectionListView: View {
if #unavailable(iOS 26.0) {
sectionHeaderView
}

if #available(iOS 17.0, *) {
listView
.contentMargins(.top, 0)
.contentMargins([.leading, .trailing], 5)
} else {
listView
}
listView
}
.padding()
.background(Color(BMColor.cardBackground))
Expand Down
9 changes: 1 addition & 8 deletions berkeley-mobile/Home/Map/MapUserLocationButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ struct MapUserLocationButton: View {
}
}
}) {
if #available(iOS 17.0, *) {
locationImage
.contentTransition (
.symbolEffect(.replace)
)
} else {
locationImage
}
locationImage
}
.buttonStyle(BMControlButtonStyle())
}
Expand Down
10 changes: 2 additions & 8 deletions berkeley-mobile/Safety/SafetyLogDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ struct SafetyLogDetailView: View {
if let selectedSafetyLog = selectedSafetyLog {
let mapRegion = MKCoordinateRegion(center: selectedSafetyLog.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
Group {
if #available(iOS 17.0, *) {
Map(bounds: MapCameraBounds(centerCoordinateBounds: mapRegion, minimumDistance: 2000)) {
SafetyMapMarker(safetyLog: selectedSafetyLog)
}
} else {
Map(coordinateRegion: .constant(mapRegion), annotationItems: [selectedSafetyLog]) { safetyLog in
MapPin(coordinate: safetyLog.coordinate)
}
Map(coordinateRegion: .constant(mapRegion), annotationItems: [selectedSafetyLog]) { safetyLog in
MapPin(coordinate: safetyLog.coordinate)
}
}
.allowsHitTesting(false)
Expand Down
9 changes: 3 additions & 6 deletions berkeley-mobile/Safety/SafetyMapMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import MapKit
import SwiftUI

@available(iOS 17.0, *)
struct SafetyMapMarker: MapContent {
@EnvironmentObject var safetyViewModel: SafetyViewModel

Expand All @@ -25,10 +24,8 @@ struct SafetyMapMarker: MapContent {
}

#Preview {
if #available(iOS 17.0, *) {
Map {
SafetyMapMarker(safetyLog: SafetyViewModel.getSampleSafetyLog())
}
.environmentObject(SafetyViewModel())
Map {
SafetyMapMarker(safetyLog: SafetyViewModel.getSampleSafetyLog())
}
.environmentObject(SafetyViewModel())
}
24 changes: 3 additions & 21 deletions berkeley-mobile/Safety/SafetyMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ struct SafetyMapView: View {
var isPresentingDetailView: Bool

var body: some View {
if #available(iOS 17.0, *) {
SafetyNewMapView(selectedSafetyLog: $selectedSafetyLog,
isShowingLegend: $isShowingLegend,
drawerViewState: $drawerViewState,
isPresentingDetailView: isPresentingDetailView)
} else {
oldMapView
}
oldMapView
}

private var oldMapView: some View {
Map(coordinateRegion: .constant(BMConstants.mapBoundsRegion), showsUserLocation: true, annotationItems: safetyViewModel.filteredSafetyLogs) { safetyLog in
MapPin(coordinate: safetyLog.coordinate)
Expand All @@ -39,7 +32,6 @@ struct SafetyMapView: View {

// MARK: - SafetyNewMapView

@available(iOS 17.0, *)
struct SafetyNewMapView: View {
@EnvironmentObject var safetyViewModel: SafetyViewModel

Expand Down Expand Up @@ -110,17 +102,8 @@ struct SafetyNewMapView: View {
HStack(alignment: .top, spacing: 10) {
if #unavailable(iOS 26.0) {
VStack {
if #available(iOS 17.0, *) {
mapLegendButton
.contentTransition(
.symbolEffect(.replace)
)
} else {
mapLegendButton
}

mapLegendButton
mapZoomInButton

}
.buttonStyle(BMControlButtonStyle())
}
Expand Down Expand Up @@ -203,7 +186,6 @@ struct SafetyNewMapView: View {
}
}

@available(iOS 17.0, *)
#Preview {
@Previewable @State var drawerViewState = BMDrawerViewState.medium
SafetyMapView(selectedSafetyLog: .constant(nil), drawerViewState: $drawerViewState, isPresentingDetailView: false)
Expand Down
5 changes: 0 additions & 5 deletions berkeley-mobile/Safety/SafetyViewFilterScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ struct SafetyViewFilterScrollView: View {
}
}
}
.modify {
if #available(iOS 17.0, *) {
$0.scrollClipDisabled()
}
}
.scrollIndicators(.hidden)
}
}