From 6948c50e7a14fb146dcb34c304b361f68235ca8b Mon Sep 17 00:00:00 2001 From: Harry Owen Date: Tue, 8 Oct 2024 18:48:34 +0100 Subject: [PATCH] Implemented Phone Numbers Added the ability to give Location's Phone Numbers and to be able to call them on the detail view. --- Code Relay/Code Relay.xcodeproj/project.pbxproj | 2 ++ Code Relay/Code Relay/ContentView.swift | 2 +- Code Relay/Code Relay/DetailsView.swift | 7 +++++++ Code Relay/Code Relay/Localizable.xcstrings | 3 +++ Code Relay/Code Relay/Location.swift | 1 + Code Relay/Code Relay/ViewModel.swift | 14 ++++++++------ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Code Relay/Code Relay.xcodeproj/project.pbxproj b/Code Relay/Code Relay.xcodeproj/project.pbxproj index c4ba27f..7534a28 100644 --- a/Code Relay/Code Relay.xcodeproj/project.pbxproj +++ b/Code Relay/Code Relay.xcodeproj/project.pbxproj @@ -254,6 +254,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Code Relay/Preview Content\""; + DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; @@ -282,6 +283,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Code Relay/Preview Content\""; + DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; diff --git a/Code Relay/Code Relay/ContentView.swift b/Code Relay/Code Relay/ContentView.swift index b917fe4..ac261e1 100644 --- a/Code Relay/Code Relay/ContentView.swift +++ b/Code Relay/Code Relay/ContentView.swift @@ -17,7 +17,7 @@ struct ContentView: View { Tab("Settings", systemImage: "gear") { SettingsView() } - } + }.tint(.red) } } diff --git a/Code Relay/Code Relay/DetailsView.swift b/Code Relay/Code Relay/DetailsView.swift index 280bfa5..c3e8eaf 100644 --- a/Code Relay/Code Relay/DetailsView.swift +++ b/Code Relay/Code Relay/DetailsView.swift @@ -24,6 +24,13 @@ struct DetailsView: View { Text(location.title).fontWeight(.bold) Text(location.details) + + Spacer() + + if let phoneNumber = location.phoneNumber { + Link("Call", destination: URL(string: "tel:\(phoneNumber)")!) + .padding() + } } .frame(maxHeight: .infinity, alignment: .top) } diff --git a/Code Relay/Code Relay/Localizable.xcstrings b/Code Relay/Code Relay/Localizable.xcstrings index 1d9325a..3869857 100644 --- a/Code Relay/Code Relay/Localizable.xcstrings +++ b/Code Relay/Code Relay/Localizable.xcstrings @@ -1,6 +1,9 @@ { "sourceLanguage" : "en", "strings" : { + "Call" : { + + }, "Developed at " : { "localizations" : { "en" : { diff --git a/Code Relay/Code Relay/Location.swift b/Code Relay/Code Relay/Location.swift index a25bb6d..6178ec1 100644 --- a/Code Relay/Code Relay/Location.swift +++ b/Code Relay/Code Relay/Location.swift @@ -11,6 +11,7 @@ struct Location: Identifiable { let title: String let details: String let coordinate: CLLocationCoordinate2D? + let phoneNumber: String? var id: String { title } } diff --git a/Code Relay/Code Relay/ViewModel.swift b/Code Relay/Code Relay/ViewModel.swift index e0ba06d..6a3f091 100644 --- a/Code Relay/Code Relay/ViewModel.swift +++ b/Code Relay/Code Relay/ViewModel.swift @@ -5,16 +5,18 @@ // Created by Sebastian Bolling on 2024-10-08. // +import CoreLocation + struct ViewModel { init() { locationsData = [ - Location(title: "Leeds Playhouse", details: "Good Conference", coordinate: nil), - Location(title: "Leeds Art Gallery", details: "Good Art", coordinate: nil), - Location(title: "Victoria Leeds", details: "Something good", coordinate: nil), - Location(title: "Royal Armouries", details: "Good Armor", coordinate: nil), - Location(title: "Brew Society", details: "Good Beer", coordinate: nil), - Location(title: "Brew Dog", details: "Good Dog Beer", coordinate: nil), + Location(title: "Leeds Playhouse", details: "Good Conference", coordinate: nil, phoneNumber: "0044 113 213 7700"), + Location(title: "Leeds Art Gallery", details: "Good Art", coordinate: nil, phoneNumber: "0044 113 378 5350"), + Location(title: "Victoria Leeds", details: "Something good", coordinate: nil, phoneNumber: "0044 113 245 5333"), + Location(title: "Royal Armouries", details: "Good Armor", coordinate: nil, phoneNumber: "0044 113 220 1916"), + Location(title: "Brew Society", details: "Good Beer", coordinate: nil, phoneNumber: nil), + Location(title: "Brew Dog", details: "Good Dog Beer", coordinate: nil, phoneNumber: "0044 113 391 2950"), ] }