diff --git a/berkeley-mobile.xcodeproj/project.pbxproj b/berkeley-mobile.xcodeproj/project.pbxproj index 961655f3c..ad028106d 100644 --- a/berkeley-mobile.xcodeproj/project.pbxproj +++ b/berkeley-mobile.xcodeproj/project.pbxproj @@ -115,6 +115,10 @@ 55DCF78923722CF1001B01B8 /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DCF78823722CF1001B01B8 /* Fonts.swift */; }; 55DCF79623723CF2001B01B8 /* UIView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DCF79523723CF2001B01B8 /* UIView+Extensions.swift */; }; C14CCB612D9CC2730075FE69 /* BMFilterButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C14CCB602D9CC2680075FE69 /* BMFilterButton.swift */; }; + C60EC4352ED5641B007195A0 /* DistanceLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60EC4342ED56412007195A0 /* DistanceLabelView.swift */; }; + C67BE4412ED12A6E0037005D /* BMSortOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67BE4402ED12A6E0037005D /* BMSortOption.swift */; }; + C67BE4432ED12AFE0037005D /* BMSortMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67BE4422ED12AFB0037005D /* BMSortMenuView.swift */; }; + C67BE4452ED12B730037005D /* BMSortEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67BE4442ED12B6E0037005D /* BMSortEngine.swift */; }; E80330EB2CE431C200DC9574 /* DepthButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E80330EA2CE431C200DC9574 /* DepthButtonStyle.swift */; }; E80330ED2CE7EBB100DC9574 /* NSCoding+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E80330EC2CE7EBB100DC9574 /* NSCoding+Extension.swift */; }; E80ECC312AFB02BA004604BA /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = E80ECC302AFB02BA004604BA /* Secrets.swift */; }; @@ -337,6 +341,10 @@ 55DCF79523723CF2001B01B8 /* UIView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extensions.swift"; sourceTree = ""; }; 61D128E68A4FC209FFCDE60F /* Pods-berkeley-mobile.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-berkeley-mobile.release.xcconfig"; path = "Target Support Files/Pods-berkeley-mobile/Pods-berkeley-mobile.release.xcconfig"; sourceTree = ""; }; C14CCB602D9CC2680075FE69 /* BMFilterButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMFilterButton.swift; sourceTree = ""; }; + C60EC4342ED56412007195A0 /* DistanceLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DistanceLabelView.swift; sourceTree = ""; }; + C67BE4402ED12A6E0037005D /* BMSortOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMSortOption.swift; sourceTree = ""; }; + C67BE4422ED12AFB0037005D /* BMSortMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMSortMenuView.swift; sourceTree = ""; }; + C67BE4442ED12B6E0037005D /* BMSortEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMSortEngine.swift; sourceTree = ""; }; E80330EA2CE431C200DC9574 /* DepthButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepthButtonStyle.swift; sourceTree = ""; }; E80330EC2CE7EBB100DC9574 /* NSCoding+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSCoding+Extension.swift"; sourceTree = ""; }; E80330EE2CE9A8EB00DC9574 /* berkeley-mobile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "berkeley-mobile.entitlements"; sourceTree = ""; }; @@ -676,6 +684,7 @@ 2913595524B135B600DE9AD6 /* DetailView */ = { isa = PBXGroup; children = ( + C60EC4342ED56412007195A0 /* DistanceLabelView.swift */, 01BC8EAF24E8C3E3005B4969 /* DetailView.swift */, 01FA50F224E8BA5400DCC490 /* LocationDetailView.swift */, 29345E2624A7E76300859A88 /* OverviewCardView.swift */, @@ -1225,6 +1234,7 @@ 29345E2724A7E76300859A88 /* OverviewCardView.swift in Sources */, 01D11B902504560700BDF660 /* GymDetailViewController.swift in Sources */, 55AF442D2453ACE600F13232 /* BMDiningLocation.swift in Sources */, + C60EC4352ED5641B007195A0 /* DistanceLabelView.swift in Sources */, 136DC97B2398B4D1009B1810 /* UIViewController+Extensions.swift in Sources */, 2913595724B136BE00DE9AD6 /* CollapsibleCardView.swift in Sources */, E83C6CED2B71DF190085E277 /* SafariWebView.swift in Sources */, diff --git a/berkeley-mobile/Common/DetailView/DistanceLabelView.swift b/berkeley-mobile/Common/DetailView/DistanceLabelView.swift new file mode 100644 index 000000000..6d3365800 --- /dev/null +++ b/berkeley-mobile/Common/DetailView/DistanceLabelView.swift @@ -0,0 +1,25 @@ +// +// DistanceLabelView.swift +// berkeley-mobile +// +// Created by Ananya Dua on 11/24/25. +// Copyright © 2025 ASUC OCTO. All rights reserved. +// + +import SwiftUI + +struct DistanceLabelView: View { + let distance: Double? + + var body: some View { + HStack { + Image(systemName: "figure.walk") + .foregroundStyle(Color(BMColor.blackText)) + .font(.system(size: 12)) + + Text("\(distance ?? 0.0, specifier: "%.1f") mi") + .foregroundStyle(Color(BMColor.blackText)) + .font(Font(BMFont.light(12))) + } + } +} diff --git a/berkeley-mobile/Home/Guides/GuideDetailView.swift b/berkeley-mobile/Home/Guides/GuideDetailView.swift index 586ab7b69..bcfa7c6d2 100644 --- a/berkeley-mobile/Home/Guides/GuideDetailView.swift +++ b/berkeley-mobile/Home/Guides/GuideDetailView.swift @@ -57,11 +57,18 @@ struct GuideDetailRowHeaderView: View { .frame(maxWidth: 370) .frame(height: 220) .clipped() + VStack { Spacer() + HStack(spacing: 10) { - Text(place.name) - .font(Font(BMFont.bold(20))) + VStack(alignment: .leading, spacing: 4) { + Text(place.name) + .font(Font(BMFont.bold(20))) + + DistanceLabelView(distance: place.distanceToUser) + } + Spacer() if place.hasWebsite { @@ -75,7 +82,7 @@ struct GuideDetailRowHeaderView: View { viewModel.call(place) } } - + if place.hasCoordinate { GuideDetailRowActionItemView(systemName: "map", backgroundColor: .blue) { viewModel.openPlaceInMaps(for: place) @@ -89,22 +96,19 @@ struct GuideDetailRowHeaderView: View { } } .fullScreenCover(isPresented: $isPresentingWebView) { - if let websiteURLString = place.websiteURLString, let url = URL(string: websiteURLString) { + if let urlString = place.websiteURLString, + let url = URL(string: urlString) { SafariWebView(url: url) } } } } - // MARK: - GuideDetailRowActionItemView struct GuideDetailRowActionItemView: View { - @Environment(GuidesViewModel.self) private var viewModel - var systemName: String var backgroundColor: Color - var actionHandler: () -> Void var body: some View { diff --git a/berkeley-mobile/Home/HomeSectionListRowView.swift b/berkeley-mobile/Home/HomeSectionListRowView.swift index a5d13ef62..3985719c7 100644 --- a/berkeley-mobile/Home/HomeSectionListRowView.swift +++ b/berkeley-mobile/Home/HomeSectionListRowView.swift @@ -21,7 +21,7 @@ struct HomeSectionListRowView: View { HStack { Group { openClosedStatusView - distanceLabelView + DistanceLabelView(distance: rowItem.distanceToUser) } .applyHomeDrawerRowAttributesStyle() } @@ -43,27 +43,27 @@ struct HomeSectionListRowView: View { } } - private var distanceLabelView: some View { - HStack { - Image(systemName: "figure.walk") - .foregroundStyle(Color(BMColor.blackText)) - .font(.system(size: 12)) - - Text("\(rowItem.distanceToUser ?? 0.0, specifier: "%.1f") mi") - .foregroundStyle(Color(BMColor.blackText)) - .font(Font(BMFont.light(12))) - } - } - private var imageView: some View { - BMCachedAsyncImageView(imageURL: rowItem.imageURL, placeholderImage: BMConstants.doeGladeImage, aspectRatio: .fill) - .frame(maxWidth: 80, maxHeight: 80) - .clipShape(RoundedRectangle(cornerRadius: 12)) + BMCachedAsyncImageView( + imageURL: rowItem.imageURL, + placeholderImage: BMConstants.doeGladeImage, + aspectRatio: .fill + ) + .frame(maxWidth: 80, maxHeight: 80) + .clipShape(RoundedRectangle(cornerRadius: 12)) } } #Preview { - let foothillDiningHall = BMDiningHall(name: "Foothill", address: nil, phoneNumber: nil, imageLink: "https://firebasestorage.googleapis.com/v0/b/berkeley-mobile.appspot.com/o/images%2FFoothill.jpg?alt=media&token=b645d675-6f51-45ea-99f7-9b36576e14b7", hours: [], latitude: 37.87538, longitude: -122.25612109999999) + let foothillDiningHall = BMDiningHall( + name: "Foothill", + address: nil, + phoneNumber: nil, + imageLink: "https://firebasestorage.googleapis.com/v0/b/berkeley-mobile.appspot.com/o/images%2FFoothill.jpg?alt=media&token=b645d675-6f51-45ea-99f7-9b36576e14b7", + hours: [], + latitude: 37.87538, + longitude: -122.25612109999999 + ) return HomeSectionListRowView(rowItem: foothillDiningHall) .padding(40)