Skip to content

Commit

Permalink
Merge pull request krzysztofzablocki#3 in EX/lifetimetracker from bug…
Browse files Browse the repository at this point in the history
…fix/lifetime-tracker-changes-HOS-18445 to lightspeed_changes

* commit '30a895767935b4feb047e397ce37372d60eb6f6c':
  HOS-18445 Prevent crash on iPad
  HOS-18445 Added strings to project
  HOS-18445 Load proper bundle for strings
  HOS-18445 Added .DS_Store to gitignore
  HOS-18445 Removed unnecessary files
  • Loading branch information
ls-philippe-casgrain committed May 16, 2019
2 parents 7855e1a + 30a8957 commit 899033f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ xcuserdata/
*.moved-aside
*.xccheckout
*.xcscmblueprint
.DS_Store

## Obj-C/Swift specific
*.hmap
Expand Down
Binary file removed Example/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions LifetimeTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
383869131F9FEE7800B1A6AB /* VisibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 383869121F9FEE7800B1A6AB /* VisibilityTests.swift */; };
383869141F9FEE7E00B1A6AB /* VisibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 383869121F9FEE7800B1A6AB /* VisibilityTests.swift */; };
383869151F9FEE7F00B1A6AB /* VisibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 383869121F9FEE7800B1A6AB /* VisibilityTests.swift */; };
4A563B28228C9655009C389D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A563B27228C9655009C389D /* Localizable.strings */; };
4ACDB013212ED6440012CE2F /* SettingsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACDB012212ED6440012CE2F /* SettingsManager.swift */; };
4AFAE7042136E6DB001A63C7 /* HideOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AFAE7032136E6DB001A63C7 /* HideOption.swift */; };
52D6D9871BEFF229002C0205 /* LifetimeTracker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D97C1BEFF229002C0205 /* LifetimeTracker.framework */; };
Expand Down Expand Up @@ -64,6 +65,7 @@

/* Begin PBXFileReference section */
383869121F9FEE7800B1A6AB /* VisibilityTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisibilityTests.swift; sourceTree = "<group>"; };
4A563B27228C9655009C389D /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
4ACDB012212ED6440012CE2F /* SettingsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsManager.swift; sourceTree = "<group>"; };
4AFAE7032136E6DB001A63C7 /* HideOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideOption.swift; sourceTree = "<group>"; };
52D6D97C1BEFF229002C0205 /* LifetimeTracker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LifetimeTracker.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -240,6 +242,7 @@
8933C7841EB5B820000D00A4 /* LifetimeTracker.swift */,
4ACDB012212ED6440012CE2F /* SettingsManager.swift */,
87F76A25206FE07D00F2BFF4 /* UI */,
4A563B27228C9655009C389D /* Localizable.strings */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -500,6 +503,7 @@
buildActionMask = 2147483647;
files = (
87F76A4F206FE85800F2BFF4 /* CircularDashboard.storyboard in Resources */,
4A563B28228C9655009C389D /* Localizable.strings in Resources */,
87F76A3D206FE07D00F2BFF4 /* DashboardTableViewHeaderView.xib in Resources */,
87F76A39206FE07D00F2BFF4 /* BarDashboard.storyboard in Resources */,
87F76A3A206FE07D00F2BFF4 /* DashboardTableView.storyboard in Resources */,
Expand Down
4 changes: 1 addition & 3 deletions Sources/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import Foundation
internal extension String {

var lt_localized: String {
guard let path = Bundle(for: LifetimeTracker.self).path(forResource: "LifetimeTracker", ofType: "bundle"), let bundle = Bundle(path: path) else {
return self
}
let bundle = Bundle(for: LifetimeTracker.self)
return NSLocalizedString(self, bundle: bundle, comment: self)
}
}
15 changes: 15 additions & 0 deletions Sources/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import UIKit

struct SettingsManager {

// On iPhone, this has no effect if the alert has preferredStyle: .actionSheet.
// On iPad, this creates a root-less popover which mimics the appearance of an actionSheet
// without requiring a sourceView or barButton.
private static func createRootlessPopover(centeredOn view: UIView, alert: UIAlertController) {
if let popoverController = alert.popoverPresentationController {
popoverController.sourceView = view
popoverController.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
}

static func showSettingsActionSheet(on viewController: UIViewController, completionHandler: @escaping (HideOption) -> Void) {
let alert = UIAlertController(title: "settings".lt_localized, message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "settings.hide.title".lt_localized, style: .default, handler: { (action: UIAlertAction) in
Expand All @@ -26,11 +37,15 @@ struct SettingsManager {
alert.addAction(UIAlertAction(title: "settings.cancel".lt_localized, style: .cancel, handler: { (action: UIAlertAction) in
completionHandler(.none)
}))
createRootlessPopover(centeredOn: viewController.view, alert: alert)
viewController.present(alert, animated: true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "settings.cancel".lt_localized, style: .cancel, handler: { (action: UIAlertAction) in
completionHandler(.none)
}))

createRootlessPopover(centeredOn: viewController.view, alert: alert)

viewController.present(alert, animated: true, completion: nil)
}
}

0 comments on commit 899033f

Please sign in to comment.