Skip to content

Commit 130b28c

Browse files
committed
User app title for displaying current filename
1 parent 91a72d5 commit 130b28c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

OpenGpxTracker/ViewController.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import CoreGPX
1414

1515
// swiftlint:disable line_length
1616

17+
/// App title
18+
19+
let kAppTitle: String = " Open GPX Tracker"
1720
/// Purple color for button background
1821
let kPurpleButtonBackgroundColor: UIColor = UIColor(red: 146.0/255.0, green: 166.0/255.0, blue: 218.0/255.0, alpha: 0.90)
1922

@@ -126,7 +129,20 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
126129
var stopWatch = StopWatch()
127130

128131
/// Name of the last file that was saved (without extension)
129-
var lastGpxFilename: String = ""
132+
var lastGpxFilename: String = "" {
133+
didSet {
134+
if lastGpxFilename == "" {
135+
appTitleLabel.text = kAppTitle
136+
} else {
137+
// if name is too long arbitrary cut
138+
var displayedName = lastGpxFilename
139+
if lastGpxFilename.count > 20 {
140+
displayedName = lastGpxFilename.prefix(10) + "..." + lastGpxFilename.suffix(3)
141+
}
142+
appTitleLabel.text = " " + displayedName + ".gpx"
143+
}
144+
}
145+
}
130146

131147
/// Status variable that indicates if the app was sent to background.
132148
var wasSentToBackground: Bool = false
@@ -411,9 +427,6 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
411427
locationManager.startUpdatingLocation()
412428
locationManager.startUpdatingHeading()
413429

414-
//let pinchGesture = UIPinchGestureRecognizer(target: self, action: "pinchGesture")
415-
//map.addGestureRecognizer(pinchGesture)
416-
417430
// Preferences
418431
map.tileServer = Preferences.shared.tileServer
419432
map.useCache = Preferences.shared.useCache
@@ -442,10 +455,9 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
442455
let font12 = UIFont(name: "DinAlternate-Bold", size: 12.0)
443456

444457
// Add the app title Label (Branding, branding, branding! )
445-
appTitleLabel.text = " Open GPX Tracker"
458+
appTitleLabel.text = kAppTitle
446459
appTitleLabel.textAlignment = .left
447460
appTitleLabel.font = UIFont.boldSystemFont(ofSize: 10)
448-
//appTitleLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
449461
appTitleLabel.textColor = UIColor.yellow
450462
appTitleLabel.backgroundColor = UIColor(red: 58.0/255.0, green: 57.0/255.0, blue: 54.0/255.0, alpha: 0.80)
451463
self.view.addSubview(appTitleLabel)

0 commit comments

Comments
 (0)