-
Notifications
You must be signed in to change notification settings - Fork 9
BER-80: Converting MapMarkerDetailView into SwiftUI [WIP] #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Chhumbucket
wants to merge
42
commits into
master
Choose a base branch
from
dylchhum/ber-80
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6293188
something
Chhumbucket 72e7aec
Created SwiftUI view for MapMarkerDetail
Chhumbucket dff7222
Added Button templates
Chhumbucket a6500af
Added fixes and changes button to the formatting guide. Worried about…
Chhumbucket 7afef88
merging
Chhumbucket 0bdc698
Fixed Colors
Chhumbucket 77356ee
message
Chhumbucket 504bff5
Implemented SwiftUI Map marker, bug when on menstrual category, onclo…
Chhumbucket 83d72c1
Fixed padding
Chhumbucket bb79a60
Save before Essa
Chhumbucket 7d1e11c
Saving
Chhumbucket d273278
Merge branch 'master' of github.com:asuc-octo/berkeley-mobile-ios
Chhumbucket b93720b
BER-80: Fix project file structure after merge
Chhumbucket d48348f
Revert "Fixed padding"
Chhumbucket 152c754
Fixed the MapViewController
Chhumbucket 1d6da83
Added Justin and Baurzjohn fixes
Chhumbucket 5bc47fc
Add new line
Chhumbucket 102796f
Fix spacing
Chhumbucket c5d7da4
fixed marks
Chhumbucket af98076
Fixing space
Chhumbucket 329c5e5
Changed sizes
Chhumbucket a2ae856
Fix alignedmnet
Chhumbucket 3f048bb
Messing with changes
Chhumbucket 8b8707a
Added fixes
Chhumbucket 0d61a4d
Adding changes
Chhumbucket ac7752b
Fixed the padding, I want to make the code more modular
Chhumbucket 2a39354
Modular
Chhumbucket 6efe6d4
Fixed negative space
Chhumbucket 12c0663
adding version
Chhumbucket ffd7cb5
Merge branch 'master' of github.com:asuc-octo/berkeley-mobile-ios
Chhumbucket b25e4c1
Merge branch 'master' into dylchhum/ber-80
Chhumbucket ae98773
Merge branch 'master' of github.com:asuc-octo/berkeley-mobile-ios
Chhumbucket a7e0d43
Merge branch 'master' into dylchhum/ber-80
Chhumbucket e0b442c
Fixed crashing lost info sheet
Chhumbucket 9d09882
Fixed everything
Chhumbucket bf6a6bd
Added fixes
Chhumbucket 49062fd
Merge branch 'master' of github.com:asuc-octo/berkeley-mobile-ios
Chhumbucket 81b6135
Merge branch 'master' into dylchhum/ber-80
Chhumbucket 2b3aae2
Merge branch 'master' of github.com:asuc-octo/berkeley-mobile-ios
Chhumbucket f363f0c
pushing
Chhumbucket f3c1a44
add merge fixes
Chhumbucket 5c99411
Added Justin Fixes
Chhumbucket File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
berkeley-mobile.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
berkeley-mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
176 changes: 176 additions & 0 deletions
176
berkeley-mobile/Home/Map/MapMarkerDetailSwiftView.swift
This file contains hidden or 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,176 @@ | ||
// | ||
// MapMakerDetailSwiftView.swift | ||
// berkeley-mobile | ||
// | ||
// Created by Dylan Chhum on 3/11/25. | ||
// Copyright © 2025 ASUC OCTO. All rights reserved. | ||
// | ||
|
||
import MapKit | ||
import SwiftUI | ||
|
||
struct MapMarkerDetailSwiftView: View { | ||
var marker: MapMarker? | ||
var onClose: (() -> Void)? | ||
|
||
var body: some View { | ||
HStack { | ||
colorAccentBar | ||
|
||
VStack(alignment: .leading, spacing: 4) { | ||
headerView | ||
Spacer() | ||
descriptionView | ||
Spacer() | ||
infoRowView | ||
} | ||
.padding(.vertical, 8) | ||
Spacer() | ||
} | ||
.background(Color(BMColor.cardBackground)) | ||
.clipShape(RoundedRectangle(cornerRadius: 12)) | ||
.frame(maxWidth: .infinity) | ||
.frame(minWidth: 200, maxHeight: 140) | ||
.shadow(color: .black.opacity(0.2), radius: 5, x: 0, y: 2) | ||
.padding(.horizontal, 20) | ||
} | ||
|
||
|
||
// MARK: - Private Views | ||
|
||
private var colorAccentBar: some View { | ||
Rectangle() | ||
.fill(getMarkerColor()) | ||
.frame(width: 12) | ||
} | ||
|
||
private func getMarkerColor() -> Color { | ||
guard let marker else { | ||
return .purple | ||
} | ||
|
||
switch marker.type { | ||
case .known(let type): | ||
return Color(type.color()) | ||
case .unknown: | ||
return Color(BMColor.MapMarker.other) | ||
} | ||
} | ||
|
||
private var headerView: some View { | ||
HStack(alignment: .top) { | ||
Text((marker?.title ?? "Unknown").capitalized) | ||
.font(Font(BMFont.bold(21))) | ||
.foregroundStyle(.primary) | ||
.fixedSize(horizontal: false, vertical: true) | ||
Spacer() | ||
|
||
Button(action: { | ||
onClose?() | ||
}) { | ||
Image(systemName: "xmark") | ||
.font(.system(size: 16)) | ||
.foregroundStyle(Color.secondary) | ||
.padding(.trailing, 4) | ||
} | ||
} | ||
} | ||
|
||
private var descriptionView: some View { | ||
Text(marker?.subtitle ?? "No description") | ||
.font(Font(BMFont.regular(10))) | ||
.fixedSize(horizontal: false, vertical: true) | ||
.padding(.trailing, 8) | ||
} | ||
|
||
private var infoRowView: some View { | ||
HStack(spacing: 8) { | ||
Image(systemName: "clock") | ||
.font(.system(size: 12)) | ||
.foregroundStyle(.secondary) | ||
.rotationEffect(.init(degrees: 90)) | ||
openStatusButton | ||
|
||
Spacer() | ||
|
||
locationInfoView | ||
|
||
Spacer() | ||
|
||
categoryView | ||
} | ||
} | ||
|
||
private var openStatusButton: some View { | ||
Capsule() | ||
.fill(marker?.isOpen ?? false ? .blue : Color(red: 0.4, green: 0.5, blue: 0.9)) | ||
.frame(width: 48, height: 18) | ||
.overlay { | ||
Text(marker?.isOpen ?? false ? "Open" : "Closed") | ||
.font(Font(BMFont.medium(9))) | ||
.foregroundStyle(.white) | ||
} | ||
} | ||
|
||
private var locationInfoView: some View { | ||
HStack(spacing: 8) { | ||
Image(systemName: "mappin.and.ellipse") | ||
.font(.system(size: 12)) | ||
.foregroundStyle(.secondary) | ||
Text(marker?.address ?? "No Address") | ||
.font(Font(BMFont.regular(12))) | ||
.foregroundColor(.primary) | ||
.minimumScaleFactor(0.5) | ||
.lineLimit(2) | ||
} | ||
} | ||
|
||
private var categoryView: some View { | ||
HStack(spacing: 8){ | ||
if let marker, case .known(let type) = marker.type { | ||
Image(uiImage: type.icon()) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 12, height: 12) | ||
.foregroundStyle(.secondary) | ||
} else { | ||
Image(systemName: "mappin") | ||
.font(.system(size: 12)) | ||
.foregroundStyle(.secondary) | ||
} | ||
|
||
if let marker, case .known(let type) = marker.type, type == .cafe, let mealPrice = marker.mealPrice { | ||
Text(mealPrice) | ||
.font(Font(BMFont.regular(12))) | ||
.foregroundColor(.primary) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
// MARK: - Preview | ||
|
||
#Preview { | ||
MapMarkerDetailSwiftView( | ||
marker: MapMarker( | ||
type: "Cafe", | ||
location: CLLocationCoordinate2D(latitude: 37.871684, longitude: -122.259934), | ||
name: "Babette South Hall Coffee Bar", | ||
description: "A retail Cal Dining location featuring a Peet Coffee & tea store, made- to-go order deli and bagels bar, smoothies, and grab-and-go items.", | ||
address: "Lower Sproul Plaza", | ||
onCampus: true, | ||
phone: "510-123-4567", | ||
email: "[email protected]", | ||
weeklyHours: nil, | ||
appointment: false, | ||
mealPrice: "$5-10", | ||
cal1Card: true, | ||
eatWell: true, | ||
mpdRooms: nil, | ||
accessibleGIRs: nil, | ||
nonAccesibleGIRs: nil | ||
), | ||
onClose: {} | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.