Files
comaps/iphone/Maps/Common/Common.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

45 lines
1.1 KiB
Swift

import Foundation
var isIPad: Bool { return UI_USER_INTERFACE_IDIOM() == .pad }
func L(_ key: String) -> String { return NSLocalizedString(key, comment: "") }
func alternative<T>(iPhone: T, iPad: T) -> T { return isIPad ? iPad : iPhone }
func iPadSpecific(_ f: () -> Void) {
if isIPad {
f()
}
}
func iPhoneSpecific(_ f: () -> Void) {
if !isIPad {
f()
}
}
func toString(_ cls: AnyClass) -> String {
return String(describing: cls)
}
func statusBarHeight() -> CGFloat {
let statusBarSize = UIApplication.shared.statusBarFrame.size
return min(statusBarSize.height, statusBarSize.width)
}
func LOG(_ level: LogLevel,
_ message: @autoclosure () -> Any,
functionName: StaticString = #function,
fileName: StaticString = #file,
lineNumber: UInt = #line) {
if (Logger.canLog(level)) {
let shortFileName = URL(string: "\(fileName)")?.lastPathComponent ?? ""
let formattedMessage = "\(shortFileName):\(lineNumber) \(functionName): \(message())"
Logger.log(level, message: formattedMessage)
}
}
struct Weak<T> where T: AnyObject {
weak var value: T?
}