Skip to content
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

Update App branding and add new features #15

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "150",
"green" : "70",
"red" : "96"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "150",
"green" : "70",
"red" : "96"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "150",
"green" : "70",
"red" : "96"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
1 change: 1 addition & 0 deletions apps/ios/GuideDogs/Assets/PropertyLists/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>googlegmail</string>
<string>ms-outlook</string>
<string>ymail</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Licensed under the MIT License.
//

import Foundation
import UIKit
import SwiftUI

extension Gradient {
Expand All @@ -31,5 +31,13 @@ extension Gradient {
Color(.sRGB, red: 0.101, green: 0.406, blue: 0.608, opacity: 1)
])
}


static var palePurple: Gradient {
let uiColor1 = UIColor(hex: "#1c0549")
let uiColor2 = UIColor(hex: "#7e87cb")

let color1 = Color(uiColor1)
let color2 = Color(uiColor2)
return Gradient(colors: [color1, color2])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import CoreLocation

enum MailClient: String, CaseIterable {

Expand Down Expand Up @@ -43,6 +44,33 @@ enum MailClient: String, CaseIterable {
}
}

enum MapsApp: String, CaseIterable {
case apple
case google
case waze

static let defaultMapZoom: Int = 10

var localizedTitle: String {
switch self {
case .apple: return "Apple Maps"
case .google: return "Google Maps"
case .waze: return "Waze"
}
}

func url(for location: CLLocation, name: String) -> URL? {
switch self {
case .apple:
return URL(string: "https://maps.apple.com/?q=\(location.coordinate.latitude.roundToDecimalPlaces(2)),\(location.coordinate.longitude.roundToDecimalPlaces(2))&ll=\(location.coordinate.latitude),\(location.coordinate.longitude)&z=\(MapsApp.defaultMapZoom)&t=s")
case .google:
return URL(string: "https://www.google.com/maps/search/?api=1&query=\(location.coordinate.latitude)%2C\(location.coordinate.longitude)")
case .waze:
return URL(string: "https://www.waze.com/ul?ll=\(location.coordinate.latitude)%2C\(location.coordinate.longitude)&zoom=\(MapsApp.defaultMapZoom)")
}
}
}

extension UIAlertController {
/// Create and return a `UIAlertController` that is able to send an email with external email clients
convenience init(email: String, subject: String, preferredStyle: UIAlertController.Style, handler: ((MailClient?) -> Void)? = nil) {
Expand Down Expand Up @@ -71,4 +99,34 @@ extension UIAlertController {

self.addAction(UIAlertAction(title: GDLocalizedString("general.alert.cancel"), style: .cancel, handler: nil))
}

/// Create and return a `UIAlertController` that is able to open a map location in an external maps app
convenience init(locationDetail: LocationDetail, preferredStyle: UIAlertController.Style, handler: ((MapsApp?) -> Void)? = nil) {

// Create alert actions for each support maps application
let actions = MapsApp.allCases.compactMap { (mapApp) -> UIAlertAction? in
guard let url = mapApp.url(for: locationDetail.location, name: locationDetail.displayName) else {
return nil
}
return UIAlertAction(title: mapApp.localizedTitle, url: url) {
handler?(mapApp)
}
}

if actions.isEmpty {
self.init(title: GDLocalizedString("general.error.error_occurred"),
message: "No maps app installed",
preferredStyle: .alert)
} else {
self.init(title: GDLocalizedString("general.alert.choose_an_app"),
message: nil,
preferredStyle: preferredStyle)

actions.forEach({ action in
self.addAction(action)
})
}

self.addAction(UIAlertAction(title: GDLocalizedString("general.alert.cancel"), style: .cancel, handler: nil))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension UINavigationBarAppearance {
case .darkBlue: configureWithOpaqueBackground()
}


// Background and foreground colors
backgroundColor = navigationBarStyle.backgroundUIColor
titleTextAttributes = [.foregroundColor: navigationBarStyle.foregroundUIColor]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ServiceModel {
static let errorRealm = "GDAHTTPErrorRealm"

private static let productionServicesHostName =
"https://soundscape.scottishtecharmy.org/"
"https://prd2.soundscape.scottishtecharmy.org/"
private static let productionAssestsHostName = "https://yourstaticblobstore"
// Do not change `productionVoicesHostName`!
private static let productionVoicesHostName = "https://yourstaticblobstore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class CardStateViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// Configure the initial state
if AppContext.shared.eventProcessor.activeBehavior is RouteGuidance {
state = .route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class CustomDisclosureTableViewCell: UITableViewCell {

// Initialization code
self.accessoryView = disclosureImage

self.selectionStyle = .default
backgroundColor = Colors.Background.primary
}

func showActivityIndicator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,23 @@ class SearchResultsUpdater: NSObject {
}
}

func fetchCoordinate() -> CLLocationCoordinate2D {
guard AppContext.shared.geolocationManager.isAuthorized,
let coordinate = self.location?.coordinate
else {
return CLLocation.sample.coordinate
}
return coordinate
}

func getMKLocalSearch(searchText: String) -> MKLocalSearch {
let request = MKLocalSearch.Request()
request.naturalLanguageQuery = searchText
let coordinate = self.location!.coordinate
let coordinate = fetchCoordinate()
request.region = MKCoordinateRegion(center: coordinate, latitudinalMeters: 75000, longitudinalMeters: 75000)
let search = MKLocalSearch(request: request)
return search
}

}

// MARK: - UISearchResultsUpdating
Expand Down
28 changes: 27 additions & 1 deletion apps/ios/GuideDogs/Code/Visual UI/Themes/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Colors {
}

struct Background {
static let primary: UIColor? = UIColor(named: "Background 1")
static let primary: UIColor? = UIColor(hex: "#604696")
static let secondary: UIColor? = UIColor(named: "Background 2")
static let tertiary: UIColor? = UIColor(named: "Background 3")
static let quaternary: UIColor? = UIColor(named: "Background Base")
Expand Down Expand Up @@ -64,3 +64,29 @@ extension Color {
static let yellowHighlight = Color(Colors.Highlight.yellow!)
static let greenHighlight = Color(Colors.Highlight.green!)
}


// MARK: - Hex colors

public extension UIColor {

convenience init(hex: UInt32) {
self.init(
red: CGFloat((hex & 0xFF0000) >> 16) / 255.0,
green: CGFloat((hex & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(hex & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}

convenience init(hex: String) {
var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")

guard let intHex = UInt32(hexSanitized, radix: 16) else {
fatalError("Incorrect string hex")
}

self.init(hex: intHex)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,10 @@ class CalloutButtonPanelViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Configure header
headerLabel.text = GDLocalizedString("callouts.panel.title").uppercasedWithAppLocale()


stylize()
configureButtonLabels()

NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleLocateNotification), name: Notification.Name.didToggleLocate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleOrientateNotification), name: Notification.Name.didToggleOrientate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleLookAheadNotification), name: Notification.Name.didToggleLookAhead, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleMarkedPointsNotification), name: Notification.Name.didToggleMarkedPoints, object: nil)
setNotification()
}

override func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -99,7 +93,20 @@ class CalloutButtonPanelViewController: UIViewController {
element.accessibilityIdentifier = "btn.nearbymarkers"
}
}

// MARK: - Private functions

private func stylize() {
view.backgroundColor = Colors.Background.primary
headerLabel.text = GDLocalizedString("callouts.panel.title").uppercasedWithAppLocale()
}

private func setNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleLocateNotification), name: Notification.Name.didToggleLocate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleOrientateNotification), name: Notification.Name.didToggleOrientate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleLookAheadNotification), name: Notification.Name.didToggleLookAhead, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleDidToggleMarkedPointsNotification), name: Notification.Name.didToggleMarkedPoints, object: nil)
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AppCenter
import AppCenterAnalytics
import AppCenterCrashes
import Combine
import SwiftUI

