Skip to content

Instantly share code, notes, and snippets.

Tiago Martinho tiagomartinho

Block or report user

Report or block tiagomartinho

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ImportLocalizations.sh
# Portuguese
xcodebuild -importLocalizations -project TVStreams.xcodeproj/ -localizationPath ./localizations/uikit/pt.xliff
xcodebuild -importLocalizations -project TVStreamsCore/TVStreamsCore.xcodeproj/ -localizationPath ./localizations/core/pt.xliff
xcodebuild -importLocalizations -project TVStreamsOSX/TVStreamsOSX.xcodeproj/ -localizationPath ./localizations/appkit/pt.xliff
View ExportLocalizations.sh
rm -rf localizations/
mkdir localizations/
mkdir localizations/uikit
mkdir localizations/core
mkdir localizations/appkit
xcodebuild -exportLocalizations -project TVStreams.xcodeproj/ -localizationPath ./localizations/uikit -exportLanguage en
xcodebuild -exportLocalizations -project TVStreamsCore/TVStreamsCore.xcodeproj/ -localizationPath ./localizations/core -exportLanguage en
xcodebuild -exportLocalizations -project TVStreamsOSX/TVStreamsOSX.xcodeproj/ -localizationPath ./localizations/appkit -exportLanguage en
View didTapView.swift
@objc func didTapView(_ gestureRecognizer: UITapGestureRecognizer) {
let location = gestureRecognizer.location(in: view)
let circleView = addCircleView(in: location)
let pinchGestureRecognizer = UIPinchGestureRecognizer(target: self, action: #selector(didPinchView))
circleView.addGestureRecognizer(pinchGestureRecognizer)
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(didPanView))
circleView.addGestureRecognizer(panGestureRecognizer)
}
View didPinchView.swift
@objc func didPinchView(gestureRecognizer: UIPinchGestureRecognizer) {
if gestureRecognizer.state == .began || gestureRecognizer.state == .changed {
guard let transform = gestureRecognizer.view?.transform else { return }
let scale = gestureRecognizer.scale
gestureRecognizer.view?.transform = transform.scaledBy(x: scale, y: scale)
gestureRecognizer.scale = 1.0
}
}
View didPanView.swift
@objc func didPanView(sender: UIPanGestureRecognizer) {
let viewToMove = sender.view!
view.bringSubview(toFront: viewToMove)
let translation = sender.translation(in: view)
let newCenter = CGPoint(x: viewToMove.center.x + translation.x, y: viewToMove.center.y + translation.y)
viewToMove.center = newCenter
sender.setTranslation(CGPoint.zero, in: view)
}
View addCircleView.swift
let location = gestureRecognizer.location(in: view)
let circleView = UIView()
let colors = [#colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1),#colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1),#colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1),#colorLiteral(red: 0.9568627477, green: 0.6588235497, blue: 0.5450980663, alpha: 1),#colorLiteral(red: 0.9764705896, green: 0.850980401, blue: 0.5490196347, alpha: 1),#colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1)]
circleView.backgroundColor = colors[Int(arc4random_uniform(UInt32(colors.count)))].withAlphaComponent(0.8)
let size: CGFloat = 200
circleView.frame = CGRect(x: location.x, y: location.y, width: size, height: size).offsetBy(dx: -size/2, dy: -size/2)
circleView.layer.cornerRadius = size / 2
view.addSubview(circleView)
View UITapGestureRecognizer.swift
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapView))
tapGestureRecognizer.numberOfTapsRequired = 2
view.addGestureRecognizer(tapGestureRecognizer)
View LightTheme.swift
import UIKit
struct LightTheme: Theme {
var name: ThemeName {
return .light
}
var tintColor: UIColor {
return #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)
View ThemeManagerAPI.swift
import UIKit
class ThemeManager {
private let themeRepository: ThemeRepository
var current: Theme { get }
func apply(theme: Theme)
}
View DefaultsThemeRepository.swift
import Foundation
class DefaultsThemeRepository: ThemeRepository {
private let selectedThemeKey = "selectedThemeKey"
private let defaults = UserDefaults.standard
func load() -> Theme {
if let storedTheme = defaults.string(forKey: selectedThemeKey),
let theme = ThemeName(rawValue: storedTheme)?.theme {
You can’t perform that action at this time.