View ImportLocalizations.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 didPanView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 didPinchView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 didTapView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 addCircleView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapView)) | |
tapGestureRecognizer.numberOfTapsRequired = 2 | |
view.addGestureRecognizer(tapGestureRecognizer) |
View ThemeManagerAPI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ThemeManager { | |
private let themeRepository: ThemeRepository | |
var current: Theme { get } | |
func apply(theme: Theme) | |
} |
View DefaultsThemeRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
View ThemeRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ThemeRepository { | |
func load() -> Theme | |
func save(_ theme: Theme) | |
} |
NewerOlder