class DynamicLaunchViewController: UIViewController {

Expand All @@ -24,7 +25,6 @@ class DynamicLaunchViewController: UIViewController {
/// static initialization or are global.
override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
LoggingContext.shared.start()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,9 @@ class ExpandableMapViewController: UIViewController {
}

if let locationDetail = locationDetail {
// Create and configure the alert controller.
let alert = UIAlertController(title: GDLocalizedString("general.alert.choose_an_app"), message: nil, preferredStyle: .actionSheet)

// TODO: Add actions to open the given location in a third-party map application
// These applications must also be defined in 'Queried URL Schemes' in Info.plist

let cancelAction = UIAlertAction(title: GDLocalizedString("general.alert.cancel"), style: .cancel)
alert.addAction(cancelAction)

let alert = UIAlertController(locationDetail: locationDetail, preferredStyle: .actionSheet) { mapApp in
guard mapApp != nil else { return }
}
present(alert, animated: true, completion: nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,8 @@ class SearchTableViewController: BaseTableViewController {

override func viewDidLoad() {
super.viewDidLoad()

// If this is a release build, hide `Nearby Places Map`
if FeatureFlag.isEnabled(.developerTools) == false {
navigationItem.rightBarButtonItems = []
}

// Initialize search controller
self.searchController = UISearchController(delegate: self)

// Add search controller to navigation bar
self.navigationItem.searchController = self.searchController
self.navigationItem.hidesSearchBarWhenScrolling = false

// Search results will be displayed modally
// Use this view controller to define presentation context
self.definesPresentationContext = true


setActions()
updateTableView()
}

Expand Down Expand Up @@ -161,7 +146,25 @@ class SearchTableViewController: BaseTableViewController {
preferredContentSize.height = UIView.preferredContentHeight(for: tableView)
}

// `UITableView`
// MARK: - // `UITableView` Private functions

private func setActions() {
// If this is a release build, hide `Nearby Places Map`
if FeatureFlag.isEnabled(.developerTools) == false {
navigationItem.rightBarButtonItems = []
}

// Initialize search controller
self.searchController = UISearchController(delegate: self)

// Add search controller to navigation bar
self.navigationItem.searchController = self.searchController
self.navigationItem.hidesSearchBarWhenScrolling = false

// Search results will be displayed modally
// Use this view controller to define presentation context
self.definesPresentationContext = true
}

private func updateTableView() {
DispatchQueue.main.async { [weak self] in
Expand Down
Loading