blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
625
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
47
| license_type
stringclasses 2
values | repo_name
stringlengths 5
116
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 643
values | visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 80.4k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 16
values | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_language
stringclasses 85
values | src_encoding
stringclasses 7
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 4
6.44M
| extension
stringclasses 17
values | content
stringlengths 4
6.44M
| duplicates
listlengths 1
9.02k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
410f80e155fafb636c560f957394f8653eead433
|
320d3d7b42d91215411e4cf45cee75d859bcb1a8
|
/GankJiZhongYing/Classes/Home/View/CLHSearchView.swift
|
ef0e6d5166a52b24dae2b1c122a3179788e16570
|
[] |
no_license
|
AnICoo1/GankJiZhongYing
|
b8f4ea72838dc70a1220e5d52b64af55653e9902
|
a1cce65e7f17b4e070640822d52dc14f5d57149c
|
refs/heads/master
| 2021-01-01T18:08:25.526609 | 2017-08-08T07:20:46 | 2017-08-08T07:20:46 | 98,253,482 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,853 |
swift
|
//
// CLHSearchView.swift
// GankJiZhongYing
//
// Created by AnICoo1 on 2017/7/24.
// Copyright © 2017年 AnICoo1. All rights reserved.
//
import UIKit
import SnapKit
class CLHSearchView: UIView {
weak var locationVC : UIViewController?
var searchLabel: UILabel = {
let label = UILabel()
label.text = "搜索"
label.textColor = .white
label.font = UIFont.boldSystemFont(ofSize: 14.0)
return label
}()
var searchImage: UIImageView = {
let imageV = UIImageView(image: UIImage(named: "icon_search_blue.png"))
return imageV
}()
override init(frame: CGRect) {
super.init(frame: frame)
setUpAll()
let tap = UITapGestureRecognizer(target: self, action: #selector(showSearchVC))
self.addGestureRecognizer(tap)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setUpAll() {
self.layer.cornerRadius = 15
self.layer.masksToBounds = true
self.backgroundColor = UIColorTextBlue
self.addSubview(searchImage)
self.addSubview(searchLabel)
searchImage.snp.makeConstraints { (make) in
make.centerY.equalToSuperview()
make.left.equalTo(self).offset(5)
make.width.equalTo(24)
make.height.equalTo(24)
}
searchLabel.snp.makeConstraints { (make) in
make.centerY.equalToSuperview()
make.left.equalTo(searchImage).offset(searchImage.Width + 5)
}
}
func showSearchVC() {
print("click search")
let searchVC = CLHSearchViewController()
let nav = UINavigationController(rootViewController: searchVC)
locationVC?.present(nav, animated: true, completion: nil)
}
}
|
[
-1
] |
e9ceae6e1e2365581e9b5105202822cde5f3165a
|
35c366e85b9931a84723969b78135ef6e03c91d7
|
/Act02/ViewControllerDetalle.swift
|
a853ed034a87a7237a875ad50fb6c95408ef0a2a
|
[] |
no_license
|
LuisAlvarez98/ios-course
|
3f7afad90c00b95c402dd5d16e0e1955cf8d88cf
|
00a9854ba34be4f5c95d0294f455e1faa283ba16
|
refs/heads/master
| 2022-12-25T16:59:53.753077 | 2020-10-10T22:27:19 | 2020-10-10T22:27:19 | 299,334,801 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,027 |
swift
|
//
// ViewControllerDetalle.swift
// Actividad2
//
// Created by Luis Felipe Alvarez Sanchez on 07/09/20.
// Copyright © 2020 Luis Felipe Alvarez Sanchez. All rights reserved.
//
import UIKit
class ViewControllerDetalle: UIViewController {
@IBOutlet weak var lblNombre: UILabel!
@IBOutlet weak var lblPuntos: UILabel!
@IBOutlet weak var foto: UIImageView!
var unJugador: Jugador!
override func viewDidLoad() {
super.viewDidLoad()
foto.image = unJugador.foto
lblNombre.text = unJugador.nombre
lblPuntos.text = String(unJugador.puntos)
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
4f4693a077e7f400a7dfdb08ef690d0367a23fac
|
f3c0dc5e41b6020de4883898326e803a9285ae22
|
/Extensions/CGSize.swift
|
886a54a5478bc7f04f31657f3565724ecc3832cc
|
[] |
no_license
|
sestinj/SSL
|
573fed3644a5db84b2521782e9c5788963cefa3c
|
8d5a54836d9b09d851a6bae1bc310a5753df567b
|
refs/heads/master
| 2020-04-03T18:17:52.813347 | 2019-06-24T17:22:10 | 2019-06-24T17:22:10 | 155,477,734 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 868 |
swift
|
//
// CGSize.swift
// Gravitate
//
// Created by Nate Sesti on 6/19/18.
// Copyright © 2018 Nate Sesti. All rights reserved.
//
import Foundation
import UIKit
extension CGSize {
init(_ size: Int) {
self.init(width: size, height: size)
}
static func *(lhs: CGSize, rhs: CGFloat) -> CGSize {
return CGSize(width: lhs.width*rhs, height: lhs.height*rhs)
}
static func /(lhs: CGSize, rhs: CGFloat) -> CGSize {
return CGSize(width: lhs.width/rhs, height: lhs.height/rhs)
}
static func /(lhs: CGSize, rhs: Int) -> CGSize {
return CGSize(width: lhs.width/CGFloat(rhs), height: lhs.height/CGFloat(rhs))
}
func toPoint() -> CGPoint {
return CGPoint(x: self.width, y: self.height)
}
func toVector() -> CGVector {
return CGVector(dx: self.width, dy: self.height)
}
}
|
[
-1
] |
89b7508fda856e9794fe0e685774e3c50502c71a
|
324b605ac9703a465712f3eed7d3a0d919efbec0
|
/Sources/NIOUDPEchoClient/main.swift
|
3c05658a4ec1e3706d73c685867d36d802218844
|
[
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
k-ymmt/swift-nio
|
06c7f6d71cd2a905e3feabb05f0680f3be2e54c3
|
79f0d1600494c70c6718e667f67c7c7f8fba01b5
|
refs/heads/master
| 2022-05-28T09:43:13.021566 | 2020-05-04T15:06:32 | 2020-05-04T15:06:32 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,576 |
swift
|
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIO
print("Please enter line to send to the server")
let line = readLine(strippingNewline: true)!
private final class EchoHandler: ChannelInboundHandler {
public typealias InboundIn = AddressedEnvelope<ByteBuffer>
public typealias OutboundOut = AddressedEnvelope<ByteBuffer>
private var numBytes = 0
private let remoteAddressInitializer: () throws -> SocketAddress
init(remoteAddressInitializer: @escaping () throws -> SocketAddress) {
self.remoteAddressInitializer = remoteAddressInitializer
}
public func channelActive(context: ChannelHandlerContext) {
do {
// Channel is available. It's time to send the message to the server to initialize the ping-pong sequence.
// Get the server address.
let remoteAddress = try self.remoteAddressInitializer()
// Set the transmission data.
var buffer = context.channel.allocator.buffer(capacity: line.utf8.count)
buffer.writeString(line)
self.numBytes = buffer.readableBytes
// Forward the data.
let envolope = AddressedEnvelope<ByteBuffer>(remoteAddress: remoteAddress, data: buffer)
context.writeAndFlush(self.wrapOutboundOut(envolope), promise: nil)
} catch {
print("Could not resolve remote address")
}
}
public func channelRead(context: ChannelHandlerContext, data: NIOAny) {
let envelope = self.unwrapInboundIn(data)
let byteBuffer = envelope.data
self.numBytes -= byteBuffer.readableBytes
if self.numBytes <= 0 {
let string = String(buffer: byteBuffer)
print("Received: '\(string)' back from the server, closing channel.")
context.close(promise: nil)
}
}
public func errorCaught(context: ChannelHandlerContext, error: Error) {
print("error: ", error)
// As we are not really interested getting notified on success or failure we just pass nil as promise to
// reduce allocations.
context.close(promise: nil)
}
}
// First argument is the program path
let arguments = CommandLine.arguments
let arg1 = arguments.dropFirst().first
let arg2 = arguments.dropFirst(2).first
let arg3 = arguments.dropFirst(3).first
// If only writing to the destination address, bind to local port 0 and address 0.0.0.0 or ::.
let defaultHost = "::1"
// If the server and the client are running on the same computer, these will need to differ from each other.
let defaultServerPort: Int = 9999
let defaultListeningPort: Int = 8888
enum ConnectTo {
case ip(host: String, sendPort: Int, listeningPort: Int)
case unixDomainSocket(sendPath: String, listeningPath: String)
}
let connectTarget: ConnectTo
switch (arg1, arg1.flatMap(Int.init), arg2, arg2.flatMap(Int.init), arg3.flatMap(Int.init)) {
case (.some(let h), .none , _, .some(let sp), .some(let lp)):
/* We received three arguments (String Int Int), let's interpret that as a server host with a server port and a local listening port */
connectTarget = .ip(host: h, sendPort: sp, listeningPort: lp)
case (.some(let sp), .none , .some(let lp), .none, _):
/* We received two arguments (String String), let's interpret that as sending socket path and listening socket path */
assert(sp != lp, "The sending and listening sockets should differ.")
connectTarget = .unixDomainSocket(sendPath: sp, listeningPath: lp)
case (_, .some(let sp), _, .some(let lp), _):
/* We received two argument (Int Int), let's interpret that as the server port and a listening port on the default host. */
connectTarget = .ip(host: defaultHost, sendPort: sp, listeningPort: lp)
default:
connectTarget = .ip(host: defaultHost, sendPort: defaultServerPort, listeningPort: defaultListeningPort)
}
let remoteAddress = { () -> SocketAddress in
switch connectTarget {
case .ip(let host, let sendPort, _):
return try SocketAddress.makeAddressResolvingHost(host, port: sendPort)
case .unixDomainSocket(let sendPath, _):
return try SocketAddress(unixDomainSocketPath: sendPath)
}
}
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let bootstrap = DatagramBootstrap(group: group)
// Enable SO_REUSEADDR.
.channelOption(ChannelOptions.socketOption(.reuseaddr), value: 1)
.channelInitializer { channel in
channel.pipeline.addHandler(EchoHandler(remoteAddressInitializer: remoteAddress))
}
defer {
try! group.syncShutdownGracefully()
}
let channel = try { () -> Channel in
switch connectTarget {
case .ip(let host, _, let listeningPort):
return try bootstrap.bind(host: host, port: listeningPort).wait()
case .unixDomainSocket(_, let listeningPath):
return try bootstrap.bind(unixDomainSocketPath: listeningPath).wait()
}
}()
// Will be closed after we echo-ed back to the server.
try channel.closeFuture.wait()
print("Client closed")
|
[
-1
] |
75806a1ce84fcf920e60926a96b20afe9a1564ab
|
aa7c58dd18985def2667b4e1439cc85647c2e1e1
|
/Mars Rover ProblemTests/RoverTests.swift
|
771a794c76beeb35c87e177dc35e14896363b6a0
|
[] |
no_license
|
zionix357/Mars-Rover-Problem-in-Swift
|
f67e7767123259d73939e70c26b03650040a5e05
|
2a0a1eb1f588a626c59f9d849c0a709a8b979d86
|
refs/heads/master
| 2021-01-19T00:14:50.434914 | 2016-08-12T22:50:53 | 2016-08-12T22:50:53 | 65,586,647 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 941 |
swift
|
//
// RoverTests.swift
// Mars Rover Problem
//
// Created by Arthur Rocha on 12/08/16.
// Copyright © 2016 Arthur Rocha. All rights reserved.
//
import XCTest
@testable import Mars_Rover_Problem
class RoverTests: XCTestCase {
private var rover : Rover?
private var board : Board?
override func setUp() {
super.setUp()
board = Board(pX: 5, pY: 5)
rover = Rover(pX: 1, pY: 2, pDirection: "N", pInstructions: "LMLMLMLMM", pBoard: board!)
}
override func tearDown() {
super.tearDown()
}
func testNewRover(){
XCTAssertEqual(1, rover?.getX()!)
XCTAssertEqual(2, rover?.getY()!)
XCTAssertEqual("N", rover?.getDirection()!)
}
func testInstruction(){
XCTAssertEqual("LMLMLMLMM", rover?.getInstructions()!)
}
func testFailInstruction(){
XCTAssertEqual("LMLMLM", rover?.getInstructions()!)
}
}
|
[
-1
] |
0b2abe3c7b8fd56a4831e0bc6beb7250b4db7e5b
|
eeaa3f00e6a2607f5e5f9b64e69bffb66e18b786
|
/tabbar-santander/tabbar-santander/AccountBalance/AccountBalanceVC.swift
|
c1643f31171003a0d9942881d972bb52f52e712c
|
[] |
no_license
|
FelipeIOS/0820CDMASCN05BRED
|
3bc83c3040966ab38d985a412c36bb820fe5a684
|
3f86dab3952ddd1e686ff0d750703ff8a36a6e2f
|
refs/heads/main
| 2023-02-12T12:56:04.743226 | 2021-01-16T00:46:41 | 2021-01-16T00:46:41 | 308,692,571 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,036 |
swift
|
//
// SecondVC.swift
// tabbar-santander
//
// Created by Felipe Miranda on 23/10/20.
//
import UIKit
class AccountBalanceVC: BaseViewController {
@IBOutlet weak var timeLineTableView: UITableView!
private var controller: AccountBalanceController = AccountBalanceController()
override func viewDidLoad() {
super.viewDidLoad()
print("AccountBalanceVC----viewDidLoad")
// Do any additional setup after loading the view.
self.timeLineTableView.register(UINib(nibName: "ExtratoCell", bundle: nil), forCellReuseIdentifier: "ExtratoCell")
self.showLoading()
self.controller.loadLancamentos { (result, error) in
if result {
DispatchQueue.main.async {
self.timeLineTableView.delegate = self
self.timeLineTableView.dataSource = self
self.timeLineTableView.separatorStyle = .none
self.timeLineTableView.reloadData()
self.hiddenLoading()
}
}else{
DispatchQueue.main.async {
self.hiddenLoading()
}
print("======deu erro \(error)")
}
}
}
}
extension AccountBalanceVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.controller.numberOfRows
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: ExtratoCell? = tableView.dequeueReusableCell(withIdentifier: "ExtratoCell", for: indexPath) as? ExtratoCell
self.controller.loadCurrentLancamentoElement(index: indexPath.row)
cell?.setup(value:self.controller.lancamentoElement)
return cell ?? UITableViewCell()
}
}
|
[
-1
] |
a73615f1236902bd529b38754673162457af1582
|
d95c2fafca44ecbb2f5b93836d64f93c7ca01d2a
|
/pet-place/PetProfileEditViewController.swift
|
10624f40ec8289bb5a5ff40387e4d78e5d1e3524
|
[] |
no_license
|
Choijh84/petcity
|
b1f938aa512a219b84a49a5f8323b58e4c8d67a2
|
819c6dea78f9bc86e0052dd651ab9c7ecb8f9f32
|
refs/heads/master
| 2021-01-19T00:28:55.733359 | 2017-05-12T17:35:24 | 2017-05-12T17:35:24 | 87,173,576 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 15,873 |
swift
|
//
// PetProfileEditViewController.swift
// pet-place
//
// Created by Ken Choi on 2017. 2. 27..
// Copyright © 2017년 press.S. All rights reserved.
//
import UIKit
import Eureka
import SCLAlertView
/// 펫 프로필 편집해주는 VC
class PetProfileEditViewController: FormViewController {
var selectedPetProfile: PetProfile!
/// Initial Value of the species
var petSpecies = "Dog"
/// Array of Dog Breed List
var DogBreed = [AnimalBreed]()
/// Array of Cat Breed List
var CatBreed = [AnimalBreed]()
/// value of all rows in the form
var valueDictionary = [String: AnyObject]()
@IBAction func petProfileSave(_ sender: Any) {
// form에서 value 형성
valueDictionary = form.values(includeHidden: false) as [String : AnyObject]
/// 데이터 입력 여부 체크
/// 필수 입력: 이름, 성별, 종, 품종 등
if valueDictionary["species"] is NSNull || valueDictionary["name"] is NSNull || valueDictionary["breed"] is NSNull || valueDictionary["gender"] is NSNull {
SCLAlertView().showError("입력 에러", subTitle: "필수 값을 입력해주세요")
} else {
/// To ask user to save or not
/// close 버튼 숨기기
let appearance = SCLAlertView.SCLAppearance(
showCloseButton: false
)
let alertView = SCLAlertView(appearance: appearance)
alertView.addButton("Yes") {
/// setup pet profile
self.updatePetProfile { (success) in
if success {
/// show alarm and dismiss
SCLAlertView().showSuccess("프로필 변경 완료", subTitle: "저장되었습니다")
self.navigationController?.popViewController(animated: true)
NotificationCenter.default.post(name: Notification.Name(rawValue: "petProfileChanged"), object: nil)
} else {
/// show error
SCLAlertView().showError("에러 발생", subTitle: "다시 시도해주세요")
}
}
}
alertView.addButton("No") {
print("User says no")
SCLAlertView().showInfo("취소", subTitle: "저장이 취소되었습니다")
}
alertView.showInfo("펫 프로필 저장", subTitle: "저장이 완료되면 알려드립니다")
}
}
override func viewDidLoad() {
super.viewDidLoad()
print("This is Pet Profile Edit Page: \(selectedPetProfile)")
readPetBreedList()
petSpecies = selectedPetProfile.species
form =
Section("필수 정보")
// {
// $0.header = HeaderFooterView<HeaderImageView>(.class)
// }
<<< TextRow("name") {
$0.title = NSLocalizedString("Pet name", comment: "")
$0.add(rule: RuleRequired())
$0.value = selectedPetProfile.name
$0.validationOptions = .validatesOnChange
}.cellUpdate { cell, row in
if !row.isValid {
cell.titleLabel?.textColor = .red
}
}
<<< ActionSheetRow<String>("species") {
$0.title = NSLocalizedString("Species", comment: "")
$0.selectorTitle = "Your Pet? "
$0.options = ["강아지", "고양이", "기타"]
$0.value = petSpecies
$0.add(rule: RuleRequired())
$0.validationOptions = .validatesOnChange
}.onChange({ (row) in
self.petSpecies = row.value!
print("This is pet species: \(self.petSpecies)")
})
/*
<<< PushRow<String>("breed") {
$0.title = NSLocalizedString("Breed", comment: "")
$0.value = selectedPetProfile.breed
if petSpecies == "강아지" {
$0.options = dogBreed
} else if petSpecies == "고양이" {
$0.options = catBreed
} else {
$0.options = dogBreed
}
$0.add(rule: RuleRequired())
$0.validationOptions = .validatesOnChange
}.onCellSelection({ (cell, row) in
if self.petSpecies == "강아지" {
row.options = self.dogBreed
} else if self.petSpecies == "고양이" {
row.options = self.catBreed
} else {
row.options = self.dogBreed
}
})
*/
<<< SearchablePushRow<AnimalBreed>("breed") { row in
row.title = NSLocalizedString("Breed", comment: "")
row.value = AnimalBreed(name: selectedPetProfile.breed)
if self.petSpecies == "강아지" {
row.options = self.DogBreed
} else if self.petSpecies == "고양이" {
row.options = self.CatBreed
} else {
row.options = self.DogBreed
}
row.add(rule: RuleRequired())
row.validationOptions = .validatesOnChange
}.onCellSelection({ (cell, row) in
if self.petSpecies == "강아지" {
row.options = self.DogBreed
} else if self.petSpecies == "고양이" {
row.options = self.CatBreed
} else {
row.options = self.DogBreed
}
})
<<< SegmentedRow<String>("gender") {
$0.options = [NSLocalizedString("Female", comment: ""), NSLocalizedString("Male", comment: "")]
if selectedPetProfile.gender == "Male" {
$0.value = NSLocalizedString("Male", comment: "")
} else {
$0.value = NSLocalizedString("Female", comment: "")
}
$0.add(rule: RuleRequired())
}
<<< SegmentedRow<String>("neutralized") {
// $0.title = NSLocalizedString("Neutralized", comment: "")
$0.options = [NSLocalizedString("No Neutralized", comment: ""), NSLocalizedString("Neutralized", comment: "")]
if selectedPetProfile.neutralized {
$0.value = NSLocalizedString("Neutralized", comment: "")
} else {
$0.value = NSLocalizedString("No Neutralized", comment: "")
}
$0.add(rule: RuleRequired())
}
+++ Section("추가 정보 1")
<<< DecimalRow("weight") {
$0.title = NSLocalizedString("Weight", comment: "")
$0.value = selectedPetProfile.weight
$0.formatter = DecimalFormatter()
$0.useFormatterDuringInput = true
//$0.useFormatterOnDidBeginEditing = true
$0.add(rule: RuleRequired())
$0.validationOptions = .validatesOnChange
}.cellSetup { cell, _ in
cell.textField.keyboardType = .numberPad
}
<<< AccountRow("registration") {
$0.title = NSLocalizedString("Registration", comment: "")
$0.placeholder = selectedPetProfile.registration
}
<<< ImageRow("imagePic"){ row in
row.title = NSLocalizedString("Pet Photo", comment: "")
if let imageUrl = selectedPetProfile.imagePic {
if let url = URL(string: imageUrl) {
let data = try? Data(contentsOf: url)
let image = UIImage(data: data!)
row.value = image
}
}
}
<<< DateRow("birthday"){
$0.title = NSLocalizedString("Birthday", comment: "")
$0.value = selectedPetProfile.birthday
let formatter = DateFormatter()
formatter.locale = .current
formatter.dateStyle = .long
$0.dateFormatter = formatter
}
+++ Section("추가 정보 2")
<<< TextAreaRow() {
print("백신: \(String(describing: selectedPetProfile.vaccination))")
if selectedPetProfile.vaccination == nil {
$0.placeholder = "백신 접종 현황"
} else {
$0.value = selectedPetProfile.vaccination
}
$0.textAreaHeight = .dynamic(initialTextViewHeight: 110)
}
<<< TextAreaRow("sickHistory") {
print("병력: \(String(describing: selectedPetProfile.sickHistory))")
if selectedPetProfile.sickHistory == nil {
$0.placeholder = "병력"
} else {
$0.value = selectedPetProfile.sickHistory
}
$0.textAreaHeight = .dynamic(initialTextViewHeight: 110)
}
}
/**
Pet List Read - from the property list: PetBreedList.plist
- current: dogBreed(강아지 종류 - alphabetically sort), catBreed(고양이 종류)
*/
func readPetBreedList() {
let pathList = Bundle.main.path(forResource: "PetBreedList", ofType: "plist")
let data: NSData? = NSData(contentsOfFile: pathList!)
let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data! as Data, options: [], format: nil) as! [String:Any]
var temps = datasourceDictionary["Dog"] as! [NSArray]
for temp in temps {
let breed = AnimalBreed(name: temp[0] as! String)
DogBreed.append(breed)
}
DogBreed = DogBreed.sorted(by: { (lhs, rhs) -> Bool in
return rhs.name > lhs.name
})
temps = datasourceDictionary["Cat"] as! [NSArray]
for temp in temps {
let breed = AnimalBreed(name: temp[0] as! String)
CatBreed.append(breed)
}
CatBreed = CatBreed.sorted(by: { (lhs, rhs) -> Bool in
return rhs.name > lhs.name
})
}
/**
펫 프로필을 업데이트 시키는 함수
*/
func updatePetProfile(completionHandler: @escaping (_ success: Bool) -> ()) {
var name: String?
if let species = valueDictionary["species"] as? String {
selectedPetProfile.species = species
}
if let tempname = valueDictionary["name"] as? String {
selectedPetProfile.name = tempname
name = tempname
}
if let breed = valueDictionary["breed"] as? AnimalBreed {
selectedPetProfile.breed = breed.name
}
if let vaccination = valueDictionary["vaccination"] as? String {
selectedPetProfile.vaccination = vaccination
}
if let sickHistory = valueDictionary["sickHistory"] as? String {
selectedPetProfile.sickHistory = sickHistory
}
if let neutralized = valueDictionary["neutralized"] as? String {
if neutralized == NSLocalizedString("No Neutralized", comment: "") {
selectedPetProfile.neutralized = false
} else {
selectedPetProfile.neutralized = true
}
}
if let gender = valueDictionary["gender"] as? String {
if gender == NSLocalizedString("Male", comment: "") {
selectedPetProfile.gender = "Male"
} else {
selectedPetProfile.gender = "Female"
}
}
if let weight = valueDictionary["weight"] as? Double {
selectedPetProfile.weight = weight
}
if let birthday = valueDictionary["birthday"] as? Date {
selectedPetProfile.birthday = birthday
}
if let registration = valueDictionary["registration"] as? String {
selectedPetProfile.registration = registration
}
if let image = valueDictionary["imagePic"] as? UIImage {
// 포토 매니저를 이용해 사진을 업로드
PhotoManager().uploadBlobPhoto(selectedFile: image.compressImage(image), container: "pet-profile-images", completionBlock: { (success, fileURL, error) in
if success {
print("This is pet profile url: \(String(describing: fileURL))")
self.selectedPetProfile.imagePic = fileURL
self.uploadPetProfile(profile: self.selectedPetProfile, completionHandler: { (success) in
if success {
completionHandler(true)
} else {
completionHandler(false)
}
})
} else {
print("Failure in upload")
}
})
} else {
self.uploadPetProfile(profile: selectedPetProfile, completionHandler: { (success) in
if success {
completionHandler(true)
} else {
completionHandler(false)
}
})
}
}
func uploadPetProfile(profile: PetProfile, completionHandler: @escaping (_ success: Bool) -> ()) {
let dataStore = Backendless.sharedInstance().data.of(PetProfile.ofClass())
dataStore?.save(profile, response: { (response) in
SCLAlertView().showSuccess("변경 완료", subTitle: "완료되었습니다")
completionHandler(true)
}, error: { (Fault) in
print("Server reported an error on saving pet profile: \(String(describing: Fault?.description))")
completionHandler(false)
})
}
/**
Upload photo, compressImage를 활용해서 압축해서 저장할 예정임 - into Backendelss
:param: image
:param: name, 파일네임이 name+time 형태로 저장될 예정, 저장 루트: petProfileImages/
*/
func uploadPhoto(image: UIImage!, name: String!, completionHandler: @escaping (_ success: Bool, _ url: String) -> ()) {
let compressed = image.compressImage(image)
let fileName = String(format: "\(name!)%0.0f.jpeg", Date().timeIntervalSince1970)
let filePath = "petProfileImages/\(fileName)"
print("This is filePath:\(filePath)")
let content = UIImageJPEGRepresentation(compressed, 1.0)
Backendless.sharedInstance().fileService.saveFile(filePath, content: content, response: { (uploadedFile) in
let fileURL = uploadedFile?.fileURL
print("This is fileURL:\(fileURL!)")
completionHandler(true, fileURL!)
}, error: { (fault) in
print(fault?.description ?? "There is an error in uploading pet profile photo")
completionHandler(false, (fault?.description)!)
})
}
}
|
[
-1
] |
331c8c12c207efb778baefd0662be0724a1aef26
|
2f90b9150434291f7d629922036a347adad06c71
|
/Sources/Globals/Others.swift
|
0284536cf9f6a9ca36fb10c95071cd31f511df03
|
[
"MIT"
] |
permissive
|
joewalsh/toolbox
|
7a78ad442ce5858bf6f01af2a3b418205f580880
|
ed7ab0eeeb786b620a91e1186effbd9574b5f6c3
|
refs/heads/master
| 2020-04-24T23:13:16.361982 | 2019-02-12T16:04:18 | 2019-02-12T16:04:18 | 172,336,509 | 0 | 0 |
MIT
| 2019-02-24T12:46:28 | 2019-02-24T12:46:28 | null |
UTF-8
|
Swift
| false | false | 121 |
swift
|
import Vapor
extension CommandContext {
public var done: Future<Void> {
return .done(on: container)
}
}
|
[
-1
] |
12551ffa0b66383132d5106969de851abf5f6e60
|
6167dd93abc17df2fc66919e1392f1dc7baf1a55
|
/filmapp/Home/Controller/HomeViewController.swift
|
c3415782bd540a0b9eec0be312a7e8a9aab2d251
|
[] |
no_license
|
elemanhillary-zz/BK_FILM_APP_CHALLENGE
|
534e836aefe81f01bddfe9fd0a3f7180523e8239
|
8bc3cc39ac49b71280f1e034e1cb728ee5602d68
|
refs/heads/main
| 2023-06-03T11:53:58.328769 | 2021-06-13T12:34:51 | 2021-06-13T12:34:51 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,770 |
swift
|
//
// HomeViewController.swift
// filmapp
//
// Created by MacBook Pro on 6/12/21.
//
import UIKit
class HomeViewController: UIViewController {
@IBOutlet weak var homeContentCollectionView: UICollectionView!
private var homeViewModel = HomeViewModel()
private lazy var dataSource = homeViewModel.makeDataSource(collectionView: homeContentCollectionView)
override func viewDidLoad() {
super.viewDidLoad()
self.homeContentCollectionView.delegate = self
self.homeContentCollectionView.tag = 1002
self.homeContentCollectionView.collectionViewLayout = createLayout()
self.homeContentCollectionView.register(UINib.init(nibName: String(describing: MovieCollectionViewCell.self), bundle: nil), forCellWithReuseIdentifier: String(describing: MovieCollectionViewCell.self))
homeViewModel.getNowPlayingList(completion: {[weak self] (response, error) in
if error == nil {
self?.homeViewModel.update(with: response!, dataSource: self!.dataSource)
} else {}
})
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
}
extension HomeViewController {
private func createLayout() -> UICollectionViewLayout {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(250))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 2)
let section = NSCollectionLayoutSection(group: group)
let layout = UICollectionViewCompositionalLayout(section: section)
return layout
}
}
extension HomeViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView.tag == 1002 {
let storyBoard = UIStoryboard.init(name: "Movie", bundle: nil)
if let controller = storyBoard.instantiateViewController(withIdentifier: "MovieViewController") as? MovieViewController {
controller.movieId = self.homeViewModel.nowPlaying[indexPath.item].id ?? 0
DispatchQueue.main.async {
self.navigationController?.pushViewController(controller, animated: true)
}
}
}
}
}
|
[
-1
] |
32dbb75edea8e354655b50dc9e28a62984670b40
|
3b379c2209fd52b4df3cf0e18dfd3e62848bd875
|
/RegistrationTableView/Commons/Extensions/UIColor.swift
|
4bc96da07fe254c5c96f2c8904d7298c966dad45
|
[] |
no_license
|
firaskahlout/RegistrationProject
|
3a220f87369571c15f7a9d80affc97350db016e4
|
5b815c38d46b28dc30c9b0d4eb6f22a4eb5bc452
|
refs/heads/master
| 2021-07-22T11:00:21.101034 | 2020-09-04T22:43:01 | 2020-09-04T22:43:01 | 213,567,996 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 438 |
swift
|
//
// UIColor.swift
// RegistrationTableView
//
// Created by IFone on 10/14/19.
// Copyright © 2019 Firas Alkahlout. All rights reserved.
//
import UIKit
extension UIColor {
static var lightRed: UIColor {
return UIColor(red: 230/255, green: 125/255, blue: 115/255, alpha: 1)
}
static var lightGray: UIColor {
return UIColor(red: 244/255, green: 244/255, blue: 244/255, alpha: 1)
}
}
|
[
-1
] |
240971f62443af0482da0194ad89a17ceccabbda
|
d727eda6ca532b9b34a6ce01d02e05b7984dc59c
|
/Interlude/Scenes/Questions/QuestionsInteractor.swift
|
6cdcb9e43cd06f4fe2575f410cd6205414b839e8
|
[] |
no_license
|
gersonnoboa/interlude
|
bf0820f4f7907b41fdaa3b1b21caa1c4b898b7c5
|
0466e74d9aceb91a568fa9d1788043c54278b238
|
refs/heads/master
| 2020-09-02T07:08:16.529758 | 2019-11-07T05:58:33 | 2019-11-07T05:58:33 | 219,163,185 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 700 |
swift
|
//
// QuestionsInteractor.swift
// Interlude
//
// Created by Gerson Noboa on 05/11/2019.
// Copyright (c) 2019 Heavenlapse. All rights reserved.
//
import Foundation
protocol QuestionsInteractorProtocol {
func requestQuestions()
}
final class QuestionsInteractor: QuestionsInteractorProtocol {
var presenter: QuestionsPresenterProtocol
var worker: QuestionsWorkerProtocol
init(presenter: QuestionsPresenterProtocol, worker: QuestionsWorkerProtocol) {
self.presenter = presenter
self.worker = worker
}
func requestQuestions() {
let response = worker.fetchQuestions()
presenter.presentQuestions(with: response)
}
}
|
[
-1
] |
b7ee8268ba2fdfa87c95b6e8512eb7950e11fedd
|
70edab32010a0f60b956de0e21621ef780400350
|
/Fibonacci Sequence/ViewController.swift
|
a92130b79b35c2cb0d3287ea981d74a810a675a5
|
[] |
no_license
|
AshwinGopalakrishnan/Fibonnacci
|
7667920a5ba9c8b5a248bb39d86b81dd16e41758
|
b16345502477c9a55214d63abd4300128f826cb9
|
refs/heads/master
| 2021-01-19T20:57:10.756928 | 2017-10-31T01:51:02 | 2017-10-31T01:51:02 | 101,241,893 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,086 |
swift
|
//
// ViewController.swift
// Fibonacci Sequence
//
// Created by Ashwin Gopalakrishnan on 6/19/17.
// Copyright © 2017 Ashwin Gopalakrishnan. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textView: UITextView!
@IBOutlet weak var includesZeroSwitch: UISwitch!
@IBOutlet weak var incluesZeroLabel: UILabel!
@IBOutlet var numberOfItemsSlider: [UITextView]!
@IBOutlet weak var numberOfIemsSlider: UISlider!
@IBOutlet var numberOfItemsInLabel: [UILabel]!
var fibonacciSequence = FibonacciSequence(numberOfItemsInSequence: 2, includesZero: true)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func updateFibonacciSequence() {
}
}
|
[
-1
] |
e3402bad3004e5a061d4b3437fe7db0421cd2c5c
|
761b48ca090763d39c010b2ffdfe5562c505fae8
|
/Localization-SwiftGen/Localizer/Secret.swift
|
f03708dbf7e8ccbbc64e7a0719936fd4f3ff9215
|
[] |
no_license
|
cuappdev/ios-workshops
|
e24a39c2689d814f6f5eadc9d9efc5c74c7969c0
|
1fe8b0a2c2b3970c1f32a2af488a30336d016772
|
refs/heads/master
| 2020-03-28T09:45:13.378572 | 2019-05-01T17:31:39 | 2019-05-01T17:31:39 | 148,057,517 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,138 |
swift
|
//
// Secret.swift
// Localizer
//
// Created by William Ma on 2/10/19.
// Copyright © 2019 William Ma. All rights reserved.
//
import UIKit
class Secret: UIViewController {
@IBOutlet weak var topImage: UIImageView!
@IBOutlet weak var bottomImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
topImage.image = Asset.southernBrunchProduct.image
bottomImage.image = Asset.untitled.image
var index = 0
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] _ in
guard let `self` = self else { return }
switch index {
case 0: self.view.backgroundColor = Asset.red.color
case 1: self.view.backgroundColor = Asset.yellow.color
case 2: self.view.backgroundColor = Asset.blue.color
case 3: self.view.backgroundColor = Asset.green.color
case 4: self.view.backgroundColor = Asset.purple.color
case 5: self.view.backgroundColor = Asset.orange.color
default: break
}
index += 1
index %= 6
}
}
}
|
[
-1
] |
f5c3c63585239431be4cc88d7ce8be78fcf12527
|
8b4443c42a696fa6c20380c584ffe9e22e092d39
|
/Tests/Services/Modules/Tags/ArtistsByTagViewModelTests.swift
|
fbf88496cc49177f1042f8d2b240c0f0c5f2e73a
|
[] |
no_license
|
icecoffin/MementoFM
|
f73fc94e9829aab89f993588d1044a0e89fb6106
|
a0c5c364a7e242200f761f5998eff1708f66dc86
|
refs/heads/master
| 2023-08-18T04:33:52.007260 | 2022-12-18T21:07:56 | 2022-12-18T21:07:56 | 103,047,011 | 2 | 1 | null | 2019-06-15T12:40:40 | 2017-09-10T17:10:59 |
Swift
|
UTF-8
|
Swift
| false | false | 4,419 |
swift
|
//
// ArtistsByTagViewModelTests.swift
// MementoFMTests
//
// Created by Daniel on 29/11/2017.
// Copyright © 2017 icecoffin. All rights reserved.
//
import XCTest
@testable import MementoFM
import Nimble
import RealmSwift
import Combine
final class ArtistsByTagViewModelTests: XCTestCase {
private final class Dependencies: ArtistsByTagViewModel.Dependencies {
let artistService: ArtistServiceProtocol
init(artistService: ArtistServiceProtocol) {
self.artistService = artistService
}
}
private final class TestArtistsByTagViewModelDelegate: ArtistListViewModelDelegate {
var selectedArtist: Artist?
func artistListViewModel(_ viewModel: ArtistListViewModel, didSelectArtist artist: Artist) {
selectedArtist = artist
}
}
private var collection: MockPersistentMappedCollection<Artist>!
private var artistService: MockArtistService!
private var dependencies: Dependencies!
private var viewModel: ArtistsByTagViewModel!
private var cancelBag: Set<AnyCancellable>!
private var sampleArtists: [Artist] = {
let tag1 = Tag(name: "Tag1", count: 1)
let tag2 = Tag(name: "Tag2", count: 2)
return [
Artist(name: "Artist1", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag1], country: nil),
Artist(name: "Artist2", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag1], country: nil),
Artist(name: "Artist3", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag1], country: nil),
Artist(name: "Artist4", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag2], country: nil),
Artist(name: "Artist5", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag2], country: nil),
Artist(name: "Artist6", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [], topTags: [tag2], country: nil),
Artist(name: "Artist7", playcount: 1, urlString: "", needsTagsUpdate: true, tags: [],
topTags: [tag1, tag2], country: nil)
]
}()
override func setUp() {
artistService = MockArtistService()
collection = MockPersistentMappedCollection<Artist>(values: sampleArtists)
artistService.customMappedCollection = AnyPersistentMappedCollection(collection)
dependencies = Dependencies(artistService: artistService)
cancelBag = .init()
viewModel = ArtistsByTagViewModel(tagName: "Tag1", dependencies: dependencies)
}
override func tearDown() {
artistService = nil
collection = nil
dependencies = nil
cancelBag = nil
viewModel = nil
super.tearDown()
}
// MARK: - itemCount
func test_itemCount_returnsCorrectValue() {
collection.customCount = 4
expect(self.viewModel.itemCount) == 4
}
// MARK: - title
func test_title_returnsCorrectValue() {
expect(self.viewModel.title) == "Tag1"
}
// MARK: - artistViewModelAtIndexPath
func test_artistViewModelAtIndexPath_returnsCorrectValue() {
let indexPath = IndexPath(row: 1, section: 0)
let artistViewModel = viewModel.artistViewModel(at: indexPath)
expect(artistViewModel.name) == "Artist2"
}
// MARK: - selectArtistAtIndexPath
func test_selectArtistAtIndexPath_notifiesDelegate() {
let delegate = TestArtistsByTagViewModelDelegate()
viewModel.delegate = delegate
let indexPath = IndexPath(row: 1, section: 0)
viewModel.selectArtist(at: indexPath)
expect(delegate.selectedArtist) == sampleArtists[1]
}
// MARK: - performSearch
func test_performSearch_setsCorrectPredicate() {
viewModel.performSearch(withText: "test")
let predicateFormat = artistService.customMappedCollection.predicate?.predicateFormat
expect(predicateFormat) == "ANY topTags.name == \"Tag1\" AND name CONTAINS[cd] \"test\""
}
func test_performSearch_emitsDidUpdate() {
var didUpdateData = false
viewModel.didUpdate
.sink(receiveValue: { _ in
didUpdateData = true
})
.store(in: &cancelBag)
viewModel.performSearch(withText: "test")
expect(didUpdateData) == true
}
}
|
[
-1
] |
b30baca7abaafa1ce4ebaf837bef10f7389edaf1
|
23c97ea4a169ac89f386053a7cbbbbf737f2b731
|
/week1/Function in Swift.playground/Contents.swift
|
7a278191e3f7c40e254f9ec8e9b9de8e813b5c3e
|
[] |
no_license
|
wl02722691/practice-AppworkSchool2018Summer-assignment
|
e7db5462f42666159efe3cfe102c83c217a6106f
|
b2b039622d1b2aad947f2e7a0cb18bff119f983e
|
refs/heads/master
| 2020-03-22T11:18:48.437212 | 2018-07-29T11:45:52 | 2018-07-29T11:45:52 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,447 |
swift
|
//1.Please declare a function named greet with person as argument label and parametername. greet method will return a String. For example, if you call the method greet like:greet(person: "Celeste")It will return string: “Hello, Celeste”.
func greet(person:String){
print("Hello,\(person)")
}
greet(person: "Celest")
//2.Please declare a method named multiply with two argument a , b , and with no returnvalue. When you call this method, compiler will print out the result of a * b. Notice that wewant to give argument b with a default value 10. Please implement this requirement.
func multiply(a:Int,b:Int=10){
_ = a * b
}
multiply(a: 3)
multiply(a: 21, b: 3223)
//3.What is the difference between argument label and pararmeter label in function ?
//Parameter Names” 和 “Argument Labels”, 其實就是function內/外名字,可以增加可讀性。
//The use of argument labels can allow a function to be called in an expressive, sentence-like manner, while still providing a function body that is readable and clear in intent
//單純使用argument labels的狀況在24行就會有冗字的感覺
//func move(origin: String, destination: String) -> String {
// return "Move from \(origin) to \(destination)."
//}
//let string = move(origin: "Tokyo", destination: "Taipei")
//print(string)
//設計上若Parameter Namesm與Argument Labels兼用,在30行中用from跟to就可以很明顯地瞭解其解讀性
func move(from origin: String, to destination: String) -> String {
return "Move from \(origin) to \(destination)."
}
let string = move(from: "Tokyo", to: "Taipei")
print(string)
//4.What is the return type in the following statements?
//birthday的return type 是 String
//birthday的return type 是 Double
//Others
//Please describe how to establish a github repo and how to upload the local projects to github. Try to explain it as detail as possible.
//1.先辦github帳號cd
//2.開啟終端機
//3.先到要上傳的檔案
//4.git init讓git開始監視檔案
//5.git status看一下狀態,一開始應該在branch master
//6.輸入git add .將git放到暫存區
//7.git commit -m "現在狀況"
//8.git remote add origin https://github.com/wl02722691/AppworkSchool2018Summer.git(填寫在github上的http)
//9.git remote -v 檢查一下狀態-v代表詳情
//10.git push origin master把本地的狀態推到github
|
[
-1
] |
82765b24fba35b95e65b1dfd98138a88a4078600
|
a7fb23bda128914aa014f502d80b0330e4f699fa
|
/STBaseProject/Classes/STBaseModule/STCommon/STImage.swift
|
72c0f23d53fc351e5658a2f6e47b24b79ca50952
|
[
"MIT"
] |
permissive
|
i-stack/STBaseProject
|
e5838d5994fd92b01d79fd4b38eb4084c2c206d9
|
1566c830ab1a99b40f5ef42e08bfbf3c0ebb7abd
|
refs/heads/master
| 2023-03-12T16:19:20.319058 | 2023-03-01T18:14:24 | 2023-03-01T18:14:24 | 186,945,622 | 255 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,815 |
swift
|
//
// STImage.swift
// STBaseProject
//
// Created by stack on 2018/10/17.
// Copyright © 2018 ST. All rights reserved.
//
import UIKit
public enum STImageFormat {
case STImageFormatPNG
case STImageFormatGIF
case STImageFormatJPEG
case STImageFormatTIFF
case STImageFormatWebP
case STImageFormatHEIC
case STImageFormatHEIF
case STImageFormatUndefined
}
public extension UIImage {
static func st_imageIsEmpty(image: UIImage) -> Bool {
var cgImageIsEmpty: Bool = false
if let _: CGImage = image.cgImage {
cgImageIsEmpty = false
} else {
cgImageIsEmpty = true
}
var ciImageIsEmpty: Bool = false
if let _: CIImage = image.ciImage {
ciImageIsEmpty = false
} else {
ciImageIsEmpty = true
}
if cgImageIsEmpty == true, ciImageIsEmpty == true {
return true
}
return false
}
func st_imageToBase64() -> String {
var content = ""
let imageData = st_imageToData()
if imageData.count > 0 {
content = imageData.base64EncodedString()
}
return content
}
func st_imageToData() -> Data {
var imageData = Data()
if let pngData: Data = self.pngData(), pngData.count > 0 {
imageData = pngData
} else if let jpegData: Data = self.jpegData(compressionQuality: 1.0), jpegData.count > 0 {
imageData = jpegData
}
return imageData
}
func st_imageFormat() -> STImageFormat {
let data = st_imageToData()
let newData = NSData.init(data: data)
if newData.length < 1 {
return .STImageFormatUndefined
}
var c: UInt8?
newData.getBytes(&c, length: 1)
switch c {
case 0xFF:
return .STImageFormatJPEG
case 0x89:
return .STImageFormatPNG
case 0x47:
return .STImageFormatGIF
case 0x49:
return .STImageFormatTIFF
case 0x4D:
return .STImageFormatTIFF
case 0x52:
if newData.length >= 12 {
//RIFF....WEBP
if let testString = NSString.init(data: newData.subdata(with: NSRange.init(location: 0, length: 12)), encoding: String.Encoding.ascii.rawValue) {
if testString.hasPrefix("RIFF"), testString.hasPrefix("WEBP") {
return .STImageFormatWebP
}
}
}
break;
case 0x00:
if newData.length >= 12 {
if let testString = NSString.init(data: newData.subdata(with: NSRange.init(location: 4, length: 8)), encoding: String.Encoding.ascii.rawValue) {
//....ftypheic ....ftypheix ....ftyphevc ....ftyphevx
if testString.isEqual(to: "ftypheic") ||
testString.isEqual(to: "ftypheix") ||
testString.isEqual(to: "ftyphevc") ||
testString.isEqual(to: "ftyphevx") {
return .STImageFormatHEIC
}
//....ftypmif1 ....ftypmsf1
if testString.isEqual(to: "ftypmif1") ||
testString.isEqual(to: "ftypmsf1") {
return .STImageFormatHEIF
}
}
}
break
case .none:
break
case .some(_):
break
}
return .STImageFormatUndefined
}
/// 获取图片某一点的颜色
func st_getPointColor(point: CGPoint) -> UIColor {
guard CGRect(origin: CGPoint(x: 0, y: 0), size: self.size).contains(point) else {
return UIColor.clear
}
let pointX = trunc(point.x);
let pointY = trunc(point.y);
let width = self.size.width;
let height = self.size.height;
let colorSpace = CGColorSpaceCreateDeviceRGB();
var pixelData: [UInt8] = [0, 0, 0, 0]
pixelData.withUnsafeMutableBytes { pointer in
if let context = CGContext(data: pointer.baseAddress, width: 1, height: 1, bitsPerComponent: 8, bytesPerRow: 4, space: colorSpace, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue), let cgImage = self.cgImage {
context.setBlendMode(.copy)
context.translateBy(x: -pointX, y: pointY - height)
context.draw(cgImage, in: CGRect(x: 0, y: 0, width: width, height: height))
}
}
let red = CGFloat(pixelData[0]) / CGFloat(255.0)
let green = CGFloat(pixelData[1]) / CGFloat(255.0)
let blue = CGFloat(pixelData[2]) / CGFloat(255.0)
let alpha = CGFloat(pixelData[3]) / CGFloat(255.0)
if #available(iOS 10.0, *) {
return UIColor(displayP3Red: red, green: green, blue: blue, alpha: alpha)
} else {
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
}
}
}
public extension UIImage {
static func st_getLaunchImage() -> UIImage {
let viewSize = UIScreen.main.bounds.size
var launchImage = ""
if let imageDict = Bundle.main.infoDictionary?["UILaunchImages"] as? Array<Dictionary<String, String>> {
for dict in imageDict {
if let value = dict["UILaunchImageSize"] {
let imageSize = NSCoder.cgSize(for: value)
if imageSize.equalTo(viewSize) {
launchImage = dict["UILaunchImageName"] ?? ""
}
}
}
}
return UIImage.init(named: launchImage) ?? UIImage()
}
}
|
[
-1
] |
ca19712063bc4e4d684cb69aafda9bd63afde859
|
a6e9ec0956bcb497438496a688645cfcf8397e30
|
/10_Timer_Project/9_Timer_Project/ViewController.swift
|
dd883c5657f40541d7f87fce366e0edc958f82c2
|
[] |
no_license
|
ashesh1105/iOS-projects
|
3e76ad53a249a71fb5af540565062c0b8e5aac79
|
8a62e2933fd7bde85462b1bb97a9087267ad29cb
|
refs/heads/master
| 2021-07-12T14:14:43.531374 | 2020-10-16T18:47:29 | 2020-10-16T18:47:29 | 207,577,660 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,900 |
swift
|
// 9_Timer_Project
/*
This project demonstrates the use of threads via Timer object by displaying countdown from 10 to 0 in a label.
You'll need pause between counters printed for a human to see it. If you use Thread.sleep(forTimeInterval: 1)
method in viewDidLoad, that won't work since viewDidLoad runs before view gets loaded so your view won't even
display on app till all counters come down to 0 and then it will display Timer: 0
If you do same code in viewDidAppear, that will be better but there also since you do this in main thread,
label won't get updated till for loop is all done and then you'll see Time: 0 on the label.
Hence we need Timer object here instanciated via a method that allows us to say how many times timer runs, on which object, which objectivbe c function to execute and all of that done as another thread, not the main one.
You do this in viewDidLoad, so before view gets loaded, it displays what you put to label, i.e., Time: 10,
then it instantiates a new Timer thread which runs in parallel to continue updating the label. When counter
reaches 0, you invalidate the Timer and the loop finishes.
Note while running this app, you can click on button (or anything else you put on the app) while Timer is doing
its job!
*/
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var timeLabel: UILabel!
var timer = Timer()
var counter = 0
// Runs before the view gets loaded, so label timers won't work if you put it in this method
override func viewDidLoad() {
super.viewDidLoad()
counter = 10
timeLabel.text = "Time: \(counter)"
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerFunction), userInfo: nil, repeats: true)
}
// Runs after the view gets loaded, so better place to add visible count down timer but there's a catch here!
// override func viewDidAppear(_ animated: Bool) {
//
// // Below code blocks current thread so you will see end result as "Time: 0" but not the progress
// // Best approach in this case will be to run it in a background thread using Timers in viewDidLoad itself, shown above
// var counter = 10
// for _ in 1...10 {
// counter -= 1
// timeLabel.text = "Time: \(counter)"
// Thread.sleep(forTimeInterval: 1)
// }
// }
// This is the #selector objective c function called by Timer timer for specified number of time
@objc func timerFunction() {
timeLabel.text = "Time: \(counter)"
counter -= 1
if counter == 0 {
timer.invalidate() // Must do this once done with a timer
timeLabel.text = "Time is over!"
}
}
@IBAction func buttonClicked(_ sender: Any) {
print("button clicked!")
}
}
|
[
-1
] |
e3fe3ab5cf9026da150a3f493e3a7ac8d4b6186a
|
5c75417ad98b79e48f9f4788c4d2df81e7f9b7fb
|
/Source/Charts/Renderers/BarChartRenderer.swift
|
12712b2c3f0454f2a0b5722e2d6271aa55ee4705
|
[
"Apache-2.0"
] |
permissive
|
iOsNeelShah/Charts
|
22f566a8a5be27ac9c4796bf7b60d2c982729f30
|
73b7923bd4038bd48405db97f0c958122002b551
|
refs/heads/master
| 2022-06-17T07:40:00.885152 | 2020-05-05T13:33:41 | 2020-05-05T13:33:41 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 41,913 |
swift
|
//
// BarChartRenderer.swift
// Charts
//
// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
// A port of MPAndroidChart for iOS
// Licensed under Apache License 2.0
//
// https://github.com/danielgindi/Charts
//
import Foundation
import CoreGraphics
open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
{
/// A nested array of elements ordered logically (i.e not in visual/drawing order) for use with VoiceOver
///
/// Its use is apparent when there are multiple data sets, since we want to read bars in left to right order,
/// irrespective of dataset. However, drawing is done per dataset, so using this array and then flattening it prevents us from needing to
/// re-render for the sake of accessibility.
///
/// In practise, its structure is:
///
/// ````
/// [
/// [dataset1 element1, dataset2 element1],
/// [dataset1 element2, dataset2 element2],
/// [dataset1 element3, dataset2 element3]
/// ...
/// ]
/// ````
/// This is done to provide numerical inference across datasets to a screenreader user, in the same way that a sighted individual
/// uses a multi-dataset bar chart.
///
/// The ````internal```` specifier is to allow subclasses (HorizontalBar) to populate the same array
internal lazy var accessibilityOrderedElements: [[NSUIAccessibilityElement]] = accessibilityCreateEmptyOrderedElements()
private class Buffer
{
var rects = [CGRect]()
}
@objc open weak var dataProvider: BarChartDataProvider?
@objc public init(dataProvider: BarChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler)
{
super.init(animator: animator, viewPortHandler: viewPortHandler)
self.dataProvider = dataProvider
}
// [CGRect] per dataset
private var _buffers = [Buffer]()
open override func initBuffers()
{
if let barData = dataProvider?.barData
{
// Matche buffers count to dataset count
if _buffers.count != barData.dataSetCount
{
while _buffers.count < barData.dataSetCount
{
_buffers.append(Buffer())
}
while _buffers.count > barData.dataSetCount
{
_buffers.removeLast()
}
}
for i in stride(from: 0, to: barData.dataSetCount, by: 1)
{
let set = barData.dataSets[i] as! IBarChartDataSet
let size = set.entryCount * (set.isStacked ? set.stackSize : 1)
if _buffers[i].rects.count != size
{
_buffers[i].rects = [CGRect](repeating: CGRect(), count: size)
}
}
}
else
{
_buffers.removeAll()
}
}
private func prepareBuffer(dataSet: IBarChartDataSet, index: Int)
{
guard
let dataProvider = dataProvider,
let barData = dataProvider.barData
else { return }
let barWidthHalf = barData.barWidth / 2.0
let buffer = _buffers[index]
var bufferIndex = 0
let containsStacks = dataSet.isStacked
let isInverted = dataProvider.isInverted(axis: dataSet.axisDependency)
let phaseY = animator.phaseY
var barRect = CGRect()
var x: Double
var y: Double
for i in stride(from: 0, to: min(Int(ceil(Double(dataSet.entryCount) * animator.phaseX)), dataSet.entryCount), by: 1)
{
guard let e = dataSet.entryForIndex(i) as? BarChartDataEntry else { continue }
let vals = e.yValues
x = e.x
y = e.y
if !containsStacks || vals == nil
{
let left = CGFloat(x - barWidthHalf)
let right = CGFloat(x + barWidthHalf)
var top = isInverted
? (y <= 0.0 ? CGFloat(y) : 0)
: (y >= 0.0 ? CGFloat(y) : 0)
var bottom = isInverted
? (y >= 0.0 ? CGFloat(y) : 0)
: (y <= 0.0 ? CGFloat(y) : 0)
/* When drawing each bar, the renderer actually draws each bar from 0 to the required value.
* This drawn bar is then clipped to the visible chart rect in BarLineChartViewBase's draw(rect:) using clipDataToContent.
* While this works fine when calculating the bar rects for drawing, it causes the accessibilityFrames to be oversized in some cases.
* This offset attempts to undo that unnecessary drawing when calculating barRects
*
* +---------------------------------------------------------------+---------------------------------------------------------------+
* | Situation 1: (!inverted && y >= 0) | Situation 3: (inverted && y >= 0) |
* | | |
* | y -> +--+ <- top | 0 -> ---+--+---+--+------ <- top |
* | |//| } topOffset = y - max | | | |//| } topOffset = min |
* | max -> +---------+--+----+ <- top - topOffset | min -> +--+--+---+--+----+ <- top + topOffset |
* | | +--+ |//| | | | | | |//| | |
* | | | | |//| | | | +--+ |//| | |
* | | | | |//| | | | |//| | |
* | min -> +--+--+---+--+----+ <- bottom + bottomOffset | max -> +---------+--+----+ <- bottom - bottomOffset |
* | | | |//| } bottomOffset = min | |//| } bottomOffset = y - max |
* | 0 -> ---+--+---+--+----- <- bottom | y -> +--+ <- bottom |
* | | |
* +---------------------------------------------------------------+---------------------------------------------------------------+
* | Situation 2: (!inverted && y < 0) | Situation 4: (inverted && y < 0) |
* | | |
* | 0 -> ---+--+---+--+----- <- top | y -> +--+ <- top |
* | | | |//| } topOffset = -max | |//| } topOffset = min - y |
* | max -> +--+--+---+--+----+ <- top - topOffset | min -> +---------+--+----+ <- top + topOffset |
* | | | | |//| | | | +--+ |//| | |
* | | +--+ |//| | | | | | |//| | |
* | | |//| | | | | | |//| | |
* | min -> +---------+--+----+ <- bottom + bottomOffset | max -> +--+--+---+--+----+ <- bottom - bottomOffset |
* | |//| } bottomOffset = min - y | | | |//| } bottomOffset = -max |
* | y -> +--+ <- bottom | 0 -> ---+--+---+--+------- <- bottom |
* | | |
* +---------------------------------------------------------------+---------------------------------------------------------------+
*/
var topOffset: CGFloat = 0.0
var bottomOffset: CGFloat = 0.0
if let offsetView = dataProvider as? BarChartView
{
let offsetAxis = offsetView.getAxis(dataSet.axisDependency)
if y >= 0
{
// situation 1
if offsetAxis.axisMaximum < y
{
topOffset = CGFloat(y - offsetAxis.axisMaximum)
}
if offsetAxis.axisMinimum > 0
{
bottomOffset = CGFloat(offsetAxis.axisMinimum)
}
}
else // y < 0
{
//situation 2
if offsetAxis.axisMaximum < 0
{
topOffset = CGFloat(offsetAxis.axisMaximum * -1)
}
if offsetAxis.axisMinimum > y
{
bottomOffset = CGFloat(offsetAxis.axisMinimum - y)
}
}
if isInverted
{
// situation 3 and 4
// exchange topOffset/bottomOffset based on 1 and 2
// see diagram above
(topOffset, bottomOffset) = (bottomOffset, topOffset)
}
}
//apply offset
top = isInverted ? top + topOffset : top - topOffset
bottom = isInverted ? bottom - bottomOffset : bottom + bottomOffset
// multiply the height of the rect with the phase
// explicitly add 0 + topOffset to indicate this is changed after adding accessibility support (#3650, #3520)
if top > 0 + topOffset
{
top *= CGFloat(phaseY)
}
else
{
bottom *= CGFloat(phaseY)
}
barRect.origin.x = left
barRect.origin.y = top
barRect.size.width = right - left
barRect.size.height = bottom - top
buffer.rects[bufferIndex] = barRect
bufferIndex += 1
}
else
{
var posY = 0.0
var negY = -e.negativeSum
var yStart = 0.0
// fill the stack
for k in 0 ..< vals!.count
{
let value = vals![k]
if value == 0.0 && (posY == 0.0 || negY == 0.0)
{
// Take care of the situation of a 0.0 value, which overlaps a non-zero bar
y = value
yStart = y
}
else if value >= 0.0
{
y = posY
yStart = posY + value
posY = yStart
}
else
{
y = negY
yStart = negY + abs(value)
negY += abs(value)
}
let left = CGFloat(x - barWidthHalf)
let right = CGFloat(x + barWidthHalf)
var top = isInverted
? (y <= yStart ? CGFloat(y) : CGFloat(yStart))
: (y >= yStart ? CGFloat(y) : CGFloat(yStart))
var bottom = isInverted
? (y >= yStart ? CGFloat(y) : CGFloat(yStart))
: (y <= yStart ? CGFloat(y) : CGFloat(yStart))
// multiply the height of the rect with the phase
top *= CGFloat(phaseY)
bottom *= CGFloat(phaseY)
barRect.origin.x = left
barRect.size.width = right - left
barRect.origin.y = top
barRect.size.height = bottom - top
buffer.rects[bufferIndex] = barRect
bufferIndex += 1
}
}
}
}
open override func drawData(context: CGContext)
{
guard
let dataProvider = dataProvider,
let barData = dataProvider.barData
else { return }
// If we redraw the data, remove and repopulate accessible elements to update label values and frames
accessibleChartElements.removeAll()
accessibilityOrderedElements = accessibilityCreateEmptyOrderedElements()
// Make the chart header the first element in the accessible elements array
if let chart = dataProvider as? BarChartView {
let element = createAccessibleHeader(usingChart: chart,
andData: barData,
withDefaultDescription: "Bar Chart")
accessibleChartElements.append(element)
}
// Populate logically ordered nested elements into accessibilityOrderedElements in drawDataSet()
for i in 0 ..< barData.dataSetCount
{
guard let set = barData.getDataSetByIndex(i) else { continue }
if set.isVisible
{
if !(set is IBarChartDataSet)
{
fatalError("Datasets for BarChartRenderer must conform to IBarChartDataset")
}
drawDataSet(context: context, dataSet: set as! IBarChartDataSet, index: i)
}
}
// Merge nested ordered arrays into the single accessibleChartElements.
accessibleChartElements.append(contentsOf: accessibilityOrderedElements.flatMap { $0 } )
accessibilityPostLayoutChangedNotification()
}
private var _barShadowRectBuffer: CGRect = CGRect()
@objc open func drawDataSet(context: CGContext, dataSet: IBarChartDataSet, index: Int)
{
guard let dataProvider = dataProvider else { return }
let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency)
prepareBuffer(dataSet: dataSet, index: index)
trans.rectValuesToPixel(&_buffers[index].rects)
let borderWidth = dataSet.barBorderWidth
let borderColor = dataSet.barBorderColor
let drawBorder = borderWidth > 0.0
let dashBorderWidh = dataSet.dashBorderWidth
let dashBorder = dashBorderWidh > 0.0
context.saveGState()
// draw the bar shadow before the values
if dataProvider.isDrawBarShadowEnabled
{
guard let barData = dataProvider.barData else { return }
let barWidth = barData.barWidth
let barWidthHalf = barWidth / 2.0
var x: Double = 0.0
for i in stride(from: 0, to: min(Int(ceil(Double(dataSet.entryCount) * animator.phaseX)), dataSet.entryCount), by: 1)
{
guard let e = dataSet.entryForIndex(i) as? BarChartDataEntry else { continue }
x = e.x
_barShadowRectBuffer.origin.x = CGFloat(x - barWidthHalf)
_barShadowRectBuffer.size.width = CGFloat(barWidth)
trans.rectValueToPixel(&_barShadowRectBuffer)
if !viewPortHandler.isInBoundsLeft(_barShadowRectBuffer.origin.x + _barShadowRectBuffer.size.width)
{
continue
}
if !viewPortHandler.isInBoundsRight(_barShadowRectBuffer.origin.x)
{
break
}
_barShadowRectBuffer.origin.y = viewPortHandler.contentTop
_barShadowRectBuffer.size.height = viewPortHandler.contentHeight
context.setFillColor(dataSet.barShadowColor.cgColor)
context.fill(_barShadowRectBuffer)
}
}
let buffer = _buffers[index]
// draw the bar shadow before the values
if dataProvider.isDrawBarShadowEnabled
{
for j in stride(from: 0, to: buffer.rects.count, by: 1)
{
let barRect = buffer.rects[j]
if (!viewPortHandler.isInBoundsLeft(barRect.origin.x + barRect.size.width))
{
continue
}
if (!viewPortHandler.isInBoundsRight(barRect.origin.x))
{
break
}
context.setFillColor(dataSet.barShadowColor.cgColor)
context.fill(barRect)
}
}
let isSingleColor = dataSet.colors.count == 1
if isSingleColor
{
context.setFillColor(dataSet.color(atIndex: 0).cgColor)
}
// In case the chart is stacked, we need to accomodate individual bars within accessibilityOrdereredElements
let isStacked = dataSet.isStacked
let stackSize = isStacked ? dataSet.stackSize : 1
for j in stride(from: 0, to: buffer.rects.count, by: 1)
{
let barRect = buffer.rects[j]
if (!viewPortHandler.isInBoundsLeft(barRect.origin.x + barRect.size.width))
{
continue
}
if (!viewPortHandler.isInBoundsRight(barRect.origin.x))
{
break
}
if !isSingleColor
{
// Set the color for the currently drawn value. If the index is out of bounds, reuse colors.
context.setFillColor(dataSet.color(atIndex: j).cgColor)
}
if dataSet.showCornerRadious == true
{
let clipPath = UIBezierPath(roundedRect: barRect, cornerRadius: CGFloat(dataSet.cornerRadiousValue)).cgPath
context.addPath(clipPath)
context.closePath()
context.fillPath()
}
else{
context.fill(barRect)
}
if drawBorder
{
context.setStrokeColor(borderColor.cgColor)
context.setLineWidth(borderWidth)
context.stroke(barRect)
}
if dashBorder && (j % dataSet.moduleToShowDash == 0){
context.setStrokeColor(borderColor.cgColor)
context.setLineWidth(dashBorderWidh)
context.setLineDash(phase: 3, lengths: [3,3])
context.stroke(CGRect(x: barRect.origin.x + 1, y: barRect.origin.y, width: barRect.size.width - 2, height: barRect.size.height))
}
// Create and append the corresponding accessibility element to accessibilityOrderedElements
if let chart = dataProvider as? BarChartView
{
let element = createAccessibleElement(withIndex: j,
container: chart,
dataSet: dataSet,
dataSetIndex: index,
stackSize: stackSize)
{ (element) in
element.accessibilityFrame = barRect
}
accessibilityOrderedElements[j/stackSize].append(element)
}
}
context.restoreGState()
}
open func prepareBarHighlight(
x: Double,
y1: Double,
y2: Double,
barWidthHalf: Double,
trans: Transformer,
rect: inout CGRect)
{
let left = x - barWidthHalf
let right = x + barWidthHalf
let top = y1
let bottom = y2
rect.origin.x = CGFloat(left)
rect.origin.y = CGFloat(top)
rect.size.width = CGFloat(right - left)
rect.size.height = CGFloat(bottom - top)
trans.rectValueToPixel(&rect, phaseY: animator.phaseY )
}
open override func drawValues(context: CGContext)
{
// if values are drawn
if isDrawingValuesAllowed(dataProvider: dataProvider)
{
guard
let dataProvider = dataProvider,
let barData = dataProvider.barData
else { return }
var dataSets = barData.dataSets
let valueOffsetPlus: CGFloat = 4.5
var posOffset: CGFloat
var negOffset: CGFloat
let drawValueAboveBar = dataProvider.isDrawValueAboveBarEnabled
for dataSetIndex in 0 ..< barData.dataSetCount
{
guard let
dataSet = dataSets[dataSetIndex] as? IBarChartDataSet,
shouldDrawValues(forDataSet: dataSet)
else { continue }
let isInverted = dataProvider.isInverted(axis: dataSet.axisDependency)
// calculate the correct offset depending on the draw position of the value
let valueFont = dataSet.valueFont
let valueTextHeight = valueFont.lineHeight
posOffset = (drawValueAboveBar ? -(valueTextHeight + valueOffsetPlus) : valueOffsetPlus)
negOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextHeight + valueOffsetPlus))
if isInverted
{
posOffset = -posOffset - valueTextHeight
negOffset = -negOffset - valueTextHeight
}
let buffer = _buffers[dataSetIndex]
guard let formatter = dataSet.valueFormatter else { continue }
let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency)
let phaseY = animator.phaseY
let iconsOffset = dataSet.iconsOffset
// if only single values are drawn (sum)
if !dataSet.isStacked
{
for j in 0 ..< Int(ceil(Double(dataSet.entryCount) * animator.phaseX))
{
guard let e = dataSet.entryForIndex(j) as? BarChartDataEntry else { continue }
let rect = buffer.rects[j]
let x = rect.origin.x + rect.size.width / 2.0
if !viewPortHandler.isInBoundsRight(x)
{
break
}
if !viewPortHandler.isInBoundsY(rect.origin.y)
|| !viewPortHandler.isInBoundsLeft(x)
{
continue
}
let val = e.y
if dataSet.isDrawValuesEnabled
{
drawValue(
context: context,
value: formatter.stringForValue(
val,
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler),
xPos: x,
yPos: val >= 0.0
? (rect.origin.y + posOffset)
: (rect.origin.y + rect.size.height + negOffset),
font: valueFont,
align: .center,
color: dataSet.valueTextColorAt(j))
}
if let icon = e.icon, dataSet.isDrawIconsEnabled
{
var px = x
var py = val >= 0.0
? (rect.origin.y + posOffset)
: (rect.origin.y + rect.size.height + negOffset)
px += iconsOffset.x
py += iconsOffset.y
ChartUtils.drawImage(
context: context,
image: icon,
x: px,
y: py,
size: icon.size)
}
}
}
else
{
// if we have stacks
var bufferIndex = 0
for index in 0 ..< Int(ceil(Double(dataSet.entryCount) * animator.phaseX))
{
guard let e = dataSet.entryForIndex(index) as? BarChartDataEntry else { continue }
let vals = e.yValues
let rect = buffer.rects[bufferIndex]
let x = rect.origin.x + rect.size.width / 2.0
// we still draw stacked bars, but there is one non-stacked in between
if vals == nil
{
if !viewPortHandler.isInBoundsRight(x)
{
break
}
if !viewPortHandler.isInBoundsY(rect.origin.y)
|| !viewPortHandler.isInBoundsLeft(x)
{
continue
}
if dataSet.isDrawValuesEnabled
{
drawValue(
context: context,
value: formatter.stringForValue(
e.y,
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler),
xPos: x,
yPos: rect.origin.y +
(e.y >= 0 ? posOffset : negOffset),
font: valueFont,
align: .center,
color: dataSet.valueTextColorAt(index))
}
if let icon = e.icon, dataSet.isDrawIconsEnabled
{
var px = x
var py = rect.origin.y +
(e.y >= 0 ? posOffset : negOffset)
px += iconsOffset.x
py += iconsOffset.y
ChartUtils.drawImage(
context: context,
image: icon,
x: px,
y: py,
size: icon.size)
}
}
else
{
// draw stack values
let vals = vals!
var transformed = [CGPoint]()
var posY = 0.0
var negY = -e.negativeSum
for k in 0 ..< vals.count
{
let value = vals[k]
var y: Double
if value == 0.0 && (posY == 0.0 || negY == 0.0)
{
// Take care of the situation of a 0.0 value, which overlaps a non-zero bar
y = value
}
else if value >= 0.0
{
posY += value
y = posY
}
else
{
y = negY
negY -= value
}
transformed.append(CGPoint(x: 0.0, y: CGFloat(y * phaseY)))
}
trans.pointValuesToPixel(&transformed)
for k in 0 ..< transformed.count
{
let val = vals[k]
let drawBelow = (val == 0.0 && negY == 0.0 && posY > 0.0) || val < 0.0
let y = transformed[k].y + (drawBelow ? negOffset : posOffset)
if !viewPortHandler.isInBoundsRight(x)
{
break
}
if !viewPortHandler.isInBoundsY(y) || !viewPortHandler.isInBoundsLeft(x)
{
continue
}
if dataSet.isDrawValuesEnabled
{
let dashBorderWidh = dataSet.dashBorderWidth
let dashBorder = dashBorderWidh > 0.0
if dashBorder && (k % dataSet.moduleToShowDash == 0){
}
else{
drawValue(
context: context,
value: formatter.stringForValue(
vals[k],
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler),
xPos: x,
yPos: y,
font: valueFont,
align: .center,
color: dataSet.valueTextColorAt(index))
}
}
if let icon = e.icon, dataSet.isDrawIconsEnabled
{
if dataSet.isToShowIconAtSpecific == true{
if dataSet.barIndex == index && dataSet.barInnerIndex == k{
ChartUtils.drawImage(
context: context,
image: icon,
x: x + iconsOffset.x,
y: y + iconsOffset.y,
size: icon.size)
}
}
else if dataSet.barInnerIndex > 0 && dataSet.barInnerIndex == k{
let imageSecond = e.data as! UIImage
ChartUtils.drawImage(
context: context,
image: imageSecond,
x: x + iconsOffset.x,
y: y + iconsOffset.y,
size: icon.size)
}
else{
ChartUtils.drawImage(
context: context,
image: icon,
x: x + iconsOffset.x,
y: y + iconsOffset.y,
size: icon.size)
}
}
}
}
bufferIndex = vals == nil ? (bufferIndex + 1) : (bufferIndex + vals!.count)
}
}
}
}
}
/// Draws a value at the specified x and y position.
@objc open func drawValue(context: CGContext, value: String, xPos: CGFloat, yPos: CGFloat, font: NSUIFont, align: NSTextAlignment, color: NSUIColor)
{
ChartUtils.drawText(context: context, text: value, point: CGPoint(x: xPos, y: yPos), align: align, attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: color])
}
open override func drawExtras(context: CGContext)
{
}
open override func drawHighlighted(context: CGContext, indices: [Highlight])
{
guard
let dataProvider = dataProvider,
let barData = dataProvider.barData
else { return }
context.saveGState()
var barRect = CGRect()
for high in indices
{
guard
let set = barData.getDataSetByIndex(high.dataSetIndex) as? IBarChartDataSet,
set.isHighlightEnabled
else { continue }
if let e = set.entryForXValue(high.x, closestToY: high.y) as? BarChartDataEntry
{
if !isInBoundsX(entry: e, dataSet: set)
{
continue
}
let trans = dataProvider.getTransformer(forAxis: set.axisDependency)
context.setFillColor(set.highlightColor.cgColor)
context.setAlpha(set.highlightAlpha)
let isStack = high.stackIndex >= 0 && e.isStacked
let y1: Double
let y2: Double
if isStack
{
if dataProvider.isHighlightFullBarEnabled
{
y1 = e.positiveSum
y2 = -e.negativeSum
}
else
{
let range = e.ranges?[high.stackIndex]
y1 = range?.from ?? 0.0
y2 = range?.to ?? 0.0
}
}
else
{
y1 = e.y
y2 = 0.0
}
prepareBarHighlight(x: e.x, y1: y1, y2: y2, barWidthHalf: barData.barWidth / 2.0, trans: trans, rect: &barRect)
setHighlightDrawPos(highlight: high, barRect: barRect)
context.fill(barRect)
}
}
context.restoreGState()
}
/// Sets the drawing position of the highlight object based on the given bar-rect.
internal func setHighlightDrawPos(highlight high: Highlight, barRect: CGRect)
{
high.setDraw(x: barRect.midX, y: barRect.origin.y)
}
/// Creates a nested array of empty subarrays each of which will be populated with NSUIAccessibilityElements.
/// This is marked internal to support HorizontalBarChartRenderer as well.
internal func accessibilityCreateEmptyOrderedElements() -> [[NSUIAccessibilityElement]]
{
guard let chart = dataProvider as? BarChartView else { return [] }
// Unlike Bubble & Line charts, here we use the maximum entry count to account for stacked bars
let maxEntryCount = chart.data?.maxEntryCountSet?.entryCount ?? 0
return Array(repeating: [NSUIAccessibilityElement](),
count: maxEntryCount)
}
/// Creates an NSUIAccessibleElement representing the smallest meaningful bar of the chart
/// i.e. in case of a stacked chart, this returns each stack, not the combined bar.
/// Note that it is marked internal to support subclass modification in the HorizontalBarChart.
internal func createAccessibleElement(withIndex idx: Int,
container: BarChartView,
dataSet: IBarChartDataSet,
dataSetIndex: Int,
stackSize: Int,
modifier: (NSUIAccessibilityElement) -> ()) -> NSUIAccessibilityElement
{
let element = NSUIAccessibilityElement(accessibilityContainer: container)
let xAxis = container.xAxis
guard let e = dataSet.entryForIndex(idx/stackSize) as? BarChartDataEntry else { return element }
guard let dataProvider = dataProvider else { return element }
// NOTE: The formatter can cause issues when the x-axis labels are consecutive ints.
// i.e. due to the Double conversion, if there are more than one data set that are grouped,
// there is the possibility of some labels being rounded up. A floor() might fix this, but seems to be a brute force solution.
let label = xAxis.valueFormatter?.stringForValue(e.x, axis: xAxis) ?? "\(e.x)"
var elementValueText = dataSet.valueFormatter?.stringForValue(
e.y,
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler) ?? "\(e.y)"
if dataSet.isStacked, let vals = e.yValues
{
let labelCount = min(dataSet.colors.count, stackSize)
let stackLabel: String?
if (dataSet.stackLabels.count > 0 && labelCount > 0) {
let labelIndex = idx % labelCount
stackLabel = dataSet.stackLabels.indices.contains(labelIndex) ? dataSet.stackLabels[labelIndex] : nil
} else {
stackLabel = nil
}
elementValueText = dataSet.valueFormatter?.stringForValue(
vals[idx % stackSize],
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler) ?? "\(e.y)"
if let stackLabel = stackLabel {
elementValueText = stackLabel + " \(elementValueText)"
} else {
elementValueText = "\(elementValueText)"
}
}
let dataSetCount = dataProvider.barData?.dataSetCount ?? -1
let doesContainMultipleDataSets = dataSetCount > 1
element.accessibilityLabel = "\(doesContainMultipleDataSets ? (dataSet.label ?? "") + ", " : "") \(label): \(elementValueText)"
modifier(element)
return element
}
}
|
[
192171,
361486,
97456,
237457,
54544,
185012,
319445,
221977,
248669
] |
5de3ed3490b89685396c4d98e1af6ce6f37a5e8e
|
64295f98abaf9dd81486d8dd1948429fa48f8342
|
/TableViewApp/TableViewApp/Photo.swift
|
dc7f4a4400a9b19ab68f0431b1151bcf21157a3f
|
[
"MIT"
] |
permissive
|
Roy-wonji/iOSProjects
|
6895d38cb02f16a2c2739d0ad2b6a0019bd4e1a4
|
429f89bfabfd198bf5a722e62fa9472a851f99d7
|
refs/heads/master
| 2023-08-01T01:52:14.646723 | 2021-09-21T15:37:40 | 2021-09-21T15:37:40 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 942 |
swift
|
//
// Photo.swift
// TableViewApp
//
// Created by Halil Özel on 15.08.2018.
// Copyright © 2018 Halil Özel. All rights reserved.
//
import Foundation
class Photo {
var name : String = ""
var profileImage : String = ""
var caption : String = ""
var thumbnailImageName : String = ""
init(name:String,profileImage:String,caption:String,thumbnailImageName:String) {
self.name = name
self.profileImage = profileImage
self.caption = caption
self.thumbnailImageName = thumbnailImageName
}
class func downloadAllPhotos() -> [Photo]{
var photos = [Photo]()
for i in 1...6 {
let photo = Photo(name: "\(i)", profileImage: "p\(i)", caption: "hello guys", thumbnailImageName: "t\(i)")
photos.append(photo)
}
return photos
}
}
|
[
-1
] |
80a5093952ea23094a911d575c3abb596860ea2f
|
331fd467fcf097004c9ee9f771bdeb4799a7e64d
|
/ZUrl.Apple.swift
|
eaea16f09a51519d16c77f0a24ac3b7871c717b5
|
[
"MIT"
] |
permissive
|
torlangballe/cetrusapple
|
663d58d73d28bb639a0df683faf4b4673eb79a39
|
ec487ee1b8666ca098004748c29502069eac5e7d
|
refs/heads/master
| 2022-01-13T22:09:05.148134 | 2019-05-24T13:40:35 | 2019-05-24T13:40:35 | 118,171,207 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,549 |
swift
|
//
// ZUrl.swift
//
// Created by Tor Langballe on /30/10/15.
//
import Foundation
#if os(iOS)
import SafariServices
import MobileCoreServices
#endif
class ZUrl : Hashable {
var url: URL?
var hashValue: Int {
return url?.hashValue ?? 0
}
init() {
url = nil
}
init(string:String) {
if let u = URL(string:string) {
url = u
} else {
url = nil
}
}
init(nsUrl:URL) {
url = nsUrl
}
init(url:ZUrl) {
self.url = url.url
}
var IsEmpty : Bool {
return url == nil
}
func IsDirectory() -> Bool {
if url == nil {
return false
}
var o: AnyObject?
do {
try (url! as NSURL).getResourceValue(&o, forKey:URLResourceKey.isDirectoryKey)
} catch {
// handle error
}
if let n = o as? NSNumber {
return n.intValue == 1
}
return false
}
func OpenInBrowser(inApp:Bool, notInAppForSocial:Bool = true) {
var out = false
if inApp {
if let host = url?.host {
if host.hasSuffix("twitter.com") || host.hasSuffix("facebook.com") {
out = true
}
}
}
#if os(iOS)
if inApp && !out {
let c = SFSafariViewController(url:url!)
ZGetTopViewController()!.present(c, animated:true, completion:nil)
return
}
UIApplication.shared.open(url!, options:[:]) // can have completion handler too
#endif
}
func GetName() -> String {
if url != nil {
return url!.lastPathComponent // if lastPathComponent is nil, ?? returns ""
}
return ""
}
var Scheme : String{
get { return url?.scheme ?? "" }
}
var Host : String {
get { return url?.host ?? "" }
}
var Port : Int {
get { return url?.port ?? -1 }
}
var AbsString : String {
get { return url?.absoluteString ?? "" }
}
var ResourcePath : String {
get { return url?.path ?? "" }
}
var Extension : String {
get { return url?.pathExtension ?? "" }
set {
if url != nil {
url = url!.appendingPathExtension(newValue)
}
}
}
var Anchor : String { // called fragment really
return url?.fragment ?? ""
}
var Parameters: [String:String] {
get {
if let q = url?.query {
return ZUrl.ParametersFromString(q)
}
let tail = ZStr.TailUntil((url?.absoluteString) ?? "", sep:"?")
if !tail.isEmpty {
return ZUrl.ParametersFromString(tail)
}
return [String:String]()
}
}
static func ParametersFromString(_ parameters:String) -> [String:String] {
var queryStrings = [String: String]()
for qs in parameters.components(separatedBy: "&") {
let comps = qs.components(separatedBy: "=")
if comps.count == 2 {
let key = comps[0]
var value = comps[1]
value = value.replacingOccurrences(of: "+", with: " ")
value = value.removingPercentEncoding ?? ""
queryStrings[key] = value
}
}
return queryStrings
}
}
func ==(lhs: ZUrl, rhs: ZUrl) -> Bool {
return lhs.url == rhs.url
}
|
[
-1
] |
cddd01e40cd5baf16d9ed6baa8a8d80fdb00eb39
|
df4b09243202ac801027431274683755a1b3836e
|
/smartList/View Controllers/New Group/ListHomeVC.swift
|
e5bfd7de37cb016f28b64938459d3842afd2f15d
|
[] |
no_license
|
sdito/Food-Guru
|
4414e0fba60a04b12cffab72c0ae43202a3579f7
|
2c3d502a9a0da45943055771961b169b5ce455db
|
refs/heads/master
| 2022-11-16T05:02:56.591208 | 2019-10-23T22:52:04 | 2019-10-23T22:52:04 | 201,183,075 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,277 |
swift
|
//
// ListHomeVC.swift
// smartList
//
// Created by Steven Dito on 9/5/19.
// Copyright © 2019 Steven Dito. All rights reserved.
//
import UIKit
import FirebaseFirestore
class ListHomeVC: UIViewController {
@IBOutlet weak var tableView: UITableView!
var db: Firestore!
var sections: [String]?
var listsForSections: [[List]]?
lazy private var emptyCells: [UITableViewCell] = createEmptyListCells()
private var items: [Item] = []
private var lists: [List]? {
didSet {
(sections, listsForSections) = self.lists?.organizeTableViewForListHome() ?? (nil, nil)
tableView.reloadData()
}
}
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.setNavigationBarHidden(true, animated: animated)
//super.viewWillAppear(animated)
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
createObserver()
db = Firestore.firestore()
List.readAllUserLists(db: db, userID: SharedValues.shared.userID!) { (dbLists) in
self.lists = dbLists
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "listSelected" {
let destVC = segue.destination as! AddItemsVC
destVC.list = sender as? List
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@IBAction func setUpList(_ sender: Any) {
let vc = storyboard?.instantiateViewController(withIdentifier: "setUpList") as! SetUpListVC
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true, completion: nil)
}
private func createObserver() {
NotificationCenter.default.addObserver(self, selector: #selector(observerSelectorGroupID), name: .groupIDchanged, object: nil)
}
@objc func observerSelectorGroupID() {
emptyCells = createEmptyListCells()
tableView.reloadData()
}
}
extension ListHomeVC: UITableViewDataSource, UITableViewDelegate {
func createEmptyListCells() -> [UITableViewCell] {
let one = tableView.dequeueReusableCell(withIdentifier: "settingBasicCell") as! SettingBasicCell
var hasGroup: Bool {
switch SharedValues.shared.groupID {
case nil:
return false
default:
return true
}
}
var groupText: String {
switch hasGroup {
case false:
return "Create a group in order to have your lists shared with other people."
case true:
return ""
}
}
one.setUI(str: "You do not have any lists created or shared with you yet.\(groupText)")
switch hasGroup {
case true:
return [one]
case false:
let two = tableView.dequeueReusableCell(withIdentifier: "settingButtonCell") as! SettingButtonCell
two.setUI(title: "Create group")
two.button.addTarget(self, action: #selector(self.createGroupPopUp), for: .touchUpInside)
return [one, two]
}
}
func numberOfSections(in tableView: UITableView) -> Int {
switch lists?.count {
case 0:
return 1
default:
return sections?.count ?? 1
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch lists?.count {
case 0:
return emptyCells.count
default:
return listsForSections?[section].count ?? 0
}
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
switch lists?.count {
case 0:
let view = UIView()
view.alpha = 0
return view
default:
let label = UILabel()
label.text = sections?[section]
label.font = UIFont(name: "futura", size: 15)
label.backgroundColor = .lightGray
label.textColor = .white
label.alpha = 0.8
return label
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch lists?.count {
case 0:
return emptyCells[indexPath.row]
default:
let item = listsForSections![indexPath.section][indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "listHomeCell", for: indexPath) as! ListHomeCell
cell.setUI(list: item)
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//let l = lists![indexPath.row]
if lists?.count != 0 {
let l = listsForSections?[indexPath.section][indexPath.row]
SharedValues.shared.listIdentifier = self.db.collection("lists").document("\(l?.docID! ?? " ")")
self.performSegue(withIdentifier: "listSelected", sender: l)
}
}
}
|
[
-1
] |
ed2956d1b8898878584869689000606fdd10df97
|
3ae4a422892eea81d0a47b9ef681fadc4b85cdfc
|
/ViperProductDemo/ViperProductDemoUITests/ViperProductDemoUITests.swift
|
5545320c0a3c23398cf963a43fa99c927d77686e
|
[] |
no_license
|
PriyankaLohri/PSViperDemo
|
203baf4e36943caa61938ff9b7e394eeb28a39a3
|
82d3cf026c63e9854cdd6dd5dd7267cb0d37b1f7
|
refs/heads/master
| 2020-09-09T18:49:08.809878 | 2019-11-13T19:33:27 | 2019-11-13T19:33:27 | 221,533,528 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,183 |
swift
|
//
// ViperProductDemoUITests.swift
// ViperProductDemoUITests
//
// Created by Priyanka on 20/10/19.
// Copyright © 2019 Priyanka. All rights reserved.
//
import XCTest
class ViperProductDemoUITests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
333827,
243720,
282634,
313356,
155665,
241695,
237599,
223269,
229414,
292901,
315431,
315433,
102441,
325675,
354346,
278571,
124974,
282671,
102446,
229425,
243763,
241717,
321589,
229431,
180279,
215095,
319543,
288829,
325695,
288835,
237638,
313415,
239689,
315468,
311373,
278607,
196687,
311377,
354386,
223317,
315477,
354394,
323678,
321632,
315489,
45154,
313446,
227432,
215144,
233578,
194667,
307306,
288878,
319599,
278642,
284789,
131190,
288890,
292987,
215165,
131199,
227459,
194692,
235661,
278669,
241809,
323730,
278676,
311447,
153752,
327834,
284827,
278684,
299166,
278690,
311459,
215204,
299176,
184489,
278698,
284843,
284840,
278703,
184498,
278707,
125108,
180409,
278713,
295099,
223418,
299197,
258233,
280767,
227517,
280761,
299202,
139459,
309443,
176325,
131270,
301255,
227525,
299208,
280779,
227536,
282832,
321744,
301270,
229591,
280792,
301271,
311520,
325857,
280803,
182503,
319719,
307431,
338151,
295147,
317676,
286957,
125166,
125170,
313595,
125180,
184574,
125184,
309504,
217352,
125192,
125197,
125200,
227601,
125204,
319764,
278805,
334104,
315674,
282908,
299294,
125215,
282912,
233761,
278817,
125216,
311582,
211239,
282920,
125225,
317738,
311596,
321839,
315698,
98611,
125236,
307514,
282938,
278843,
168251,
319812,
311622,
227655,
280903,
319816,
323914,
201037,
282959,
229716,
289109,
168280,
379224,
391521,
239973,
381286,
313703,
285031,
280938,
242027,
242028,
321901,
278895,
354671,
287089,
199030,
315768,
139641,
291194,
223611,
248188,
291193,
313726,
211327,
291200,
240003,
158087,
227721,
242059,
311692,
285074,
227730,
240020,
315798,
190870,
190872,
291225,
317851,
285083,
293275,
227743,
242079,
283039,
285089,
289185,
305572,
293281,
156069,
289195,
311723,
377265,
299449,
319931,
311739,
293309,
278974,
311744,
317889,
291266,
278979,
278988,
289229,
281038,
326093,
281039,
283089,
278992,
283088,
279000,
242138,
176602,
285152,
291297,
279009,
188899,
195044,
242150,
279014,
319976,
279017,
311787,
281071,
319986,
279030,
311800,
279033,
317949,
279042,
233987,
287237,
322057,
309770,
342537,
279053,
182802,
283154,
303635,
279061,
279066,
188954,
322077,
291359,
227881,
293420,
289328,
283185,
279092,
23093,
234037,
244279,
244280,
338491,
301635,
309831,
322119,
55880,
377419,
303693,
281165,
301647,
326229,
309847,
189016,
115287,
111197,
295518,
287327,
242274,
244326,
279143,
279150,
281200,
287345,
313970,
301688,
189054,
287359,
297600,
291455,
311944,
334473,
279176,
311948,
316044,
184974,
311950,
316048,
311953,
316050,
287379,
295575,
227991,
289435,
303772,
205469,
221853,
314020,
279207,
295591,
295598,
279215,
318127,
285360,
293552,
342705,
287412,
166581,
285362,
154295,
287418,
303802,
314043,
66243,
291529,
287434,
225996,
363212,
287438,
242385,
303826,
279249,
279253,
158424,
230105,
299737,
322269,
342757,
295653,
289511,
230120,
330473,
234216,
285419,
289517,
279278,
312046,
170735,
215790,
199415,
234233,
279293,
322302,
289534,
291584,
299777,
205566,
285443,
228099,
291591,
295688,
322312,
285450,
264971,
312076,
322320,
285457,
295698,
166677,
291605,
283418,
285467,
221980,
281378,
234276,
318247,
262952,
262953,
279337,
318251,
289580,
262957,
293673,
283431,
301872,
242481,
303921,
234290,
164655,
285493,
230198,
285496,
301883,
201534,
281407,
295745,
222017,
293702,
318279,
281426,
279379,
295769,
201562,
281434,
234330,
322396,
230238,
301919,
275294,
293729,
279393,
349025,
281444,
303973,
279398,
177002,
308075,
242540,
242542,
310132,
295797,
228214,
295799,
177018,
269179,
279418,
308093,
314240,
291713,
158594,
240517,
287623,
228232,
416649,
320394,
316299,
299912,
234382,
189327,
308111,
308113,
293780,
310166,
289691,
209820,
277404,
240543,
283551,
310177,
189349,
289704,
279465,
293801,
177074,
304050,
289720,
289723,
189373,
213956,
281541,
19398,
345030,
279499,
56270,
191445,
304086,
183254,
183258,
234469,
314343,
304104,
324587,
183276,
234476,
203758,
320495,
289773,
320492,
277493,
320504,
312313,
312317,
354342,
234499,
293894,
320520,
230411,
320526,
234513,
238611,
140311,
293911,
316441,
197658,
132140,
189487,
281647,
322609,
312372,
203829,
238646,
300087,
238650,
320571,
21567,
308288,
160834,
336962,
314437,
349254,
238663,
300109,
207954,
234578,
296023,
205911,
314458,
277600,
281699,
230500,
285795,
322664,
228457,
318571,
279659,
234606,
300145,
238706,
312435,
187508,
230514,
279666,
302202,
285819,
314493,
285823,
279686,
222344,
285834,
318602,
228492,
337037,
177297,
162962,
187539,
308375,
324761,
285850,
296091,
119965,
302239,
300192,
234655,
339106,
306339,
234662,
300200,
3243,
238764,
322733,
279729,
294069,
300215,
294075,
64699,
228541,
283846,
312519,
279752,
283849,
148687,
290001,
189651,
316628,
279766,
189656,
279775,
304352,
298209,
304353,
279780,
228587,
279789,
290030,
302319,
234741,
283894,
316661,
208123,
292092,
279803,
228608,
320769,
234756,
322826,
242955,
177420,
312588,
318732,
126229,
318746,
320795,
320802,
304422,
130342,
130344,
292145,
298290,
312628,
300342,
222523,
286012,
181568,
279872,
294210,
216387,
286019,
279874,
300354,
300355,
193858,
304457,
230730,
372039,
294220,
296269,
234830,
224591,
238928,
296274,
318804,
314708,
283990,
314711,
357720,
300378,
300379,
294236,
316764,
314721,
292194,
230757,
281958,
314727,
134504,
306541,
314734,
327023,
234864,
296304,
312688,
316786,
230772,
314740,
284015,
314742,
314745,
290170,
310650,
224637,
306558,
290176,
243073,
179586,
306561,
314752,
294278,
314759,
296328,
298378,
296330,
318860,
314765,
304523,
292242,
314771,
306580,
224662,
234902,
282008,
314776,
318876,
290206,
148899,
314788,
298406,
282023,
314790,
241067,
279979,
314797,
279980,
286128,
173492,
286133,
284086,
279988,
284090,
302523,
310714,
228796,
302530,
280003,
228804,
310725,
306630,
292291,
300488,
306634,
280011,
302539,
300490,
234957,
310731,
310735,
312785,
222674,
280020,
280025,
310747,
239069,
144862,
286176,
187877,
310758,
320997,
280042,
280043,
191980,
300526,
337391,
282097,
296434,
308722,
40439,
191991,
286201,
300539,
288252,
312830,
286208,
290304,
228868,
292359,
323079,
218632,
230922,
302602,
323083,
294413,
304655,
323088,
282132,
230933,
282135,
316951,
374297,
313338,
282147,
222754,
306730,
312879,
230960,
288305,
239159,
290359,
323132,
157246,
288319,
288322,
280131,
349764,
310853,
124486,
194118,
288328,
286281,
292426,
282182,
224848,
224852,
290391,
128600,
306777,
235096,
239192,
212574,
99937,
204386,
345697,
300645,
282214,
312937,
243306,
224874,
312941,
310896,
294517,
314997,
288377,
290425,
325246,
333438,
235136,
280193,
282244,
239238,
286344,
323208,
282248,
286351,
188049,
239251,
280217,
323226,
229021,
302751,
282272,
198304,
282279,
298664,
298666,
317102,
286392,
302778,
306875,
280252,
296636,
323262,
282302,
286400,
323265,
321217,
280259,
321220,
280253,
282309,
239305,
296649,
280266,
212684,
241360,
282321,
313042,
286419,
241366,
282330,
294621,
280285,
282336,
321250,
294629,
153318,
12009,
282347,
288492,
282349,
34547,
67316,
323315,
286457,
284410,
200444,
282366,
286463,
319232,
278273,
280326,
282375,
323335,
284425,
300810,
282379,
116491,
216844,
284430,
161553,
124691,
278292,
118549,
116502,
282390,
284436,
278294,
325403,
321308,
321309,
282399,
241440,
282401,
315172,
186148,
186149,
241447,
333609,
286507,
284460,
294699,
280367,
300849,
282418,
280373,
282424,
280377,
319289,
321338,
282428,
280381,
345918,
241471,
413500,
280386,
280391,
153416,
315209,
159563,
280396,
307024,
317268,
237397,
307030,
241494,
188250,
284508,
300893,
307038,
237411,
276326,
282471,
296807,
292713,
282476,
292719,
296815,
313200,
313204,
317305,
124795,
317308,
339840,
315265,
280451,
327556,
188293,
282503,
305032,
315272,
325514,
315275,
67464,
243592,
184207,
124816,
311183,
282517,
294806,
214936,
294808,
124826,
239515,
214943,
298912,
319393,
294820,
333734,
219046,
284584,
313257,
298921,
292783,
200628,
300983,
343993,
288698,
98240,
214978,
280517,
280518,
214983,
282572,
282573,
153553,
24531,
231382,
323554,
292835,
190437,
292838,
294887,
317416,
313322,
298987,
278507,
311277,
296942,
124912,
327666,
278515,
325620,
239610
] |
55d4417ec2a21b322cfd2719098e6d8508a39494
|
d3db00ee7411d740ee1ec46d6a05f3695a411ff0
|
/CustomCVTransition/CustomCVTransition/DetailViewController.swift
|
4360b4355b9ee6cd5a7366cfb91a3ae438995635
|
[] |
no_license
|
kitanai-kitsune/ForTest
|
39cd205af6a7b31ff59f8fe668c8ab0cc012f751
|
1236d5334f1f1034a580dddf9edd862f85c35345
|
refs/heads/master
| 2022-12-07T07:08:48.569773 | 2020-09-03T11:53:14 | 2020-09-03T11:53:14 | 286,745,857 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,025 |
swift
|
//
// DetailViewController.swift
// CustomCVTransition
//
// Created by 金超 on 2020/9/2.
// Copyright © 2020 jinchao. All rights reserved.
//
import UIKit
class DetailViewController: UIViewController {
@IBOutlet weak var detailImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
detailImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap2(tap:))))
}
@objc func handleTap2(tap: UITapGestureRecognizer){
dismiss(animated: true, completion: nil)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
f62ae30a529f331d21492ef9e767b41194011939
|
8a9134fcb48cb3ef5fac34f5a458831915288af7
|
/JPWB/JPWB/Classes/Main(主要)/Visitor/JPVisitorView.swift
|
5f73f3e179278e14d91fd00d82e1d6f512237b5c
|
[] |
no_license
|
dudiaohanjiangxue/JPWB-Swift-3.0
|
511427b04b5ddabd306c7781a225338c23a805c8
|
c425ce3aee307cb5da0098204e3f870d98a02458
|
refs/heads/master
| 2020-04-06T06:28:09.577869 | 2016-10-31T09:20:33 | 2016-10-31T09:20:33 | 70,441,325 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,262 |
swift
|
//
// JPVisitorView.swift
// JPWB
//
// Created by KC on 16/10/11.
// Copyright © 2016年 KC. All rights reserved.
//
import UIKit
class JPVisitorView: UIView {
//MARK: - 懒加载
class func visitorView() -> JPVisitorView {
return Bundle.main.loadNibNamed("JPVisitorView", owner: nil, options: nil)!.first as! JPVisitorView
}
//MARK: - 属性
@IBOutlet weak var rotationView: UIImageView!
@IBOutlet weak var iconView: UIImageView!
@IBOutlet weak var tipLabel: UILabel!
@IBOutlet weak var registerBtn: UIButton!
@IBOutlet weak var loginBtn: UIButton!
//设置空间的内容
func setupVisitorViewInfo(iconName: String, tipString: String) {
iconView.image = UIImage(named: iconName)
tipLabel.text = tipString
rotationView.isHidden = true
}
///给转盘添加动画
func addRotationAnmation() {
let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
rotationAnim.repeatCount = MAXFLOAT
rotationAnim.duration = 10
rotationAnim.fromValue = 0
rotationAnim.toValue = M_PI * 2
rotationAnim.isRemovedOnCompletion = false
rotationView.layer.add(rotationAnim, forKey: nil)
}
}
|
[
-1
] |
377dfab29e78839c24f8223564c9fb9ee797443b
|
cb1750f195f8b44033154328d95df8fb3ecc9769
|
/SmartSuggestionsBox/SmartSuggestionsBox/CustomViewFlowLayout.swift
|
6963bd0bfcf49ff2aaa38adef52009abe5e8b569
|
[] |
no_license
|
raghav1786/SwiftApps
|
4a2ecb2f4910157da53a47a176663f9af4a38898
|
3bcb12b008a1e442190c1888d444db595876b194
|
refs/heads/master
| 2023-02-19T09:06:33.635408 | 2023-02-08T18:58:46 | 2023-02-08T18:58:46 | 229,374,864 | 1 | 1 | null | 2023-02-08T18:58:40 | 2019-12-21T04:15:19 |
Swift
|
UTF-8
|
Swift
| false | false | 1,281 |
swift
|
//
// CustomViewFlowLayout.swift
// SmartSuggestionsBox
//
// Created by RAGHAV SHARMA on 02/05/20.
// Copyright © 2020 RAGHAV SHARMA. All rights reserved.
//
import Foundation
import UIKit
class CustomViewFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributesForElementsInRect = super.layoutAttributesForElements(in: rect)
var newAttributesForElementsInRect = [UICollectionViewLayoutAttributes]()
var leftMargin: CGFloat = self.sectionInset.left
for attributes in attributesForElementsInRect! {
if (attributes.frame.origin.x == self.sectionInset.left) {
leftMargin = self.sectionInset.left
} else {
var newLeftAlignedFrame = attributes.frame
if leftMargin + attributes.frame.width < self.collectionViewContentSize.width {
newLeftAlignedFrame.origin.x = leftMargin
} else {
newLeftAlignedFrame.origin.x = self.sectionInset.left
}
attributes.frame = newLeftAlignedFrame
}
leftMargin += attributes.frame.size.width + 8
newAttributesForElementsInRect.append(attributes)
}
return newAttributesForElementsInRect
}
}
|
[
-1
] |
1307d5f1ec6de906615eede4bd48e1f55e71fff1
|
af84c606a06cac13ddb4a430075ed0e467de69cf
|
/Pokedox/PokeDetailViewModel.swift
|
77db6150e9fa3731b6d9a63718141ec77ec4dc90
|
[] |
no_license
|
nim23/pokedex-reactivex
|
3c528d46ae81fcc187c13a2dfbf07dee3c68b102
|
19ab06b7911de16afe60eca6d5496d4c1da575f5
|
refs/heads/master
| 2021-04-28T21:54:44.150737 | 2017-01-03T19:54:21 | 2017-01-03T19:54:21 | 77,732,549 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 4,159 |
swift
|
//
// ViewModel.swift
// Pokedox
//
// Created by Nimesh Gurung on 31/12/2016.
// Copyright © 2016 Nimesh Gurung. All rights reserved.
//
import Foundation
import RxSwift
import SwiftyJSON
class PokeDetailViewModel {
var pokedexId: Observable<Int>
var pokemonName: Observable<String>
var pokemonImage: Observable<UIImage?>
var attack: Observable<String>
var height: Observable<String>
var weight: Observable<String>
var defense: Observable<String>
var types: Observable<String>
var nextEvolutionName: Observable<String>
var nextEvolutionText: Observable<String>
var nextEvolutionId: Observable<String>
var nextEvolutionLevel: Observable<String>
var description: Observable<String>
init(pokemon: Pokemon, pokeApiService: PokeApiService) {
pokedexId = .just(pokemon.pokedexId)
pokemonName = .just(pokemon.name.capitalized)
pokemonImage = {
guard let image = UIImage(named: "\(pokemon.pokedexId)") else {
return .just(nil)
}
return .just(image)
}()
let pokemonDetails = pokeApiService.getPokemonDetails(pokemon.pokemonUrl)
.shareReplay(1)
//Map converts the Observable<JSON> to Observable<String>
attack = pokemonDetails
.map {
let attack = $0["attack"].int
return attack != nil ? "\(attack!)" : ""
}
height = pokemonDetails
.map { $0["height"].string ?? "" }
weight = pokemonDetails
.map { $0["weight"].string ?? "" }
defense = pokemonDetails
.map {
let defense = $0["defense"].int
return defense != nil ? "\(defense!)" : ""
}
let getTypes = { (json:JSON) -> String in
guard let types = json["types"].array,
types.count > 0 else { return "" }
return types.map {
$0["name"].string?.capitalized ?? ""
}.joined(separator: "/")
}
types = pokemonDetails
.map(getTypes)
let getEvolutions = {(json:JSON) -> [JSON]? in
guard let evolutions = json["evolutions"].array,
evolutions.count > 0,
evolutions[0]["to"].string?.range(of: "mega") == nil else { return nil }
return evolutions
}
nextEvolutionName = pokemonDetails
.map {
guard let evolutions = getEvolutions($0) else { return "" }
return evolutions[0]["to"].string ?? ""
}
nextEvolutionId = pokemonDetails
.map {
guard let evolutions = getEvolutions($0),
let uri = evolutions[0]["resource_uri"].string else { return "" }
let newStr = uri.replacingOccurrences(of: "/api/v1/pokemon", with: "")
let id = newStr.replacingOccurrences(of: "/", with: "")
return id
}
nextEvolutionLevel = pokemonDetails
.map {
guard let evolutions = getEvolutions($0),
let level = evolutions[0]["level"].int else { return "" }
return "\(level)"
}
nextEvolutionText = Observable.combineLatest(nextEvolutionId, nextEvolutionLevel, nextEvolutionName, resultSelector: { (id: String, level: String, name: String) -> String in
guard id != "" else { return "No Evolutions" }
let nextEvolutionLevelTxt = level != "" ? " - LVL \(level)" : ""
return "Next Evolution: \(name + nextEvolutionLevelTxt)"
})
description = pokemonDetails
.flatMapLatest {(json: JSON) -> Observable<String> in
guard let descriptionUrl = json["descriptions"].array?[0]["resource_uri"].string else { return .just("") }
return pokeApiService.getPokemonDescription(descriptionUrl)
}
}
}
|
[
-1
] |
39920bfd9583b7d4388c6c21b32649215ad637dd
|
fae7914e64b224a8ea1125edc2df9f87a11dc7cd
|
/AR Orbits/Tutorial/N0Tutorial.swift
|
ac6a3eefd248c0109c329c38d15926c66af90c00
|
[] |
no_license
|
turn3rt/BlastOff
|
0953b32ce715b05bb18a420a57b184d88218ff8a
|
adc10ff7a89d839fa3fe4660508ab6fd20dd3192
|
refs/heads/master
| 2022-09-10T10:19:29.749245 | 2019-07-26T17:16:52 | 2019-07-26T17:16:52 | 186,506,502 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 769 |
swift
|
//
// N0Tutorial.swift
// AR Orbits
//
// Created by Turner Thornberry on 7/6/19.
// Copyright © 2019 personal. All rights reserved.
//
import UIKit
class N0Tutorial: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = false
// configureAutoLayoutForDevice()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
ecfc9c393d7cf0d3f1980d355e45f2185dbc279f
|
69be9717926af3b6ddb84ea93daed2e664ed329b
|
/StudySpaces/AppDelegate.swift
|
3d7040ed7d41c6de2b1c8aa79f50b3ea50d01606
|
[] |
no_license
|
candace-chiang/StudySpaces_iOS
|
a91aca34211faa8c1a472572325fa5db5ae1a3b4
|
0a68dfffffd6634fea1cfe648c28723aed9e5060
|
refs/heads/master
| 2021-07-19T04:20:02.239123 | 2017-10-27T06:52:18 | 2017-10-27T06:52:18 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,643 |
swift
|
//
// AppDelegate.swift
// StudySpaces
//
// Created by Candace Chiang on 10/7/17.
// Copyright © 2017 Candace Chiang. All rights reserved.
//
import UIKit
import Google
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func applicationWillResignActive(application: UIApplication) {
}
func applicationDidEnterBackground(application: UIApplication) {
}
func applicationWillEnterForeground(application: UIApplication) {
}
func applicationDidBecomeActive(application: UIApplication) {
}
func applicationWillTerminate(application: UIApplication) {
}
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Initialize sign-in
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
GIDSignIn.sharedInstance().clientID = "1056789746338-8l22qnu855blbd0qc5ltv51okmv56t0e.apps.googleusercontent.com"
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(application: UIApplication, openURL url: NSURL, options: [String: AnyObject]) -> Bool {
return GIDSignIn.sharedInstance().handle(
url as URL!,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication.rawValue] as! String?,
annotation: options[UIApplicationOpenURLOptionsKey.annotation.rawValue])
}
func sign(_ _signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if (error == nil) {
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.idToken // Safe to send to the server
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
// ...
} else {
print("\(error.localizedDescription)")
}
}
func sign(_signIn: GIDSignIn!, didSignInFor user:GIDGoogleUser!,
withError error: Error!) {
// Perform any operations when the user disconnects from app here.
// ...
}
}
|
[
-1
] |
e274ee9e9e194297f22de6bdb7c211deb6141671
|
f633fe6581eebf2cc179b8704e064a01205dc696
|
/SwiftRecipeParser/Utility Classes/TextDoc.swift
|
9b543ae967f01c3f2039591d16ff38b3a621e516
|
[] |
no_license
|
bunkersmith/SwiftRecipeParser
|
ffcdf3c469641015443ecd593a4b0283036866f8
|
b324e4d0f9d206712065728a0ff8989e28814908
|
refs/heads/master
| 2023-05-25T09:11:37.062408 | 2023-05-12T21:10:50 | 2023-05-12T21:10:50 | 22,321,286 | 3 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,176 |
swift
|
//
// TextDoc.swift
// Swift 3 Music Player
//
// Created by CarlSmith on 12/31/16.
// Copyright © 2016 CarlSmith. All rights reserved.
//
import UIKit
class TextDoc: UIDocument {
var docText: String? = ""
// Called whenever the application reads data from the file system
override func load(fromContents contents: Any, ofType typeName: String?) throws {
if let content = contents as? Data {
Logger.logDetails(msg: "Length of contents = \(content.count)")
if content.count > 0 {
docText = String(data: content, encoding: .utf8)
}
}
}
override func contents(forType typeName: String) throws -> Any {
//Logger.logDetails(msg: "docText = \(docText)")
if let content = docText {
//Logger.logDetails(msg: "content = \(content)")
let length =
content.lengthOfBytes(using: String.Encoding.utf8)
Logger.logDetails(msg: "Length of docText = \(length)")
if length > 0 {
return content.data(using: .utf8) as Any
}
}
return Data()
}
}
|
[
-1
] |
f6bd18c171f61a7cb1ce0128635168378ee06764
|
6dc5f2e7a6955befa8444f0896e583acc9fc81a4
|
/Tests/MockedClientTestCase.swift
|
a3d8dcd3a74d28ae27d21fb51cc1cff842871ba7
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
boxcast/boxcast-sdk-apple
|
b1c291a0f0392a06e1f1a5671cec05afd252e78d
|
2c28ec4287a97f9dedfcdac679b82cb9d1257a6b
|
refs/heads/master
| 2023-07-05T12:34:27.426866 | 2022-10-12T13:12:38 | 2022-10-12T13:12:38 | 91,189,531 | 0 | 3 |
MIT
| 2023-07-03T17:23:34 | 2017-05-13T16:59:21 |
Swift
|
UTF-8
|
Swift
| false | false | 1,203 |
swift
|
//
// MockedClientTestCase.swift
// BoxCast
//
// Created by Camden Fullmer on 8/22/17.
// Copyright © 2017 BoxCast, Inc. All rights reserved.
//
import XCTest
@testable import BoxCast
class MockedClientTestCase: XCTestCase {
var client: BoxCastClient!
override func setUp() {
super.setUp()
// Set up mocking of the responses.
let configuration = URLSessionConfiguration.default
configuration.protocolClasses?.insert(MockedURLProtocol.self, at: 0)
client = BoxCastClient(scope: PublicScope(), configuration: configuration)
}
func fixtureData(for name: String) -> Data? {
let bundle = Bundle(for: MockedClientTestCase.self)
guard let resourceURL = bundle.resourceURL else {
return nil
}
let fileManager = FileManager.default
let fileURL = resourceURL.appendingPathComponent("\(name).json")
guard fileManager.fileExists(atPath: fileURL.path) else {
return nil
}
do {
let data = try Data(contentsOf: fileURL)
return data
} catch {
return nil
}
}
}
|
[
-1
] |
163a4ac0302a6e1b17dbb04343b19cbedb6a3001
|
ea5069c140a56a17340eb26a8497852258e5eb78
|
/Mac/AppDefaults.swift
|
66d952b7de20f3c34d54f281de5cfb93bb7238c3
|
[
"MIT"
] |
permissive
|
danielpunkass/NetNewsWire
|
b620a205417ff64755114031b3eb1750870ef637
|
72497c4c874813e21aba91d2e55899378ca357a5
|
refs/heads/main
| 2023-03-04T14:50:52.546504 | 2023-03-01T02:56:07 | 2023-03-01T02:56:07 | 92,971,135 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 12,631 |
swift
|
//
// AppDefaults.swift
// NetNewsWire
//
// Created by Brent Simmons on 9/22/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import AppKit
enum FontSize: Int {
case small = 0
case medium = 1
case large = 2
case veryLarge = 3
}
final class AppDefaults {
static let defaultThemeName = "Default"
static var shared = AppDefaults()
private init() {}
struct Key {
static let firstRunDate = "firstRunDate"
static let windowState = "windowState"
static let activeExtensionPointIDs = "activeExtensionPointIDs"
static let lastImageCacheFlushDate = "lastImageCacheFlushDate"
static let sidebarFontSize = "sidebarFontSize"
static let timelineFontSize = "timelineFontSize"
static let timelineSortDirection = "timelineSortDirection"
static let timelineGroupByFeed = "timelineGroupByFeed"
static let detailFontSize = "detailFontSize"
static let openInBrowserInBackground = "openInBrowserInBackground"
static let subscribeToFeedsInDefaultBrowser = "subscribeToFeedsInDefaultBrowser"
static let articleTextSize = "articleTextSize"
static let refreshInterval = "refreshInterval"
static let addWebFeedAccountID = "addWebFeedAccountID"
static let addWebFeedFolderName = "addWebFeedFolderName"
static let addFolderAccountID = "addFolderAccountID"
static let importOPMLAccountID = "importOPMLAccountID"
static let exportOPMLAccountID = "exportOPMLAccountID"
static let defaultBrowserID = "defaultBrowserID"
static let currentThemeName = "currentThemeName"
static let hasSeenNotAllArticlesHaveURLsAlert = "hasSeenNotAllArticlesHaveURLsAlert"
static let twitterDeprecationAlertShown = "twitterDeprecationAlertShown"
// Hidden prefs
static let showDebugMenu = "ShowDebugMenu"
static let timelineShowsSeparators = "CorreiaSeparators"
static let showTitleOnMainWindow = "KafasisTitleMode"
static let feedDoubleClickMarkAsRead = "GruberFeedDoubleClickMarkAsRead"
static let suppressSyncOnLaunch = "DevroeSuppressSyncOnLaunch"
#if !MAC_APP_STORE
static let webInspectorEnabled = "WebInspectorEnabled"
static let webInspectorStartsAttached = "__WebInspectorPageGroupLevel1__.WebKit2InspectorStartsAttached"
#endif
}
private static let smallestFontSizeRawValue = FontSize.small.rawValue
private static let largestFontSizeRawValue = FontSize.veryLarge.rawValue
let isDeveloperBuild: Bool = {
if let dev = Bundle.main.object(forInfoDictionaryKey: "DeveloperEntitlements") as? String, dev == "-dev" {
return true
}
return false
}()
var isFirstRun: Bool = {
if let _ = UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date {
return false
}
firstRunDate = Date()
return true
}()
var windowState: [AnyHashable : Any]? {
get {
return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any]
}
set {
UserDefaults.standard.set(newValue, forKey: Key.windowState)
}
}
var activeExtensionPointIDs: [[AnyHashable : AnyHashable]]? {
get {
return UserDefaults.standard.object(forKey: Key.activeExtensionPointIDs) as? [[AnyHashable : AnyHashable]]
}
set {
UserDefaults.standard.set(newValue, forKey: Key.activeExtensionPointIDs)
}
}
var lastImageCacheFlushDate: Date? {
get {
return AppDefaults.date(for: Key.lastImageCacheFlushDate)
}
set {
AppDefaults.setDate(for: Key.lastImageCacheFlushDate, newValue)
}
}
var openInBrowserInBackground: Bool {
get {
return AppDefaults.bool(for: Key.openInBrowserInBackground)
}
set {
AppDefaults.setBool(for: Key.openInBrowserInBackground, newValue)
}
}
// Special case for this default: store/retrieve it from the shared app group
// defaults, so that it can be resolved by the Safari App Extension.
var subscribeToFeedDefaults: UserDefaults {
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
return appGroupDefaults
}
else {
return UserDefaults.standard
}
}
var subscribeToFeedsInDefaultBrowser: Bool {
get {
return subscribeToFeedDefaults.bool(forKey: Key.subscribeToFeedsInDefaultBrowser)
}
set {
subscribeToFeedDefaults.set(newValue, forKey: Key.subscribeToFeedsInDefaultBrowser)
}
}
var sidebarFontSize: FontSize {
get {
return fontSize(for: Key.sidebarFontSize)
}
set {
AppDefaults.setFontSize(for: Key.sidebarFontSize, newValue)
}
}
var timelineFontSize: FontSize {
get {
return fontSize(for: Key.timelineFontSize)
}
set {
AppDefaults.setFontSize(for: Key.timelineFontSize, newValue)
}
}
var detailFontSize: FontSize {
get {
return fontSize(for: Key.detailFontSize)
}
set {
AppDefaults.setFontSize(for: Key.detailFontSize, newValue)
}
}
var addWebFeedAccountID: String? {
get {
return AppDefaults.string(for: Key.addWebFeedAccountID)
}
set {
AppDefaults.setString(for: Key.addWebFeedAccountID, newValue)
}
}
var addWebFeedFolderName: String? {
get {
return AppDefaults.string(for: Key.addWebFeedFolderName)
}
set {
AppDefaults.setString(for: Key.addWebFeedFolderName, newValue)
}
}
var addFolderAccountID: String? {
get {
return AppDefaults.string(for: Key.addFolderAccountID)
}
set {
AppDefaults.setString(for: Key.addFolderAccountID, newValue)
}
}
var importOPMLAccountID: String? {
get {
return AppDefaults.string(for: Key.importOPMLAccountID)
}
set {
AppDefaults.setString(for: Key.importOPMLAccountID, newValue)
}
}
var exportOPMLAccountID: String? {
get {
return AppDefaults.string(for: Key.exportOPMLAccountID)
}
set {
AppDefaults.setString(for: Key.exportOPMLAccountID, newValue)
}
}
var defaultBrowserID: String? {
get {
return AppDefaults.string(for: Key.defaultBrowserID)
}
set {
AppDefaults.setString(for: Key.defaultBrowserID, newValue)
}
}
var currentThemeName: String? {
get {
return AppDefaults.string(for: Key.currentThemeName)
}
set {
AppDefaults.setString(for: Key.currentThemeName, newValue)
}
}
var hasSeenNotAllArticlesHaveURLsAlert: Bool {
get {
return UserDefaults.standard.bool(forKey: Key.hasSeenNotAllArticlesHaveURLsAlert)
}
set {
UserDefaults.standard.set(newValue, forKey: Key.hasSeenNotAllArticlesHaveURLsAlert)
}
}
var showTitleOnMainWindow: Bool {
return AppDefaults.bool(for: Key.showTitleOnMainWindow)
}
var showDebugMenu: Bool {
return AppDefaults.bool(for: Key.showDebugMenu)
}
var feedDoubleClickMarkAsRead: Bool {
get {
return AppDefaults.bool(for: Key.feedDoubleClickMarkAsRead)
}
set {
AppDefaults.setBool(for: Key.feedDoubleClickMarkAsRead, newValue)
}
}
var suppressSyncOnLaunch: Bool {
get {
return AppDefaults.bool(for: Key.suppressSyncOnLaunch)
}
set {
AppDefaults.setBool(for: Key.suppressSyncOnLaunch, newValue)
}
}
#if !MAC_APP_STORE
var webInspectorEnabled: Bool {
get {
return AppDefaults.bool(for: Key.webInspectorEnabled)
}
set {
AppDefaults.setBool(for: Key.webInspectorEnabled, newValue)
}
}
var webInspectorStartsAttached: Bool {
get {
return AppDefaults.bool(for: Key.webInspectorStartsAttached)
}
set {
AppDefaults.setBool(for: Key.webInspectorStartsAttached, newValue)
}
}
#endif
var timelineSortDirection: ComparisonResult {
get {
return AppDefaults.sortDirection(for: Key.timelineSortDirection)
}
set {
AppDefaults.setSortDirection(for: Key.timelineSortDirection, newValue)
}
}
var timelineGroupByFeed: Bool {
get {
return AppDefaults.bool(for: Key.timelineGroupByFeed)
}
set {
AppDefaults.setBool(for: Key.timelineGroupByFeed, newValue)
}
}
var timelineShowsSeparators: Bool {
return AppDefaults.bool(for: Key.timelineShowsSeparators)
}
var articleTextSize: ArticleTextSize {
get {
let rawValue = UserDefaults.standard.integer(forKey: Key.articleTextSize)
return ArticleTextSize(rawValue: rawValue) ?? ArticleTextSize.large
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: Key.articleTextSize)
}
}
var refreshInterval: RefreshInterval {
get {
let rawValue = UserDefaults.standard.integer(forKey: Key.refreshInterval)
return RefreshInterval(rawValue: rawValue) ?? RefreshInterval.everyHour
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: Key.refreshInterval)
}
}
var twitterDeprecationAlertShown: Bool {
get {
return AppDefaults.bool(for: Key.twitterDeprecationAlertShown)
}
set {
AppDefaults.setBool(for: Key.twitterDeprecationAlertShown, newValue)
}
}
func registerDefaults() {
#if DEBUG
let showDebugMenu = true
#else
let showDebugMenu = false
#endif
let defaults: [String : Any] = [Key.sidebarFontSize: FontSize.medium.rawValue,
Key.timelineFontSize: FontSize.medium.rawValue,
Key.detailFontSize: FontSize.medium.rawValue,
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
Key.timelineGroupByFeed: false,
"NSScrollViewShouldScrollUnderTitlebar": false,
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
Key.showDebugMenu: showDebugMenu,
Key.currentThemeName: Self.defaultThemeName]
UserDefaults.standard.register(defaults: defaults)
// It seems that registering a default for NSQuitAlwaysKeepsWindows to true
// is not good enough to get the system to respect it, so we have to literally
// set it as the default to get it to take effect. This overrides a system-wide
// setting in the System Preferences, which is ostensibly meant to "close windows"
// in an app, but has the side-effect of also not preserving or restoring any state
// for the window. Since we've switched to using the standard state preservation and
// restoration mechanisms, and because it seems highly unlikely any user would object
// to NetNewsWire preserving this state, we'll force the preference on. If this becomes
// an issue, this could be changed to proactively look for whether the default has been
// set _by the user_ to false, and respect that default if it is so-set.
// UserDefaults.standard.set(true, forKey: "NSQuitAlwaysKeepsWindows")
// TODO: revisit the above when coming back to state restoration issues.
}
func actualFontSize(for fontSize: FontSize) -> CGFloat {
switch fontSize {
case .small:
return NSFont.systemFontSize
case .medium:
return actualFontSize(for: .small) + 1.0
case .large:
return actualFontSize(for: .medium) + 4.0
case .veryLarge:
return actualFontSize(for: .large) + 8.0
}
}
}
private extension AppDefaults {
static var firstRunDate: Date? {
get {
return AppDefaults.date(for: Key.firstRunDate)
}
set {
AppDefaults.setDate(for: Key.firstRunDate, newValue)
}
}
func fontSize(for key: String) -> FontSize {
// Punted till after 1.0.
return .medium
// var rawFontSize = int(for: key)
// if rawFontSize < smallestFontSizeRawValue {
// rawFontSize = smallestFontSizeRawValue
// }
// if rawFontSize > largestFontSizeRawValue {
// rawFontSize = largestFontSizeRawValue
// }
// return FontSize(rawValue: rawFontSize)!
}
static func setFontSize(for key: String, _ fontSize: FontSize) {
setInt(for: key, fontSize.rawValue)
}
static func string(for key: String) -> String? {
return UserDefaults.standard.string(forKey: key)
}
static func setString(for key: String, _ value: String?) {
UserDefaults.standard.set(value, forKey: key)
}
static func bool(for key: String) -> Bool {
return UserDefaults.standard.bool(forKey: key)
}
static func setBool(for key: String, _ flag: Bool) {
UserDefaults.standard.set(flag, forKey: key)
}
static func int(for key: String) -> Int {
return UserDefaults.standard.integer(forKey: key)
}
static func setInt(for key: String, _ x: Int) {
UserDefaults.standard.set(x, forKey: key)
}
static func date(for key: String) -> Date? {
return UserDefaults.standard.object(forKey: key) as? Date
}
static func setDate(for key: String, _ date: Date?) {
UserDefaults.standard.set(date, forKey: key)
}
static func sortDirection(for key:String) -> ComparisonResult {
let rawInt = int(for: key)
if rawInt == ComparisonResult.orderedAscending.rawValue {
return .orderedAscending
}
return .orderedDescending
}
static func setSortDirection(for key: String, _ value: ComparisonResult) {
if value == .orderedAscending {
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
}
else {
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
}
}
}
|
[
-1
] |
e43e6775640536698bd8c281450404372d669f46
|
0d6146aa71b969272964551223fa3e3445ae9958
|
/GYLJR-Swift/Model/UserModel/BorrowManagerModel.swift
|
692f583085321f51647cb17ea5608a567cab688f
|
[] |
no_license
|
sy19921103/GYLJR
|
e415cc6b6ba79d7f3bdb4b1a4d637af32972cc59
|
f86430f3a2f8c987e72ff8116469911fde2a937e
|
refs/heads/master
| 2021-05-03T05:11:10.802962 | 2018-03-14T10:01:03 | 2018-03-14T10:01:03 | 120,634,265 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 204 |
swift
|
//
// BorrowManagerModel.swift
// GYLJR-Swift
//
// Created by iOS on 2018/2/13.
// Copyright © 2018年 iOS. All rights reserved.
//
import UIKit
class BorrowManagerModel: BaseModel {
}
|
[
-1
] |
9a25a2a3b2e6962c63ee402a5b6ee9603e1071a0
|
db45c74ecf13f59e4c1065edde9d1dff9bf94d96
|
/Spine/Spine/Networking.swift
|
24129cdb57c4fd3ce8aef150158f9ef942f41bb2
|
[] |
no_license
|
mohshin-shah/swift-json-api
|
1320b8e38305fadab363f39601966abd1ac1cd65
|
472297cf5c106d5211ffffd345ef4b0119e7115c
|
refs/heads/master
| 2021-01-20T15:02:58.815367 | 2014-09-29T12:03:36 | 2014-09-29T12:03:36 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,365 |
swift
|
//
// Networking.swift
// Spine
//
// Created by Ward van Teijlingen on 05-09-14.
// Copyright (c) 2014 Ward van Teijlingen. All rights reserved.
//
import Foundation
import Alamofire
public protocol HTTPClientProtocol {
var traceEnabled: Bool { get set }
func get(URL: String, callback: (Int?, NSData?, NSError?) -> Void)
func post(URL: String, json: [String: AnyObject], callback: (Int?, NSData?, NSError?) -> Void)
func put(URL: String, json: [String: AnyObject], callback: (Int?, NSData?, NSError?) -> Void)
func delete(URL: String, callback: (Int?, NSData?, NSError?) -> Void)
}
class AlamofireClient: HTTPClientProtocol {
var traceEnabled = true
init() {
var additionalHeaders = Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders!
additionalHeaders.updateValue("application/vnd.api+json", forKey: "Content-Type")
}
func get(URL: String, callback: (Int?, NSData?, NSError?) -> Void) {
trace("GET: " + URL)
self.performRequest(Alamofire.request(Alamofire.Method.GET, URL), callback: callback)
}
func post(URL: String, json: [String: AnyObject], callback: (Int?, NSData?, NSError?) -> Void) {
trace("POST: " + URL)
self.performRequest(Alamofire.request(Alamofire.Method.POST, URL, parameters: json, encoding: Alamofire.ParameterEncoding.JSON), callback: callback)
}
func put(URL: String, json: [String: AnyObject], callback: (Int?, NSData?, NSError?) -> Void) {
trace("PUT: " + URL)
self.performRequest(Alamofire.request(Alamofire.Method.PUT, URL, parameters: json, encoding: Alamofire.ParameterEncoding.JSON), callback: callback)
}
func delete(URL: String, callback: (Int?, NSData?, NSError?) -> Void) {
trace("DELETE: " + URL)
self.performRequest(Alamofire.request(Alamofire.Method.DELETE, URL), callback: callback)
}
private func performRequest(request: Request, callback: (Int?, NSData?, NSError?) -> Void) {
request.response { request, response, data, error in
self.trace("RESPONSE: \(request.URL)")
if let error = error {
self.trace(" └─ Network error: \(error.localizedDescription)")
} else {
self.trace(" └─ HTTP status: \(response!.statusCode)")
}
callback(response?.statusCode, data as? NSData, error)
}
}
private func trace<T>(object: T) {
if self.traceEnabled {
println(object)
}
}
}
|
[
-1
] |
c144a4c0943a8fa4167a7dc15ace865db5942a3e
|
bc1d51ea2d6b3959b92fe9874c156f3895bb441c
|
/iOS/ePotato/ePotato/Source/ListPotatoBig.swift
|
633d27390c512c09b45257d2087e32a7a2c58b35
|
[
"Apache-2.0"
] |
permissive
|
onnoeberhard/epotato
|
3042adda6cf517b6ae86fa2b03131bb7c0dc873a
|
3405742fe7566baa6fd58d73cb5c2be3a0168331
|
refs/heads/master
| 2021-08-27T18:57:26.640569 | 2017-11-23T15:59:58 | 2017-11-23T15:59:58 | 109,120,125 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,474 |
swift
|
import UIKit
import SelectionDialog
class ListPotatoBig: ListPotato {
@IBOutlet weak var label: UILabel!
@IBOutlet weak var more: UIButton!
@IBOutlet weak var date: UILabel!
@IBOutlet weak var potato: PotatoView!
override func setup(_ p: [String: String?], _ type: Int, _ vc: HomeController) {
super.setup(p, type, vc)
label.text = name ?? ""
date.text = ((p[LocalDatabaseHandler.RECEIVED_POTATOES_TS]!! as NSString).boolValue ? "Total Strangers!\n" : "") + LocalDatabaseHandler.getNiceDate(p[LocalDatabaseHandler.DT]!!)
potato.setup(form: Int(p[LocalDatabaseHandler.POTATO_FORM]!!)!, text: p[LocalDatabaseHandler.POTATO_TEXT]!! as NSString)
}
override func action() {
reply()
}
@IBAction func doMore(_ sender: Any) {
let dlg = SelectionDialog(title: "Potato\(name != nil ? (type == 2 ? " for \(name!)" : " from \(name!)") : "")", closeButtonTitle: "Close")
let addToContacts = ldb.get(table: ldb.contacts, idKey: ldb.uid, idValue: uid!, column: ldb.id) == nil && name != nil
dlg.addItem(item: "Reply!") {
self.reply()
dlg.close();
}
if addToContacts {
dlg.addItem(item: "Add \(name!) to Contacts") {
self.addToContacts()
dlg.close();
}
}
dlg.addItem(item: "Delete") {
self.delete()
dlg.close();
}
dlg.show()
}
}
|
[
-1
] |
5bef618a4f1c59a70f682becc23c6e92e99f1b28
|
4943a747b1733d85a0fb95978eb012fd66c01d6c
|
/cs496/final/finalProject/ListWebModel.swift
|
b2b5f891185eb3196bf0321e01c18cd8c09d42c7
|
[
"MIT"
] |
permissive
|
andychase/classwork
|
83603ec6b026ece52f78314781805db9a1b6f010
|
8219dc8c353b5dfdf559b0f8e7870561c13b3633
|
refs/heads/master
| 2021-03-22T03:05:06.644641 | 2016-10-24T03:49:54 | 2016-10-24T03:49:54 | 39,471,418 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,056 |
swift
|
//
// ListWebModel.swift
// finalProject
//
// Created by Andy Chase on 12/6/15.
// Copyright © 2015 Andy Chase. All rights reserved.
//
import Alamofire
class ListWebModel: NSObject {
static func getListItems(userList:String, userId:String, callback: (list:[String]) -> Void) {
let parameters = ["get_user_list": userList, "user": userId]
Alamofire.request(.GET, "http://127.0.0.1:5000/get", parameters: parameters)
.responseJSON { response in
if let JSON = response.result.value {
if let list = JSON["list"] as? [String] {
callback(list: list)
}
}
}
}
static func setListItems(userList:String, userId:String, data:[String]) {
let parameters:[String:AnyObject] = ["get_user_list": userList, "user": userId, "data": data]
Alamofire.request(.POST, "http://127.0.0.1:5000/set", parameters: parameters, encoding: .JSON)
.responseJSON { response in
}
}
}
|
[
-1
] |
6fa823b117745a345ccacf749a34b86b47f420f3
|
8eb055449fdbb0c31bfc9ce1c2f8b374460726c0
|
/ExSwiftUI/AppDelegate.swift
|
f2639b62314857da2bff7be5dc42d9cc4ff0ab34
|
[] |
no_license
|
ogawa0147/ExSwiftUI
|
5734819eff912f0429dc526098dbab82b7cd17e7
|
1bfdab465595cacb10ab2845d1eba10e25c05b26
|
refs/heads/master
| 2020-12-30T01:16:31.374071 | 2020-02-07T00:02:11 | 2020-02-07T00:02:11 | 238,808,126 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,407 |
swift
|
//
// AppDelegate.swift
// ExSwiftUI
//
// Created by ogawa on 2020/02/07.
// Copyright © 2020 ogawa. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
|
[
393222,
393224,
393230,
393250,
344102,
393261,
393266,
213048,
385081,
376889,
393275,
376905,
327756,
254030,
286800,
368727,
180313,
368735,
180320,
376931,
286831,
368752,
286844,
417924,
262283,
286879,
286888,
377012,
327871,
180416,
377036,
180431,
377046,
377060,
327914,
205036,
393456,
393460,
418043,
336123,
336128,
385280,
262404,
180490,
368911,
262416,
262422,
377117,
262436,
336180,
262454,
393538,
262472,
344403,
213332,
65880,
262496,
418144,
262499,
213352,
246123,
262507,
262510,
213372,
385419,
393612,
262550,
262552,
385440,
385443,
385451,
262573,
393647,
385458,
262586,
344511,
262592,
360916,
369118,
328177,
328179,
328182,
328189,
328192,
164361,
410128,
393747,
254490,
188958,
385570,
33316,
197159,
377383,
352821,
188987,
418363,
369223,
385609,
385616,
352864,
369253,
262760,
352874,
352887,
254587,
377472,
336512,
148105,
377484,
352918,
98968,
344744,
361129,
336555,
434867,
164534,
336567,
164538,
328378,
328386,
352968,
344776,
418507,
352971,
352973,
385742,
385748,
361179,
189153,
369381,
361195,
418553,
344831,
336643,
344835,
344841,
361230,
336659,
418580,
418585,
434970,
369435,
418589,
262942,
418593,
336675,
328484,
418598,
418605,
336696,
361273,
328515,
336708,
328519,
336711,
328522,
336714,
426841,
254812,
361309,
197468,
361315,
361322,
328573,
369542,
336784,
222128,
345035,
345043,
386003,
386011,
386018,
386022,
435187,
328714,
361489,
386069,
336921,
386073,
336925,
345118,
377887,
345133,
345138,
386101,
361536,
197707,
189520,
345169,
156761,
361567,
148578,
345199,
386167,
361593,
410745,
361598,
214149,
345222,
386186,
337047,
345246,
214175,
337071,
337075,
345267,
386258,
328924,
66782,
222437,
386285,
328941,
386291,
345376,
353570,
345379,
410917,
345382,
337205,
345399,
378169,
369978,
337222,
337229,
337234,
263508,
402791,
345448,
271730,
378227,
271745,
181638,
353673,
181643,
181654,
230809,
181670,
181673,
181678,
181681,
337329,
181684,
181690,
361917,
181696,
337349,
181703,
337365,
271839,
329191,
361960,
329194,
116210,
337398,
337415,
329226,
419339,
419343,
419349,
345625,
419355,
370205,
419359,
394786,
419362,
370213,
419368,
419376,
206395,
214593,
419400,
419402,
353867,
419406,
419410,
345701,
394853,
222830,
370297,
353919,
403075,
345736,
198280,
403091,
345749,
345757,
345762,
419491,
345765,
419497,
419501,
370350,
419506,
419509,
419512,
337592,
337599,
419527,
419530,
419535,
272081,
419542,
394966,
419544,
181977,
345818,
419547,
419550,
419559,
337642,
419563,
337645,
370415,
337659,
141051,
337668,
362247,
395021,
362255,
116509,
345887,
378663,
345905,
354106,
354111,
247617,
354117,
370503,
329544,
370509,
354130,
247637,
337750,
370519,
313180,
354142,
345967,
345970,
345974,
403320,
354172,
247691,
337808,
247700,
329623,
436126,
436132,
337833,
362413,
337844,
346057,
247759,
346063,
329697,
354277,
190439,
247789,
354313,
346139,
436289,
378954,
395339,
338004,
100453,
329832,
329855,
329867,
329885,
411805,
346272,
362660,
100524,
387249,
379066,
387260,
256191,
395466,
346316,
411861,
411864,
411868,
411873,
379107,
411876,
387301,
346343,
338152,
387306,
387312,
346355,
436473,
321786,
379134,
411903,
411916,
379152,
395538,
387349,
338199,
387352,
182558,
338211,
395566,
248111,
362822,
436555,
190796,
379233,
354673,
248186,
420236,
379278,
272786,
354727,
338352,
330189,
338381,
338386,
256472,
338403,
338409,
248308,
199164,
330252,
199186,
330267,
354855,
10828,
199249,
346721,
174695,
248425,
191084,
338543,
191092,
346742,
330383,
354974,
150183,
174774,
248504,
174777,
223934,
355024,
273108,
355028,
264918,
183005,
256734,
338660,
338664,
264941,
207619,
264964,
338700,
256786,
199452,
363293,
396066,
346916,
396069,
215853,
355122,
355131,
355140,
355143,
338763,
355150,
330580,
355166,
265055,
265058,
355175,
387944,
355179,
330610,
330642,
355218,
412599,
207808,
379848,
396245,
330710,
248792,
248798,
347105,
257008,
183282,
265207,
330748,
330760,
330768,
248862,
396328,
158761,
199728,
396336,
330800,
396339,
339001,
388154,
388161,
347205,
248904,
330826,
248914,
183383,
339036,
412764,
257120,
265320,
248951,
420984,
330889,
347287,
339097,
248985,
44197,
380070,
339112,
249014,
126144,
330958,
330965,
265432,
265436,
388319,
388347,
175375,
159005,
175396,
208166,
273708,
372015,
347441,
372018,
199988,
44342,
175415,
396600,
437566,
175423,
437570,
437575,
437583,
331088,
437587,
331093,
396633,
175450,
437595,
175457,
208227,
175460,
175463,
265580,
437620,
175477,
249208,
175483,
175486,
249214,
175489,
249218,
249224,
249227,
249234,
175513,
175516,
396705,
175522,
355748,
380332,
396722,
208311,
372163,
216517,
380360,
216522,
339404,
372176,
208337,
339412,
413141,
339417,
249308,
339420,
339424,
249312,
339428,
339434,
249328,
69113,
372228,
339461,
208398,
380432,
175635,
339503,
265778,
265795,
396872,
265805,
224853,
224857,
257633,
224870,
372327,
257646,
372337,
224884,
224887,
224890,
224894,
224897,
372353,
216707,
126596,
421508,
224904,
224909,
11918,
159374,
224913,
126610,
339601,
224916,
224919,
126616,
224922,
208538,
224926,
224929,
224932,
224936,
257704,
224942,
257712,
224947,
257716,
257720,
224953,
257724,
224959,
257732,
224965,
224969,
339662,
224975,
257747,
224981,
224986,
257761,
224993,
257764,
224999,
339695,
225012,
257787,
225020,
339710,
257790,
225025,
257794,
339721,
257801,
257804,
225038,
257807,
225043,
372499,
167700,
225048,
257819,
225053,
184094,
225058,
257833,
225066,
257836,
413484,
225070,
225073,
372532,
257845,
225079,
397112,
225082,
397115,
225087,
225092,
225096,
323402,
257868,
225103,
257871,
397139,
225108,
225112,
257883,
257886,
225119,
257890,
339814,
225127,
257896,
274280,
257901,
225137,
339826,
257908,
225141,
257912,
257916,
225148,
257920,
225155,
339844,
225165,
397200,
225170,
380822,
225175,
225180,
118691,
184244,
372664,
372702,
372706,
356335,
380918,
405533,
430129,
266294,
266297,
421960,
356439,
421990,
266350,
356466,
266362,
381068,
225423,
250002,
250004,
225429,
356506,
225437,
135327,
225441,
438433,
225444,
438436,
225447,
438440,
225450,
258222,
225455,
430256,
225458,
225461,
225466,
389307,
225470,
381120,
372929,
430274,
225475,
389320,
225484,
225487,
225490,
266453,
225493,
225496,
225499,
225502,
225505,
356578,
225510,
217318,
225514,
225518,
372976,
381176,
397571,
389380,
61722,
356637,
356640,
356643,
356646,
266536,
356649,
356655,
332080,
340275,
356660,
397622,
332090,
225597,
332097,
201028,
348488,
332106,
332117,
250199,
250202,
332125,
250210,
348522,
348525,
348527,
332152,
389502,
250238,
332161,
356740,
332172,
373145,
340379,
389550,
324030,
266687,
340451,
160234,
127471,
340472,
324094,
266754,
324099,
324102,
324111,
340500,
324117,
324131,
332324,
381481,
324139,
356907,
324142,
356916,
324149,
324155,
348733,
324160,
324164,
356934,
348743,
381512,
324170,
324173,
324176,
389723,
332380,
373343,
381545,
340627,
373398,
184982,
258721,
332453,
332459,
389805,
332463,
381617,
332471,
332483,
332486,
373449,
332493,
357069,
357073,
332511,
332520,
340718,
332533,
348924,
389892,
373510,
389926,
152370,
348978,
340789,
348982,
398139,
127814,
357201,
357206,
389978,
430939,
357211,
357214,
201579,
201582,
349040,
340849,
201588,
430965,
324472,
398201,
119674,
340858,
324475,
430972,
340861,
324478,
324481,
373634,
398211,
324484,
324487,
381833,
324492,
324495,
324498,
430995,
324501,
324510,
422816,
324513,
398245,
201637,
324524,
340909,
324533,
324538,
324541,
398279,
340939,
340941,
209873,
340957,
431072,
398306,
340963,
201711,
349180,
439294,
209943,
209946,
250914,
357410,
185380,
357418,
209965,
209968,
209971,
209975,
209979,
209987,
209990,
341071,
349267,
250967,
210010,
341091,
210025,
210027,
210030,
210039,
341113,
349308,
210044,
349311,
160895,
152703,
210052,
349319,
210055,
210067,
210071,
210077,
210080,
251044,
210084,
185511,
210088,
210095,
210098,
210107,
210115,
332997,
210127,
333009,
210131,
333014,
210138,
210143,
218354,
218360,
251128,
275706,
275712,
275715,
275721,
349459,
333078,
251160,
349484,
349491,
251189,
415033,
251210,
357708,
210260,
259421,
365921,
333154,
251235,
374117,
333162,
234866,
390516,
333175,
357755,
251271,
136590,
112020,
349590,
357792,
259515,
415166,
415185,
366034,
366038,
415191,
415193,
415196,
415199,
423392,
333284,
415207,
366056,
415216,
210420,
415224,
423423,
415257,
415263,
366117,
415270,
144939,
415278,
415281,
415285,
210487,
415290,
415293,
349761,
415300,
333386,
333399,
366172,
333413,
423528,
423532,
210544,
415353,
333439,
415361,
267909,
153227,
333498,
210631,
333511,
259788,
358099,
333534,
366307,
366311,
431851,
366318,
210672,
366321,
366325,
210695,
268041,
210698,
366348,
210706,
399128,
333594,
210719,
358191,
366387,
210739,
399159,
358200,
325440,
366401,
341829,
325446,
46920,
341834,
341838,
341843,
415573,
358234,
341851,
350045,
399199,
259938,
399206,
268143,
358255,
399215,
358259,
333689,
243579,
325504,
333698,
333708,
333724,
382890,
350146,
333774,
358371,
350189,
350193,
350202,
333818,
350206,
350213,
268298,
350224,
350231,
333850,
350237,
350240,
350244,
350248,
178218,
350251,
350256,
350259,
350271,
243781,
350285,
374864,
342111,
342133,
374902,
432271,
333997,
334011,
260289,
260298,
350410,
350416,
350422,
350425,
334045,
350445,
375026,
358644,
350458,
350461,
350464,
325891,
350467,
350475,
268559,
350480,
432405,
350486,
325914,
350490,
325917,
350493,
350498,
350504,
358700,
350509,
391468,
358704,
358713,
358716,
383306,
334161,
383321,
383330,
383333,
391530,
383341,
334203,
268668,
194941,
391563,
366990,
416157,
342430,
268701,
375208,
326058,
375216,
334262,
334275,
326084,
358856,
334304,
334311,
375277,
334321,
350723,
186897,
342545,
334358,
342550,
342554,
334363,
358941,
350761,
252461,
334384,
383536,
358961,
334394,
252482,
219718,
334407,
334420,
350822,
375400,
334465,
334468,
162445,
326290,
342679,
342683,
260766,
342710,
244409,
260797,
260801,
350917,
154317,
391894,
154328,
416473,
64230,
113388,
342766,
375535,
203506,
342776,
391937,
391948,
375568,
326416,
375571,
375574,
162591,
326441,
326451,
326454,
326460,
244540,
375612,
260924,
326467,
244551,
326473,
326477,
326485,
416597,
326490,
342874,
326502,
375656,
326507,
326510,
211825,
211831,
351097,
392060,
359295,
351104,
342915,
400259,
236430,
342930,
252822,
392091,
400285,
252836,
359334,
211884,
400306,
351168,
359361,
326598,
359366,
359382,
359388,
383967,
343015,
359407,
261108,
244726,
261111,
383997,
261129,
359451,
261147,
211998,
261153,
261159,
359470,
359476,
343131,
384098,
384101,
384107,
367723,
187502,
384114,
343154,
212094,
351364,
384135,
384139,
384143,
351381,
384160,
384168,
367794,
384181,
384191,
351423,
384198,
326855,
244937,
253130,
343244,
146642,
359649,
343270,
351466,
351479,
384249,
343306,
261389,
359694,
253200,
261393,
384275,
245020,
245029,
171302,
351534,
376110,
245040,
384314,
425276,
384323,
212291,
343365,
212303,
343393,
343398,
425328,
343409,
253303,
154999,
343417,
327034,
245127,
384397,
245136,
245142,
245145,
343450,
245148,
245151,
245154,
245157,
245162,
327084,
359865,
384443,
146876,
327107,
384453,
327110,
327115,
327117,
359886,
359890,
343507,
368092,
343534,
343539,
368119,
343544,
368122,
409091,
359947,
359955,
359983,
343630,
327275,
245357,
138864,
155254,
155273,
368288,
245409,
425638,
425649,
155322,
425662,
155327,
155351,
155354,
212699,
155363,
245475,
245483,
155371,
409335,
155393,
155403,
245525,
155422,
360223,
155438,
155442,
155447,
155461,
360261,
376663,
155482,
261981,
425822,
155487,
376671,
155490,
155491,
327531,
261996,
376685,
261999,
262002,
327539,
262005,
147317,
425845,
262008,
262011,
155516,
155521,
155525,
360326,
155531,
262027,
262030,
262033,
262036,
262039,
262042,
155549,
262045,
262048,
262051,
327589,
155559,
155562,
155565,
393150,
393169,
384977,
155611,
155619,
253923,
155621,
253926,
327654,
204784,
393203,
360438,
253943,
393206,
393212,
155646
] |
7490b6ebe5493b70d2e2831df54c73ed10277793
|
5dc3647f14ecafdf19c0e600d1386c326b7d6811
|
/Sources/algorithms/binarySearchTrees.swift
|
4cac90b42ccb57a17de576fe34c63609293605bd
|
[] |
no_license
|
Secretum-MB/Algorithms
|
6e7b2a9ba76ab65ece55d1fb7bd89da5db28c85e
|
0895a1d322d72f580b3e1d62e36e84ec4d14b09a
|
refs/heads/master
| 2023-08-10T04:52:56.353288 | 2020-12-17T19:42:14 | 2020-12-17T19:42:14 | 322,396,599 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,843 |
swift
|
// supported operations:
// Search, Max, Min, Predecessor, Successor, Insert, Delete
// they can be used therefore also as:
// dictionaries (req: search, insert, delete), priority queue.
// performance depends on the height of the tree, which in turn
// depends on how well the tree is balanced.
//
// All the operations above run in O(tree height)
// (issue is, how well is the tree balanced)
//
// binary-search-tree property:
// if y is left child of x, y.key is <= x.key
// if y is right child of x, y.key is >= x.key
//
// A randomly built binary search tree has expected height of lg n
//
// no need to inherit here, but thought it was cool
public class NodeBT<Element>: Node<Element> {
var parent: NodeBT<Element>?
var left: NodeBT<Element>?
var right: NodeBT<Element>?
public init(_ value: Element) {
super.init(key: value)
}
}
public struct BinarySearchTree<Element: Comparable> {
public private(set) var root: NodeBT<Element>?
// certainly not the standard way
public var count: Int {
let counter = incrementer()
return size(from: self.root, counter)
}
public init() {}
public init(_ arr: [Element]) {
self.init()
arr.shuffled().forEach { each in self.insert(node: NodeBT(each)) }
}
public var is_empty: Bool {
return self.root == nil
}
private func incrementer() -> (Int) -> Int {
var total = 0
return { (by: Int) -> Int in total += by; return total }
}
public func size(from node: NodeBT<Element>?, _ counter: (Int) -> Int) -> Int {
if node != nil {
size(from: node?.left, counter)
counter(1)
size(from: node?.right, counter)
}
return counter(0)
}
public func min(from node: NodeBT<Element>?) -> NodeBT<Element>? {
var node = node
while node?.left != nil { node = node!.left }
return node
}
public func max(from node: NodeBT<Element>?) -> NodeBT<Element>? {
var node = node
while node?.right != nil { node = node!.right }
return node
}
public func traverseInOrder(from node: NodeBT<Element>?) {
if node != nil {
traverseInOrder(from: node?.left)
print(node!.key, terminator:", ")
traverseInOrder(from: node?.right)
}
}
// prints root first, then tree from top to bottom, left before right
public func traversePreOrder(from node: NodeBT<Element>?) {
if node != nil {
print(node!.key, terminator:", ")
traversePreOrder(from: node?.left)
traversePreOrder(from: node?.right)
}
}
// prints root last, prints tree from bottom up, left before right
public func traversePostOrder(from node: NodeBT<Element>?) {
if node != nil {
traversePostOrder(from: node?.left)
traversePostOrder(from: node?.right)
print(node!.key, terminator:", ")
}
}
public func depth(node: NodeBT<Element>?) -> Int? {
if node == nil {return nil}
var current = self.root
var level = 0
while current != nil {
if current === node {return level}
level += 1
if node!.key < current!.key {current = current?.left}
else {current = current?.right}
}
return nil
}
// returns the first node with given key
public func search(key: Element) -> NodeBT<Element>? {
var node = self.root
while node != nil && node!.key != key {
if key < node!.key {node = node?.left}
else {node = node?.right}
}
return node
}
public func successor(node: NodeBT<Element>) -> NodeBT<Element>? {
if node.right != nil { return self.min(from: node.right) }
var node: NodeBT<Element>? = node
var parent: NodeBT<Element>? = node?.parent
while parent != nil && node === parent?.right {
node = parent
parent = parent?.parent
}
return parent
}
public func predecessor(node: NodeBT<Element>) -> NodeBT<Element>? {
if node.left != nil { return self.max(from: node.left) }
var node: NodeBT<Element>? = node
var parent: NodeBT<Element>? = node?.parent
while parent != nil && node === parent?.left {
node = parent
parent = parent?.parent
}
return parent
}
// insertions are made to bottom of tree
public mutating func insert(node: NodeBT<Element>) {
var parent: NodeBT<Element>? = nil
var place = self.root
while place != nil {
parent = place
if node.key < place!.key {place = place!.left}
else {place = place!.right}
}
node.parent = parent
if parent == nil {self.root = node}
else if node.key < parent!.key {parent!.left = node}
else {parent!.right = node}
}
public mutating func delete(node: NodeBT<Element>) {
func transplant(replace: NodeBT<Element>, by: NodeBT<Element>?) {
if replace.parent == nil {
self.root = by
} else if replace.parent?.left === replace {
replace.parent!.left = by
} else {
replace.parent!.right = by
}
if by != nil {by!.parent = replace.parent}
}
if node.left == nil {
transplant(replace: node, by: node.right)
}
else if node.right == nil {
transplant(replace: node, by: node.left)
}
else {
let next = self.min(from: node.right)
if next !== node.right {
transplant(replace: next!, by: next!.right)
next?.right = node.right
next?.right!.parent = next
}
transplant(replace: node, by: next)
next!.left = node.left
next!.left!.parent = next
}
}
}
func example_tree() -> BinarySearchTree<Int> {
// builds the following tree:
//
// 8
// / \
// 3 14
// / \ / \
// 2 4 9 16
// / \ \
// 1 7 10
var a = BinarySearchTree<Int>()
let n1 = NodeBT(1)
let n2 = NodeBT(2)
let n3 = NodeBT(3)
let n4 = NodeBT(4)
let n5 = NodeBT(7)
let n6 = NodeBT(8)
let n7 = NodeBT(9)
let n8 = NodeBT(10)
let n9 = NodeBT(14)
let n10 = NodeBT(16)
a.insert(node: n6)
a.insert(node: n3)
a.insert(node: n4)
a.insert(node: n5)
a.insert(node: n2)
a.insert(node: n1)
a.insert(node: n9)
a.insert(node: n7)
a.insert(node: n8)
a.insert(node: n10)
return a
}
|
[
-1
] |
f4740b65819224bcc9ef2badc47549ef67649417
|
277793cdeee0e3de42ecff1f735f3b393125c28b
|
/SoundCloudViper/Module/Home/Presenter/HomePresenter.swift
|
098911debababfe7790a725b788723d7e93ce8c2
|
[] |
no_license
|
Asmins/SoundCloudViper
|
919e35c76be673718e204cadf7f88286b0a18c4e
|
958694f1c6a21f649b7c5275401b0b874471929c
|
refs/heads/master
| 2021-01-17T17:47:16.902271 | 2016-10-21T08:16:58 | 2016-10-21T08:16:58 | 70,599,367 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,002 |
swift
|
//
// HomePresenter.swift
// SoundCloudViper
//
// Created by admin on 19.10.16.
// Copyright © 2016 Mozi. All rights reserved.
//
import UIKit
class HomePresenter {
var arrayActivity:[Activity]?
var interactor:HomeInteractor?
}
extension HomePresenter: HomePresenterProtocol {
func setupHeader(header: HeaderTableViewCell) {
self.interactor?.setupHeader(header: header)
}
func numberOfRows() -> Int {
arrayActivity = self.interactor?.service.arrayActivity
return (self.arrayActivity?.count)!
}
func configurationCell(cell: ActivityTableViewCell, indexPath: NSIndexPath) {
self.interactor?.setupCell(cell: cell, indexPath: indexPath)
}
func getData(tableView: UITableView, activityIndicator: UIActivityIndicatorView) {
self.interactor?.service.requestMe(tableView: tableView)
self.interactor?.service.getDataAboutActivity(tableView: tableView, activityIndicator: activityIndicator)
}
}
|
[
-1
] |
1c0c2af02953b5d5ea95c89ae02f434d089f6831
|
57610456b5317e7279da03b0de0f27250a8b42f0
|
/iModel/DataModel/UserBasic.swift
|
f36bda090e2fc056c47eb6c379bef16d29019444
|
[] |
no_license
|
marcapecoraro/iModel
|
bbd01087413ab757ee4b6c4668cc77f9f7b980af
|
cf44f662e2d781ab6b7097fb85e349b17efcb9b4
|
refs/heads/master
| 2020-04-06T19:09:15.618601 | 2018-11-27T15:59:40 | 2018-11-27T15:59:40 | 157,727,643 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 730 |
swift
|
import Foundation
struct UserBasic {
let id: Int
let email: String
let firstname: String
let lastname: String
let telephone: String
let location: String
init(id: Int, email: String, firstname: String, lastname: String, telephone: String, location: String) {
self.id = id
self.email = email
self.firstname = firstname
self.lastname = lastname
self.telephone = telephone
self.location = location
}
func getAllProperties() -> [[String: Any]] {
var result: [[String: Any]] = []
let mirror = Mirror(reflecting: self)
for (property, value) in mirror.children where value is String {
guard let property = property else {
continue
}
result.append([property : value])
}
return result
}
}
|
[
-1
] |
4e81fbf602466eb0c836361be76b530e4c19e5c7
|
a87ec5a52c682ebc5edea1d594a1f3eb8ab5de82
|
/On the Map/GCDBlackBox.swift
|
afa61057c22e8da0a9d3353be22071cb34d164ce
|
[] |
no_license
|
Nikunj-Jain/ios-on-the-map
|
e55ef7a41ce192cb6831f091489155558b12f027
|
514a50c1966939c5ed3a88ae0e5c0efd8440c588
|
refs/heads/master
| 2021-01-01T04:11:50.114987 | 2016-04-17T07:00:39 | 2016-04-17T07:00:39 | 56,423,279 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 286 |
swift
|
//
// GCDBlackBox.swift
// On the Map
//
// Created by Nikunj Jain on 17/03/16.
// Copyright © 2016 Nikunj Jain. All rights reserved.
//
import Foundation
func performUIUpdatesOnMain(updates: () -> Void) {
dispatch_async(dispatch_get_main_queue()) {
updates()
}
}
|
[
-1
] |
c61db1a0d3d18da7a9bf0002fc988d8e17042388
|
52f1bd12537d787d9417dcfd204e068b6beedffe
|
/MadLibs2UITests/MadLibs2UITests.swift
|
485ef13935261f89f0b5e5aacdfad707e921174b
|
[] |
no_license
|
kkudumu/Mad_Libs_iOS
|
2b6613146d893acd70e4d792ae5af29c9fe63803
|
1057f3ca8e89685fea83ff0b9ec2cf80b93ace8f
|
refs/heads/master
| 2021-07-25T11:06:42.913445 | 2017-11-08T03:02:46 | 2017-11-08T03:02:46 | 109,920,735 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,249 |
swift
|
//
// MadLibs2UITests.swift
// MadLibs2UITests
//
// Created by Kioja Kudumu on 11/7/17.
// Copyright © 2017 Kioja Kudumu. All rights reserved.
//
import XCTest
class MadLibs2UITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
155665,
237599,
229414,
278571,
229425,
180279,
229431,
319543,
213051,
286787,
237638,
311373,
196687,
278607,
311377,
368732,
180317,
278637,
319599,
278642,
131190,
131199,
278676,
311447,
327834,
278684,
278690,
311459,
278698,
278703,
278707,
180409,
278713,
295099,
139459,
131270,
229591,
147679,
311520,
147680,
295147,
286957,
319764,
278805,
311582,
278817,
311596,
336177,
98611,
278843,
287040,
319812,
311622,
229716,
278895,
287089,
139641,
311679,
311692,
106893,
156069,
311723,
377265,
311739,
319931,
278974,
336319,
311744,
278979,
336323,
278988,
278992,
279000,
369121,
279009,
279014,
319976,
279017,
311787,
319986,
279030,
311800,
279033,
279042,
287237,
377352,
279053,
303634,
303635,
279060,
279061,
188954,
279066,
279092,
377419,
303693,
115287,
189016,
287319,
295518,
287327,
279143,
279150,
287345,
287348,
189054,
287359,
303743,
164487,
279176,
311944,
344714,
311948,
311950,
311953,
336531,
287379,
295575,
303772,
221853,
205469,
279207,
295591,
295598,
279215,
279218,
287412,
164532,
287418,
303802,
66243,
287434,
287438,
164561,
303826,
279249,
279253,
369365,
369366,
230105,
295653,
230120,
312046,
279278,
230133,
279293,
205566,
295688,
312076,
295698,
221980,
336678,
262952,
262953,
279337,
262957,
164655,
328495,
303921,
230198,
222017,
295745,
279379,
295769,
230238,
230239,
279393,
303973,
279398,
295797,
295799,
279418,
336765,
287623,
279434,
320394,
189327,
189349,
279465,
304050,
189373,
213956,
345030,
213961,
279499,
304086,
304104,
123880,
320492,
320495,
287730,
312313,
214009,
312315,
312317,
328701,
328705,
418819,
320520,
230411,
320526,
238611,
140311,
238617,
197658,
336930,
189487,
312372,
238646,
238650,
320571,
336962,
238663,
205911,
296023,
156763,
230500,
214116,
279659,
238706,
279666,
312435,
230514,
279686,
222344,
337037,
296091,
238764,
148674,
312519,
279752,
148687,
189651,
279766,
189656,
279775,
304352,
304353,
279780,
279789,
279803,
320769,
312588,
320795,
320802,
304422,
312628,
345398,
222523,
181568,
279872,
279874,
304457,
345418,
230730,
337228,
296269,
222542,
238928,
296274,
230757,
296304,
312688,
230772,
337280,
296328,
296330,
304523,
9618,
279955,
148899,
279979,
279980,
173492,
279988,
280003,
370122,
280011,
337359,
329168,
312785,
222674,
329170,
280020,
280025,
239069,
320997,
280042,
280043,
329198,
337391,
296434,
288248,
288252,
312830,
230922,
329231,
304655,
230933,
222754,
312879,
230960,
288305,
239159,
157246,
288319,
288322,
280131,
124486,
288328,
230999,
239192,
99937,
345697,
312937,
312941,
206447,
288377,
337533,
280193,
239238,
288391,
239251,
280217,
198304,
337590,
280252,
296636,
280253,
321217,
280259,
321220,
296649,
239305,
280266,
9935,
313042,
280279,
18139,
280285,
321250,
337638,
181992,
288492,
34547,
67316,
313082,
288508,
288515,
280326,
116491,
280333,
124691,
116502,
321308,
321309,
280367,
280373,
280377,
321338,
280381,
345918,
280386,
280391,
280396,
337746,
18263,
370526,
296807,
296815,
313200,
313204,
124795,
182145,
280451,
67464,
305032,
124816,
214936,
337816,
124826,
329627,
239515,
214943,
313257,
288698,
214978,
280517,
280518,
214983,
231382,
329696,
190437,
313322,
329707,
174058,
296942,
124912,
313338,
239610,
182277,
313356,
305173,
223269,
354342,
354346,
313388,
124974,
321589,
215095,
288829,
288835,
313415,
239689,
354386,
280660,
223317,
329812,
280674,
280676,
313446,
215144,
288878,
288890,
215165,
280708,
329884,
215204,
125108,
280761,
223418,
280767,
338118,
280779,
321744,
280792,
280803,
182503,
338151,
125166,
125170,
395511,
313595,
125180,
125184,
125192,
125200,
125204,
338196,
125215,
125225,
338217,
321839,
125236,
280903,
289109,
379224,
239973,
280938,
321901,
354671,
354672,
199030,
223611,
248188,
313726,
240003,
158087,
313736,
240020,
190870,
190872,
289185,
305572,
289195,
338359,
289229,
281038,
281039,
281071,
322057,
322077,
289328,
338491,
322119,
281165,
281170,
281200,
297600,
289435,
314020,
248494,
166581,
314043,
363212,
158424,
322269,
338658,
289511,
330473,
330476,
289517,
215790,
125683,
199415,
289534,
322302,
35584,
322312,
346889,
264971,
322320,
166677,
207639,
281378,
289580,
281407,
289599,
281426,
281434,
322396,
281444,
207735,
314240,
158594,
330627,
240517,
289691,
240543,
289699,
289704,
289720,
289723,
281541,
19398,
191445,
183254,
207839,
142309,
314343,
183276,
289773,
248815,
240631,
330759,
330766,
330789,
248871,
281647,
322609,
314437,
207954,
339031,
314458,
281698,
281699,
322664,
314493,
150656,
347286,
330912,
339106,
306339,
249003,
208044,
322733,
3243,
339131,
290001,
339167,
298209,
290030,
208123,
322826,
126229,
298290,
208179,
159033,
216387,
372039,
224591,
331091,
314708,
150868,
314711,
314721,
281958,
314727,
134504,
306541,
314734,
314740,
314742,
314745,
290170,
224637,
306558,
290176,
314759,
298378,
314765,
314771,
306580,
224662,
282008,
314776,
282013,
290206,
314788,
314790,
282023,
298406,
241067,
314797,
306630,
306634,
339403,
191980,
282097,
306678,
191991,
290304,
323083,
323088,
282132,
282135,
175640,
306730,
290359,
323132,
282182,
224848,
224852,
290391,
306777,
323171,
282214,
224874,
314997,
290425,
339579,
282244,
323208,
282248,
323226,
282272,
282279,
298664,
298666,
306875,
282302,
323262,
323265,
282309,
306891,
241360,
282321,
241366,
282330,
282336,
12009,
282347,
282349,
323315,
200444,
282366,
249606,
282375,
323335,
282379,
216844,
118549,
282390,
282399,
282401,
339746,
315172,
216868,
241447,
282418,
282424,
282428,
413500,
241471,
315209,
159563,
307024,
307030,
241494,
307038,
282471,
339840,
315265,
282503,
315272,
315275,
184207,
282517,
298912,
118693,
298921,
126896,
200628,
282572,
282573,
323554,
298987,
282634,
241695,
315431,
102441,
315433,
102446,
282671,
241717,
307269,
233548,
315468,
315477,
200795,
323678,
315488,
315489,
45154,
217194,
233578,
307306,
249976,
241809,
323730,
299166,
233635,
299176,
184489,
323761,
184498,
258233,
299197,
299202,
176325,
299208,
233678,
282832,
356575,
307431,
184574,
217352,
315674,
282908,
299294,
282912,
233761,
282920,
315698,
332084,
307514,
282938,
127292,
168251,
323914,
201037,
282959,
250196,
168280,
323934,
381286,
242027,
242028,
250227,
315768,
315769,
291194,
291193,
291200,
242059,
315798,
291225,
242079,
283039,
299449,
291266,
373196,
283088,
283089,
242138,
176602,
160224,
291297,
242150,
283138,
233987,
324098,
340489,
283154,
291359,
283185,
234037,
340539,
234044,
332379,
111197,
242274,
291455,
316044,
184974,
316048,
316050,
340645,
176810,
299698,
291529,
225996,
135888,
242385,
299737,
234216,
234233,
242428,
291584,
299777,
291591,
291605,
283418,
234276,
283431,
242481,
234290,
201534,
283466,
201562,
234330,
275294,
349025,
357219,
177002,
308075,
242540,
242542,
201590,
177018,
308093,
291713,
340865,
299912,
316299,
234382,
308111,
308113,
209820,
283551,
177074,
127945,
340960,
234469,
340967,
324587,
234476,
201721,
234499,
234513,
316441,
300087,
21567,
308288,
160834,
349254,
300109,
234578,
250965,
234588,
250982,
234606,
300145,
300147,
234626,
234635,
177297,
308375,
324761,
119965,
234655,
300192,
234662,
300200,
324790,
300215,
283841,
283846,
283849,
316628,
251124,
234741,
316661,
283894,
292092,
234756,
242955,
177420,
292145,
300342,
333114,
333115,
193858,
300355,
300354,
234830,
283990,
357720,
300378,
300379,
316764,
292194,
284015,
234864,
316786,
243073,
112019,
234902,
333224,
284086,
259513,
284090,
54719,
415170,
292291,
300488,
300490,
234957,
144862,
300526,
308722,
300539,
210429,
292359,
218632,
316951,
374297,
235069,
349764,
194118,
292424,
292426,
333389,
349780,
128600,
235096,
300643,
300645,
243306,
325246,
235136,
317102,
300725,
300729,
333508,
333522,
325345,
153318,
333543,
284410,
284425,
300810,
300812,
284430,
161553,
284436,
325403,
341791,
325411,
186148,
186149,
333609,
284460,
300849,
325444,
153416,
325449,
317268,
325460,
341846,
284508,
300893,
284515,
276326,
292713,
292719,
325491,
333687,
317305,
317308,
325508,
333700,
243590,
243592,
325514,
350091,
350092,
350102,
333727,
219046,
333734,
284584,
292783,
300983,
153553,
292835,
6116,
292838,
317416,
325620,
333827,
243720,
292901,
325675,
243763,
325695,
333902,
227432,
194667,
284789,
284790,
292987,
227459,
194692,
235661,
333968,
153752,
284827,
333990,
284840,
284843,
227517,
309443,
227525,
301255,
227536,
301270,
301271,
325857,
334049,
317676,
309504,
194832,
227601,
325904,
334104,
211239,
334121,
317738,
325930,
227655,
383309,
391521,
285031,
416103,
227702,
211327,
227721,
285074,
227730,
285083,
293275,
317851,
227743,
285089,
293281,
301482,
375211,
334259,
293309,
317889,
326083,
129484,
326093,
285152,
195044,
334315,
236020,
293368,
317949,
342537,
309770,
334345,
342560,
227881,
293420,
236080,
23093,
244279,
244280,
301635,
309831,
55880,
301647,
309847,
244311,
244326,
277095,
301688,
244345,
301702,
334473,
326288,
227991,
285348,
318127,
293552,
285360,
285362,
342705,
154295,
342757,
285419,
170735,
342775,
375552,
228099,
285443,
285450,
326413,
285457,
285467,
326428,
318247,
293673,
318251,
301872,
285493,
285496,
301883,
342846,
293702,
244569,
301919,
293729,
351078,
310132,
228214,
269179,
228232,
416649,
236427,
252812,
293780,
310166,
310177,
293801,
326571,
326580,
326586,
359365,
211913,
326602,
56270,
203758,
293894,
293911,
326684,
113710,
318515,
203829,
285795,
228457,
318571,
187508,
302202,
285819,
285823,
285833,
318602,
285834,
228492,
162962,
187539,
326803,
285850,
302239,
302251,
294069,
294075,
64699,
228541,
343230,
310496,
228587,
302319,
228608,
318732,
245018,
318746,
130342,
130344,
130347,
286012,
294210,
318804,
294236,
327023,
327030,
310650,
179586,
294278,
368012,
318860,
318876,
343457,
245160,
286128,
286133,
310714,
302523,
228796,
302530,
228804,
310725,
302539,
310731,
310735,
327122,
310747,
286176,
187877,
310758,
40439,
286201,
359931,
245249,
228868,
302602,
294413,
359949,
302613,
302620,
245291,
130622,
310853,
286281,
196184,
212574,
204386,
204394,
138862,
310896,
294517,
286344,
179853,
286351,
188049,
229011,
179868,
229021,
302751,
245413,
212649,
286387,
286392,
302778,
286400,
212684,
302798,
286419,
278232,
294621,
278237,
278241,
294629,
286457,
286463,
319232,
278292,
278294,
294699,
286507,
319289,
237397,
188250,
237411,
327556,
188293,
311183,
294806,
294808,
319393,
294820,
294824,
343993,
98240,
294849,
24531,
294887,
278507,
311277,
327666,
278515
] |
a25571305372c651d49eee838274bda7ed8e9dba
|
156c48d76c0890606cde6bc266be2b6e9d378a8d
|
/Cheatsheet/ControlFlowLoops.swift
|
023fd900a5ec3c906509c07b3ce3c03bd91f358b
|
[] |
no_license
|
ram4ik/Cheatsheet
|
3608335232a93a4b54659a61260fb0123bfa7cd5
|
68052649f0347002a707f87d0d09bb67977efa66
|
refs/heads/master
| 2020-11-30T05:31:45.808317 | 2019-12-26T19:32:30 | 2019-12-26T19:32:30 | 230,317,725 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 702 |
swift
|
//
// ControlFlowLoops.swift
// Cheatsheet
//
// Created by Ramill Ibragimov on 26.12.2019.
// Copyright © 2019 Ramill Ibragimov. All rights reserved.
//
import Foundation
// ## Control Flow: Loops
// Iterate over list or set
//for item in listOrSet {
// print(item)
//}
// Iterate over dictionary
//for (key, value) in dictionary {
// print("\(key) = \(value)")
//}
// Iterate over ranges
// Closed range operator (...)
//for i in 0...10 {
// print(i) // 0 to 10
//}
// Half-open range operator (..<)
//for i in 0..<10 {
// print(i) // 0 to 9
//}
// while
var x = 0
//while x < 10 {
// x += 1
// print(x)
//}
// repeat-while
//repeat {
// x -= 1
// print(x)
//} while(x > 0)
|
[
-1
] |
13f1f5776fbfcc23cab422667344da3756dda038
|
36d7b77c85925671ae8ece8e17a2de69f5c7c24a
|
/RoadTrip/UpdateUIViewFrameByPixel.swift
|
8cb6e221e6158f453ea1f39cecefa9832798684d
|
[] |
no_license
|
yiqin/RoadTrip
|
aaaa79d9a40bb6e323faa9e24250fa04b793bb80
|
94197611635844ad54423dfb7b8675bb9db2f824
|
refs/heads/master
| 2021-01-10T01:06:32.462001 | 2015-10-04T00:53:45 | 2015-10-04T00:53:45 | 36,323,597 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 538 |
swift
|
//
// UpdateUIViewByPixel.swift
// RoadTrip
//
// Created by Yi Qin on 4/26/15.
// Copyright (c) 2015 Yi Qin. All rights reserved.
//
import UIKit
import Foundation
extension UIView {
func moveY(yOffset:CGFloat) {
frame = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame)+yOffset, CGRectGetWidth(frame), CGRectGetHeight(frame))
}
func moveX(xOffset:CGFloat) {
frame = CGRectMake(CGRectGetMinX(frame)+xOffset, CGRectGetMinY(frame), CGRectGetWidth(frame), CGRectGetHeight(frame))
}
}
|
[
-1
] |
9b8e6086ae6b52a4a24a9c785f0274162534f504
|
f769581faea08925d1d3560967ead0726d904ac2
|
/CleanArchitectureRxSwiftTests/Scenes/AllPosts/PostsUseCaseMock.swift
|
4c9ebcc04eda9ab5e87871e0fbf043827f992d0e
|
[
"MIT"
] |
permissive
|
sakwangjin/CleanArchitectureRxSwift
|
593264f3288df2b148162a5f2ea1ecb83290f058
|
7eaf2a9f89fb92c197933beb04c87daf19382750
|
refs/heads/master
| 2022-10-20T14:48:53.607217 | 2020-07-23T09:57:16 | 2020-07-23T09:57:16 | 281,850,382 | 1 | 0 |
MIT
| 2020-07-23T04:29:09 | 2020-07-23T04:29:08 | null |
UTF-8
|
Swift
| false | false | 702 |
swift
|
@testable import CleanArchitectureRxSwift
import RxSwift
import Domain
class PostsUseCaseMock: Domain.PostsUseCase {
var posts_ReturnValue: Observable<[Post]> = Observable.just([])
var posts_Called = false
var save_ReturnValue: Observable<Void> = Observable.just(())
var save_Called = false
var delete_ReturnValue: Observable<Void> = Observable.just(())
var delete_Called = false
func posts() -> Observable<[Post]> {
posts_Called = true
return posts_ReturnValue
}
func save(post: Post) -> Observable<Void> {
save_Called = true
return save_ReturnValue
}
func delete(post: Post) -> Observable<Void> {
delete_Called = true
return delete_ReturnValue
}
}
|
[
-1
] |
c9a06ce76dbbf82e07f0eaca53af14b76de30dde
|
098812b3ea5095f5aabe29de85811463d31d82d8
|
/Realm/classWork/RealmCell.swift
|
66e4d7a03219323e3fe3fa617109c91edecbcf9b
|
[] |
no_license
|
Anatolii29/json_test
|
7d1ecd03a23c51443b98d9da8b3782aceb08b713
|
f75bedb01a0693eb41b8430b1643154b8dc5e869
|
refs/heads/master
| 2020-07-03T16:33:53.028810 | 2019-08-12T16:44:26 | 2019-08-12T16:44:26 | 201,968,565 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 500 |
swift
|
//
// RealmCell.swift
// json_test
//
// Created by Anatolii on 7/15/19.
// Copyright © 2019 Anatolii. All rights reserved.
//
import Foundation
import UIKit
class RealmCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var contentLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
func update(model: RealmModel?) {
titleLabel.text = model?.name
contentLabel.text = model?.title
}
}
|
[
-1
] |
64ef27892f2dd0d86c897fadbdf5eefa96be9d41
|
ccb04ff4adc37abbdf4342d829c48dff20c30d89
|
/SwiftTraceApp/AppDelegate.swift
|
f6906100f37c40970bf46c2f8533db8b8f4c3bcf
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
inamiy/SwiftTrace
|
cd098284ac64e992d2d1aaa61d1eb13effac5172
|
150cb937023e734d7d355e0b07915f7363b55f63
|
refs/heads/master
| 2021-01-19T22:01:31.831444 | 2016-06-10T07:00:17 | 2016-06-10T07:00:17 | 60,831,481 | 0 | 0 | null | 2016-06-10T07:38:16 | 2016-06-10T07:38:16 | null |
UTF-8
|
Swift
| false | false | 4,136 |
swift
|
//
// AppDelegate.swift
// SwiftTraceApp
//
// Created by John Holdsworth on 10/06/2016.
// Copyright © 2016 John Holdsworth. All rights reserved.
//
import UIKit
import SwiftTrace
public class TestClass {
let i = 999
public func x() {
print( "HERE \(i)" )
}
public func y() -> Float {
print( "HERE2" )
return -9.0
}
public func z( d: Int, f: Double, g: Float, h: Double, f1: Double, g1: Float, h1: Double, f2: Double, g2: Float, h2: Double, e: Int ) {
print( "HERE \(i) \(d) \(e) \(f) \(g) \(h) \(f1) \(g1) \(h1) \(f2) \(g2) \(h2)" )
}
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
// any inclusions or exlusiona need to come before trace enabled
//SwiftTrace.include( "Swift.Optiona|TestClass" )
self.dynamicType.traceBubdle()
let a = TestClass()
a.x()
print( a.y() )
a.x()
a.z( 88, f: 66, g: 55, h: 44, f1: 66, g1: 55, h1: 44, f2: 66, g2: 55, h2: 44, e: 77 )
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
// MARK: - Split view
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController, ontoPrimaryViewController primaryViewController:UIViewController) -> Bool {
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
if topAsDetailController.detailItem == nil {
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
return true
}
return false
}
}
|
[
-1
] |
20067ff96262a9e74054cb022dae8419680737fa
|
7ae6a8e3ed7478ee676929f92ce25d6d1291be13
|
/FlickrPhotos/Classes/BusinessLogicLayer/Services/FlickrPhotoService/FlickrPhotoService.swift
|
40c93aa0850bf8e2d5f0f723acc68eea497988cb
|
[] |
no_license
|
EvgeniyGT/ViperExampleSwift
|
2efc8b0b652a16fc50e2b6f90d69ee7560d656a8
|
1b83be8fe9179872ce9b688fcc20ca69ada01e71
|
refs/heads/master
| 2020-03-19T04:18:07.298439 | 2017-09-21T07:31:19 | 2017-09-21T07:31:19 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 662 |
swift
|
//
// FlickrPhotoService.swift
// FlickrPhotos
//
// Created by Sergey Matveev on 7/2/17.
// Copyright © 2017 GNS-IT. All rights reserved.
//
typealias FlickrPhotosCompletion = ([Photo], Int, Error?) -> ()
protocol FlickrPhotoService {
/**
Method is used to find a Flickr photos by sending request to server
@param tag is photo tag
@param page it is page number
@param completion called upon completion the method, and returns Error if there is any
*/
func searchPhotos(withTag tag: String,
page: Int,
completion: @escaping FlickrPhotosCompletion)
}
|
[
-1
] |
fa08724a5f2bbbe3b38e6616f6730e90a4813dd7
|
5725b5609c3e0a8ee60dc54516bedb3159e80704
|
/Sample-Project-Chapter-1.2/Moody/GeoLocationController.swift
|
acf54018976f3e36c52f223ce2e6ffe3975348cb
|
[
"MIT"
] |
permissive
|
landonepps/core-data
|
3f7ce5e2835fedb97ad22941893aa72f738d4a65
|
2c573f688bef3d1a2fb2988d3f37fa2bb1eb4ee3
|
refs/heads/master
| 2020-09-13T13:01:32.105553 | 2019-11-19T22:31:49 | 2019-11-19T22:31:49 | 222,789,766 | 0 | 0 |
MIT
| 2019-11-19T21:06:38 | 2019-11-19T21:06:37 | null |
UTF-8
|
Swift
| false | false | 2,494 |
swift
|
//
// GeoLocationController.swift
// Moody
//
// Created by Florian on 18/05/15.
// Copyright (c) 2015 objc.io. All rights reserved.
//
import Foundation
import CoreLocation
protocol GeoLocationControllerDelegate: class {
func geoLocationDidChangeAuthorizationStatus(authorized: Bool)
}
class GeoLocationController: NSObject {
var isAuthorized: Bool {
let status = CLLocationManager.authorizationStatus()
return status == .authorizedAlways || status == .authorizedWhenInUse
}
required init(delegate: GeoLocationControllerDelegate) {
super.init()
self.delegate = delegate
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers
locationManager.delegate = self
if CLLocationManager.authorizationStatus() == .notDetermined {
locationManager.requestWhenInUseAuthorization()
} else {
start()
}
}
func retrieveCurrentLocation(_ completion: @escaping (CLLocation?, CLPlacemark?) -> ()) {
guard let location = locationManager.location else {
completion(nil, nil)
return
}
guard previousLocation == nil || (previousLocation?.distance(from: location) ?? 0) > 1000 || previousPlacemark == nil else {
return completion(location, previousPlacemark)
}
geocoder.reverseGeocodeLocation(location) { placemarks, error in
self.previousPlacemark = placemarks?.first
completion(location, placemarks?.first)
}
}
// MARK: Private
fileprivate weak var delegate: GeoLocationControllerDelegate!
fileprivate var locationManager: CLLocationManager = CLLocationManager()
fileprivate var geocoder = CLGeocoder()
fileprivate var previousLocation: CLLocation?
fileprivate var previousPlacemark: CLPlacemark?
fileprivate func start() {
delegate.geoLocationDidChangeAuthorizationStatus(authorized: isAuthorized)
if isAuthorized {
locationManager.startUpdatingLocation()
}
}
}
extension GeoLocationController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
start()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
}
}
|
[
-1
] |
adf156bd014af0f644fb37dae8ff0de460bc4dad
|
c4449144ff19ed8baf8fe5a54640a25ca335ae63
|
/MusicTaste/Model/Fields/AlbumForms.swift
|
d1d3f52fa96f60b17abe36c38201ec1d041c9833
|
[] |
no_license
|
FernandoDLucas/Discoo
|
55058d40f44c7e40a5bf16a6e8f3d9ec4514a310
|
a2572e5fb9f0133352c02dc20551b6e29e96b189
|
refs/heads/main
| 2023-03-24T21:19:26.716485 | 2021-02-12T11:32:57 | 2021-02-12T11:32:57 | 335,623,888 | 3 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 382 |
swift
|
//
// AlbumFields.swift
// MusicTaste
//
// Created by Fernando de Lucas da Silva Gomes on 03/02/21.
//
enum AlbumForm {
case create
var fields: [String] {
switch self {
case .create:
return ["Título", "Artista", "Ano"]
}
}
}
enum AlbumFields: String {
case name = "Título"
case artist = "Artista"
case year = "Ano"
}
|
[
-1
] |
7ee587135e980f2b4619a4d9e22aa1d5b07b8620
|
2b5950a5b8d03b6f6d1a9174299aa30f0ff8bdf7
|
/SwiftUIRestAPI/SwiftUIRestAPI/View/ContentView.swift
|
91bb40ec6e4c2e814cc1ad7a3854083c5fc640d3
|
[
"MIT"
] |
permissive
|
angelosstaboulis/SwiftUIRestAPI
|
5c2354d27be6058a00db72cfb6796059b1ff8d70
|
f4e5d276627ac792082da0fbdcd966dfc8651d3e
|
refs/heads/main
| 2023-07-19T14:23:48.279017 | 2021-09-05T23:09:49 | 2021-09-05T23:09:49 | 403,430,476 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,049 |
swift
|
//
// ContentView.swift
// SwiftUIRestAPI
//
// Created by Angelos Staboulis on 5/9/21.
//
import SwiftUI
import Alamofire
import SwiftyJSON
struct ContentView: View {
@ObservedObject var viewModel = EmployeeViewModel()
var body: some View {
Form{
List(viewModel.employess){item in
VStack{
Text(String(item.id)).frame(width: 230, height: 50, alignment: .leading)
Text(item.employee_name).frame(width: 230, height: 50, alignment: .leading)
Text(String(item.employee_age)).frame(width: 230, height: 50, alignment: .leading)
Text(String(item.employee_salary)).frame(width: 230, height: 50, alignment: .leading)
}
}.frame(width: 1200, height: 190, alignment: .topLeading)
}.onAppear {
viewModel.fetchEmployees()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
|
[
-1
] |
4081ae13db622f8a623726420cb4637b53579bdb
|
8c6272cc27ff1d55057ca1cc398204b844247c42
|
/Lolita/DribbbleAPIService.swift
|
f753b83a31016dfec456976c9121099814b59656
|
[] |
no_license
|
ImEric/Lolita
|
1fbeb1298d82a258ce891e97dd8d5b2595db02ff
|
4cb3273b972bf3ea3ec799ae9c425007238f9f65
|
refs/heads/master
| 2021-01-21T03:54:32.251219 | 2015-09-21T08:49:47 | 2015-09-21T08:49:47 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,028 |
swift
|
//
// DribbbleAPIService.swift
// Lolita
//
// Created by zhowkevin on 15/9/20.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import Foundation
import Alamofire
import SVProgressHUD
import SwiftyUserDefaults
enum DribbbleAPI: String {
case Shots = "/shots"
case ShotsByFollowed = "/user/following/shots"
}
enum DribbbleTimeframe: String {
case Week = "week"
case Month = "month"
case Year = "year"
case Ever = "ever"
}
func shotsByListType(type: LolitaSelectChannel, page: Int, complete: (shots: [DribbbleShot]?) -> Void) {
let request = authRequestPath(DribbbleAPI.Shots.rawValue + "?page=\(page)&per_page=50&list=\(type.HumanRead)", useMethod: .GET)
Alamofire.request(request).responseJSON { (request, response, JSON) in
if JSON.isSuccess {
if let JSON = JSON.value as? [JSONDictionary] {
print("Profile Got")
let shots = JSON.map({ shotFromInfo($0) }).filter({ $0 != nil }).map({ $0! })
complete(shots: shots)
} else {
complete(shots: nil)
}
} else {
complete(shots: nil)
}
//
// handleError(response, JSON: JSON.value, complete: { (statusCode, errorMesage) in
// complete(nil)
// })
}
}
func followedShots(page: Int, complete: (shots: [DribbbleShot]?) -> Void) {
let request = authRequestPath(DribbbleAPI.ShotsByFollowed.rawValue + "?page=\(page)&per_page=50", useMethod: .GET)
Alamofire.request(request).responseJSON { (request, response, JSON) in
if JSON.isSuccess {
if let JSON = JSON.value as? [JSONDictionary] {
print("Profile Got")
let shots = JSON.map({ shotFromInfo($0) }).filter({ $0 != nil }).map({ $0! })
complete(shots: shots)
} else {
complete(shots: nil)
}
} else {
complete(shots: nil)
}
//
// handleError(response, JSON: JSON.value, complete: { (statusCode, errorMesage) in
// complete(nil)
// })
}
}
func commentsByShotID(shotID: Int, complete: (comments: [DribbbleComment]?) -> Void) {
let request = authRequestPath("\(DribbbleAPI.Shots.rawValue)/\(shotID)/comments", useMethod: .GET)
Alamofire.request(request).responseJSON { (request, response, JSON) in
if JSON.isSuccess {
if let JSON = JSON.value as? [JSONDictionary] {
print("Comments Got")
let comments = JSON.map({ commentFromInfo($0) }).filter({ $0 != nil }).map({ $0! })
complete(comments: comments)
} else {
complete(comments: nil)
}
} else {
complete(comments: nil)
}
//
// handleError(response, JSON: JSON.value, complete: { (statusCode, errorMesage) in
// complete(nil)
// })
}
}
func likeByShotID(shotID: Int, complete: (likeID: Int?) -> Void) {
let request = authRequestPath("\(DribbbleAPI.Shots.rawValue)/\(shotID)/like", useMethod: .POST)
Alamofire.request(request).responseJSON { (request, response, JSON) in
if JSON.isSuccess {
if let JSON = JSON.value as? JSONDictionary, likeID = JSON["id"] as? Int {
print("Like Got")
var dribbbleLike = Defaults[.dribbbleLike]
dribbbleLike["\(shotID)"] = true
Defaults[.dribbbleLike] = dribbbleLike
complete(likeID: likeID)
} else {
complete(likeID: nil)
}
} else {
complete(likeID: nil)
}
//
// handleError(response, JSON: JSON.value, complete: { (statusCode, errorMesage) in
// complete(nil)
// })
}
}
func unLikeByShotID(shotID: Int, complete: (finished: Bool?) -> Void) {
let request = authRequestPath("\(DribbbleAPI.Shots.rawValue)/\(shotID)/like", useMethod: .DELETE)
Alamofire.request(request).responseJSON { (request, response, JSON) in
if JSON.isSuccess {
var dribbbleLike = Defaults[.dribbbleLike]
dribbbleLike["\(shotID)"] = false
Defaults[.dribbbleLike] = dribbbleLike
complete(finished: true)
} else {
complete(finished: nil)
}
//
// handleError(response, JSON: JSON.value, complete: { (statusCode, errorMesage) in
// complete(nil)
// })
}
}
|
[
-1
] |
cc63df8deed31af05eb7857d2f412ce9fa1272fc
|
c6e99394bbcb4528e926bba532d780b48f290e40
|
/Sesion4_1/AppDelegate.swift
|
ba733e3734bf095165a323cb0d565804e66a4a35
|
[] |
no_license
|
enigma2006x/Podcast-And-Feed-Unam
|
af5989328091149cfe24f039ff7fa0bdd8d1bc76
|
a59e4b64e90daaa362042d930f48e8891f04a72c
|
refs/heads/master
| 2021-03-20T06:57:13.308087 | 2020-03-14T01:11:34 | 2020-03-14T01:11:34 | 247,187,767 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,638 |
swift
|
//
// AppDelegate.swift
// Sesion4_1
//
// Created by Jose Antonio Trejo Flores on 28/02/20.
// Copyright © 2020 Jose Antonio Trejo Flores. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
appearanceNavigationBar()
appearanceTextField()
return true
}
private func appearanceNavigationBar() {
let backgroundColor = UIColor.purple
let tintColor = UIColor.white
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = backgroundColor
appearance.titleTextAttributes = [.foregroundColor: tintColor]
appearance.largeTitleTextAttributes = [.foregroundColor: tintColor]
UINavigationBar.appearance().tintColor = tintColor
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
UINavigationBar.appearance().tintColor = tintColor
UINavigationBar.appearance().barTintColor = backgroundColor
UINavigationBar.appearance().isTranslucent = false
}
}
private func appearanceTextField() {
UITextField.appearance().backgroundColor = .white
}
}
|
[
-1
] |
fa57459f314ca38f0aec98501bf1eb9158769e07
|
5895c9fbc5baceb40591455ff880a471672cb9e3
|
/CondeNastAssignment/Controller/NewsDetailsViewController.swift
|
003d3cb6425e42ccda9171ebb5b4c7e098492b54
|
[] |
no_license
|
jitendrahome123/Condenast-Assignment
|
4a20b5ff4205b73b8d7d9a837f016561cd6b646f
|
b53b780681dfa13bdba21e204ab445be828af4be
|
refs/heads/master
| 2022-11-28T16:43:15.826560 | 2020-08-03T06:55:53 | 2020-08-03T06:55:53 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,633 |
swift
|
//
// NewDetailsViewController.swift
// CondeNastAssignment
//
// Created by Jitendra Kumar Agarwal on 3/08/19.
// Copyright © 2019 Jitendra Kumar Agarwal. All rights reserved.
//
import UIKit
class NewsDetailsViewController: UIViewController {
var artical: Articles!
@IBOutlet weak var imgNewsImage: UIImageView!
@IBOutlet weak var tableNewsDetails: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
if let imageNewUrl = artical.urlToImage {
addImageTapGesture()
self.imgNewsImage.sd_setImage(with: URL(string: imageNewUrl), placeholderImage: UIImage(named: "news-default"))
}else{
self.imgNewsImage.image = UIImage(named: "news-default")
}
self.tableNewsDetails.rowHeight = UITableView.automaticDimension
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.title = (String.isSafeString(artical.source?.name as AnyObject?)) ? artical.source?.name : ""
}
private func addImageTapGesture() {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
imgNewsImage.isUserInteractionEnabled = true
imgNewsImage.addGestureRecognizer(tapGestureRecognizer)
}
@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{
let webView = mainStoryboard.instantiateViewController(withIdentifier: "NewWebViewViewController") as! NewWebViewViewController
if let imageNewUrl = artical.url {
webView.imageURL = imageNewUrl
self.navigationController?.pushViewController(webView, animated: true)
}
}
}
// MARK:- User Define
extension NewsDetailsViewController {
@objc func backAction(sender:UIButton) {
self.navigationController?.popViewController(animated: true)
}
}
// MARK:- Tableview Delagte and Datascource.
extension NewsDetailsViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "NewsDetailsHeaderCell") as! NewsDetailsHeaderCell
cell.datasource = artical as AnyObject
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return UITableView.automaticDimension
}
}
|
[
-1
] |
8bc1b8afccfc3974beaab71b0a97ced01c498cf2
|
21b50964af998ebaa49b3e1eca7eb5373b9a55c0
|
/News/Manager/NewsManager.swift
|
c33c5757b64553c7dff466dbb21de1aaa4c01e7a
|
[] |
no_license
|
maheshanaik/News
|
e38753f5ec9e5bce7591d5c338224e801428af5d
|
1e23216cd630148d75d51f6960573c84a9e5ae3f
|
refs/heads/main
| 2023-07-12T02:18:21.653593 | 2021-08-20T09:47:49 | 2021-08-20T09:47:49 | 342,166,317 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,288 |
swift
|
//
// NewsManager.swift
// News
//
// Created by Mahesha on 24/02/21.
//
import Foundation
class NewsManager {
static let shared = NewsManager()
private init() {}
private var pageCount = 1
private var apiManager = APIManager()
func getNews(completion: @escaping (_ news: Articles?, _ error: APIManager.CustomError?) -> Void) {
guard let url = URL(string: "https://newsapi.org/v2/top-headlines?country=us&apiKey=79b25b150d504b818cab4c2dd000f59a&pageSize=10&page=\(pageCount)") else {
return
}
apiManager.getData(fromURL: url) { result in
guard let result = result else {
return
}
if result.error == nil {
let decoder = JSONDecoder()
guard let data = result.data else {
return
}
do {
let articles = try decoder.decode(Articles.self, from: data)
self.pageCount += 1
completion(articles, nil)
} catch {
completion(nil, .noData)
}
} else {
completion(nil, result.error)
}
}
}
}
|
[
-1
] |
baedc5bf72c8ecf78f468ccf9731d58cfc2a6285
|
ce243ff98dc9d87be510e1d985ba562a4e0273a5
|
/Snozer/Models/MatchScoreDto.swift
|
c59cbd39f4c939c7296c31d9d561000d682104f7
|
[] |
no_license
|
deepti0697/snozerdev
|
423fa98785a4290ec37b54c50b40ca3423f34f37
|
780020d315425fda7d0f7c85845e5d0028b40e49
|
refs/heads/master
| 2022-12-04T23:58:04.444495 | 2020-08-24T09:48:50 | 2020-08-24T09:48:50 | 289,887,476 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,103 |
swift
|
//
// MatchScoreDto.swift
// Snozer
//
// Created by Admin on 23/11/19.
// Copyright © 2019 Calieo Technologies. All rights reserved.
//
import Foundation
import ObjectMapper
class MatchScoreDto: NSObject, Mappable {
var notes: String = "";
var team1: TeamScoreDto?;
var team2: TeamScoreDto?;
override init() {
}
required init(map: Map) {
}
func mapping(map: Map) {
notes <- map["score_board_notes"];
team1 <- map["team1"];
team2 <- map["team2"];
}
}
class TeamScoreDto: NSObject, Mappable {
var id: String = "";
var name: String = "";
var sortName: String = "";
var teamOvers: String = "";
var teamRun: String = "";
var teamWicket: String = "";
override init() {
}
required init(map: Map) {
}
func mapping(map: Map) {
id <- map["id"];
name <- map["name"];
sortName <- map["sort_name"];
teamOvers <- map["team_overs"];
teamRun <- map["team_run"];
teamWicket <- map["team_wicket"];
}
}
|
[
-1
] |
32be7bd3c335fa8dc3fa70aaa901edcdbbcb909a
|
2b79b77ca93b87af7597cff0b5954f30a7e53675
|
/ThoughtForTheDay/ThoughtForTheDay/Quotes/Cell/QuoteTableViewCell.swift
|
91485b5b742bbc4fc8384d63120bb2d8e4b3e46d
|
[] |
no_license
|
MartinBergerDX/ThoughtForTheDay
|
8a29921996b5b3c50de0008e8067edafb56e7b64
|
30206771dc81125ba2c89148a46db21ae4d78b51
|
refs/heads/master
| 2020-03-19T22:10:14.761445 | 2019-06-20T16:04:01 | 2019-06-20T16:04:01 | 136,961,269 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 269 |
swift
|
//
// QuoteTableViewCell.swift
// ThoughtForTheDay
//
// Created by Martin on 6/8/18.
// Copyright © 2018 heavydebugging. All rights reserved.
//
import Foundation
import UIKit
class QuoteTableViewCell: UITableViewCell {
@IBOutlet var quoteLabel: UILabel?
}
|
[
-1
] |
b219f5b143f3d7a40e7d7c39479bd361cab79df7
|
76833e964c86a7fcf1fe9909bc388ed4f0ed9108
|
/Capsula/Modules/User/CompleteProfile/CompleteProfileInteractor.swift
|
7c7a84f27aee769bd5ba5851e846362593f1a208
|
[] |
no_license
|
sherefshokry/NewCapsula
|
b17699cdbc9da6cdf694b286dbfa4e6e6a27b1b9
|
a0294b9fc786a70e25ac47ea3e878525573de822
|
refs/heads/master
| 2023-02-21T23:36:16.070484 | 2021-01-11T14:46:18 | 2021-01-11T14:46:18 | 320,609,998 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 939 |
swift
|
//
// CompleteProfileInteractor.swift
// Capsula
//
// Created SherifShokry on 1/4/20.
// Copyright © 2020 SherifShokry. All rights reserved.
//
// Template generated by Juanpe Catalán @JuanpeCMiOS
//
import UIKit
import Moya
class CompleteProfileInteractor : PresenterToIntetractorCompleteProfileProtocol {
var presenter: InteractorToPresenterCompleteProfileProtocol?
private let provider = MoyaProvider<UserDataSource>()
func checkIfPhoneExist(phone: String,email :String) {
provider.request(.checkPhoneIsExist(phone, email)) { [weak self] result in
guard let self = self else { return }
switch result {
case .success(_):
self.presenter?.phoneIsExist()
case .failure(let error):
//error.response?.statusCode ?? 0
self.presenter?.phoneNotExist()
}
}
}
}
|
[
-1
] |
c1fb78fdba4ac756d1ff1462efa9028d35ae433d
|
771d821775d7a10735e8e5e22e2a643fa541bbdf
|
/Word Scramble/ViewController.swift
|
cae9ef86a776f2619dafd173b5603d43fe3eef96
|
[] |
no_license
|
mehar19/Word-Scramble
|
2195a7823c8272609ac170b12c65c71bc301c615
|
bc988bcd7c1b7b699af69f6151cdbd799170b5d7
|
refs/heads/main
| 2023-08-02T11:10:50.775116 | 2021-09-24T18:07:54 | 2021-09-24T18:07:54 | 410,059,207 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 4,797 |
swift
|
//
// ViewController.swift
// Word Scramble
//
// Created by Mehar on 24/09/2021.
//
import UIKit
class ViewController: UITableViewController {
var allWords = [String]()
var usedWords = [String]()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem =
UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(promptForAnswer))
navigationItem.leftBarButtonItem =
UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(startGame))
if let startWordsURL = Bundle.main.url(forResource: "start", withExtension: "txt"){
if let startWords = try? String(contentsOf: startWordsURL){
allWords = startWords.components(separatedBy: "\n")
}
}
if allWords.isEmpty{
allWords = ["silkworm"]
}
startGame()
}
@objc func startGame(){
title = allWords.randomElement()
usedWords.removeAll(keepingCapacity: true)
tableView.reloadData()
}
@objc func promptForAnswer(){
let ac = UIAlertController(title: "Enter answer", message: nil, preferredStyle: .alert)
ac.addTextField()
let submitAction = UIAlertAction(title: "Submit", style: .default) { [weak self, weak ac ] action in
guard let answer = ac?.textFields?[0].text else {return}
self?.submit(answer)
}
ac.addAction(submitAction)
present(ac,animated: true)
}
func submit(_ answer: String){
let lowerAnswer = answer.lowercased()
if isPossible(word: lowerAnswer) {
if isOrignal(word: lowerAnswer) {
if isReal(word: lowerAnswer) {
if isBig(word: lowerAnswer){
usedWords.insert(answer, at: 0)
let indexPath = IndexPath(row: 0, section: 0)
tableView.insertRows(at: [indexPath], with: .automatic)
return
}else {showErrorMessage(errorType: "notBig")}
}else {showErrorMessage(errorType: "notReal")}
} else {showErrorMessage(errorType: "notOrignal") }
} else {showErrorMessage(errorType: "notPossible") }
}
func showErrorMessage(errorType: String){
var errorTitle: String
var errorMessage: String
switch errorType{
case "notPossible":
errorTitle = "Word not possible"
errorMessage = "You can't spell that word from '\(title!.lowercased())'!"
case "notOrignal":
errorTitle = "Word used already"
errorMessage = "Be more original!"
case "notReal":
errorTitle = "Word not recognised"
errorMessage = "You can't just make them up, you know!"
case "notBig":
errorTitle = "Word too small"
errorMessage = "Try making big words!"
default:
errorTitle = ""
errorMessage = ""
}
let ac = UIAlertController(title: errorTitle, message: errorMessage, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
}
func isBig(word: String) -> Bool{
if word.count < 4{
return false
} else{
return true
}
}
func isPossible(word: String) -> Bool{
guard var tempWord = title?.lowercased() else {return false}
for letter in word{
if let position = tempWord.firstIndex(of: letter){
tempWord.remove(at: position)
}else{return false}
}
return true
}
func isOrignal(word: String) -> Bool{
return !usedWords.contains(word)
}
func isReal(word: String) -> Bool{
let checker = UITextChecker()
let range = NSRange(location: 0, length: word.utf16.count)
let misspelledRange = checker.rangeOfMisspelledWord(in: word, range: range, startingAt: 0, wrap: false, language: "en")
return misspelledRange.location == NSNotFound
}
//MARK: - TableView methods
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return usedWords.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Word", for: indexPath)
cell.textLabel?.text = usedWords[indexPath.row]
return cell
}
}
|
[
257763
] |
2d3662be5a3680c77c5b00782adbbcbdf8ab188e
|
2a0b14d73964ac53972b5069a09af3b1d32095bc
|
/IceBoxOrganizer최종/IceBoxOrganizer/Delegate/IceboxViewDelegate.swift
|
4d77f189d897a33f69ef3f7edf66d067b8f4cabd
|
[] |
no_license
|
eunyuni/IceBoxOrganizer
|
9ce7c8cff565efea8723159c8bb8b3e66ef95547
|
39215a16115ed0ebd22ace88a9090a3caad552d0
|
refs/heads/master
| 2022-12-07T18:12:47.208481 | 2020-08-14T13:49:55 | 2020-08-14T13:49:55 | 275,087,183 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 347 |
swift
|
//
// IceBoxViewDelegate.swift
// IceBoxOrganizer
//
// Created by Soohan Lee on 2020/01/31.
// Copyright © 2020 Soohan Lee. All rights reserved.
//
import UIKit
protocol IceboxViewDelegate {
func whenDidTapSeeAllMaterialButton(_ button: UIButton)
func whenDidTouchedUpInsideIceboxButton(_ button: IceboxButton, icebox: Icebox)
}
|
[
-1
] |
3b91e4a8e7644e0b0fb73cb2e7a5808111039b41
|
45e585009cd36e9f51ff6055c05c3ac5f5ba832a
|
/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinChart/Views/IndicatorSelectorCell.swift
|
e20f43f3422c6d4be2451f7cd1b6dec56396c76b
|
[
"MIT"
] |
permissive
|
gotnull/unstoppable-wallet-ios
|
b7ff834ff846b247e19bd9e77566cd345f7ba7dc
|
9de65609d3e3e418d33d49d1f6286c767aee45d5
|
refs/heads/master
| 2023-05-29T13:26:58.940745 | 2021-06-10T07:03:19 | 2021-06-10T07:03:19 | 375,601,415 | 1 | 0 |
MIT
| 2021-06-10T07:03:19 | 2021-06-10T06:58:01 | null |
UTF-8
|
Swift
| false | false | 3,567 |
swift
|
import UIKit
import ThemeKit
import ComponentKit
class IndicatorSelectorCell: UITableViewCell {
private let topSeparatorView = UIView()
private let bottomSeparatorView = UIView()
private var indicatorViews = [ChartIndicatorSet : UIButton]()
public var onTapIndicator: ((ChartIndicatorSet) -> ())?
override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: nil)
backgroundColor = .clear
contentView.backgroundColor = .clear
selectionStyle = .none
let emaIndicatorView = ThemeButton().apply(style: .tertiary)
contentView.addSubview(emaIndicatorView)
emaIndicatorView.snp.makeConstraints { maker in
maker.centerY.equalToSuperview()
maker.leading.equalToSuperview().inset(CGFloat.margin16)
maker.height.equalTo(24)
}
emaIndicatorView.addTarget(self, action: #selector(tapIndicator), for: .touchUpInside)
emaIndicatorView.setTitle("EMA", for: .normal)
emaIndicatorView.tag = Int(ChartIndicatorSet.ema.rawValue)
indicatorViews[.ema] = emaIndicatorView
let macdIndicatorView = ThemeButton().apply(style: .tertiary)
contentView.addSubview(macdIndicatorView)
macdIndicatorView.snp.makeConstraints { maker in
maker.centerY.equalToSuperview()
maker.leading.equalTo(emaIndicatorView.snp.trailing).offset(CGFloat.margin8)
maker.height.equalTo(24)
}
macdIndicatorView.addTarget(self, action: #selector(tapIndicator), for: .touchUpInside)
macdIndicatorView.setTitle("MACD", for: .normal)
macdIndicatorView.tag = Int(ChartIndicatorSet.macd.rawValue)
indicatorViews[.macd] = macdIndicatorView
let rsiIndicatorView = ThemeButton().apply(style: .tertiary)
contentView.addSubview(rsiIndicatorView)
rsiIndicatorView.snp.makeConstraints { maker in
maker.centerY.equalToSuperview()
maker.leading.equalTo(macdIndicatorView.snp.trailing).offset(CGFloat.margin8)
maker.height.equalTo(24)
}
rsiIndicatorView.addTarget(self, action: #selector(tapIndicator), for: .touchUpInside)
rsiIndicatorView.setTitle("RSI", for: .normal)
rsiIndicatorView.tag = Int(ChartIndicatorSet.rsi.rawValue)
indicatorViews[.rsi] = rsiIndicatorView
contentView.addSubview(topSeparatorView)
topSeparatorView.snp.makeConstraints { maker in
maker.leading.top.trailing.equalToSuperview()
maker.height.equalTo(CGFloat.heightOneDp)
}
topSeparatorView.backgroundColor = .themeSteel10
contentView.addSubview(bottomSeparatorView)
bottomSeparatorView.snp.makeConstraints { maker in
maker.leading.bottom.trailing.equalToSuperview()
maker.height.equalTo(CGFloat.heightOneDp)
}
bottomSeparatorView.backgroundColor = .themeSteel10
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc private func tapIndicator(sender: UIButton) {
let indicator = ChartIndicatorSet(rawValue: UInt8(sender.tag))
onTapIndicator?(indicator)
}
public func set(indicator: ChartIndicatorSet, selected: Bool) {
indicatorViews[indicator]?.isSelected = selected
}
public func set(indicator: ChartIndicatorSet, disabled: Bool) {
indicatorViews[indicator]?.isEnabled = !disabled
}
}
|
[
-1
] |
906528e9b1ee97fcc64bea1065164c7068549a18
|
0e1d710b87b81a3e49d91f7677d1697304e038e9
|
/SwiftUdemyBootcamp/QuizzApp/TnpQuizz/Model/QuestionBank.swift
|
51c1d380b3546498677a582c6b152c10b61556c7
|
[] |
no_license
|
tnpestana/LearningSwift
|
f646c1040693f5d5e2c6007fb6a098f5864ccdff
|
15bf8aff8f66c28da2bb8157f07d1b017da8edc2
|
refs/heads/master
| 2023-04-30T13:58:14.890884 | 2021-05-14T15:56:50 | 2021-05-14T15:56:50 | 287,776,130 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,375 |
swift
|
//
// QuestionBank.swift
// TnpQuizz
//
// Created by Tiago Pestana on 02/06/2019.
// Copyright © 2019 Tiago Pestana. All rights reserved.
//
import Foundation
struct QuestionBank
{
var list = [Question]()
init()
{
// Add the Question to the list of questions
list.append(Question(question: "Valentine\'s day is banned in Saudi Arabia.", answer: true, explanation: "According to the BBC, religious police banned red roses and sale of Valentine's day gifts as it is both un-Islamic and encourages relations of men and women outside wedlock."))
list.append(Question(question: "A slug\'s blood is green.", answer: true, explanation: "52 bones in the feet and 206 in the whole body."))
list.append(Question(question: "Approximately one quarter of human bones are in the feet.", answer: true, explanation: ""))
list.append(Question(question: "The total surface area of two human lungs is approximately 70 square metres.", answer: true, explanation: "Under West Virginia state code §20-2-4 it is legal to take home and eat roadkill."))
list.append(Question(question: "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.", answer: true, explanation: ""))
list.append(Question(question: "In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.", answer: false, explanation: ""))
list.append(Question(question: "It is illegal to pee in the Ocean in Portugal.", answer: true, explanation: ""))
list.append(Question(question: "You can lead a cow down stairs but not up stairs.", answer: false, explanation: "You can lead a cow up the stairs but not down the stairs. A cow’s ankle and knee joints are misaligned for supporting the animal’s weight when travelling down stairs."))
list.append(Question(question: "Google was originally called \"Backrub\".", answer: true, explanation: "Larry and Sergey began collaborating on a search engine called BackRub in 1996."))
list.append(Question(question: "Buzz Aldrin\'s mother\'s maiden name was \"Moon\".", answer: true, explanation: "Her name was Marion Moon."))
list.append(Question(question: "The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.", answer: false, explanation: "Loud structured sounds of Blue Whales have been recorded in excess of 188 db (louder than a jet engine). The Tiger Pistol Shrimp is able to snap its claw and stun its prey by emitting a sound up to 200 db."))
list.append(Question(question: "No piece of square dry paper can be folded in half more than 7 times.", answer: false, explanation: ""))
list.append(Question(question: "Chocolate affects a dog\'s heart and nervous system; a few ounces are enough to kill a small dog.", answer: true, explanation: "Theobromine is a bitter alkaloid of the cocoa plant found in chocolate. Although harmless to humans, it can cause vomiting, diarrhoea, convulsions and even death in animals that digest theobromine slowly, such as dogs. The lethal dosage is between 250 and 500 mg per kg of body weight."))
}
}
|
[
-1
] |
52c177c2a985526dd70169706ca0a983c96fd89a
|
879dc6481b7a357a2eedf251ee52eec74087aa7e
|
/sleden2/ViewController.swift
|
f33f45ce1f5f1095f1669f7338a94bd9f513df45
|
[] |
no_license
|
alvestad10/sleden1
|
3f034163d4a5e5f4a86407096074d67a30e3c668
|
39551468cabef011b4dbb6c94919edfbdc7c4cdb
|
refs/heads/master
| 2021-01-10T14:28:33.888413 | 2015-12-19T23:17:16 | 2015-12-19T23:17:16 | 48,291,320 | 0 | 0 | null | 2015-12-19T23:17:16 | 2015-12-19T17:39:47 |
Objective-C
|
UTF-8
|
Swift
| false | false | 3,329 |
swift
|
//
// ViewController.swift
// sleden2
//
// Created by Daniel Alvestad on 12/12/15.
// Copyright © 2015 Daniel Alvestad. All rights reserved.
//
import UIKit
import Parse
class ViewController: UIViewController {
@IBOutlet weak var usernameField: UITextField!
@IBOutlet weak var passwordField: UITextField!
var actInd: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0,0,150,150)) as UIActivityIndicatorView
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if (PFUser.currentUser() != nil){
print("Did log in user")
self.performSegueWithIdentifier("startAppLog", sender: PFUser.currentUser())
}
self.actInd.center = self.view.center
self.actInd.hidesWhenStopped = true
self.actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(self.actInd)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func logInButton(sender: AnyObject) {
let username = self.usernameField.text
let password = self.passwordField.text
if (username?.utf16.count < 4 || password?.utf16.count < 5){
let alert = UIAlertController(title: "Invalid", message:"Username must be greater then 4 and Password must be greater then then 5.", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
} else {
self.actInd.startAnimating()
PFUser.logInWithUsernameInBackground(username!, password: password!, block: {(user,error) -> Void in
self.actInd.stopAnimating()
if ((user) != nil){
let alert = UIAlertController(title: "Success", message:"Logged In", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { alertAction in
print("Did log in user")
self.performSegueWithIdentifier("startAppLog", sender: user)
})
self.presentViewController(alert, animated: true){}
} else {
let alert = UIAlertController(title: "Invalide", message:"\(error)", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
}
})
}
}
@IBAction func lgoOutButton(sender: AnyObject) {
PFUser.logOut()
usernameField.text = ""
passwordField.text = ""
}
@IBAction func SignInButton(sender: AnyObject) {
self.performSegueWithIdentifier("SignInViewController", sender: self)
}
}
|
[
-1
] |
6b2318b958d966dfe211a11b653a833c4eff72c0
|
8988be87522cb6c13c2a69c3c8653c0d1f54ac53
|
/TipCalculator2/AppDelegate.swift
|
22fea7dcb7cf7e166e4de05585fed78f45742b50
|
[
"Apache-2.0"
] |
permissive
|
b2liang/tipcalculator
|
8aeacdcaf9058dcf4431407c4349f1ffb63134dc
|
e8c7acca49931535b71a2c076a913044499fb32f
|
refs/heads/master
| 2020-05-25T05:20:24.553288 | 2017-03-21T17:21:33 | 2017-03-21T17:21:33 | 84,914,362 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,097 |
swift
|
//
// AppDelegate.swift
// TipCalculator2
//
// Created by 梁宝 on 3/12/17.
// Copyright © 2017 Bao LIang. All rights reserved.
//
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
// MARK: - Core Data stack
lazy var applicationDocumentsDirectory: NSURL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named "intuit.TipCalculator2" in the application's documents Application Support directory.
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return urls[urls.count-1]
}()
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
let modelURL = NSBundle.mainBundle().URLForResource("TipCalculator2", withExtension: "momd")!
return NSManagedObjectModel(contentsOfURL: modelURL)!
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
// The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
// Create the coordinator and store
let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
var failureReason = "There was an error creating or loading the application's saved data."
do {
try coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
} catch {
// Report any error we got.
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error as NSError
let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
abort()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext = {
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
let coordinator = self.persistentStoreCoordinator
var managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
// MARK: - Core Data Saving support
func saveContext () {
if managedObjectContext.hasChanges {
do {
try managedObjectContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
NSLog("Unresolved error \(nserror), \(nserror.userInfo)")
abort()
}
}
}
}
|
[
283144,
277514,
277003,
280085,
278551,
278042,
276510,
281635,
194085,
277030,
228396,
277038,
223280,
278577,
280132,
162394,
282203,
189025,
292450,
285796,
279148,
278125,
285296,
227455,
278656,
228481,
276611,
278665,
280205,
225934,
278674,
188050,
276629,
283803,
278687,
282274,
277154,
278692,
228009,
287402,
227499,
278700,
284845,
278705,
276149,
278711,
279223,
278718,
283838,
228544,
279753,
229068,
227533,
280273,
278751,
201439,
226031,
159477,
280312,
203532,
181516,
277262,
280335,
284432,
278289,
278801,
284434,
321296,
276751,
278287,
276755,
278808,
278297,
282910,
281379,
282915,
280370,
277306,
278844,
280382,
282433,
237382,
164166,
226634,
276313,
278877,
280415,
277344,
276321,
227687,
334185,
279405,
278896,
277363,
281972,
275828,
278902,
280439,
276347,
228220,
279422,
278916,
284557,
293773,
191374,
277395,
283028,
288147,
214934,
278943,
282016,
283554,
230320,
230322,
281011,
283058,
286130,
278971,
276923,
282558,
299970,
280007,
288200,
284617,
287689,
286157,
326096,
281041,
283091,
282585,
294390,
282616,
214010
] |
895980d5a86175460988f3105b16e1820c4db139
|
359fdfd8b911cbc2f521de7ddb8d1fd3f251df02
|
/otraprueba/otraprueba/ViewController.swift
|
1b0d701f79d03749e8d5bd489983c78d89dd64fe
|
[] |
no_license
|
RBevilacqua/IOS-Development
|
ffdd3796142fc54f8469c1787abc32eb33b2404b
|
4149d867a34710e5c34eb04559157b1623ce09af
|
refs/heads/master
| 2016-09-06T18:27:38.555449 | 2015-03-11T00:48:42 | 2015-03-11T00:48:42 | 31,220,721 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 505 |
swift
|
//
// ViewController.swift
// otraprueba
//
// Created by Mohamed DIb on 25/2/15.
// Copyright (c) 2015 UpperSky. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
|
[
215562,
287243,
282128,
277527,
282143,
295460,
286249,
286775,
279096,
300089,
277057,
293961,
278606,
212561,
284242,
276054,
237655,
212573,
309347,
309351,
309353,
311913,
356458,
277612,
284275,
276597,
276099,
276612,
279684,
280710,
253066,
285837,
280219,
299165,
225955,
326311,
302256,
280760,
299709,
283839,
277696,
282311,
313550,
307410,
302295,
278752,
282338,
290020,
291556,
277224,
282346,
312049,
282365,
300288,
230147,
282389,
369434,
276256,
315170,
277796,
304933,
283433,
315177,
289578,
288579,
293700,
298842,
241499,
298843,
311645,
308064,
313704,
313706,
313708,
296813,
276849,
315250,
277364,
207738,
275842,
224643,
313733,
306577,
279442,
306578,
275358,
283556,
288165,
277420,
289196,
370093,
285103,
277935,
289204,
277430,
277432,
298936,
278968,
299973,
288205,
280015,
301012,
301016,
280028,
280029,
280030,
294889,
277487,
281073,
308721,
227315,
296436,
281078
] |
008357870193d855ffc070ae7c10badd79476206
|
3079ae3df2236ec59e12792a0fc2fbc7ebd0cdbc
|
/Photon-Tinker/ParticleUtils.swift
|
b014d090da4392f9391f12bec73e85da2ec7d0fa
|
[
"Apache-2.0"
] |
permissive
|
rocklee325/photon-tinker-ios
|
d216067f924c3f509562148d21fd9f4d542a7bba
|
e028483a4b1b66443bc802515062e5444688e894
|
refs/heads/master
| 2020-03-28T15:06:48.521532 | 2018-08-09T13:06:46 | 2018-08-09T13:06:46 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,318 |
swift
|
//
// ParticleUtils.swift
// Particle
//
// Created by Ido Kleinman on 6/29/16.
// Copyright © 2016 particle. All rights reserved.
//
import Foundation
class ParticleUtils: NSObject {
static var particleCyanColor = UIColor.color("#00ADEF")!
static var particleAlmostWhiteColor = UIColor.color("#F7F7F7")!
static var particleDarkGrayColor = UIColor.color("#333333")!
static var particleGrayColor = UIColor.color("#777777")!
static var particleLightGrayColor = UIColor.color("#C7C7C7")!
static var particlePomegranateColor = UIColor.color("#C0392B")!
static var particleEmeraldColor = UIColor.color("#2ECC71")!
static var particleRegularFont = UIFont(name: "Gotham-book", size: 16.0)!
static var particleBoldFont = UIFont(name: "Gotham-medium", size: 16.0)!
class func getDeviceTypeAndImage(_ device : ParticleDevice?) -> (deviceType: String, deviceImage: UIImage) {
var image : UIImage?
var text : String?
switch (device!.type)
{
case .core:
image = UIImage(named: "imgDeviceCore")
text = "Core"
case .electron:
image = UIImage(named: "imgDeviceElectron")
text = "Electron"
case .photon:
image = UIImage(named: "imgDevicePhoton")
text = "Photon/P0"
case .P1:
image = UIImage(named: "imgDeviceP1")
text = "P1"
case .raspberryPi:
image = UIImage(named: "imgDeviceRaspberryPi")
text = "Raspberry Pi"
case .redBearDuo:
image = UIImage(named: "imgDeviceRedBearDuo")
text = "RedBear Duo"
case .bluz:
image = UIImage(named: "imgDeviceBluz")
text = "Bluz"
case .digistumpOak:
image = UIImage(named: "imgDeviceDigistumpOak")
text = "Digistump Oak"
default:
image = UIImage(named: "imgDeviceUnknown")
text = "Unknown"
}
return (text!, image!)
}
@objc class func shouldDisplayTutorialForViewController(_ vc : UIViewController) -> Bool {
// return true
/// debug
let prefs = UserDefaults.standard
let defaultsKeyName = "Tutorial"
let dictKeyName = String(describing: type(of: vc))
if let onceDict = prefs.dictionary(forKey: defaultsKeyName) {
let keyExists = onceDict[dictKeyName] != nil
if keyExists {
return false
} else {
return true
}
} else {
return true
}
}
@objc class func setTutorialWasDisplayedForViewController(_ vc : UIViewController) {
let prefs = UserDefaults.standard
let defaultsKeyName = "Tutorial"
let dictKeyName = String(describing: type(of: vc))
if var onceDict = prefs.dictionary(forKey: defaultsKeyName) {
onceDict[dictKeyName] = true
prefs.set(onceDict, forKey: defaultsKeyName)
} else {
prefs.set([dictKeyName : true], forKey: defaultsKeyName)
}
}
class func resetTutorialWasDisplayed() {
let prefs = UserDefaults.standard
let keyName = "Tutorial"
prefs.removeObject(forKey: keyName)
}
@objc class func animateOnlineIndicatorImageView(_ imageView: UIImageView, online: Bool, flashing: Bool) {
DispatchQueue.main.async(execute: {
imageView.image = UIImage(named: "imgCircle")
//
imageView.image = imageView.image!.withRenderingMode(UIImageRenderingMode.alwaysTemplate)
if flashing {
imageView.tintColor = UIColor(red: 239.0/255.0, green: 13.0/255.0, blue: 209.0/255.0, alpha: 1.0) // Flashing purple
imageView.alpha = 1
UIView.animate(withDuration: 0.12, delay: 0, options: [.autoreverse, .repeat], animations: {
imageView.alpha = 0
}, completion: nil)
} else if online {
imageView.tintColor = UIColor(red: 0, green: 173.0/255.0, blue: 239.0/255.0, alpha: 1.0) // ParticleCyan
if imageView.alpha == 1 {
// print ("1-->0")
UIView.animate(withDuration: 2.5, delay: 0, options: [.autoreverse, .repeat], animations: {
imageView.alpha = 0.15
}, completion: nil)
} else {
// print ("0-->1")
imageView.alpha = 0.15
UIView.animate(withDuration: 2.5, delay: 0, options: [.autoreverse, .repeat], animations: {
imageView.alpha = 1
}, completion: nil)
}
} else {
imageView.tintColor = UIColor(white: 0.466, alpha: 1.0) // ParticleGray
imageView.alpha = 1
imageView.layer.removeAllAnimations()
}
})
}
}
|
[
-1
] |
56f91b4d09bc3a2fcfd610341b0fdb0891f289e1
|
0fe295d82daee39c95812471983c55675270fab5
|
/NSMainMenu/NSMainMenu/AppDelegate.swift
|
41f65838fc308a99bfbf9f13cb5a87bc96cd763b
|
[] |
no_license
|
liuaaaddxiaoer/Macos
|
23212e8eb404937c28e3fb4ef45b2fba6e41df46
|
905e4b285fc0e3a2e3b0f90cdaa696068ec29a2e
|
refs/heads/master
| 2021-09-09T15:22:10.827738 | 2018-03-17T11:51:15 | 2018-03-17T11:51:15 | 125,624,018 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 589 |
swift
|
//
// AppDelegate.swift
// NSMainMenu
//
// Created by 刘小二 on 2018/2/13.
// Copyright © 2018年 刘小二. All rights reserved.
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBAction func showFont(_ sender: NSMenuItem) {
print(11111)
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}
|
[
244352,
200577,
171778,
291459,
293764,
293889,
320774,
333829,
183176,
236425,
336649,
402566,
349069,
242939,
116368,
384017,
349588,
295704,
259353,
361500,
339103,
62112,
113953,
237861,
200490,
200746,
333611,
295726,
324654,
358064,
165041,
243768,
38330,
216379,
44610,
229314,
436606,
188997,
349002,
265420,
286412,
193490,
3284,
234965,
327645,
383710,
389981,
144864,
119521,
182625,
302818,
313316,
323173,
327649,
321898,
234731,
287341,
416369,
249844,
288120,
237819,
344700,
313342
] |
b8426916fedfe13afe7d33d57c15b923fa98b6e0
|
0d7db8c3d60e964e74d47f5b60163f3439efa48f
|
/WaterAnimationSample/ViewController.swift
|
3ab58af96acc96c04a2cc53a797a02d89ae71d6c
|
[] |
no_license
|
432daiki/WaterAnimationSample
|
af91288a2931341db766f25ec6957a1eee21e32f
|
3a98006dd7e745b899248f2c44b0e889f44235d2
|
refs/heads/master
| 2020-03-18T23:43:03.428707 | 2018-06-01T07:30:17 | 2018-06-01T07:30:17 | 135,422,293 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,481 |
swift
|
//
// ViewController.swift
// WaterAnimationSample
//
// Created by Daiki Shimizu on 2018/05/29.
// Copyright © 2018年 Daiki Shimizu. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet private weak var parentView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
let maskLayer = CAShapeLayer()
let bottlePath = UIBezierPath()
// left, bottom, right
bottlePath.move(to: CGPoint(x: 0.0, y: 150.0))
bottlePath.addLine(to: CGPoint(x: 0.0, y: parentView.bounds.height - 40.0))
bottlePath.addQuadCurve(to: CGPoint(x: 40.0, y: parentView.bounds.height),
controlPoint: CGPoint(x: 0.0, y: parentView.bounds.height))
bottlePath.addLine(to: CGPoint(x: parentView.bounds.width - 40.0, y: parentView.bounds.height))
bottlePath.addQuadCurve(to: CGPoint(x: parentView.bounds.width, y: parentView.bounds.height - 40.0),
controlPoint: CGPoint(x: parentView.bounds.width, y: parentView.bounds.height))
bottlePath.addLine(to: CGPoint(x: parentView.bounds.width, y: 150.0))
// top
bottlePath.addQuadCurve(to: CGPoint(x: parentView.bounds.width * 0.65, y: 50.0),
controlPoint: CGPoint(x: parentView.bounds.width, y: 100.0))
bottlePath.addLine(to: CGPoint(x: parentView.bounds.width * 0.65, y: 20.0))
bottlePath.addQuadCurve(to: CGPoint(x: parentView.bounds.width * 0.65 - 20.0, y: 0.0),
controlPoint: CGPoint(x: parentView.bounds.width * 0.65, y: 0.0))
bottlePath.addLine(to: CGPoint(x: parentView.bounds.width * 0.35 + 20.0, y: 0.0))
bottlePath.addQuadCurve(to: CGPoint(x: parentView.bounds.width * 0.35, y: 20.0),
controlPoint: CGPoint(x: parentView.bounds.width * 0.35, y: 0.0))
bottlePath.addLine(to: CGPoint(x: parentView.bounds.width * 0.35, y: 50.0))
bottlePath.addQuadCurve(to: CGPoint(x: 0.0, y: 150.0),
controlPoint: CGPoint(x: 0.0, y: 100.0))
maskLayer.path = bottlePath.cgPath
let animationLayer = ArcLayer()
animationLayer.frame = parentView.bounds
animationLayer.mask = maskLayer
parentView.layer.addSublayer(animationLayer)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
animationLayer.animate()
}
}
}
|
[
-1
] |
35620357b439efc8e511842c7605695a16236b3d
|
1a42eeec972e79598a8146df8c8d9146938a1609
|
/MatchHeightOfPciture_Swift/Tool/NetWorkTool/JGRequestPath.swift
|
4bfcd2bccd44ba4e1cf85abd846fad59c21012d8
|
[] |
no_license
|
pengjinguang521/testCodable
|
2a974c95289d226180c6bd4167b47ad683e2d7a9
|
78d6f68536454a9580936d9580e2bf35226bb807
|
refs/heads/master
| 2020-04-07T08:10:03.488372 | 2018-11-19T10:32:06 | 2018-11-19T10:32:06 | 158,202,790 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 260 |
swift
|
//
// JGRequestPath.swift
// MatchHeightOfPciture_Swift
//
// Created by JGPeng on 2018/11/19.
// Copyright © 2018年 彭金光. All rights reserved.
//
import UIKit
let JGLoginUrl = "http://1.movie.applinzi.com/home/index/userLogin" /// JGWallModel
|
[
-1
] |
8c79e684ca79308f73e5c342892314243b838735
|
6fddf88546edacb9fed218d10f1bf9263d2a781f
|
/XCTestExample/XCTestExampleTests/CoreDataTestClass.swift
|
fb5f34c3ec6a534a247eb075161580cccfe7e7e0
|
[] |
no_license
|
walterobvio/Blog-Examples
|
30d899ebaad7c2eb9fc1fb9ecf1a9ebfe7c2dbfd
|
052d717230ceefca5627c582b5702c533bc3cc61
|
refs/heads/master
| 2023-03-19T02:12:57.668293 | 2019-06-08T13:51:42 | 2019-06-08T13:51:42 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,500 |
swift
|
//
// CoreDataTestClass.swift
// XCTestExample
//
// Created by Matt Eaton on 10/8/16.
// Copyright © 2016 AgnosticDev. All rights reserved.
//
import XCTest
import CoreData
class CoreDataTestClass: XCTestCase {
// Create a local NSManagedObjectContext
var managedObjectContext: NSManagedObjectContext? = nil
// In iOS 10 and Swift 3 this is all I need to create my core data stack
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "XCTestExample")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
override func tearDown() {
super.tearDown()
managedObjectContext = nil
}
override func setUp() {
super.setUp()
// Set the NSManagedObjectContext with the view Context
managedObjectContext = self.persistentContainer.viewContext
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
|
[
-1
] |
eb3057665a0812fa0301e8562f03e317af3f0bcd
|
97400aa61a9844540ce0d20e51ffe72f142f029c
|
/RunnerApp/Utilities/Constants.swift
|
bcf1f598fb874833d8f9dc2dcd8f3f726d15326c
|
[] |
no_license
|
OleksPol/RunnerApp
|
16781f639be07e650ef4cacc30b1db9a57f845a2
|
431434e0552f96d5eb2f63b73b01056351b25ed6
|
refs/heads/master
| 2020-04-10T12:42:34.288541 | 2018-12-13T15:15:49 | 2018-12-13T15:15:49 | 161,030,238 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 284 |
swift
|
//
// Constants.swift
// RunnerApp
//
// Created by Alexandr on 12/9/18.
// Copyright © 2018 Alexander. All rights reserved.
//
import Foundation
//MARK: - CONSTANTS, GLOBAL_VARIABLES
let REALM_QUEUE = DispatchQueue(label: "realmQueue")
let REALM_RUN_CONFIG = "realmRunConfig"
|
[
-1
] |
216e77f742a9738bc723fbaeb948ef214f864c36
|
d5f9e95d14c91c61d93b83024669ca31713f0d5d
|
/countUITests/countUITests.swift
|
dbe1c360c328a5c138fe99576a90105fc1370ffd
|
[] |
no_license
|
sei1204/count_swift
|
9e070b7b8e785cbeb12948de06677d1836a3a927
|
e47a84cd25a7d4849a03d795659637745d77e54f
|
refs/heads/master
| 2021-01-10T04:58:10.865001 | 2015-11-01T04:51:53 | 2015-11-01T04:51:53 | 45,326,678 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,237 |
swift
|
//
// countUITests.swift
// countUITests
//
// Created by 三城勝美 on 2015/11/01.
// Copyright © 2015年 sei. All rights reserved.
//
import XCTest
class countUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
333827,
243720,
282634,
313356,
155665,
305173,
237599,
241695,
223269,
229414,
292901,
354342,
102441,
315433,
278571,
313388,
325675,
124974,
282671,
102446,
229425,
354346,
243763,
241717,
229431,
180279,
215095,
319543,
213051,
288829,
325695,
288835,
286787,
307269,
237638,
313415,
285360,
239689,
233548,
311373,
315468,
278607,
333902,
311377,
354386,
196687,
329812,
223317,
315477,
354394,
200795,
323678,
315488,
321632,
45154,
315489,
280676,
313446,
227432,
215144,
307306,
233578,
194667,
217194,
288878,
319599,
278637,
278642,
284789,
131190,
284790,
288890,
292987,
215165,
131199,
227459,
194692,
278669,
235661,
241809,
323730,
278676,
311447,
153752,
327834,
284827,
278684,
329884,
299166,
278690,
233635,
215204,
311459,
299176,
284840,
278698,
284843,
184489,
278703,
184498,
278707,
125108,
278713,
223418,
280761,
180409,
295099,
299197,
280767,
258233,
227517,
299202,
139459,
309443,
176325,
131270,
301255,
299208,
227525,
280779,
233678,
227536,
282832,
321744,
301270,
229591,
280792,
301271,
311520,
325857,
334049,
280803,
307431,
182503,
319719,
338151,
295147,
317676,
286957,
125166,
125170,
313595,
125180,
184574,
309504,
125184,
217352,
125192,
125197,
194832,
227601,
325904,
125200,
125204,
278805,
319764,
334104,
315674,
282908,
299294,
125215,
282912,
233761,
278817,
311582,
211239,
282920,
125225,
317738,
311596,
321839,
315698,
98611,
125236,
332084,
282938,
307514,
278843,
168251,
287040,
319812,
311622,
280903,
227655,
319816,
323914,
201037,
282959,
229716,
289109,
168280,
379224,
323934,
391521,
239973,
381286,
285031,
313703,
416103,
280938,
242027,
242028,
321901,
354671,
278895,
287089,
199030,
227702,
315768,
291193,
291194,
223611,
248188,
315769,
313726,
311679,
211327,
291200,
139641,
240003,
158087,
313736,
227721,
242059,
311692,
227730,
285074,
240020,
190870,
315798,
190872,
291225,
317851,
293275,
285083,
242079,
227743,
289185,
285089,
293281,
305572,
283039,
156069,
301482,
311723,
289195,
377265,
338359,
299449,
311739,
319931,
293309,
278974,
311744,
317889,
291266,
278979,
326083,
278988,
289229,
281038,
326093,
278992,
283089,
283088,
281039,
279000,
176602,
242138,
160224,
279009,
291297,
188899,
195044,
369121,
279014,
242150,
319976,
279017,
311787,
281071,
319986,
236020,
279030,
311800,
279033,
317949,
279042,
283138,
233987,
287237,
377352,
322057,
309770,
342537,
279053,
182802,
283154,
303634,
279060,
279061,
303635,
279066,
188954,
322077,
291359,
227881,
293420,
236080,
283185,
279092,
23093,
234037,
244279,
244280,
338491,
234044,
301635,
309831,
55880,
322119,
377419,
303693,
281165,
301647,
281170,
326229,
309847,
189016,
115287,
287319,
332379,
111197,
295518,
287327,
283431,
242274,
244326,
279143,
279150,
281200,
287345,
313970,
287348,
301688,
244345,
189054,
303743,
297600,
287359,
291455,
301702,
164487,
279176,
311944,
334473,
316044,
311948,
184974,
311950,
316048,
311953,
316050,
287379,
326288,
295575,
227991,
289435,
303772,
205469,
221853,
285348,
314020,
279207,
295591,
295598,
279215,
318127,
248494,
299698,
285362,
164532,
166581,
287412,
154295,
293552,
342705,
287418,
314043,
303802,
66243,
291529,
287434,
225996,
363212,
287438,
279249,
303826,
242385,
164561,
279253,
158424,
230105,
299737,
322269,
342757,
295653,
289511,
230120,
330473,
234216,
285419,
330476,
289517,
279278,
312046,
215790,
170735,
125683,
230133,
199415,
234233,
242428,
279293,
289534,
322302,
205566,
299777,
291584,
228099,
285443,
291591,
295688,
322312,
285450,
264971,
312076,
326413,
322320,
285457,
295698,
291605,
166677,
283418,
285467,
326428,
221980,
281378,
234276,
318247,
203560,
279337,
262952,
262953,
318251,
289580,
262957,
164655,
301872,
242481,
303921,
234290,
328495,
285493,
230198,
285496,
301883,
201534,
289599,
281407,
295745,
222017,
342846,
293702,
318279,
283466,
281426,
279379,
295769,
201562,
234330,
244569,
281434,
275294,
301919,
322396,
279393,
293729,
230238,
281444,
230239,
279398,
349025,
303973,
351078,
177002,
308075,
242540,
242542,
310132,
295797,
228214,
207735,
201590,
295799,
177018,
269179,
279418,
308093,
314240,
291713,
158594,
240517,
287623,
228232,
416649,
279434,
320394,
316299,
299912,
234382,
252812,
308111,
308113,
189327,
293780,
310166,
289691,
209820,
277404,
240543,
283551,
310177,
289699,
189349,
293673,
289704,
293801,
279465,
326571,
177074,
304050,
326580,
289720,
326586,
289723,
189373,
213956,
281541,
19398,
345030,
213961,
279499,
56270,
191445,
304086,
183254,
183258,
234469,
314343,
304104,
324587,
320492,
234476,
183276,
320495,
203758,
289773,
287730,
277493,
240631,
320504,
214009,
312313,
312317,
328701,
328705,
234499,
293894,
320520,
322571,
230411,
320526,
330766,
234513,
238611,
140311,
293911,
238617,
197658,
316441,
132140,
113710,
189487,
281647,
322609,
285152,
312372,
203829,
238646,
300087,
238650,
320571,
21567,
308288,
160834,
336962,
314437,
349254,
238663,
300109,
234578,
207954,
296023,
205911,
314458,
156763,
277600,
281698,
281699,
285795,
214116,
230500,
322664,
228457,
318571,
279659,
234606,
300145,
238706,
230514,
187508,
312435,
279666,
300147,
302202,
285819,
314493,
285823,
150656,
234626,
279686,
222344,
285833,
285834,
234635,
228492,
337037,
318602,
177297,
162962,
187539,
326803,
308375,
324761,
285850,
296091,
119965,
234655,
300192,
302239,
339106,
306339,
330912,
234662,
300200,
302251,
208044,
238764,
322733,
249003,
3243,
279729,
294069,
300215,
294075,
64699,
228541,
283841,
148674,
283846,
312519,
279752,
283849,
148687,
290001,
189651,
316628,
279766,
189656,
279775,
304352,
298209,
304353,
310496,
279780,
228587,
279789,
290030,
302319,
251124,
234741,
283894,
316661,
208123,
292092,
279803,
228608,
320769,
234756,
322826,
242955,
312588,
177420,
318732,
126229,
318746,
320795,
245018,
320802,
130342,
304422,
130344,
292145,
298290,
312628,
300342,
159033,
333114,
333115,
286012,
222523,
181568,
279872,
279874,
300355,
294210,
216387,
286019,
193858,
300354,
304457,
230730,
372039,
294220,
296269,
234830,
224591,
238928,
222542,
296274,
314708,
318804,
283990,
314711,
357720,
300378,
300379,
294236,
316764,
314721,
292194,
230757,
281958,
314727,
134504,
306541,
314734,
327023,
234864,
312688,
296304,
316786,
230772,
314740,
314742,
327030,
284015,
314745,
290170,
310650,
224637,
306558,
290176,
306561,
243073,
179586,
314752,
294278,
314759,
296328,
298378,
304523,
368012,
318860,
314765,
296330,
292242,
279955,
306580,
314771,
224662,
234902,
282008,
314776,
112019,
318876,
282013,
290206,
148899,
314788,
298406,
314790,
245160,
333224,
282023,
279979,
279980,
241067,
314797,
286128,
173492,
286133,
279988,
284086,
310714,
302523,
228796,
284090,
54719,
302530,
280003,
228804,
310725,
306630,
292291,
300488,
415170,
306634,
280011,
302539,
300490,
310731,
370122,
339403,
329168,
222674,
327122,
280020,
329170,
234957,
312785,
310735,
280025,
310747,
239069,
144862,
286176,
187877,
310758,
320997,
280042,
280043,
191980,
300526,
329198,
337391,
282097,
296434,
308722,
306678,
40439,
191991,
288248,
286201,
300539,
288252,
312830,
286208,
290304,
245249,
228868,
292359,
218632,
323079,
302602,
230922,
323083,
294413,
304655,
323088,
329231,
282132,
230933,
302613,
282135,
316951,
374297,
302620,
313338,
282147,
222754,
306730,
245291,
312879,
230960,
288305,
239159,
290359,
323132,
235069,
157246,
288319,
288322,
280131,
349764,
310853,
282182,
124486,
288328,
194118,
286281,
292426,
333389,
224848,
224852,
290391,
128600,
235096,
239192,
306777,
196184,
212574,
99937,
204386,
300643,
323171,
300645,
282214,
345697,
312937,
224874,
243306,
204394,
312941,
206447,
310896,
314997,
294517,
290425,
288377,
325246,
333438,
235136,
280193,
282244,
239238,
288391,
282248,
286344,
323208,
179853,
286351,
188049,
229011,
239251,
280217,
323226,
179868,
229021,
302751,
282272,
198304,
282279,
298664,
212649,
298666,
317102,
286387,
300725,
337590,
286392,
300729,
302778,
306875,
280252,
296636,
282302,
280253,
286400,
323265,
323262,
280259,
321220,
282309,
321217,
333508,
239305,
280266,
296649,
306891,
212684,
302798,
9935,
241360,
282321,
313042,
286419,
241366,
280279,
282330,
18139,
294621,
280285,
282336,
321250,
294629,
153318,
333543,
181992,
12009,
337638,
282347,
288492,
282349,
34547,
67316,
323315,
286457,
284410,
200444,
288508,
282366,
286463,
319232,
278273,
288515,
280326,
282375,
323335,
284425,
300810,
282379,
216844,
116491,
284430,
280333,
300812,
161553,
124691,
284436,
278292,
278294,
282390,
118549,
116502,
325403,
321308,
321309,
282399,
241440,
282401,
325411,
315172,
186149,
186148,
241447,
333609,
286507,
294699,
284460,
280367,
300849,
282418,
280373,
282424,
280377,
321338,
319289,
282428,
280381,
345918,
413500,
241471,
280386,
315431,
280391,
153416,
315209,
325449,
159563,
280396,
307024,
317268,
237397,
307030,
18263,
241494,
188250,
284508,
300893,
307038,
237411,
284515,
276326,
282471,
296807,
292713,
282476,
292719,
296815,
313200,
325491,
313204,
333687,
317305,
124795,
317308,
339840,
315265,
280451,
327556,
188293,
243590,
282503,
67464,
243592,
325514,
305032,
315272,
315275,
311183,
184207,
124816,
282517,
294806,
214936,
294808,
337816,
239515,
214943,
298912,
319393,
333727,
294820,
333734,
219046,
284584,
294824,
313257,
298921,
292783,
126896,
200628,
300983,
343993,
288698,
98240,
294849,
214978,
280517,
280518,
214983,
282572,
282573,
153553,
24531,
231382,
329696,
323554,
292835,
6116,
190437,
292838,
294887,
317416,
313322,
278507,
298987,
311277,
296942,
329707,
124912,
327666,
278515,
325620,
239610
] |
0e9c553e8020b935cf15803037d2eb12f40158a8
|
097d1d5c982c54a788d5df39c39c6b23e5f13bf0
|
/ios/Classes/Collectibles/Detail/ViewModels/Media/CollectibleMediaVideoPreviewViewModel.swift
|
71c1164b32e547c518a7dc212a57a03f026e559b
|
[
"Apache-2.0"
] |
permissive
|
perawallet/pera-wallet
|
d12435020ded4705b4a7929ab2611b29dd85810e
|
115f85f2d897817276eca9090933f6b0c020f1ab
|
refs/heads/master
| 2023-08-16T21:27:27.885005 | 2023-08-15T21:38:03 | 2023-08-15T21:38:03 | 364,359,642 | 67 | 26 |
NOASSERTION
| 2023-06-02T16:51:55 | 2021-05-04T19:08:11 |
Swift
|
UTF-8
|
Swift
| false | false | 3,008 |
swift
|
// Copyright 2022 Pera Wallet, LDA
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// CollectibleMediaVideoPreviewViewModel.swift
import Foundation
import UIKit
import MacaroonUIKit
import MacaroonURLImage
struct CollectibleMediaVideoPreviewViewModel: ViewModel {
private(set) var placeholder: ImagePlaceholder?
private(set) var url: URL?
private(set) var overlayImage: UIImage?
private(set) var is3DModeActionHidden: Bool = false
private(set) var isFullScreenActionHidden: Bool = false
init(
asset: CollectibleAsset,
accountCollectibleStatus: AccountCollectibleStatus,
media: Media
) {
bindPlaceholder(asset)
bindURL(media)
bindOverlayImage(asset, accountCollectibleStatus)
bindIs3DActionHidden(asset)
bindIsFullScreenBadgeHidden(asset)
}
}
extension CollectibleMediaVideoPreviewViewModel {
private mutating func bindPlaceholder(
_ asset: CollectibleAsset
) {
let placeholder = asset.title.fallback(asset.name.fallback(asset.id.stringWithHashtag))
self.placeholder = getPlaceholder(placeholder)
}
private mutating func bindURL(
_ media: Media
) {
if media.type != .video {
self.url = nil
return
}
url = media.downloadURL
}
private mutating func bindOverlayImage(
_ asset: CollectibleAsset,
_ accountCollectibleStatus: AccountCollectibleStatus
) {
switch accountCollectibleStatus {
case .notOptedIn,
.optingOut,
.optingIn,
.owned:
overlayImage = nil
case .optedIn:
overlayImage = "overlay-bg".uiImage
}
}
private mutating func bindIs3DActionHidden(
_ asset: CollectibleAsset
) {
is3DModeActionHidden = !asset.mediaType.isSupported
}
private mutating func bindIsFullScreenBadgeHidden(
_ asset: CollectibleAsset
) {
isFullScreenActionHidden = !asset.mediaType.isSupported
}
}
extension CollectibleMediaVideoPreviewViewModel {
private func getPlaceholder(
_ aPlaceholder: String
) -> ImagePlaceholder {
let placeholderText: EditText = .attributedString(
aPlaceholder
.bodyLargeRegular(
alignment: .center
)
)
return ImagePlaceholder(
image: nil,
text: placeholderText
)
}
}
|
[
-1
] |
9021381086b1b6c9446a7dd499f7919258f92421
|
c14f653e49b92f00f6935a95cb1a47554fc09a70
|
/ios-sectionsTests/ios_sectionsTests.swift
|
a3ea7bc431569bff387308c2bf32a9b3a096e549
|
[] |
no_license
|
rebornwhu/ios-sections
|
8b9ea99f208616863c19f9f0b1e546d6c7ad2dcb
|
f07d6a4e95220f81e992d6bb85d1fa1975d6d3aa
|
refs/heads/master
| 2021-01-10T05:04:56.095026 | 2015-10-11T05:54:07 | 2015-10-11T05:54:07 | 44,038,720 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 987 |
swift
|
//
// ios_sectionsTests.swift
// ios-sectionsTests
//
// Created by Xiao Lu on 10/10/15.
// Copyright © 2015 Xiao Lu. All rights reserved.
//
import XCTest
@testable import ios_sections
class ios_sectionsTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}
|
[
98333,
278558,
16419,
229413,
204840,
278570,
360491,
344107,
155694,
253999,
229424,
237620,
229430,
319542,
180280,
286788,
352326,
311372,
196691,
278615,
237663,
278634,
131178,
278638,
319598,
352368,
131189,
131191,
237689,
131198,
278655,
311435,
311438,
278670,
278677,
278685,
311458,
278691,
49316,
196773,
32941,
278704,
278708,
131256,
278714,
295098,
254170,
229597,
311519,
286958,
327929,
278797,
180493,
254226,
278810,
278816,
237857,
262450,
278842,
287041,
287043,
139589,
319813,
311621,
319821,
254286,
344401,
278869,
155990,
106847,
246127,
139640,
246136,
246137,
311681,
377264,
278961,
278965,
278970,
33211,
319930,
336317,
278978,
188871,
278989,
278993,
278999,
328152,
369116,
188894,
287198,
279008,
279013,
279018,
279022,
279029,
279032,
279039,
287241,
279050,
303631,
279057,
303636,
279062,
279065,
180771,
377386,
279094,
352829,
115270,
377418,
287318,
295519,
66150,
279144,
344680,
279146,
295536,
287346,
287352,
279164,
189057,
303746,
311941,
279177,
369289,
344715,
311949,
287374,
352917,
230040,
295576,
271000,
303771,
221852,
279206,
295590,
279210,
287404,
295599,
205487,
303793,
279217,
164533,
287417,
303803,
287422,
66242,
287433,
287439,
279252,
287452,
295652,
279269,
230125,
312047,
279280,
230134,
221948,
279294,
205568,
295682,
336671,
344865,
262951,
279336,
262954,
295724,
353069,
312108,
164656,
303920,
262962,
328499,
353078,
230199,
353079,
336702,
295746,
353094,
353095,
353109,
230234,
295776,
279392,
303972,
230248,
246641,
295798,
246648,
279417,
361337,
254850,
287622,
213894,
295824,
279456,
189348,
279464,
353195,
140204,
353197,
304051,
287677,
189374,
353216,
213960,
279498,
50143,
123881,
304110,
320494,
287731,
295927,
304122,
312314,
320507,
328700,
328706,
320516,
230410,
320527,
418837,
140310,
230423,
197657,
336929,
189474,
345132,
238639,
238651,
230463,
238664,
296019,
353367,
156764,
156765,
304222,
230499,
279660,
156785,
312434,
353397,
279672,
279685,
222343,
296086,
238743,
296092,
238765,
279728,
238769,
230588,
279747,
353479,
353481,
353482,
279760,
189652,
279765,
296153,
279774,
304351,
304356,
279785,
279792,
353523,
279814,
312587,
328971,
173334,
320796,
304421,
279854,
345396,
116026,
222524,
279875,
230729,
222541,
296270,
238927,
296273,
222559,
230756,
230765,
296303,
279920,
312689,
296307,
116084,
181625,
148867,
378244,
296335,
230799,
279974,
173491,
304564,
279989,
296375,
296387,
296391,
296392,
361927,
280010,
370123,
148940,
280013,
312782,
222675,
353750,
239068,
280032,
280041,
296425,
361963,
296433,
321009,
280055,
288249,
296448,
230913,
230921,
296461,
149007,
304656,
329232,
230959,
288309,
288318,
280130,
124485,
288326,
288327,
280147,
239198,
222832,
247416,
288378,
337535,
239237,
288392,
239250,
345752,
255649,
198324,
296628,
321207,
296632,
280251,
280257,
321219,
280267,
280278,
280280,
18138,
67292,
321247,
313065,
288491,
280300,
239341,
419569,
313081,
124669,
288512,
288516,
280327,
280329,
321295,
321302,
116505,
321310,
313120,
247590,
280366,
296755,
280372,
321337,
345919,
280390,
280392,
345929,
304977,
18262,
280410,
370522,
345951,
362337,
345955,
296806,
288619,
288620,
280430,
362352,
313203,
124798,
182144,
305026,
67463,
329622,
124824,
214937,
214938,
239514,
247712,
354212,
124852,
288697,
214977,
280514,
280519,
247757,
231375,
280541,
337895,
247785,
296941,
362480,
313339,
313357,
182296,
305179,
313375,
354343,
354345,
223274,
124975,
346162,
124984,
288833,
288834,
280649,
354385,
223316,
280661,
223318,
329814,
338007,
288857,
354393,
280675,
280677,
313447,
288879,
223350,
280694,
215164,
313469,
215166,
280712,
215178,
141450,
346271,
239793,
125109,
182456,
280762,
223419,
379071,
280768,
338119,
280778,
321745,
280795,
280802,
338150,
125169,
338164,
157944,
125183,
125188,
313608,
125193,
125198,
125203,
125208,
305440,
125217,
125235,
280887,
125240,
280902,
182598,
379225,
272729,
321894,
280939,
313713,
354676,
199029,
280961,
362881,
248194,
395659,
395661,
240016,
190871,
289189,
281037,
281040,
281072,
223767,
289304,
223769,
182817,
289332,
322120,
281166,
281171,
354911,
436832,
191082,
313966,
281199,
330379,
133774,
330387,
330388,
117397,
314009,
289434,
338613,
166582,
289462,
314040,
158394,
199366,
363211,
289502,
363230,
338662,
346858,
289518,
199414,
35583,
363263,
322313,
322319,
166676,
207640,
289576,
289598,
281408,
420677,
281427,
281433,
330609,
174963,
207732,
158593,
240518,
289703,
289727,
363458,
52172,
183248,
338899,
248797,
207838,
314342,
289774,
183279,
314355,
240630,
314362,
322570,
281625,
281626,
175132,
248872,
322612,
207938,
314448,
281697,
314467,
281700,
322663,
207979,
363644,
150657,
248961,
339102,
330913,
306338,
249002,
281771,
208058,
339130,
290000,
363744,
298212,
290022,
330984,
298221,
298228,
216315,
208124,
363771,
388349,
322824,
126237,
339234,
199971,
298291,
224586,
372043,
314709,
224606,
314720,
142689,
281957,
281962,
306542,
314739,
290173,
306559,
224640,
298374,
314758,
281992,
142729,
314760,
388487,
314766,
306579,
282007,
290207,
314783,
314789,
282022,
282024,
241066,
380357,
306631,
306639,
191981,
306673,
306677,
290300,
290301,
282114,
306692,
306693,
323080,
192010,
323087,
282129,
282136,
282141,
282146,
306723,
290358,
282183,
290390,
306776,
282213,
323178,
314998,
175741,
192131,
282245,
282246,
224901,
290443,
323217,
282259,
282271,
282273,
282276,
298661,
323236,
290471,
282280,
298667,
306874,
282303,
282312,
306890,
241361,
282327,
298712,
216795,
282339,
12010,
282348,
282355,
323316,
282358,
175873,
323331,
323332,
216839,
282378,
249626,
282400,
241441,
339745,
315171,
257830,
159533,
282417,
200498,
282427,
282434,
315202,
307011,
282438,
307025,
413521,
216918,
307031,
282474,
282480,
241528,
282504,
110480,
184208,
282518,
282519,
44952,
298909,
118685,
298920,
282549,
290746,
298980,
282612,
282633,
241692,
307231,
102437,
233517,
282672,
159807,
315476,
307289,
200794,
315487,
45153,
315498,
299121,
233589,
233590,
241808,
323729,
233636,
299174,
233642,
299187,
184505,
299198,
299203,
282831,
356576,
176362,
233715,
184570,
168188,
184575,
282909,
299293,
282913,
233762,
217380,
282919,
151847,
332085,
332089,
315706,
282939,
307517,
241986,
332101,
323916,
348492,
250192,
323920,
348500,
168281,
323935,
242029,
242033,
291192,
225670,
291224,
283038,
61857,
61859,
340398,
299441,
61873,
283064,
61880,
127427,
127428,
291267,
283075,
324039,
176601,
242139,
160225,
242148,
291311,
233978,
291333,
340490,
283153,
291358,
283182,
283184,
234036,
315960,
70209,
348742,
348749,
111208,
291454,
184962,
348806,
152203,
184973,
299699,
299700,
225995,
225997,
226004,
226007,
226019,
234217,
299770,
234234,
299776,
242433,
234241,
209670,
226058,
234250,
234253,
291604,
234263,
283419,
234268,
234277,
283430,
234283,
152365,
234286,
234289,
242485,
234294,
234301,
160575,
234311,
234312,
299849,
283467,
234317,
201551,
234323,
234326,
234331,
349026,
234340,
234343,
275303,
177001,
234346,
308076,
242541,
234355,
209783,
234360,
209785,
234361,
177019,
308092,
234366,
234367,
291712,
234372,
226181,
226184,
308107,
308112,
234386,
234387,
234392,
209817,
324506,
324507,
234400,
234404,
324517,
283558,
234409,
275371,
234419,
234425,
234427,
234430,
349121,
234436,
234438,
316364,
234444,
234445,
234451,
234454,
234457,
340955,
234463,
340961,
234466,
234472,
234473,
324586,
234477,
340974,
234482,
316405,
201720,
234498,
234500,
234506,
324625,
234514,
316437,
201755,
234531,
300068,
234534,
357414,
234542,
300084,
234548,
324666,
234555,
308287,
234560,
21569,
234565,
234569,
300111,
234577,
341073,
234583,
234584,
234587,
250981,
300135,
300136,
316520,
275565,
316526,
357486,
144496,
234609,
275571,
300151,
234616,
398457,
160891,
341115,
300158,
234622,
234625,
349316,
349318,
275591,
234632,
234638,
169104,
177296,
234642,
308372,
185493,
119962,
119963,
283802,
300187,
300188,
234656,
234659,
234663,
275625,
300202,
300201,
226481,
283840,
259268,
283847,
62665,
283852,
283853,
357595,
234733,
234742,
292091,
316669,
242954,
292107,
251153,
226608,
300343,
226624,
193859,
300359,
226632,
234827,
177484,
251213,
234831,
120148,
357719,
283991,
218462,
292195,
333160,
284014,
243056,
112017,
112018,
234898,
357786,
333220,
316842,
210358,
284089,
292283,
415171,
292292,
300487,
300489,
284116,
366037,
210390,
210391,
210393,
226781,
144867,
316902,
54765,
251378,
308723,
300535,
300536,
300542,
210433,
366083,
316946,
308756,
398869,
308764,
349726,
349741,
169518,
194110,
235070,
349763,
218696,
276040,
366154,
292425,
243274,
276045,
128587,
333388,
333393,
300630,
128599,
235095,
243292,
300644,
374372,
317032,
54893,
276085,
366203,
276120,
276126,
300714,
218819,
276173,
333517,
333520,
333521,
333523,
276195,
153319,
284401,
276210,
300794,
276219,
325371,
194303,
194304,
300811,
284429,
276238,
284431,
366360,
284442,
325404,
276253,
325410,
341796,
284459,
317232,
276282,
276283,
276287,
325439,
276294,
276298,
341836,
325457,
284507,
300894,
284512,
284514,
276327,
292712,
325484,
292720,
325492,
300918,
276344,
194429,
325503,
333701,
243591,
243597,
325518,
300963,
292771,
333735,
284587,
292782,
243637,
276408,
276421,
284619,
276430,
301008,
153554,
194515,
276444,
219101,
292836,
292837,
276454,
276459,
325619,
333817,
292858,
292902,
227370,
309295,
276534,
243767,
358456,
227417,
194656,
309345,
227428,
276582,
276589,
227439,
284788,
333940,
292992,
194691,
227460,
333955,
235662,
325776,
276627,
317587,
276632,
284825,
284826,
333991,
333992,
284841,
284842,
333996,
153776,
129203,
227513,
301251,
227524,
309444,
276682,
227548,
301279,
211193,
227578,
243962,
309503,
375051,
325905,
325912,
309529,
211235,
211238,
260418,
227654,
227658,
276813,
6481,
6482,
366929,
366930,
6489,
391520,
276835,
416104,
276847,
285040,
227725,
178578,
293274,
285084,
317852,
285090,
375207,
293303,
276920,
293306,
276925,
293310,
317901,
326100,
285150,
227809,
358882,
342498,
227813,
195045,
309744,
276998,
342536,
186893,
342553,
375333,
293419,
244269,
236081,
23092,
277048,
309830,
301638,
293448,
55881,
309846,
244310,
277094,
277101,
277111,
301689,
277133,
227990,
342682,
285353,
285361,
342706,
293556,
342713,
285371,
285372,
285373,
285374,
154316,
203477,
96984,
318173,
285415,
342762,
277227,
293612,
154359,
228088,
162561,
285444,
285466,
326429,
293664,
326433,
318250,
318252,
301871,
285487,
285497,
293693,
162621,
162626,
277316,
318278,
277325,
293711,
301918,
293730,
351077,
342887,
400239,
310131,
277366,
228215,
269178,
277370,
359298,
277381,
113542,
228233,
228234,
56208,
293781,
277403,
318364,
310176,
310178,
310182,
293800,
236461,
293806,
130016,
64485,
277479,
326635,
203757,
277492,
277509,
277510,
146448,
277523,
277524,
293910,
310317,
252980,
359478,
277563,
302139,
359495,
277597,
302177,
228458,
15471,
187506,
285814,
285820,
187521,
285828,
302213,
285830,
253063,
302216,
228491,
228493,
285838,
162961,
326804,
187544,
285851,
302240,
343203,
253099,
367799,
294074,
277690,
64700,
228540,
228542,
302274,
343234,
367810,
244940,
228563,
310497,
195811,
228588,
253167,
302325,
204022,
228600,
228609,
245019,
277792,
130338,
130343,
277800,
113966,
351537,
286013,
286018,
113987,
15686,
294218,
318805,
294243,
163175,
327025,
327031,
294275,
368011,
318875,
310692,
310701,
286129,
228795,
302529,
302531,
163268,
163269,
310732,
302540,
64975,
310736,
327121,
212442,
228827,
286172,
310757,
187878,
343542,
343543,
286202,
286205,
302590,
294400,
228867,
253452,
65041,
146964,
204313,
302623,
286244,
245287,
278060,
245292,
286254,
56902,
228943,
286288,
196187,
147036,
343647,
286306,
138863,
188031,
294529,
286343,
229001,
310923,
188048,
229020,
302754,
245412,
40613,
40614,
40615,
229029,
278191,
286388,
286391,
319162,
286399,
302797,
212685,
212688,
245457,
302802,
286423,
278233,
278234,
294622,
278240,
212716,
212717,
229113,
286459,
278272,
319233,
311042,
278291,
278293,
294678,
278299,
286494,
294700,
360252,
188251,
237408,
253829,
40853,
294809,
294814,
311199,
319392,
294823,
294843,
98239,
294850,
163781,
344013,
212946,
24532,
294886,
253929,
327661,
278512,
311282
] |
7aaced828f826cb47ff8e842ebceb4931446cc9a
|
ce7327fb76036a1b9b940da144ab9ff89f076a62
|
/ReforzaTecv1/Otros/Utils.swift
|
9a9445f1f4d4cad2fbaa76d98cae1b45d07db2b2
|
[] |
no_license
|
bolderoctopus/reforzatecv1ios
|
2a216e0fa567dd418c91d4ec1340c4e959febe67
|
dea01a1299ddf7ae2cce2719562cfee6dec52844
|
refs/heads/master
| 2021-09-08T06:28:11.219761 | 2018-03-07T22:05:09 | 2018-03-07T22:05:09 | 104,620,938 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,311 |
swift
|
//
// Libreria.swift
// ReforzaTecv1
//
// Created by Omar Rico on 7/17/17.
// Copyright © 2017 TecUruapan. All rights reserved.
//
import Foundation
import UIKit
class Utils : NSObject {
/**
Regresa un color de acuerdo al Hash de una String.
*/
static func colorHash(_ string :String ) -> UIColor {
var hash : UInt64 = strHash(string)
hash = hash>>40
let hash2: Int = Int(hash&0b000000000000000011111111)
var hash3: Int = Int(hash&0b000000001111111100000000)
hash3 = hash3 >> 8
var hash4: Int = Int(hash&0b111111110000000000000000)
hash4 = hash4 >> 16
return UIColor(red:CGFloat(Float(hash2)/255) , green: CGFloat(Float(hash3)/255), blue: CGFloat(Float(hash4)/255), alpha: 0.8)
}
/**
Utilizado para reemplazar al hash con el que cuentan los String debido a que ese puede cambiar de un ejecución a otra, mientras que este
debería devolver el mismo resultado según la cadena dada ya sea en simulador o en diferentes dispositivos.
*/
static func strHash(_ str: String) -> UInt64 {
var result = UInt64(1234567809)
let buf = [UInt8](str.utf8)
for b in buf {
result = 127 * (result & 0x00ffffffffffffff) + UInt64(b)
}
return result
}
}
|
[
-1
] |
dd154b6282c5739f73714ac37eb53df5d7b839e7
|
5abc575ca137d1c3c3793a1010030814c3b3c29f
|
/BakPak/LoginVC.swift
|
d37c0eebf6b2507e5c6db68b44c8abe1783d51fe
|
[] |
no_license
|
gshaw1997/BakPak
|
b2e847facc6b4c9f69fde8e3e036b473d8676153
|
57d168ff081301756c0396fbcabf620793b6c74b
|
refs/heads/master
| 2021-01-23T03:44:00.512110 | 2017-03-25T17:31:26 | 2017-03-25T17:31:26 | 86,118,590 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,767 |
swift
|
//
// LoginVC.swift
// BakPak
//
// Created by User on 3/24/17.
// Copyright © 2017 BakPak Edu. All rights reserved.
//
import UIKit
import Firebase
import FBSDKCoreKit
import FBSDKLoginKit
class LoginVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func facebookPressed(_ sender: Any) {
let facebookLogin = FBSDKLoginManager()
facebookLogin.logIn(withReadPermissions: ["email"], from: self){(result,error) in
if error != nil {
print("FB:Error - \(error)")
}else if result?.isCancelled == true {
print("FB: Users has cancelled")
}else{
print("FB: Success")
let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
self.firbaseAuth(credential)
}
}
}
// @IBAction func signInPressed(_ sender: Any) {
// }
func firbaseAuth(_ credential: FIRAuthCredential){
FIRAuth.auth()?.signIn(with: credential, completion:{ (user, error) in
if error != nil{
print("FIR: Unable to auth - \(error)")
}else{
print("FIR: Success auth")
self.performSegue(withIdentifier: "FBToSetup", sender: nil)
}
})
}
@IBAction func twitterPressed(_ sender: Any) {
}
}
|
[
-1
] |
451b2bfd2882923e58f912ff30c11371ba78370b
|
feca6b86f9e7f453d6c2c77bdd5e6f633cfcda70
|
/Dependencies/CocoaCore/CocoaCoreTests/CocoaCoreTests.swift
|
7341d1edb667611c0e5e5f983bbb2326fe83db8e
|
[
"MIT"
] |
permissive
|
manish-practo/Chitrahar
|
14b2a04f3d086febcc32eacc2655f49d26982838
|
0183c31af286d079a41a5756e987d83bdc5aa719
|
refs/heads/main
| 2023-05-08T19:13:21.416852 | 2021-06-01T02:43:52 | 2021-06-01T02:43:52 | 331,352,379 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 903 |
swift
|
//
// CocoaCoreTests.swift
// CocoaCoreTests
//
// Created by Manish Pandey on 29/05/21.
//
import XCTest
@testable import CocoaCore
class CocoaCoreTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
|
[
333828,
346118,
43014,
358410,
354316,
313357,
360462,
399373,
182296,
317467,
145435,
16419,
223268,
229413,
204840,
315432,
325674,
344107,
102445,
155694,
176175,
253999,
233517,
346162,
129076,
241716,
229430,
243767,
163896,
180280,
358456,
352315,
288828,
436285,
376894,
288833,
288834,
436292,
403525,
352326,
225351,
315465,
436301,
338001,
196691,
338003,
280661,
329814,
307289,
385116,
356447,
254048,
237663,
315487,
280675,
280677,
43110,
319591,
321637,
436329,
221290,
438377,
194666,
260207,
432240,
352368,
204916,
233589,
266357,
131191,
215164,
215166,
422019,
280712,
415881,
104587,
235662,
241808,
381073,
196760,
284826,
426138,
346271,
436383,
362659,
49316,
258214,
299174,
333991,
333992,
239793,
377009,
405687,
182456,
295098,
379071,
258239,
389313,
299203,
149703,
299209,
346314,
372941,
266449,
321745,
139479,
254170,
229597,
194782,
301279,
311519,
317664,
280802,
379106,
387296,
346346,
205035,
307435,
321772,
438511,
381172,
436470,
327929,
243962,
344313,
184575,
149760,
375039,
411906,
147717,
368905,
375051,
180493,
325905,
254226,
272658,
272660,
368916,
262421,
325912,
381208,
377114,
151839,
237856,
237857,
233762,
211235,
217380,
432421,
211238,
338218,
254251,
251213,
311597,
358703,
321840,
98610,
332083,
379186,
332085,
358709,
180535,
336183,
332089,
321860,
332101,
438596,
323913,
348492,
383311,
250192,
344401,
323920,
366930,
348500,
377169,
368981,
155990,
289110,
272729,
368984,
168281,
215385,
332123,
332127,
98657,
383332,
242023,
383336,
270701,
160110,
242033,
270706,
354676,
354677,
139640,
291192,
106874,
211326,
436608,
362881,
240002,
436611,
340357,
225670,
311685,
106888,
317831,
242058,
385417,
373134,
385422,
108944,
252308,
190871,
213403,
149916,
39324,
121245,
242078,
420253,
141728,
315810,
315811,
381347,
289189,
108972,
272813,
340398,
385454,
377264,
342450,
338356,
436661,
293303,
311738,
33211,
293310,
336320,
311745,
342466,
127427,
416197,
254406,
188871,
324039,
129483,
342476,
373197,
289232,
328152,
256477,
287198,
160225,
342498,
358882,
334309,
340453,
391655,
432618,
375276,
319981,
291311,
254456,
377338,
377343,
254465,
174593,
291333,
348682,
340490,
139792,
420369,
303636,
258581,
393751,
254488,
416286,
377376,
207393,
375333,
358954,
377386,
244269,
197167,
375343,
385588,
289332,
234036,
375351,
174648,
338489,
338490,
244281,
348732,
315960,
242237,
352829,
70209,
115270,
70215,
293448,
55881,
301638,
309830,
348742,
348749,
381517,
385615,
426576,
340558,
369235,
416341,
297560,
332378,
201308,
354911,
416351,
139872,
436832,
436834,
268899,
111208,
39530,
184940,
373358,
420463,
346737,
389745,
313971,
346740,
139892,
420471,
344696,
287352,
209530,
244347,
356989,
373375,
152195,
311941,
348806,
336518,
369289,
311945,
330379,
344715,
311949,
287374,
326287,
375440,
316049,
311954,
334481,
117396,
352917,
111253,
316053,
346772,
230040,
342682,
363163,
264856,
111258,
111259,
271000,
289434,
303771,
205471,
318106,
318107,
139939,
344738,
176808,
205487,
303793,
318130,
299699,
293556,
336564,
383667,
314040,
287417,
342713,
39614,
287422,
377539,
422596,
422599,
291530,
225995,
363211,
164560,
242386,
385747,
361176,
418520,
422617,
287452,
363230,
264928,
422626,
375526,
422631,
234217,
346858,
330474,
342762,
293612,
342763,
289518,
299759,
369385,
377489,
312052,
154359,
348920,
172792,
344827,
344828,
221948,
432893,
363263,
35583,
205568,
162561,
291585,
295682,
430849,
291592,
197386,
383754,
62220,
117517,
434957,
322319,
422673,
377497,
430865,
166676,
291604,
310036,
197399,
207640,
422680,
426774,
426775,
326429,
293664,
344865,
377500,
326433,
342820,
197411,
400166,
289576,
293672,
189228,
295724,
152365,
197422,
353070,
164656,
295729,
422703,
191283,
422709,
353078,
152374,
197431,
273207,
355130,
375609,
160571,
336702,
289598,
160575,
355137,
430910,
355139,
160580,
252741,
420677,
381773,
201551,
293711,
353109,
377686,
244568,
230234,
189275,
244570,
435039,
295776,
127841,
357218,
242529,
349026,
303972,
385893,
342887,
360417,
355178,
308076,
242541,
207727,
207729,
330609,
246643,
207732,
295798,
361337,
177019,
185211,
308092,
398206,
400252,
291712,
158593,
254850,
359298,
260996,
359299,
113542,
369538,
381829,
316298,
392074,
349067,
295824,
224145,
349072,
355217,
256922,
289690,
318364,
390045,
310176,
185250,
310178,
420773,
185254,
289703,
293800,
140204,
236461,
363438,
252847,
347055,
377772,
304051,
326581,
373687,
326587,
230332,
377790,
289727,
273344,
349121,
363458,
330689,
359364,
353215,
379844,
213957,
19399,
326601,
345033,
373706,
316364,
359381,
386006,
418776,
359387,
433115,
343005,
248796,
347103,
50143,
340955,
130016,
64485,
123881,
326635,
359406,
187374,
383983,
347123,
240630,
349175,
201720,
271350,
127992,
295927,
328700,
318461,
293886,
257024,
328706,
330754,
320516,
293893,
295942,
357379,
386056,
410627,
353290,
254987,
330763,
377869,
433165,
146448,
384016,
238610,
308243,
418837,
140310,
433174,
201755,
252958,
369701,
357414,
248872,
238639,
357423,
252980,
300084,
359478,
312373,
203830,
238651,
308287,
336960,
248901,
257094,
359495,
377926,
218186,
250954,
250956,
314448,
341073,
339030,
439384,
361566,
304222,
392290,
250981,
257125,
253029,
300135,
316520,
273515,
173166,
357486,
351344,
144496,
187506,
404593,
377972,
285814,
291959,
300150,
300151,
363641,
160891,
363644,
341115,
300158,
377983,
392318,
248961,
150657,
384131,
349316,
402565,
349318,
302216,
330888,
386189,
337039,
169104,
373903,
177296,
347283,
326804,
363669,
238743,
119962,
300187,
300188,
339100,
351390,
199839,
380061,
429214,
343203,
265379,
300201,
249002,
253099,
253100,
238765,
3246,
300202,
306346,
238769,
318639,
402613,
367799,
421048,
373945,
113850,
294074,
367810,
302274,
259268,
253125,
265412,
353479,
62665,
402634,
283852,
259280,
290000,
316627,
333011,
189653,
351446,
419029,
148696,
296153,
134366,
359647,
304351,
195808,
298208,
310497,
298212,
298213,
222440,
330984,
328940,
298221,
253167,
298228,
302325,
234742,
386294,
351476,
351478,
128251,
363771,
386301,
261377,
351490,
320770,
386306,
437505,
322824,
369930,
439562,
292107,
328971,
414990,
353551,
251153,
177428,
349462,
257305,
320796,
222494,
253216,
339234,
372009,
412971,
130348,
353584,
351537,
261425,
382258,
345396,
300343,
386359,
116026,
378172,
286013,
306494,
382269,
216386,
312648,
337225,
304456,
230729,
146762,
224586,
177484,
294218,
353616,
259406,
234831,
238927,
294219,
331090,
406861,
318805,
314710,
372054,
159066,
425304,
374109,
314720,
378209,
163175,
333160,
386412,
380271,
327024,
296307,
116084,
208244,
249204,
316787,
382330,
290173,
357759,
306559,
337281,
357762,
314751,
378244,
253317,
318848,
148867,
298374,
314758,
314760,
142729,
296329,
368011,
384393,
388487,
314766,
296335,
318864,
112017,
234898,
9619,
259475,
275859,
318868,
370071,
357786,
290207,
314783,
251298,
310692,
314789,
333220,
314791,
396711,
245161,
396712,
374191,
286129,
380337,
173491,
286132,
150965,
304564,
353719,
380338,
210358,
228795,
425405,
302531,
163268,
380357,
339398,
361927,
300489,
425418,
306639,
413137,
23092,
210390,
210391,
210393,
353750,
210392,
286172,
144867,
271843,
429542,
361963,
296433,
251378,
308723,
300536,
286202,
359930,
302590,
210433,
366083,
372227,
323080,
329225,
253451,
253452,
296461,
359950,
259599,
304656,
329232,
146964,
398869,
308756,
370197,
175639,
253463,
374296,
388632,
374299,
423453,
349726,
308764,
396827,
134686,
431649,
355876,
286244,
245287,
402985,
394794,
245292,
349741,
347694,
169518,
431663,
288309,
312889,
194110,
425535,
349763,
196164,
265798,
288327,
218696,
292425,
128587,
265804,
333388,
396882,
128599,
179801,
44635,
239198,
343647,
333408,
396895,
99938,
374372,
300644,
323172,
310889,
415338,
243307,
312940,
54893,
204397,
138863,
188016,
222832,
325231,
224883,
120427,
314998,
370296,
366203,
323196,
325245,
337534,
337535,
339584,
339585,
263809,
294529,
194180,
224901,
288392,
229001,
415375,
188048,
239250,
419478,
345752,
425626,
255649,
302754,
153251,
298661,
40614,
300714,
210603,
224946,
337591,
384695,
370363,
110268,
415420,
224958,
327358,
333503,
274115,
259781,
306890,
403148,
212685,
333517,
9936,
9937,
241361,
302802,
333520,
272085,
345814,
370388,
384720,
224984,
345821,
321247,
298720,
321249,
325346,
153319,
325352,
345833,
345834,
212716,
212717,
372460,
360177,
67315,
173814,
325371,
288512,
319233,
175873,
339715,
288516,
360195,
339720,
243472,
372496,
323346,
321302,
345879,
366360,
249626,
325404,
286494,
321310,
255776,
339745,
341796,
257830,
421672,
362283,
378668,
399147,
431916,
300848,
339762,
409394,
296755,
259899,
319292,
360252,
325439,
345919,
436031,
403267,
339783,
360264,
345929,
153415,
341836,
415567,
337745,
325457,
255829,
317269,
18262,
216918,
241495,
341847,
362327,
350044,
346779,
128862,
345951,
245599,
362337,
376669,
345955,
425825,
296806,
292712,
425833,
423789,
214895,
362352,
313199,
325492,
276341,
417654,
341879,
241528,
317304,
333688,
112509,
55167,
182144,
325503,
305026,
339841,
188292,
253829,
333701,
243591,
315273,
315274,
325518,
372626,
380821,
329622,
294807,
337815,
333722,
376732,
118685,
298909,
311199,
319392,
350109,
253856,
292771,
436131,
354212,
294823,
415655,
436137,
327596,
362417,
323507,
243637,
290745,
294843,
188348,
362431,
237504,
294850,
274371,
384964,
214984,
151497,
362443,
344013,
212942,
301008,
212946,
153554,
24532,
346067,
212951,
354269,
372701,
329695,
354272,
436191,
354274,
219101,
292836,
292837,
298980,
337895,
354280,
253929,
313319,
317415,
380908,
436205,
247791,
362480,
311281,
311282,
325619,
432116,
292858,
415741
] |
690f698ec43ac8bdc78edbfedd224ec58f68e649
|
5e49c03a59dad865dcd42d786b8696d7bf899d84
|
/Examples/Swift/AdMobBannerAdapterExample/AdMobBannerAdapterExample/ViewController.swift
|
6c9cee76a546ee7c219dabf87bd2ed70541fe847
|
[] |
no_license
|
NSFuntik/yandex-ads-sdk-ios
|
a92bb315552fa1fc1cea47768bc6f3870e81a0ef
|
4a027e49149e88782e46247c016101a4e05e7300
|
refs/heads/master
| 2023-04-05T16:50:07.606391 | 2021-04-16T08:58:40 | 2021-04-16T08:58:40 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,783 |
swift
|
/*
* Version for iOS © 2015–2021 YANDEX
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://yandex.com/legal/mobileads_sdk_agreement/
*/
import GoogleMobileAds
class ViewController: UIViewController {
private var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Replace ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY with Ad Unit ID generated at https://apps.admob.com".
bannerView = GADBannerView(adSize: kGADAdSizeBanner)
bannerView.adUnitID = "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY"
bannerView.delegate = self
bannerView.rootViewController = self
bannerView.translatesAutoresizingMaskIntoConstraints = false
}
func addBannerView(banner: GADBannerView) {
banner.removeFromSuperview()
view.addSubview(banner)
var layoutGuide = self.view.layoutMarginsGuide
if #available(iOS 11.0, *) {
layoutGuide = self.view.safeAreaLayoutGuide
}
let constraints = [
banner.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor),
banner.centerXAnchor.constraint(equalTo: layoutGuide.centerXAnchor),
]
NSLayoutConstraint.activate(constraints)
}
@IBAction func loadAd(_ sender: UIButton) {
bannerView.load(GADRequest())
}
}
extension ViewController: GADBannerViewDelegate {
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
addBannerView(banner: bannerView)
print("Ad view did receive ad")
}
func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
print("Ad view did fail to receive ad with error: \(error)")
}
}
|
[
-1
] |
9f821cff8d5166bc2213c010b480cd0257a76b9d
|
568ad0160fe4f8391ecf57f8e092d90987aaede0
|
/ToDoList/ToDoListViewController.swift
|
8fe49db44b8d02851cd12e25f7bf534a3238d8a2
|
[] |
no_license
|
superrichkingstar/ToDoList
|
c160ca0ff8a691b176e3135ce055e22d224969b8
|
01846ec0fc2be5b6537a05649dabe8cf78c62af6
|
refs/heads/master
| 2020-03-28T18:15:43.877265 | 2018-09-15T03:31:45 | 2018-09-15T03:31:45 | 148,866,090 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 376 |
swift
|
//
// ViewController.swift
// ToDoList
//
// Created by student on 2018/9/15.
// Copyright © 2018年 SuperRichKingStar. All rights reserved.
//
import UIKit
class ToDoListViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
|
[
311645,
277367
] |
55a7edbbe51633bbcc38c4634755d8d3b43dcba3
|
3180d8c09da2302b86deca2286df35fbbaa2bd83
|
/Sources/XMLParsing/Encoder/XMLEncoder.swift
|
f77cef73fd0bf915983e8e7310a377dfe4e6c100
|
[
"MIT"
] |
permissive
|
MaxDesiatov/XMLParsing
|
1d7af49cc90154675b68d9f55f9e48c498a15b7f
|
fe315cfa68c3ad471aa5adae466cf0e4a229af88
|
refs/heads/master
| 2020-04-03T02:40:28.152647 | 2019-01-02T12:45:51 | 2019-01-02T12:45:51 | 154,962,919 | 1 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 48,416 |
swift
|
//
// XMLEncoder.swift
// XMLParsing
//
// Created by Shawn Moore on 11/22/17.
// Copyright © 2017 Shawn Moore. All rights reserved.
//
import Foundation
//===----------------------------------------------------------------------===//
// XML Encoder
//===----------------------------------------------------------------------===//
/// `XMLEncoder` facilitates the encoding of `Encodable` values into XML.
open class XMLEncoder {
// MARK: Options
/// The formatting of the output XML data.
public struct OutputFormatting : OptionSet {
/// The format's default value.
public let rawValue: UInt
/// Creates an OutputFormatting value with the given raw value.
public init(rawValue: UInt) {
self.rawValue = rawValue
}
/// Produce human-readable XML with indented output.
public static let prettyPrinted = OutputFormatting(rawValue: 1 << 0)
/// Produce XML with dictionary keys sorted in lexicographic order.
@available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
public static let sortedKeys = OutputFormatting(rawValue: 1 << 1)
}
/// A node's encoding tyoe
public enum NodeEncoding {
case attribute
case element
public static let `default`: NodeEncoding = .element
}
/// The strategy to use for encoding `Date` values.
public enum DateEncodingStrategy {
/// Defer to `Date` for choosing an encoding. This is the default strategy.
case deferredToDate
/// Encode the `Date` as a UNIX timestamp (as a XML number).
case secondsSince1970
/// Encode the `Date` as UNIX millisecond timestamp (as a XML number).
case millisecondsSince1970
/// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
case iso8601
/// Encode the `Date` as a string formatted by the given formatter.
case formatted(DateFormatter)
/// Encode the `Date` as a custom value encoded by the given closure.
///
/// If the closure fails to encode a value into the given encoder, the encoder will encode an empty automatic container in its place.
case custom((Date, Encoder) throws -> Void)
}
/// The strategy to use for encoding `String` values.
public enum StringEncodingStrategy {
/// Defer to `String` for choosing an encoding. This is the default strategy.
case deferredToString
/// Encoded the `String` as a CData-encoded string.
case cdata
}
/// The strategy to use for encoding `Data` values.
public enum DataEncodingStrategy {
/// Defer to `Data` for choosing an encoding.
case deferredToData
/// Encoded the `Data` as a Base64-encoded string. This is the default strategy.
case base64
/// Encode the `Data` as a custom value encoded by the given closure.
///
/// If the closure fails to encode a value into the given encoder, the encoder will encode an empty automatic container in its place.
case custom((Data, Encoder) throws -> Void)
}
/// The strategy to use for non-XML-conforming floating-point values (IEEE 754 infinity and NaN).
public enum NonConformingFloatEncodingStrategy {
/// Throw upon encountering non-conforming values. This is the default strategy.
case `throw`
/// Encode the values using the given representation strings.
case convertToString(positiveInfinity: String, negativeInfinity: String, nan: String)
}
/// The strategy to use for automatically changing the value of keys before encoding.
public enum KeyEncodingStrategy {
/// Use the keys specified by each type. This is the default strategy.
case useDefaultKeys
/// Convert from "camelCaseKeys" to "snake_case_keys" before writing a key to XML payload.
///
/// Capital characters are determined by testing membership in `CharacterSet.uppercaseLetters` and `CharacterSet.lowercaseLetters` (Unicode General Categories Lu and Lt).
/// The conversion to lower case uses `Locale.system`, also known as the ICU "root" locale. This means the result is consistent regardless of the current user's locale and language preferences.
///
/// Converting from camel case to snake case:
/// 1. Splits words at the boundary of lower-case to upper-case
/// 2. Inserts `_` between words
/// 3. Lowercases the entire string
/// 4. Preserves starting and ending `_`.
///
/// For example, `oneTwoThree` becomes `one_two_three`. `_oneTwoThree_` becomes `_one_two_three_`.
///
/// - Note: Using a key encoding strategy has a nominal performance cost, as each string key has to be converted.
case convertToSnakeCase
/// Provide a custom conversion to the key in the encoded XML from the keys specified by the encoded types.
/// The full path to the current encoding position is provided for context (in case you need to locate this key within the payload). The returned key is used in place of the last component in the coding path before encoding.
/// If the result of the conversion is a duplicate key, then only one value will be present in the result.
case custom((_ codingPath: [CodingKey]) -> CodingKey)
internal static func _convertToSnakeCase(_ stringKey: String) -> String {
guard !stringKey.isEmpty else { return stringKey }
var words : [Range<String.Index>] = []
// The general idea of this algorithm is to split words on transition from lower to upper case, then on transition of >1 upper case characters to lowercase
//
// myProperty -> my_property
// myURLProperty -> my_url_property
//
// We assume, per Swift naming conventions, that the first character of the key is lowercase.
var wordStart = stringKey.startIndex
var searchRange = stringKey.index(after: wordStart)..<stringKey.endIndex
// Find next uppercase character
while let upperCaseRange = stringKey.rangeOfCharacter(from: CharacterSet.uppercaseLetters, options: [], range: searchRange) {
let untilUpperCase = wordStart..<upperCaseRange.lowerBound
words.append(untilUpperCase)
// Find next lowercase character
searchRange = upperCaseRange.lowerBound..<searchRange.upperBound
guard let lowerCaseRange = stringKey.rangeOfCharacter(from: CharacterSet.lowercaseLetters, options: [], range: searchRange) else {
// There are no more lower case letters. Just end here.
wordStart = searchRange.lowerBound
break
}
// Is the next lowercase letter more than 1 after the uppercase? If so, we encountered a group of uppercase letters that we should treat as its own word
let nextCharacterAfterCapital = stringKey.index(after: upperCaseRange.lowerBound)
if lowerCaseRange.lowerBound == nextCharacterAfterCapital {
// The next character after capital is a lower case character and therefore not a word boundary.
// Continue searching for the next upper case for the boundary.
wordStart = upperCaseRange.lowerBound
} else {
// There was a range of >1 capital letters. Turn those into a word, stopping at the capital before the lower case character.
let beforeLowerIndex = stringKey.index(before: lowerCaseRange.lowerBound)
words.append(upperCaseRange.lowerBound..<beforeLowerIndex)
// Next word starts at the capital before the lowercase we just found
wordStart = beforeLowerIndex
}
searchRange = lowerCaseRange.upperBound..<searchRange.upperBound
}
words.append(wordStart..<searchRange.upperBound)
let result = words.map({ (range) in
return stringKey[range].lowercased()
}).joined(separator: "_")
return result
}
}
/// Set of strategies to use for encoding of nodes.
public enum NodeEncodingStrategies {
/// Defer to `Encoder` for choosing an encoding. This is the default strategy.
case deferredToEncoder
/// Return a closure computing the desired node encoding for the value by its coding key.
case custom((Encodable.Type, Encoder) -> ((CodingKey) -> XMLEncoder.NodeEncoding))
internal func nodeEncodings(
forType codableType: Encodable.Type,
with encoder: Encoder
) -> ((CodingKey) -> XMLEncoder.NodeEncoding) {
switch self {
case .deferredToEncoder:
return { _ in .default }
case .custom(let closure):
return closure(codableType, encoder)
}
}
}
/// The output format to produce. Defaults to `[]`.
open var outputFormatting: OutputFormatting = []
/// The strategy to use in encoding dates. Defaults to `.deferredToDate`.
open var dateEncodingStrategy: DateEncodingStrategy = .deferredToDate
/// The strategy to use in encoding binary data. Defaults to `.base64`.
open var dataEncodingStrategy: DataEncodingStrategy = .base64
/// The strategy to use in encoding non-conforming numbers. Defaults to `.throw`.
open var nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy = .throw
/// The strategy to use for encoding keys. Defaults to `.useDefaultKeys`.
open var keyEncodingStrategy: KeyEncodingStrategy = .useDefaultKeys
/// The strategy to use in encoding encoding attributes. Defaults to `.deferredToEncoder`.
open var nodeEncodingStrategy: NodeEncodingStrategies = .deferredToEncoder
/// The strategy to use in encoding strings. Defaults to `.deferredToString`.
open var stringEncodingStrategy: StringEncodingStrategy = .deferredToString
/// Contextual user-provided information for use during encoding.
open var userInfo: [CodingUserInfoKey : Any] = [:]
/// Options set on the top-level encoder to pass down the encoding hierarchy.
internal struct _Options {
let dateEncodingStrategy: DateEncodingStrategy
let dataEncodingStrategy: DataEncodingStrategy
let nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy
let keyEncodingStrategy: KeyEncodingStrategy
let nodeEncodingStrategy: NodeEncodingStrategies
let stringEncodingStrategy: StringEncodingStrategy
let userInfo: [CodingUserInfoKey : Any]
}
/// The options set on the top-level encoder.
internal var options: _Options {
return _Options(dateEncodingStrategy: dateEncodingStrategy,
dataEncodingStrategy: dataEncodingStrategy,
nonConformingFloatEncodingStrategy: nonConformingFloatEncodingStrategy,
keyEncodingStrategy: keyEncodingStrategy,
nodeEncodingStrategy: nodeEncodingStrategy,
stringEncodingStrategy: stringEncodingStrategy,
userInfo: userInfo)
}
// MARK: - Constructing a XML Encoder
/// Initializes `self` with default strategies.
public init() {}
// MARK: - Encoding Values
/// Encodes the given top-level value and returns its XML representation.
///
/// - parameter value: The value to encode.
/// - parameter withRootKey: the key used to wrap the encoded values.
/// - returns: A new `Data` value containing the encoded XML data.
/// - throws: `EncodingError.invalidValue` if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is `.throw`.
/// - throws: An error if any value throws an error during encoding.
open func encode<T : Encodable>(_ value: T, withRootKey rootKey: String, header: XMLHeader? = nil) throws -> Data {
let encoder = _XMLEncoder(
options: self.options,
nodeEncodings: []
)
encoder.nodeEncodings.append(self.options.nodeEncodingStrategy.nodeEncodings(forType: T.self, with: encoder))
guard let topLevel = try encoder.box_(value) else {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) did not encode any values."))
}
if topLevel is NSNull {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as null XML fragment."))
} else if topLevel is NSNumber {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as number XML fragment."))
} else if topLevel is NSString {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as string XML fragment."))
}
guard let element = _XMLElement.createRootElement(rootKey: rootKey, object: topLevel) else {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value to XML."))
}
let withCDATA = stringEncodingStrategy != .deferredToString
return element.toXMLString(with: header, withCDATA: withCDATA, formatting: self.outputFormatting).data(using: .utf8, allowLossyConversion: true)!
}
}
internal class _XMLEncoder: Encoder {
// MARK: Properties
/// The encoder's storage.
internal var storage: _XMLEncodingStorage
/// Options set on the top-level encoder.
internal let options: XMLEncoder._Options
/// The path to the current point in encoding.
public var codingPath: [CodingKey]
public var nodeEncodings: [(CodingKey) -> XMLEncoder.NodeEncoding]
/// Contextual user-provided information for use during encoding.
public var userInfo: [CodingUserInfoKey : Any] {
return self.options.userInfo
}
// MARK: - Initialization
/// Initializes `self` with the given top-level encoder options.
internal init(
options: XMLEncoder._Options,
nodeEncodings: [(CodingKey) -> XMLEncoder.NodeEncoding],
codingPath: [CodingKey] = []
) {
self.options = options
self.storage = _XMLEncodingStorage()
self.codingPath = codingPath
self.nodeEncodings = nodeEncodings
}
/// Returns whether a new element can be encoded at this coding path.
///
/// `true` if an element has not yet been encoded at this coding path; `false` otherwise.
internal var canEncodeNewValue: Bool {
// Every time a new value gets encoded, the key it's encoded for is pushed onto the coding path (even if it's a nil key from an unkeyed container).
// At the same time, every time a container is requested, a new value gets pushed onto the storage stack.
// If there are more values on the storage stack than on the coding path, it means the value is requesting more than one container, which violates the precondition.
//
// This means that anytime something that can request a new container goes onto the stack, we MUST push a key onto the coding path.
// Things which will not request containers do not need to have the coding path extended for them (but it doesn't matter if it is, because they will not reach here).
return self.storage.count == self.codingPath.count
}
// MARK: - Encoder Methods
public func container<Key>(keyedBy: Key.Type) -> KeyedEncodingContainer<Key> {
// If an existing keyed container was already requested, return that one.
let topContainer: NSMutableDictionary
if self.canEncodeNewValue {
// We haven't yet pushed a container at this level; do so here.
topContainer = self.storage.pushKeyedContainer()
} else {
guard let container = self.storage.containers.last as? NSMutableDictionary else {
preconditionFailure("Attempt to push new keyed encoding container when already previously encoded at this path.")
}
topContainer = container
}
let container = _XMLKeyedEncodingContainer<Key>(referencing: self, codingPath: self.codingPath, wrapping: topContainer)
return KeyedEncodingContainer(container)
}
public func unkeyedContainer() -> UnkeyedEncodingContainer {
// If an existing unkeyed container was already requested, return that one.
let topContainer: NSMutableArray
if self.canEncodeNewValue {
// We haven't yet pushed a container at this level; do so here.
topContainer = self.storage.pushUnkeyedContainer()
} else {
guard let container = self.storage.containers.last as? NSMutableArray else {
preconditionFailure("Attempt to push new unkeyed encoding container when already previously encoded at this path.")
}
topContainer = container
}
return _XMLUnkeyedEncodingContainer(referencing: self, codingPath: self.codingPath, wrapping: topContainer)
}
public func singleValueContainer() -> SingleValueEncodingContainer {
return self
}
}
// MARK: - Encoding Containers
fileprivate struct _XMLKeyedEncodingContainer<K : CodingKey> : KeyedEncodingContainerProtocol {
typealias Key = K
// MARK: Properties
/// A reference to the encoder we're writing to.
private let encoder: _XMLEncoder
/// A reference to the container we're writing to.
private let container: NSMutableDictionary
/// The path of coding keys taken to get to this point in encoding.
private(set) public var codingPath: [CodingKey]
// MARK: - Initialization
/// Initializes `self` with the given references.
fileprivate init(referencing encoder: _XMLEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) {
self.encoder = encoder
self.codingPath = codingPath
self.container = container
}
// MARK: - Coding Path Operations
private func _converted(_ key: CodingKey) -> CodingKey {
switch encoder.options.keyEncodingStrategy {
case .useDefaultKeys:
return key
case .convertToSnakeCase:
let newKeyString = XMLEncoder.KeyEncodingStrategy._convertToSnakeCase(key.stringValue)
return _XMLKey(stringValue: newKeyString, intValue: key.intValue)
case .custom(let converter):
return converter(codingPath + [key])
}
}
// MARK: - KeyedEncodingContainerProtocol Methods
public mutating func encodeNil(forKey key: Key) throws {
self.container[_converted(key).stringValue] = NSNull()
}
public mutating func encode(_ value: Bool, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Int, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Int8, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Int16, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Int32, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Int64, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: UInt, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: UInt8, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: UInt16, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: UInt32, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: UInt64, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: String, forKey key: Key) throws {
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = self.encoder.box(value)
}
}
public mutating func encode(_ value: Float, forKey key: Key) throws {
// Since the float may be invalid and throw, the coding path needs to contain this key.
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
self.container[_converted(key).stringValue] = try self.encoder.box(value)
}
public mutating func encode(_ value: Double, forKey key: Key) throws {
// Since the double may be invalid and throw, the coding path needs to contain this key.
self.encoder.codingPath.append(key)
defer { self.encoder.codingPath.removeLast() }
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = try self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = try self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = try self.encoder.box(value)
}
}
public mutating func encode<T : Encodable>(_ value: T, forKey key: Key) throws {
guard let strategy = self.encoder.nodeEncodings.last else {
preconditionFailure("Attempt to access node encoding strategy from empty stack.")
}
self.encoder.codingPath.append(key)
let nodeEncodings = self.encoder.options.nodeEncodingStrategy.nodeEncodings(
forType: T.self,
with: self.encoder
)
self.encoder.nodeEncodings.append(nodeEncodings)
defer {
let _ = self.encoder.nodeEncodings.removeLast()
self.encoder.codingPath.removeLast()
}
switch strategy(key) {
case .attribute:
if let attributesContainer = self.container[_XMLElement.attributesKey] as? NSMutableDictionary {
attributesContainer[_converted(key).stringValue] = try self.encoder.box(value)
} else {
let attributesContainer = NSMutableDictionary()
attributesContainer[_converted(key).stringValue] = try self.encoder.box(value)
self.container[_XMLElement.attributesKey] = attributesContainer
}
case .element:
self.container[_converted(key).stringValue] = try self.encoder.box(value)
}
}
public mutating func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type, forKey key: Key) -> KeyedEncodingContainer<NestedKey> {
let dictionary = NSMutableDictionary()
self.container[_converted(key).stringValue] = dictionary
self.codingPath.append(key)
defer { self.codingPath.removeLast() }
let container = _XMLKeyedEncodingContainer<NestedKey>(referencing: self.encoder, codingPath: self.codingPath, wrapping: dictionary)
return KeyedEncodingContainer(container)
}
public mutating func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer {
let array = NSMutableArray()
self.container[_converted(key).stringValue] = array
self.codingPath.append(key)
defer { self.codingPath.removeLast() }
return _XMLUnkeyedEncodingContainer(referencing: self.encoder, codingPath: self.codingPath, wrapping: array)
}
public mutating func superEncoder() -> Encoder {
return _XMLReferencingEncoder(referencing: self.encoder, key: _XMLKey.super, convertedKey: _converted(_XMLKey.super), wrapping: self.container)
}
public mutating func superEncoder(forKey key: Key) -> Encoder {
return _XMLReferencingEncoder(referencing: self.encoder, key: key, convertedKey: _converted(key), wrapping: self.container)
}
}
fileprivate struct _XMLUnkeyedEncodingContainer : UnkeyedEncodingContainer {
// MARK: Properties
/// A reference to the encoder we're writing to.
private let encoder: _XMLEncoder
/// A reference to the container we're writing to.
private let container: NSMutableArray
/// The path of coding keys taken to get to this point in encoding.
private(set) public var codingPath: [CodingKey]
/// The number of elements encoded into the container.
public var count: Int {
return self.container.count
}
// MARK: - Initialization
/// Initializes `self` with the given references.
fileprivate init(referencing encoder: _XMLEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) {
self.encoder = encoder
self.codingPath = codingPath
self.container = container
}
// MARK: - UnkeyedEncodingContainer Methods
public mutating func encodeNil() throws { self.container.add(NSNull()) }
public mutating func encode(_ value: Bool) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Int) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Int8) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Int16) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Int32) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Int64) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: UInt) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: UInt8) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: UInt16) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: UInt32) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: UInt64) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: String) throws { self.container.add(self.encoder.box(value)) }
public mutating func encode(_ value: Float) throws {
// Since the float may be invalid and throw, the coding path needs to contain this key.
self.encoder.codingPath.append(_XMLKey(index: self.count))
defer { self.encoder.codingPath.removeLast() }
self.container.add(try self.encoder.box(value))
}
public mutating func encode(_ value: Double) throws {
// Since the double may be invalid and throw, the coding path needs to contain this key.
self.encoder.codingPath.append(_XMLKey(index: self.count))
defer { self.encoder.codingPath.removeLast() }
self.container.add(try self.encoder.box(value))
}
public mutating func encode<T : Encodable>(_ value: T) throws {
self.encoder.codingPath.append(_XMLKey(index: self.count))
defer { self.encoder.codingPath.removeLast() }
self.container.add(try self.encoder.box(value))
}
public mutating func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type) -> KeyedEncodingContainer<NestedKey> {
self.codingPath.append(_XMLKey(index: self.count))
defer { self.codingPath.removeLast() }
let dictionary = NSMutableDictionary()
self.container.add(dictionary)
let container = _XMLKeyedEncodingContainer<NestedKey>(referencing: self.encoder, codingPath: self.codingPath, wrapping: dictionary)
return KeyedEncodingContainer(container)
}
public mutating func nestedUnkeyedContainer() -> UnkeyedEncodingContainer {
self.codingPath.append(_XMLKey(index: self.count))
defer { self.codingPath.removeLast() }
let array = NSMutableArray()
self.container.add(array)
return _XMLUnkeyedEncodingContainer(referencing: self.encoder, codingPath: self.codingPath, wrapping: array)
}
public mutating func superEncoder() -> Encoder {
return _XMLReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container)
}
}
extension _XMLEncoder: SingleValueEncodingContainer {
// MARK: - SingleValueEncodingContainer Methods
fileprivate func assertCanEncodeNewValue() {
precondition(self.canEncodeNewValue, "Attempt to encode value through single value container when previously value already encoded.")
}
public func encodeNil() throws {
assertCanEncodeNewValue()
self.storage.push(container: NSNull())
}
public func encode(_ value: Bool) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Int) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Int8) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Int16) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Int32) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Int64) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: UInt) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: UInt8) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: UInt16) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: UInt32) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: UInt64) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: String) throws {
assertCanEncodeNewValue()
self.storage.push(container: self.box(value))
}
public func encode(_ value: Float) throws {
assertCanEncodeNewValue()
try self.storage.push(container: self.box(value))
}
public func encode(_ value: Double) throws {
assertCanEncodeNewValue()
try self.storage.push(container: self.box(value))
}
public func encode<T : Encodable>(_ value: T) throws {
assertCanEncodeNewValue()
try self.storage.push(container: self.box(value))
}
}
extension _XMLEncoder {
/// Returns the given value boxed in a container appropriate for pushing onto the container stack.
fileprivate func box(_ value: Bool) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: Int) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: Int8) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: Int16) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: Int32) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: Int64) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: UInt) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: UInt8) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: UInt16) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: UInt32) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: UInt64) -> NSObject { return NSNumber(value: value) }
fileprivate func box(_ value: String) -> NSObject { return NSString(string: value) }
internal func box(_ value: Float) throws -> NSObject {
if value.isInfinite || value.isNaN {
guard case let .convertToString(positiveInfinity: posInfString, negativeInfinity: negInfString, nan: nanString) = self.options.nonConformingFloatEncodingStrategy else {
throw EncodingError._invalidFloatingPointValue(value, at: codingPath)
}
if value == Float.infinity {
return posInfString as NSObject
} else if value == -Float.infinity {
return negInfString as NSObject
} else {
return nanString as NSObject
}
} else {
return NSNumber(value: value)
}
}
internal func box(_ value: Double) throws -> NSObject {
if value.isInfinite || value.isNaN {
guard case let .convertToString(positiveInfinity: posInfString, negativeInfinity: negInfString, nan: nanString) = self.options.nonConformingFloatEncodingStrategy else {
throw EncodingError._invalidFloatingPointValue(value, at: codingPath)
}
if value == Double.infinity {
return posInfString as NSObject
} else if value == -Double.infinity {
return negInfString as NSObject
} else {
return nanString as NSObject
}
} else {
return NSNumber(value: value)
}
}
internal func box(_ value: Date) throws -> NSObject {
switch self.options.dateEncodingStrategy {
case .deferredToDate:
try value.encode(to: self)
return self.storage.popContainer()
case .secondsSince1970:
return NSNumber(value: value.timeIntervalSince1970)
case .millisecondsSince1970:
return NSNumber(value: value.timeIntervalSince1970 * 1000.0)
case .iso8601:
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return _iso8601Formatter.string(from: value) as NSObject
} else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
}
case .formatted(let formatter):
return formatter.string(from: value) as NSObject
case .custom(let closure):
let depth = self.storage.count
try closure(value, self)
guard self.storage.count > depth else { return NSDictionary() }
return self.storage.popContainer()
}
}
internal func box(_ value: Data) throws -> NSObject {
switch self.options.dataEncodingStrategy {
case .deferredToData:
try value.encode(to: self)
return self.storage.popContainer()
case .base64:
return value.base64EncodedString() as NSObject
case .custom(let closure):
let depth = self.storage.count
try closure(value, self)
guard self.storage.count > depth else { return NSDictionary() }
return self.storage.popContainer() as NSObject
}
}
fileprivate func box<T : Encodable>(_ value: T) throws -> NSObject {
return try self.box_(value) ?? NSDictionary()
}
// This method is called "box_" instead of "box" to disambiguate it from the overloads. Because the return type here is different from all of the "box" overloads (and is more general), any "box" calls in here would call back into "box" recursively instead of calling the appropriate overload, which is not what we want.
fileprivate func box_<T : Encodable>(_ value: T) throws -> NSObject? {
if T.self == Date.self || T.self == NSDate.self {
return try self.box((value as! Date))
} else if T.self == Data.self || T.self == NSData.self {
return try self.box((value as! Data))
} else if T.self == URL.self || T.self == NSURL.self {
return self.box((value as! URL).absoluteString)
} else if T.self == Decimal.self || T.self == NSDecimalNumber.self {
return (value as! NSDecimalNumber)
}
let depth = self.storage.count
try value.encode(to: self)
// The top container should be a new container.
guard self.storage.count > depth else {
return nil
}
return self.storage.popContainer()
}
}
|
[
-1
] |
4f36ba293b2284edb63df1d05823a0fd7458f0f0
|
97746063c568ab987fd93f0727e6da11082f3809
|
/i am Poor/ViewController.swift
|
8e43493d13910ca71696c9c104908cc414bfc17f
|
[] |
no_license
|
UncleVuk/i-am-Poor
|
8a3c85343172c29a6ffda4f360b9bfa10478c833
|
d4c0453da9138d80c06930c17e034065adc8cf9f
|
refs/heads/main
| 2023-08-29T05:36:28.646642 | 2021-10-18T20:20:08 | 2021-10-18T20:20:08 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 283 |
swift
|
//
// ViewController.swift
// i am Poor
//
// Created by Yevhenii Vuksta on 18.10.2021.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
|
[
266816,
187937,
265797,
352295,
354729,
11920,
344695,
357209,
420381
] |
e56e02f6c174c17ca58251f748af10235e63d6d0
|
83bfc8e7c496b8f128a956abcf0216c5886c8edc
|
/OAuth2 Tests/OAuth2CodeGrant_tests.swift
|
d95b83bd56f891254bacf2244a8e3354ff63c2b9
|
[
"Apache-2.0"
] |
permissive
|
OmarTawashi/OAuth2
|
61403f7e6346df41833c0f32bb73f0b1bd24ba40
|
ee7c1de6c3cebfa6304e851de8809c879b8df998
|
refs/heads/master
| 2021-01-18T03:15:52.087338 | 2015-06-05T20:59:31 | 2015-06-05T20:59:31 | 36,970,065 | 1 | 0 | null | 2015-06-06T06:32:02 | 2015-06-06T06:32:02 | null |
UTF-8
|
Swift
| false | false | 4,225 |
swift
|
//
// OAuth2CodeGrant.swift
// OAuth2
//
// Created by Pascal Pfiffner on 6/18/14.
// Copyright 2014 Pascal Pfiffner
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import XCTest
import OAuth2
class OAuth2CodeGrantTests: XCTestCase
{
func testInit() {
//var oauth = OAuth2(settings: NSDictionary()) // TODO: how to test that this raises?
let oauth = OAuth2CodeGrant(settings: [
"client_id": "abc",
"client_secret": "xyz",
"verbose": 1,
"authorize_uri": "https://auth.ful.io",
"token_uri": "https://token.ful.io",
])
XCTAssertEqual(oauth.clientId, "abc", "Must init `client_id`")
XCTAssertEqual(oauth.clientSecret!, "xyz", "Must init `client_secret`")
XCTAssertTrue(oauth.verbose, "Set to verbose")
XCTAssertNil(oauth.scope, "Empty scope")
XCTAssertEqual(oauth.authURL, NSURL(string: "https://auth.ful.io")!, "Must init `authorize_uri`")
XCTAssertEqual(oauth.tokenURL!, NSURL(string: "https://token.ful.io")!, "Must init `token_uri`")
}
func testAuthorizeURI() {
let oauth = OAuth2CodeGrant(settings: [
"client_id": "abc",
"client_secret": "xyz",
"authorize_uri": "https://auth.ful.io",
"token_uri": "https://token.ful.io",
])
XCTAssertNotNil(oauth.authURL, "Must init `authorize_uri`")
let comp = NSURLComponents(URL: oauth.authorizeURLWithRedirect("oauth2://callback", scope: nil, params: nil), resolvingAgainstBaseURL: true)!
XCTAssertEqual(comp.host!, "auth.ful.io", "Correct host")
let query = OAuth2CodeGrant.paramsFromQuery(comp.percentEncodedQuery!)
XCTAssertEqual(query["client_id"]!, "abc", "Expecting correct `client_id`")
XCTAssertNil(query["client_secret"], "Must not have `client_secret`")
XCTAssertEqual(query["response_type"]!, "code", "Expecting correct `response_type`")
XCTAssertEqual(query["redirect_uri"]!, "oauth2://callback", "Expecting correct `redirect_uri`")
XCTAssertTrue(8 == count(query["state"]!), "Expecting an auto-generated UUID for `state`")
// TODO: test for non-https URLs (must raise)
}
func testTokenRequest() {
var oauth = OAuth2CodeGrant(settings: [
"client_id": "abc",
"client_secret": "xyz",
"authorize_uri": "https://auth.ful.io",
"token_uri": "https://token.ful.io",
])
oauth.redirect = "oauth2://callback"
let req = oauth.tokenRequestWithCode("pp")
let comp = NSURLComponents(URL: req.URL!, resolvingAgainstBaseURL: true)!
XCTAssertEqual(comp.host!, "token.ful.io", "Correct host")
let body = NSString(data: req.HTTPBody!, encoding: NSUTF8StringEncoding) as? String
let query = OAuth2CodeGrant.paramsFromQuery(body!)
XCTAssertEqual(query["client_id"]!, "abc", "Expecting correct `client_id`")
XCTAssertNil(query["client_secret"], "Must not have `client_secret`")
XCTAssertEqual(query["code"]!, "pp", "Expecting correct `code`")
XCTAssertEqual(query["grant_type"]!, "authorization_code", "Expecting correct `grant_type`")
XCTAssertEqual(query["redirect_uri"]!, "oauth2://callback", "Expecting correct `redirect_uri`")
XCTAssertTrue(8 == count(query["state"]!), "Expecting an auto-generated UUID for `state`")
// test fallback to authURL
oauth = OAuth2CodeGrant(settings: [
"client_id": "abc",
"client_secret": "xyz",
"authorize_uri": "https://auth.ful.io",
])
oauth.redirect = "oauth2://callback"
let req2 = oauth.tokenRequestWithCode("pp")
let comp2 = NSURLComponents(URL: req2.URL!, resolvingAgainstBaseURL: true)!
XCTAssertEqual(comp2.host!, "auth.ful.io", "Correct host")
}
/*func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}*/
}
|
[
-1
] |
8e17b285d1146069637259e41fccb246fce71fd1
|
17f492b5b36aa5ad1be3246cb07ca88a7b8b1602
|
/theParker/Controller/MyBookingsVC.swift
|
c5e69359e4577e644b5477788a7dd0e22700ff27
|
[
"MIT"
] |
permissive
|
ketanchoyal/theParker-iOS
|
c5e3fe006037e1dbdee2d31ece9a0f8a306795cf
|
1c914a3b576961f6725ee60741ab33071dbf9f31
|
refs/heads/Experimental
| 2021-06-15T11:29:47.516753 | 2019-06-22T06:29:58 | 2019-06-22T06:29:58 | 164,677,963 | 27 | 9 |
MIT
| 2021-03-22T21:42:12 | 2019-01-08T15:28:21 |
Swift
|
UTF-8
|
Swift
| false | false | 2,325 |
swift
|
//
// MyBookingsVC.swift
// theParker
//
// Created by Ketan Choyal on 18/03/19.
// Copyright © 2019 Ketan Choyal. All rights reserved.
//
import UIKit
class MyBookingsVC: UIViewController {
@IBOutlet weak var menu: UIBarButtonItem!
@IBOutlet weak var myBookingsTable: UITableView!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.tintColor = UIColor.white
}
override func viewDidLoad() {
super.viewDidLoad()
menu.target = revealViewController()
menu.action = #selector(SWRevealViewController.revealToggle(_:))
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
myBookingsTable.delegate = self
myBookingsTable.dataSource = self
BookingService.instance.getMyBookings { (success) in
self.myBookingsTable.reloadData()
}
}
}
extension MyBookingsVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return BookingService.instance.myBookings.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "myBookingCell") as? MyBookingCell else { return UITableViewCell() }
let bookings = BookingService.instance.myBookings
let key = Array(bookings.keys)[indexPath.row]
let booking = bookings[key]
cell.configureCell(booking!)
return cell
}
}
extension MyBookingsVC {
func alert(message:String )
{
let alertview = UIAlertController(title: "", message: message, preferredStyle: .alert)
alertview.addAction(UIAlertAction(title: "Try Again!", style: .default, handler: {
action in
DispatchQueue.main.async {
// self.UISetup(enable: true)
}
}))
self.present(alertview, animated: true, completion: nil)
}
}
|
[
-1
] |
70522556dddb13f36634f4ecc2f95a47952a3e67
|
07ddb634845184bbce24f69dba4255d0649ec0ed
|
/ClassyDrives/View Controllers/Tab/HomeVC.swift
|
c1d9f2f1a8b73d20ab85ad340c0c42db4c184e2c
|
[] |
no_license
|
mindfulljunkies/Ios
|
e08b408d2c19c8a6381fa4053b7b992d5130ceef
|
a1a9e3854e25064619c3b54d096367a903503e74
|
refs/heads/master
| 2023-04-01T18:27:02.691977 | 2021-04-04T02:57:22 | 2021-04-04T02:57:22 | 294,174,214 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 26,832 |
swift
|
//
// HomeVC.swift
// ClassyDrives
//
// Created by Mindfull Junkies on 08/06/19.
// Copyright © 2019 Mindfull Junkies. All rights reserved.
//
import UIKit
import CoreLocation
protocol OfferRideDelegate {
func getLocation(_ lat: CLLocationDegrees, _ long:CLLocationDegrees, _ str:String, _ index:Int)
}
class HomeVC: BaseVC, UITextFieldDelegate, OfferRideDelegate{
fileprivate var newStatus:Bool = false
@IBOutlet weak var sosBtn: UIButton!
@IBOutlet var mainImg: UIImageView!
@IBOutlet var exploreBtn: UIButton!
@IBOutlet var offerRideView: UIView!
@IBOutlet var offerRideHeight: NSLayoutConstraint!
@IBOutlet var offerRideTable: UITableView!
@IBOutlet var findRideView: UIView!
@IBOutlet var FindRideHeight: NSLayoutConstraint!
@IBOutlet var findPicTF: UITextField!
@IBOutlet var findDropTF: UITextField!
@IBOutlet var dateTF: UITextField!
@IBOutlet var findNextBtn: UIButton!
@IBOutlet weak var currentRideBtn: UIButton!
@IBOutlet var findPicView: UIView!
@IBOutlet var dropPicView: UIView!
@IBOutlet var dateView: UIView!
@IBOutlet var heightOfferRideTFView: NSLayoutConstraint!
@IBOutlet var offerDropTF: UITextField!
@IBOutlet var offerDateTF: UITextField!
@IBOutlet var offerTimeTF: UITextField!
@IBOutlet var offerNextBtn: UIButton!
@IBOutlet var offerPickupView: UIView!
@IBOutlet var offerdateView: UIView!
@IBOutlet var offerTimeView: UIView!
var lat = String()
var lat1 = String()
var lat2 = String()
var lat3 = String()
var lat4 = String()
var lat5 = String()
var newRide:String = ""
var am_i_booked:String = ""
var long = String()
var long1 = String()
var long2 = String()
var long3 = String()
var long4 = String()
var long5 = String()
var address = String()
var address1 = String()
var address2 = String()
var address3 = String()
var address4 = String()
var address5 = String()
var addArr = [String]()
var addLat = [String]()
var offerDropLat = String()
var offerDropLong = String()
var findPicLat = String()
var findPicLong = String()
var findDropLat = String()
var findDropLong = String()
var text = ["Pickup Location"]
// var images = [#imageLiteral(resourceName: "pickup_location"),#imageLiteral(resourceName: "where_u_go")]
var text1 = ["Pickup Location","Drop Location","Date"]
var image1 = [#imageLiteral(resourceName: "pickup_location"),#imageLiteral(resourceName: "where_u_go"),#imageLiteral(resourceName: "date")]
var offerValue = false
var findValue = false
var offerHeight = 500
var indexValue = 1
var offerDate = String()
var offerTime = String()
var dropLocation = String()
var date = UIDatePicker()
var date1 = UIDatePicker()
var newOfferTime:String = ""
var currentLocation = CLLocation()
var locationManager = CLLocationManager()
var myLocationLat:String?
var myLocationLng:String?
func sosCall()
{
if CLLocationManager.locationServicesEnabled()
&& CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse
{
if let location = locationManager.location
{
currentLocation = location
}
let latii = String(format: "%.8f", currentLocation.coordinate.latitude)
let longi = String(format: "%.8f", currentLocation.coordinate.longitude)
print(latii,longi)
let rideId = UserDefaults.standard.value(forKey: "rideID") as? String ?? ""
let userId = UserDefaults.standard.value(forKey: "LoginID") as? String ?? ""
Indicator.sharedInstance.showIndicator()
UserVM.sheard.panicApi(user_id: userId , ride_id: newRide, lattitude: latii, longitude: longi) { (success, message, error) in
if error == nil{
Indicator.sharedInstance.hideIndicator()
if success{
// self.showAlert(message: message)
// let story = self.storyboard?.instantiateViewController(withIdentifier:"MainTabVC") as! MainTabVC
// DataManager.isLogin = true
// self.navigationController?.pushViewController(story, animated: true)
}else{
// self.showAlert(message: message)
}
}else{
// self.showAlert(message: error?.domain)
}
}
if let url = URL(string: "tel://911"), UIApplication.shared.canOpenURL(url) {
if #available(iOS 10, *) {
UIApplication.shared.open(url)
} else {
UIApplication.shared.openURL(url)
}
}
}
}
@IBAction func notificationsBtn(_ sender: Any) {
let story = self.storyboard?.instantiateViewController(withIdentifier: "NotificationVC") as! NotificationVC
self.navigationController?.pushViewController(story, animated: true)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.rideOnlineStatus { (status,ride_id,m_booked) in
if status{
self.newRide = ride_id
self.am_i_booked = m_booked
self.currentRideBtn.isHidden = false
self.sosBtn.isHidden = false
}else{
self.currentRideBtn.isHidden = true
self.sosBtn.isHidden = true
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// self.tabBarController?.hidesBottomBarWhenPushed = false
offerRideTable.isScrollEnabled = false
self.offerRideHeight.constant = 190
self.FindRideHeight.constant = 130
self.heightOfferRideTFView.constant = 0
// exploreBtn.setButtonBorder()
exploreBtn.layer.cornerRadius = exploreBtn.frame.height/2
exploreBtn.layer.borderColor = UIColor.white.cgColor
exploreBtn.layer.borderWidth = 2
exploreBtn.alpha = 0.8
exploreBtn.clipsToBounds = true
offerRideView.setShadow()
offerRideView.layer.cornerRadius = 40
offerRideView.layer.borderColor = UIColor.white.cgColor
offerRideView.layer.borderWidth = 1
offerPickupView.setShadow()
offerdateView.setShadow()
offerTimeView.setShadow()
offerNextBtn.setButtonBorder()
offerDateTF.delegate = self
offerTimeTF.delegate = self
findRideView.setShadow()
findRideView.layer.cornerRadius = 40
findRideView.layer.borderColor = UIColor.white.cgColor
findRideView.layer.borderWidth = 1
findNextBtn.setButtonBorder()
findPicView.setShadow()
dropPicView.setShadow()
dateView.setShadow()
dateTF.placeholder = "Date"
dateTF.delegate = self
//curntDate()
}
func curntDate()->String {
let dateFormatter : DateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-mmm-dd"
//dateFormatter.dateFormat = "mm-dd-yyy"
dateFormatter.dateFormat = "MM-dd-yyyy"
let date = Date()
let dateString = dateFormatter.string(from: date)
return dateString
// currentDate = dateString
}
func curentRide()
{
let story = self.storyboard?.instantiateViewController(withIdentifier: "OfferedRideDetailsCurrentVC") as! OfferedRideDetailsCurrentVC
// let rideId = UserDefaults.standard.value(forKey: "rideID") as? String
// let bookID = UserDefaults.standard.value(forKey: "bookID") as? String
story.isFromView = true
// story.islocal = UserVM.sheard.allRidesDetails[0].bookedRide[indexPath.row].is_local_ride ?? ""
if am_i_booked == "1"{
story.bookid = ""
//story.isFromCurrentRide = true
story.rideId = newRide
}else{
story.rideId = newRide
//story.isFromCurrentRide = true
story.bookid = ""
}
// story.rideId = newRide
// story.isReceived = true
// story.cancelReason = "usercancel"
self.navigationController?.pushViewController(story, animated: true)
}
@IBAction func currentRideBtnAction(_ sender: Any) {
self.curentRide()
}
@IBAction func sosBtnAction(_ sender: Any) {
self.sosCall()
}
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == dateTF{
self.date.datePickerMode = .date
if #available(iOS 14.0, *) {
self.date.preferredDatePickerStyle = .wheels
} else {
// Fallback on earlier versions
}
self.date.minimumDate = Date()
self.date.backgroundColor = .white
// self.date.setValue(UIColor.white, forKeyPath: "textColor")
let toolbar = UIToolbar()
toolbar.sizeToFit()
toolbar.backgroundColor = .black
dateTF.inputAccessoryView = toolbar
dateTF.inputView = self.date
let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let cancelBtn = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.cancelBtn))
cancelBtn.tintColor = .white
let doneBtn = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.finddoneAction))
doneBtn.tintColor = .white
toolbar.setItems([cancelBtn,flexSpace,doneBtn], animated: true)
}
else if textField == offerDateTF{
self.date.datePickerMode = .date
if #available(iOS 14.0, *) {
self.date.preferredDatePickerStyle = .wheels
} else {
// Fallback on earlier versions
}
self.date.minimumDate = Date()
self.date.backgroundColor = .white
//x self.date.setValue(UIColor.white, forKeyPath: "textColor")
let toolbar = UIToolbar()
toolbar.sizeToFit()
toolbar.backgroundColor = .black
offerDateTF.inputAccessoryView = toolbar
offerDateTF.inputView = self.date
let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let cancelBtn = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.cancelBtn))
cancelBtn.tintColor = .white
let doneBtn = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.doneAction))
doneBtn.tintColor = .white
toolbar.setItems([cancelBtn,flexSpace,doneBtn], animated: true)
}
else if textField == offerTimeTF{
// self.date1.datePickerMode = .time
// self.date1.minimumDate = Date()
print(Date().toString(format: "MM-dd-yyyy"))
if offerDateTF.text ?? "" == Date().toString(format: "MM-dd-yyyy"){
self.date1.minimumDate = Date()
self.date1.datePickerMode = .time
if #available(iOS 14.0, *) {
self.date1.preferredDatePickerStyle = .wheels
} else {
// Fallback on earlier versions
}
}else{
date1 = UIDatePicker()
self.date1.datePickerMode = .time
if #available(iOS 14.0, *) {
self.date1.preferredDatePickerStyle = .wheels
} else {
// Fallback on earlier versions
}
}
self.date1.backgroundColor = .white
// self.date1.setValue(UIColor.white, forKeyPath: "textColor")
let toolbar1 = UIToolbar()
toolbar1.sizeToFit()
toolbar1.backgroundColor = .black
offerTimeTF.inputAccessoryView = toolbar1
offerTimeTF.inputView = self.date1
let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let cancelBtn1 = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.cancelBtn))
cancelBtn1.tintColor = .white
let doneBtn1 = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.doneActionTime))
doneBtn1.tintColor = .white
toolbar1.setItems([cancelBtn1,flexSpace,doneBtn1], animated: true)
}
}
@objc func finddoneAction() {
let formatter = DateFormatter()
formatter.dateFormat = "MM-dd-yyyy"
dateTF.text = "\(formatter.string(from: date.date))"
self.view.endEditing(true)
offerRideTable.reloadData()
}
func getLocation(_ lat: CLLocationDegrees, _ long:CLLocationDegrees, _ str:String, _ index:Int) {
print(str)
print(lat)
print(long)
print(index)
if index <= 2{
newStatus = true
text[index] = str
}
if index == 0{
self.lat = "\(lat)"
self.long = "\(long)"
self.address = str
}else if index == 1{
self.lat1 = "\(lat)"
self.long1 = "\(long)"
self.address1 = str
}else if index == 2{
self.lat2 = "\(lat)"
self.long2 = "\(long)"
self.address2 = str
}else if index == 3{
self.offerDropLat = "\(lat)"
self.offerDropLong = "\(long)"
self.offerDropTF.text = str
}
else if index == 4{
self.findPicLat = "\(lat)"
self.findPicLong = "\(long)"
findPicTF.text = str
}else if index == 5{
self.findDropLat = "\(lat)"
self.findDropLong = "\(long)"
findDropTF.text = str
}
offerRideTable.reloadData()
}
@IBAction func findRideBtnAtn(_ sender: Any) {
UIView.animate(withDuration: 0.5) {
if self.findValue == false && self.offerValue == false{
self.offerRideHeight.constant = 400
self.FindRideHeight.constant = 350
self.heightOfferRideTFView.constant = 0
self.view.layoutIfNeeded()
self.findValue = true
self.offerValue = false
}
else if self.offerValue == false && self.findValue == true{
self.offerRideHeight.constant = 190
self.FindRideHeight.constant = 130
self.heightOfferRideTFView.constant = 0
self.view.layoutIfNeeded()
self.findValue = false
self.offerValue = false
}
else if self.offerValue == true && self.findValue == false{
self.offerRideHeight.constant = 400
self.FindRideHeight.constant = 350
self.heightOfferRideTFView.constant = 50
self.view.layoutIfNeeded()
self.findValue = true
self.offerValue = false
}
}
}
@IBAction func findPicLocationBtnAtn(_ sender: Any) {
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
story.index = 4
story.delegate = self
self.navigationController?.pushViewController(story, animated: true)
}
@IBAction func dropLocationBtnAtn(_ sender: Any) {
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
story.index = 5
story.delegate = self
self.navigationController?.pushViewController(story, animated: true)
}
@IBAction func findNextBtnAtn(_ sender: Any) {
if findPicTF.text!.isEmpty && findDropTF.text!.isEmpty && dateTF.text!.isEmpty{
showAlert(message: "Please fill the required data.")
}else{
findRide(fromAdd: findPicTF.text!, toAdd: findDropTF.text!, fromLat: findPicLat, fromLong: findPicLong, to_lat: findDropLat, to_Long: findDropLong)
}
}
@IBAction func exploreBtnAtn(_ sender: Any) {
let story = storyboard?.instantiateViewController(withIdentifier: "LocalRideVC") as! LocalRideVC
navigationController?.pushViewController(story, animated: true)
}
@IBAction func offerRideBtnAtn(_ sender: Any) {
UIView.animate(withDuration: 0.5) {
if self.offerValue == false && self.findValue == false{
self.offerRideHeight.constant = CGFloat(self.offerHeight)
self.heightOfferRideTFView.constant = 335
self.FindRideHeight.constant = 130
self.offerValue = true
self.findValue = false
self.view.layoutIfNeeded()
}else if self.offerValue == true && self.findValue == false{
self.offerRideHeight.constant = 190
self.FindRideHeight.constant = 130
self.heightOfferRideTFView.constant = 0
self.offerValue = false
self.findValue = false
self.view.layoutIfNeeded()
}
else if self.offerValue == false && self.findValue == true{
self.offerRideHeight.constant = CGFloat(self.offerHeight)
self.FindRideHeight.constant = 130
self.heightOfferRideTFView.constant = 335
self.offerValue = true
self.findValue = false
self.view.layoutIfNeeded()
}
}
}
@IBAction func offerDropBtnAtn(_ sender: Any) {
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
story.index = 3
story.delegate = self
self.navigationController?.pushViewController(story, animated: true)
}
func covertDate(date : String) -> String
{
let dateString = date
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
dateFormatter.locale = Locale.init(identifier: "en_GB")
let dateObj = dateFormatter.date(from: dateString)
dateFormatter.dateFormat = "MM-dd-yyyy"
print("Dateobj: \(dateFormatter.string(from: dateObj ?? Date()))")
return dateFormatter.string(from: dateObj ?? Date())
}
@IBAction func offerNextBtnAtn(_ sender: Any) {
if self.lat == "" && offerDropTF.text!.isEmpty && offerDateTF.text!.isEmpty && offerTimeTF.text!.isEmpty{
self.showAlert(message: "Please fill all data")
}else{
let story = self.storyboard?.instantiateViewController(withIdentifier: "RideDetailsVC") as! RideDetailsVC
story.rideFromAdd = address
story.rideFromLat = lat
story.rideFromLong = long
story.address2 = address1
story.rideLat2 = lat1
story.rideLong2 = long1
story.address3 = address2
story.rideLat3 = lat2
story.rideLong3 = long2
story.rideToAdd = offerDropTF.text!
story.rideToLat = offerDropLat
story.rideToLong = offerDropLong
story.ridedate = self.offerDateTF.text ?? ""
story.rideTime = self.offerTimeTF.text ?? ""
self.navigationController?.pushViewController(story, animated: true)
}
}
}
extension HomeVC : UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if text.count < 3 {
return text.count + 1
}
return text.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == text.count {
print(text)
tableView.register(UINib.init(nibName: "addStopCellFile", bundle: nil), forCellReuseIdentifier: "addStopCellFile")
let cell = tableView.dequeueReusableCell(withIdentifier: "addStopCellFile") as! addStopCellFile
cell.addStpBtn.isHidden = false
cell.addStopAtn = { (action) in
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
cell.addStpBtn.isHidden = false
story.index = indexPath.row
story.delegate = self
story.boolPickup = true
self.navigationController?.pushViewController(story, animated: true)
self.text.append("")
self.indexValue = self.indexValue + 1
if self.text.count < 3 {
self.offerHeight = self.offerHeight + 50
cell.addStpBtn.isHidden = false
} else {
cell.addStpBtn.isHidden = true
}
self.offerRideHeight.constant = CGFloat(self.offerHeight)
tableView.reloadData()
}
return cell
}else{
if indexPath.row == 0 {
tableView.register(UINib.init(nibName: "offerRideCellFile", bundle: nil), forCellReuseIdentifier: "offerRideCellFile")
let cell = tableView.dequeueReusableCell(withIdentifier:
"offerRideCellFile") as! offerRideCellFile
if newStatus{
cell.cellName.text = text[indexPath.row]
}else{
cell.cellName.placeholder = text[indexPath.row]
}
cell.cellName.textColor = .black
cell.cellAtn = { (action) in
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
story.index = indexPath.row
story.delegate = self
story.boolPickup = false
self.navigationController?.pushViewController(story, animated: true)
}
return cell
} else {
tableView.register(UINib.init(nibName: "offerRidetnCellFile", bundle: nil), forCellReuseIdentifier: "offerRidetnCellFile")
let cell = tableView.dequeueReusableCell(withIdentifier: "offerRidetnCellFile") as! offerRidetnCellFile
cell.locationNameTF.text = text[indexPath.row]
cell.locationNameTF.textColor = .black
cell.addLocationAtn = { (action) in
let story = self.storyboard?.instantiateViewController(withIdentifier: "MapVC") as! MapVC
story.index = indexPath.row
story.delegate = self
story.boolPickup = false
self.navigationController?.pushViewController(story, animated: true)
}
cell.cellAtn = { (action) in
self.text.remove(at: indexPath.row)
if self.text.count < 2 {
self.offerHeight = self.offerHeight - 50
}
tableView.reloadData()
self.offerRideHeight.constant = CGFloat(self.offerHeight)
}
return cell
}
}
}
@objc func doneAction() {
let formatter = DateFormatter()
formatter.dateFormat = "MM-dd-yyyy"
offerDateTF.text = "\(formatter.string(from: date.date))"
self.view.endEditing(true)
offerRideTable.reloadData()
}
@objc func doneActionTime(sender: UITextField){
let formatter = DateFormatter()
formatter.dateFormat = "hh:mm a"
offerTimeTF.text = "\(formatter.string(from: date1.date))"
self.view.endEditing(true)
offerRideTable.reloadData()
}
@objc func cancelBtn(){
self.view.endEditing(true)
}
}
//MARK: - API Methods
extension HomeVC{
func findRide(fromAdd: String, toAdd: String, fromLat: String, fromLong: String, to_lat: String, to_Long: String) {
UserVM.sheard.allRideDetails.removeAll()
Indicator.sharedInstance.showIndicator()
UserVM.sheard.findRide(userid: userID, from_address: fromAdd, to_address: toAdd, from_lat: fromLat, from_long: fromLong, to_lat: to_lat, to_long: to_Long, date: dateTF.text ?? "", price: "ASC", is_local_ride: "0") { (success, message, error) in
if error == nil{
Indicator.sharedInstance.hideIndicator()
if success{
print(UserVM.sheard.allRideDetails)
let story = self.storyboard?.instantiateViewController(withIdentifier:"allRides") as! allRides
story.topvalue = "\(fromAdd)"
story.bottomValue = toAdd
story.rideFromAdd = fromAdd
story.rideFromLat = fromLat
story.rideFromLong = fromLong
story.rideToAdd = toAdd
story.rideToLat = to_lat
story.rideToLong = to_Long
story.date = self.dateTF.text!
self.navigationController?.pushViewController(story, animated: true)
}else{
self.showAlert(message: message)
}
}else{
self.showAlert(message: error?.domain)
}
}
}
}
extension Date {
func toString(format: String = "yyyy-MM-dd") -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.dateFormat = format
return formatter.string(from: self)
}
}
|
[
-1
] |
fd71937ad0ba90216fa203e2bfbbec61be70d2a2
|
4bacc6ab0a98d1e2d8ff3d0f20f203fbb9e554ee
|
/Journal-end/Journal/JournalEntry.swift
|
b1aee9bf88938cb7a1748bbe4ac5ce6f2ccf020d
|
[] |
no_license
|
santi101093/CursoIOS
|
8c03e967e9bbf63e9f5af0e63ebbbd420002a1d8
|
45bd8a1b1b04a5d3db85d772d0bb0f870655fb63
|
refs/heads/master
| 2021-01-12T01:18:50.544290 | 2017-01-08T22:12:07 | 2017-01-08T22:12:07 | 78,371,324 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 583 |
swift
|
/*
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License, by Yong Bakos.
*/
import Foundation
class JournalEntry: CustomStringConvertible {
let date: Date
let contents: String
let dateFormatter = DateFormatter()
var description: String {
return dateFormatter.string(from: date)
}
init(date: Date, contents: String) {
self.date = date
self.contents = contents
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .short
}
}
|
[
-1
] |
b737f6bab2e77f1751ca5f463b4c9ae4aeb8c5d7
|
61e8273758ec73464925ca3b0ab8cc9ac7a79659
|
/SwiftUI Masterclass/TOUCHDOWN/Students/Touchdown/Touchdown/View/Home/FeaturedTabView.swift
|
b293f4f5480fee9da126479de99cbfb5198d27f1
|
[] |
no_license
|
mendessilvagui/Swift-Courses
|
22ce60c6a8bfc7782824b124ca4f572fca3f071d
|
67ae059b00b55aced7a567d7acd16d26d80ec5d2
|
refs/heads/main
| 2023-06-24T10:28:47.148998 | 2021-07-23T19:39:03 | 2021-07-23T19:39:03 | 387,768,246 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 738 |
swift
|
//
// FeaturedTabView.swift
// Touchdown
//
// Created by Guilherme Mendes on 09/06/21.
//
import SwiftUI
struct FeaturedTabView: View {
// MARK: - PROPERTIES
// MARK: - BODY
var body: some View {
TabView {
ForEach(players) { player in
FeaturedItemView(player: player)
.padding(.top, 10)
.padding(.horizontal, 15)
}
} //: TAB
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
}
}
// MARK: - PREVIEW
struct FeaturedTabView_Previews: PreviewProvider {
static var previews: some View {
FeaturedTabView()
.previewDevice("iPhone 11")
.background(Color.gray)
}
}
|
[
358608
] |
70ea54dd46a5c4c846592a98e1aa75df64481b86
|
0d8d9dde4260d9ef4053e2891fb4a198d1fefa18
|
/CallsApp/CallsApp/CallCell.swift
|
2f32c355480add562ed81fc3d054790beb15d438
|
[
"MIT"
] |
permissive
|
emilia98/CallsRegisterApp
|
e239c7363f1d1e9a0cdd9a2bacdf4379ee509f8b
|
08f64a16908cd8e604361350c327acf3799da8ca
|
refs/heads/main
| 2023-04-19T18:30:02.816194 | 2021-05-07T09:21:59 | 2021-05-07T09:21:59 | 358,650,637 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 341 |
swift
|
//
// CallCell.swift
// CallsApp
//
// Created by Emilia Nedyalkova on 16.04.21.
//
import UIKit
class CallCell: UITableViewCell {
@IBOutlet var nameLabel: UILabel!
@IBOutlet var typeImage: UIImageView!
@IBOutlet var sourceLabel: UILabel!
@IBOutlet var dateLabel: UILabel!
@IBOutlet var outcomeImage: UIImageView!
}
|
[
-1
] |
20ae40afdd1e57be72e1b06004479e2afb450eee
|
be393c4c0739d2d4901a66b724e8380568581d44
|
/GJJUserSwift/Classes/UI/Feed/View/GFeedNodeView.swift
|
6970e46001519d8a4a98bb3eb0c6b160a7d80f4f
|
[] |
no_license
|
lishten/GJJUserSwift
|
fe1ace118bb83b8b819df6676248e0ee5b66b9b9
|
f99ba24c74cb50db902ce9425fdfd96e526d0759
|
refs/heads/master
| 2021-01-11T03:04:41.911140 | 2016-10-14T06:50:22 | 2016-10-14T06:50:22 | 70,882,239 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,283 |
swift
|
//
// GFeedNodeView.swift
// GJJUserSwift
//
// Created by Lishten on 15/11/20.
// Copyright © 2015年 Lishten. All rights reserved.
//
import UIKit
class GFeedNodeView: UIView {
@IBOutlet weak var progressView: UIProgressView!
@IBOutlet weak var stateLabelOne: UILabel!
@IBOutlet weak var stateLabelTwo: UILabel!
@IBOutlet weak var stateLabelThree: UILabel!
@IBOutlet weak var stateLabelFour: UILabel!
@IBOutlet weak var stateLabelFive: UILabel!
@IBOutlet weak var nodeLabelOne: UILabel!
@IBOutlet weak var nodeLabelTwo: UILabel!
@IBOutlet weak var nodeLabelThree: UILabel!
@IBOutlet weak var nodeLabelFour: UILabel!
@IBOutlet weak var nodeLabelFive: UILabel!
@IBOutlet weak var stateImageOne: UIImageView!
@IBOutlet weak var stateImageTwo: UIImageView!
@IBOutlet weak var stateImageThree: UIImageView!
@IBOutlet weak var stateImageFour: UIImageView!
@IBOutlet weak var stateImageFive: UIImageView!
class func userFeedHeaderViewFromXib() -> GFeedNodeView {
let feedHeaderV = NSBundle.mainBundle().loadNibNamed("GFeedNodeView", owner: nil, options: nil).last as! GFeedNodeView
feedHeaderV.setNormalUI()
return feedHeaderV
}
func setNormalUI(){
self.progressView.progressTintColor = kCommonColor
self.progressView.trackTintColor = UIColor.UIColorFromRGB(0xdcdce2)
self.layer.borderColor = kLineColor.CGColor
self.layer.borderWidth = 0.5
var setLabelNormal:((label:UILabel) -> ())
setLabelNormal = { (label:UILabel) -> () in
label.font = kDescriptionLabelFont
label.textColor = kSubTitleLbaelColor
}
setLabelNormal(label: self.stateLabelOne)
setLabelNormal(label: self.stateLabelTwo)
setLabelNormal(label: self.stateLabelThree)
setLabelNormal(label: self.stateLabelFour)
setLabelNormal(label: self.stateLabelFive)
setLabelNormal(label: self.nodeLabelOne)
setLabelNormal(label: self.nodeLabelTwo)
setLabelNormal(label: self.nodeLabelThree)
setLabelNormal(label: self.nodeLabelFour)
setLabelNormal(label: self.nodeLabelFive)
}
}
|
[
-1
] |
dd83f21541ddac4f0810af341e2311e2bf7a96c6
|
b610d5b24ff375f93b278a1d1a9ee20afcb9381e
|
/RoomDebts/Tools/Protocols/KeyboardHandler.swift
|
8b38f74d9aaf1f11bb95c28c3e5cab7e0793116f
|
[] |
no_license
|
timbaev/RoomDebtsiOS_V2
|
2a3da5d023ba774720b2c9a67cd91d59d4f9ca90
|
5fec476e6aed1e98d8055675c38a23b8e4deb14e
|
refs/heads/master
| 2020-04-17T18:20:14.910004 | 2019-08-18T19:16:03 | 2019-08-18T19:16:03 | 166,822,062 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,380 |
swift
|
//
// KeyboardHandler.swift
// Tools
//
// Created by Almaz Ibragimov on 06.06.2018.
// Copyright © 2018 Flatstack. All rights reserved.
//
import UIKit
public protocol KeyboardHandler {
// MARK: - Instance Methods
func handle(keyboardHeight: CGFloat, view: UIView)
func subscribeToKeyboardNotifications()
func unsubscribeFromKeyboardNotifications()
}
// MARK: -
public extension KeyboardHandler where Self: AnyObject {
// MARK: - Instance Methods
func unsubscribeFromKeyboardNotifications() {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}
}
// MARK: -
public extension KeyboardHandler where Self: UIViewController {
// MARK: - Instance Methods
private func onKeyboardWillShow(with notification: NSNotification) {
guard let userInfo = notification.userInfo else {
return
}
guard let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else {
return
}
self.handle(keyboardHeight: self.view.frame.bottom - self.view.convert(keyboardFrame.origin, from: nil).y,
view: self.view)
}
private func onKeyboardWillHide(with notification: NSNotification) {
self.handle(keyboardHeight: 0.0, view: self.view)
}
// MARK: -
func subscribeToKeyboardNotifications() {
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification,
object: nil,
queue: nil,
using: { [weak self] notification in
self?.onKeyboardWillShow(with: notification as NSNotification)
})
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillHideNotification,
object: nil,
queue: nil,
using: { [weak self] notification in
self?.onKeyboardWillHide(with: notification as NSNotification)
})
}
}
|
[
-1
] |
ea0b8ee11826c82ed46be6df5d571b26683cf80e
|
bbd23b25de248e2890cc8a5d947c70e229a54498
|
/Tooli/SelctionCell.swift
|
f0251cca7d9eedc565608b5f983f9da9ba02f735
|
[] |
no_license
|
sunilkateshiya/Tooli
|
b568eb5e14956956a9500f1f96a6fb5c019512ce
|
69506310b71278361843d6161f3c9ea63c23be7a
|
refs/heads/master
| 2021-08-24T00:57:50.096039 | 2017-09-19T07:52:01 | 2017-09-19T07:52:01 | 113,431,213 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 676 |
swift
|
//
// CertificateCell.swift
// Tooli
//
// Created by Impero IT on 26/01/2017.
// Copyright © 2017 impero. All rights reserved.
//
import UIKit
class SelctionCell: UITableViewCell
{
@IBOutlet var btnSelction : UIButton!
@IBOutlet var lblName : UILabel!
@IBOutlet var btnRemove : UIButton!
@IBOutlet var btnView : UIButton!
override func awakeFromNib()
{
super.awakeFromNib()
// btnRemove.isHidden = true
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool)
{
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
|
[
-1
] |
a913fa90afb08031740ecdac621811c1929cacbc
|
9e6b15877cabafa0f5b7d2daeddf5d4d929c54d4
|
/Sources/ComposablePlayer/Interface.swift
|
7d1aecebb46d316837a353c4652560567cd13742
|
[] |
no_license
|
tcakit/composable-player
|
601699a745c8a177b2cc4acd762246a5ecbe7829
|
ced68c0c4edb78bf0e15f086b10613f935550cb9
|
refs/heads/main
| 2023-03-14T23:51:35.836284 | 2021-03-11T21:06:54 | 2021-03-11T21:06:54 | 333,231,561 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,146 |
swift
|
// Interface.swift
// Copyright (c) 2021 Joe Blau
import AVFoundation
import ComposableArchitecture
public struct AudioPlayer {
public enum Action: Equatable {}
public struct Error: Swift.Error, Equatable {
public let error: NSError?
public init(_ error: Swift.Error?) {
self.error = error as NSError?
}
}
// MARK: - Variables
var create: (AnyHashable) -> Effect<Action, Never> = { _ in _unimplemented("create") }
var destroy: (AnyHashable) -> Effect<Never, Never> = { _ in _unimplemented("destroy") }
var play: (AnyHashable, URL) -> Effect<Never, Never> = { _, _ in _unimplemented("play") }
var pause: (AnyHashable) -> Effect<Never, Never> = { _ in _unimplemented("stop") }
// MARK: - Functions
public func create(id: AnyHashable) -> Effect<Action, Never> {
create(id)
}
public func destroy(id: AnyHashable) -> Effect<Never, Never> {
destroy(id)
}
func play(id: AnyHashable, url: URL) -> Effect<Never, Never> {
play(id, url)
}
func pause(id: AnyHashable) -> Effect<Never, Never> {
pause(id)
}
}
|
[
-1
] |
67ce0f34eea5debf2aa190d1f0bd59e1f4855787
|
d44e8d5ecd524749c3b782b77cab0b5c6d178b61
|
/Sources/Capsule/SDKs/UIKit/Builders/Fakes/FakeStoryboardBuilder.swift
|
768dbfcbfe65b50ee36f250c810491274d6f8657
|
[
"MIT"
] |
permissive
|
rbaumbach/Capsule
|
8967eea8a07390bf04e5d3ba24670c01cd675e40
|
5065f4e8540eb8df639b32084c9dc74c1b62b4b4
|
refs/heads/master
| 2022-11-07T14:27:51.851267 | 2022-11-06T16:21:57 | 2022-11-06T16:21:57 | 224,002,467 | 6 | 0 |
MIT
| 2022-11-06T16:21:58 | 2019-11-25T17:16:26 |
Swift
|
UTF-8
|
Swift
| false | false | 2,671 |
swift
|
//MIT License
//
//Copyright (c) 2020-2022 Ryan Baumbach <[email protected]>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
import UIKit
public class FakeStoyboardBuilder: StoryboardBuilderProtocol {
// MARK: - Captured properties
public var capturedBuildInitialViewControllerName: String?
public var capturedBuildViewControllerName: String?
public var capturedBuildViewControllerIdentifier: String?
// MARK: - Stubbed properties
public var stubbedBuildInitialViewController = UIViewController()
public var stubbedBuildViewController = UIViewController()
// MARK: - Init methods
public init() { }
// MARK: - <StoryboardBuilderProtocol>
public func buildInitialViewController<T: UIViewController>(name: String) -> T {
guard let stubbedBuildInitialViewController = stubbedBuildViewController as? T else {
preconditionFailure("FakeStoryboardBuilder.stubbedBuildInitialViewController property has not been set properly")
}
capturedBuildInitialViewControllerName = name
return stubbedBuildInitialViewController
}
public func buildViewController<T: UIViewController>(name: String, identifier: String) -> T {
guard let stubbedBuildViewController = stubbedBuildViewController as? T else {
preconditionFailure("FakeStoryboardBuilder.stubbedBuildViewController property has not been set properly")
}
capturedBuildViewControllerName = name
capturedBuildViewControllerIdentifier = identifier
return stubbedBuildViewController
}
}
|
[
229440,
127689,
336478,
289067,
341068,
97328,
142097,
297618,
142078,
108415
] |
35b0d5c6fdd549ce092ceae7559a5c45901db906
|
90c9a02434a37d383e4c822dfc89c7dac0dc1daa
|
/VisitorBook/CustomView/Categories/MMSlidingButton.swift
|
b3cc371d6aa481bfd374733d0cafd8aeaf7e9373
|
[] |
no_license
|
praveensharma8989/VisitorBook
|
05ce6f4c52825a15c051729799fb8d67f4e765dc
|
033c8f0c54280b3e0eb2efe38e04c5ef6c7d017b
|
refs/heads/master
| 2020-03-27T22:36:24.605995 | 2018-10-12T12:53:41 | 2018-10-12T12:53:41 | 147,245,426 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 8,108 |
swift
|
//
// MMSlidingButton.swift
// MMSlidingButton
//
// Created by Mohamed Maail on 6/7/16.
// Copyright © 2016 Mohamed Maail. All rights reserved.
//
import Foundation
import UIKit
protocol SlideButtonDelegate{
func buttonStatus(status:String, sender:MMSlidingButton)
}
@IBDesignable class MMSlidingButton: UIView{
var delegate: SlideButtonDelegate?
@IBInspectable var dragPointWidth: CGFloat = 70 {
didSet{
setStyle()
}
}
@IBInspectable var dragPointColor: UIColor = UIColor.darkGray {
didSet{
setStyle()
}
}
@IBInspectable var buttonColor: UIColor = UIColor.gray {
didSet{
setStyle()
}
}
@IBInspectable var buttonText: String = "UNLOCK" {
didSet{
setStyle()
}
}
@IBInspectable var imageName: UIImage = UIImage() {
didSet{
setStyle()
}
}
@IBInspectable var buttonTextColor: UIColor = UIColor.white {
didSet{
setStyle()
}
}
@IBInspectable var dragPointTextColor: UIColor = UIColor.white {
didSet{
setStyle()
}
}
@IBInspectable var buttonUnlockedTextColor: UIColor = UIColor.white {
didSet{
setStyle()
}
}
@IBInspectable var buttonCornerRadius: CGFloat = 30 {
didSet{
setStyle()
}
}
@IBInspectable var buttonUnlockedText: String = "UNLOCKED"
@IBInspectable var buttonUnlockedColor: UIColor = UIColor.black
var buttonFont = UIFont.boldSystemFont(ofSize: 17)
var dragPoint = UIView()
var buttonLabel = UILabel()
var dragPointButtonLabel = UILabel()
var imageView = UIImageView()
var unlocked = false
var layoutSet = false
override init (frame : CGRect) {
super.init(frame : frame)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
override func layoutSubviews() {
if !layoutSet{
self.setUpButton()
self.layoutSet = true
}
}
func setStyle(){
self.buttonLabel.text = self.buttonText
self.dragPointButtonLabel.text = self.buttonText
self.dragPoint.frame.size.width = self.dragPointWidth
self.dragPoint.backgroundColor = self.dragPointColor
self.backgroundColor = self.buttonColor
self.imageView.image = imageName
self.buttonLabel.textColor = self.buttonTextColor
self.dragPointButtonLabel.textColor = self.dragPointTextColor
self.dragPoint.layer.cornerRadius = buttonCornerRadius
self.layer.cornerRadius = buttonCornerRadius
}
func setUpButton(){
self.backgroundColor = self.buttonColor
self.dragPoint = UIView(frame: CGRect(x: dragPointWidth - self.frame.size.width, y: 0, width: self.frame.size.width, height: self.frame.size.height))
self.dragPoint.backgroundColor = dragPointColor
self.dragPoint.layer.cornerRadius = buttonCornerRadius
self.addSubview(self.dragPoint)
if !self.buttonText.isEmpty{
self.buttonLabel = UILabel(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height))
self.buttonLabel.textAlignment = .center
self.buttonLabel.text = buttonText
self.buttonLabel.textColor = UIColor.white
self.buttonLabel.font = self.buttonFont
self.buttonLabel.textColor = self.buttonTextColor
self.addSubview(self.buttonLabel)
self.dragPointButtonLabel = UILabel(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height))
self.dragPointButtonLabel.textAlignment = .center
self.dragPointButtonLabel.text = buttonText
self.dragPointButtonLabel.textColor = UIColor.white
self.dragPointButtonLabel.font = self.buttonFont
self.dragPointButtonLabel.textColor = self.dragPointTextColor
self.dragPoint.addSubview(self.dragPointButtonLabel)
}
self.bringSubview(toFront: self.dragPoint)
if self.imageName != UIImage(){
self.imageView = UIImageView(frame: CGRect(x: self.frame.size.width - dragPointWidth, y: 0, width: self.dragPointWidth, height: self.frame.size.height))
self.imageView.contentMode = .center
self.imageView.image = self.imageName
self.dragPoint.addSubview(self.imageView)
}
self.layer.masksToBounds = true
// start detecting pan gesture
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panDetected(sender:)))
panGestureRecognizer.minimumNumberOfTouches = 1
self.dragPoint.addGestureRecognizer(panGestureRecognizer)
}
@objc func panDetected(sender: UIPanGestureRecognizer){
var translatedPoint = sender.translation(in: self)
translatedPoint = CGPoint(x: translatedPoint.x, y: self.frame.size.height / 2)
sender.view?.frame.origin.x = (dragPointWidth - self.frame.size.width) + translatedPoint.x
if sender.state == .ended{
let velocityX = sender.velocity(in: self).x * 0.2
var finalX = translatedPoint.x + velocityX
if finalX < 0{
finalX = 0
}else if finalX + self.dragPointWidth > (self.frame.size.width - 60){
unlocked = true
self.unlock()
}
let animationDuration:Double = abs(Double(velocityX) * 0.0002) + 0.2
UIView.transition(with: self, duration: animationDuration, options: UIViewAnimationOptions.curveEaseOut, animations: {
}, completion: { (Status) in
if Status{
self.animationFinished()
}
})
}
}
func animationFinished(){
if !unlocked{
self.reset()
}
}
//lock button animation (SUCCESS)
func unlock(){
UIView.transition(with: self, duration: 0.2, options: .curveEaseOut, animations: {
self.dragPoint.frame = CGRect(x: self.frame.size.width - self.dragPoint.frame.size.width, y: 0, width: self.dragPoint.frame.size.width, height: self.dragPoint.frame.size.height)
}) { (Status) in
if Status{
self.dragPointButtonLabel.text = self.buttonUnlockedText
self.imageView.isHidden = true
self.dragPoint.backgroundColor = self.buttonUnlockedColor
self.dragPointButtonLabel.textColor = self.buttonUnlockedTextColor
self.delegate?.buttonStatus(status: "Unlocked", sender: self)
}
}
}
//reset button animation (RESET)
func reset(){
UIView.transition(with: self, duration: 0.2, options: .curveEaseOut, animations: {
self.dragPoint.frame = CGRect(x: self.dragPointWidth - self.frame.size.width, y: 0, width: self.dragPoint.frame.size.width, height: self.dragPoint.frame.size.height)
}) { (Status) in
if Status{
self.dragPointButtonLabel.text = self.buttonText
self.imageView.isHidden = false
self.dragPoint.backgroundColor = self.dragPointColor
self.dragPointButtonLabel.textColor = self.dragPointTextColor
self.unlocked = false
//self.delegate?.buttonStatus("Locked")
}
}
}
}
|
[
-1
] |
2e8b661e54608ddda26710aecc9dfdce8f78dffe
|
e8de967e8c9ee7a7d100e9a1e81dcea084fb562b
|
/Source/Classes/GIFAnimatable.swift
|
974247e9928c501b9632ed2a37a2de555b5761fa
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
xsown/Gifu
|
d849964f2059fe91d50113ec68bb1dc24a8477e2
|
04e8c242bc728afd1a1743a96f242e848512346d
|
refs/heads/master
| 2020-03-29T08:59:18.834281 | 2018-09-21T10:10:56 | 2018-09-21T10:10:56 | 149,736,164 | 0 | 0 | null | 2018-09-21T08:47:00 | 2018-09-21T08:46:59 | null |
UTF-8
|
Swift
| false | false | 7,889 |
swift
|
import Foundation
import UIKit
/// The protocol that view classes need to conform to to enable animated GIF support.
public protocol GIFAnimatable: class {
/// Responsible for managing the animation frames.
var animator: Animator? { get set }
/// Notifies the instance that it needs display.
var layer: CALayer { get }
/// View frame used for resizing the frames.
var frame: CGRect { get set }
/// Content mode used for resizing the frames.
var contentMode: UIView.ContentMode { get set }
/// Multiple of speed, making gif playing faster or slower
var speed: Double { get set }
}
/// A single-property protocol that animatable classes can optionally conform to.
public protocol ImageContainer {
/// Used for displaying the animation frames.
var image: UIImage? { get set }
}
extension GIFAnimatable {
public var speed: Double {
get {
return animator?.speed ?? 1.0
}
set {
animator?.speed = newValue
}
}
}
extension GIFAnimatable where Self: ImageContainer {
/// Returns the intrinsic content size based on the size of the image.
public var intrinsicContentSize: CGSize {
return image?.size ?? CGSize.zero
}
}
extension GIFAnimatable {
/// Total duration of one animation loop
public var gifLoopDuration: TimeInterval {
return animator?.loopDuration ?? 0
}
/// Returns the active frame if available.
public var activeFrame: UIImage? {
return animator?.activeFrame()
}
/// Total frame count of the GIF.
public var frameCount: Int {
return animator?.frameCount ?? 0
}
/// Introspect whether the instance is animating.
public var isAnimatingGIF: Bool {
return animator?.isAnimating ?? false
}
/// Prepare for animation and start animating immediately.
///
/// - parameter imageName: The file name of the GIF in the main bundle.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
/// - parameter completionHandler: Completion callback function
public func animate(withGIFNamed imageName: String, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
animator?.animate(withGIFNamed: imageName,
size: frame.size,
contentMode: contentMode,
loopCount: loopCount,
completionHandler: completionHandler)
}
/// Prepare for animation and start animating immediately.
///
/// - parameter imageData: GIF image data.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
/// - parameter completionHandler: Completion callback function
public func animate(withGIFData imageData: Data, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
animator?.animate(withGIFData: imageData,
size: frame.size,
contentMode: contentMode,
loopCount: loopCount,
completionHandler: completionHandler)
}
/// Prepare for animation and start animating immediately.
///
/// - parameter imageURL: GIF image url.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
/// - parameter completionHandler: Completion callback function
public func animate(withGIFURL imageURL: URL, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
let session = URLSession.shared
let task = session.dataTask(with: imageURL) { (data, response, error) in
switch (data, response, error) {
case (.none, _, let error?):
print("Error downloading gif:", error.localizedDescription, "at url:", imageURL.absoluteString)
case (let data?, _, _):
DispatchQueue.main.async {
self.animate(withGIFData: data, loopCount: loopCount, completionHandler: completionHandler)
}
default: ()
}
}
task.resume()
}
/// Prepares the animator instance for animation.
///
/// - parameter imageName: The file name of the GIF in the main bundle.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
public func prepareForAnimation(withGIFNamed imageName: String,
loopCount: Int = 0,
completionHandler: (() -> Void)? = nil) {
animator?.prepareForAnimation(withGIFNamed: imageName,
size: frame.size,
contentMode: contentMode,
loopCount: loopCount,
completionHandler: completionHandler)
}
/// Prepare for animation and start animating immediately.
///
/// - parameter imageData: GIF image data.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
public func prepareForAnimation(withGIFData imageData: Data,
loopCount: Int = 0,
completionHandler: (() -> Void)? = nil) {
if var imageContainer = self as? ImageContainer {
imageContainer.image = UIImage(data: imageData)
}
animator?.prepareForAnimation(withGIFData: imageData,
size: frame.size,
contentMode: contentMode,
loopCount: loopCount,
completionHandler: completionHandler)
}
/// Prepare for animation and start animating immediately.
///
/// - parameter imageURL: GIF image url.
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
public func prepareForAnimation(withGIFURL imageURL: URL,
loopCount: Int = 0,
completionHandler: (() -> Void)? = nil) {
let session = URLSession.shared
let task = session.dataTask(with: imageURL) { (data, response, error) in
switch (data, response, error) {
case (.none, _, let error?):
print("Error downloading gif:", error.localizedDescription, "at url:", imageURL.absoluteString)
case (let data?, _, _):
DispatchQueue.main.async {
self.prepareForAnimation(withGIFData: data,
loopCount: loopCount,
completionHandler: completionHandler)
}
default: ()
}
}
task.resume()
}
/// Stop animating and free up GIF data from memory.
public func prepareForReuse() {
animator?.prepareForReuse()
}
/// Start animating GIF.
public func startAnimatingGIF() {
animator?.startAnimating()
}
/// Stop animating GIF.
public func stopAnimatingGIF() {
animator?.stopAnimating()
}
/// Whether the frame images should be resized or not. The default is `false`, which means that the frame images retain their original size.
///
/// - parameter resize: Boolean value indicating whether individual frames should be resized.
public func setShouldResizeFrames(_ resize: Bool) {
animator?.shouldResizeFrames = resize
}
/// Sets the number of frames that should be buffered. Default is 50. A high number will result in more memory usage and less CPU load, and vice versa.
///
/// - parameter frames: The number of frames to buffer.
public func setFrameBufferCount(_ frames: Int) {
animator?.frameBufferCount = frames
}
/// Updates the image with a new frame if necessary.
public func updateImageIfNeeded() {
if var imageContainer = self as? ImageContainer {
let container = imageContainer
imageContainer.image = activeFrame ?? container.image
} else {
layer.contents = activeFrame?.cgImage
}
}
}
extension GIFAnimatable {
/// Calls setNeedsDisplay on the layer whenever the animator has a new frame. Should *not* be called directly.
func animatorHasNewFrame() {
layer.setNeedsDisplay()
}
}
|
[
319277,
363221,
160216,
131610,
167100
] |
ec215a3a86ac7b2daef7e7afdd7d4d511a2f106b
|
9716cef0d11d5368bc4895d7a805145c32f930d0
|
/Source/SPPermission/SPPermissionType.swift
|
0189434f0ad4f4ba40757235cb353987867f6ee2
|
[
"MIT"
] |
permissive
|
damarte/SPPermission
|
4c67c6e017e43fc824e2bb579c24480f5d50a430
|
05a8b2f4411b15e3ac27ea497c97ec91643299da
|
refs/heads/master
| 2020-04-24T02:41:09.034889 | 2019-02-20T10:10:51 | 2019-02-20T10:10:51 | 169,044,982 | 0 | 0 |
MIT
| 2019-02-04T08:00:21 | 2019-02-04T08:00:20 | null |
UTF-8
|
Swift
| false | false | 3,530 |
swift
|
// The MIT License (MIT)
// Copyright © 2017 Ivan Vorobei ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import UIKit
@objc public enum SPPermissionType: Int {
case camera = 0
case photoLibrary = 1
case notification = 2
case microphone = 3
case calendar = 4
case contacts = 5
case reminders = 6
case speech = 7
@available(iOS, obsoleted: 11, renamed: "locationAlwaysAndWhenInUse")
case locationAlways = 8
case locationWhenInUse = 9
case locationAlwaysAndWhenInUse = 10
case motion = 11
case mediaLibrary = 12
var name: String {
switch self {
case .camera:
return "Camera"
case .photoLibrary:
return "Photo Library"
case .notification:
return "Notification"
case .microphone:
return "Microphone"
case .calendar:
return "Calendar"
case .contacts:
return "Contacts"
case .reminders:
return "Reminders"
case .speech:
return "Speech"
case .locationAlways:
return "Location"
case .locationWhenInUse:
return "Location"
case .locationAlwaysAndWhenInUse:
return "Location"
case .motion:
return "Motion"
case .mediaLibrary:
return "Media Library"
}
}
var usageDescriptionKey: String? {
switch self {
case .camera:
return "NSCameraUsageDescription"
case .photoLibrary:
return "NSPhotoLibraryUsageDescription"
case .notification:
return nil
case .microphone:
return "NSMicrophoneUsageDescription"
case .calendar:
return "NSCalendarsUsageDescription"
case .contacts:
return "NSContactsUsageDescription"
case .reminders:
return "NSRemindersUsageDescription"
case .speech:
return "NSSpeechRecognitionUsageDescription"
case .locationAlways:
return "NSLocationAlwaysUsageDescription"
case .locationWhenInUse:
return "NSLocationWhenInUseUsageDescription"
case .locationAlwaysAndWhenInUse:
return "NSLocationAlwaysAndWhenInUseUsageDescription"
case .motion:
return "NSMotionUsageDescription"
case .mediaLibrary:
return "NSAppleMusicUsageDescription"
}
}
}
|
[
241952,
241901
] |
45e4417b673952e1ee7f9a1649169caab6f50896
|
3d144a23e67c839a4df1c073c6a2c842508f16b2
|
/test/SILGen/reabstract.swift
|
75f40fbc823638586d1a732f3ff15d66a36d6ad9
|
[
"Apache-2.0",
"Swift-exception"
] |
permissive
|
apple/swift
|
c2724e388959f6623cf6e4ad6dc1cdd875fd0592
|
98ada1b200a43d090311b72eb45fe8ecebc97f81
|
refs/heads/main
| 2023-08-16T10:48:25.985330 | 2023-08-16T09:00:42 | 2023-08-16T09:00:42 | 44,838,949 | 78,897 | 15,074 |
Apache-2.0
| 2023-09-14T21:19:23 | 2015-10-23T21:15:07 |
C++
|
UTF-8
|
Swift
| false | false | 6,371 |
swift
|
// RUN: %target-swift-emit-silgen -module-name reabstract -Xllvm -sil-full-demangle %s | %FileCheck %s
// RUN: %target-swift-emit-sil -module-name reabstract -Xllvm -sil-full-demangle %s | %FileCheck %s --check-prefix=MANDATORY
func closureTakingOptional(_ fn: (Int?) -> ()) {}
closureTakingOptional({ (_: Any) -> () in })
// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sypIgn_SiSgIegy_TR :
// CHECK: [[ANYADDR:%.*]] = alloc_stack $Any
// CHECK: [[OPTADDR:%.*]] = init_existential_addr [[ANYADDR]] : $*Any, $Optional<Int>
// CHECK: store %0 to [trivial] [[OPTADDR]] : $*Optional<Int>
// CHECK: apply %1([[ANYADDR]]) : $@noescape @callee_guaranteed (@in_guaranteed Any) -> ()
func takeFn<T>(_ f : (T) -> T?) {}
func liftOptional(_ x : Int) -> Int? { return x }
func test0() {
takeFn(liftOptional)
}
// CHECK: sil hidden [ossa] @$s10reabstract5test0yyF : $@convention(thin) () -> () {
// Emit a generalized reference to liftOptional.
// TODO: just emit a globalized thunk
// CHECK: reabstract.liftOptional
// CHECK-NEXT: [[T1:%.*]] = function_ref @$s10reabstract12liftOptional{{[_0-9a-zA-Z]*}}F
// CHECK-NEXT: [[T2:%.*]] = thin_to_thick_function [[T1]]
// CHECK-NEXT: [[CVT:%.*]] = convert_escape_to_noescape [not_guaranteed] [[T2]]
// CHECK-NEXT: reabstraction thunk
// CHECK-NEXT: [[T3:%.*]] = function_ref [[THUNK:@.*]] :
// CHECK-NEXT: [[T4:%.*]] = partial_apply [callee_guaranteed] [[T3]]([[CVT]])
// CHECK-NEXT: [[T5:%.*]] = convert_function [[T4]]
// CHECK-NEXT: [[CVT:%.*]] = convert_escape_to_noescape [not_guaranteed] [[T5]]
// CHECK: destroy_value [[T5]]
// CHECK: [[T0:%.*]] = function_ref @$s10reabstract6takeFn{{[_0-9a-zA-Z]*}}F
// CHECK-NEXT: apply [[T0]]<Int>([[CVT]])
// CHECK-NEXT: destroy_value [[CVT]]
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return
// CHECK-NEXT: } // end sil function '$s10reabstract5test0yyF'
// MANDATORY: sil hidden @$s10reabstract5test0yyF : $@convention(thin) () -> () {
// Emit a generalized reference to liftOptional.
// TODO: just emit a globalized thunk
// MANDATORY: reabstract.liftOptional
// MANDATORY-NEXT: [[T1:%.*]] = function_ref @$s10reabstract12liftOptional{{[_0-9a-zA-Z]*}}F
// MANDATORY-NEXT: [[T2:%.*]] = thin_to_thick_function [[T1]]
// MANDATORY-NEXT: strong_retain [[T2]]
// MANDATORY-NEXT: [[CVT:%.*]] = convert_escape_to_noescape [[T2]]
// MANDATORY-NEXT: //{{.*}}reabstraction thunk
// MANDATORY-NEXT: [[T3:%.*]] = function_ref [[THUNK:@.*]] :
// MANDATORY-NEXT: [[T4:%.*]] = partial_apply [callee_guaranteed] [on_stack] [[T3]]([[CVT]])
// MANDATORY-NEXT: [[T4_1:%.*]] = mark_dependence [[T4]]
// MANDATORY-NEXT: [[T5:%.*]] = convert_function [[T4_1]]
// MANDATORY-NEXT: // function_ref
// MANDATORY-NEXT: [[T0:%.*]] = function_ref @$s10reabstract6takeFn{{[_0-9a-zA-Z]*}}F
// MANDATORY-NEXT: apply [[T0]]<Int>([[T5]])
// MANDATORY-NEXT: strong_release [[T2]]
// MANDATORY-NEXT: dealloc_stack [[T4]] : $@noescape @callee_guaranteed (@in_guaranteed Int) -> @out Optional<Int>
// MANDATORY-NEXT: tuple ()
// MANDATORY-NEXT: return
// MANDATORY-NEXT: } // end sil function '$s10reabstract5test0yyF'
// CHECK: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] [[THUNK]] :
// CHECK: [[T0:%.*]] = load [trivial] %1 : $*Int
// CHECK-NEXT: [[T1:%.*]] = apply %2([[T0]])
// CHECK-NEXT: store [[T1]] to [trivial] %0
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return
// CHECK-LABEL: sil hidden [ossa] @$s10reabstract10testThrowsyyypF
// CHECK: function_ref @$sytIegr_Ieg_TR
// CHECK: function_ref @$syts5Error_pIegrzo_sAA_pIegzo_TR
func testThrows(_ x: Any) {
_ = x as? () -> ()
_ = x as? () throws -> ()
}
// Make sure that we preserve inout-ness when lowering types with maximum
// abstraction level -- <rdar://problem/21329377>
class C {}
struct Box<T> {
let t: T
}
func notFun(_ c: inout C, i: Int) {}
func testInoutOpaque(_ c: C, i: Int) {
var c = c
let box = Box(t: notFun)
box.t(&c, i)
}
// CHECK-LABEL: sil hidden [ossa] @$s10reabstract15testInoutOpaque_1iyAA1CC_SitF
// CHECK: function_ref @$s10reabstract6notFun_1iyAA1CCz_SitF
// CHECK: thin_to_thick_function {{%[0-9]+}}
// CHECK: function_ref @$s10reabstract1CCSiIegly_ACSiytIeglnr_TR
// CHECK: partial_apply
// CHECK: store
// CHECK: [[CLOSURE:%.*]] = struct_extract {{.*}}, #Box.t
// CHECK: [[CLOSURE1:%.*]] = copy_value [[CLOSURE]]
// CHECK: [[CLOSURE2:%.*]] = begin_borrow [[CLOSURE1]]
// CHECK: apply [[CLOSURE2]]
// CHECK: } // end sil function '$s10reabstract15testInoutOpaque_1iyAA1CC_SitF'
// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s10reabstract1CCSiIegly_ACSiytIeglnr_TR : $@convention(thin) (@inout C, @in_guaranteed Int, @guaranteed @callee_guaranteed (@inout C, Int) -> ()) -> @out () {
// Same behavior as above with other ownership qualifiers.
func evenLessFun(_ s: __shared C, _ o: __owned C) {}
// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s10reabstract1CCACIeggx_A2CytIegnir_TR : $@convention(thin) (@in_guaranteed C, @in C, @guaranteed @callee_guaranteed (@guaranteed C, @owned C) -> ()) -> @out ()
func testSharedOwnedOpaque(_ s: C, o: C) {
let box = Box(t: evenLessFun)
box.t(s, o)
}
// Make sure that when we generate the reabstraction thunk from Klass -> P, we
// pass off the value at +1.
// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s10reabstract1P_pIegg_xIegg_AaBRzlTR : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed τ_0_0, @guaranteed @callee_guaranteed (@guaranteed any P) -> ()) -> () {
// CHECK: bb0([[ARG:%.*]] : @guaranteed $τ_0_0,
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
// CHECK: [[EXISTENTIAL:%.*]] = init_existential_ref [[ARG_COPY]]
// CHECK: [[BORROWED_EXISTENTIAL:%.*]] = begin_borrow [[EXISTENTIAL]]
// CHECK: apply {{%.*}}([[BORROWED_EXISTENTIAL]])
// CHECK: end_borrow [[BORROWED_EXISTENTIAL]]
// CHECK: destroy_value [[EXISTENTIAL]]
// CHECK: } // end sil function '$s10reabstract1P_pIegg_xIegg_AaBRzlTR'
protocol P : class {}
class Klass : P { }
extension P { static func crash(setup: ((Self) -> ())?) {} }
func checkInitExistentialThunk() -> P? {
let cls : P.Type = Klass.self
cls.crash(setup: { (arg: P) -> () in })
return nil
}
|
[
85761
] |
b7e7042beb9e00840aba772e5ff41900ab53ea7b
|
8136f5f3d8f6bab9ec230b690dab5fc5142861a4
|
/BitmovinAnalyticsCollector/Classes/AVPlayer/AVPlayerCollector.swift
|
e4cd59223bcf6ca00832fed0859f065e86268c34
|
[
"LicenseRef-scancode-generic-cla",
"MIT"
] |
permissive
|
nsillik/bitmovin-analytics-collector-ios
|
653022781fa4e1c13ebaa1144a17836b43c09449
|
e08ba75f338610c5b58363335f9225a671fdbc3d
|
refs/heads/main
| 2023-04-15T18:02:06.211575 | 2021-04-28T16:57:47 | 2021-04-28T16:57:47 | 362,545,055 | 0 | 0 |
MIT
| 2021-04-28T16:56:03 | 2021-04-28T16:56:02 | null |
UTF-8
|
Swift
| false | false | 565 |
swift
|
import AVKit
import Foundation
public class AVPlayerCollector: BitmovinAnalyticsInternal {
public override init(config: BitmovinAnalyticsConfig) {
super.init(config: config)
}
/**
* Attach a player instance to this analytics plugin. After this is completed, BitmovinAnalytics
* will start monitoring and sending analytics data based on the attached player instance.
*/
public func attachPlayer(player: AVPlayer) {
attach(adapter: AVPlayerAdapter(player: player, config: config, stateMachine: stateMachine))
}
}
|
[
-1
] |
5bd42a33f97726858159ad85a583b724e3ff7395
|
8cc10bec70203d9cca0b1e2887242eac124bc7c6
|
/BlueLight/BlueLight/Controllers/Control/AlarmAddController.swift
|
2561710d36ffd139d61ace54719f0c0a1554b558
|
[] |
no_license
|
luoheng1994/BlueToothLight
|
b8e28d973c3906f6276c7bc2e9ea10792edb8763
|
539514180d9e0988cd5c7d62b77a3d0ca85fbf2c
|
refs/heads/master
| 2020-04-06T09:25:34.416149 | 2018-11-13T08:12:00 | 2018-11-13T08:12:00 | 157,342,292 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,362 |
swift
|
//
// AlarmAddController.swift
// BlueLight
//
// Created by Rail on 7/12/16.
// Copyright © 2016 Rail. All rights reserved.
//
import UIKit
let DisplayWeeks = ["周日","周一","周二","周三","周四","周五","周六"]
class AlarmAddController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var sender:ColorSendAdapter!
let datePicker = UIDatePicker()
let tableView = UITableView(frame: CGRectZero, style: .Plain)
var selectWeeks:[Int] = []
var action:AlarmAction = .On
override func viewDidLoad() {
super.viewDidLoad()
title = "定时添加"
view.backgroundColor = UIColor.whiteColor()
navigationItem.backBarButtonItem = UIBarButtonItem(title: "返回", style: .Plain, target: nil, action: nil)
datePicker.datePickerMode = .Time
datePicker.date = NSDate()
datePicker.tintColor = UIColor.colorWithHex(0xDFE8EE)
datePicker.frame = CGRect(x: 0, y: 74, width: view.frame.width, height: 216)
datePicker.locale = NSLocale(localeIdentifier: "en_US")
view.addSubview(datePicker)
tableView.frame = CGRect(x: 0, y: 300, width: view.frame.width, height: 82)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorColor = UIColor.colorWithHex(0xDFE8EE)
tableView.bounces = false
view.addSubview(tableView)
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "保存", style: .Plain, target: self, action: #selector(AlarmAddController.doSave))
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AlarmAddController.weekPicked(_:)), name: NotificationWeekPicked, object: nil)
}
func weekPicked(notification:NSNotification) {
selectWeeks = notification.userInfo?["weeks"] as! [Int]
tableView.reloadData()
}
func doSave() {
let date = datePicker.date
if selectWeeks.count > 0 {
sender.setAlarm(selectWeeks, date: date, action: action, index: 0x00)
}else {
sender.setAlarm(date, action: action, index: 0x00)
}
Utils.instance.showLoading("保存中", showBg: true)
performSelector(#selector(AlarmAddController.hideLoading), withObject: nil, afterDelay: 1.5)
}
func hideLoading() {
Utils.instance.hideLoading()
Utils.instance.showTip("保存成功")
navigationController?.popViewControllerAnimated(true)
}
//MARK: - UITableView
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 35
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .Value1, reuseIdentifier: "Value1 cell")
if indexPath.row == 0 {
cell.textLabel?.text = "重复"
cell.detailTextLabel?.text = displayWeek()
}else if indexPath.row == 1 {
cell.textLabel?.text = "动作"
cell.detailTextLabel?.text = action == .On ? "开灯" : "关灯"
}
cell.accessoryType = .DisclosureIndicator
cell.selectionStyle = .None
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
let ctl = WeekPickerController(style: .Grouped)
ctl.selectIndexs = selectWeeks
navigationController?.pushViewController(ctl, animated: true)
}else {
let alert = UIAlertController(title: "请选择动作", message: "选择一个定时应该执行动作", preferredStyle: .ActionSheet)
alert.addAction(UIAlertAction(title: "开灯", style: .Default, handler: { (action) in
self.action = .On
self.tableView.reloadData()
}))
alert.addAction(UIAlertAction(title: "关灯", style: .Default, handler: { (action) in
self.action = .Off
self.tableView.reloadData()
}))
alert.addAction(UIAlertAction(title: "取消", style: .Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
}
}
func displayWeek() -> String{
if selectWeeks.count == 0 {
return "永不"
}else if selectWeeks.count == 1 {
return DisplayWeeks[selectWeeks.first!]
}else if selectWeeks.count == 2 && selectWeeks.contains(0) && selectWeeks.contains(6){
return "周末"
}else if selectWeeks.count == 5 && !selectWeeks.contains(0) && !selectWeeks.contains(6){
return "工作日"
}else if selectWeeks.count == 7 {
return "每天"
}
var weekStr = ""
for index in selectWeeks.sort() {
let week = DisplayWeeks[index]
weekStr = weekStr + week + " "
}
return weekStr
}
}
|
[
-1
] |
239da65abd0a129770ac583d8456efc0f8e6d8cf
|
17e6a7ecda8f463cea519376cedab2326f53064f
|
/serverlessapp/AppDelegate.swift
|
5ac4610b3eaf4cfa63e96add6124d1a2abaa1ecb
|
[] |
no_license
|
marlonburnett/serverlessapps-thedevconf2019-recife
|
b0add2d2dba2f85689502a4941b34fa610317230
|
12fed5ad46c964e7a8c2b69e1ca4ec54ff4ce1f0
|
refs/heads/master
| 2020-08-09T19:51:46.565971 | 2019-10-11T00:07:15 | 2019-10-11T00:07:15 | 214,160,605 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,232 |
swift
|
//
// AppDelegate.swift
// serverlessapp
//
// Created by Marlon Morato on 09/10/19.
// Copyright © 2019 Marlon Burnett. All rights reserved.
//
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
|
[
229380,
229383,
229385,
294924,
229388,
229391,
327695,
229394,
229397,
229399,
229402,
229405,
229408,
229415,
229417,
327722,
237613,
229422,
360496,
229426,
237618,
229428,
286774,
286776,
319544,
286778,
204856,
229432,
352318,
286791,
237640,
286797,
237646,
311375,
196692,
319573,
311383,
319590,
311400,
303212,
131192,
237693,
303230,
327814,
303241,
131209,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
286916,
286924,
286926,
319694,
131281,
155872,
319716,
237807,
303345,
286962,
303347,
229622,
327930,
237826,
319751,
286987,
319757,
286999,
319770,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
319809,
319810,
319814,
311623,
319818,
311628,
229709,
319822,
287054,
229717,
196969,
139638,
213367,
106872,
319872,
311683,
311693,
65943,
319898,
311719,
139689,
311728,
311741,
319938,
319945,
188895,
172512,
287202,
172520,
319978,
172526,
311791,
172529,
319989,
172534,
180727,
311804,
287230,
303617,
287234,
172550,
303623,
172552,
320007,
172558,
303632,
303637,
172572,
172577,
295459,
172581,
295461,
172591,
172598,
172607,
172609,
172612,
172614,
213575,
172618,
303690,
33357,
303696,
172634,
262752,
254563,
172644,
311911,
172655,
172656,
352880,
295538,
172660,
287349,
287355,
295553,
172675,
295557,
311942,
303751,
352905,
311946,
287371,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
172702,
287390,
303773,
172705,
287394,
172707,
303780,
287398,
287400,
172714,
295595,
189102,
172721,
287409,
66227,
189114,
287419,
303804,
328381,
287423,
328384,
172737,
287427,
312006,
172748,
287436,
107212,
172751,
287440,
295633,
172755,
303827,
287450,
303835,
189149,
303838,
312035,
295654,
230128,
312048,
312050,
189169,
303871,
230146,
328453,
230154,
312077,
295695,
295701,
230169,
295707,
328476,
295710,
295720,
303914,
230202,
312124,
328508,
222018,
295755,
287569,
303959,
230237,
230241,
303976,
336744,
303981,
303985,
303987,
328563,
303991,
303997,
295806,
295808,
295813,
304005,
320391,
304007,
304009,
304011,
304013,
295822,
189329,
295825,
304019,
189331,
58262,
304023,
304027,
304042,
213931,
230327,
304055,
287675,
197564,
230334,
304063,
304065,
156612,
197580,
312272,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
295945,
230413,
320528,
140312,
295961,
238620,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
238658,
336964,
132165,
296004,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
361576,
205931,
205934,
312432,
337018,
115836,
66690,
222340,
205968,
296084,
238745,
304285,
238756,
222377,
165035,
238766,
165038,
230576,
238770,
304311,
230592,
312518,
230600,
230607,
148690,
320727,
304348,
304354,
296163,
320740,
304360,
320748,
304370,
296189,
320771,
312585,
296202,
296205,
230674,
320786,
230677,
214294,
296213,
320792,
230681,
296215,
230689,
173350,
312622,
296243,
312630,
296253,
230718,
296255,
312639,
296259,
296262,
230727,
238919,
296264,
320840,
296267,
296271,
312663,
222556,
337244,
230752,
312676,
230760,
148843,
410987,
230763,
230768,
296305,
312692,
230773,
304505,
304506,
181626,
181631,
312711,
312712,
296331,
288140,
288144,
304533,
288162,
288164,
304555,
173488,
288176,
312755,
312759,
337335,
288185,
222652,
312766,
173507,
222665,
230860,
312783,
288208,
230865,
148946,
222676,
329177,
239070,
288229,
288232,
296435,
288244,
288250,
296446,
321022,
402942,
148990,
296450,
206336,
230916,
230919,
230923,
304651,
304653,
222752,
108066,
296486,
296488,
157229,
239152,
230961,
157236,
288320,
288325,
124489,
288338,
288344,
239194,
403039,
312938,
116354,
419489,
321195,
296622,
321200,
337585,
296634,
296637,
419522,
313027,
419525,
206536,
206539,
206541,
206543,
263888,
313044,
321239,
313052,
18140,
288478,
313055,
419555,
321252,
313066,
288494,
313073,
321266,
419570,
288499,
288502,
288510,
124671,
67330,
198405,
288519,
198416,
296723,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
321336,
296767,
288576,
345921,
304968,
173907,
313171,
313176,
321381,
296812,
313201,
305028,
247688,
124817,
239510,
124827,
214940,
247709,
214944,
321458,
124853,
214966,
296890,
10170,
288700,
296894,
190403,
296900,
337862,
165831,
296921,
354265,
354270,
239586,
313320,
354281,
124913,
165876,
321528,
239612,
313340,
288764,
239617,
313347,
288773,
313358,
305176,
321560,
313371,
305191,
223273,
313386,
124978,
215090,
124980,
288824,
288826,
321595,
313406,
288831,
288836,
215123,
288859,
280669,
149599,
280671,
149601,
321634,
149603,
329830,
280681,
280687,
149618,
215154,
313458,
313464,
329850,
321659,
288895,
321670,
215175,
288909,
141455,
280725,
313498,
100520,
280747,
288947,
321717,
313548,
321740,
313557,
338147,
280804,
125171,
182517,
280825,
280831,
125187,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280891,
289087,
305480,
239944,
239947,
305485,
305489,
248153,
354653,
313700,
313705,
190832,
313720,
313731,
199051,
240011,
289166,
240017,
297363,
240021,
297365,
297372,
297377,
289186,
289201,
240052,
289207,
289210,
305594,
281024,
166378,
305647,
174580,
240124,
305662,
305664,
240129,
305666,
305668,
223749,
240132,
223752,
150025,
338440,
223757,
223763,
223765,
322074,
150066,
158266,
289342,
322115,
338528,
338532,
199273,
19053,
158317,
313973,
297594,
158347,
264845,
314003,
240275,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
174764,
314029,
314033,
240309,
133817,
314045,
314047,
314051,
297671,
158409,
256716,
289493,
363234,
289513,
289522,
289532,
322303,
322310,
264969,
322314,
322318,
322341,
215850,
289593,
289601,
240458,
240468,
322393,
297818,
224110,
207733,
207737,
158596,
183172,
338823,
322440,
314249,
183184,
289687,
240535,
297883,
289694,
289696,
289700,
289712,
281529,
289724,
183260,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
314372,
330764,
175134,
322599,
322610,
314421,
281654,
314427,
314433,
314441,
322642,
314456,
314461,
248995,
306341,
306344,
306347,
322734,
306354,
199877,
289997,
249045,
363742,
363745,
330988,
216303,
322801,
388350,
257302,
363802,
199976,
199978,
314671,
298292,
298294,
216376,
380226,
224587,
224594,
216404,
306517,
150870,
314714,
314718,
265568,
314723,
150890,
306539,
314732,
314736,
290161,
216436,
306549,
314743,
306552,
290171,
314747,
306555,
298365,
290174,
224641,
298372,
314756,
224647,
298377,
314763,
314768,
224657,
306581,
314773,
314779,
314785,
314793,
241068,
241070,
241072,
150966,
306618,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
191985,
290291,
241142,
191992,
290298,
151036,
290302,
290305,
306694,
192008,
323084,
290321,
290325,
241175,
290332,
241181,
290344,
306731,
290349,
290351,
290356,
28219,
224849,
306778,
314979,
323176,
224875,
241260,
323181,
315016,
290445,
175770,
298651,
282269,
323229,
298655,
323231,
61092,
306856,
323260,
323266,
241362,
306904,
52959,
241380,
323318,
306945,
241412,
323333,
323345,
323349,
315167,
315169,
315174,
323367,
241448,
315176,
241450,
306988,
306991,
315184,
323376,
315190,
241464,
159545,
298811,
118593,
307009,
413506,
307012,
298822,
315211,
307027,
315221,
315223,
241496,
241498,
307035,
307040,
110433,
241509,
110438,
110445,
315249,
315253,
315255,
339838,
315267,
241544,
241546,
241548,
298896,
298898,
241556,
298901,
241560,
241563,
241565,
241567,
241569,
241574,
241581,
241583,
323504,
241586,
241588,
241590,
241592,
241598,
290751,
241600,
241605,
241610,
298975,
241632,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
299003,
241661,
299006,
315396,
241669,
315397,
290835,
241693,
241701,
102438,
217127,
323630,
290877,
315463,
315466,
192589,
307278,
192596,
307287,
307290,
217179,
315482,
192605,
315483,
233567,
299105,
217188,
299109,
307303,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
323700,
299126,
233591,
299136,
307329,
315524,
307338,
241813,
307352,
299164,
241821,
299167,
315552,
315557,
184486,
307370,
307372,
307374,
307376,
299185,
323763,
184503,
307385,
307386,
258235,
307388,
307390,
307394,
299204,
307396,
184518,
307399,
323784,
233679,
307409,
307411,
299225,
233701,
307432,
323854,
291104,
307508,
315701,
332086,
307510,
307512,
307515,
307518,
282942,
323917,
110926,
233808,
323921,
315733,
323926,
315739,
323932,
299357,
242018,
242024,
299373,
250231,
242043,
315771,
299391,
291202,
299398,
242057,
291212,
299405,
291222,
315801,
242075,
61855,
291231,
291241,
127405,
291247,
299440,
127407,
127413,
291254,
291260,
127424,
299457,
127434,
315856,
315860,
283095,
299481,
176605,
242143,
291299,
127463,
242152,
291305,
127466,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
135689,
233994,
127500,
233998,
127506,
234006,
127511,
152087,
234010,
135707,
242202,
135710,
242206,
242208,
291361,
242220,
291378,
152118,
234041,
70213,
242250,
111193,
242275,
299620,
242279,
184952,
135805,
135808,
373383,
299655,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
135839,
225954,
299684,
135844,
242343,
242345,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
299726,
299740,
201444,
234219,
316151,
242431,
234242,
299778,
242436,
234246,
242443,
234252,
242445,
291601,
234258,
242450,
242452,
201496,
234264,
234266,
234269,
234272,
152355,
299814,
234278,
234281,
234287,
185138,
234296,
160572,
234302,
234307,
316233,
316235,
234319,
242511,
234324,
185173,
201557,
308063,
234336,
242530,
349027,
234341,
234344,
234347,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234364,
291711,
291714,
234370,
291716,
234373,
316294,
308105,
234390,
324504,
234393,
209818,
308123,
324508,
291742,
234401,
291748,
234405,
291750,
324518,
324520,
324522,
234410,
291756,
291754,
324527,
291760,
234417,
201650,
324531,
234422,
324536,
275384,
291773,
242623,
324544,
234431,
234434,
324546,
324548,
234437,
234443,
291788,
234446,
234449,
234452,
234455,
234464,
234467,
168935,
324585,
234478,
316400,
234481,
316403,
234485,
234487,
324599,
316416,
234496,
308231,
234504,
234507,
300054,
316439,
234520,
234519,
234526,
234528,
300066,
300069,
234535,
234537,
234540,
234546,
300085,
234549,
234553,
234558,
316479,
234561,
316483,
160835,
234563,
308291,
316491,
234572,
300108,
234574,
300115,
242777,
234593,
234597,
300133,
300139,
234605,
160879,
234610,
300148,
398455,
144506,
234620,
234629,
234634,
177293,
234640,
234643,
308373,
324757,
234647,
234648,
234650,
308379,
300189,
324766,
119967,
234653,
324768,
242852,
300197,
234661,
177318,
234667,
316596,
308414,
234687,
300223,
300226,
308418,
234692,
300229,
308420,
308422,
283844,
300234,
283850,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
300263,
300265,
300267,
300270,
300272,
300278,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
161027,
300292,
300294,
275719,
234760,
177419,
300299,
242957,
300301,
275725,
349451,
177424,
349464,
415009,
300344,
243003,
300357,
283973,
283983,
316758,
357722,
316766,
316768,
292197,
316774,
243046,
218473,
136562,
324978,
333178,
275836,
316803,
316806,
316811,
316814,
300433,
234899,
300436,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
144814,
144820,
374196,
292279,
144826,
144830,
144832,
144837,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
292329,
300523,
300527,
308720,
292338,
316917,
292343,
300537,
316933,
316947,
308757,
308762,
316959,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
194101,
284213,
316983,
194103,
284215,
308790,
284218,
284223,
284226,
284228,
243268,
284231,
284234,
366155,
317004,
284238,
284241,
194130,
284243,
300628,
284245,
292433,
284247,
317015,
235097,
243290,
284249,
300638,
292452,
292454,
292458,
292461,
284272,
284274,
284278,
292470,
292473,
284283,
284286,
292479,
284288,
284290,
325250,
284292,
292485,
284297,
317066,
284299,
317068,
284301,
276109,
284303,
284306,
284308,
284312,
284316,
284320,
284327,
284329,
317098,
284331,
284333,
284335,
300726,
284343,
284346,
284350,
358080,
284354,
358083,
284358,
358089,
284362,
284365,
284368,
284370,
358098,
284372,
317138,
284377,
358114,
358116,
317158,
358119,
325353,
358122,
358126,
358128,
358133,
358135,
358138,
300795,
358140,
358142,
358146,
317187,
317189,
317191,
300816,
300819,
317207,
300828,
300830,
300832,
325408,
300834,
317221,
358183,
300845,
243504,
300850,
325436,
358206,
366406,
292681,
153417,
358224,
178006,
317271,
292700,
317279,
292715,
300912,
292721,
300915,
292729,
317306,
292734,
325512,
317332,
358292,
284564,
399252,
350106,
284572,
358312,
317353,
292784,
358326,
358330,
301009,
301011,
301013,
292823,
358360,
301017,
301015,
292828,
153568,
292839,
292843,
178161,
325624,
317435,
317446,
350218,
350222,
317456,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
243779,
325700,
292934,
243785,
350293,
350295,
309337,
350299,
350302,
350304,
178273,
309346,
194660,
350308,
309350,
309348,
292968,
309352,
309354,
301163,
350313,
350316,
301167,
350321,
350325,
252022,
350328,
292985,
292989,
301185,
317570,
350339,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
153765,
350375,
350379,
350381,
350383,
350385,
350387,
350389,
350395,
350397,
350399,
350402,
301252,
350406,
301258,
309450,
309455,
309462,
301272,
194780,
309468,
309471,
317672,
317674,
325867,
243948,
309491,
309494,
243960,
325910,
309530,
342298,
211232,
317729,
211241,
325937,
325943,
211260,
235853,
235858,
391523,
293227,
293232,
186744,
211324,
285061,
366983,
317833,
317853,
317858,
342434,
317864,
235955,
293304,
293314,
309707,
317910,
293336,
235996,
317917,
293343,
358880,
293352,
236013,
293364,
301562,
317951,
309764,
301575,
121352,
293387,
342541,
113167,
309779,
317971,
309781,
227882,
309804,
236082,
23094,
219714,
301636,
318020,
301639,
301643,
309844,
309849,
326244,
318055,
309871,
121458,
309885,
309888,
301706,
318092,
326285,
334476,
318094,
318108,
318110,
137889,
383658,
318128,
293555,
318132,
318144,
342745,
137946,
342747,
342749,
113378,
342760,
56043,
56059,
310015,
310020,
310029,
293659,
326430,
285474,
293666,
318248,
318253,
301876,
293685,
301880,
301884,
310080,
293706,
310100,
301911,
301921,
236397,
162671,
326514,
310134,
236408,
15224,
416639,
416640,
113538,
310147,
416648,
39817,
187274,
301972,
424853,
277411,
310179,
293798,
293802,
236460,
293817,
293820,
203715,
326603,
342994,
318442,
228332,
326638,
351217,
318450,
293876,
293877,
285686,
302073,
121850,
293882,
302075,
293899,
293908,
293917,
293939,
318516,
310336,
293956,
293960,
310344,
203857,
293971,
310355,
310359,
236632,
138332,
203872,
203879,
310376,
228460,
318573,
203886,
367737,
302205,
392326,
294026,
302218,
162964,
384148,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
285862,
302248,
64682,
294063,
302258,
294072,
318651,
318657,
244930,
302275,
130244,
302277,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
310486,
302296,
384222,
310498,
318698,
302315,
294132,
138485,
204026,
64768,
310531,
130345,
285999,
318773,
318776,
286010,
417086,
302403,
384328,
294221,
294223,
326991,
294246,
327015,
310632,
327017,
351594,
351607,
310648,
310651,
310657,
351619,
294276,
310659,
327046,
253320,
310665,
318858,
310672,
351633,
310689,
130468,
310703,
310710,
130486,
310712,
310715,
302526,
228799,
302534,
310727,
245191,
302541,
302543,
310737,
310749,
310755,
310764,
310772,
40440,
212472,
40443,
286203,
310780,
40448,
286214,
302603,
302614,
302617,
302621,
286240,
146977,
187939,
40484,
40486,
286246,
294440,
40488,
294439,
294443,
40491,
294445,
245288,
310831,
40499,
40502,
212538,
40507,
40511,
40513,
327240,
40521,
286283,
40525,
40527,
212560,
400976,
40533,
40537,
40539,
40541,
40544,
40548,
40550,
40552,
286312,
40554,
310892,
40557,
40560,
294521,
343679,
294537,
310925,
302740,
179870,
327333,
229030,
302764,
319153,
319163,
302781,
294601,
302793,
343757,
212690,
319187,
286420,
286425,
319194,
294625,
294634,
302838,
319226,
286460,
302852,
278277,
302854,
294664,
311048,
319243,
311053,
302862,
319251,
294682,
188199,
294701,
319280,
319290,
229192,
302925,
188247,
188252,
237409,
294776,
360317,
294785,
327554,
360322,
40851,
237470,
319390,
40865,
319394,
311209,
180142,
343983,
188340,
40886,
294844,
294847,
237508,
393177,
294876,
294879,
393190,
294890,
311279,
237555,
311283,
237562
] |
110b563ddcf5be50b9d0025deae2cbbcf852a2ba
|
ecfce91d691709333fae47124ac3a87cf6bd2642
|
/Sources/CommandLineTools/List.swift
|
114521e90493a887f59b4d7252a3fb363990fa4c
|
[
"MIT"
] |
permissive
|
Dev1an/ImageExtractor
|
5dfa18ca2569ab5d89916c4bd154f156f6a3839e
|
38abfed5822f8c042770fb0667d1b51af1879a19
|
refs/heads/main
| 2023-08-02T16:22:39.302591 | 2021-09-30T13:31:12 | 2021-09-30T13:31:12 | 366,094,990 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 940 |
swift
|
//
// File.swift
//
//
// Created by Damiaan on 10/05/2021.
//
import Foundation
import ArgumentParser
import ImageExtractor
let pageOptionHelp: ArgumentHelp = "A 0-based index of the pages you want to extract images from"
extension MainTool {
struct List: ParsableCommand {
@Argument(help: "The file URL for the PDF input", transform: URL.init(fileURLWithPath:))
var input: URL
@Option(name: [.short, .long], parsing: .upToNextOption, help: pageOptionHelp)
var pages = [Int]()
func run() throws {
let pdf = try pdfDocument(from: input)
let pageIndices = pages.isEmpty ? AnySequence(0 ..< pdf.pageCount) : AnySequence(pages)
for index in pageIndices {
if let page = pdf.page(at: index) {
try extractImages(from: page) { (image, name) in
print("Page \(index):", name, image, to: &standardOutput)
}
} else {
print("Cannot read page \(index)", to: &standardError)
}
}
}
}
}
|
[
-1
] |
22673918ed56acdacf036fdc1e54bc9e356a1cf1
|
405cff0548fc805ea596bfbc85c67da3fce1974a
|
/DouYuZB/Class/Main/View/PageContentView.swift
|
a8a228d0813837f3ccbc54beaa9a5796056b57e6
|
[
"MIT"
] |
permissive
|
iambryanshen/DouYuZB
|
8f6579871148b48b8a2a8866114adfdb77c5f1e3
|
86e692bc03dcfc0837c16678d12028c9aefddd66
|
refs/heads/master
| 2021-09-07T20:10:47.529667 | 2018-02-28T12:08:44 | 2018-02-28T12:08:44 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,413 |
swift
|
//
// PageContentView.swift
// DouYuZB
//
// Created by BrianShen on 17/3/30.
// Copyright © 2017年 brianshen. All rights reserved.
//
import UIKit
// MARK:- 代理方法通过HomeViewController让titleLabel同步选中
protocol PageContentViewDelegate : class {
func pageContentView(contentView: PageContentView, progress: CGFloat, sourceIndex: Int, targetIndex: Int)
}
// MARK:- 定义常量
private let collectionViewCellID = "collectionViewCellID"
// MARK:- 定义类
class PageContentView: UIView {
// MARK:- 定义属性
fileprivate var childVCs : [UIViewController]
fileprivate var parentVC : UIViewController?
fileprivate var startOffsetX : CGFloat = 0
weak var delegate : PageContentViewDelegate? //代理
fileprivate var isForbidScrollDelegate : Bool = false //禁止ScrollDelegate
// MARK:- 懒加载属性
fileprivate lazy var collectionView : UICollectionView = {[weak self] in
//1. 创建布局
let layout = UICollectionViewFlowLayout()
layout.itemSize = (self?.bounds.size)!
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.scrollDirection = .horizontal
//2. 创建collectionView
let collectionView : UICollectionView = UICollectionView(frame: self!.bounds, collectionViewLayout: layout)
collectionView.bounces = false //边缘弹回效果
collectionView.isPagingEnabled = true //分页效果
collectionView.dataSource = self
collectionView.delegate = self
//注册collectionViewCell
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: collectionViewCellID)
return collectionView
}()
// MARK:- 自定义构造方法
init(frame: CGRect, childVCs: [UIViewController], parentVC : UIViewController?) {
//把外界传入的控制器保存到属性中
self.childVCs = childVCs
self.parentVC = parentVC
super.init(frame: frame)
//设置UI界面
setupUI()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
// MARK:- 设置UI界面
extension PageContentView {
func setupUI() {
for childVC in childVCs {
self.parentVC?.addChildViewController(childVC)
}
//添加UICollectionView
addSubview(collectionView)
}
}
// MARK:- UICollectionViewDataSource
extension PageContentView : UICollectionViewDataSource {
//1. collectionViewCell的个数
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.childVCs.count;
}
//2. collectionViewCell的内容
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//创建一个collectionViewCell
let collectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: collectionViewCellID, for: indexPath)
//防止反复添加subView,移除上一次添加的subView
for view in collectionViewCell.contentView.subviews {
view.removeFromSuperview()
}
//设置cell的内容
let childVC = childVCs[indexPath.item]
childVC.view.frame = collectionViewCell.contentView.bounds
collectionViewCell.contentView.addSubview(childVC.view)
return collectionViewCell
}
}
// MARK:- UICollectionViewDelegate
extension PageContentView : UICollectionViewDelegate{
//开始滑动时调用
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
//如果是滑动调用,则不禁止滑动代理方法
isForbidScrollDelegate = false
let startOffsetX = scrollView.contentOffset.x
self.startOffsetX = startOffsetX
}
//滑动的时候就会调用
func scrollViewDidScroll(_ scrollView: UIScrollView) {
//如果禁止了滑动代理方法,代表是点击事件(点击了label),则返回
if isForbidScrollDelegate {
return
}
var progress : CGFloat = 0
var sourceIndex : Int = 0
var targetIndex : Int = 0
//当前offsetx
let currentOffsetX = scrollView.contentOffset.x
//如果是左滑
if currentOffsetX > startOffsetX{
progress = currentOffsetX/kScreenW - floor(currentOffsetX/kScreenW) //进度
sourceIndex = Int(currentOffsetX/kScreenW) //sourceIndex
targetIndex = sourceIndex+1 //targetIndex
//如果目标index等于总控制器个数
if targetIndex == childVCs.count {
targetIndex = childVCs.count-1
}
//如果完全划过去
if currentOffsetX - startOffsetX == kScreenW {
progress = 1
targetIndex = sourceIndex
}
}else{//否则是右滑
progress = 1 - (currentOffsetX/kScreenW - floor(currentOffsetX/kScreenW)) //进度
targetIndex = Int(currentOffsetX/kScreenW) //targetIndex
sourceIndex = targetIndex + 1 //sourceIndex
//如果源index等于总控制器个数
if sourceIndex == childVCs.count {
sourceIndex = childVCs.count - 1
}
}
//通知代理
delegate?.pageContentView(contentView: self, progress: progress, sourceIndex: sourceIndex, targetIndex: targetIndex)
}
}
// MARK:- 对外暴露的方法
extension PageContentView {
func setSelectedIndex(selectedIndex: Int) {
//因为是点击了titleLabel,禁止collocationDelegate
isForbidScrollDelegate = true
//点击了titleLabel设置collectionView的contentOffset
let offsetX = CGFloat(selectedIndex)*(collectionView.bounds.width)
collectionView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: false)
}
}
|
[
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.