blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
625
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 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
sequencelengths 1
9.02k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
334e4a61f1e366267c4ba43f698a116f483d42af | 5414fed6fe9489ef1f10e16d7f9483a38e385012 | /Calculator/LogicManager.swift | 868f39ad89d9e82819c1d87076c79a514388804d | [] | no_license | Cam1T/Calculator-Programmatic | 57fff154dba0ce4fac8ef9acd0f5a2a5f372facb | b2a11806442b60103db85b0212c433c01a4b4628 | refs/heads/master | 2022-12-17T04:20:31.987821 | 2020-09-19T11:00:49 | 2020-09-19T11:00:49 | 296,842,912 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,124 | swift | //
// LogicManager.swift
// Calculator
//
// Created by USER on 09/09/2020.
// Copyright © 2020 CJAPPS. All rights reserved.
//
import Foundation
class LogicManager {
var calculateArray = [Double]()
var lastNumber = 0.0
var lastOperation = 0.0
var currentNumber = 0.0
func Clear() {
calculateArray = []
lastNumber = 0.0
lastOperation = 0.0
currentNumber = 0.0
}
func calculateAndReturn(operation: String) -> String? {
if operation == "operation" {
if calculateArray.count >= 3 {
let newValue = calculate(firstNumber: calculateArray[0], SecondNumber: calculateArray[2], operation: Int(calculateArray[1]))
calculateArray.removeAll()
calculateArray.append(newValue)
calculateArray.append(lastOperation)
return String(calculateArray[0])
}
} else if operation == "equals" {
if calculateArray.count >= 1 {
let newValue = calculate(firstNumber: calculateArray[0], SecondNumber: lastNumber, operation: Int(lastOperation))
calculateArray.removeAll()
calculateArray.append(newValue)
return String(calculateArray[0])
}
}
return nil
}
func calculate(firstNumber: Double, SecondNumber: Double, operation: Int) -> Double {
var total = 0.0
if let operations = Enumerations.Operations(rawValue: operation){
switch operations {
case .add:
total = firstNumber + SecondNumber
case .subtract:
total = firstNumber - SecondNumber
case .multiply:
total = firstNumber * SecondNumber
case .divide:
total = firstNumber / SecondNumber
default:
print("")
}}
return Double(floor(1000*total)/1000)
}
}
| [
-1
] |
96e8e34c6a9f6eb99b81b3b5941f29c745b9c242 | 8e71c018f7ed5d7659fd6133d09f446c493f6bc0 | /ENote/HistoryNotesLayout.swift | 0c30f6b1be5577f335deb258ea12e4ed1c668627 | [] | no_license | EgeTart/ENote | 1ed3e09bd42d57becef1ee2e27adcaeeafc8534f | baace6970cc75761311f10e25f78305deb438bb3 | refs/heads/master | 2020-06-17T18:16:56.652718 | 2016-12-17T16:11:37 | 2016-12-17T16:11:37 | 74,965,933 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,878 | swift | //
// HistoryNotesLayout.swift
// ENote
//
// Created by min-mac on 16/12/5.
// Copyright © 2016年 EgeTart. All rights reserved.
//
import UIKit
protocol HistoryNoteLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, heightForContentAtIndexPath indexPath: IndexPath, withWidth width: CGFloat) -> CGFloat
}
class HistoryNotesLayout: UICollectionViewLayout {
var delegate: HistoryNoteLayoutDelegate!
var numberOfColumns: Int {
if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft || UIDevice.current.orientation == UIDeviceOrientation.landscapeRight {
return 3
}
return 2
}
let cellPadding: CGFloat = 6.0
private var attributesCache = [[UICollectionViewLayoutAttributes]]()
private var contentHeight: CGFloat = 0.0
private var contentWidth: CGFloat {
let insets = collectionView!.contentInset
return (collectionView!.bounds).width - (insets.left + insets.right)
}
private let fixHeight: CGFloat = 38.0
override func prepare() {
if attributesCache.isEmpty {
let columnWidth = contentWidth / CGFloat(numberOfColumns)
var xOffset = [CGFloat]()
for column in 0..<numberOfColumns {
xOffset.append(CGFloat(column) * columnWidth + cellPadding)
}
var column = 0
var yOffset = [CGFloat](repeating: 0, count: numberOfColumns)
let numberOfSections = collectionView!.numberOfSections
for section in 0..<numberOfSections {
var cache = [UICollectionViewLayoutAttributes]()
let headerAttributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, with: IndexPath(item: 0, section: section))
headerAttributes.frame = CGRect(x: 0, y: yOffset[0], width: collectionView!.bounds.width, height: 30.0)
cache.append(headerAttributes)
yOffset = yOffset.map({ (offset: CGFloat) -> CGFloat in
return offset + 30.0
})
for item in 0..<collectionView!.numberOfItems(inSection: section) {
let indexPath = IndexPath(item: item, section: section)
let width = columnWidth - 2 * cellPadding
let contentLabelHeight = delegate.collectionView(collectionView!, heightForContentAtIndexPath: indexPath, withWidth: width)
let height = contentLabelHeight + fixHeight + cellPadding * 5.8
let frame = CGRect(x: xOffset[column], y: yOffset[column], width: width, height: height)
let insetFrame = frame.insetBy(dx: 2.0, dy: cellPadding)
let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
attributes.frame = insetFrame
cache.append(attributes)
contentHeight = max(contentHeight, frame.maxY)
yOffset[column] = yOffset[column] + height
column = (column >= numberOfColumns - 1) ? 0 : column + 1
}
column = 0
let maxYOffset = yOffset.max()!
for column in 0..<numberOfColumns {
yOffset[column] = maxYOffset + 10.0
}
attributesCache.append(cache)
}
}
}
override var collectionViewContentSize: CGSize {
return CGSize(width: contentWidth, height: contentHeight)
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var layoutAttributes = [UICollectionViewLayoutAttributes]()
for cache in attributesCache {
for attributes in cache {
if attributes.frame.intersects(rect) {
layoutAttributes.append(attributes)
}
}
}
return layoutAttributes
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return attributesCache[indexPath.section][indexPath.item + 1]
}
override func layoutAttributesForSupplementaryView(ofKind elementKind: String, at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return attributesCache[indexPath.section][indexPath.item]
}
override func invalidateLayout() {
attributesCache.removeAll()
}
}
| [
-1
] |
14c320479ab7e7588f242af073d76dcce687116d | 4825a5ee1f67a695d307ad4a9d05eceefdf31bf5 | /ios_src/Binoculars/Sample.swift | 075619e33e76ca823de1d03988149a7525143725 | [] | no_license | gogus/binoculars | 81f21c6703dcabd029792d5d2806eddcab0b69d7 | f0da8c737f0893a963213d077e0d0af86635e66e | refs/heads/main | 2022-12-28T15:30:05.888910 | 2020-10-11T00:48:32 | 2020-10-11T00:48:32 | 302,697,948 | 2 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,159 | swift | /* Copyright (c) 2017 Google Inc.
*
* 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 UIKit
enum Sample: CaseIterable {
case Heatmaps
case List
}
extension Sample {
var title: String {
switch self {
case .Heatmaps: return "Traffic map"
case .List: return "List"
}
}
var description: String {
switch self {
case .Heatmaps: return "Show map of Luxembourg City"
case .List: return "Show list of places"
}
}
var controller: UIViewController.Type {
switch self {
case .Heatmaps: return HeatmapViewController.self
case .List: return ListViewController.self
}
}
}
| [
-1
] |
eb87ea23fc9ebba5a01dad1698473b876d15ef41 | 42df66d2d380438b3a5164d4d0e00bb270a94a9d | /StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerSelectionView.swift | 7c411162e55b8da3b3f46c75b61043af247d2b21 | [
"MIT"
] | permissive | stripe/stripe-ios | 2472a3a693a144d934e165058c07593630439c9e | dd9e4b4c4bf7cceffc8ba661cbe2ec2430b3ce4a | refs/heads/master | 2023-08-31T20:29:56.708961 | 2023-08-31T17:53:57 | 2023-08-31T17:53:57 | 6,656,911 | 1,824 | 1,005 | MIT | 2023-09-14T21:39:48 | 2012-11-12T16:55:08 | Swift | UTF-8 | Swift | false | false | 1,934 | swift | //
// AccountPickerSelectionView.swift
// StripeFinancialConnections
//
// Created by Krisjanis Gaidis on 8/10/22.
//
import Foundation
@_spi(STP) import StripeUICore
import UIKit
protocol AccountPickerSelectionViewDelegate: AnyObject {
func accountPickerSelectionView(
_ view: AccountPickerSelectionView,
didSelectAccounts selectedAccounts: [FinancialConnectionsPartnerAccount]
)
}
final class AccountPickerSelectionView: UIView {
private weak var delegate: AccountPickerSelectionViewDelegate?
private let listView: AccountPickerSelectionListView
init(
accountPickerType: AccountPickerType,
enabledAccounts: [FinancialConnectionsPartnerAccount],
disabledAccounts: [FinancialConnectionsPartnerAccount],
institution: FinancialConnectionsInstitution,
delegate: AccountPickerSelectionViewDelegate
) {
self.delegate = delegate
self.listView = AccountPickerSelectionListView(
selectionType: accountPickerType == .checkbox ? .checkbox : .radioButton,
enabledAccounts: enabledAccounts,
disabledAccounts: disabledAccounts
)
super.init(frame: .zero)
listView.delegate = self
addAndPinSubviewToSafeArea(listView)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func selectAccounts(_ selectedAccounts: [FinancialConnectionsPartnerAccount]) {
listView.selectAccounts(selectedAccounts)
}
}
// MARK: - AccountPickerSelectionListViewDelegate
extension AccountPickerSelectionView: AccountPickerSelectionListViewDelegate {
func accountPickerSelectionListView(
_ view: AccountPickerSelectionListView,
didSelectAccounts selectedAccounts: [FinancialConnectionsPartnerAccount]
) {
delegate?.accountPickerSelectionView(self, didSelectAccounts: selectedAccounts)
}
}
| [
-1
] |
4e3d5621278e800e376b8a5266f2117fe0b27bbb | 79bbd6cc49efd116a1899466f9bfa26f4b584f97 | /Sources/Maaku/Core/Inline/InlineHtml.swift | e08ac28858b0415c13e5d4fc88138263dcebd061 | [
"MIT"
] | permissive | KristopherGBaker/Maaku | 495d4095bb988ad28202da580472283016a2f420 | 7d2360b31b6b81bb37e45f1d1c14531ab033ce88 | refs/heads/master | 2023-01-25T03:46:35.559249 | 2020-11-17T10:18:16 | 2020-11-17T10:18:16 | 114,937,625 | 50 | 20 | MIT | 2020-11-17T10:18:18 | 2017-12-20T22:38:44 | Swift | UTF-8 | Swift | false | false | 1,521 | swift | //
// InlineHtml.swift
// Maaku
//
// Created by Kris Baker on 12/20/17.
// Copyright © 2017 Kristopher Baker. All rights reserved.
//
import Foundation
/// Represents markdown inline HTML.
public struct InlineHtml: Inline {
/// The HTML.
public let html: String
/// Creates an InlineHtml with the specified HTML.
///
/// - Parameters:
/// - html: The HTML.
/// - Returns:
/// The initialized InlineHtml.
public init(html: String) {
self.html = html
}
}
public extension InlineHtml {
func attributedText(style: Style) -> NSAttributedString {
// TODO: update DocumentConverter to properly deal with inline HTML,
// for now, just render the inline HTML as a string.
// guard let data = html.data(using: .utf16, allowLossyConversion: false),
// let attributedString = try? NSAttributedString(data: data, options: [.documentType:
// NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue],
// documentAttributes: nil) else {
// return NSAttributedString(string: html, attributes:
// [.font: style.currentFont, .foregroundColor: style.currentForegroundColor])
// }
// return attributedString
let attributes: [NSAttributedString.Key: Any] = [
.font: style.fonts.current,
.foregroundColor: style.colors.current
]
return NSAttributedString(string: html, attributes: attributes)
}
}
| [
-1
] |
6463f8a60dee0906996f41e20a53b41f1a9c9cf2 | b532f3ec38b2b1ba765995337f7cbfdd916e4730 | /WLNI_Wijesinghe-COBSCCOMP192P-029/WLNI_Wijesinghe-COBSCCOMP192P-029/ViewController.swift | 906a92bd60aab22afb88f8d6a70df43995a5e9d8 | [] | no_license | NIPUNSGITHUB/Caf--Manager | e03ab68e88d26c585720727bb84bbed68fbb625b | 793273f9cd93161428f2aef6a97c29e79fbb95dd | refs/heads/main | 2023-04-12T14:53:48.004732 | 2021-05-09T03:39:51 | 2021-05-09T03:39:51 | 361,090,640 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 296 | swift | //
// ViewController.swift
// WLNI_Wijesinghe-COBSCCOMP192P-029
//
// Created by Macbook on 4/24/21.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
| [
262528,
254464,
275714,
398203,
361600,
385282,
436489,
317194,
373648,
384145,
391441,
373651,
373652,
409238,
375576,
352920,
370299,
155424,
187937,
345378,
391456,
396707,
397091,
354729,
356652,
384300,
273710,
370352,
372017,
381618,
383797,
378171,
354108,
397117,
266816,
354113,
359368,
421962,
437582,
265807,
199251,
372692,
372693,
257750,
224855,
210262,
436316,
362845,
359390,
165087,
425824,
399201,
389725,
225504,
437220,
155493,
155623,
318568,
384103,
350187,
56046,
381179,
345966,
349297,
376687,
398193,
432243,
345972,
435189,
345976,
361595,
351486
] |
ebb7ef3ab11f0526fa750a7b588e2a57e143b1fe | c8dcd0e0fc16b2dd53922f367c3946e87ec9bdc0 | /EdBinx/Pods/XLPagerTabStrip/Sources/PagerTabStripViewController.swift | d2fc8f762fd43e461c96543c24b54f176d559b76 | [
"MIT"
] | permissive | tush4r/Edbinx | 914e610c03713cf621513172f8a4d0ecf03b9da2 | 4ad4be331c890bebecf123aea24a42a5d08a2230 | refs/heads/master | 2021-01-20T11:22:55.862912 | 2017-01-28T11:21:12 | 2017-01-28T11:21:12 | 64,945,554 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 15,781 | swift | // PagerTabStripViewController.swift
// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip )
//
// Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com )
//
//
// 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 Foundation
// MARK: Protocols
public protocol IndicatorInfoProvider {
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
}
public protocol PagerTabStripDelegate: class {
func pagerTabStripViewController(_ pagerTabStripViewController: PagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex: Int)
}
public protocol PagerTabStripIsProgressiveDelegate : PagerTabStripDelegate {
func pagerTabStripViewController(_ pagerTabStripViewController: PagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)
}
public protocol PagerTabStripDataSource: class {
func viewControllersForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
}
//MARK: PagerTabStripViewController
open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet lazy open var containerView: UIScrollView! = { [unowned self] in
let containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height))
containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
return containerView
}()
open weak var delegate: PagerTabStripDelegate?
open weak var datasource: PagerTabStripDataSource?
open var pagerBehaviour = PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true)
open fileprivate(set) var viewControllers = [UIViewController]()
open fileprivate(set) var currentIndex = 0
open var pageWidth: CGFloat {
return containerView.bounds.width
}
open var scrollPercentage: CGFloat {
if swipeDirection != .right {
let module = fmod(containerView.contentOffset.x, pageWidth)
return module == 0.0 ? 1.0 : module / pageWidth
}
return 1 - fmod(containerView.contentOffset.x >= 0 ? containerView.contentOffset.x : pageWidth + containerView.contentOffset.x, pageWidth) / pageWidth
}
open var swipeDirection: SwipeDirection {
if containerView.contentOffset.x > lastContentOffset {
return .left
}
else if containerView.contentOffset.x < lastContentOffset {
return .right
}
return .none
}
override open func viewDidLoad() {
super.viewDidLoad()
if containerView.superview == nil {
view.addSubview(containerView)
}
containerView.bounces = true
containerView.alwaysBounceHorizontal = true
containerView.alwaysBounceVertical = false
containerView.scrollsToTop = false
containerView.delegate = self
containerView.showsVerticalScrollIndicator = false
containerView.showsHorizontalScrollIndicator = false
containerView.isPagingEnabled = true
reloadViewControllers()
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
isViewAppearing = true
}
override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
lastSize = containerView.bounds.size
updateIfNeeded()
isViewAppearing = false
}
override open func viewDidLayoutSubviews(){
super.viewDidLayoutSubviews()
updateIfNeeded()
}
open func moveToViewControllerAtIndex(_ index: Int, animated: Bool = true) {
guard isViewLoaded && view.window != nil else {
currentIndex = index
return
}
if animated && pagerBehaviour.skipIntermediateViewControllers && abs(currentIndex - index) > 1 {
var tmpViewControllers = viewControllers
let currentChildVC = viewControllers[currentIndex]
let fromIndex = currentIndex < index ? index - 1 : index + 1
let fromChildVC = viewControllers[fromIndex]
tmpViewControllers[currentIndex] = fromChildVC
tmpViewControllers[fromIndex] = currentChildVC
pagerTabStripChildViewControllersForScrolling = tmpViewControllers
containerView.setContentOffset(CGPoint(x: pageOffsetForChildIndex(fromIndex), y: 0), animated: false)
(navigationController?.view ?? view).isUserInteractionEnabled = false
containerView.setContentOffset(CGPoint(x: pageOffsetForChildIndex(index), y: 0), animated: true)
}
else {
containerView.setContentOffset(CGPoint(x: pageOffsetForChildIndex(index), y: 0), animated: animated)
}
}
open func moveToViewController(_ viewController: UIViewController, animated: Bool = true) {
moveToViewControllerAtIndex(viewControllers.index(of: viewController)!, animated: animated)
}
//MARK: - PagerTabStripDataSource
open func viewControllersForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllersForPagerTabStrip: method")
return []
}
//MARK: - Helpers
open func updateIfNeeded() {
if isViewLoaded && !lastSize.equalTo(containerView.bounds.size){
updateContent()
}
}
open func canMoveToIndex(_ index: Int) -> Bool {
return currentIndex != index && viewControllers.count > index
}
open func pageOffsetForChildIndex(_ index: Int) -> CGFloat {
return CGFloat(index) * containerView.bounds.width
}
open func offsetForChildIndex(_ index: Int) -> CGFloat{
return (CGFloat(index) * containerView.bounds.width) + ((containerView.bounds.width - view.bounds.width) * 0.5)
}
open func offsetForChildViewController(_ viewController: UIViewController) throws -> CGFloat{
guard let index = viewControllers.index(of: viewController) else {
throw PagerTabStripError.viewControllerNotContainedInPagerTabStrip
}
return offsetForChildIndex(index)
}
open func pageForContentOffset(_ contentOffset: CGFloat) -> Int {
let result = virtualPageForContentOffset(contentOffset)
return pageForVirtualPage(result)
}
open func virtualPageForContentOffset(_ contentOffset: CGFloat) -> Int {
return Int((contentOffset + 1.5 * pageWidth) / pageWidth) - 1
}
open func pageForVirtualPage(_ virtualPage: Int) -> Int{
if virtualPage < 0 {
return 0
}
if virtualPage > viewControllers.count - 1 {
return viewControllers.count - 1
}
return virtualPage
}
open func updateContent() {
if lastSize.width != containerView.bounds.size.width {
lastSize = containerView.bounds.size
containerView.contentOffset = CGPoint(x: pageOffsetForChildIndex(currentIndex), y: 0)
}
lastSize = containerView.bounds.size
let pagerViewControllers = pagerTabStripChildViewControllersForScrolling ?? viewControllers
containerView.contentSize = CGSize(width: containerView.bounds.width * CGFloat(pagerViewControllers.count), height: containerView.contentSize.height)
for (index, childController) in pagerViewControllers.enumerated() {
let pageOffsetForChild = pageOffsetForChildIndex(index)
if fabs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width {
if let _ = childController.parent {
childController.view.frame = CGRect(x: offsetForChildIndex(index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
}
else {
addChildViewController(childController)
childController.beginAppearanceTransition(true, animated: false)
childController.view.frame = CGRect(x: offsetForChildIndex(index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
containerView.addSubview(childController.view)
childController.didMove(toParentViewController: self)
childController.endAppearanceTransition()
}
}
else {
if let _ = childController.parent {
childController.willMove(toParentViewController: nil)
childController.beginAppearanceTransition(false, animated: false)
childController.view.removeFromSuperview()
childController.removeFromParentViewController()
childController.endAppearanceTransition()
}
}
}
let oldCurrentIndex = currentIndex
let virtualPage = virtualPageForContentOffset(containerView.contentOffset.x)
let newCurrentIndex = pageForVirtualPage(virtualPage)
currentIndex = newCurrentIndex
let changeCurrentIndex = newCurrentIndex != oldCurrentIndex
if let progressiveDeledate = self as? PagerTabStripIsProgressiveDelegate, pagerBehaviour.isProgressiveIndicator {
let (fromIndex, toIndex, scrollPercentage) = progressiveIndicatorData(virtualPage)
progressiveDeledate.pagerTabStripViewController(self, updateIndicatorFromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: scrollPercentage, indexWasChanged: changeCurrentIndex)
}
else{
delegate?.pagerTabStripViewController(self, updateIndicatorFromIndex: min(oldCurrentIndex, pagerViewControllers.count - 1), toIndex: newCurrentIndex)
}
}
open func reloadPagerTabStripView() {
guard isViewLoaded else { return }
for childController in viewControllers {
if let _ = childController.parent {
childController.view.removeFromSuperview()
childController.willMove(toParentViewController: nil)
childController.removeFromParentViewController()
}
}
reloadViewControllers()
containerView.contentSize = CGSize(width: containerView.bounds.width * CGFloat(viewControllers.count), height: containerView.contentSize.height)
if currentIndex >= viewControllers.count {
currentIndex = viewControllers.count - 1
}
containerView.contentOffset = CGPoint(x: pageOffsetForChildIndex(currentIndex), y: 0)
updateContent()
}
//MARK: - UIScrollDelegate
open func scrollViewDidScroll(_ scrollView: UIScrollView) {
if containerView == scrollView {
updateContent()
}
}
open func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
if containerView == scrollView {
lastPageNumber = pageForContentOffset(scrollView.contentOffset.x)
lastContentOffset = scrollView.contentOffset.x
}
}
open func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
if containerView == scrollView {
pagerTabStripChildViewControllersForScrolling = nil
(navigationController?.view ?? view).isUserInteractionEnabled = true
updateContent()
}
}
//MARK: - Orientation
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
isViewRotating = true
pageBeforeRotate = currentIndex
coordinator.animate(alongsideTransition: nil) { [weak self] _ in
guard let me = self else { return }
me.isViewRotating = false
me.currentIndex = me.pageBeforeRotate
me.updateIfNeeded()
}
}
//MARK: Private
fileprivate func progressiveIndicatorData(_ virtualPage: Int) -> (Int, Int, CGFloat) {
let count = viewControllers.count
var fromIndex = currentIndex
var toIndex = currentIndex
let direction = swipeDirection
if direction == .left {
if virtualPage > count - 1 {
fromIndex = count - 1
toIndex = count
}
else {
if self.scrollPercentage >= 0.5 {
fromIndex = max(toIndex - 1, 0)
}
else {
toIndex = fromIndex + 1
}
}
}
else if direction == .right {
if virtualPage < 0 {
fromIndex = 0
toIndex = -1
}
else {
if self.scrollPercentage > 0.5 {
fromIndex = min(toIndex + 1, count - 1)
}
else {
toIndex = fromIndex - 1
}
}
}
let scrollPercentage = pagerBehaviour.isElasticIndicatorLimit ? self.scrollPercentage : ((toIndex < 0 || toIndex >= count) ? 0.0 : self.scrollPercentage)
return (fromIndex, toIndex, scrollPercentage)
}
fileprivate func reloadViewControllers(){
guard let dataSource = datasource else {
fatalError("dataSource must not be nil")
}
viewControllers = dataSource.viewControllersForPagerTabStrip(self)
// viewControllers
guard viewControllers.count != 0 else {
fatalError("viewControllersForPagerTabStrip should provide at least one child view controller")
}
viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllersForPagerTabStrip method must conform to InfoProvider") }}
}
fileprivate var pagerTabStripChildViewControllersForScrolling : [UIViewController]?
fileprivate var lastPageNumber = 0
fileprivate var lastContentOffset: CGFloat = 0.0
fileprivate var pageBeforeRotate = 0
fileprivate var lastSize = CGSize(width: 0, height: 0)
internal var isViewRotating = false
internal var isViewAppearing = false
}
| [
235655,
174065,
292045,
197023
] |
31c4ca81183a7c7d1da993f2f79bd67f66fab8f4 | 08b11c2c30a7a58629f4c8a635869b47d3229db1 | /Package.swift | a3b41cfd5f6e7f96ac3da52e23c8f2061e6fc000 | [
"MIT"
] | permissive | athlete-cf/athlete-vapor-api | 24d1c80bbffacf1275dea8e1d7a03edf78a425b6 | 9a292ff5a2b881f0a0d8650546bc3fa6d0bbb473 | refs/heads/master | 2021-01-24T02:30:49.084273 | 2018-02-26T18:45:08 | 2018-02-26T18:45:08 | 122,852,118 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 636 | swift | // swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "athlete-api",
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0-rc"),
// 🔵 Swift ORM (queries, models, relations, etc) built on SQLite 3.
.package(url: "https://github.com/vapor/fluent-sqlite.git", from: "3.0.0-rc"),
],
targets: [
.target(name: "App", dependencies: ["FluentSQLite", "Vapor"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"]),
]
)
| [
327559,
308712,
334506,
334636,
312305
] |
1344f21b2aecf6761ba559550a17475bac4db594 | e498e78637b9905f730ad0f952331fc3aa1344af | /JogTrackerApp/Extension/UIFont+Extensions.swift | 5f6633c5f462ef340c96d9d82b407140775414c3 | [] | no_license | NastyaMarkovets/JogTrackerApp | 71a57d015c78aaabef17ab12701921dc7eb73439 | 3dd7b158e350376bbd9f4828659a9305e95fb937 | refs/heads/master | 2020-09-10T15:15:26.666126 | 2019-11-18T15:02:30 | 2019-11-18T15:02:30 | 221,735,462 | 0 | 0 | null | 2019-11-18T15:02:32 | 2019-11-14T16:00:18 | Swift | UTF-8 | Swift | false | false | 879 | swift | //
// UIFont+Extensions.swift
// JogTrackerApp
//
// Created by Anastasia Markovets on 11/14/19.
// Copyright © 2019 Lonely Tree Std. All rights reserved.
//
import UIKit
extension UIFont {
struct Base {
static let titleFont = UIFont.systemFont(ofSize: 25, weight: .bold)
static let subTitleFont = UIFont.systemFont(ofSize: 24, weight: .regular)
static let buttonFont = UIFont.systemFont(ofSize: 18, weight: .bold)
static let jogTextFont = UIFont.systemFont(ofSize: 14, weight: .medium)
static let jogSubTextFont = UIFont.systemFont(ofSize: 14, weight: .regular)
static let popUpLabelFont = UIFont.systemFont(ofSize: 13, weight: .regular)
static let popUpButtonFont = UIFont.systemFont(ofSize: 13, weight: .bold)
static let descriptionFont = UIFont.systemFont(ofSize: 12, weight: .regular)
}
}
| [
-1
] |
1c0062a84d17806a61e1109fcdaba91d8098672f | 0a4d011eb562f57f2173e701a24d3267d627c2a0 | /TidalSwiftLib/Codables/Videos.swift | 24af7eda8fdb8a3f058cb4257de075baa9cbbb70 | [] | no_license | melgu/TidalSwift | 68bccc1ea957e09488d0a3f3d3320c696b25347c | 6d589276ebc7de99be15a361b259dc4913084b48 | refs/heads/main | 2022-11-24T19:30:51.763421 | 2022-11-20T21:19:24 | 2022-11-20T21:19:24 | 175,749,310 | 75 | 8 | null | 2022-11-20T21:19:25 | 2019-03-15T04:38:53 | Swift | UTF-8 | Swift | false | false | 3,016 | swift | //
// Video.swift
// TidalSwiftLib
//
// Created by Melvin Gundlach on 01.08.20.
// Copyright © 2020 Melvin Gundlach. All rights reserved.
//
import Foundation
import SwiftUI
struct Videos: Decodable {
let limit: Int
let offset: Int
let totalNumberOfItems: Int
let items: [Video]
}
public struct Video: Codable, Equatable, Identifiable, Hashable {
public let id: Int
public let title: String
public let volumeNumber: Int
public let trackNumber: Int
public let releaseDate: Date
public let imagePath: String? // As far as I know always null
public let imageId: String?
public let duration: Int
public let quality: String // Careful as video quality is different to audio quality
public let streamReady: Bool
public let streamStartDate: Date?
public let allowStreaming: Bool
public let explicit: Bool
public let popularity: Int
public let type: String // e.g. Music Video
public let adsUrl: String?
public let adsPrePaywallOnly: Bool
public let artists: [Artist]
// public let album: Album? // Sometimes Tidal returns empty object here which breaks things. In all other cases I found, returns nil otherwise, so doesn't matter anyways.
public func isInFavorites(session: Session) -> Bool? {
session.favorites?.doFavoritesContainVideo(videoId: id)
}
public func getVideoUrl(session: Session) -> URL? {
session.getVideoUrl(videoId: id)
}
public func getImageUrl(session: Session, resolution: Int) -> URL? {
guard let imageId = imageId else {
return nil
}
return session.getImageUrl(imageId: imageId, resolution: resolution)
}
public func getImage(session: Session, resolution: Int) -> NSImage? {
guard let imageId = imageId else {
return nil
}
return session.getImage(imageId: imageId, resolution: resolution)
}
public static func == (lhs: Video, rhs: Video) -> Bool {
lhs.id == rhs.id
}
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
struct VideoUrl: Decodable {
let url: URL
let videoQuality: String
}
public enum VideoSorting: Int, Codable {
case dateAdded // to Favorites
case title
case artists
case releaseDate
case duration
case popularity
}
extension Array where Element == Video {
public func sortedVideos(by sorting: VideoSorting) -> [Video] {
switch sorting {
case .dateAdded:
return self
case .title:
return self.sorted { $0.title.lowercased() < $1.title.lowercased() }
case .artists:
return self.sorted {
($0.artists.formArtistString().lowercased(), $0.title.lowercased()) <
($1.artists.formArtistString().lowercased(), $1.title.lowercased())
}
case .releaseDate:
return self.sorted {
($0.releaseDate, $0.title.lowercased()) <
($1.releaseDate, $1.title.lowercased())
}
case .duration:
return self.sorted {
($0.duration, $0.title.lowercased()) <
($1.duration, $1.title.lowercased())
}
case .popularity:
return self.sorted {
($0.popularity, $0.title.lowercased()) <
($1.popularity, $1.title.lowercased())
}
}
}
}
| [
-1
] |
151efd2be081740d8425affd11b9a2223d49cc5d | fb3ec3147a18ef7895cbf4d5abfe38f6a19963f1 | /zjlao/Classes/Profile/Sub/Setting/Sub/ChangeLanguage/Controller/ChooseLanguageVC.swift | 2b02e468f688a6c2e709f22d13bea8fa6bc145a6 | [
"Apache-2.0"
] | permissive | hhcszgd/projectArchive | 6cbcbd28e48d4e5236008b7679213dc0508defdb | 5f106905b510bab1c15a5e2ef051814731d3ac9c | refs/heads/master | 2021-01-18T05:43:14.253060 | 2017-03-08T06:00:12 | 2017-03-08T06:00:12 | 84,281,549 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 7,741 | swift | //
// ChooseLanguageVC.swift
// zjlao
//
// Created by WY on 16/10/19.
// Copyright © 2016年 WY. All rights reserved.
/*进来时 确定按钮不可用 , 只有选择非当前语言后 确定按钮才可用**/
import UIKit
import MJRefresh
class ChooseLanguageVC: GDNormalVC/*,UITableViewDelegate ,*/ /*, UITableViewDataSource */{
let languages : [String] = [/*LFollowSystemLanguage,*/LEnglish,LChinese]
let bottomButton = UIButton()
// let tableView = BaseTableView(frame: CGRect.zero, style: UITableViewStyle.plain)
var currentLanguageIndexPath = IndexPath(row: 111, section: 0)
var selectedLanguageIndexPath = IndexPath(row: 1111, section: 0)
var choosedIndexPaths = [String : IndexPath]()
var selectedLanguage : String = ""
override func viewDidLoad() {
super.viewDidLoad()
self.naviBar.currentBarActionType = .offset // .color//.alpha //
self.naviBar.layoutType = .asc
self.automaticallyAdjustsScrollViewInsets = false
self.setupSubViews()
self.view.addSubview(bottomButton)
// self.view.addSubview(tableView)
// self.naviBar.currentBarStatus = .disapear
// Do any additional setup after loading the view.
}
func setupSubViews() {
self.tableView.contentInset = UIEdgeInsetsMake(NavigationBarHeight, 0, 0, 0)
let margin : CGFloat = 20.0
let btnW : CGFloat = GDDevice.width - margin * 2
let btnH : CGFloat = 44
let btnX : CGFloat = margin
let btnY : CGFloat = GDDevice.height - margin - btnH
self.bottomButton.frame = CGRect(x: btnX, y: btnY, width: btnW, height: btnH)
let tableViewX : CGFloat = 0
// let tableViewY : CGFloat = NavigationBarHeight
let tableViewY : CGFloat = 0
let tableViewW : CGFloat = GDDevice.width
let tableViewH : CGFloat = btnY - tableViewY - margin
self.tableView.frame = CGRect(x: tableViewX, y: tableViewY, width: tableViewW, height: tableViewH)
// self.tableView.contentInset = UIEdgeInsetsMake(NavigationBarHeight, 0, 20, 0)
self.tableView.backgroundColor = UIColor.randomColor()
self.tableView.delegate = self
self.tableView.dataSource = self
self.bottomButton.embellishView(redius: 5)
self.bottomButton.backgroundColor = UIColor.red
self.bottomButton.setTitle(GDLanguageManager.titleByKey(key: "confirm"), for: UIControlState.normal)
self.bottomButton.addTarget(self, action: #selector(sureClick(sender:)), for: UIControlEvents.touchUpInside)
self.bottomButton.setTitleColor(UIColor.white, for: UIControlState.normal)
self.bottomButton.setTitleColor(UIColor.gray, for: UIControlState.disabled)
self.bottomButton.isEnabled = false
}
override func refresh () {
self.tableView.reloadData()
self.tableView.mj_header.endRefreshing()
self.tableView.mj_footer.state = MJRefreshState.idle
}
override func loadMore () {
self.tableView.mj_footer.endRefreshingWithNoMoreData()
}
//MARK:UITableViewDelegate and UITableViewDataSource
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return self.languages.count ;
}
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
if cell == nil {
cell = GDBaseCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "cell")
}
cell?.textLabel?.text = self.languages[indexPath.row]
cell?.selectionStyle = UITableViewCellSelectionStyle.blue
if let currentLanguage = GDLanguageManager.LanguageTableName {
if self.selectedLanguageIndexPath.row == 1111 {//第一次
if currentLanguage == languages[indexPath.row] {
cell?.isSelected = true
cell?.detailTextLabel?.text = "选中"
self.currentLanguageIndexPath = indexPath
}else{
cell?.detailTextLabel?.text = "未选中"
}
}else{//点击了任何行以后
if indexPath == self.selectedLanguageIndexPath {
cell?.detailTextLabel?.text = "选中"
}else{
cell?.detailTextLabel?.text = "未选中"
}
if self.currentLanguageIndexPath == self.selectedLanguageIndexPath {
self.bottomButton.isEnabled = false
}else{
self.bottomButton.isEnabled = true
}
}
}
return cell ?? GDBaseCell()
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//无关紧要
let currentStr = "\(indexPath.row)"
if let _ = self.choosedIndexPaths[currentStr] {//键能找到值
self.choosedIndexPaths.removeValue(forKey: currentStr)
}else{//找不到就加进去
self.choosedIndexPaths[currentStr] = indexPath
}
// self.tableView.beginUpdates()
// self.tableView.endUpdates()
//重要
self.selectedLanguageIndexPath = indexPath
self.selectedLanguage = self.languages[indexPath.row]
self.tableView.reloadData()
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let currentStr = "\(indexPath.row)"
if let _ = self.choosedIndexPaths[currentStr] {
return 66
}else{return 44}
}
//MARK:customMethod
func sureClick(sender : UIButton) {
mylog(GDStorgeManager.standard.object(forKey: "AppleLanguages"))
mylog(GDLanguageManager.gotcurrentSystemLanguage())
if self.selectedLanguage == "" {
GDAlertView.alert("请选择目标语言", image: nil, time: 2, complateBlock: nil)
return
}
GDLanguageManager.performChangeLanguage(targetLanguage: self.selectedLanguage)
NotificationCenter.default.post(name: GDLanguageChanged, object: nil, userInfo: nil)
GDAlertView.alert("保存成功", image: nil , time: 2) {
self.navigationController?.popViewController(animated: true)
}
// (UIApplication.shared.delegate as? AppDelegate)?.performChangeLanguage(targetLanguage: self.selectedLanguage)//更改语言
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// mylog(scrollView.contentOffset)
// mylog(scrollView.contentSize)
// mylog(scrollView.bounds.size)
// self.naviBar.currentBarActionType = .alpha
// self.naviBar.layoutType = .desc
self.naviBar.change(by: scrollView)
// self.naviBar.changeWithOffset(offset: (scrollView.contentOffset.y + 64) / scrollView.contentSize.height)
// self.naviBar.changeWithOffset(offset: scrollView.contentOffset.y, contentSize: scrollView.contentSize)
}
}
| [
-1
] |
42a80bdf50db89c0159f12f8000f002f7365ebad | 8efbc6e491c84cd9c6a95a88ca14ae79c1a2ab15 | /PokemonApp/Library/Utils/Protocols/Coordinator.swift | 9c8c8394fdb4d11927b141125f89b6692d12f02f | [] | no_license | bchavarria01/PokemonApp | 5da56f540d39786e1ff880317ccf7afa2a98b864 | 3156d418569bdc354d34521e6643510209b49e9f | refs/heads/master | 2020-07-29T18:10:19.668087 | 2020-07-15T20:56:24 | 2020-07-15T20:56:24 | 209,914,023 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 883 | swift | //
// Coordinator.swift
// PokemonApp
//
// Created by Byron Chavarría on 2/8/20.
// Copyright © 2020 Byron Chavarría. All rights reserved.
//
import UIKit
protocol Coordinator: AnyObject {
var presenter: UINavigationController { get }
var parentCoordinator: Coordinator? { get set }
var childCoordinators: [Coordinator] { get set }
func start()
func childDidFinish(_ child: Coordinator?)
func addChildCoordinator(_ coordinator: Coordinator)
}
extension Coordinator {
func childDidFinish(_ child: Coordinator?) {
for (index, coordinator) in childCoordinators.enumerated() {
if coordinator === child {
childCoordinators.remove(at: index)
break
}
}
}
func addChildCoordinator(_ coordinator: Coordinator) {
childCoordinators.append(coordinator)
}
}
| [
-1
] |
5c9bf2242f3095a0f486b2c2314d98906d076a6c | c58f6eb041318d5a315870a81cdfd708faef96eb | /ORC/Modules/History Module/View/Cell/HistoryDataTableViewCell.swift | a2f21cb6072ec07b1feb998ac9f9b3acb683d2c3 | [] | no_license | iOSDias/sauda | 2e8b0b5c2a2c6a55c07a2cad22d34ad40e4a88f8 | ac70b14d355cb53ff107d62363fea30f25508a2e | refs/heads/master | 2020-04-16T15:20:35.333169 | 2019-01-14T17:21:24 | 2019-01-14T17:21:24 | 165,699,145 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 9,561 | swift | //
// HistoryDataTableViewCell.swift
// ORC
//
// Created by Dias Ermekbaev on 24.10.2018.
// Copyright © 2018 Dias. All rights reserved.
//
import UIKit
class HistoryDataTableViewCell: UITableViewCell {
private enum Constant {
enum Size {
enum RoundView {
static let size: CGFloat = 16
}
}
enum Image {
static let calendar = UIImage(named: "calendar")!
}
enum Font {
static let monthLabel = Functions.font(type: FontType.light, size: .normal)
static let dayLabel = Functions.font(type: FontType.regular, size: .big)
static let purchaseTotal = Functions.font(type: FontType.regular, size: .normal)
}
}
// MARK: - Properties
lazy var leftView = UIView()
lazy var rightView = UIView()
lazy var verticalSeparator: UIView = {
let view = UIView()
view.backgroundColor = UIColor.gray2
return view
}()
lazy var horizontalSeparator: UIView = {
let view = UIView()
view.backgroundColor = UIColor.gray2
return view
}()
lazy var roundView: UIView = {
let view = UIView()
view.clipsToBounds = true
view.layer.cornerRadius = Constant.Size.RoundView.size/2
view.layer.borderWidth = 1
view.layer.borderColor = UIColor.gray2.cgColor
return view
}()
lazy var calendarImgView: CustomImageView = {
let imageView = CustomImageView()
imageView.image = Constant.Image.calendar
return imageView
}()
lazy var dayLabel: UILabel = {
let label = UILabel()
label.font = Constant.Font.dayLabel
label.textAlignment = .center
return label
}()
lazy var monthLabel: UILabel = {
let label = UILabel()
label.font = Constant.Font.monthLabel
label.textAlignment = .center
return label
}()
lazy var statusLabel: UILabel = {
let label = UILabel()
label.font = Constant.Font.purchaseTotal
label.textColor = .blue1
return label
}()
lazy var purchaseTotalLabel: UILabel = {
let label = UILabel()
label.textColor = .blue1
label.textAlignment = .right
label.font = Constant.Font.purchaseTotal
return label
}()
lazy var tableView: UITableView = {
let tableView = UITableView()
tableView.delegate = self
tableView.dataSource = self
tableView.isScrollEnabled = false
tableView.tableFooterView = UIView()
tableView.separatorStyle = .none
tableView.register(HistoryProductTableViewCell.self, forCellReuseIdentifier: "HistoryProductTableViewCell")
return tableView
}()
private var height: CGFloat = 0
private var statusTitle: String {
switch data.group_status {
case 0: return "В обработке"
case 1: return "Заявка принята"
case 2: return "Курьер принял"
case 3: return "Заявка доставлена"
case 4: return "Заявка завершена"
default: return ""
}
}
private var statusColor: UIColor {
switch data.group_status {
case 4: return UIColor.red1
default: return UIColor.green1
}
}
var data: HistoryData! {
didSet {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
var day: Int = 22
var month: Int = 11
if let date = dateFormatter.date(from: data.created_at) {
let components = Calendar.current.dateComponents([.day, .month], from: date)
if let componentsDay = components.day {
day = componentsDay
}
if let componentsMonth = components.month {
month = componentsMonth
}
}
dayLabel.text = day.description
monthLabel.text = month.stringOfMonthNumber
statusLabel.text = statusTitle
purchaseTotalLabel.text = data.group_total + " " + Constants.currency
roundView.backgroundColor = statusColor
height = 0
let width = 0.8 * (UIScreen.width * 0.7 - 1) - 10 - 2 * Constants.baseOffset
data.purchases.forEach { (purchase) in
let nameHeight = purchase.product.product_name.height(withConstrainedWidth: width, font: Functions.font(type: FontType.regular, size: FontSize.normal))
height += 48 + nameHeight
}
configureViews()
}
}
// MARK: - Methods
private func configureViews() {
[leftView, verticalSeparator, horizontalSeparator, roundView, rightView].forEach({ contentView.addSubview($0) })
leftView.snp.makeConstraints { (make) in
make.left.equalToSuperview()
make.top.bottom.equalTo(rightView)
make.width.equalToSuperview().multipliedBy(0.3)
}
[calendarImgView, monthLabel].forEach({ leftView.addSubview($0) })
let imageSize = Constant.Image.calendar.size
let imageHeight = UIScreen.width * 0.3 * 0.5 * imageSize.height / imageSize.width
calendarImgView.snp.makeConstraints { (make) in
make.top.equalToSuperview().offset(8)
make.centerX.equalToSuperview()
make.width.equalToSuperview().multipliedBy(0.5)
make.height.equalTo(imageHeight)
}
calendarImgView.addSubview(dayLabel)
dayLabel.snp.makeConstraints { (make) in
make.centerY.equalToSuperview().offset(imageHeight/8)
make.centerX.equalToSuperview()
}
monthLabel.snp.makeConstraints { (make) in
make.top.equalTo(calendarImgView.snp.bottom).offset(8)
make.left.right.equalToSuperview()
make.height.equalTo(22)
}
verticalSeparator.snp.makeConstraints { (make) in
make.top.bottom.equalToSuperview()
make.width.equalTo(1)
make.left.equalTo(leftView.snp.right)
}
contentView.bringSubviewToFront(roundView)
roundView.snp.makeConstraints { (make) in
make.top.equalToSuperview()
make.centerX.equalTo(verticalSeparator)
make.width.height.equalTo(Constant.Size.RoundView.size)
}
horizontalSeparator.snp.makeConstraints { (make) in
make.centerY.equalTo(roundView)
make.left.right.equalToSuperview()
make.height.equalTo(1)
}
rightView.snp.makeConstraints { (make) in
make.left.equalTo(verticalSeparator.snp.right)
make.right.top.bottom.equalToSuperview()
}
[statusLabel, purchaseTotalLabel, tableView].forEach({ rightView.addSubview($0) })
statusLabel.snp.makeConstraints { (make) in
make.left.equalToSuperview().offset(Constants.baseOffset)
make.top.equalToSuperview().offset(15)
make.height.equalTo(22)
make.width.equalTo(statusLabel.intrinsicContentSize.width)
}
purchaseTotalLabel.snp.makeConstraints { (make) in
make.right.equalToSuperview().offset(-Constants.baseOffset)
make.centerY.equalTo(statusLabel)
make.left.equalTo(statusLabel.snp.right).offset(8)
}
tableView.snp.makeConstraints { (make) in
make.top.equalTo(statusLabel.snp.bottom).offset(10)
make.left.right.equalToSuperview()
make.height.equalTo(height)
make.bottom.equalToSuperview()
}
tableView.reloadData()
}
// MARK: - Inits
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension HistoryDataTableViewCell: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.purchases.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HistoryProductTableViewCell", for: indexPath) as! HistoryProductTableViewCell
cell.selectionStyle = .none
cell.data = data.purchases[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let dvc = ProductDetailViewController()
dvc.product_id = data.purchases[indexPath.row].product.product_id
UIApplication.topViewController()?.navigationController?.pushViewController(dvc, animated: true)
}
}
| [
-1
] |
c2ca2cd7177ad98ec10ed18b27d0e6b88933f7a1 | 01790bc4ce434ef14d9efde669b3823a450f3bac | /mtrckr/Interactors/Transactions/TransactionsCalendarDataSource.swift | b8c50de28119fb2b9c667ca1d6bc0edd398a372a | [] | no_license | nicolettemanas/mtrckr | b122586fa577f68b9ac19e86771f348528e12ef8 | b9d60b322d35c47de585400f9ff975510c2aeeae | refs/heads/master | 2021-01-19T07:41:25.874142 | 2018-03-06T08:51:00 | 2018-03-06T08:51:00 | 87,562,656 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 8,455 | swift | //
// TransactionsCalendarDataSource.swift
// mtrckr
//
// Created by User on 7/18/17.
//
import UIKit
import JTAppleCalendar
import RealmSwift
protocol TransactionsCalendarDataSourceDelegate: class {
func didScrollto(dateSegmentWith visibleDates: DateSegmentInfo)
func didReceiveChanges(changes: RealmCollectionChange<Results<Transaction>>)
func didSelect(date: Date)
}
protocol TransactionsCalendarDataSourceProtocol: JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {
func reloadCalendar(with accounts: [Account], initialDate: Date)
func reloadDates(dates: [Date])
func allAccounts() -> [Account]
}
class TransactionsCalendarDataSource: RealmHolder, TransactionsCalendarDataSourceProtocol {
weak var calendar: JTAppleCalendarView?
weak var delegate: TransactionsCalendarDataSourceDelegate?
var transactions: Results<Transaction>?
var transactionDict: [Date: (String, String)] = [:]
var notificationToken: NotificationToken?
init(calendar cal: JTAppleCalendarView, delegate del: TransactionsCalendarDataSourceDelegate, initialMonth: Date) {
super.init(with: RealmAuthConfig())
calendar = cal
delegate = del
setupTransactions(initialDate: initialMonth, accounts: [])
}
func setupTransactions(initialDate: Date, accounts: [Account]) {
let startDate = initialDate.subtract(3.months)
let endDate = initialDate.add(3.months)
self.transactions = Transaction.all(in: self.realmContainer!.userRealm!, between: startDate.start(of: .month),
and: endDate.end(of: .month), inAccounts: accounts)
self.notificationToken = self.transactions?.observe({ [weak self] collectionChange in
if let strongSelf = self {
strongSelf.delegate?.didReceiveChanges(changes: collectionChange)
}
})
}
func reloadDates(dates: [Date]) {
for date in dates {
let safeTransactions = ThreadSafeReference(to: self.transactions!)
DispatchQueue.global(qos: .background).async {
let resolvedTransactions: Results<Transaction>? = self.realmContainer!.userRealm!.resolve(safeTransactions)
let filteredTransactions: Results<Transaction>? =
self.filter(transactions: resolvedTransactions, for: date)
let transSum = self.sum(of: filteredTransactions)
self.transactionDict[date.start(of: .day)] = transSum
DispatchQueue.main.async {
self.calendar?.reloadDates(dates)
}
}
}
}
func reloadCalendar(with accounts: [Account], initialDate: Date) {
self.transactionDict = [:]
setupTransactions(initialDate: initialDate, accounts: accounts)
self.calendar?.reloadData()
}
func allAccounts() -> [Account] {
return Array(Account.all(in: self.realmContainer!.userRealm!))
}
func sum(of transactions: Results<Transaction>?) -> (String, String) {
guard let trans = transactions else { return ("", "") }
var expenses: Double = 0
var income: Double = 0
let currency = realmContainer!.currency()
for tran in trans {
if tran.type == TransactionType.expense.rawValue {
expenses += tran.amount
} else if tran.type == TransactionType.income.rawValue {
income += tran.amount
}
}
return (expenses > 0 ? (NumberFormatter.currencyKString(withCurrency: currency, amount: expenses) ?? "") : "",
income > 0 ? (NumberFormatter.currencyKString(withCurrency: currency, amount: income) ?? "") : "")
}
func filter(transactions: Results<Transaction>?, for date: Date) -> Results<Transaction>? {
return transactions?.filter("transactionDate >= %@ AND transactionDate <= %@",
date.start(of: .day),
date.end(of: .day))
}
}
extension TransactionsCalendarDataSource: JTAppleCalendarViewDataSource {
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let parameters = ConfigurationParameters(startDate: Date().start(of: .year),
endDate: Date().end(of: .year),
numberOfRows: 6, calendar: Calendar.current,
generateInDates: InDateCellGeneration.forAllMonths,
generateOutDates: OutDateCellGeneration.tillEndOfGrid,
firstDayOfWeek: DaysOfWeek.sunday,
hasStrictBoundaries: true)
return parameters
}
}
extension TransactionsCalendarDataSource: JTAppleCalendarViewDelegate {
func calendar(_ calendar: JTAppleCalendarView,
willDisplay cell: JTAppleCell,
forItemAt date: Date,
cellState: CellState,
indexPath: IndexPath) {
}
func calendar(_ calendar: JTAppleCalendarView,
cellForItemAt date: Date,
cellState: CellState,
indexPath: IndexPath) -> JTAppleCell {
guard let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "customCalendarCell", for: indexPath)
as? CustomCalendarCell else { fatalError("Cannot find cell with identifier customCalendarCell") }
cell.dateLabel.text = cellState.text
cell.configureCell(cellState: cellState)
if let transSum = transactionDict[date] {
cell.expensesLabel.text = transSum.0
cell.incomeLabel.text = transSum.1
} else {
if let trans = self.transactions {
let threadSafeTransactions = ThreadSafeReference(to: trans)
DispatchQueue.global(qos: .background).async {
autoreleasepool(invoking: {
let resolvedTransactions = self.realmContainer!.userRealm!.resolve(threadSafeTransactions)
let transactionsForDate = resolvedTransactions!
.filter("transactionDate >= %@ AND transactionDate <= %@",
date.start(of: .day), date.end(of: .day))
let transSum = self.sum(of: transactionsForDate)
self.transactionDict[date] = transSum
DispatchQueue.main.async {
cell.expensesLabel.text = transSum.0
cell.incomeLabel.text = transSum.1
}
})
}
}
}
return cell
}
func calendar(_ calendar: JTAppleCalendarView,
didSelectDate date: Date,
cell: JTAppleCell?,
cellState: CellState) {
guard let validCell = cell as? CustomCalendarCell else { return }
print("Didselect cell date \(date)")
calendar.visibleDates({ [unowned self] datesInfo in
if datesInfo.monthDates.first?.date.month != date.month {
self.calendar?.scrollToDate(date)
print("Scroll to \(date)")
} else {
print("Configure cell \(date)")
validCell.configureCell(cellState: cellState)
}
})
delegate?.didSelect(date: date)
}
func calendar(_ calendar: JTAppleCalendarView,
didDeselectDate date: Date,
cell: JTAppleCell?,
cellState: CellState) {
guard let validCell = cell as? CustomCalendarCell else { return }
validCell.configureCell(cellState: cellState)
}
func calendar(_ calendar: JTAppleCalendarView,
didScrollToDateSegmentWith visibleDates: DateSegmentInfo) {
let date = (visibleDates.monthDates[5].date)
print("Did scroll to \(date)")
setupTransactions(initialDate: date, accounts: [])
delegate?.didScrollto(dateSegmentWith: visibleDates)
print("Will select \(visibleDates.monthDates[5].date)")
calendar.selectDates([date], triggerSelectionDelegate: true, keepSelectionIfMultiSelectionAllowed: true)
}
}
| [
-1
] |
5e2079b30612b1496006a06c3cabecfee4249842 | 57aa38a5e2d697a7b87730b7e4f80e144e4332e3 | /AudioKit/Common/Nodes/Generators/Polysynths/FM Oscillator Bank/AKFMOscillatorBank.swift | 7e0729f1aa26bb25fd30ad4370604ffe5cbcc9e9 | [
"MIT"
] | permissive | LIFX/AudioKit | 92b88d1e93690d355fe9c0b23454646214f5d3a8 | 3782e9933a93eb39b93f0167159d1e0b53643cab | refs/heads/master | 2021-10-13T16:01:15.727361 | 2021-05-03T06:28:45 | 2021-05-03T06:28:45 | 146,549,879 | 2 | 0 | MIT | 2020-09-15T23:07:53 | 2018-08-29T05:31:52 | C++ | UTF-8 | Swift | false | false | 10,269 | swift | //
// AKFMOscillatorBank.swift
// AudioKit
//
// Created by Aurelius Prochazka, revision history on Github.
// Copyright © 2018 AudioKit. All rights reserved.
//
/// Frequency Modulation Polyphonic Oscillator
///
open class AKFMOscillatorBank: AKPolyphonicNode, AKComponent {
public typealias AKAudioUnitType = AKFMOscillatorBankAudioUnit
/// Four letter unique description of the node
public static let ComponentDescription = AudioComponentDescription(instrument: "fmob")
// MARK: - Properties
private var internalAU: AKAudioUnitType?
/// Waveform of the oscillator
open var waveform: AKTable? {
//TODO: Add error checking for table size...needs to match init()
willSet {
if let wf = newValue {
for (i, sample) in wf.enumerated() {
self.internalAU?.setWaveformValue(sample, at: UInt32(i))
}
}
}
}
fileprivate var carrierMultiplierParameter: AUParameter?
fileprivate var modulatingMultiplierParameter: AUParameter?
fileprivate var modulationIndexParameter: AUParameter?
fileprivate var attackDurationParameter: AUParameter?
fileprivate var decayDurationParameter: AUParameter?
fileprivate var sustainLevelParameter: AUParameter?
fileprivate var releaseDurationParameter: AUParameter?
fileprivate var pitchBendParameter: AUParameter?
fileprivate var vibratoDepthParameter: AUParameter?
fileprivate var vibratoRateParameter: AUParameter?
/// Ramp Duration represents the speed at which parameters are allowed to change
@objc open dynamic var rampDuration: Double = AKSettings.rampDuration {
willSet {
internalAU?.rampDuration = newValue
}
}
/// This multiplied by the baseFrequency gives the carrier frequency.
@objc open dynamic var carrierMultiplier: Double = 1.0 {
willSet {
guard carrierMultiplier != newValue else { return }
if internalAU?.isSetUp == true {
carrierMultiplierParameter?.value = AUValue(newValue)
} else {
internalAU?.carrierMultiplier = AUValue(newValue)
}
}
}
/// This multiplied by the baseFrequency gives the modulating frequency.
@objc open dynamic var modulatingMultiplier: Double = 1 {
willSet {
guard modulatingMultiplier != newValue else { return }
if internalAU?.isSetUp == true {
modulatingMultiplierParameter?.value = AUValue(newValue)
} else {
internalAU?.modulatingMultiplier = AUValue(newValue)
}
}
}
/// This multiplied by the modulating frequency gives the modulation amplitude.
@objc open dynamic var modulationIndex: Double = 1 {
willSet {
guard modulationIndex != newValue else { return }
if internalAU?.isSetUp == true {
modulationIndexParameter?.value = AUValue(newValue)
} else {
internalAU?.modulationIndex = AUValue(newValue)
}
}
}
/// Attack duration in seconds
@objc open dynamic var attackDuration: Double = 0.1 {
willSet {
guard attackDuration != newValue else { return }
if internalAU?.isSetUp == true {
attackDurationParameter?.value = AUValue(newValue)
} else {
internalAU?.attackDuration = AUValue(newValue)
}
}
}
/// Decay duration in seconds
@objc open dynamic var decayDuration: Double = 0.1 {
willSet {
guard decayDuration != newValue else { return }
if internalAU?.isSetUp == true {
decayDurationParameter?.value = AUValue(newValue)
} else {
internalAU?.decayDuration = AUValue(newValue)
}
}
}
/// Sustain Level
@objc open dynamic var sustainLevel: Double = 1.0 {
willSet {
guard sustainLevel != newValue else { return }
if internalAU?.isSetUp == true {
sustainLevelParameter?.value = AUValue(newValue)
} else {
internalAU?.sustainLevel = AUValue(newValue)
}
}
}
/// Release duration in seconds
@objc open dynamic var releaseDuration: Double = 0.1 {
willSet {
guard releaseDuration != newValue else { return }
if internalAU?.isSetUp == true {
releaseDurationParameter?.value = AUValue(newValue)
} else {
internalAU?.releaseDuration = AUValue(newValue)
}
}
}
/// Pitch Bend as number of semitones
@objc open dynamic var pitchBend: Double = 0 {
willSet {
guard pitchBend != newValue else { return }
if internalAU?.isSetUp == true {
pitchBendParameter?.value = AUValue(newValue)
} else {
internalAU?.pitchBend = AUValue(newValue)
}
}
}
/// Vibrato Depth in semitones
@objc open dynamic var vibratoDepth: Double = 0 {
willSet {
guard vibratoDepth != newValue else { return }
if internalAU?.isSetUp == true {
vibratoDepthParameter?.value = AUValue(newValue)
} else {
internalAU?.vibratoDepth = AUValue(newValue)
}
}
}
/// Vibrato Rate in Hz
@objc open dynamic var vibratoRate: Double = 0 {
willSet {
guard vibratoRate != newValue else { return }
if internalAU?.isSetUp == true {
vibratoRateParameter?.value = AUValue(newValue)
} else {
internalAU?.vibratoRate = AUValue(newValue)
}
}
}
// MARK: - Initialization
/// Initialize the oscillator with defaults
@objc public convenience override init() {
self.init(waveform: AKTable(.sine))
}
/// Initialize this oscillator node
///
/// - Parameters:
/// - waveform: The waveform of oscillation
/// - carrierMultiplier: This multiplied by the baseFrequency gives the carrier frequency.
/// - modulatingMultiplier: This multiplied by the baseFrequency gives the modulating frequency.
/// - modulationIndex: This multiplied by the modulating frequency gives the modulation amplitude.
/// - attackDuration: Attack duration in seconds
/// - decayDuration: Decay duration in seconds
/// - sustainLevel: Sustain Level
/// - releaseDuration: Release duration in seconds
/// - pitchBend: Change of pitch in semitones
/// - vibratoDepth: Vibrato size in semitones
/// - vibratoRate: Frequency of vibrato in Hz
///
@objc public init(
waveform: AKTable,
carrierMultiplier: Double = 1,
modulatingMultiplier: Double = 1,
modulationIndex: Double = 1,
attackDuration: Double = 0.1,
decayDuration: Double = 0.1,
sustainLevel: Double = 1,
releaseDuration: Double = 0.1,
pitchBend: Double = 0,
vibratoDepth: Double = 0,
vibratoRate: Double = 0) {
self.waveform = waveform
self.carrierMultiplier = carrierMultiplier
self.modulatingMultiplier = modulatingMultiplier
self.modulationIndex = modulationIndex
self.attackDuration = attackDuration
self.decayDuration = decayDuration
self.sustainLevel = sustainLevel
self.releaseDuration = releaseDuration
self.pitchBend = pitchBend
self.vibratoDepth = vibratoDepth
self.vibratoRate = vibratoRate
_Self.register()
super.init()
AVAudioUnit._instantiate(with: _Self.ComponentDescription) { [weak self] avAudioUnit in
self?.avAudioUnit = avAudioUnit
self?.avAudioNode = avAudioUnit
self?.midiInstrument = avAudioUnit as? AVAudioUnitMIDIInstrument
self?.internalAU = avAudioUnit.auAudioUnit as? AKAudioUnitType
self?.internalAU?.setupWaveform(Int32(waveform.count))
for (i, sample) in waveform.enumerated() {
self?.internalAU?.setWaveformValue(sample, at: UInt32(i))
}
}
guard let tree = internalAU?.parameterTree else {
AKLog("Parameter Tree Failed")
return
}
carrierMultiplierParameter = tree["carrierMultiplier"]
modulatingMultiplierParameter = tree["modulatingMultiplier"]
modulationIndexParameter = tree["modulationIndex"]
attackDurationParameter = tree["attackDuration"]
decayDurationParameter = tree["decayDuration"]
sustainLevelParameter = tree["sustainLevel"]
releaseDurationParameter = tree["releaseDuration"]
pitchBendParameter = tree["pitchBend"]
vibratoDepthParameter = tree["vibratoDepth"]
vibratoRateParameter = tree["vibratoRate"]
internalAU?.carrierMultiplier = Float(carrierMultiplier)
internalAU?.modulatingMultiplier = Float(modulatingMultiplier)
internalAU?.modulationIndex = Float(modulationIndex)
internalAU?.attackDuration = Float(attackDuration)
internalAU?.decayDuration = Float(decayDuration)
internalAU?.sustainLevel = Float(sustainLevel)
internalAU?.releaseDuration = Float(releaseDuration)
internalAU?.pitchBend = Float(pitchBend)
internalAU?.vibratoDepth = Float(vibratoDepth)
internalAU?.vibratoRate = Float(vibratoRate)
}
// MARK: - AKPolyphonic
// Function to start, play, or activate the node at frequency
open override func play(noteNumber: MIDINoteNumber,
velocity: MIDIVelocity,
frequency: Double,
channel: MIDIChannel = 0) {
internalAU?.startNote(noteNumber, velocity: velocity, frequency: Float(frequency))
}
/// Function to stop or bypass the node, both are equivalent
open override func stop(noteNumber: MIDINoteNumber) {
internalAU?.stopNote(noteNumber)
}
}
| [
351686
] |
22527019504c1702a84f3a9e1933d1f7bcfa3fd8 | 2a345da4b7a210f5f25f394ef7a772eed5bf542f | /BAM/Source/BAMify/Keyword.swift | 6df4e3ceb45127616879240db80c70f0bb1c7132 | [] | no_license | wwe-johndpope/BAMify | 8603de698ee55fda79010908053a0040b5d387cd | d8ec70556a27c3f0fbd5ca706a9d55753412708f | refs/heads/master | 2021-05-16T13:13:42.746666 | 2017-09-30T12:39:00 | 2017-09-30T12:39:00 | 105,368,626 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,429 | swift | // Generated from graphql_swift_gen gem
import Foundation
extension BAMify {
open class KeywordQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = Keyword
@discardableResult
open func type(aliasSuffix: String? = nil) -> KeywordQuery {
addField(field: "type", aliasSuffix: aliasSuffix)
return self
}
@discardableResult
open func value(aliasSuffix: String? = nil) -> KeywordQuery {
addField(field: "value", aliasSuffix: aliasSuffix)
return self
}
}
open class Keyword: GraphQL.AbstractResponse, GraphQLObject {
public typealias Query = KeywordQuery
open override func deserializeValue(fieldName: String, value: Any) throws -> Any? {
let fieldValue = value
switch fieldName {
case "type":
if value is NSNull { return nil }
guard let value = value as? String else {
throw SchemaViolationError(type: Keyword.self, field: fieldName, value: fieldValue)
}
return value
case "value":
if value is NSNull { return nil }
guard let value = value as? String else {
throw SchemaViolationError(type: Keyword.self, field: fieldName, value: fieldValue)
}
return value
default:
throw SchemaViolationError(type: Keyword.self, field: fieldName, value: fieldValue)
}
}
open var typeName: String { return "Keyword" }
open var type: String? {
return internalGetType()
}
func internalGetType(aliasSuffix: String? = nil) -> String? {
return field(field: "type", aliasSuffix: aliasSuffix) as! String?
}
open var value: String? {
return internalGetValue()
}
func internalGetValue(aliasSuffix: String? = nil) -> String? {
return field(field: "value", aliasSuffix: aliasSuffix) as! String?
}
override open func childObjectType(key: String) -> GraphQL.ChildObjectType {
switch(key) {
case "type":
return .scalar
case "value":
return .scalar
default:
return .scalar
}
}
override open func fetchChildObject(key: String) -> GraphQL.AbstractResponse? {
switch(key) {
default:
break
}
return nil
}
override open func fetchChildObjectList(key: String) -> [GraphQL.AbstractResponse] {
switch(key) {
default:
return []
}
}
open func childResponseObjectMap() -> [GraphQL.AbstractResponse] {
return []
}
open func responseObject() -> GraphQL.AbstractResponse {
return self as GraphQL.AbstractResponse
}
}
}
| [
-1
] |
df66cea6e206eaa04d3b44a3248ef4608580d5cb | 86e55e3d08f1e739449624d1ed477800d6a3a11b | /Chapter11/Generic_subscripts.playground/Contents.swift | 9c7a3d428380790e1b10ce77734cc241ddc5698f | [
"MIT"
] | permissive | hoffmanjon/Mastering-Swift-4-Fourth-Edition | 55c24f1173363cc06263323dd7730fc42ba31cbf | ea6dcd65ef35f75bb47f906cb022cc76deba129b | refs/heads/master | 2021-04-26T23:42:42.907652 | 2018-02-28T04:45:23 | 2018-02-28T04:45:23 | 123,842,965 | 1 | 0 | MIT | 2018-03-05T00:31:37 | 2018-03-05T00:31:37 | null | UTF-8 | Swift | false | false | 389 | swift | //: Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
struct GenericSubscript {
let dictionary: [String: Any] = [:]
subscript<T: Hashable>(item: T) -> Int {
return item.hashValue
}
subscript<T>(key: String) -> T? {
return dictionary[key] as? T
}
}
var g = GenericSubscript()
var x = g["test"]
| [
-1
] |
9c30fb54ac818fbcf343c3018b629e8c09d87a73 | 7cf78f138f6bd71488ce052094ae2df91056282a | /AdvancedCodable/JSONLoads.swift | 9f0000d3ff304de43bbb21852e78024b825cb099 | [] | no_license | DaytonSteffeny/AdvancedCodable | fd84eea615acf908395e63558ea8466902794b1c | 33bafb7d4ecc114613d827026766df1be1fb7d7f | refs/heads/master | 2020-07-25T18:40:01.311873 | 2019-09-14T04:35:10 | 2019-09-14T04:35:10 | 208,388,951 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,697 | swift | //
// JSONLoads.swift
// AdvancedCodable
//
// Created by Dayton Steffeny on 9/13/19.
// Copyright © 2019 Dayton Steffeny. All rights reserved.
//
import Foundation
class JSONLoads {
class func loadRosters(jsonFileName: String) -> Rosters? {
var rosters: Rosters?
let jsonDecoder = JSONDecoder()
if let jsonFileURL = Bundle.main.url(forResource: jsonFileName, withExtension: ".json"),
let jsonData = try? Data(contentsOf: jsonFileURL) {
rosters = try? jsonDecoder.decode(Rosters.self, from: jsonData)
} else {
print("JSON file not found.")
}
return rosters
}
class func loadSchedules(jsonFileName: String) -> Schedules? {
var schedules: Schedules?
let jsonDecoder = JSONDecoder()
if let jsonFileURL = Bundle.main.url(forResource: jsonFileName, withExtension: ".json"),
let jsonData = try? Data(contentsOf: jsonFileURL) {
schedules = try? jsonDecoder.decode(Schedules.self, from: jsonData)
} else {
print("JSON file not found.")
}
return schedules
}
class func loadNFLPlayers(jsonFileName: String) -> NFLplayers? {
var nflplayers: NFLplayers?
let jsonDecoder = JSONDecoder()
if let jsonFileURL = Bundle.main.url(forResource: jsonFileName, withExtension: ".json"),
let jsonData = try? Data(contentsOf: jsonFileURL) {
nflplayers = try? jsonDecoder.decode(NFLplayers.self, from: jsonData)
} else {
print("JSON file not found.")
}
return nflplayers
}
}
| [
-1
] |
909fc12242ff6ff2f6ada0dcdc4a6ccc7117bb2f | 5d895400ceecf4587f4de5ab18f7468b90d2983e | /Project-8-Moonshot/Project-8-Moonshot/Mission.swift | b97d22e73a4372e39a5efa1cb36110a415847dc0 | [] | no_license | jthmiranda/HackingWithSwiftTraining | a54cd8af33cf23855efcc8cd6819dacaa8281237 | 7d7ca1f20bee0ca80bf917113ea5658082997e23 | refs/heads/master | 2021-01-04T00:46:02.715650 | 2020-09-08T04:05:27 | 2020-09-08T04:05:27 | 240,308,397 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 803 | swift | //
// Mission.swift
// Project-8-Moonshot
//
// Created by Jonathan Miranda on 7/13/20.
// Copyright © 2020 Jonathan Miranda. All rights reserved.
//
import Foundation
struct Mission: Codable, Identifiable {
struct CrewRole: Codable {
let name: String
let role: String
}
let id: Int
var launchDate: Date?
let crew: [CrewRole]
let description: String
var displayName: String {
"Apollo \(id)"
}
var image: String {
"apollo\(id)"
}
var formattedLaunchDate: String {
if let launchDate = launchDate {
let formatter = DateFormatter()
formatter.dateStyle = .long
return formatter.string(from: launchDate)
} else {
return "N/A"
}
}
}
| [
343094,
350415
] |
fd9f6e57f7e6fae328551a57a03c9f3109433184 | 69561078559bec5d6384f2690b0ccc32138b3de2 | /DemoDraw/ContentView.swift | 353143b03e76a528b04ee5bf6673830f3f9e443f | [] | no_license | lan-yin/Dolphin-Safe-UIBezierPath- | 709af182f1b75f2c7f324f1bb2544bc064a33fad | 9d597f6c5a85585027b9eeb064fdf8d05c04e11f | refs/heads/main | 2023-01-22T23:31:33.489382 | 2020-12-05T13:33:40 | 2020-12-05T13:33:40 | 319,693,647 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 330 | swift | //
// ContentView.swift
// DemoDraw
//
// Created by Lan Yin Lu on 2020/12/5.
//
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
| [
-1
] |
424f5829a7a67152970f26f5539674bb91e0998b | fa1f0634bdb1986feb8d23524c440aa416968d63 | /Place_Friendly_10/ShowCategory.swift | 12e2d52e37da9f54046b4050971bf25b5ccf8cef | [] | no_license | surachet11/Place_Friendly | d937e1a8a9b7730c7b28430932e41aee53271988 | 5c8e2d6db37c11c40ccf3c362e271d13b6d36ae1 | refs/heads/master | 2020-06-15T17:00:01.086612 | 2016-12-02T01:50:42 | 2016-12-02T01:50:42 | 75,272,573 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 5,632 | swift | //
// ShowCategory.swift
// Place_Freindly
//
// Created by Surachet Songsakaew on 9/5/2558 BE.
// Copyright (c) 2558 Surachet Songsakaew. All rights reserved.
//
import UIKit
import Parse
class ShowCategory: UITableViewController {
var placeArray = NSMutableArray()
var categoryArray = [PFObject]()
var placeName: String = ""
var itemCount : NSInteger = 0
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
queryCategory()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.placeArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCell(withIdentifier: "ShowPlaceCell", for: indexPath) as! ShowCell
var placeClass = PFObject(className: PLACE_CLASS_NAME)
placeClass = placeArray[indexPath.row] as! PFObject
let imageFile = placeClass[PLACE_IMAGE1] as? PFFile
imageFile?.getDataInBackground{ (imageData,error) -> Void in
if error == nil {
if let imageData = imageData {
cell.showImage.image = UIImage(data: imageData)
}
}
}
cell.showTitle.text = "\(placeClass[PLACE_TITLE]!)"
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var placeClass = PFObject(className: PLACE_CLASS_NAME)
placeClass = placeArray[indexPath.row] as! PFObject
let showPlaceVC = self.storyboard?.instantiateViewController(withIdentifier: "ShowSinglePlace") as! ShowSinglePlace
//showPlaceVC.eventObj = placeClass
showPlaceVC.singleID = placeClass.objectId!
self.navigationController?.pushViewController(showPlaceVC, animated: true)
}
func queryCategory() {
placeArray.removeAllObjects()
showHUD()
let itemCount = 0
let query = PFQuery(className:PLACE_CLASS_NAME)
query.whereKey(PLACE_CATEGORY, contains: categoriesArray[itemCount])
query.order(byAscending: PLACE_UPDATED_AT)
query.limit = 20
query.findObjectsInBackground { (objects, error) -> Void in
if error == nil {
if let objects = objects as [PFObject]! {
for object in objects {
self.placeArray.add(object)
}
}
self.tableView.reloadData()
} else {
self.simpleAlert("\(error!.localizedDescription)")
}
self.hideHUD()
}
}
/*
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
// Configure the cell...
return cell
}
*/
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
}
| [
-1
] |
36d8ce40afff4d081e56c4dbbb8c9e6d96db11da | 11d6c64a2047ccdd39832a18c574ab15915867fc | /Print.swift | 707aedc87efbf23ea1c3b56179ce9b4ff8c28699 | [] | no_license | marciok/Fabienne | e65b438b25fc17559b2e527e7e9a8d8384bcb806 | 8055341d59072de9134d7dd4dc4532f040791215 | refs/heads/master | 2021-01-17T17:37:16.684954 | 2016-11-22T22:26:33 | 2016-11-22T22:26:33 | 70,496,297 | 2 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 422 | swift | //
// Print.swift
// Fabienne
//
// Created by Marcio Klepacz on 11/13/16.
// Copyright © 2016 Marcio Klepacz. All rights reserved.
//
import Foundation
@_silgen_name("printd")
public func printd(char: Int) -> Int {
print("> \(char) <")
return char
}
@_silgen_name("putchard")
public func putchard(char: Int) -> Int {
print(Character(UnicodeScalar(char)!), terminator: "")
return char
}
| [
-1
] |
964d9446540e5d13a2f6d9b2b2ff83a43bac5b15 | 2d7b00023d4acc9cd62dc7ca65acc137c606d88b | /Examples/Examples/ViewControllers/Programmatically.swift | 0bca66b9304e7f2bb3ea45166f2391db75db20fa | [
"MIT"
] | permissive | 84bits/KSTokenView | 301916b60505d9c4e92a5db154a09caf92c804db | e6e4ad0c2949574f3e3907ab55423227550f30ec | refs/heads/master | 2021-01-19T05:03:01.948603 | 2017-07-04T08:14:41 | 2017-07-04T08:14:41 | 87,410,872 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,222 | swift | //
// Programmatically.swift
// Examples
//
// Created by Khawar Shahzad on 01/01/2015.
// Copyright (c) 2015 Khawar Shahzad. All rights reserved.
//
// 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
class Programmatically: UIViewController {
let names = List.names()
var tokenView: KSTokenView = KSTokenView(frame: .zero)
@IBOutlet weak var shouldChangeSwitch: UISwitch!
override func viewDidLoad() {
super.viewDidLoad()
tokenView = KSTokenView(frame: CGRect(x: 10, y: 220, width: 300, height: 30))
tokenView.delegate = self
tokenView.promptText = "Favorites: "
tokenView.placeholder = "Type to search"
tokenView.descriptionText = "Languages"
tokenView.style = .squared
view.addSubview(tokenView)
for i in 0...20 {
let token: KSToken = KSToken(title: names[i])
tokenView.addToken(token)
}
}
@IBAction func addToken(sender: AnyObject) {
let title = names[Int(arc4random_uniform(UInt32(names.count)))] as String
let token = KSToken(title: title, object: title as AnyObject?)
// Token background color
var red = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
var green = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
var blue = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
token.tokenBackgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
// Token text color
red = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
green = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
blue = CGFloat(Float(arc4random()) / Float(UINT32_MAX))
token.tokenTextColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
tokenView.addToken(token)
}
@IBAction func deleteLastToken(sender: AnyObject) {
tokenView.deleteLastToken()
}
@IBAction func deleteAllTokens(sender: AnyObject) {
tokenView.deleteAllTokens()
}
}
extension Programmatically: KSTokenViewDelegate {
func tokenView(_ token: KSTokenView, performSearchWithString string: String, completion: ((_ results: Array<AnyObject>) -> Void)?) {
var data: Array<String> = []
for value: String in names {
if value.lowercased().range(of: string.lowercased()) != nil {
data.append(value)
}
}
completion!(data as Array<AnyObject>)
}
func tokenView(_ token: KSTokenView, displayTitleForObject object: AnyObject) -> String {
return object as! String
}
func tokenView(_ tokenView: KSTokenView, shouldChangeAppearanceForToken token: KSToken) -> KSToken? {
if !shouldChangeSwitch.isOn {
token.tokenBackgroundColor = UIColor.red
token.tokenTextColor = UIColor.black
}
return token
}
func tokenView(_ tokenView: KSTokenView, shouldAddToken token: KSToken) -> Bool {
var shouldAddToken = true
if (token.title == "f") {
shouldAddToken = false
}
return shouldAddToken
}
}
| [
-1
] |
716d46a0d6bc2b0711091d1e4523da94461d766b | 57633b58c96d1a5cce01930e9db9598d4078ccbd | /EmojiLibrary/EmojiHeaderView.swift | 0134edbe0112ea09b4e5dd5264de4ac7226534d7 | [] | no_license | YamamotoDesu/OldCollectionView | 7e34b207a3066bd0699cc15a3b8a7ba89e9fd869 | b4f999ec6a1a951a826cf9e82f58dc50e309b26c | refs/heads/main | 2023-07-13T06:40:30.309841 | 2021-08-20T11:38:29 | 2021-08-20T11:38:29 | 397,948,857 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 276 | swift | //
// EmojiHeaderView.swift
// EmojiLibrary
//
// Created by 山本響 on 2021/08/16.
//
import UIKit
class EmojiHeaderView: UICollectionReusableView {
static let reuseIdentifier = String(describing: EmojiHeaderView.self)
@IBOutlet weak var textLabel: UILabel!
}
| [
-1
] |
d186c50dc20ffb833a03538578ee22811fe5ea80 | e1d8f75f5d3db5aa140b6c28b7d5deabfd91d8ba | /Q2Tests/Q2Tests.swift | ea5c8e56df3bf51cd92ec8c45a31370b070017be | [] | no_license | varXY/ElectricianHelper | 7021de7cf8a060a5ceb9cce42d25c008335e3068 | ac777438f3610631a390be1dfad74516df358f3b | refs/heads/master | 2021-01-23T14:03:43.625766 | 2016-03-26T07:30:40 | 2016-03-26T07:30:40 | 44,355,556 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 882 | swift | //
// Q2Tests.swift
// Q2Tests
//
// Created by 文川术 on 15/9/12.
// Copyright (c) 2015年 xiaoyao. All rights reserved.
//
import UIKit
import XCTest
class Q2Tests: 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.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
| [
276481,
276484,
276489,
276492,
278541,
278550,
276509,
278561,
276543,
159807,
288834,
280649,
223318,
288857,
227417,
194652,
194653,
278624,
276577,
276581,
276582,
43109,
276585,
223340,
276589,
227439,
276592,
227446,
276603,
276606,
141450,
311435,
276627,
184475,
227492,
196773,
129203,
176314,
227528,
276684,
278742,
278746,
278753,
276709,
276710,
276715,
157944,
211193,
227576,
227585,
276737,
276744,
227592,
276748,
276753,
129301,
276760,
278810,
276764,
262450,
276787,
276792,
278846,
164162,
278856,
276813,
278862,
278863,
6482,
276821,
276822,
276831,
276835,
276839,
276847,
278898,
278908,
178571,
276891,
276900,
278954,
278965,
276919,
276920,
278969,
276925,
278985,
279002,
276958,
276962,
227813,
279019,
279022,
186893,
279054,
223767,
277017,
223769,
277029,
301634,
369220,
277066,
277083,
277094,
166507,
189036,
189037,
277101,
189043,
277118,
184962,
225933,
133774,
277133,
225936,
277138,
277142,
164512,
225956,
225962,
209581,
154291,
277172,
154294,
277175,
277176,
277182,
277190,
199366,
225997,
277198,
164563,
277204,
203477,
119513,
201442,
226043,
209660,
234241,
226051,
277254,
209670,
203529,
226058,
234256,
285463,
234268,
105246,
228129,
234280,
234283,
277294,
234286,
226097,
234301,
277312,
234304,
162626,
279362,
277316,
234311,
234312,
234317,
277327,
234323,
234326,
277339,
297822,
234335,
297826,
234340,
174949,
234343,
277354,
234346,
234349,
277360,
213876,
277366,
234361,
277370,
234367,
234372,
226181,
213894,
234377,
226189,
234381,
226194,
234387,
234392,
279456,
277410,
234404,
226214,
234409,
234412,
234419,
226227,
277435,
234430,
226241,
275397,
234438,
226249,
275410,
234450,
234451,
234454,
234457,
275418,
234463,
234466,
277479,
277480,
179176,
234482,
234492,
277505,
234498,
277510,
234503,
277513,
234506,
277517,
275469,
277518,
234509,
295953,
197647,
234517,
281625,
234530,
234534,
275495,
234539,
275500,
310317,
277550,
275505,
275506,
234548,
277563,
156733,
277566,
230463,
7230,
7229,
207938,
7231,
234560,
234565,
277574,
234569,
207953,
277585,
296018,
234583,
234584,
275547,
277596,
234594,
277603,
234603,
281707,
275565,
156785,
275571,
234612,
398457,
234622,
275590,
275591,
234631,
253063,
277640,
302217,
226451,
226452,
275607,
119963,
234652,
277665,
275620,
275625,
208043,
275628,
226479,
277690,
277694,
203989,
275671,
195811,
285929,
204022,
120055,
279814,
204041,
259363,
199971,
277800,
113962,
277803,
277806,
113966,
226608,
277809,
226609,
277814,
277815,
277821,
277824,
277825,
226624,
277831,
226632,
277834,
142669,
277838,
277841,
222548,
277845,
277844,
277852,
224605,
218462,
224606,
277856,
142689,
302438,
277862,
277866,
173420,
277868,
277871,
279919,
277878,
275831,
275832,
277882,
142716,
275838,
275839,
277890,
277891,
226694,
275847,
277896,
277897,
277900,
230799,
296338,
277907,
206228,
226711,
226712,
277919,
277920,
277925,
277927,
277936,
277939,
296375,
277943,
277946,
277949,
277952,
296387,
163269,
277957,
296391,
277962,
282060,
277965,
284116,
277974,
228823,
228824,
277977,
277980,
226781,
277983,
277988,
187878,
277993,
296425,
277994,
277997,
278002,
278005,
226805,
278008,
153095,
175625,
192010,
280077,
65041,
204313,
278056,
278060,
226875,
128583,
226888,
276046,
276050,
226906,
243292,
226910,
276085,
314998,
276088,
278140,
276092,
188031,
276097,
276100,
276101,
312972,
278160,
276116,
276117,
276120,
278170,
280220,
276126,
278191,
276146,
278195,
276148,
296628,
278201,
276156,
276165,
278214,
323276,
276179,
276180,
216795,
216796,
276195,
313065,
276210,
276211,
276219,
171776,
278285,
227091,
184086,
278299,
276253,
276257,
278307,
288547,
159533,
276279,
276282,
276283,
276287,
276298,
296779,
276311,
276325,
227177,
276332,
173936,
110452,
227199,
44952,
247712,
276394,
276400,
276401,
276408,
161722,
276413,
276421,
276422,
276430,
153552,
276444,
276450,
276451,
276454,
276459,
276462,
276463,
276468,
276469,
278518,
276475,
276478
] |
a8da9b2db7f00b1260553619613b102c8cf219ae | f6b9c5286754f2fa45fafd04feaebf0592338748 | /assignment_12-nov/CombineFrameWorkiOS/CombineFrameWorkiOS/Controllers/URLSession/PostListTableViewController.swift | 226a4d3f9ad9171e58fc6d92ff403367f446b794 | [] | no_license | its-talha/assignment_iOS | d6ad689265681cc54a9dd5a6f95aae2d5ebf769b | 954947f86f4b4c3640fa09d654c2ac5acbba72d4 | refs/heads/master | 2023-09-02T06:08:07.103763 | 2021-11-16T15:53:29 | 2021-11-16T15:53:29 | 410,287,214 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,330 | swift | //
// PostListTableViewController.swift
// CombineFrameWorkiOS
//
// Created by Mohammad Talha on 12/11/21.
//
import UIKit
import Combine
class PostListTableViewController: UITableViewController {
private var webService = Webservice()
private var cancellable: AnyCancellable?
private var posts = [Post]() {
didSet {
self.tableView.reloadData()
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.cancellable = self.webService.getPost()
.catch { _ in Just([Post]())}
.assign(to: \.posts, on: self)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return posts.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "PostTableViewCell", for: indexPath)
cell.textLabel?.text = "Title : " + self.posts[indexPath.row].title
cell.textLabel?.numberOfLines = 0
// cell.textLabel?.text = "Body : " + self.posts[indexPath.row].body
return cell
}
}
| [
-1
] |
63c63d67d5aabf3eb184d8a73215bb7029984101 | 7843ee90cbd91180d0842cd382f33266fce380f0 | /Guide Project - Light/AppDelegate.swift | 23e44414aa87428dcdce52b24ebe1725bcdf2e99 | [] | no_license | Nenavijunytie/Guide-Project---Light | b0fe6e29b2327eb315ebdf8dbc2e213f7db5e0ae | d26c4fc3f52fb476045476429402417ea9235148 | refs/heads/master | 2021-08-24T06:02:39.208975 | 2017-12-08T09:54:38 | 2017-12-08T09:54:38 | 113,433,965 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,180 | swift | //
// AppDelegate.swift
// Guide Project - Light
//
// Created by student on 07.12.2017.
// Copyright © 2017 student. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> 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 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,
278539,
294924,
229388,
278542,
327695,
229391,
278545,
229394,
278548,
229397,
229399,
229402,
352284,
229405,
278556,
278559,
229408,
294950,
229415,
229417,
327722,
237613,
229422,
360496,
229426,
237618,
229428,
311349,
286774,
286776,
319544,
286778,
229432,
204856,
352318,
286791,
237640,
286797,
278605,
311375,
163920,
237646,
196692,
319573,
311383,
278623,
278626,
319590,
311400,
278635,
303212,
278639,
131192,
278648,
237693,
303230,
327814,
303241,
131209,
417930,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
131264,
286916,
286922,
286924,
286926,
319694,
286928,
131281,
131278,
278743,
278747,
295133,
155872,
131299,
319716,
237807,
303345,
286962,
131314,
229622,
327930,
278781,
278783,
278785,
237826,
319751,
278792,
286987,
319757,
311569,
286999,
319770,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
295220,
287032,
155966,
319809,
319810,
278849,
319814,
311623,
319818,
311628,
229709,
319822,
287054,
278865,
229717,
196963,
196969,
139638,
213367,
106872,
319872,
311683,
319879,
311693,
65943,
319898,
311719,
278952,
139689,
278957,
311728,
278967,
180668,
311741,
278975,
319938,
278980,
98756,
278983,
319945,
278986,
319947,
278990,
278994,
311767,
279003,
279006,
188895,
172512,
287202,
279010,
279015,
172520,
319978,
279020,
172526,
311791,
279023,
172529,
279027,
319989,
172534,
180727,
164343,
279035,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
303623,
172552,
320007,
287238,
279051,
172558,
279055,
303632,
279058,
303637,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
311850,
279084,
172591,
172598,
279095,
172607,
172609,
172612,
377413,
172614,
172618,
303690,
33357,
287309,
303696,
279124,
172634,
262752,
254563,
172644,
311911,
189034,
295533,
172655,
172656,
352880,
295538,
189040,
172660,
287349,
189044,
189039,
287355,
287360,
295553,
172675,
295557,
311942,
303751,
287365,
352905,
311946,
287371,
279178,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
172702,
287390,
303773,
172705,
287394,
172707,
303780,
164509,
287398,
205479,
287400,
279208,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
303804,
328381,
287423,
328384,
172737,
279231,
287427,
312005,
312006,
107208,
172748,
287436,
107212,
172751,
287440,
295633,
172755,
303827,
279255,
172760,
287450,
303835,
279258,
189149,
303838,
213724,
312035,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
189169,
205564,
303871,
230146,
328453,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
295720,
303914,
279340,
205613,
279353,
230202,
312124,
328508,
222018,
295755,
377676,
148302,
287569,
303959,
230237,
279390,
230241,
279394,
303976,
336744,
303985,
303987,
328563,
279413,
303991,
303997,
295806,
295808,
295813,
304005,
320391,
304007,
304009,
213895,
304011,
230284,
304013,
295822,
189325,
213902,
189329,
295825,
304019,
279438,
189331,
58262,
304023,
304027,
279452,
410526,
279461,
279462,
304042,
213931,
230327,
304055,
287675,
230334,
304063,
238528,
304065,
213954,
189378,
156612,
295873,
213963,
197580,
312272,
304084,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
312321,
295945,
230413,
197645,
295949,
320528,
140312,
295961,
238620,
197663,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
230465,
238658,
336964,
296004,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
361576,
205931,
296044,
164973,
205934,
279661,
312432,
279669,
337018,
189562,
279679,
304258,
279683,
66690,
222340,
205968,
296084,
238745,
304285,
238756,
205991,
222377,
165035,
337067,
238766,
165038,
230576,
238770,
304311,
230592,
312518,
279750,
230600,
230607,
148690,
320727,
279769,
304348,
279777,
304354,
296163,
320740,
279781,
304360,
320748,
279788,
279790,
304370,
296189,
320771,
312585,
296202,
296205,
230674,
320786,
230677,
296213,
230679,
320792,
230681,
296215,
214294,
304416,
230689,
173350,
312622,
296243,
312630,
222522,
296253,
222525,
296255,
312639,
230718,
296259,
378181,
296262,
230727,
238919,
296264,
320840,
296267,
296271,
222545,
230739,
312663,
222556,
337244,
230752,
312676,
230760,
173418,
148843,
410987,
230763,
230768,
296305,
312692,
230773,
304505,
304506,
181626,
279929,
181631,
148865,
312711,
296331,
288140,
288144,
230800,
304533,
288154,
337306,
288160,
173472,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
288176,
279985,
312755,
296373,
312759,
279991,
288185,
337335,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
148946,
370130,
222676,
288210,
288212,
288214,
239064,
329177,
288217,
288218,
280027,
288220,
239070,
288224,
370146,
280034,
288226,
288229,
280036,
280038,
288232,
288230,
288234,
320998,
288236,
288238,
288240,
288242,
296435,
288244,
288250,
296446,
321022,
402942,
148990,
296450,
206336,
230916,
230919,
214535,
230923,
304651,
304653,
370187,
402969,
230940,
222752,
108066,
296486,
296488,
157229,
230961,
157236,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
288344,
280152,
239194,
280158,
403039,
370272,
181854,
239202,
370279,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
419489,
190118,
198310,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
419522,
280260,
419525,
206536,
280264,
206539,
206541,
206543,
263888,
313044,
280276,
321239,
280283,
313052,
18140,
288478,
313055,
419555,
321252,
313066,
288494,
280302,
280304,
313073,
321266,
288499,
419570,
288502,
280314,
288510,
124671,
67330,
280324,
198405,
288519,
280331,
198416,
280337,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
280375,
321336,
296767,
288576,
345921,
337732,
280388,
304968,
280393,
280402,
173907,
313171,
313176,
42842,
280419,
321381,
296809,
296812,
313201,
1920,
255873,
305028,
280454,
247688,
280464,
124817,
280468,
239510,
280473,
124827,
214940,
247709,
214944,
280487,
313258,
321458,
296883,
124853,
214966,
296890,
10170,
288700,
296894,
190403,
296900,
280515,
337862,
165831,
280521,
231379,
296921,
354265,
354270,
239586,
313320,
354281,
231404,
124913,
165876,
321528,
239612,
313340,
288764,
239617,
313347,
288773,
313358,
305176,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
215090,
124980,
288824,
288826,
321595,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
288848,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
149599,
280671,
149601,
321634,
149603,
223327,
329830,
280681,
313451,
223341,
280687,
149618,
215154,
313458,
280691,
313464,
329850,
321659,
280702,
288895,
321670,
215175,
141446,
141455,
275606,
141459,
280725,
313498,
100520,
288936,
280747,
288940,
288947,
280755,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
157930,
280811,
280817,
125171,
280819,
157940,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
305464,
280891,
289087,
280897,
280900,
305480,
239944,
280906,
239947,
305485,
305489,
379218,
280919,
248153,
215387,
354653,
354656,
313700,
280937,
313705,
190832,
280946,
223606,
313720,
280956,
239997,
280959,
313731,
199051,
240011,
289166,
240017,
297363,
190868,
240021,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
289210,
305594,
281024,
289218,
289221,
289227,
436684,
281045,
281047,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
305668,
223749,
330244,
240132,
223752,
150025,
338440,
281095,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
289317,
281127,
281135,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
281179,
338528,
338532,
281190,
199273,
281196,
19053,
158317,
313973,
297594,
281210,
158347,
264845,
182926,
133776,
182929,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
174764,
314029,
314033,
240309,
133817,
314045,
314047,
314051,
199364,
297671,
158409,
256716,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322314,
322318,
281361,
281372,
322341,
215850,
281388,
289593,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
158596,
183172,
338823,
322440,
314249,
240519,
183184,
289687,
224151,
240535,
289694,
289696,
289700,
289712,
281529,
289724,
52163,
183260,
420829,
281567,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
314372,
330764,
175134,
322599,
322610,
314421,
281654,
314427,
314433,
207937,
314441,
207949,
322642,
314456,
281691,
314461,
281702,
281704,
314474,
281708,
281711,
289912,
248995,
306341,
306344,
306347,
322734,
306354,
142531,
199877,
289991,
306377,
289997,
249045,
363742,
363745,
298216,
330988,
126190,
216303,
322801,
388350,
257302,
363802,
199976,
199978,
314671,
298292,
298294,
257334,
216376,
380226,
298306,
224584,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314718,
265568,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
306549,
298358,
314743,
306552,
290171,
314747,
298365,
290174,
306555,
224641,
281987,
298372,
314756,
281990,
224647,
265604,
298377,
314763,
142733,
298381,
314768,
224657,
306581,
314773,
314779,
314785,
314793,
282025,
282027,
241068,
241070,
241072,
282034,
241077,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
282089,
191985,
282098,
290291,
282101,
241142,
191992,
290298,
151036,
290302,
282111,
290305,
175621,
306694,
192008,
323084,
257550,
282127,
290321,
282130,
323090,
290325,
282133,
241175,
290328,
282137,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290351,
290356,
282186,
224849,
282195,
282199,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
224875,
241260,
323181,
257658,
315016,
282249,
290445,
282255,
282261,
175770,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
306856,
282295,
323260,
282300,
323266,
282310,
323273,
282319,
306897,
241362,
306904,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
323349,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
241450,
282410,
306988,
306991,
315184,
323376,
315190,
241464,
159545,
282425,
298811,
118593,
307009,
413506,
307012,
241475,
315211,
282446,
307027,
315221,
323414,
315223,
241496,
241498,
307035,
307040,
110433,
282465,
241509,
110438,
298860,
110445,
282478,
315249,
282481,
110450,
315251,
315253,
315255,
339838,
315267,
282499,
315269,
241544,
282505,
241546,
241548,
298896,
298898,
282514,
241556,
44948,
298901,
241560,
282520,
241563,
241565,
241567,
241569,
282531,
241574,
282537,
298922,
36779,
241581,
282542,
241583,
323504,
241586,
290739,
241588,
282547,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241640,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
299003,
241661,
299006,
282623,
315396,
241669,
315397,
282632,
307211,
282639,
290835,
282645,
241693,
282654,
102438,
217127,
282669,
323630,
282681,
290877,
282687,
159811,
315463,
315466,
192589,
307278,
192596,
176213,
307287,
307290,
217179,
315482,
192605,
315483,
233567,
299105,
200801,
217188,
299109,
307303,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
323700,
299126,
233591,
299136,
307329,
307338,
233613,
241813,
307352,
299164,
241821,
299167,
315552,
184479,
184481,
315557,
184486,
307370,
307372,
184492,
307374,
307376,
299185,
323763,
184503,
299191,
307385,
176311,
258235,
307388,
176316,
307390,
307386,
299200,
184512,
307394,
299204,
307396,
184518,
307399,
323784,
233679,
307409,
307411,
176343,
299225,
233701,
307432,
184572,
282881,
184579,
282893,
291089,
282906,
291104,
233766,
295583,
176435,
307508,
315701,
332086,
307510,
307512,
168245,
307515,
307518,
282942,
282947,
323917,
282957,
110926,
233808,
323921,
315733,
323926,
233815,
315739,
323932,
299357,
242018,
242024,
299373,
315757,
250231,
242043,
315771,
299388,
299391,
291202,
299398,
242057,
291212,
299405,
291222,
315801,
291226,
242075,
283033,
61855,
291231,
283042,
291238,
291241,
127403,
127405,
291247,
299440,
127407,
299444,
127413,
291254,
283062,
127417,
291260,
127421,
127424,
299457,
127429,
127431,
127434,
315856,
127440,
176592,
315860,
176597,
127447,
283095,
299481,
127449,
176605,
242143,
127455,
127457,
291299,
127460,
340454,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
127490,
127494,
283142,
127497,
233994,
135689,
127500,
291341,
233998,
127506,
234003,
127509,
234006,
127511,
152087,
283161,
242202,
234010,
135707,
135710,
242206,
242208,
291361,
242220,
291378,
152118,
234038,
234041,
315961,
70213,
242250,
111193,
242275,
299620,
242279,
168562,
184952,
135805,
135808,
291456,
299655,
373383,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
225948,
135839,
299680,
225954,
299684,
135844,
242343,
209576,
242345,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
299726,
225998,
226002,
119509,
226005,
226008,
299740,
242396,
201444,
299750,
283368,
234219,
283372,
185074,
226037,
283382,
316151,
234231,
234236,
226045,
242431,
234239,
209665,
234242,
299778,
242436,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
348950,
201496,
234264,
234266,
234269,
283421,
234272,
234274,
152355,
299814,
234278,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
242499,
234309,
316233,
234313,
316235,
234316,
283468,
234319,
242511,
234321,
234324,
185173,
201557,
234329,
234333,
308063,
234336,
242530,
349027,
234338,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
226171,
291711,
234368,
291714,
234370,
291716,
234373,
226182,
234375,
201603,
308105,
226185,
234379,
324490,
234384,
234388,
234390,
226200,
234393,
209818,
308123,
234396,
324508,
291742,
324504,
234398,
234401,
291747,
291748,
234405,
291750,
324518,
324520,
234407,
324522,
234410,
291756,
291754,
226220,
324527,
291760,
234417,
201650,
324531,
234414,
234422,
226230,
324536,
275384,
234428,
291773,
242623,
324544,
234431,
234434,
324546,
324548,
226239,
226245,
234437,
234439,
234443,
291788,
193486,
234446,
193488,
234449,
316370,
275406,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
234487,
324599,
234490,
234493,
316416,
234496,
308226,
234501,
275462,
308231,
234504,
234507,
234510,
234515,
300054,
316439,
234520,
234519,
234523,
234526,
234528,
300066,
234532,
300069,
234535,
234537,
234540,
234543,
234546,
275508,
300085,
234549,
300088,
234553,
234556,
234558,
316479,
234561,
316483,
160835,
234563,
308291,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
242777,
234590,
234593,
234595,
234597,
300133,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
316530,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
226433,
234627,
275588,
234629,
242822,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
324757,
234647,
234648,
226453,
234650,
308379,
275608,
300189,
324766,
119967,
234653,
324768,
283805,
234657,
242852,
300197,
234661,
283813,
234664,
177318,
275626,
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,
234726,
300263,
300265,
300267,
161003,
300270,
300272,
120053,
300278,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
161027,
300292,
300294,
275719,
234760,
177419,
300299,
242957,
300301,
349451,
177424,
275725,
283917,
349464,
415009,
283939,
259367,
292143,
283951,
300344,
226617,
243003,
283963,
226628,
300357,
283973,
177482,
283983,
316758,
357722,
316766,
316768,
292192,
218464,
292197,
316774,
243046,
218473,
284010,
136562,
324978,
333178,
275834,
275836,
275840,
316803,
316806,
226696,
316811,
226699,
316814,
226703,
300433,
234899,
300436,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
284076,
144814,
227426,
144820,
374196,
284084,
292279,
284087,
144826,
144828,
144830,
144832,
144835,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
226787,
218597,
292329,
300523,
259565,
300527,
308720,
259567,
292338,
226802,
316917,
292343,
308727,
300537,
316933,
316947,
308757,
308762,
284191,
316959,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
194101,
284213,
316983,
194103,
284215,
308790,
284218,
226877,
292414,
284223,
284226,
284228,
243268,
292421,
284231,
226886,
128584,
284234,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
284243,
300628,
284245,
292433,
284247,
317015,
235097,
243290,
284249,
276052,
276053,
300638,
284251,
284253,
284255,
284258,
243293,
292452,
292454,
284263,
177766,
284265,
292458,
284267,
292461,
284272,
284274,
284278,
292470,
276086,
292473,
284283,
276093,
284286,
292479,
284288,
292481,
284290,
325250,
284292,
292485,
325251,
276095,
276098,
284297,
317066,
284299,
317068,
284301,
276109,
284303,
284306,
276114,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
284329,
317098,
284331,
276137,
284333,
284335,
276144,
284337,
284339,
300726,
284343,
284346,
284350,
358080,
276160,
284354,
358083,
284358,
276166,
358089,
284362,
276170,
284365,
276175,
284368,
276177,
284370,
358098,
284372,
317138,
284377,
284379,
284381,
284384,
358114,
284386,
358116,
276197,
317158,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
284399,
358128,
276206,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
284428,
300816,
300819,
317207,
284440,
300828,
300830,
276255,
300832,
325408,
300834,
317221,
227109,
358183,
186151,
276268,
300845,
243504,
300850,
284469,
276280,
325436,
358206,
276291,
366406,
276295,
300872,
292681,
153417,
358224,
284499,
276308,
284502,
317271,
178006,
276315,
292700,
317279,
284511,
227175,
292715,
300912,
292721,
284529,
300915,
284533,
292729,
317306,
284540,
292734,
325512,
169868,
276365,
317332,
358292,
399252,
284564,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
317353,
284585,
276395,
292776,
292784,
276402,
358326,
161718,
358330,
276411,
276418,
276425,
301009,
301011,
301013,
292823,
358360,
301017,
301015,
292828,
276446,
153568,
276448,
276452,
292839,
276455,
350186,
292843,
276460,
178161,
227314,
276466,
325624,
350200,
276472,
317435,
276476,
276479,
350210,
276482,
178181,
317446,
276485,
350218,
276490,
292876,
350222,
317456,
276496,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
178224,
276528,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
243779,
325700,
284739,
292934,
243785,
276553,
350293,
350295,
309337,
227418,
350299,
194649,
350302,
194654,
350304,
178273,
309346,
227423,
194660,
350308,
309350,
309348,
292968,
309352,
350313,
309354,
350316,
227430,
276583,
301167,
276590,
350321,
284786,
276595,
301163,
350325,
252022,
227440,
350328,
292985,
301178,
350332,
292989,
301185,
292993,
350339,
317570,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
276638,
153765,
284837,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
301258,
309450,
276685,
309455,
276689,
309462,
301272,
276699,
194780,
309468,
309471,
301283,
317672,
317674,
325867,
243948,
194801,
227571,
309491,
309494,
243960,
227583,
276735,
227587,
276739,
211204,
276742,
227596,
325910,
309530,
342298,
211232,
317729,
276775,
211241,
325937,
325943,
211260,
260421,
276809,
285002,
276811,
235853,
276816,
235858,
276829,
276833,
391523,
276836,
293227,
276843,
293232,
276848,
186744,
211324,
227709,
285061,
366983,
317833,
178572,
285070,
285077,
178583,
227738,
317853,
276896,
317858,
342434,
285093,
317864,
285098,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
293325,
129486,
317910,
293336,
235996,
317917,
293343,
358880,
276961,
293346,
227810,
276964,
293352,
236013,
293364,
301562,
293370,
317951,
309764,
301575,
121352,
293387,
236043,
342541,
317963,
113167,
55822,
309779,
317971,
309781,
277011,
55837,
227877,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
219714,
129603,
301636,
318020,
301639,
301643,
285265,
399955,
309844,
277080,
309849,
285277,
285282,
326244,
318055,
277100,
309871,
121458,
277106,
170618,
170619,
309885,
309888,
277122,
227975,
277128,
285320,
301706,
318092,
326285,
334476,
318094,
277136,
277139,
227992,
318108,
285340,
318110,
227998,
137889,
383658,
285357,
318128,
277170,
293555,
342707,
154292,
277173,
318132,
285368,
277177,
277181,
318144,
277187,
277191,
277194,
277196,
277201,
342745,
137946,
342747,
342749,
113378,
203491,
228069,
277223,
342760,
285417,
56041,
56043,
56045,
277232,
228081,
56059,
310015,
285441,
310020,
285448,
310029,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
318253,
293677,
285489,
301876,
293685,
285494,
301880,
285499,
301884,
293696,
310080,
277317,
277322,
277329,
162643,
310100,
301911,
301913,
277337,
301921,
400236,
236397,
162671,
326514,
310134,
236408,
277368,
15224,
416639,
416640,
113538,
310147,
416648,
277385,
39817,
187274,
301972,
424853,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
293811,
276579,
293817,
293820,
203715,
326603,
342994,
276586,
293849,
293861,
228327,
228328,
318442,
228330,
228332,
326638,
277486,
351217,
318450,
293876,
293877,
285686,
302073,
121850,
293882,
302075,
244731,
285690,
293887,
277504,
277507,
277511,
293899,
277519,
293908,
302105,
293917,
293939,
318516,
277561,
277564,
310336,
7232,
293956,
277573,
228422,
293960,
310344,
277577,
277583,
203857,
293971,
310355,
310359,
236632,
277594,
138332,
277598,
203872,
277601,
285792,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
367737,
285817,
302205,
285821,
392326,
285831,
253064,
294026,
302218,
285835,
162964,
384148,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
302258,
277687,
294072,
318651,
294076,
277695,
318657,
244930,
302275,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
310486,
302296,
384222,
310498,
285927,
318698,
302315,
228592,
294132,
138485,
228601,
204026,
228606,
204031,
64768,
310531,
138505,
228617,
318742,
204067,
277798,
130345,
277801,
113964,
285997,
384302,
285999,
277804,
113969,
277807,
277811,
318773,
318776,
277816,
286010,
277819,
294204,
417086,
277822,
286016,
302403,
294211,
384328,
277832,
277836,
294221,
146765,
294223,
326991,
277839,
277842,
277847,
277850,
179547,
277853,
146784,
277857,
302436,
277860,
294246,
327015,
310632,
327017,
351594,
277864,
277869,
277872,
351607,
310648,
277880,
310651,
277884,
277888,
310657,
351619,
294276,
310659,
327046,
277892,
253320,
310665,
318858,
277894,
277898,
277903,
310672,
351633,
277905,
277908,
277917,
310689,
277921,
130468,
228776,
277928,
277932,
310703,
277937,
310710,
130486,
310712,
277944,
310715,
277947,
302526,
228799,
277950,
277953,
302534,
310727,
245191,
64966,
277959,
277963,
302541,
277966,
302543,
310737,
277971,
228825,
163290,
277978,
310749,
277981,
277984,
310755,
277989,
277991,
187880,
277995,
310764,
286188,
278000,
228851,
310772,
278003,
278006,
40440,
212472,
278009,
40443,
286203,
40448,
228864,
286214,
228871,
302603,
302614,
302617,
286233,
302621,
286240,
187936,
146977,
187939,
40484,
294435,
40486,
286246,
294440,
40488,
294439,
294443,
40491,
294445,
245288,
310831,
286248,
40499,
40502,
212538,
40507,
40511,
40513,
228933,
327240,
40521,
286283,
40525,
40527,
212560,
400976,
228944,
40533,
147032,
40537,
40539,
40541,
278109,
40544,
40548,
40550,
40552,
286312,
40554,
286313,
310892,
40557,
40560,
188022,
122488,
294521,
343679,
294537,
310925,
286354,
278163,
302740,
122517,
278168,
179870,
327333,
229030,
212648,
302764,
278188,
278192,
319153,
278196,
302781,
319171,
302789,
294599,
278216,
294601,
302793,
343757,
212690,
319187,
286420,
278227,
229076,
286425,
319194,
278235,
229086,
278238,
286432,
294625,
294634,
302838,
319226,
286460,
278274,
302852,
278277,
302854,
294664,
311048,
352008,
319243,
311053,
302862,
319251,
294682,
278306,
188199,
294701,
319280,
278320,
319290,
229192,
302925,
188247,
280021,
188252,
237409,
294776,
360317,
294785,
327554,
360322,
40840,
294803,
40851,
188312,
294811,
237470,
319390,
40865,
319394,
294817,
294821,
311209,
180142,
343983,
294831,
188340,
40886,
319419,
294844,
294847,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
311283,
278516,
278519,
237562
] |
66be1f98b3d6c593c9cb0494726bcc45f816e529 | 86812513a69b7aa50562ccb387ffc63f9d096ff3 | /AlgorithmsChapters/DP/GridMinCost.swift | cad98b21e36c48cd52f9a46fe7dd5185bce1168c | [] | no_license | Hemant-Jain-Author/Data-Structures-and-Algorithms-using-Swift | 42551db196aac618b9a25d910ea85358519855a7 | 680e26121fdde5cf06ad0c6c7391b2087730117d | refs/heads/master | 2023-01-04T22:03:28.624330 | 2022-12-27T08:07:41 | 2022-12-27T08:07:41 | 124,673,489 | 2 | 4 | null | null | null | null | UTF-8 | Swift | false | false | 1,090 | swift | import Foundation
func min(_ x : Int, _ y : Int, _ z : Int) -> Int {
return min(min(x,y), z)
}
func minCost(_ cost : inout [[Int]], _ m : Int, _ n : Int) -> Int {
if (m == 0 || n == 0) {
return 99999
}
if (m == 1 && n == 1) {
return cost[0][0]
}
return cost[m - 1][n - 1] + min(minCost( &cost,m - 1,n - 1),minCost( &cost,m - 1,n),minCost( &cost,m,n - 1))
}
func minCostBU(_ cost : inout [[Int]], _ m : Int, _ n : Int) -> Int {
var tc : [[Int]] = Array(repeating: Array(repeating: 0, count: n), count: m)
tc[0][0] = cost[0][0]
var i : Int = 1 // Initialize first column.
while (i < m) {
tc[i][0] = tc[i - 1][0] + cost[i][0]
i += 1
}
var j : Int = 1 // Initialize first row.
while (j < n) {
tc[0][j] = tc[0][j - 1] + cost[0][j]
j += 1
}
i = 1
while (i < m) {
j = 1
while (j < n) {
tc[i][j] = cost[i][j] + min(tc[i - 1][j - 1],tc[i - 1][j],tc[i][j - 1])
j += 1
}
i += 1
}
return tc[m - 1][n - 1]
}
// Testing code.
var cost : [[Int]] = [[1, 3, 4],[4, 7, 5],[1, 5, 3]]
print(minCost( &cost,3,3))
print(minCostBU( &cost,3,3))
/*
11
11
*/
| [
-1
] |
04c6059087dbf5a1b039d6b253e36f4a33dbda66 | eee1ae5f60cce3dd8bd53af9bd3dfe83b069beb5 | /Sources/Transcripts/Collections/CaseStudies.swift | 556499fa20b9004a77e36b8dc2e9dacd982359cd | [
"MIT",
"CC-BY-NC-4.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-unknown-license-reference",
"CC-BY-NC-SA-4.0",
"LicenseRef-scancode-proprietary-license",
"CC-BY-4.0"
] | permissive | pointfreeco/pointfreeco | 1c7b0124f4a45ae4dbabcf46d44c8a4da8048a1f | 279274c4bc1e566154ebb2a6add5acde0d50bf9e | refs/heads/main | 2023-09-01T15:34:37.517187 | 2023-08-28T21:34:44 | 2023-08-28T21:35:22 | 102,958,914 | 1,094 | 117 | MIT | 2023-09-13T18:49:26 | 2017-09-09T14:02:08 | Swift | UTF-8 | Swift | false | false | 5,142 | swift | extension Episode.Collection {
public static let caseStudies = Self(
blurb: """
The Composable Architecture can help build large, complex applications in a consistent, modular and testable manner, but it can still be difficult to figure out how to solve certain common problems. This case studies collection will analyze some common, real life problems and show how to approach them in the Composable Architecture.
""",
sections: [
.swiftUIRedactions(),
.conciseForms,
.swiftUIAnimations(),
.derivedBehavior,
],
title: "Case Studies"
)
}
extension Episode.Collection.Section {
public static let conciseForms = Self(
blurb: """
Forms and settings screens in applications display lots of editable data at once, but due to how the Composable Architecture is designed this can lead to some boilerplate. We show how to fix this deficiency and make the Composable Architecture as concise as vanilla SwiftUI applications.
""",
coreLessons: [
.init(episode: .ep131_conciseForms),
.init(episode: .ep132_conciseForms),
.init(episode: .ep133_conciseForms),
.init(episode: .ep134_conciseForms),
.init(episode: .ep158_saferConciserForms),
.init(episode: .ep159_saferConciserForms),
],
related: [
.init(
blurb: """
For more on the Composable Architecture, be sure to check out the entire collection \
where we break down the problems of application architecture to build a solution \
from first principles.
""",
content: .collections([
.composableArchitecture
])
)
],
title: "Concise Forms",
whereToGoFromHere: nil
)
public static var derivedBehavior = Self(
blurb: #"""
The ability to break down applications into small domains that are understandable in isolation is a universal problem, and yet there is no default story for doing so in SwiftUI. We explore the problem space and solutions, in both vanilla SwiftUI and the Composable Architecture.
"""#,
coreLessons: [
.init(episode: .ep146_derivedBehavior),
.init(episode: .ep147_derivedBehavior),
.init(episode: .ep148_derivedBehavior),
.init(episode: .ep149_derivedBehavior),
.init(episode: .ep150_derivedBehavior),
],
related: [
.init(
blurb: """
For more on the Composable Architecture, be sure to check out the entire collection \
where we break down the problems of application architecture to build a solution \
from first principles.
""",
content: .collections([
.composableArchitecture
])
)
],
title: "Derived Behavior",
whereToGoFromHere: nil
)
public static func swiftUIRedactions(title: String = "SwiftUI Redactions") -> Self {
Self(
blurb: #"""
SwiftUI has introduced the concept of “redacted views”, which gives you a really nice way to redact the a view's content. This is really powerful, but just because the view has been redacted it doesn’t mean the logic has been. We will demonstrate this problem and show how the Composable Architecture offers a really nice solution.
"""#,
coreLessons: [
.init(episode: .ep115_redactions_pt1),
.init(episode: .ep116_redactions_pt2),
.init(episode: .ep117_redactions_pt3),
.init(episode: .ep118_redactions_pt4),
],
related: [
.init(
blurb: #"""
For more on the Composable Architecture, be sure to check out the entire collection where we break down the problems of application architecture to build a solution from first principles.
"""#,
content: .collection(.composableArchitecture)
)
],
title: "Redactions",
whereToGoFromHere: nil
)
}
public static func swiftUIAnimations(title: String = "SwiftUI Animations") -> Self {
Self(
blurb: """
Animations are one of the most impressive features of SwiftUI. With very little work you can
animate almost any aspect of a SwiftUI application. We take a deep-dive into the various
flavors of animations (implicit versus explicit), and show that a surprising transformation
of Combine schedulers allows us to animate asynchronous data flow in a seamless manner,
which is applicable to both vanilla SwiftUI applications and Composable Architecture
applications.
""",
coreLessons: [
.init(episode: .ep135_animations),
.init(episode: .ep136_animations),
.init(episode: .ep137_animations),
],
related: [
.init(
blurb: """
For more on the Composable Architecture, be sure to check out the entire collection \
where we break down the problems of application architecture to build a solution from \
first principles.
""",
content: .collections([
.composableArchitecture
])
)
],
title: title,
whereToGoFromHere: nil
)
}
}
| [
-1
] |
d51f967745ffff1726f5f75c383ad82144573b7c | f127bc5949dfcca79fd1955c1f31a7de13138ec0 | /Down?/Down?/MainNavigationVC/HomeFeed/Feed/HomeFeedTableExtension.swift | 39b0de779925115c8a1aa9aec1753c9c2573bd23 | [] | no_license | jameslu255/Down-Project | b93509a3eb79cbf4c5dba01909a3c936a3ab489a | 70f1f7f8389a5556ad101a3d571a9681629ec1e3 | refs/heads/master | 2020-12-10T20:12:48.544015 | 2020-01-13T22:14:05 | 2020-01-13T22:14:05 | 233,698,908 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,905 | swift | //
// HomeFeedTableExtension.swift
// Down?
//
// Created by Caleb Bolton on 11/24/19.
//
import Foundation
import UIKit
import MapKit
import Firebase
// General feed functions
extension HomeViewController {
func setUpFeed(){
if events.count == 0{
DataManager.shared.firstVC.noEventsLabel.isHidden = false
}
else{
DataManager.shared.firstVC.noEventsLabel.isHidden = true
}
self.Feed.rowHeight = 100
self.Feed.rowHeight = UITableView.automaticDimension
self.Feed.estimatedRowHeight = UITableView.automaticDimension
Feed.register(FeedEventCell.self, forCellReuseIdentifier: "cellId")
Feed.delegate = self
Feed.dataSource = self
Feed.separatorStyle = .none
//checks if version is older that ios 10.0 because refresh is not there yet.
if #available(iOS 10.0, *) {
Feed.refreshControl = refreshControl
} else {
//adds a subview containing the refresh
Feed.addSubview(refreshControl)
}
}
/// Loads event model data and then calls Feed.reloadData()
func loadModelData() {
if let user = Auth.auth().currentUser {
ApiEvent.getUnviewedEvent(uid: user.uid) { apiEvents in
events = apiEvents
events.sort(by: {return $0.dates.startDate < $1.dates.startDate})
loadLocations() { geoLocations in
self.removeSpinner()
self.view.isUserInteractionEnabled = true
locations = geoLocations
self.Feed.reloadData()
}
}
}
}
/// Removes the specified EventCell from the Feed with the specified direction
func removeEventCell(_ cell: EventCell, withDirection direction: UITableView.RowAnimation){
guard let indexPath = Feed.indexPath(for: cell) else {
return
}
// Removes event and location name from model data arrays
events.remove(at: indexPath.row)
locations.remove(at: indexPath.row)
// Let's the Feed remove the cell with an animtion
Feed.beginUpdates()
Feed.deleteRows(at: [indexPath], with: direction)
Feed.endUpdates()
}
}
// Swiping functionality
extension HomeViewController: SwipeableEventCellDelegate {
func swipeRight(cell: EventCell) {
removeEventCell(cell, withDirection: .right)
// Adds the cell's event to the user's list of down events
if let eventID = cell.event?.autoID, let uid = Auth.auth().currentUser?.uid {
ApiEvent.addUserDown(eventID: eventID, uid: uid) {}
}
}
func swipeLeft(cell: EventCell) {
removeEventCell(cell, withDirection: .left)
// Adds the cell's event to the user's list of notDown events
if let eventID = cell.event?.autoID, let uid = Auth.auth().currentUser?.uid {
ApiEvent.addUserNotDown(eventID: eventID, uid: uid) {}
}
}
// Brings up the detailed view of the event
func tapped(cell: EventCell) {
guard let event = cell.event else {
return
}
let storyboard = UIStoryboard(name: "HomeFeed", bundle: nil)
guard let eventDetailsPopup = storyboard.instantiateViewController(withIdentifier: "eventDetailsPopup") as? EventDetailsPopupViewController else {return}
eventDetailsPopup.event = event
// Bad practice, but will fix in a future release when we are passing around a data structure that holds the locationName as well as the event
eventDetailsPopup.locationName = cell.addressButton.titleLabel?.text
self.present(eventDetailsPopup, animated: true)
}
}
// Datasource and Delegate functions
extension HomeViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return events.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Feed.dequeueReusableCell(withIdentifier: "cellId", for: indexPath)
guard let eventCell = cell as? SwipeableEventCell else {
print("ISSUE")
return cell
}
let event = events[indexPath.row]
let locationName = locations[indexPath.row] ?? "No Location"
eventCell.delegate = self
eventCell.event = event
eventCell.addressButton.setTitle(locationName, for: .normal)
return eventCell
}
}
| [
-1
] |
ef63bb5c180181e261ca2c5bc0021d755a0d580d | 4bff5b999a4d2ba8fa4d4f3e0f8e6cedd023652c | /SwiftDS/sort/QuickSort.swift | 65ad12bd295a506671e4ff69087312bd64e30872 | [
"Apache-2.0"
] | permissive | KyleLearnedThis/SwiftDS | e919f2cc42acff0b1efc8b0dfa1c7b60e24835bd | de741babef27125e2f17e5f633d3f6a481d8ace2 | refs/heads/master | 2021-12-15T04:58:07.711207 | 2021-12-09T08:27:00 | 2021-12-09T08:27:00 | 172,394,395 | 0 | 0 | Apache-2.0 | 2021-12-09T08:27:01 | 2019-02-24T21:49:47 | Swift | UTF-8 | Swift | false | false | 827 | swift | //
// QuickSort.swift
// SwiftDS
//
// Copyright © 2019 kylelearnedthis. All rights reserved.
//
import Foundation
class QuickSort: BaseSort {
func sort() -> [Int] {
if input.isEmpty {
return input
}
quickSort(low: 0, high: input.count - 1)
return input
}
func quickSort(low: Int, high: Int) {
var i = low
var j = high
let pivotIndex = low + (high - low) / 2
let pivotValue = input[pivotIndex]
while i <= j {
while (input[i] < pivotValue) {
i = i + 1
}
while (input[j] > pivotValue) {
j = j - 1
}
if (i <= j) {
input.swapAt(i, j)
i = i + 1
j = j - 1
}
}
}
}
| [
-1
] |
532cdd8b64a87c7fe33c4bde33a2d56ba0c6a6bd | c7be05a80f5aa06f9d6e4cf60b13138a6924ca96 | /Package.swift | faf24b9b07bdd910008414416f23f8ec25c5117e | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-commercial-license"
] | permissive | Fun1hero/SwiftGraph | b9d52367f7ccce34578cf13493da42ffc1e41d34 | 2bd8902a782ee301c32679ac1ba2239c2b63d02d | refs/heads/master | 2020-03-30T23:35:05.212270 | 2018-09-25T18:34:20 | 2018-09-25T18:34:20 | 151,705,440 | 1 | 0 | Apache-2.0 | 2018-10-05T10:34:02 | 2018-10-05T10:34:02 | null | UTF-8 | Swift | false | false | 447 | swift | // swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "SwiftGraph",
products: [
.library(
name: "SwiftGraph",
targets: ["SwiftGraph"]),
],
dependencies: [],
targets: [
.target(
name: "SwiftGraph",
dependencies: []),
.testTarget(
name: "SwiftGraphTests",
dependencies: ["SwiftGraph"]),
]
)
| [
127872,
127877,
13192,
127882,
26638,
127857,
127862,
350710,
333528,
169817,
225594
] |
2b9acc24776bdb880871bf30385e9b38c637095b | e2f5500e08c8a40b9b4afdcfc25cde88f5b26922 | /iAquarium2/iAquarium2/DataModels/NSManagedObjects/WaterParameter+CoreDataClass.swift | b87fed8babf7b0ec866ce2ebdb074e8b93c7884e | [] | no_license | MacPiston/iAquarium2 | 29cefacd5f545e0dc456eef1fbdcb3b5d9732908 | 63b14b743f090d65b9a84e69690c676376e3eba0 | refs/heads/master | 2021-06-13T12:23:48.375538 | 2020-12-22T15:44:29 | 2020-12-22T15:44:29 | 254,432,903 | 0 | 0 | null | 2020-12-22T15:44:30 | 2020-04-09T17:10:01 | Swift | UTF-8 | Swift | false | false | 278 | swift | //
// WaterParameter+CoreDataClass.swift
// iAquarium2
//
// Created by Maciej Zajecki on 25/06/2020.
// Copyright © 2020 Maciej Zajecki. All rights reserved.
//
//
import Foundation
import CoreData
@objc(WaterParameter)
public class WaterParameter: NSManagedObject {
}
| [
-1
] |
fecf8cffeee3d919cabda751033e599c211ea013 | a7158fc83548ed97acef08d51e0e83d072197121 | /Nightly Planner/Sowing/Helpers/ReflectionSubclass.swift | 372b0026a257c7cefa89fc78455b081a4b0c2fdf | [] | no_license | Drfalcoew/GoalsRepo | a45dd06a890a23df03b1facd89fbc5c4396582e2 | 91a260b38c46cc37613b2e25b62e475756e21407 | refs/heads/master | 2023-07-11T06:22:42.431581 | 2021-08-13T21:55:28 | 2021-08-13T21:55:28 | 162,200,672 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 8,095 | swift | //
// ReflectionSubclass.swift
// Sowing
//
// Created by Drew Foster on 5/26/21.
// Copyright © 2021 Drew Foster. All rights reserved.
//
import Foundation
import UIKit
class ReflectionSubclass : UIView {
var tap : UITapGestureRecognizer?
let happyCount : Int? = UserDefaults.standard.integer(forKey: "happyCount")
let sadCount : Int? = UserDefaults.standard.integer(forKey: "sadCount")
let reset = UserDefaults.standard.string(forKey: "reflectionDate")
var chartView_LeftAnchor : NSLayoutConstraint?
let outerView : UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.masksToBounds = true
view.backgroundColor = UIColor(r: 221, g: 221, b: 221)
view.layer.cornerRadius = 5
return view
}()
let chartView : ChartViewSubclass = {
let view = ChartViewSubclass()
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.masksToBounds = true
return view
}()
var happyPercentage : Double?
var sadPercentage : Double?
let reflectionLabel : UILabel = {
let lbl = UILabel()
lbl.minimumScaleFactor = 0.2
lbl.adjustsFontSizeToFitWidth = true
lbl.numberOfLines = 1
lbl.text = "Self-Reflection"
lbl.font = UIFont(name: "Helvetica Neue", size: 23)
lbl.translatesAutoresizingMaskIntoConstraints = false
lbl.layer.masksToBounds = true
lbl.isHidden = true // does not look too clean
return lbl
}()
let badButton : ReflectionButton = {
let btn = ReflectionButton()
btn.setImage(UIImage(named: "sadIcon"), for: .normal)
btn.translatesAutoresizingMaskIntoConstraints = false
btn.layer.masksToBounds = true
btn.layer.zPosition = 0
btn.backgroundColor = UIColor(r: 221, g: 221, b: 221)
btn.layer.borderWidth = 0.25
btn.tag = 1
btn.alpha = 1
btn.layer.borderColor = UIColor.white.cgColor
btn.addTarget(self, action: #selector(handleGoodBad), for: .touchUpInside)
return btn
}()
let goodButton : ReflectionButton = {
let btn = ReflectionButton()
btn.setImage(UIImage(named: "happyIcon"), for: .normal)
btn.translatesAutoresizingMaskIntoConstraints = false
btn.layer.masksToBounds = true
btn.layer.zPosition = 0
btn.backgroundColor = UIColor(r: 221, g: 221, b: 221)
btn.layer.borderWidth = 0.25
btn.tag = 0
btn.alpha = 1
btn.layer.borderColor = UIColor.white.cgColor
btn.addTarget(self, action: #selector(handleGoodBad), for: .touchUpInside)
return btn
}()
override func layoutSubviews() {
self.goodButton.layer.cornerRadius = self.frame.width * 0.08
self.badButton.layer.cornerRadius = self.frame.width * 0.08
}
override init(frame: CGRect) {
super.init(frame: frame)
tap = UITapGestureRecognizer(target: self, action: #selector(handleChartTap))
setupViews()
setupConstraints()
updatePercentage()
}
func setupViews() {
self.addSubview(reflectionLabel)
self.addSubview(outerView)
self.outerView.addSubview(goodButton)
self.outerView.addSubview(badButton)
self.addSubview(chartView)
chartView.addGestureRecognizer(tap!)
}
func setupConstraints() {
NSLayoutConstraint.activate([
outerView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
outerView.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1),
outerView.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 1),
outerView.centerYAnchor.constraint(equalTo: self.centerYAnchor, constant: 0),
reflectionLabel.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 20),
reflectionLabel.topAnchor.constraint(equalTo: self.topAnchor),
reflectionLabel.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1/2.3),
reflectionLabel.heightAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1/4),
badButton.topAnchor.constraint(equalTo: self.outerView.centerYAnchor, constant: 5),
badButton.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.78),
badButton.heightAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.78),
badButton.centerXAnchor.constraint(equalTo: self.outerView.centerXAnchor, constant: 0),
goodButton.centerXAnchor.constraint(equalTo: self.outerView.centerXAnchor, constant: 0),
goodButton.bottomAnchor.constraint(equalTo: self.outerView.centerYAnchor, constant: -5),
goodButton.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.8),
goodButton.heightAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.8),
chartView.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1),
chartView.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 1),
chartView.centerYAnchor.constraint(equalTo: self.centerYAnchor, constant: 0)
])
chartView_LeftAnchor = chartView.leftAnchor.constraint(equalTo: self.rightAnchor)
chartView_LeftAnchor?.isActive = true
}
func updatePercentage() {
if reset == Date().toString() {
chartView.setupChart()
outerView.isHidden = true
chartView_LeftAnchor?.isActive = false
chartView_LeftAnchor = chartView.leftAnchor.constraint(equalTo: self.leftAnchor)
chartView_LeftAnchor?.isActive = true
self.chartView.animateChart()
} else {
chartView_LeftAnchor?.isActive = false
chartView_LeftAnchor = chartView.leftAnchor.constraint(equalTo: self.rightAnchor)
chartView_LeftAnchor?.isActive = true
}
if let x = happyCount, let y = sadCount {
let total = x + y
if total == 0 { return }
self.happyPercentage = Double(x / total)
self.sadPercentage = 100.0 - happyPercentage!
}
}
@objc func handleGoodBad(sender: UIButton) {
UserDefaults.standard.setValue(Date().toString(), forKey: "reflectionDate")
if sender.tag == 0 {
let happyCount : Int = UserDefaults.standard.integer(forKey: "happyCount")
UserDefaults.standard.setValue(happyCount + 1, forKey: "happyCount")
UserDefaults.standard.synchronize()
// good
} else if sender.tag == 1 {
let sadCount : Int = UserDefaults.standard.integer(forKey: "sadCount")
UserDefaults.standard.setValue(sadCount + 1, forKey: "sadCount")
UserDefaults.standard.synchronize()
// bad
}
chartView.setupChart()
UIView.animate(withDuration: 0.6, delay: 0.3, usingSpringWithDamping: 1, initialSpringVelocity: 0.1, options: .curveEaseIn) {
self.outerView.center.x += self.outerView.frame.width + 5
} completion: { (true) in
UIView.animate(withDuration: 0.6, delay: 0.3, usingSpringWithDamping: 1, initialSpringVelocity: 0.1, options: .curveEaseIn) {
self.chartView.center.x -= self.chartView.frame.width + 5
} completion: { (true) in
self.chartView.animateChart()
}
}
}
@objc func handleChartTap() {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "handleChartTap"), object: nil)
}
required init(coder aDecoder: NSCoder) {
fatalError("This class does not support NSCoding")
}
}
| [
-1
] |
771b613a6acdbe880336454e73c3b11832d6e847 | 2984cbeed82835da5322df30bbfa4daab67de531 | /TestMediaPlayer/ViewController2.swift | 565fc0d19d00190e26d2587696a450be3bf6a9bc | [] | no_license | SimpleTaro/FirstMusic | b28e99240a4d406bb2a9304aa403cfed12e58fd1 | fa4083e8939edd432159feaf2caf1f945a04d5e9 | refs/heads/master | 2020-06-10T04:18:37.045809 | 2017-04-09T08:19:09 | 2017-04-09T08:19:09 | 76,089,282 | 0 | 0 | null | 2017-04-09T08:19:10 | 2016-12-10T03:59:23 | Swift | UTF-8 | Swift | false | false | 861 | swift | //
// ViewController2.swift
// TestMediaPlayer
//
// Created by Takeru on 2016/12/11.
// Copyright © 2016年 Takeru. All rights reserved.
//
import UIKit
class ViewController2: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// 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.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
| [
-1
] |
4e46fa352c6736d4807de3ca6f8d4bb02fc4cd42 | aafa62992bc8ab0edf0ab82a737356e3643e0294 | /Sources/StatefulTableView.swift | 1130fa69fa863992a9b4d1666a36dabe8f3f6101 | [
"MIT"
] | permissive | iomusashi/StatefulTableView | 792a1ddd6addbd34252982c4186b2bb159867691 | c0a26b9229fd1623e6bbfdf6dec2bc470e1f67e4 | refs/heads/master | 2021-08-01T23:54:17.484063 | 2021-07-21T13:50:19 | 2021-07-21T13:50:19 | 151,582,572 | 0 | 1 | MIT | 2018-10-04T14:10:31 | 2018-10-04T14:10:31 | null | UTF-8 | Swift | false | false | 4,716 | swift | //
// StatefulTableView.swift
// Demo
//
// Created by Tim on 12/05/2016.
// Copyright © 2016 timominous. All rights reserved.
//
import UIKit
/**
Drop-in replacement for `UITableView` that supports pull-to-refresh, load-more, initial load, and empty states.
*/
@IBDesignable
public final class StatefulTableView: UIView {
internal enum State {
case idle
case initialLoading
case initialLoadingTableView
case emptyOrInitialLoadError
case loadingFromPullToRefresh
case loadingMore
var isLoading: Bool {
switch self {
case .initialLoading: fallthrough
case .initialLoadingTableView: fallthrough
case .loadingFromPullToRefresh: fallthrough
case .loadingMore:
return true
default: return false
}
}
var isInitialLoading: Bool {
switch self {
case .initialLoading: fallthrough
case .initialLoadingTableView:
return true
default: return false
}
}
}
internal enum ViewMode {
case table
case `static`
}
/**
Returns an object initialized from data in a given unarchiver.
- Parameter aDecoder: An unarchiver object.
- Returns: An initialized StatefulTableView object.
*/
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
/**
Initializes and returns a newly allocatied view object with the specified frame rectangle.
- Parameter frame: The frame rectangle for the view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. this method uses the frame rectangle to set the center and bounds properties accordingly.
- Returns: An initialized StatefulTableView object.
*/
public override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
func commonInit() {
addSubview(tableView)
addSubview(dynamicContentView)
refreshControl.addTarget(self,
action: #selector(refreshControlValueChanged), for: .valueChanged)
tableView.addSubview(refreshControl)
}
/**
Lays out subviews.
*/
override public func layoutSubviews() {
super.layoutSubviews()
tableView.frame = bounds
dynamicContentView.frame = bounds
}
private func reset() {
tableView.removeFromSuperview()
dynamicContentView.removeFromSuperview()
tableView = UITableView(frame: .zero, style: tableStyle)
refreshControl = UIRefreshControl()
dynamicContentView = { [unowned self] in
let view = UIView(frame: self.bounds)
view.backgroundColor = .white
view.isHidden = true
return view
}()
}
internal lazy var tableView = UITableView(frame: .zero, style: tableStyle)
/**
An accessor to the contained `UITableView`.
*/
public var innerTable: UITableView {
return tableView
}
internal lazy var dynamicContentView: UIView = { [unowned self] in
let view = UIView(frame: self.bounds)
view.backgroundColor = .white
view.isHidden = true
return view
}()
public lazy var refreshControl = UIRefreshControl()
// MARK: - Properties
/**
Enables the user to pull down on the tableView to initiate a refresh
*/
public var canPullToRefresh = false
/**
Enables the user to control whether to trigger loading of more objects or not
*/
public var canLoadMore = false
/**
Distance from the bottom of the tableView's vertical content offset where load more will be triggered
*/
public var loadMoreTriggerThreshold: CGFloat = 64
/**
The pluralized name of the items to be displayed. This will be used when the table is empty and no error view has been provided.
*/
@available(*, deprecated, message: "Use the delegate: statefulTable(tableView:initialLoadWithError:errorView:) instead, and customise the label of the default errorView.")
public var pluralType = "records"
internal var loadMoreViewIsErrorView = false
internal var lastLoadMoreError: NSError?
internal var watchForLoadMore = false
internal var state: State = .idle
internal var viewMode: ViewMode = .table {
didSet {
let hidden = viewMode == .table
guard dynamicContentView.isHidden != hidden else { return }
dynamicContentView.isHidden = hidden
}
}
public var tableStyle: UITableView.Style = .plain {
didSet {
reset()
commonInit()
layoutIfNeeded()
}
}
// MARK: - Stateful Delegate
/**
The object that acts as the stateful delegate of the table view.
- Discussion: The stateful delegate must adopt the `StatefulTableDelegate` protocol. The stateful delegate is not retained.
*/
public var statefulDelegate: StatefulTableDelegate?
}
| [
-1
] |
f39b2124b19fa9f4d265259f610453c15f329f99 | f5122937d62b9432081767947398b7ecc5bcdc74 | /ARNInteractiveTransition/ARNInteractiveTransition/InteractiveTransition.swift | 0b0c28371ed7d66fae5e9964e2029be9e7d93b85 | [
"MIT"
] | permissive | swift-projects/ARNInteractiveTransition | c5f17fd3cc7264e051a78506b83071150137a719 | f4e2958b0c820b5c54dc4a20107000dd26807e1f | refs/heads/master | 2021-04-06T14:47:55.989068 | 2017-10-26T10:37:35 | 2017-10-26T10:37:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,622 | swift | //
// InteractiveTransition.swift
// ARNInteractiveTransition
//
// Created by xxxAIRINxxx on 2017/09/07.
// Copyright © 2017 xxxAIRINxxx. All rights reserved.
//
import Foundation
import ARNTransitionAnimator
final class InteractiveTransition : TransitionAnimatable {
fileprivate weak var rootVC: ViewController!
fileprivate weak var modalVC: ModalViewController!
fileprivate var endOriginY: CGFloat = 0
init(rootVC: ViewController, modalVC: ModalViewController) {
self.rootVC = rootVC
self.modalVC = modalVC
self.modalVC.modalPresentationStyle = .overFullScreen
}
func prepareContainer(_ transitionType: TransitionType, containerView: UIView, from fromVC: UIViewController, to toVC: UIViewController) {
if transitionType.isPresenting {
containerView.addSubview(toVC.view)
containerView.addSubview(fromVC.view)
} else {
containerView.addSubview(fromVC.view)
containerView.addSubview(toVC.view)
}
fromVC.view.setNeedsLayout()
fromVC.view.layoutIfNeeded()
toVC.view.setNeedsLayout()
toVC.view.layoutIfNeeded()
}
func willAnimation(_ transitionType: TransitionType, containerView: UIView) {
self.rootVC.tableView.bounces = false
endOriginY = containerView.bounds.height - 50
if transitionType.isPresenting {
rootVC.tableView.setContentOffset(rootVC.tableView.contentOffset, animated: false)
modalVC.view.alpha = 0.0
} else {
self.modalVC.view.frame.origin.y = 0
}
}
func updateAnimation(_ transitionType: TransitionType, percentComplete: CGFloat) {
if transitionType.isPresenting {
rootVC.view.frame.origin.y = endOriginY * percentComplete
if rootVC.view.frame.origin.y < 0.0 {
rootVC.view.frame.origin.y = 0.0
}
modalVC.view.alpha = 1.0 * percentComplete
} else {
rootVC.view.frame.origin.y = endOriginY - (endOriginY * percentComplete)
if rootVC.view.frame.origin.y < 0.0 {
rootVC.view.frame.origin.y = 0.0
}
modalVC.view.alpha = 1.0 - (1.0 * percentComplete)
}
}
func finishAnimation(_ transitionType: TransitionType, didComplete: Bool) {
self.setTransitionFinishSetting()
self.rootVC.tableView.bounces = true
if transitionType.isPresenting {
if didComplete {
rootVC.view.isUserInteractionEnabled = false
} else {
rootVC.view.isUserInteractionEnabled = true
}
UIApplication.shared.keyWindow?.addSubview(self.rootVC.view)
} else {
if didComplete {
rootVC.view.isUserInteractionEnabled = true
UIApplication.shared.keyWindow?.addSubview(self.rootVC.view)
} else {
UIApplication.shared.keyWindow?.addSubview(self.rootVC.view)
}
}
}
fileprivate func setTransitionStartSetting() {
self.rootVC.tableView.isScrollEnabled = false
self.rootVC.tableView.bounces = false
}
fileprivate func setTransitionFinishSetting() {
self.rootVC.tableView.isScrollEnabled = true
self.rootVC.tableView.bounces = true
}
}
extension InteractiveTransition {
func sourceVC() -> UIViewController { return self.rootVC }
func destVC() -> UIViewController { return self.modalVC }
}
| [
-1
] |
683749c49cf7951ce26d6325de62c68eb6c0ff40 | 3adefd4da9d5f4e811ecfd2279329f90d0df8b21 | /Git Project/ModelView.swift | 81f2081c6148d3c2bc9bce72b9c6a4e5974a0a97 | [] | no_license | maheshpd/Git-Project | f7b31305b8cb206660ef52d620df8f9a43818604 | 36875b5a142c2232c0e7968f4b41bd36b9f71816 | refs/heads/main | 2023-04-06T17:08:48.993691 | 2021-04-22T14:13:29 | 2021-04-22T14:13:29 | 360,542,656 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 400 | swift | //
// ModelView.swift
// Git Project
//
// Created by Mahesh Prasad on 22/04/21.
//
import SwiftUI
struct ModelView: View {
var body: some View {
VStack {
Text("This is the modal View")
}.navigationBarTitle("Second View", displayMode: .inline)
}
}
struct ModelView_Previews: PreviewProvider {
static var previews: some View {
ModelView()
}
}
| [
-1
] |
318ed5c356457a7d4d9ee83393d97dce934a89d9 | 1d1bd6249f66b99417d8bfae740ae9fcdb50b213 | /Tests/GRPCTests/XCTestHelpers.swift | ab3f29a8ff69d56e4d85c4866ba69a921d6859b1 | [
"Apache-2.0"
] | permissive | abdulrahim46/grpc-swift | c7bf0b054561507e92753e573acc5765370816da | 9013e4e1ad9493e3f906a774809abae18d284817 | refs/heads/main | 2023-05-11T15:02:45.860840 | 2021-06-03T10:37:32 | 2021-06-03T10:37:32 | 374,234,058 | 0 | 1 | NOASSERTION | 2021-06-06T00:01:13 | 2021-06-06T00:01:12 | null | UTF-8 | Swift | false | false | 18,755 | swift | /*
* Copyright 2020, gRPC Authors All rights reserved.
*
* 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.
*/
@testable import GRPC
import NIO
import NIOHPACK
import NIOHTTP1
import NIOHTTP2
import XCTest
struct UnwrapError: Error {}
// We support Swift versions before 'XCTUnwrap' was introduced.
func assertNotNil<Value>(
_ expression: @autoclosure () throws -> Value?,
message: @autoclosure () -> String = "Optional value was nil",
file: StaticString = #file,
line: UInt = #line
) throws -> Value {
guard let value = try expression() else {
XCTFail(message(), file: file, line: line)
throw UnwrapError()
}
return value
}
func assertNoThrow<Value>(
_ expression: @autoclosure () throws -> Value,
message: @autoclosure () -> String = "Unexpected error thrown",
file: StaticString = #file,
line: UInt = #line
) throws -> Value {
do {
return try expression()
} catch {
XCTFail(message(), file: file, line: line)
throw error
}
}
// MARK: - Matchers.
// The Swift 5.2 compiler will crash when trying to
// inline this function if the tests are running in
// release mode.
@inline(never)
func assertThat<Value>(
_ expression: @autoclosure @escaping () throws -> Value,
_ matcher: Matcher<Value>,
file: StaticString = #file,
line: UInt = #line
) {
// For value matchers we'll assert that we don't throw by default.
assertThat(try expression(), .doesNotThrow(matcher), file: file, line: line)
}
func assertThat<Value>(
_ expression: @autoclosure @escaping () throws -> Value,
_ matcher: ExpressionMatcher<Value>,
file: StaticString = #file,
line: UInt = #line
) {
switch matcher.evaluate(expression) {
case .match:
()
case let .noMatch(actual: actual, expected: expected):
XCTFail("ACTUAL: \(actual), EXPECTED: \(expected)", file: file, line: line)
}
}
enum MatchResult {
case match
case noMatch(actual: String, expected: String)
}
struct Matcher<Value> {
fileprivate typealias Evaluator = (Value) -> MatchResult
private var matcher: Evaluator
fileprivate init(_ matcher: @escaping Evaluator) {
self.matcher = matcher
}
fileprivate func evaluate(_ value: Value) -> MatchResult {
return self.matcher(value)
}
// MARK: Sugar
/// Just returns the provided matcher.
static func `is`<Value>(_ matcher: Matcher<Value>) -> Matcher<Value> {
return matcher
}
/// Just returns the provided matcher.
static func and<Value>(_ matcher: Matcher<Value>) -> Matcher<Value> {
return matcher
}
// MARK: Equality
/// Checks the equality of the actual value against the provided value. See `equalTo(_:)`.
static func `is`<Value: Equatable>(_ value: Value) -> Matcher<Value> {
return .equalTo(value)
}
/// Checks the equality of the actual value against the provided value.
static func equalTo<Value: Equatable>(_ expected: Value) -> Matcher<Value> {
return .init { actual in
actual == expected
? .match
: .noMatch(actual: "\(actual)", expected: "equal to \(expected)")
}
}
/// Always returns a 'match', useful when the expected value is `Void`.
static func isVoid() -> Matcher<Void> {
return .init {
return .match
}
}
/// Matches if the value is `nil`.
static func `nil`<Value>() -> Matcher<Value?> {
return .init { actual in
actual == nil
? .match
: .noMatch(actual: String(describing: actual), expected: "nil")
}
}
/// Matches if the value is not `nil`.
static func notNil<Value>(_ matcher: Matcher<Value>? = nil) -> Matcher<Value?> {
return .init { actual in
if let actual = actual {
return matcher?.evaluate(actual) ?? .match
} else {
return .noMatch(actual: "nil", expected: "not nil")
}
}
}
// MARK: Result
static func success<Value>(_ matcher: Matcher<Value>? = nil) -> Matcher<Result<Value, Error>> {
return .init { actual in
switch actual {
case let .success(value):
return matcher?.evaluate(value) ?? .match
case let .failure(error):
return .noMatch(actual: "\(error)", expected: "success")
}
}
}
static func success() -> Matcher<Result<Void, Error>> {
return .init { actual in
switch actual {
case .success:
return .match
case let .failure(error):
return .noMatch(actual: "\(error)", expected: "success")
}
}
}
static func failure<Success, Failure: Error>(
_ matcher: Matcher<Failure>? = nil
) -> Matcher<Result<Success, Failure>> {
return .init { actual in
switch actual {
case let .success(value):
return .noMatch(actual: "\(value)", expected: "failure")
case let .failure(error):
return matcher?.evaluate(error) ?? .match
}
}
}
// MARK: Utility
static func all<Value>(_ matchers: Matcher<Value>...) -> Matcher<Value> {
return .init { actual in
for matcher in matchers {
let result = matcher.evaluate(actual)
switch result {
case .noMatch:
return result
case .match:
()
}
}
return .match
}
}
// MARK: Type
/// Checks that the actual value is an instance of the given type.
static func instanceOf<Value, Expected>(_: Expected.Type) -> Matcher<Value> {
return .init { actual in
if actual is Expected {
return .match
} else {
return .noMatch(
actual: String(describing: type(of: actual)) + " (\(actual))",
expected: "value of type \(Expected.self)"
)
}
}
}
// MARK: Collection
/// Checks whether the collection has the expected count.
static func hasCount<C: Collection>(_ count: Int) -> Matcher<C> {
return .init { actual in
actual.count == count
? .match
: .noMatch(actual: "has count \(actual.count)", expected: "count of \(count)")
}
}
static func isEmpty<C: Collection>() -> Matcher<C> {
return .init { actual in
actual.isEmpty
? .match
: .noMatch(actual: "has \(actual.count) items", expected: "is empty")
}
}
// MARK: gRPC matchers
static func hasCode(_ code: GRPCStatus.Code) -> Matcher<GRPCStatus> {
return .init { actual in
actual.code == code
? .match
: .noMatch(actual: "has status code \(actual)", expected: "\(code)")
}
}
static func metadata<Request>(
_ matcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<GRPCServerRequestPart<Request>> {
return .init { actual in
switch actual {
case let .metadata(headers):
return matcher?.evaluate(headers) ?? .match
default:
return .noMatch(actual: String(describing: actual), expected: "metadata")
}
}
}
static func message<Request>(
_ matcher: Matcher<Request>? = nil
) -> Matcher<GRPCServerRequestPart<Request>> {
return .init { actual in
switch actual {
case let .message(message):
return matcher?.evaluate(message) ?? .match
default:
return .noMatch(actual: String(describing: actual), expected: "message")
}
}
}
static func metadata<Response>(
_ matcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<GRPCServerResponsePart<Response>> {
return .init { actual in
switch actual {
case let .metadata(headers):
return matcher?.evaluate(headers) ?? .match
default:
return .noMatch(actual: String(describing: actual), expected: "metadata")
}
}
}
static func message<Response>(
_ matcher: Matcher<Response>? = nil
) -> Matcher<GRPCServerResponsePart<Response>> {
return .init { actual in
switch actual {
case let .message(message, _):
return matcher?.evaluate(message) ?? .match
default:
return .noMatch(actual: String(describing: actual), expected: "message")
}
}
}
static func end<Response>(
status statusMatcher: Matcher<GRPCStatus>? = nil,
trailers trailersMatcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<GRPCServerResponsePart<Response>> {
return .init { actual in
switch actual {
case let .end(status, trailers):
let statusMatch = (statusMatcher?.evaluate(status) ?? .match)
switch statusMatcher?.evaluate(status) ?? .match {
case .match:
return trailersMatcher?.evaluate(trailers) ?? .match
case .noMatch:
return statusMatch
}
default:
return .noMatch(actual: String(describing: actual), expected: "end")
}
}
}
static func sendTrailers(
_ matcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<HTTP2ToRawGRPCStateMachine.SendEndAction> {
return .init { actual in
switch actual {
case let .sendTrailers(trailers):
return matcher?.evaluate(trailers) ?? .match
case .sendTrailersAndFinish:
return .noMatch(actual: "sendTrailersAndFinish", expected: "sendTrailers")
case let .failure(error):
return .noMatch(actual: "\(error)", expected: "sendTrailers")
}
}
}
static func sendTrailersAndFinish(
_ matcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<HTTP2ToRawGRPCStateMachine.SendEndAction> {
return .init { actual in
switch actual {
case let .sendTrailersAndFinish(trailers):
return matcher?.evaluate(trailers) ?? .match
case .sendTrailers:
return .noMatch(actual: "sendTrailers", expected: "sendTrailersAndFinish")
case let .failure(error):
return .noMatch(actual: "\(error)", expected: "sendTrailersAndFinish")
}
}
}
static func failure(
_ matcher: Matcher<Error>? = nil
) -> Matcher<HTTP2ToRawGRPCStateMachine.SendEndAction> {
return .init { actual in
switch actual {
case .sendTrailers:
return .noMatch(actual: "sendTrailers", expected: "failure")
case .sendTrailersAndFinish:
return .noMatch(actual: "sendTrailersAndFinish", expected: "failure")
case let .failure(error):
return matcher?.evaluate(error) ?? .match
}
}
}
// MARK: HTTP/1
static func head(
status: HTTPResponseStatus,
headers: HTTPHeaders? = nil
) -> Matcher<HTTPServerResponsePart> {
return .init { actual in
switch actual {
case let .head(head):
let statusMatches = Matcher.is(status).evaluate(head.status)
switch statusMatches {
case .match:
return headers.map { Matcher.is($0).evaluate(head.headers) } ?? .match
case .noMatch:
return statusMatches
}
case .body, .end:
return .noMatch(actual: "\(actual)", expected: "head")
}
}
}
static func body(_ matcher: Matcher<ByteBuffer>? = nil) -> Matcher<HTTPServerResponsePart> {
return .init { actual in
switch actual {
case let .body(.byteBuffer(buffer)):
return matcher.map { $0.evaluate(buffer) } ?? .match
default:
return .noMatch(actual: "\(actual)", expected: "body")
}
}
}
static func end() -> Matcher<HTTPServerResponsePart> {
return .init { actual in
switch actual {
case .end:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "end")
}
}
}
// MARK: HTTP/2
static func contains(
_ name: String,
_ values: [String]? = nil
) -> Matcher<HPACKHeaders> {
return .init { actual in
let headers = actual[canonicalForm: name]
if headers.isEmpty {
return .noMatch(actual: "does not contain '\(name)'", expected: "contains '\(name)'")
} else {
return values.map { Matcher.equalTo($0).evaluate(headers) } ?? .match
}
}
}
static func contains(
caseSensitive caseSensitiveName: String
) -> Matcher<HPACKHeaders> {
return .init { actual in
for (name, _, _) in actual {
if name == caseSensitiveName {
return .match
}
}
return .noMatch(
actual: "does not contain '\(caseSensitiveName)'",
expected: "contains '\(caseSensitiveName)'"
)
}
}
static func headers(
_ headers: Matcher<HPACKHeaders>? = nil,
endStream: Bool? = nil
) -> Matcher<HTTP2Frame.FramePayload> {
return .init { actual in
switch actual {
case let .headers(payload):
let headersMatch = headers?.evaluate(payload.headers)
switch headersMatch {
case .none,
.some(.match):
return endStream.map { Matcher.is($0).evaluate(payload.endStream) } ?? .match
case .some(.noMatch):
return headersMatch!
}
default:
return .noMatch(actual: "\(actual)", expected: "headers")
}
}
}
static func data(
buffer: ByteBuffer? = nil,
endStream: Bool? = nil
) -> Matcher<HTTP2Frame.FramePayload> {
return .init { actual in
switch actual {
case let .data(payload):
let endStreamMatches = endStream.map { Matcher.is($0).evaluate(payload.endStream) }
switch (endStreamMatches, payload.data) {
case let (.none, .byteBuffer(b)),
let (.some(.match), .byteBuffer(b)):
return buffer.map { Matcher.is($0).evaluate(b) } ?? .match
case (.some(.noMatch), .byteBuffer):
return endStreamMatches!
case (_, .fileRegion):
preconditionFailure("Unexpected IOData.fileRegion")
}
default:
return .noMatch(actual: "\(actual)", expected: "data")
}
}
}
static func trailersOnly(
code: GRPCStatus.Code,
contentType: String = "application/grpc"
) -> Matcher<HPACKHeaders> {
return .all(
.contains(":status", ["200"]),
.contains("content-type", [contentType]),
.contains("grpc-status", ["\(code.rawValue)"])
)
}
static func trailers(code: GRPCStatus.Code, message: String) -> Matcher<HPACKHeaders> {
return .all(
.contains("grpc-status", ["\(code.rawValue)"]),
.contains("grpc-message", [message])
)
}
// MARK: HTTP2ToRawGRPCStateMachine.Action
static func errorCaught() -> Matcher<HTTP2ToRawGRPCStateMachine.ReadNextMessageAction> {
return .init { actual in
switch actual {
case .errorCaught:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "errorCaught")
}
}
}
static func configure() -> Matcher<HTTP2ToRawGRPCStateMachine.ReceiveHeadersAction> {
return .init { actual in
switch actual {
case .configure:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "configurePipeline")
}
}
}
static func rejectRPC(
_ matcher: Matcher<HPACKHeaders>? = nil
) -> Matcher<HTTP2ToRawGRPCStateMachine.ReceiveHeadersAction> {
return .init { actual in
switch actual {
case let .rejectRPC(headers):
return matcher?.evaluate(headers) ?? .match
default:
return .noMatch(actual: "\(actual)", expected: "rejectRPC")
}
}
}
static func forwardHeaders() -> Matcher<HTTP2ToRawGRPCStateMachine.PipelineConfiguredAction> {
return .init { actual in
switch actual {
case .forwardHeaders:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "forwardHeaders")
}
}
}
static func none() -> Matcher<HTTP2ToRawGRPCStateMachine.ReadNextMessageAction> {
return .init { actual in
switch actual {
case .none:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "none")
}
}
}
static func forwardMessage() -> Matcher<HTTP2ToRawGRPCStateMachine.ReadNextMessageAction> {
return .init { actual in
switch actual {
case .forwardMessage:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "forwardMessage")
}
}
}
static func forwardEnd() -> Matcher<HTTP2ToRawGRPCStateMachine.ReadNextMessageAction> {
return .init { actual in
switch actual {
case .forwardEnd:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "forwardEnd")
}
}
}
static func forwardHeadersThenRead()
-> Matcher<HTTP2ToRawGRPCStateMachine.PipelineConfiguredAction> {
return .init { actual in
switch actual {
case .forwardHeadersAndRead:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "forwardHeadersAndRead")
}
}
}
static func forwardMessageThenRead()
-> Matcher<HTTP2ToRawGRPCStateMachine.ReadNextMessageAction> {
return .init { actual in
switch actual {
case .forwardMessageThenReadNextMessage:
return .match
default:
return .noMatch(actual: "\(actual)", expected: "forwardMessageThenReadNextMessage")
}
}
}
}
struct ExpressionMatcher<Value> {
typealias Expression = () throws -> Value
private typealias Evaluator = (Expression) -> MatchResult
private var evaluator: Evaluator
private init(_ evaluator: @escaping Evaluator) {
self.evaluator = evaluator
}
fileprivate func evaluate(_ expression: Expression) -> MatchResult {
return self.evaluator(expression)
}
/// Asserts that the expression does not throw and error. Returns the result of any provided
/// matcher on the result of the expression.
static func doesNotThrow<Value>(_ matcher: Matcher<Value>? = nil) -> ExpressionMatcher<Value> {
return .init { expression in
do {
let value = try expression()
return matcher?.evaluate(value) ?? .match
} catch {
return .noMatch(actual: "threw '\(error)'", expected: "should not throw error")
}
}
}
/// Asserts that the expression throws and error. Returns the result of any provided matcher
/// on the error thrown by the expression.
static func `throws`<Value>(_ matcher: Matcher<Error>? = nil) -> ExpressionMatcher<Value> {
return .init { expression in
do {
let value = try expression()
return .noMatch(actual: "returned '\(value)'", expected: "should throw error")
} catch {
return matcher?.evaluate(error) ?? .match
}
}
}
}
| [
-1
] |
414a126d28ce2ef9be61787b025b429c36271ebe | dfb755ad1089acc4cb3cf998055a73cb654d3b68 | /iOS14VisionContourDetection/iOS14VisionContourDetection/ContentView.swift | 29425d9b5b60d5183bd8860777f5dd22dc769206 | [] | no_license | YuffieOuO/iOS14-Resources | b8f7ea97196d281b02c1421f7954b13590334373 | 48c85a0f9f7120848ca9363ccc97237d7665978f | refs/heads/master | 2023-02-13T23:06:02.393239 | 2021-01-05T19:04:00 | 2021-01-05T19:04:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 5,468 | swift | //
// ContentView.swift
// iOS14VisionContourDetection
//
// Created by Anupam Chugh on 26/06/20.
//
import SwiftUI
import Vision
import CoreImage
import CoreImage.CIFilterBuiltins
struct ContentView: View {
@State var points : String = ""
@State var preProcessImage: UIImage?
@State var contouredImage: UIImage?
var body: some View {
VStack{
Text("Contours: \(points)")
Image("coins")
.resizable()
.scaledToFit()
if let image = preProcessImage{
Image(uiImage: image)
.resizable()
.scaledToFit()
}
if let image = contouredImage{
Image(uiImage: image)
.resizable()
.scaledToFit()
}
Button("Detect Contours", action: {
detectVisionContours()
})
}
}
public func drawContours(contoursObservation: VNContoursObservation, sourceImage: CGImage) -> UIImage {
let size = CGSize(width: sourceImage.width, height: sourceImage.height)
let renderer = UIGraphicsImageRenderer(size: size)
let renderedImage = renderer.image { (context) in
let renderingContext = context.cgContext
let flipVertical = CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: size.height)
renderingContext.concatenate(flipVertical)
renderingContext.draw(sourceImage, in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
renderingContext.scaleBy(x: size.width, y: size.height)
renderingContext.setLineWidth(5.0 / CGFloat(size.width))
let redUIColor = UIColor.red
renderingContext.setStrokeColor(redUIColor.cgColor)
renderingContext.addPath(contoursObservation.normalizedPath)
renderingContext.strokePath()
}
return renderedImage
}
func detectVisionContours(){
let context = CIContext()
if let sourceImage = UIImage.init(named: "coins")
{
var inputImage = CIImage.init(cgImage: sourceImage.cgImage!)
let contourRequest = VNDetectContoursRequest.init()
contourRequest.revision = VNDetectContourRequestRevision1
contourRequest.contrastAdjustment = 1.0
contourRequest.detectDarkOnLight = true
contourRequest.maximumImageDimension = 512
do {
let noiseReductionFilter = CIFilter.gaussianBlur()
noiseReductionFilter.radius = 0.5
noiseReductionFilter.inputImage = inputImage
let blackAndWhite = CustomFilter()
blackAndWhite.inputImage = noiseReductionFilter.outputImage!
let filteredImage = blackAndWhite.outputImage!
// let monochromeFilter = CIFilter.colorControls()
// monochromeFilter.inputImage = noiseReductionFilter.outputImage!
// monochromeFilter.contrast = 20.0
// monochromeFilter.brightness = 4
// monochromeFilter.saturation = 50
// let filteredImage = monochromeFilter.outputImage!
inputImage = filteredImage
if let cgimg = context.createCGImage(filteredImage, from: filteredImage.extent) {
self.preProcessImage = UIImage(cgImage: cgimg)
}
}
let requestHandler = VNImageRequestHandler.init(ciImage: inputImage, options: [:])
try! requestHandler.perform([contourRequest])
let contoursObservation = contourRequest.results?.first as! VNContoursObservation
self.points = String(contoursObservation.contourCount)
self.contouredImage = drawContours(contoursObservation: contoursObservation, sourceImage: sourceImage.cgImage!)
} else {
self.points = "Could not load image"
}
}
}
class CustomFilter: CIFilter {
var inputImage: CIImage?
override public var outputImage: CIImage! {
get {
if let inputImage = self.inputImage {
let args = [inputImage as AnyObject]
let callback: CIKernelROICallback = {
(index, rect) in
return rect.insetBy(dx: -1, dy: -1)
}
return createCustomKernel().apply(extent: inputImage.extent, roiCallback: callback, arguments: args)
} else {
return nil
}
}
}
func createCustomKernel() -> CIKernel {
return CIColorKernel(source:
"kernel vec4 replaceWithBlackOrWhite(__sample s) {" +
"if (s.r > 0.25 && s.g > 0.25 && s.b > 0.25) {" +
" return vec4(0.0,0.0,0.0,1.0);" +
"} else {" +
" return vec4(1.0,1.0,1.0,1.0);" +
"}" +
"}"
)!
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
| [
-1
] |
cfb7d991a79dfa4e7fb7dbd0a39864da9e6c4911 | b40d2ab0aaf36fe4251edc4a1559e9e61c6aebd6 | /EEPCShop/User/Login/View/RegisterServiceView.swift | 31bafd0183b247d2de0a31f3bedbdeaad9b9db10 | [] | no_license | chennian/UIT | 39895e56aff0a6b0faa61d4b6e4e52668f7f2eb4 | 576877d1cf561ff6bd27f4276ae16688683f6869 | refs/heads/master | 2020-08-30T08:39:34.830012 | 2019-10-29T15:37:50 | 2019-10-29T15:37:50 | 218,321,664 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,182 | swift | //
// RegisterServiceView.swift
// sevenloan
//
// Created by spectator Mr.Z on 2018/12/4.
// Copyright © 2018 tangxers. All rights reserved.
//
import UIKit
class RegisterServiceView:SNBaseView {
var clickEvent:(()->())?
let checkBtn = UIButton().then {
$0.isSelected = false
}
let descLabel = UILabel().then {
$0.font = Font(28)
}
let button = UIButton().then{
$0.setTitle("服务协议", for: .normal)
$0.titleLabel?.font = Font(28)
$0.setTitleColor(Color(0x2777ff), for: .normal)
}
var checked : Bool {
get {
return checkBtn.isSelected
}
}
}
extension RegisterServiceView {
func set(image: String, selectImage: String, desc: String, serviceButtonText: String) {
checkBtn.setImage(Image(image), for: .normal)
checkBtn.setImage(Image(selectImage), for: .selected)
descLabel.text = desc
}
}
extension RegisterServiceView {
override func setupView() {
addSubviews(views: [checkBtn,descLabel,button])
checkBtn.snp.makeConstraints { (make) in
make.left.top.bottom.equalToSuperview()
make.width.snEqualTo(36)
}
descLabel.snp.makeConstraints { (make) in
make.left.equalTo(checkBtn.snp.right).snOffset(20)
make.centerY.snEqualToSuperview()
}
button.snp.makeConstraints { (make) in
make.left.equalTo(descLabel.snp.right).snOffset(5)
make.centerY.equalTo(descLabel.snp.centerY)
make.height.snEqualTo(30)
make.height.snEqualTo(120)
}
}
@objc func click(){
self.checkBtn.isSelected = !self.checkBtn.isSelected
}
@objc func clickAction(){
guard let action = clickEvent else {
return
}
action()
}
override func bindEvent() {
checkBtn.addTarget(self, action: #selector(click), for: .touchUpInside)
button.addTarget(self, action: #selector(clickAction), for: .touchUpInside)
}
}
| [
-1
] |
da6742f1e4106ee1503abd69042194ae5c57d69a | eb9a49a1ea6d302917cec0bab1c4543267ac4ff0 | /CometChatSwift/CometChatSwift/Library/UIKit Resources/Helper Extensions/CometChatSnackBoard/Theme.swift | c09286c34ae42fd0e4022da9875939c847d83c7e | [
"MIT"
] | permissive | tanbui/ios-swift-chat-app | 089bb7459cfe8d323b8fd81b1d1bfc7ad90c647f | 22cf1ab71b16725aa7cd8a405819935cf1efe449 | refs/heads/master | 2023-08-14T08:55:08.345384 | 2021-09-24T10:45:26 | 2021-09-24T10:45:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,164 | swift | //
// Theme.swift
// CometChatSnackBoard
//
// Created by Timothy Moose on 8/7/16.
// Copyright © 2016 SwiftKick Mobile LLC. All rights reserved.
//
import UIKit
/// The theme enum specifies the built-in theme options
public enum Theme {
case info
case success
case warning
case error
}
/// The Icon enum provides type-safe access to the included icons.
public enum Icon: String {
case error = "errorIcon"
case warning = "warningIcon"
case success = "successIcon"
case info = "infoIcon"
case errorLight = "errorIconLight"
case warningLight = "warningIconLight"
case successLight = "successIconLight"
case infoLight = "infoIconLight"
case errorSubtle = "errorIconSubtle"
case warningSubtle = "warningIconSubtle"
case successSubtle = "successIconSubtle"
case infoSubtle = "infoIconSubtle"
/// Returns the associated image.
public var image: UIImage {
return UIImage(named: rawValue, in: Bundle.sm_frameworkBundle(), compatibleWith: nil)!.withRenderingMode(.alwaysTemplate)
}
}
/// The IconStyle enum specifies the different variations of the included icons.
public enum IconStyle {
case `default`
case light
case subtle
case none
/// Returns the image for the given theme
public func image(theme: Theme) -> UIImage? {
switch (theme, self) {
case (.info, .default): return Icon.info.image
case (.info, .light): return Icon.infoLight.image
case (.info, .subtle): return Icon.infoSubtle.image
case (.success, .default): return Icon.success.image
case (.success, .light): return Icon.successLight.image
case (.success, .subtle): return Icon.successSubtle.image
case (.warning, .default): return Icon.warning.image
case (.warning, .light): return Icon.warningLight.image
case (.warning, .subtle): return Icon.warningSubtle.image
case (.error, .default): return Icon.error.image
case (.error, .light): return Icon.errorLight.image
case (.error, .subtle): return Icon.errorSubtle.image
default: return nil
}
}
}
| [
229544,
268993
] |
cbf8f46725031ef4a8a4aef2547dc9fe7635bf4e | 90fafa779a1cc9b1ac3becae8ec555e8ba9416c0 | /Example/Example/ViewController.swift | 4df9c62f857ab0e4361b1dadb4548384202d308a | [
"MIT"
] | permissive | mspviraj/OnOffButton | f48db647dac8f863f7d417095aa370f2f8b00ec0 | a37c12396a9b3168556de492933f6ed7a98ff115 | refs/heads/master | 2021-01-19T11:45:05.962014 | 2017-01-22T12:27:40 | 2017-01-22T12:27:40 | 82,261,187 | 1 | 0 | null | 2017-02-17T05:37:31 | 2017-02-17T05:37:31 | null | UTF-8 | Swift | false | false | 237 | swift | import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func changeButtonState(sender: OnOffButton) {
sender.checked = !sender.checked
}
} | [
-1
] |
b5c9f782b264f2be53dcbb50cbce6f126079e84c | 3b259e26cc8595fc90eae9049f528da11a593e76 | /DomestikaTech/Application/DomestikaTechApp.swift | ce722684badb3050935ea014cd1e0ee8c4fb8f7b | [
"MIT"
] | permissive | javiermorgaz/DomestikaTech | aefe9e1688a898c68620c5a4628c18d25954192c | db0e21d642c59c7a6fedfafab94bdf00afde1409 | refs/heads/master | 2022-12-03T00:18:41.787769 | 2020-08-17T10:09:18 | 2020-08-17T10:09:18 | 286,686,145 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 547 | swift | //
// DomestikaTechApp.swift
// DomestikaTech
//
// Created by Jmorgaz on 11/08/2020.
//
import SwiftUI
import OHHTTPStubs
@main
struct DomestikaTechApp: App {
var body: some Scene {
WindowGroup {
buildContentView()
}
}
}
func buildContentView() -> AnyView {
#if DEBUG
if CommandLine.arguments.contains("enable-testing") {
MockData.configureTestingState()
}
#endif
let discoverView = AppServiceLocator.shared.discover.provideDiscoverView()
return AnyView(discoverView)
}
| [
-1
] |
2cf3f3861e237a8d09d1b19f99bc527c976ca42d | 18bd2f4f77b23e0e195a720a0ae2a16f157b08c5 | /BlueprintUI/Tests/UIViewElementTests.swift | 62768d7211078a82c672b0c180ff87041a79aa8b | [
"Apache-2.0"
] | permissive | kylebshr/Blueprint | 5534e76757c7f6ff5e7d0a4557797712cf146349 | 19493b91bee0220dca6e1a34ed22b6d94d5f4a44 | refs/heads/master | 2021-08-28T08:45:30.214145 | 2021-08-20T18:55:15 | 2021-08-20T18:55:15 | 232,670,185 | 1 | 0 | null | 2020-01-08T22:11:49 | 2020-01-08T22:11:48 | null | UTF-8 | Swift | false | false | 3,847 | swift | //
// UIViewElementTests.swift
// BlueprintUI-Unit-Tests
//
// Created by Kyle Van Essen on 6/8/20.
//
import UIKit
import XCTest
@testable import BlueprintUI
class UIViewElementTests: XCTestCase {
func test_measuring() {
// Due to the static caching of UIViewElementMeasurer, this struct is nested to give it a
// unique object identifier. It only makes sense to test a unique UIViewElement type.
struct TestElement: UIViewElement {
var size: CGSize
typealias UIViewType = TestView
static var makeUIView_count: Int = 0
static func makeUIView() -> TestView {
Self.makeUIView_count += 1
return TestView()
}
static var updateUIView_count: Int = 0
static var updateUIView_isMeasuring_count: Int = 0
func updateUIView(_ view: TestView, with context: UIViewElementContext) {
Self.updateUIView_count += 1
if context.isMeasuring {
Self.updateUIView_isMeasuring_count += 1
}
view.sizeThatFits = size
}
}
XCTAssertEqual(
TestElement(size: CGSize(width: 20.0, height: 30.0)).content.measure(in: .unconstrained),
CGSize(width: 20.0, height: 30.0)
)
// Should have allocated one view for measurement.
XCTAssertEqual(TestElement.makeUIView_count, 1)
// Should have updated the view once.
XCTAssertEqual(TestElement.updateUIView_count, 1)
XCTAssertEqual(
TestElement(size: CGSize(width: 40.0, height: 60.0)).content.measure(in: .unconstrained),
CGSize(width: 40.0, height: 60.0)
)
// Should reuse the same view for measurement.
XCTAssertEqual(TestElement.makeUIView_count, 1)
// Should have updated the view again.
XCTAssertEqual(TestElement.updateUIView_count, 2)
}
func test_blueprintview() {
// Due to the static caching of UIViewElementMeasurer, this struct is nested to give it a
// unique object identifier. It only makes sense to test a unique UIViewElement type.
struct TestElement: UIViewElement {
var size: CGSize
typealias UIViewType = TestView
static var makeUIView_count: Int = 0
static func makeUIView() -> TestView {
Self.makeUIView_count += 1
return TestView()
}
static var updateUIView_count: Int = 0
static var updateUIView_isMeasuring_count: Int = 0
func updateUIView(_ view: TestView, with context: UIViewElementContext) {
Self.updateUIView_count += 1
if context.isMeasuring {
Self.updateUIView_isMeasuring_count += 1
}
view.sizeThatFits = size
}
}
let blueprintView = BlueprintView()
// Wrap the element so it needs to be measured.
blueprintView.element = TestElement(size: CGSize(width: 20.0, height: 30.0))
.centered()
// trigger a layout pass
_ = blueprintView.currentNativeViewControllers
// Should have allocated one view for measurement and one view for display.
XCTAssertEqual(TestElement.makeUIView_count, 2)
// Should have updated the view once for measurement and once for display.
XCTAssertEqual(TestElement.updateUIView_count, 2)
// Should have updated the view once for measurement.
XCTAssertEqual(TestElement.updateUIView_isMeasuring_count, 1)
}
}
fileprivate final class TestView: UIView {
var sizeThatFits: CGSize = .zero
override func sizeThatFits(_ size: CGSize) -> CGSize {
sizeThatFits
}
}
| [
-1
] |
48a4695afc89dd9e4a0a05989b01e16243f2464f | df60b8644e2e4ba23e482bd1820f2d684a4274f3 | /Tests/OpenTelemetrySdkTests/Metrics/TestMeter.swift | c51f7c6d2114361bbe5e3fcbe4c70dd4e4f3d01b | [
"Apache-2.0"
] | permissive | piyushmoolchandani/opentelemetry-swift | 14a8bdb3ef042eac5f89de881f9161c41ea656ac | 07aa022b5ff4fc1c5753efeb1c8183192b8a3ef3 | refs/heads/main | 2023-02-27T06:22:45.599903 | 2021-02-12T06:12:54 | 2021-02-12T06:12:54 | 338,015,039 | 0 | 0 | Apache-2.0 | 2021-02-11T11:53:12 | 2021-02-11T11:53:12 | null | UTF-8 | Swift | false | false | 1,003 | swift | // Copyright 2020, OpenTelemetry Authors
//
// 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.
//
@testable import OpenTelemetrySdk
import XCTest
class TestMeter: MeterSdk {
let collectAction: () -> Void
init(meterName: String, metricProcessor: MetricProcessor, collectAction: @escaping () -> Void) {
self.collectAction = collectAction
super.init(meterName: meterName, metricProcessor: metricProcessor)
}
override func collect() {
collectAction()
}
}
| [
313024
] |
2e9c9e52a60d99ad2954cdd65766bac6b2d09064 | 7ccf46b4764ca93382feb93db9163d8605f75c80 | /GrantInspection/Network/APIStatusCodes.swift | 6f9f6476a861bacdc951416c8ac5d41b38ffe30e | [] | no_license | Rajesh0912/JenkinsTest | fef218665bd9cf700c627868260e071b4e5fb774 | c34d20ca953a0d9c34513a42679643c4071c2bf7 | refs/heads/master | 2022-04-27T11:13:16.959871 | 2020-04-20T17:47:48 | 2020-04-20T17:47:48 | 257,342,838 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 13,789 | swift | //
// APIStatusCodes.swift
// iskan
//
// Created by Zeshan Hayder on 1/23/18.
// Copyright © 2018 MRHE. All rights reserved.
//
import Foundation
public enum ErrorTypes : Error {
case NilError
case InvalidStatusCodeError
}
public enum HttpStatusCode: Int{
case Http100_Continue = 100
case Http101_SwitchingProtocols = 101
case Http102_Processing = 102
/**
The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:
- GET an entity corresponding to the requested resource is sent in the response;
- HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;
- POST an entity describing or containing the result of the action;
- TRACE an entity containing the request message as received by the end server.
Wikipedia
Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action.
* General status code. Most common code used to indicate success.
**/
case Http200_OK = 200
/**
The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header field. The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.
A 201 response MAY contain an ETag response header field indicating the current value of the entity tag for the requested variant just created, see section 14.19.
Wikipedia
The request has been fulfilled and resulted in a new resource being created.
* Successful creation occurred (via either POST or PUT). Set the Location header to contain a link to the newly-created resource (on POST). Response body content may or may not be present.
**/
case Http201_Created = 201
case Http202_Accepted = 202
case Http203_NonAuthoritativeInformation = 203
/**
The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
Wikipedia
The server successfully processed the request, but is not returning any content.
* Status when wrapped responses (e.g. JSEND) are not used and nothing is in the body (e.g. DELETE).
**/
case Http204_NoContent = 204
case Http205_ResetContent = 205
case Http206_PartialContent = 206
case Http207_MultiStatus = 207
case Http208_AlreadyReported = 208
case Http209_IMUsed = 209
case Http300_MultipleChoices = 300
case Http301_MovedPermanently = 301
case Http302_Found = 302
case Http303_SeeOther = 303
/**
If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.
The response MUST include the following header fields:
- Date, unless its omission is required by section 14.18.1
If a clockless origin server obeys these rules, and proxies and clients add their own Date to any response received without one (as already specified by [RFC 2068], section 14.19), caches will operate correctly.
- ETag and/or Content-Location, if the header would have been sent in a 200 response to the same request
- Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous response for the same variant
If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers.
If a 304 response indicates an entity not currently cached, then the cache MUST disregard the response and repeat the request without the conditional.
If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response.
Wikipedia
Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header to provide a time against which to compare. Using this saves bandwidth and reprocessing on both the server and client, as only the header data must be sent and received in comparison to the entirety of the page being re-processed by the server, then sent again using more bandwidth of the server and client.
* Used for conditional GET calls to reduce band-width usage. If used, must set the Date, Content-Location, ETag headers to what they would have been on a regular GET call. There must be no body on the response.
**/
case Http304_NotModified = 304
case Http305_UseProxy = 305
case Http306_SwitchProxy = 306
case Http307_TemporaryRedirect = 307
case Http308_PermanentRedirect = 308
/**
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
Wikipedia
The request cannot be fulfilled due to bad syntax.
* General error when fulfilling the request would cause an invalid state. Domain validation errors, missing data, etc. are some examples.
**/
case Http400_BadRequest = 400
/**
The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication".
Wikipedia
Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.
* Error code response for missing or invalid authentication token.
**/
case Http401_Unauthorized = 401
case Http402_PaymentRequired = 402
/**
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.
Wikipedia
The request was a legal request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference.
* Error code for user not authorized to perform the operation or the resource is unavailable for some reason (e.g. time constraints, etc.).
**/
case Http403_Forbidden = 403
/**
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
Wikipedia
The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
* Used when the requested resource is not found, whether it doesn't exist or if there was a 401 or 403 that, for security reasons, the service wants to mask.
**/
case Http404_NotFound = 404
case Http405_MethodNotAllowed = 405
case Http406_NotAcceptable = 406
case Http407_ProxyAuthenticationRequired = 407
case Http408_RequestTimeout = 408
/**
The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be possible and is not required.
Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource which conflict with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can't complete the request. In this case, the response entity would likely contain a list of the differences between the two versions in a format defined by the response Content-Type.
Wikipedia
Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.
* Whenever a resource conflict would be caused by fulfilling the request. Duplicate entries and deleting root objects when cascade-delete is not supported are a couple of examples.
**/
case Http409_Conflict = 409
case Http410_Gone = 410
case Http411_LengthRequired = 411
case Http412_PreconditionFailed = 412
case Http413_RequestEntityTooLarge = 413
case Http414_RequestURITooLong = 414
case Http415_UnsupportedMediaType = 415
case Http416_RequestedRangeNotSatisfiable = 416
case Http417_ExpectationFailed = 417
case Http418_IamATeapot = 418
case Http419_AuthenticationTimeout = 419
case Http420_MethodFailureSpringFramework_OR_EnhanceYourCalmTwitter = 420
case Http422_UnprocessableEntity = 422
case Http423_Locked = 423
case Http424_FailedDependency_OR_MethodFailureWebDaw = 424
case Http425_UnorderedCollection = 425
case Http426_UpgradeRequired = 426
case Http428_PreconditionRequired = 428
case Http429_TooManyRequests = 429
case Http431_RequestHeaderFieldsTooLarge = 431
case Http444_NoResponseNginx = 444
case Http449_RetryWithMicrosoft = 449
case Http450_BlockedByWindowsParentalControls = 450
case Http451_RedirectMicrosoft_OR_UnavailableForLegalReasons = 451
case Http494_RequestHeaderTooLargeNginx = 494
case Http495_CertErrorNginx = 495
case Http496_NoCertNginx = 496
case Http497_HTTPToHTTPSNginx = 497
case Http499_ClientClosedRequestNginx = 499
/**
The server encountered an unexpected condition which prevented it from fulfilling the request.
Wikipedia
A generic error message, given when no more specific message is suitable.
* The general catch-all error when the server-side throws an exception.
**/
case Http500_InternalServerError = 500
case Http501_NotImplemented = 501
case Http502_BadGateway = 502
case Http503_ServiceUnavailable = 503
case Http504_GatewayTimeout = 504
case Http505_HTTPVersionNotSupported = 505
case Http506_VariantAlsoNegotiates = 506
case Http507_InsufficientStorage = 507
case Http508_LoopDetected = 508
case Http509_BandwidthLimitExceeded = 509
case Http510_NotExtended = 510
case Http511_NetworkAuthenticationRequired = 511
case Http522_ConnectionTimedOut = 522
case Http598_NetworkReadTimeoutErrorUnknown = 598
case Http599_NetworkConnectTimeoutErrorUnknown = 599
}
| [
-1
] |
4ccc68bce16a35ff8c52499b2ba9c2c2ddc5a564 | 3b2b4ac3ea328c8d097ddf3acf15d4bde9f5a931 | /AKSync/AKSync/AKLocationUpdateHandler.swift | 3bb0d82c7847c45517d60cbda342516ac945ecf9 | [] | no_license | nemoabdullah1234/ilibcr | 1709e65880d00a9e987846ec25e4b962e8224375 | 161b9d552a17ce6802e98309dd2293d6e792d870 | refs/heads/master | 2020-03-27T08:34:45.558580 | 2018-08-27T08:29:03 | 2018-08-27T08:29:03 | 146,269,026 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 11,170 | swift |
import UIKit
import RealmSwift
import CoreBluetooth
import CoreLocation
@objc public class AKLocationUpdateHandler: NSObject {
open static let sharedHandler:AKLocationUpdateHandler = AKLocationUpdateHandler()
open var delegate: AKLocationUpdaterDelegate?
var timer: Timer?
var sendInterval = 300.00
var locationUpdateTimer: Timer?
open var Kbase_url : String = ""
open var saveFactor = 0.0
open var setRole = ""
override init() {
super.init()
NotificationCenter.default.addObserver(self, selector: #selector(AKLocationUpdateHandler.handleBackground), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil);
_ = AKUtility()
if (AKUtility.getUserRole() == "warehouse") {
applicationEnvironment.ApplicationCurrentType = applicationType.warehouseOwner
}else{
applicationEnvironment.ApplicationCurrentType = applicationType.salesRep
}
}
public func setBaseUrl(_ baseUrl : String) {
AKUtility.setBaseUrl(baseUrl)
print(AKUtility.getBaseUrl())
}
public func setRole(_ role : String) {
AKUtility.setUserRole(role)
print(AKUtility.getUserRole())
}
// public func setAKSyncObject(objectModel : Object.Type) {
//
// syncObject = objectModel
//
// print(syncObject.description)
//
// }
@objc public func handleBackground(){
self.AKSyncXtimeNew()
}
public func AKStopSync()->(){
self.locationUpdateTimer?.invalidate()
self.locationUpdateTimer = nil
}
public func AKInitiateTimer(){
if(self.locationUpdateTimer == nil)
{
let time:TimeInterval = 60.0;
self.locationUpdateTimer = Timer.scheduledTimer(timeInterval: time, target: self, selector:#selector(AKLocationUpdateHandler.updateLocation), userInfo: nil, repeats: true)
}
}
@objc public func updateLocation() {
self.AKSyncXtimeNew()
}
public func AKIntiateSyncSequence() -> () {
if(self.timer == nil)
{
self.timer = Timer.scheduledTimer(timeInterval: (self.sendInterval+saveFactor),
target: self,
selector: #selector(AKLocationUpdateHandler.tick),
userInfo: nil,
repeats: true)//
}
}
var array = [Dictionary<String,String>]()
@objc public func tick() ->() {
// BeaconHandler.sharedHandler.PKSyncObj = "\(Int64(floor(NSDate().timeIntervalSince1970 * 1000.0)))"
self.AKSyncXtimeNew()
}
}
extension AKLocationUpdateHandler
{
public func AKSyncXtimeNew() -> () {
let realm = try! Realm()
// Utility.showNotification("sync called", message: "Location sync")
print("sync called")
var array = [Dictionary<String,AnyObject>]()
let dataLIst = realm.objects(AKSyncObject.self).filter("synced = false")
// let dataLIst = realm.dynamicObjects("OSSSyncObject").filter("synced = false")
print("datalist called \(dataLIst)")
var devToken = AKUtility.getDevice()
var projectId = AKUtility.getProjectId()
var clientId = AKUtility.getClientId()
if(devToken == nil)
{
devToken = " "
}
var count = 0
if(dataLIst.count<=500)
{
if(dataLIst.count == 0)
{
delegate?.AKSetLogData("1")
return
}
else
{
print("datalist count <= 0 ")
count = dataLIst.count - 1
}
}
else{
count = 500
}
for i in 0...count{
let syncObj :AKSyncObject = dataLIst[i]
var loc = Dictionary<String,AnyObject>()
print("It's for Sales Rep")
loc["projectid"] = projectId as AnyObject
loc["clientid"] = clientId as AnyObject
loc["did"] = devToken as AnyObject
loc["lat"] = Double(syncObj.value(forKey: "lat") as! String) as AnyObject
loc["lon"] = Double(syncObj.value(forKey: "lng") as! String) as AnyObject
loc["ts"] = Double(syncObj.value(forKey: "id") as! String) as AnyObject
loc["alt"] = Double(syncObj.value(forKey: "alt") as! String) as AnyObject
loc["spd"] = Double(syncObj.value(forKey: "speed") as! String) as AnyObject
loc["dir"] = Double(syncObj.value(forKey: "direction") as! String) as AnyObject
loc["acc"] = Double(syncObj.value(forKey: "accuracy") as! String) as AnyObject
loc["prv"] = "\(syncObj.value(forKey: "provider") as! String)" as AnyObject
loc["pkid"] = "\(syncObj.value(forKey: "pkid") as! String)" as AnyObject
loc["ht"] = (Int64(floor(Date().timeIntervalSince1970 * 1000.0))) as AnyObject
var sens = [Dictionary<String,AnyObject>]()
for becn in syncObj.event{
var sensor = Dictionary<String,AnyObject>()
let state = AKSyncStateModel()
state.major = becn.value(forKey: "major") as! String
state.minor = becn.value(forKey: "minor") as! String
state.proximity = becn.value(forKey: "proximity") as! String
state.longitude = syncObj.value(forKey: "lng") as! String
state.lattitude = syncObj.value(forKey: "lat") as! String
state.UDIDBeacon = becn.value(forKey: "uuid") as! String
AKSyncState.sharedHandler.setRole = setRole
AKSyncState.sharedHandler.setSensorData(state)
delegate?.AKSetLogData("2")
// delegate?.AKSenserData(state)
sensor["uuid"] = becn.value(forKey: "uuid") as? String as AnyObject
sensor["maj"] = NSInteger((becn.value(forKey: "major") as? String)!) as AnyObject
sensor["min"] = NSInteger((becn.value(forKey: "minor") as? String)!) as AnyObject
sensor["rng"] = Double((becn.value(forKey: "proximity") as? String)!) as AnyObject
sensor["rssi"] = NSInteger((becn.value(forKey: "rssi") as? String)!) as AnyObject
sensor["dis"] = Double((becn.value(forKey: "distance") as? String)!) as AnyObject
sensor["type"] = "beacon" as AnyObject
sens.append(sensor)
}
loc["sensors"] = sens as AnyObject
array.append(loc)
}
if(array.count == 0)
{
print("aborted usless sync")
delegate?.AKSetLogData("1")
AKSyncState.sharedHandler.setRole = setRole
AKSyncState.sharedHandler.setApiHitTime("\(Int64(floor(Date().timeIntervalSince1970 * 1000.0)))")
AKSyncState.sharedHandler.logEvent()
AKSyncState.sharedHandler.setApiHitTime("")
return
}
let api = AKGeneralAPI()
print("track api hit")
var param = Dictionary<String,AnyObject>()
param.updateValue(array as AnyObject, forKey: "beacons")
delegate?.AKSetLogData("4")
AKSyncState.sharedHandler.setRole = setRole
AKSyncState.sharedHandler.setApiHitTime("\(Int64(floor(Date().timeIntervalSince1970 * 1000.0)))")
AKSyncState.sharedHandler.logEvent()
AKSyncState.sharedHandler.setApiHitTime("")
delegate?.AKSendJsonToMQTT(param)
self.delegate?.AKSetLogData("5")
/* api.hitApiwith(param, serviceType:.strApiSyncNew, success: { (dict) in
print (dict)
DispatchQueue.main.async {
self.delegate?.AKSetLogData("5")
AKSyncState.sharedHandler.setRole = self.setRole
AKSyncState.sharedHandler.clearSensorData()
AKSyncState.sharedHandler.logEvent()
try! realm.write({
for obj in dataLIst{
obj.synced = true
}
// for i in 0...count{
// let syncObj:OSSSyncObject = dataLIst[i]
// syncObj.synced = true
// }
//dataLIst.setValue("true", forKey: "synced")
})
}
}) { (err) in
print(err)
DispatchQueue.main.async {
self.delegate?.AKSetLogData("5")
AKSyncState.sharedHandler.setRole = self.setRole
AKSyncState.sharedHandler.logEvent()
AKSyncState.sharedHandler.clearSensorData()
}
} */
}
public func AKScannerstate()->(){
var locationStatus : NSInteger
var bluetoothStatus : NSInteger
let os = "ios"
let generalApi = AKGeneralAPI()
bluetoothStatus = AKUtility.getBlueToothState()
if(!CLLocationManager.locationServicesEnabled() || CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways)
{
locationStatus = 0
AKSyncState.sharedHandler.setRecordTime("\(Int64(floor(Date().timeIntervalSince1970 * 1000.0)))")
AKSyncState.sharedHandler.setGPSAvailable("0")
self.delegate?.AKGPSState("0")
}
else{
locationStatus = 1
AKSyncState.sharedHandler.setRecordTime("\(Int64(floor(Date().timeIntervalSince1970 * 1000.0)))")
AKSyncState.sharedHandler.setGPSAvailable("1")
self.delegate?.AKGPSState("1")
}
let device = UIDevice.current;
let currentDeviceId = device.identifierForVendor!.uuidString;
generalApi.hitApiwith(["deviceId":currentDeviceId as AnyObject,"appCode" : AKUtility.getDevice() as AnyObject, "locationStatus":locationStatus as AnyObject,"bluetoothStatus":bluetoothStatus as AnyObject,"os":os as AnyObject], serviceType: .strApiStatus, success: { (response) in
print(response)
}) { (error) in
}
}
}
@objc public protocol AKLocationUpdaterDelegate{
func AKSetLogData(_ datacount: String);
func AKSenserData(_ senserDate: AKSyncStateModel);
func AKGPSState(_ gpsState: String);
func AKSendJsonToMQTT (_ jsonMQTT : Dictionary<String,AnyObject>)
}
public extension AKLocationUpdaterDelegate{
func AKSetLogData(_ datacount: String){
}
func AKSenserData(_ senserDate: AKSyncStateModel){
}
func AKGPSState(_ gpsState: String){
}
func AKSendJsonToMQTT (_ jsonMQTT : Dictionary<String,AnyObject>)
{
}
}
| [
-1
] |
cf894a211b87c00bba035a77cc675b91e82e92f6 | 21d99b870ac539340ec2b96f55489173af14dca6 | /Cryptocurrency/Service/CryptocurrencyNetwork.swift | 3f4ca3591830f9a3e1cd86ddabaab0ddeb6ccde6 | [] | no_license | Zeyden/Cryptocurrency | 03d8d95489246bd85a06e028a090ee9423c637d4 | 74e74cd1136fa04c1a18a7e44300a44678e75892 | refs/heads/master | 2020-03-26T06:27:24.823951 | 2018-08-13T16:40:44 | 2018-08-13T16:40:44 | 144,606,296 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,809 | swift | //
// CryptocurrencyNetwork.swift
// Cryptocurrency
//
// Created by Азат Шамсуллин on 29.04.2018.
// Copyright © 2018 ZeydenApp. All rights reserved.
//
import Foundation
class CryptocurrencyNetwork {
enum ConverterCurrencies: String {
static var allValues = ["AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR"]
case AUD = "AUD"
case BRL = "BRL"
case CAD = "CAD"
case CHF = "CHF"
case CLP = "CLP"
case CNY = "CNY"
case CZK = "CZK"
case DKK = "DKK"
case EUR = "EUR"
case GBP = "GBP"
case HKD = "HKD"
case HUF = "HUF"
case IDR = "IDR"
case ILS = "ILS"
case INR = "INR"
case JPY = "JPY"
case KRW = "KRW"
case MXN = "MXN"
case MYR = "MYR"
case NOK = "NOK"
case NZD = "NZD"
case PHP = "PHP"
case PKR = "PKR"
case PLN = "PLN"
case RUB = "RUB"
case SEK = "SEK"
case SGD = "SGD"
case THB = "THB"
case TRY = "TRY"
case TWD = "TWD"
case ZAR = "ZAR"
}
private(set) static var shared = CryptocurrencyNetwork()
private(set) var baseURL = "https://api.coinmarketcap.com/v1"
func obtainCryptocurrenciesList(start: Int = 0, limit: Int = 20, converted: ConverterCurrencies? = nil, _ completion: @escaping (([Currency]?, ServiceError?) -> Void)) {
let session = URLSession.shared
var endPoint = "/ticker/?start=\(start)&limit=\(limit)"
if let converted = converted {
endPoint += "&convert=\(converted.rawValue)"
}
let urlString = baseURL + endPoint
guard let url = URL(string: urlString) else { return }
let datatask = session.dataTask(with: url) { (data, response, error) in
let statusCode = (response as? HTTPURLResponse)?.statusCode
let serviceError = ServiceError(error: error as NSError?, responseCode: statusCode)
var entities: [Currency]?
if let data = data,
let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers),
let array = json as? [Any] {
entities = array.compactMap { Currency(json: $0) }
}
DispatchQueue.main.async {
completion(entities, serviceError)
}
}
datatask.resume()
}
func obtainCryptocurrency(id: String, converted: ConverterCurrencies? = nil, _ completion: @escaping ((Currency?, ServiceError?) -> Void)) {
let session = URLSession.shared
let endPoint = "/ticker/\(id)/"
let urlString = baseURL + endPoint
guard let url = URL(string: urlString) else { return }
let datatask = session.dataTask(with: url) { (data, response, error) in
let statusCode = (response as? HTTPURLResponse)?.statusCode
let serviceError = ServiceError(error: error as NSError?, responseCode: statusCode)
var entity: Currency?
if let data = data,
let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) {
entity = Currency(json: json)
}
DispatchQueue.main.async {
completion(entity, serviceError)
}
}
datatask.resume()
}
}
| [
-1
] |
29ea7665444460bf5c966a2bf9bb395f80049a5e | 93944605c1fd527a4664f18b8c4894e91636c360 | /BMIScreens-in-Swift/Controller/ViewController.swift | a65b49069d5c3c91ce9bc65ea3c9fd2265e60b32 | [] | no_license | tommybarral/BMIScreens-in-Swift | 0fbd04647e622226d1b4aad6cac5ddda63f2955a | 24ef2943fc5d3f65aa9f6055ea87358e02d5661b | refs/heads/master | 2021-05-20T23:42:02.562883 | 2020-04-03T08:11:50 | 2020-04-03T08:11:50 | 252,457,485 | 2 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,513 | swift | //
// ViewController.swift
// BMIScreens-in-Swift
//
// Created by tommy on 02/04/2020.
// Copyright © 2020 tommy. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var bmiValue = "0.0"
var calculatorData = CalculatorData()
@IBOutlet weak var heightLabel: UILabel!
@IBOutlet weak var weightLabel: UILabel!
@IBOutlet weak var heightCalc: UISlider!
@IBOutlet weak var weightCalc: UISlider!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func heightSlider(_ sender: UISlider) {
let height = String(format: "%.2f", sender.value)
heightLabel.text = "\(height)m"
}
@IBAction func weightSlider(_ sender: UISlider) {
let weight = String(format: "%.0f", sender.value)
weightLabel.text = "\(weight)Kg"
}
@IBAction func calc(_ sender: UIButton) {
let height = heightCalc.value
let weight = weightCalc.value
calculatorData.resultBMI(height: height, weight: weight)
self.performSegue(withIdentifier: "goToResult", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "goToResult" {
let resultView = segue.destination as! ResultsViewController
resultView.bmiValue = calculatorData.getBMIValue()
resultView.advice = calculatorData.getAdvice()
resultView.color = calculatorData.getColor()
}
}
}
| [
-1
] |
a939cf7d4aacb118ee81076f882d455c7164c622 | ec1bfb05452fe9f97837954a1c80f7a98e50b4ce | /xcode_project/RecipeHub/ContentView.swift | 2a6720ef05e42f3876b92dd52de01e99a08d894a | [] | no_license | RJC0514/RecipeHub | e1c905330e9ff6cea2a989507d776f4fbd30244f | 396e3c16b18cd6c01065e9f7212aa3b458cea64e | refs/heads/master | 2023-08-28T02:14:31.876107 | 2021-10-24T10:23:40 | 2021-10-24T10:23:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 796 | swift | //
// ContentView.swift
// RecipeMaker
//
// Created by Ryan Cosentino on 10/22/21.
//
import SwiftUI
struct ContentView: View {
@StateObject var settings = Settings()
@StateObject var favorites = Favorites()
var body: some View {
TabView {
IngredientsView().tabItem {
Image(systemName: "folder")
Text("Ingredients")
}
Search().tabItem {
Image(systemName: "magnifyingglass")
Text("Search")
}
FavoritesView().tabItem {
Image(systemName: "star.fill")
Text("Favorites")
}
SettingsView().tabItem {
Image(systemName: "gear")
Text("Settings")
}
}
.environmentObject(settings)
.environmentObject(favorites)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
| [
-1
] |
cc86dccf41a42f555d72a1ae769168ebe02c0564 | ed1a70784a55df78e4e4fbdf36dec7ecc2a87218 | /Smart Cane/Data/Data.swift | 834533d95682d8af1df571cda6deff6aa7932531 | [] | no_license | noahwrivas/Smart-Cane | 7d1ec5850afc1cba3c7846f98b7aa2aeadca7439 | 926e12db4f7d82ce0ce34cafceb4559ecbd3ac75 | refs/heads/master | 2020-08-28T06:07:12.674577 | 2019-10-25T21:26:20 | 2019-10-25T21:26:20 | 217,616,653 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 775 | swift | //
// Data.swift
// Smart Cane
//
// Created by Noah Rivas on 10/23/19.
// Copyright © 2019 Noah Rivas. All rights reserved.
//
import SwiftUI
import CoreLocation
struct JSONData: Hashable, Codable {
var id: Int
fileprivate var coordinates: Coordinates
var InitialOpening: Bool
var SilentMode: Bool
var Ping: Bool
var VibrationIntensity: Int
var bluetoothData: BluetoothData
var locationCoordinate: CLLocationCoordinate2D {
CLLocationCoordinate2D(
latitude: coordinates.latitude,
longitude: coordinates.longitude)
}
}
struct Coordinates: Hashable, Codable {
var latitude: Double
var longitude: Double
}
struct BluetoothData: Hashable, Codable {
var UUID: String
var Data: String
}
| [
-1
] |
8d32b2265b10ec94dfc8f9b9bd4b58ef5c56b874 | d4229476f023ce756e54d12ff700c39e2cbb973d | /DesignPatterns.playground/Sources/ItemIcon.swift | 6e5900736c94b57a0028ce0fde489c7722d98ffd | [] | no_license | moritzbruder/DesignPattern-Playground | 9052434848bd3d96114e3d39803a6b5ad0d3b9de | b1d11b4ef3f8de5fc25198b8e06b6e8caa3c3d7c | refs/heads/master | 2021-07-24T00:33:52.568939 | 2021-05-14T18:35:12 | 2021-05-14T18:35:12 | 126,171,166 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,337 | swift | import Foundation
import UIKit
public class ItemIcon {
public static func getIcon (name: String) -> UIImage? {
if (name.lowercased().contains("bread")) {
return UIImage.init(named: "icon/bread")
} else if (name.lowercased().contains("peanut")) {
return UIImage.init(named: "icon/peanut")
} else if (name.lowercased().contains("milk")) {
return UIImage.init(named: "icon/milk")
} else if (name.lowercased().contains("cookie")) {
return UIImage.init(named: "icon/cookies")
} else if (name.lowercased().contains("tomato")) {
return UIImage.init(named: "icon/tomato")
} else if (name.lowercased().contains("butter")) {
return UIImage.init(named: "icon/butter")
} else if (name.lowercased().contains("water")) {
return UIImage.init(named: "icon/water")
} else if (name.lowercased().contains("apple")) {
return UIImage.init(named: "icon/apple")
} else if (name.lowercased().contains("new")) {
return UIImage.init(named: "icon/new")
} else {
return UIImage.init(named: "icon/bag")
}
}
}
| [
-1
] |
69527e08025a046e8c0477002be266a6c40e27d1 | 4ae8b8cffe26fd5e477be1aa93566db2f000fdab | /NavigationController/NavigationController/RootTableViewController.swift | d7c24252e719d53012b8bc0761de02bd3dacc481 | [] | no_license | DevinLPC/learntojike | c1f4cde5ff69b94847bb04e47384ad8c542a0fac | 1e708d8f002a5575de8398d5da70fbaba924efeb | refs/heads/master | 2021-01-06T20:40:13.124235 | 2016-08-29T02:49:06 | 2016-08-29T02:49:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,092 | swift | //
// RootTableViewController.swift
// NavigationController
//
// Created by mayee on 16/7/2.
// Copyright © 2016年 jikexueyuan. All rights reserved.
//
import UIKit
class RootTableViewController: UITableViewController {
private var dataSoure:NSArray!
override func viewDidLoad() {
super.viewDidLoad()
dataSoure = NSArray(contentsOfURL: NSBundle.mainBundle().URLForResource("data", withExtension: "plist")!)
print(dataSoure)
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return dataSoure.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
// Configure the cell...
let joke = dataSoure.objectAtIndex(indexPath.row) as! NSDictionary
let lable = cell.viewWithTag(1) as!UILabel
lable.text = joke.objectForKey("title") as? String
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let joke = dataSoure.objectAtIndex(indexPath.row) as! NSDictionary
let contentVc = storyboard?.instantiateViewControllerWithIdentifier("ContentVC") as! ContentViewController
contentVc.setContent(joke.objectForKey("content") as! String)
navigationController?.pushViewController(contentVc, animated: true)
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
| [
-1
] |
dc8c6cfa2c3015dc4994ea9ffef6f96aa6e2499d | 379a41b7ffc4a282ffb5e3f6260112e51d62aa97 | /CodinomeEventos/ViewController/ListaDeFornecedoresViewController.swift | 6212bfb8be4b93a795a64c8a948f9cc9eb80b4ef | [] | no_license | brunarminosso/CodinomeEventos | 360e37cb07b3edf7b44b93964fe05a39b1d9503f | 9526d3078ea425bfaba7af19717fa179dcab187c | refs/heads/master | 2020-06-22T00:09:30.701960 | 2019-08-02T14:04:52 | 2019-08-02T14:04:52 | 197,585,140 | 0 | 2 | null | null | null | null | UTF-8 | Swift | false | false | 6,774 | swift | //
// ListaDeFornecedoresViewController.swift
// CodinomeEventos
//
// Created by Aline Osana Escobar on 23/07/19.
// Copyright © 2019 Bruna Rafaela Martins Minosso. All rights reserved.
//
import UIKit
// MARK: - Fornecedore
struct Fornecedores: Codable {
let nome, email, cep, endereco: String
let numero: Int
let bairro: String
let cidade: String
let estado: String
let telefoneFixo, celular: String
let categoria: String
let notaAvaliacaoMedia: Double
let descricao: String
let avaliacaoQualidadeMedia: Double
let avaliacaoPontualidadeMedia, avaliacaoPrecoMedia: Int
let avaliacoes: [Avaliacoe]
enum CodingKeys: String, CodingKey {
case nome = "nome"
case email = "email"
case cep = "cep"
case endereco = "endereco"
case numero = "numero"
case bairro = "bairro"
case cidade = "cidade"
case estado = "estado"
case telefoneFixo = "telefone_fixo"
case celular = "celular"
case categoria = "categoria"
case notaAvaliacaoMedia = "nota_avaliacao_media"
case descricao = "descricao"
case avaliacaoQualidadeMedia = "avaliacao_qualidade_media"
case avaliacaoPontualidadeMedia = "avaliacao_pontualidade_media"
case avaliacaoPrecoMedia = "avaliacao_preco_media"
case avaliacoes
}
}
// MARK: - Avaliacoe
struct Avaliacoe: Codable {
let nomeAvaliador: String
let fotoAvaliador: String
let nota: Int
let textoAval: String
enum CodingKeys: String, CodingKey {
case nomeAvaliador = "nome_avaliador"
case fotoAvaliador = "foto_avaliador"
case nota = "nota"
case textoAval = "texto_aval"
}
}
class ListaDeFornecedoresViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
func isFiltering() -> Bool {
return searchController.isActive && !searchBarIsEmpty()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return listaFornecedores.count
if isFiltering(){
return fornecedorFiltrado.count
}
return listaFornecedores.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ListaFornecedores") as? FornecedoresTableViewCell
let fornecedor: Fornecedores
if isFiltering() {
fornecedor = fornecedorFiltrado[indexPath.row]
}
else {
fornecedor = listaFornecedores[indexPath.row]
}
cell?.ListaFornecedores_nomeFornecedor.text = fornecedor.nome
cell?.ListaFornecedores_endereco.text = fornecedor.bairro
cell?.ListaFornecedores_Categoria.text = fornecedor.categoria
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let fornecedor: Fornecedores
if isFiltering(){
fornecedor = fornecedorFiltrado[indexPath.row]
}
else {
fornecedor = listaFornecedores[indexPath.row]
}
performSegue(withIdentifier: "segueDetalhesFornecedor", sender: fornecedor)
}
var listaFornecedores = [Fornecedores]()
var filtro: String = ""
var fornecedorFiltrado = [Fornecedores]()
// declaracao da search bar
let searchController = UISearchController(searchResultsController: nil)
func searchBarIsEmpty() -> Bool {
return searchController.searchBar.text?.isEmpty ?? true
}
func filterContentForSeachText (_ searchText: String, scope: String = "All") {
fornecedorFiltrado = self.listaFornecedores.filter { $0.nome.contains(searchText) }
tableView.reloadData()
return
}
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var categoria_Label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
getdata()
// Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Busque seus fornecedores"
navigationItem.searchController = searchController
definesPresentationContext = false
// format categoria label
categoria_Label.font = UIFont(name: "Lato-Semibold", size: CGFloat(28))
categoria_Label.textColor = UIColor(red: 0.39, green: 0.2, blue: 0.54, alpha: 1)
categoria_Label.text = filtro
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segueDetalhesFornecedor" {
if let viewController = segue.destination as? DetalhesFornecedorViewController {
if let fornecedores = sender as? Fornecedores {
viewController.fornecedor = fornecedores
// viewController.detalheNomeFornecedor = fornecedores.nome
// viewController.detalheDescricao = fornecedores.descricao
// viewController.detalheCategoria = fornecedores.categoria
// viewController.detalheEndereco = fornecedores.endereco
// viewController.nota = fornecedores.notaAvaliacaoMedia
// viewController. = filtro
}
}
}
}
func getdata() {
let jsonUrlString = "https://gist.githubusercontent.com/alineescobar/8aa8fd62a3929f82aae7720edc1900ab/raw/9cf8728cf8d699281831d307b92274994031d0bf/fornecedores.json"
guard let url = URL(string: jsonUrlString) else {return}
URLSession.shared.dataTask(with: url){ (data, response, err) in
guard let data = data else {return}
do {
let dados = try JSONDecoder().decode([Fornecedores].self, from: data)
DispatchQueue.main.async {
self.listaFornecedores = dados.filter { $0.categoria == self.filtro }
self.tableView.reloadData()
print("Numero de linhas:", self.listaFornecedores.count)
}
} catch let jsonErr{
print("Error serializating JSON", jsonErr)
}
}.resume()
}
}
extension ListaDeFornecedoresViewController: UISearchResultsUpdating{
func updateSearchResults(for searchController: UISearchController) {
filterContentForSeachText(searchController.searchBar.text!)
}
}
| [
-1
] |
6d0d4f9e6a5efdc7ccaae8036608ddc956c88037 | 1fb78a04e2b741beb449528492ac18a6c87bbe3b | /SceneDelegate.swift | d32e5496b531898adb97dcca9d08bb0b54185ac2 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | jigardave8/Climateapp_swift5_iOS13 | 5330be992d6a4814a205df591d7a7abc8465ef97 | 8baf7e3e610d35d1e1597736f26372dc9cbbb21c | refs/heads/master | 2023-06-03T19:43:47.473397 | 2021-06-29T08:55:18 | 2021-06-29T08:55:18 | 283,385,752 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,338 | swift | //
// SceneDelegate.swift
// Clima
// Created by Jigar Dave on 25/07/20.
// Copyright © 2020 Bitdegree. All rights reserved.
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
}
| [
393221,
163849,
393228,
393231,
393251,
344103,
393260,
393269,
213049,
376890,
385082,
16444,
393277,
376906,
327757,
254032,
286804,
368728,
254045,
368736,
180322,
376932,
286833,
286845,
286851,
417925,
262284,
360598,
286880,
286889,
377003,
377013,
164029,
327872,
180418,
377030,
377037,
180432,
377047,
418008,
385243,
418012,
377063,
327915,
205037,
393457,
393461,
393466,
418044,
336124,
385281,
336129,
262405,
180491,
164107,
336140,
262417,
368913,
262423,
377118,
377121,
262437,
254253,
336181,
262455,
393539,
262473,
344404,
213333,
418135,
270687,
262497,
418145,
262501,
213354,
246124,
262508,
262512,
213374,
385420,
262551,
262553,
385441,
385444,
262567,
385452,
262574,
393649,
385460,
262587,
344512,
262593,
336326,
360917,
369119,
328178,
328180,
328183,
328190,
254463,
328193,
98819,
164362,
328207,
410129,
393748,
377372,
188959,
385571,
377384,
197160,
33322,
352822,
270905,
197178,
418364,
188990,
369224,
385610,
270922,
352844,
385617,
352865,
262761,
352875,
344694,
352888,
336513,
377473,
336517,
344710,
385671,
148106,
377485,
352919,
98969,
336549,
344745,
361130,
336556,
385714,
434868,
164535,
336568,
328379,
164539,
328387,
352969,
385743,
385749,
189154,
369382,
361196,
418555,
344832,
336644,
344837,
344843,
328462,
361231,
394002,
336660,
418581,
418586,
434971,
369436,
262943,
369439,
418591,
418594,
336676,
418600,
418606,
271154,
328498,
369464,
361274,
328516,
336709,
328520,
336712,
361289,
328523,
336715,
361300,
213848,
426842,
361307,
197469,
361310,
254813,
361318,
344936,
361323,
361335,
328574,
369544,
361361,
222129,
345036,
115661,
386004,
345046,
386012,
386019,
328690,
435188,
328703,
328710,
418822,
328715,
377867,
386070,
271382,
336922,
345119,
377888,
328747,
345134,
345139,
361525,
361537,
377931,
197708,
189525,
156762,
402523,
361568,
148580,
345200,
361591,
386168,
410746,
361594,
214150,
345224,
386187,
337048,
345247,
361645,
337072,
345268,
337076,
402615,
361657,
402636,
328925,
165086,
165092,
222438,
386286,
328942,
386292,
206084,
115973,
328967,
345377,
353572,
345380,
345383,
263464,
337207,
345400,
378170,
369979,
337224,
337230,
337235,
263509,
353634,
337252,
402792,
345449,
99692,
271731,
378232,
337278,
271746,
181639,
353674,
181644,
361869,
181650,
181655,
230810,
181671,
181674,
181679,
181682,
337330,
181687,
370105,
181691,
181697,
361922,
337350,
181704,
337366,
271841,
329192,
361961,
329195,
116211,
337399,
402943,
337416,
329227,
419341,
419345,
329234,
419351,
345626,
419357,
345631,
370208,
419360,
394787,
419363,
370214,
419369,
394796,
419377,
419386,
206397,
214594,
419401,
419404,
353868,
419408,
214611,
419412,
403040,
345702,
222831,
370298,
353920,
403073,
403076,
345737,
198282,
403085,
403092,
345750,
419484,
345758,
345763,
419492,
419498,
419502,
370351,
419507,
337588,
419510,
419513,
419518,
403139,
337607,
419528,
419531,
419536,
272083,
394967,
419545,
345819,
419548,
181982,
419551,
345829,
419560,
337643,
419564,
337647,
370416,
141052,
337661,
337671,
362249,
362252,
395022,
362256,
321300,
345888,
116512,
362274,
378664,
354107,
345916,
354112,
247618,
370504,
329545,
345932,
354124,
370510,
337751,
247639,
370520,
313181,
182110,
354143,
354157,
345965,
345968,
345971,
345975,
182136,
403321,
1914,
354173,
247692,
395148,
337809,
247701,
329625,
436127,
436133,
247720,
337834,
362414,
337845,
190393,
346064,
247760,
346069,
329699,
354275,
190440,
247790,
354314,
346140,
337980,
436290,
378956,
395340,
436307,
338005,
329816,
100454,
329833,
329853,
329857,
329868,
411806,
329886,
346273,
362661,
100525,
387250,
379067,
387261,
256193,
395467,
256214,
411862,
411865,
411869,
411874,
379108,
411877,
387303,
346344,
395496,
338154,
387307,
346350,
338161,
436474,
321787,
379135,
411905,
411917,
43279,
379154,
395539,
387350,
387353,
338201,
182559,
338212,
395567,
248112,
362823,
436556,
321880,
362844,
379234,
354674,
182642,
321911,
420237,
379279,
354728,
338353,
338363,
338382,
272849,
248279,
256474,
182755,
338404,
338411,
330225,
248309,
199165,
248332,
330254,
199182,
199189,
420377,
330268,
191012,
330320,
199250,
191069,
346722,
248427,
191085,
338544,
191093,
346743,
330384,
346769,
150184,
174775,
248505,
174778,
363198,
223936,
355025,
273109,
264919,
256735,
338661,
338665,
264942,
330479,
363252,
338680,
207620,
264965,
191240,
338701,
256787,
363294,
199455,
396067,
346917,
396070,
215854,
355123,
355141,
355144,
338764,
330581,
330585,
387929,
355167,
265056,
265059,
355176,
355180,
330612,
330643,
412600,
207809,
379849,
347082,
396246,
330711,
248794,
248799,
347106,
437219,
257009,
265208,
330750,
199681,
338951,
330761,
330769,
330775,
248863,
158759,
396329,
347178,
404526,
396337,
330803,
396340,
339002,
388155,
339010,
248905,
330827,
330830,
248915,
183384,
339037,
412765,
257121,
322660,
265321,
330869,
248952,
420985,
330886,
330890,
347288,
248986,
44199,
380071,
339118,
249018,
339133,
322763,
330959,
330966,
265433,
265438,
388320,
363757,
388348,
339199,
396552,
175376,
175397,
208167,
273709,
372016,
437553,
347442,
199989,
175416,
396601,
208189,
437567,
175425,
437571,
437576,
437584,
331089,
437588,
396634,
175451,
437596,
429408,
175458,
208228,
175461,
175464,
265581,
331124,
175478,
249210,
175484,
249215,
175487,
249219,
175491,
249225,
249228,
249235,
175514,
175517,
396703,
396706,
175523,
355749,
396723,
388543,
380353,
216518,
339401,
380364,
339406,
372177,
339414,
413143,
249303,
339418,
339421,
249310,
339425,
249313,
339429,
339435,
249329,
69114,
372229,
339464,
249355,
208399,
380433,
175637,
405017,
134689,
339504,
265779,
421442,
413251,
265796,
265806,
224854,
224858,
339553,
257636,
224871,
372328,
257647,
372338,
339572,
224885,
224888,
224891,
224895,
421509,
126597,
224905,
11919,
224911,
224914,
126611,
224917,
224920,
126618,
208539,
224923,
224927,
224930,
224933,
257705,
224939,
224943,
257713,
224949,
257717,
257721,
224954,
257725,
224960,
257733,
224966,
224970,
257740,
224976,
257745,
257748,
224982,
257752,
224987,
257762,
224996,
225000,
339696,
225013,
257788,
225021,
339711,
257791,
225027,
257796,
339722,
257802,
257805,
225039,
257808,
249617,
225044,
167701,
372500,
257815,
225049,
257820,
225054,
184096,
257825,
225059,
339748,
225068,
257837,
413485,
225071,
225074,
257843,
225077,
257846,
225080,
397113,
225083,
397116,
257853,
225088,
225094,
225097,
323404,
257869,
257872,
225105,
339795,
397140,
225109,
225113,
257881,
257884,
257887,
225120,
257891,
413539,
225128,
257897,
225138,
339827,
257909,
225142,
372598,
257914,
257917,
225150,
257922,
380803,
225156,
339845,
257927,
225166,
397201,
225171,
380823,
225176,
225183,
184245,
372698,
372704,
372707,
356336,
380919,
372739,
405534,
266295,
266298,
217158,
421961,
200786,
356440,
217180,
430181,
266351,
356467,
266365,
192640,
266375,
381069,
225425,
250003,
225430,
250008,
356507,
250012,
225439,
135328,
225442,
438434,
192674,
225445,
225448,
438441,
225451,
258223,
225456,
430257,
225459,
225462,
225468,
389309,
225472,
372931,
225476,
389322,
225485,
225488,
225491,
266454,
225494,
225497,
225500,
225503,
225506,
356580,
225511,
217319,
225515,
225519,
381177,
397572,
356631,
356638,
356641,
356644,
356647,
266537,
356650,
389417,
356656,
332081,
307507,
340276,
356662,
397623,
332091,
225599,
332098,
201030,
348489,
332107,
151884,
430422,
348503,
332118,
250203,
332130,
250211,
340328,
250217,
348523,
348528,
332153,
356734,
389503,
332158,
438657,
332162,
389507,
348548,
356741,
250239,
332175,
160152,
373146,
373149,
70048,
356783,
266688,
324032,
201158,
340452,
127473,
217590,
340473,
324095,
324100,
324103,
324112,
340501,
324118,
324122,
340512,
332325,
324134,
381483,
356908,
324141,
324143,
356917,
324150,
324156,
168509,
348734,
324161,
324165,
356935,
381513,
348745,
324171,
324174,
324177,
389724,
332381,
373344,
340580,
348777,
381546,
119432,
340628,
184983,
373399,
340639,
258723,
332460,
332464,
332473,
381626,
332484,
332487,
332494,
357070,
357074,
332512,
332521,
340724,
332534,
155647,
373499,
348926,
389927,
348979,
152371,
398141,
127815,
357202,
389971,
357208,
136024,
389979,
430940,
357212,
357215,
439138,
201580,
201583,
349041,
340850,
201589,
381815,
430967,
324473,
398202,
119675,
324476,
430973,
340859,
340863,
324479,
324482,
324485,
324488,
185226,
381834,
324493,
324496,
324499,
430996,
324502,
324511,
422817,
324514,
201638,
398246,
373672,
324525,
5040,
111539,
324534,
5047,
324539,
324542,
398280,
349129,
340940,
340942,
209874,
340958,
431073,
398307,
340964,
209896,
201712,
209904,
349173,
381947,
201724,
431100,
349181,
431107,
349203,
209944,
209948,
250915,
250917,
169002,
357419,
209966,
209969,
209973,
209976,
209980,
209988,
209991,
209996,
431180,
349268,
177238,
250968,
210011,
373853,
341094,
210026,
210028,
210032,
349296,
210037,
210042,
210045,
349309,
152704,
160896,
349313,
210053,
210056,
349320,
373905,
259217,
210068,
210072,
210078,
210081,
210085,
210089,
210096,
210100,
324792,
210108,
357571,
210116,
210128,
333010,
210132,
333016,
210139,
210144,
218355,
251123,
218361,
275709,
128254,
275713,
242947,
275717,
275723,
333075,
349460,
333079,
251161,
349486,
349492,
415034,
251211,
210261,
365912,
259423,
374113,
251236,
374118,
234867,
390518,
357756,
374161,
112021,
349591,
333222,
210357,
259516,
415168,
366035,
415187,
366039,
415192,
415194,
415197,
415200,
333285,
415208,
366057,
366064,
415217,
415225,
423424,
415258,
415264,
366118,
415271,
382503,
349739,
144940,
415279,
415282,
415286,
210488,
415291,
415295,
333387,
333396,
333400,
366173,
333415,
423529,
423533,
333423,
210547,
415354,
333440,
267910,
267929,
333472,
333512,
259789,
358100,
366301,
333535,
366308,
366312,
431852,
399086,
366319,
210673,
366322,
399092,
366326,
333566,
268042,
210700,
366349,
210707,
399129,
333593,
333595,
210720,
358192,
366384,
210740,
366388,
358201,
399166,
325441,
366403,
325447,
341831,
341835,
341839,
341844,
415574,
358235,
341852,
350046,
399200,
399208,
358256,
268144,
358260,
399222,
325494,
186233,
333690,
243584,
325505,
333699,
399244,
333709,
333725,
333737,
382891,
382898,
333767,
358348,
333777,
219094,
399318,
358372,
350190,
350194,
333819,
350204,
350207,
325633,
325637,
350214,
268299,
333838,
350225,
350232,
333851,
350238,
350241,
374819,
350245,
350249,
350252,
178221,
350257,
350260,
350272,
243782,
350281,
350286,
374865,
252021,
342134,
374904,
268435,
333989,
333998,
334012,
260299,
350411,
350417,
350423,
211161,
350426,
334047,
350449,
358645,
350454,
350459,
350462,
350465,
350469,
325895,
268553,
194829,
350477,
268560,
350481,
432406,
350487,
350491,
350494,
325920,
350500,
350505,
358701,
391469,
350510,
358705,
358714,
358717,
383307,
358738,
334162,
383331,
383334,
391531,
383342,
334204,
194942,
391564,
366991,
334224,
342431,
375209,
326059,
375220,
342453,
334263,
326087,
358857,
195041,
334306,
334312,
104940,
375279,
162289,
350724,
186898,
342546,
350740,
342551,
334359,
342555,
334364,
416294,
350762,
252463,
358962,
334386,
334397,
358973,
252483,
219719,
399957,
244309,
334425,
326240,
375401,
334466,
334469,
391813,
162446,
326291,
342680,
342685,
260767,
342711,
244410,
260798,
260802,
350918,
154318,
342737,
391895,
154329,
416476,
64231,
113389,
342769,
203508,
375541,
342777,
391938,
391949,
375569,
375572,
375575,
375580,
162592,
334633,
326444,
383794,
326452,
326455,
375613,
244542,
260925,
375616,
326468,
244552,
342857,
326474,
326479,
326486,
416599,
342875,
244572,
326494,
326503,
433001,
326508,
400238,
326511,
211826,
211832,
392061,
351102,
252801,
260993,
400260,
211846,
342931,
400279,
252823,
392092,
400286,
359335,
211885,
400307,
351169,
359362,
351172,
170950,
359367,
326599,
187335,
359383,
359389,
383968,
343018,
359411,
261109,
261112,
244728,
383999,
261130,
261148,
359452,
211999,
261155,
261160,
261166,
359471,
375868,
384099,
384102,
384108,
367724,
326764,
187503,
343155,
384115,
212095,
384136,
384140,
384144,
351382,
384152,
384158,
384161,
351399,
384169,
367795,
244917,
384182,
384189,
351424,
384192,
343232,
244934,
367817,
244938,
384202,
253132,
326858,
343246,
384209,
146644,
351450,
384225,
359650,
343272,
351467,
359660,
384247,
351480,
384250,
351483,
351492,
343307,
384270,
261391,
359695,
253202,
261395,
384276,
384284,
245021,
384290,
253218,
245032,
171304,
384299,
351535,
245042,
326970,
384324,
343366,
212296,
212304,
367966,
343394,
343399,
367981,
343410,
155000,
327035,
245121,
245128,
253321,
155021,
384398,
245137,
245143,
245146,
245149,
343453,
245152,
245155,
155045,
245158,
40358,
245163,
114093,
327090,
343478,
359867,
384444,
146878,
327108,
327112,
384457,
327118,
359887,
359891,
343509,
368093,
155103,
343535,
343540,
368120,
343545,
409092,
359948,
359951,
245295,
359984,
400977,
400982,
179803,
155241,
138865,
155255,
155274,
368289,
245410,
245415,
425652,
425663,
155328,
245463,
155352,
155356,
212700,
155364,
245477,
155372,
245487,
212723,
245495,
409336,
155394,
155404,
245528,
155423,
360224,
155439,
204592,
155444,
155448,
417596,
384829,
360262,
155463,
155477,
376665,
155484,
261982,
425823,
376672,
155488,
155492,
327532,
261997,
376686,
262000,
262003,
327542,
147319,
262006,
262009,
425846,
262012,
155517,
155523,
155526,
360327,
376715,
155532,
262028,
262031,
262034,
262037,
262040,
262043,
155550,
253854,
262046,
262049,
262052,
327590,
155560,
155563,
155566,
327613,
393152,
311244,
212945,
393170,
155604,
155620,
253924,
155622,
327655,
253927,
360432,
393204,
360439,
253944,
393209,
393215
] |
68df3d01fe09d3b67b522f74308ca2c5daed9646 | 11599a41c7fe681ae235348d3496d921c9a4b4ff | /Susi/Model/Client/Constants.swift | 04bb3d5e94ab35dda74000252903ed086e25a987 | [
"Apache-2.0"
] | permissive | coltonlemmon/susi_iOS | 47bb14f96ec74e605ac0e42a3492610743509bf1 | fc6e06e3df10b11171bfae623be7902e4789dedf | refs/heads/master | 2020-08-06T08:45:23.925512 | 2019-07-07T00:29:20 | 2019-07-07T00:29:19 | 212,912,094 | 0 | 0 | Apache-2.0 | 2019-10-04T22:29:09 | 2019-10-04T22:29:09 | null | UTF-8 | Swift | false | false | 8,485 | swift | //
// Constants.swift
// Susi
//
// Created by Chashmeet Singh on 31/01/17.
// Copyright © 2017 FOSSAsia. All rights reserved.
//
extension Client {
struct APIURLs {
static let SusiAPI = "https://api.susi.ai"
static let DuckDuckGo = "http://api.duckduckgo.com"
static let YoutubeSearch = "https://www.googleapis.com/youtube/v3/search"
static let SnowboyTrain = "https://snowboy.kitt.ai/api/v1/train/"
static let SpeakerBaseURL = "http://10.0.0.1:5000"
static let SkillURL = "https://skills.susi.ai"
}
struct Methods {
static let Login = "/aaa/login.json"
static let Register = "/aaa/signup.json"
static let Chat = "/susi/chat.json"
static let RecoverPassword = "/aaa/recoverpassword.json"
static let Memory = "/susi/memory.json"
static let UserSettings = "/aaa/changeUserSettings.json"
static let ListUserSettings = "/aaa/listUserSettings.json"
static let SendFeedback = "/cms/rateSkill.json"
static let ChangePassword = "/aaa/changepassword.json"
static let GetGroups = "/cms/getGroups.json"
static let GetSkillList = "/cms/getSkillList.json"
static let FiveStarRateSkill = "/cms/fiveStarRateSkill.json"
static let GetRatingByUser = "/cms/getRatingByUser.json"
static let FeedbackSkill = "/cms/feedbackSkill.json"
static let GetSkillFeedback = "/cms/getSkillFeedback.json"
static let baseSkillImagePath = "/cms/getImage.png"
static let FeedbackLog = "/cms/feedbackLog.json"
static let WifiCredentials = "/wifi_credentials"
static let Auth = "/auth"
static let Config = "/config"
static let SpeakerConfig = "/speaker_config"
static let CheckRegistration = "/aaa/checkRegistration.json"
static let ReportSkill = "/cms/reportSkill.json"
static let GetLanguages = "/cms/getAllLanguages.json"
static let ResendVerificationLink = "/aaa/resendVerificationLink.json"
static let GetUserAvatar = "/getAvatar.png"
static let BookmarkSkill = "/cms/bookmarkSkill.json"
}
struct ResponseMessages {
static let InvalidParams = "Email ID / Password incorrect"
static let ServerError = "Problem connecting to server!"
static let SignedOut = "Successfully logged out"
static let PasswordInvalid = "Password chosen is invalid."
static let NoSkillsPresent = "No skills present."
static let NoRatingsPresent = "No ratings present."
static let NotSubmittedRatings = "Problem submitting ratings"
static let SuccessSubmitRating = "Rating submitted successfully"
static let UserRatingNotFetched = "Problem fetching user rating"
static let SuccessUserRating = "Fetched user rating successfully"
static let SuccessPostFeedback = "Skill feedback updated"
static let UnablePostFeedback = "Problem posting skill feedback"
}
struct UserKeys {
static let AccessToken = "access_token"
static let Message = "message"
static let Login = "login"
static let SignUp = "signup"
static let Password = "password"
static let ForgotEmail = "forgotemail"
static let ValidSeconds = "valid_seconds"
static let EmailOfAccount = "changepassword"
static let NewPassword = "newpassword"
static let EmailExists = "exists"
static let CheckEmail = "check_email"
static let EmailID = "emailId"
}
struct ChatKeys {
static let Answers = "answers"
static let Query = "query"
static let TimeZoneOffset = "timezoneOffset"
static let AnswerDate = "answer_date"
static let ResponseType = "type"
static let Expression = "expression"
static let Actions = "actions"
static let Skills = "skills"
static let AccessToken = "access-token"
static let Latitude = "latitude"
static let Longitude = "longitude"
static let Zoom = "zoom"
static let Language = "language"
static let Data = "data"
static let Count = "count"
static let Title = "title"
static let Link = "link"
static let Description = "description"
static let Text = "text"
static let Columns = "columns"
static let QueryDate = "query_date"
static let ShortenedUrl = "finalUrl"
static let Image = "image"
static let Cognitions = "cognitions"
static let CountryName = "country_name"
static let CountryCode = "country_code"
static let deviceType = "device_type"
static let Identifier = "identifier"
}
struct WebsearchKeys {
static let RelatedTopics = "RelatedTopics"
static let Icon = "Icon"
static let Url = "URL"
static let FirstURL = "FirstURL"
static let Text = "Text"
static let Heading = "Heading"
static let Format = "format"
static let Query = "q"
static let Result = "Result"
}
struct YoutubeParamKeys {
static let Part = "part"
static let Query = "q"
static let Key = "key"
}
struct YoutubeParamValues {
static let Part = "snippet"
static let Key = "AIzaSyAx6TqPYDDL2VekgdEU-8kHHfplJSmqoTw"
}
struct YoutubeResponseKeys {
static let Items = "items"
static let ID = "id"
static let VideoID = "videoId"
}
struct WebSearch {
static let image = "no-image"
static let noData = "No data found"
static let duckDuckGo = "https://duckduckgo.com/"
static let noDescription = "No Description"
}
struct FeedbackKeys {
static let model = "model"
static let group = "group"
static let skill = "skill"
static let language = "language"
static let rating = "rating"
static let feedback = "feedback"
static let userQuery = "user_query"
static let susiReply = "susi_reply"
static let countryName = "country_name"
static let countryCode = "country_code"
static let deviceType = "device_type"
}
struct HotwordKeys {
static let name = "name"
static let token = "token"
static let microphone = "microphone"
static let language = "language"
static let voiceSamples = "voice_samples"
static let wave = "wave"
}
struct HotwordValues {
static let susi = "susi"
static let token = "1b286c615e95d848814144e6ffe0551505fe979c"
static let microphone = "iphone microphone"
static let language = "en"
}
struct SkillListing {
static let group = "group"
static let groups = "groups"
static let skills = "skills"
static let skill = "skill"
static let image = "image"
static let authorURL = "author_url"
static let examples = "examples"
static let author = "author"
static let skillName = "skill_name"
static let description = "descriptions"
static let model = "model"
static let language = "language"
static let dynamicContent = "dynamic_content"
static let skillRating = "skill_rating"
static let accessToken = "access_token"
static let feedback = "feedback"
static let staffPick = "staffPick"
static let lastModifiedTime = "lastModifiedTime"
static let bookmarkSkill = "bookmark"
}
struct FiveStarRating {
static let oneStar = "one_star"
static let twoStar = "two_star"
static let threeStar = "three_star"
static let fourStar = "four_star"
static let fiveSatr = "five_star"
static let totalStar = "total_star"
static let average = "avg_star"
static let positive = "positive"
static let negative = "negative"
static let stars = "stars"
static let ratings = "ratings"
static let AccessToken = "access_token"
}
struct SmartSpeaker {
static let wifiSSID = "wifissid"
static let wifiPassword = "wifipassd"
static let auth = "auth"
static let email = "email"
static let password = "password"
static let STT = "stt"
static let TTS = "tts"
static let hotword = "hotword"
static let wake = "wake"
static let roomName = "room_name"
}
}
| [
-1
] |
287143aa13e1c93274248674f77e73b82aee5b9b | 47d9ea2393e73ff46c5d5c6bfcf86892bad60d86 | /SJSegmentedScrollViewSample/AppDelegate.swift | 0df88bff0d26ca52a1b796283274db8357135471 | [] | no_license | dilipiOSDeveloper/SJSegmentedScrollViewSample | 1c99b301188fcce49b6ab8727e1b80a3d5f9c7cc | 689948fc1c27c8a3a05c814343f0bd5a82428598 | refs/heads/master | 2022-11-14T02:09:24.430029 | 2020-06-25T13:09:47 | 2020-06-25T13:09:47 | 139,723,102 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,094 | swift | //
// AppDelegate.swift
// SJSegmentedScrollViewSample
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> 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 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,
278542,
229391,
327695,
278545,
229394,
278548,
229397,
229399,
229402,
278556,
229405,
278559,
229408,
278564,
294950,
229415,
229417,
327722,
237613,
229422,
360496,
229426,
237618,
229428,
311349,
286774,
286776,
319544,
286778,
204856,
229432,
352318,
286791,
237640,
286797,
278605,
311375,
163920,
237646,
196692,
319573,
311383,
319590,
311400,
278635,
303212,
278639,
131192,
278648,
237693,
303230,
327814,
303241,
131209,
417930,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
131264,
286916,
286922,
286924,
286926,
319694,
286928,
131281,
278743,
278747,
295133,
155872,
319716,
237807,
303345,
286962,
303347,
131314,
229622,
327930,
278781,
278783,
278785,
237826,
319751,
278792,
286987,
319757,
311569,
286999,
319770,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
295220,
287032,
155966,
319809,
319810,
278849,
319814,
311623,
319818,
311628,
229709,
319822,
287054,
278865,
229717,
196963,
196969,
139638,
213367,
106872,
319872,
311683,
319879,
311693,
65943,
319898,
311719,
278952,
139689,
278957,
311728,
278967,
180668,
311741,
278975,
319938,
278980,
98756,
278983,
319945,
278986,
319947,
278990,
278994,
311767,
279003,
279006,
188895,
172512,
287202,
279010,
279015,
172520,
319978,
279020,
172526,
311791,
279023,
172529,
279027,
319989,
172534,
180727,
164343,
279035,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
303623,
172552,
320007,
287238,
279051,
172558,
279055,
303632,
279058,
303637,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
311850,
279084,
172591,
172598,
279095,
172607,
172609,
172612,
377413,
172614,
213575,
172618,
303690,
33357,
287309,
303696,
279124,
172634,
262752,
254563,
172644,
311911,
189034,
295533,
172655,
172656,
352880,
295538,
189039,
172660,
287349,
189040,
189044,
287355,
287360,
295553,
172675,
295557,
311942,
303751,
287365,
352905,
311946,
279178,
287371,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
172702,
287390,
303773,
172705,
287394,
172707,
303780,
164509,
287398,
205479,
279208,
287400,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
303804,
328381,
287423,
328384,
172737,
279231,
287427,
312005,
312006,
107208,
172748,
287436,
107212,
172751,
287440,
295633,
172755,
303827,
279255,
172760,
287450,
303835,
279258,
189149,
303838,
213724,
312035,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
189169,
205564,
303871,
230146,
328453,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
295720,
303914,
279340,
205613,
279353,
230202,
312124,
328508,
222018,
295755,
377676,
148302,
287569,
303959,
230237,
279390,
230241,
279394,
303976,
336744,
303981,
303985,
303987,
328563,
279413,
303991,
303997,
295806,
295808,
295813,
304005,
320391,
304007,
213895,
304009,
304011,
230284,
304013,
295822,
279438,
189329,
295825,
304019,
189331,
58262,
304023,
304027,
279452,
234648,
410526,
279461,
279462,
304042,
213931,
230327,
304055,
287675,
197564,
230334,
304063,
238528,
304065,
213954,
189378,
156612,
295873,
213963,
197580,
312272,
304084,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
312321,
295945,
230413,
295949,
197645,
320528,
140312,
295961,
238620,
197663,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
230465,
238658,
336964,
132165,
296004,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
361576,
205931,
296044,
279661,
205934,
164973,
312432,
279669,
337018,
189562,
279679,
304258,
279683,
222340,
66690,
205968,
296084,
238745,
304285,
238756,
205991,
222377,
165035,
337067,
238766,
165038,
230576,
238770,
304311,
230592,
312518,
279750,
230600,
230607,
148690,
320727,
279769,
304348,
279777,
304354,
296163,
320740,
279781,
304360,
320748,
279788,
279790,
304370,
296189,
320771,
312585,
296202,
296205,
230674,
320786,
230677,
296213,
296215,
320792,
230681,
230679,
214294,
304416,
230689,
173350,
312622,
296243,
312630,
222522,
296253,
222525,
296255,
312639,
230718,
296259,
378181,
296262,
230727,
238919,
296264,
320840,
296267,
296271,
222545,
230739,
312663,
222556,
337244,
230752,
312676,
230760,
173418,
148843,
410987,
230763,
230768,
296305,
312692,
230773,
304505,
304506,
181626,
181631,
148865,
312711,
312712,
296331,
288140,
288144,
230800,
304533,
337306,
288154,
288160,
173472,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
288176,
279985,
312755,
296373,
312759,
337335,
288185,
279991,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
288210,
370130,
288212,
222676,
148946,
288214,
239064,
329177,
288217,
280027,
288220,
288218,
239070,
288224,
280034,
288226,
280036,
288229,
280038,
288230,
288232,
370146,
320998,
288234,
288236,
288238,
288240,
288242,
296435,
288244,
288250,
296446,
321022,
402942,
148990,
296450,
206336,
230916,
230919,
214535,
230923,
304651,
304653,
370187,
230940,
222752,
108066,
296486,
296488,
157229,
230961,
157236,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
288344,
280152,
239194,
280158,
403039,
370272,
181854,
239202,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
419489,
190118,
198310,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
419522,
313027,
280260,
419525,
206536,
280264,
206539,
206541,
206543,
263888,
313044,
280276,
321239,
280283,
313052,
18140,
288478,
313055,
419555,
321252,
313066,
288494,
280302,
280304,
313073,
321266,
419570,
288499,
288502,
280314,
288510,
124671,
67330,
280324,
198405,
288519,
280331,
198416,
280337,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
280375,
321336,
296767,
288576,
345921,
280388,
304968,
280393,
280402,
173907,
313171,
313176,
280419,
321381,
296809,
296812,
313201,
1920,
255873,
305028,
280454,
247688,
280464,
124817,
280468,
239510,
280473,
124827,
214940,
247709,
214944,
280487,
313258,
321458,
296883,
124853,
214966,
296890,
10170,
288700,
296894,
190403,
296900,
280515,
337862,
165831,
280521,
231379,
296921,
354265,
354270,
239586,
313320,
354281,
231404,
124913,
165876,
321528,
239612,
313340,
288764,
239617,
313347,
288773,
313358,
305176,
321560,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
215090,
124980,
288824,
288826,
321595,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
288848,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
149599,
280671,
149601,
321634,
149603,
223327,
329830,
280681,
313451,
223341,
280687,
149618,
215154,
313458,
280691,
313464,
329850,
321659,
280702,
288895,
321670,
215175,
141446,
288909,
141455,
141459,
280725,
313498,
100520,
288936,
280747,
288940,
288947,
280755,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
157930,
280811,
280817,
125171,
157940,
280819,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
305464,
280891,
289087,
280897,
280900,
305480,
239944,
280906,
239947,
305485,
305489,
379218,
280919,
248153,
354653,
354656,
313700,
313705,
280937,
190832,
280946,
223606,
313720,
280956,
239997,
280959,
313731,
199051,
240011,
289166,
240017,
297363,
190868,
240021,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
289210,
305594,
281024,
289218,
289221,
289227,
281045,
281047,
215526,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
305668,
223749,
240132,
281095,
223752,
150025,
338440,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
281179,
338528,
338532,
281190,
199273,
281196,
19053,
158317,
313973,
297594,
281210,
158347,
264845,
133776,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
174764,
314029,
314033,
240309,
133817,
314045,
314047,
314051,
199364,
297671,
158409,
256716,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322314,
322318,
281361,
281372,
322341,
215850,
281388,
289593,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
158596,
183172,
338823,
322440,
314249,
240519,
183184,
289687,
240535,
297883,
289694,
289696,
289700,
289712,
281529,
289724,
52163,
183260,
281567,
289762,
322534,
297961,
183277,
281581,
322550,
134142,
322563,
314372,
330764,
175134,
322599,
322610,
314421,
281654,
314427,
314433,
207937,
314441,
207949,
322642,
314456,
281691,
314461,
281702,
281704,
314474,
281708,
281711,
289912,
248995,
306341,
306344,
306347,
322734,
306354,
142531,
199877,
289991,
306377,
289997,
249045,
363742,
363745,
298216,
330988,
126190,
216303,
322801,
388350,
257302,
363802,
199976,
199978,
314671,
298292,
298294,
257334,
216376,
380226,
298306,
224584,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314718,
265568,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
306549,
298358,
314743,
306552,
290171,
314747,
306555,
298365,
290174,
224641,
281987,
298372,
314756,
281990,
224647,
265604,
298377,
314763,
142733,
298381,
314768,
224657,
306581,
314773,
314779,
314785,
314793,
282025,
282027,
241068,
241070,
241072,
282034,
241077,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
282089,
191985,
282098,
290291,
282101,
241142,
191992,
290298,
151036,
290302,
282111,
290305,
175621,
306694,
192008,
323084,
257550,
290321,
282130,
323090,
290325,
282133,
241175,
290328,
282137,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290351,
290356,
28219,
282186,
224849,
282195,
282199,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
224875,
241260,
323181,
257658,
315016,
282249,
290445,
282261,
175770,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
306856,
282295,
323260,
282300,
323266,
282310,
323273,
282319,
306897,
241362,
306904,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
323349,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
241450,
282410,
306988,
306991,
315184,
323376,
315190,
241464,
159545,
282425,
298811,
118593,
307009,
413506,
307012,
241475,
298822,
315211,
282446,
307027,
315221,
323414,
315223,
241496,
241498,
307035,
307040,
110433,
282465,
241509,
110438,
298860,
110445,
282478,
315249,
110450,
315251,
282481,
315253,
315255,
339838,
315267,
282499,
315269,
241544,
282505,
241546,
241548,
298896,
298898,
282514,
241556,
298901,
44948,
241560,
282520,
241563,
241565,
241567,
241569,
282531,
241574,
282537,
298922,
36779,
241581,
282542,
241583,
323504,
241586,
282547,
241588,
290739,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241640,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
299003,
241661,
299006,
282623,
315396,
241669,
315397,
282632,
307211,
282639,
290835,
282645,
241693,
282654,
241701,
102438,
217127,
282669,
323630,
282681,
290877,
282687,
159811,
315463,
315466,
192589,
307278,
192596,
176213,
307287,
307290,
217179,
315482,
192605,
315483,
233567,
299105,
200801,
217188,
299109,
307303,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
323700,
299126,
233591,
299136,
307329,
315524,
307338,
233613,
241813,
307352,
299164,
241821,
299167,
315552,
184479,
184481,
315557,
184486,
307370,
307372,
184492,
307374,
307376,
299185,
323763,
184503,
176311,
299191,
307386,
258235,
307388,
307385,
307390,
176316,
299200,
184512,
307394,
299204,
307396,
184518,
307399,
323784,
233679,
307409,
307411,
176343,
299225,
233701,
307432,
184572,
282881,
184579,
282893,
323854,
291089,
282906,
291104,
233766,
295583,
176435,
307508,
315701,
332086,
307510,
307512,
168245,
307515,
307518,
282942,
282947,
323917,
110926,
282957,
233808,
323921,
315733,
323926,
233815,
315739,
323932,
299357,
242018,
242024,
299373,
315757,
250231,
242043,
315771,
299388,
299391,
291202,
299398,
242057,
291212,
299405,
291222,
315801,
283033,
242075,
291226,
194654,
61855,
291231,
283042,
291238,
291241,
127403,
127405,
291247,
299440,
127407,
299444,
127413,
283062,
291254,
127417,
291260,
283069,
127421,
127424,
299457,
127429,
127431,
127434,
315856,
176592,
127440,
315860,
176597,
127447,
283095,
299481,
127449,
176605,
242143,
127455,
127457,
291299,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
127490,
283142,
127494,
135689,
233994,
127497,
127500,
291341,
233998,
127506,
234003,
127509,
234006,
127511,
152087,
283161,
242202,
234010,
135707,
135710,
242206,
242208,
291361,
242220,
291378,
152118,
234038,
234041,
315961,
70213,
242250,
111193,
242275,
299620,
242279,
168562,
184952,
135805,
135808,
291456,
373383,
299655,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
225948,
135839,
299680,
225954,
299684,
135844,
242343,
209576,
242345,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
299726,
225998,
226002,
119509,
226005,
226008,
299740,
242396,
201444,
299750,
283368,
234219,
283372,
226037,
283382,
316151,
234231,
234236,
226045,
242431,
234239,
209665,
234242,
299778,
242436,
226053,
234246,
226056,
234248,
291593,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
348950,
201496,
234264,
234266,
234269,
283421,
234272,
234274,
152355,
299814,
234278,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
242499,
234309,
316233,
234313,
316235,
234316,
283468,
234319,
242511,
234321,
234324,
185173,
201557,
234329,
234333,
308063,
234336,
242530,
349027,
234338,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
234364,
291711,
234368,
291714,
234370,
291716,
234373,
316294,
201603,
226182,
308105,
234375,
324490,
226185,
234379,
234384,
234388,
234390,
324504,
234393,
209818,
308123,
324508,
234396,
291742,
226200,
234398,
234401,
291747,
291748,
234405,
291750,
234407,
324520,
324518,
324522,
234410,
291756,
291754,
226220,
324527,
291760,
234417,
201650,
324531,
234414,
234422,
226230,
324536,
275384,
234428,
291773,
242623,
324544,
234431,
234434,
324546,
324548,
234437,
226245,
234439,
226239,
234443,
291788,
234446,
275406,
193486,
234449,
316370,
193488,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
234487,
324599,
234490,
234493,
316416,
234496,
308226,
234501,
308231,
234504,
234507,
234510,
234515,
300054,
316439,
234520,
234519,
234523,
234526,
234528,
300066,
234532,
300069,
234535,
234537,
234540,
144430,
234543,
234546,
275508,
300085,
234549,
300088,
234553,
234556,
234558,
316479,
234561,
316483,
160835,
234563,
308291,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
242777,
234585,
275545,
234590,
234593,
234595,
234597,
300133,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
316530,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
226433,
234627,
275588,
234629,
242822,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
226453,
234647,
275606,
275608,
234650,
308379,
324757,
300189,
324766,
119967,
234653,
324768,
234657,
283805,
242852,
300197,
234661,
283813,
234664,
177318,
275626,
234667,
316596,
308414,
234687,
300223,
300226,
308418,
234692,
300229,
308420,
308422,
283844,
226500,
300234,
283850,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
234726,
300263,
300265,
300267,
161003,
300270,
300272,
120053,
300278,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
161027,
300292,
300294,
275719,
234760,
177419,
300299,
242957,
300301,
283917,
177424,
275725,
349451,
349464,
415009,
283939,
259367,
292143,
283951,
300344,
226617,
243003,
283963,
226628,
300357,
283973,
177482,
283983,
316758,
357722,
316766,
316768,
292192,
218464,
292197,
316774,
243046,
218473,
284010,
136562,
324978,
275834,
333178,
275836,
275840,
316803,
316806,
226696,
316811,
226699,
316814,
226703,
300433,
234899,
300436,
226709,
357783,
316824,
316826,
144796,
300448,
144807,
144810,
144812,
284076,
144814,
227426,
144820,
374196,
284084,
292279,
284087,
144826,
144828,
144830,
144832,
144835,
284099,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
292329,
300523,
259565,
300527,
308720,
259567,
292338,
226802,
316917,
292343,
308727,
300537,
316933,
316947,
308757,
308762,
284191,
316959,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
194101,
284213,
316983,
194103,
284215,
308790,
284218,
226877,
292414,
284223,
284226,
284228,
292421,
226886,
284231,
128584,
243268,
284234,
366155,
317004,
276043,
284238,
226895,
284241,
194130,
284243,
300628,
284245,
292433,
284247,
317015,
235097,
243290,
276053,
284249,
284251,
300638,
284253,
284255,
243293,
284258,
292452,
292454,
284263,
177766,
284265,
292458,
284267,
292461,
284272,
284274,
284278,
292470,
276086,
292473,
284283,
276093,
284286,
292479,
284288,
292481,
284290,
325250,
284292,
292485,
325251,
276095,
276098,
284297,
317066,
284299,
317068,
284301,
276109,
284303,
284306,
276114,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
284329,
317098,
284331,
276137,
284333,
284335,
276144,
284337,
284339,
300726,
284343,
284346,
284350,
358080,
276160,
284354,
358083,
284358,
276166,
358089,
284362,
276170,
284365,
276175,
284368,
276177,
284370,
358098,
284372,
317138,
284377,
276187,
284379,
284381,
284384,
358114,
284386,
358116,
276197,
317158,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
276206,
358128,
284399,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
284428,
300816,
300819,
317207,
284440,
300828,
300830,
276255,
300832,
325408,
300834,
317221,
227109,
358183,
186151,
276268,
300845,
243504,
300850,
284469,
276280,
325436,
358206,
276291,
366406,
276295,
300872,
292681,
153417,
358224,
284499,
276308,
284502,
317271,
178006,
276315,
292700,
317279,
284511,
227175,
292715,
300912,
292721,
284529,
300915,
284533,
292729,
317306,
284540,
292734,
325512,
169868,
276365,
317332,
358292,
284564,
284566,
399252,
350106,
284572,
276386,
284579,
276388,
358312,
317353,
284585,
276395,
292776,
292784,
276402,
358326,
161718,
358330,
276410,
276411,
276418,
276425,
301009,
301011,
301013,
292823,
358360,
301017,
301015,
292828,
276446,
153568,
276448,
276452,
292839,
276455,
292843,
276460,
276464,
178161,
227314,
276466,
325624,
276472,
317435,
276476,
276479,
276482,
276485,
317446,
276490,
350218,
292876,
350222,
317456,
276496,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
284739,
325700,
243779,
292934,
243785,
276553,
350293,
350295,
309337,
194649,
227418,
350299,
350302,
227423,
350304,
178273,
309346,
194657,
194660,
350308,
309350,
309348,
292968,
309352,
309354,
301163,
350313,
350316,
227430,
301167,
276583,
350321,
276590,
284786,
276595,
350325,
252022,
227440,
350328,
292985,
301178,
350332,
292989,
301185,
292993,
350339,
317570,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
276638,
284837,
153765,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
301258,
309450,
276685,
309455,
276689,
309462,
301272,
276699,
194780,
309468,
309471,
301283,
317672,
317674,
325867,
243948,
194801,
309491,
227571,
309494,
243960,
276735,
227583,
227587,
276739,
211204,
276742,
227593,
227596,
325910,
309530,
342298,
211232,
317729,
276775,
211241,
325937,
325943,
211260,
260421,
276809,
285002,
276811,
235853,
276816,
235858,
276829,
276833,
391523,
276836,
293227,
276843,
293232,
276848,
186744,
211324,
227709,
285061,
366983,
317833,
178572,
285070,
285077,
178583,
227738,
317853,
276896,
317858,
342434,
285093,
317864,
285098,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
293325,
317910,
293336,
235996,
317917,
293343,
358880,
276961,
227810,
293346,
276964,
293352,
236013,
293364,
301562,
293370,
317951,
309764,
301575,
121352,
293387,
236043,
342541,
317963,
113167,
55822,
309779,
317971,
309781,
277011,
55837,
227877,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
219714,
129603,
301636,
318020,
301639,
301643,
277071,
285265,
399955,
309844,
277080,
309849,
285277,
285282,
326244,
318055,
277100,
309871,
121458,
277106,
170618,
170619,
309885,
309888,
277122,
227975,
277128,
285320,
301706,
318092,
326285,
334476,
318094,
277136,
277139,
227992,
318108,
285340,
318110,
227998,
137889,
383658,
285357,
318128,
277170,
293555,
318132,
342707,
154292,
277173,
285368,
277177,
277181,
318144,
277187,
277191,
277194,
277196,
277201,
342745,
137946,
342747,
342749,
113378,
203491,
228069,
277223,
342760,
285417,
56041,
56043,
277232,
228081,
56059,
310015,
285441,
310020,
285448,
310029,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
318253,
293677,
285489,
301876,
293685,
285494,
301880,
285499,
301884,
310080,
293696,
277317,
277322,
293706,
277329,
162643,
310100,
301911,
277337,
301913,
301921,
400236,
236397,
162671,
326514,
310134,
236408,
15224,
277368,
416639,
416640,
113538,
310147,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
276579,
293811,
293817,
293820,
203715,
326603,
342994,
276586,
293849,
293861,
228327,
228328,
318442,
228330,
228332,
326638,
277486,
351217,
318450,
293876,
293877,
285686,
302073,
121850,
293882,
302075,
285690,
244731,
293887,
277504,
277507,
277511,
293899,
277519,
293908,
302105,
293917,
293939,
318516,
277561,
277564,
310336,
7232,
293956,
277573,
228422,
293960,
310344,
277577,
277583,
203857,
293971,
310355,
310359,
236632,
277594,
138332,
277598,
203872,
277601,
285792,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
367737,
285817,
302205,
285821,
392326,
285831,
253064,
294026,
302218,
285835,
162964,
384148,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
302258,
277687,
294072,
318651,
294076,
277695,
318657,
244930,
302275,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
310486,
302296,
384222,
310498,
285927,
318698,
302315,
195822,
228592,
294132,
138485,
228601,
204026,
228606,
204031,
64768,
310531,
285958,
138505,
228617,
318742,
204067,
277798,
130345,
277801,
113964,
285997,
277804,
285999,
277807,
113969,
277811,
318773,
318776,
277816,
286010,
277819,
294204,
417086,
277822,
286016,
302403,
294211,
384328,
277832,
277836,
294221,
294223,
326991,
277839,
277842,
277847,
277850,
179547,
277853,
146784,
277857,
302436,
277860,
294246,
327015,
310632,
327017,
351594,
277864,
277869,
277872,
351607,
310648,
277880,
310651,
277884,
277888,
310657,
351619,
294276,
310659,
327046,
277892,
253320,
310665,
318858,
277894,
277898,
277903,
310672,
351633,
277905,
277908,
277917,
310689,
277921,
130468,
228776,
277928,
277932,
310703,
277937,
310710,
130486,
310712,
277944,
310715,
277947,
302526,
228799,
277950,
277953,
302534,
310727,
245191,
64966,
163272,
277959,
277963,
302541,
277966,
302543,
310737,
277971,
228825,
163290,
277978,
310749,
277981,
277984,
310755,
277989,
277991,
187880,
277995,
310764,
286188,
278000,
228851,
310772,
278003,
278006,
40440,
212472,
278009,
40443,
286203,
310780,
40448,
228864,
286214,
228871,
302603,
65038,
302614,
302617,
286233,
302621,
286240,
146977,
187939,
40484,
294435,
40486,
286246,
294440,
40488,
294439,
294443,
40491,
294445,
278057,
310831,
245288,
286248,
40499,
40502,
212538,
40507,
40511,
40513,
228933,
327240,
40521,
286283,
40525,
40527,
212560,
400976,
228944,
40533,
147032,
40537,
40539,
40541,
278109,
40544,
40548,
40550,
40552,
286312,
40554,
286313,
310892,
40557,
40560,
188022,
122488,
294521,
343679,
294537,
310925,
286354,
278163,
302740,
122517,
278168,
179870,
327333,
229030,
212648,
278188,
302764,
278192,
319153,
278196,
302781,
319171,
302789,
294599,
278216,
294601,
302793,
343757,
212690,
319187,
286420,
278227,
229076,
286425,
319194,
278235,
278238,
229086,
286432,
294625,
294634,
302838,
319226,
286460,
278274,
302852,
278277,
302854,
294664,
311048,
352008,
319243,
311053,
302862,
319251,
294682,
278306,
188199,
294701,
319280,
278320,
319290,
229192,
302925,
188247,
280021,
188252,
237409,
294776,
360317,
294785,
327554,
360322,
40840,
40851,
294803,
188312,
294811,
237470,
319390,
40865,
319394,
294817,
294821,
311209,
180142,
343983,
294831,
188340,
40886,
319419,
294844,
294847,
237508,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
311283,
278516,
278519,
237562
] |
bf0fa59e120e658c969f1847a2ed903a6eef3301 | ed18f373710c7ee099445f741d2af7d801a830bc | /SnapchatClone/AppDelegate.swift | 000ac3254db7addf3237d7ee54a62db37564cf58 | [] | no_license | Denismih/SnapchatClone | ae9c792ac508fead3a87f53d115283aeda2d5b6d | 0bd7fedfab182937cb6e4dc48ece5f8e55ecc9df | refs/heads/master | 2020-03-23T22:02:10.047091 | 2018-08-02T08:37:46 | 2018-08-02T08:37:46 | 142,148,856 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,216 | swift | //
// AppDelegate.swift
// SnapchatClone
//
// Created by Admin on 24.07.2018.
// Copyright © 2018 Admin. All rights reserved.
//
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: 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,
229388,
229391,
327695,
229394,
229397,
229399,
229402,
278556,
229405,
229408,
229415,
229417,
237613,
229422,
360496,
229426,
237618,
229428,
286774,
319544,
204856,
229432,
286776,
286778,
286791,
237640,
286797,
278605,
311375,
196692,
319573,
311383,
319590,
278635,
303212,
278639,
131192,
237693,
303230,
327814,
131209,
303241,
417930,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
286916,
286922,
286924,
286926,
131278,
286928,
131281,
278747,
295133,
155872,
131299,
319716,
237807,
303345,
286962,
303347,
229622,
327930,
278781,
278783,
278785,
237826,
319751,
286987,
311569,
286999,
319770,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
155966,
319809,
319810,
278849,
319814,
311623,
319818,
311628,
229709,
319822,
287054,
278865,
229717,
196969,
139638,
213367,
106872,
319872,
311683,
311693,
65943,
319898,
319903,
311719,
278952,
139689,
278957,
278967,
180668,
311741,
278975,
319938,
278980,
278983,
319945,
278986,
278990,
278994,
311767,
279003,
279006,
188895,
287202,
279010,
279015,
172520,
319978,
279020,
311791,
279023,
172529,
279027,
319989,
180727,
164343,
279035,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
303623,
320007,
287238,
172552,
279051,
172558,
279055,
303632,
279058,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
279084,
172591,
172598,
172607,
172609,
172612,
377413,
172614,
213575,
172618,
303690,
33357,
279124,
172634,
262752,
172644,
311911,
189034,
172655,
172656,
352880,
189039,
189040,
172660,
295538,
189044,
287349,
287355,
287360,
295553,
295557,
311942,
303751,
287365,
352905,
311946,
287371,
279178,
311951,
287377,
172691,
287381,
311957,
221850,
230045,
287390,
303773,
172702,
172705,
287394,
172707,
303780,
164509,
287398,
295583,
287400,
279208,
172714,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
303804,
328381,
287423,
328384,
279231,
287427,
312006,
107208,
107212,
172748,
287436,
172751,
287440,
295633,
172755,
303827,
279255,
287450,
303835,
279258,
189149,
303838,
213724,
279267,
295654,
279272,
312048,
230128,
312050,
230131,
205564,
303871,
230146,
328453,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
279340,
279353,
230202,
312124,
328508,
222018,
295755,
148302,
287569,
303959,
230237,
279390,
230241,
303976,
336744,
303981,
303985,
303987,
328563,
303991,
303997,
295808,
304005,
304007,
320391,
304009,
213895,
304011,
304013,
279438,
295822,
189329,
295825,
189331,
304019,
58262,
304023,
279452,
279461,
279462,
304042,
213931,
304055,
230327,
287675,
197564,
304063,
238528,
304065,
213954,
189378,
156612,
197580,
312272,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
295945,
197645,
230413,
320528,
140312,
238620,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
230465,
238658,
296004,
132165,
336964,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
361576,
296040,
205931,
296044,
164973,
205934,
312432,
337018,
189562,
115836,
279679,
279683,
222340,
205968,
296084,
238745,
304285,
238756,
205991,
222377,
165035,
165038,
238766,
230576,
238770,
304311,
230592,
312518,
279750,
230600,
148690,
304348,
304354,
296163,
320740,
304360,
320748,
279788,
279790,
304370,
296189,
320771,
312585,
296202,
296205,
230674,
320786,
230677,
214294,
296215,
320792,
230681,
296213,
304416,
230689,
173350,
312622,
296243,
312630,
222522,
296253,
230718,
296255,
312639,
222525,
296259,
296262,
238919,
296264,
320840,
230727,
296267,
296271,
222545,
312663,
337244,
222556,
230752,
312676,
230760,
173418,
410987,
230763,
230768,
296305,
312692,
230773,
304505,
181626,
304506,
181631,
312711,
312712,
296331,
288140,
288144,
230800,
304533,
337306,
173472,
288160,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
288176,
279985,
312755,
312759,
337335,
288185,
279991,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
288210,
370130,
222676,
280021,
288212,
288214,
239064,
329177,
288217,
288218,
280027,
288220,
239070,
288224,
288226,
370146,
280036,
288229,
280038,
288230,
288232,
288234,
288236,
288238,
288240,
288242,
296435,
288244,
288250,
148990,
321022,
206336,
402942,
296450,
230916,
230919,
304651,
370187,
304653,
230940,
222752,
108066,
296488,
239152,
230961,
288320,
288325,
124489,
288338,
280149,
280152,
288344,
239194,
280158,
403039,
370272,
312938,
280183,
116354,
280222,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
313027,
280260,
206536,
280264,
206539,
206541,
206543,
280276,
321239,
280283,
18140,
288478,
313055,
321252,
313066,
280302,
288494,
313073,
419570,
288499,
321266,
288502,
288510,
124671,
67330,
280324,
280331,
198416,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
280375,
321336,
288576,
345921,
280388,
304968,
280402,
173907,
313176,
321381,
296812,
313201,
1920,
255873,
305028,
247688,
124817,
280468,
239510,
280473,
124827,
214940,
247709,
214944,
313258,
321458,
296883,
124853,
10170,
296890,
288700,
296894,
190403,
280515,
296900,
337862,
165831,
231379,
296921,
239586,
313320,
231404,
124913,
165876,
321528,
313340,
239612,
288764,
239617,
313347,
288773,
313358,
305176,
321560,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
215090,
124980,
288824,
288826,
321595,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
149599,
280671,
149601,
321634,
149603,
223327,
280681,
223341,
280687,
215154,
313458,
280691,
313464,
321659,
288895,
321670,
215175,
288909,
141455,
280725,
313498,
275608,
100520,
280747,
288940,
280755,
288947,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
321740,
313548,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
280811,
280817,
125171,
157940,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
280891,
280897,
280900,
239944,
305480,
280906,
239947,
305485,
305489,
280919,
354653,
313700,
313705,
280937,
190832,
280946,
313720,
280956,
280959,
313731,
240011,
199051,
289166,
240017,
297363,
240021,
297365,
297368,
297372,
141725,
297377,
289186,
289201,
240052,
289207,
305594,
289210,
281024,
289218,
289227,
281047,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
240132,
223749,
305668,
281095,
223752,
338440,
223757,
281102,
223763,
223765,
322074,
281127,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
338532,
199273,
158317,
313973,
297594,
281210,
158347,
133776,
240275,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
174764,
314029,
314033,
240309,
133817,
314047,
314051,
199364,
297671,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
322310,
264969,
322314,
322318,
281361,
281372,
322341,
215850,
281388,
289593,
281401,
289601,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
174955,
224110,
207733,
207737,
158596,
183172,
338823,
322440,
314249,
183184,
240535,
297883,
289694,
289700,
289712,
281529,
289724,
183260,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
314372,
322599,
322610,
314421,
281654,
314427,
314433,
207937,
322642,
314456,
281691,
314461,
281702,
281704,
281711,
248995,
306341,
306344,
306347,
322734,
306354,
142531,
199877,
289991,
306377,
249045,
363742,
363745,
298216,
216303,
322801,
388350,
363802,
199976,
199978,
314671,
298292,
298294,
216376,
380226,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314718,
265568,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
306549,
314743,
306552,
306555,
314747,
298365,
290171,
290174,
224641,
281987,
314756,
298372,
281990,
224647,
298377,
314763,
314768,
224657,
306581,
314773,
314779,
314785,
314793,
282025,
282027,
241068,
241070,
241072,
282034,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
282089,
191985,
282098,
282101,
241142,
191992,
290298,
151036,
290302,
290305,
192008,
323084,
290321,
282133,
290325,
241175,
290328,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290356,
28219,
282186,
282195,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
224875,
241260,
257658,
315016,
282249,
290445,
282261,
298651,
323229,
282269,
298655,
61092,
282277,
323260,
282300,
323266,
282310,
282319,
306897,
241362,
306904,
298714,
52959,
282337,
241380,
216806,
323304,
282345,
12011,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
241450,
282410,
306988,
315184,
323376,
315190,
241464,
159545,
282425,
298811,
307009,
413506,
307012,
298822,
315211,
307027,
315221,
315223,
241496,
241498,
307035,
307040,
110433,
282465,
241509,
110438,
298860,
110445,
282478,
315249,
315253,
315255,
339838,
315267,
315269,
241544,
282505,
241546,
241548,
298896,
298898,
282514,
241556,
298901,
241560,
282520,
241563,
241565,
241567,
241569,
241574,
298922,
241581,
241583,
323504,
241586,
282547,
241588,
241590,
241592,
241598,
290751,
241600,
241605,
241610,
298975,
241632,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
241661,
299006,
282623,
315396,
241669,
315397,
282632,
282639,
282645,
241693,
241701,
102438,
217127,
282669,
323630,
282681,
282687,
159811,
315463,
315466,
192589,
307278,
307287,
315482,
217179,
315483,
192605,
200801,
217188,
299109,
307303,
315495,
356457,
307307,
45163,
315502,
192624,
307314,
323700,
307329,
315524,
307338,
233613,
241813,
307352,
299164,
241821,
184479,
299167,
184481,
315557,
307370,
307372,
307374,
307376,
299185,
323763,
176311,
184503,
307385,
307386,
258235,
307388,
176316,
307390,
299200,
307394,
307396,
299204,
184518,
307399,
323784,
307409,
307411,
233701,
307432,
282881,
282893,
323854,
291089,
282906,
291104,
233766,
307508,
315701,
332086,
307510,
307512,
307515,
307518,
282942,
282947,
323917,
110926,
282957,
233808,
323921,
315733,
323926,
233815,
315739,
323932,
299357,
242018,
242024,
299373,
315757,
250231,
315771,
242043,
299391,
291202,
299398,
242057,
291222,
315801,
291226,
242075,
291231,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
299440,
299444,
127413,
283062,
291254,
194660,
127417,
291260,
127421,
127424,
299457,
127431,
315856,
176592,
315860,
176597,
283095,
127447,
176605,
242143,
291299,
242152,
291305,
127466,
176620,
127474,
291314,
291317,
135672,
233979,
291323,
291330,
283142,
135689,
233994,
127497,
127506,
234003,
234006,
127511,
152087,
283161,
242202,
135707,
234010,
135710,
242206,
242208,
291378,
152118,
234038,
70213,
242250,
111193,
242275,
299620,
242279,
184952,
135805,
135808,
299655,
373383,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
135839,
299680,
225954,
135844,
242343,
209576,
242345,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
225998,
299726,
226002,
119509,
226005,
201444,
283368,
234219,
283372,
226037,
283382,
316151,
234231,
234236,
226045,
242431,
234239,
209665,
234242,
299778,
242436,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
242450,
234258,
242452,
234261,
348950,
201496,
234264,
234266,
234269,
283421,
234272,
234274,
152355,
234278,
283432,
234281,
234284,
234287,
283440,
185138,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
234309,
316233,
234313,
316235,
234316,
283468,
242511,
234319,
234321,
234324,
201557,
185173,
234333,
308063,
234336,
234338,
349027,
242530,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
234356,
234358,
234362,
234364,
234368,
234370,
234373,
316294,
226182,
234375,
308105,
226185,
234379,
234384,
234390,
324504,
234393,
209818,
308123,
324508,
226200,
234396,
291742,
234401,
291747,
291748,
234405,
291750,
324518,
324520,
234407,
234410,
291754,
291756,
324522,
226220,
324527,
291760,
234417,
201650,
324531,
234422,
226230,
324536,
275384,
234428,
291773,
234431,
242623,
324544,
324546,
234434,
324548,
234437,
226245,
234443,
291788,
234446,
275406,
234449,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
324599,
234487,
234490,
234493,
234496,
316416,
234501,
308231,
234504,
234507,
234510,
234515,
234519,
234520,
316439,
234528,
300066,
234532,
300069,
234535,
234537,
234540,
234546,
275508,
234549,
300085,
300088,
234556,
234558,
316479,
234561,
308291,
316483,
234563,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
234590,
234593,
234595,
234597,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
234627,
275588,
234629,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
324757,
234647,
226453,
275606,
234650,
308379,
234648,
234653,
300189,
119967,
324766,
324768,
283805,
234657,
242852,
234661,
283813,
300197,
234664,
275626,
234667,
308414,
300223,
234687,
300226,
308418,
283844,
300229,
308420,
308422,
283850,
300234,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
234726,
300263,
300265,
300267,
300270,
300272,
120053,
300278,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
300292,
300294,
275719,
234760,
177419,
300299,
242957,
275725,
283917,
177424,
300301,
349464,
283939,
259367,
283951,
292143,
300344,
243003,
283963,
283973,
300357,
283983,
316758,
357722,
316766,
316768,
218464,
292197,
316774,
218473,
324978,
136562,
275834,
275836,
275840,
316803,
316806,
316811,
316814,
226703,
300433,
234899,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
284076,
144814,
144820,
374196,
284087,
292279,
144826,
144830,
144832,
144835,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
300523,
259565,
259567,
308720,
300527,
292338,
226802,
316917,
292343,
308727,
300537,
300543,
316933,
316947,
308757,
284191,
284194,
284196,
235045,
284199,
235047,
284204,
284206,
284209,
284211,
284213,
308790,
284215,
316983,
194103,
284218,
226877,
284226,
284228,
243268,
226886,
284231,
128584,
292421,
284234,
366155,
317004,
276043,
284238,
226895,
284241,
292433,
284243,
300628,
284245,
194130,
284247,
317015,
235097,
243290,
284249,
284251,
284253,
300638,
284255,
284258,
292452,
292454,
284263,
284265,
292458,
284267,
292461,
284272,
284274,
284278,
276086,
292470,
292473,
284283,
284286,
276095,
284288,
292479,
284290,
325250,
276098,
292485,
284292,
292481,
284297,
317066,
284299,
317068,
276109,
284301,
284303,
284306,
276114,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
284329,
317098,
284331,
276137,
284333,
284335,
276144,
284337,
284339,
300726,
284343,
284346,
284350,
358080,
276160,
284354,
358083,
284358,
276166,
358089,
284362,
284368,
284370,
358098,
284372,
317138,
284377,
284379,
284381,
284384,
358114,
284386,
358116,
317158,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
276206,
358128,
284399,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
284428,
300816,
300819,
317207,
300828,
300830,
276255,
325408,
300832,
300834,
317221,
227109,
358183,
276268,
300845,
243504,
300850,
284469,
276280,
325436,
358206,
366406,
276295,
153417,
358224,
276308,
178006,
317271,
284502,
276315,
317279,
292715,
300912,
284529,
292721,
300915,
292729,
317306,
284540,
292734,
325512,
358292,
284564,
317332,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
317353,
284585,
276395,
292784,
358326,
161718,
358330,
276411,
276418,
301009,
301011,
301013,
358360,
301017,
276446,
153568,
276448,
292839,
276455,
292843,
276460,
178161,
227314,
276466,
276472,
317435,
276476,
276479,
276482,
276485,
276490,
317456,
276496,
317458,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
284739,
325700,
292934,
243785,
350293,
350295,
309337,
194649,
350299,
227418,
350302,
194654,
227423,
178273,
309346,
227426,
309348,
350308,
309350,
276579,
309352,
350313,
309354,
301163,
350316,
292968,
276583,
301167,
276586,
350321,
276590,
227440,
284786,
350325,
276595,
350328,
292985,
292989,
301185,
317570,
350339,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
301258,
309450,
276685,
309455,
276689,
309462,
301272,
309468,
194780,
309471,
317672,
317674,
325867,
243948,
309491,
227571,
309494,
243960,
227583,
276735,
276739,
227596,
325910,
309530,
342298,
211232,
317729,
211241,
325937,
325943,
211260,
276809,
285002,
276811,
235853,
235858,
276829,
276833,
391523,
276836,
293232,
186744,
211324,
227709,
285061,
317833,
178572,
285070,
285077,
227738,
317853,
276896,
317858,
342434,
317864,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
317910,
293336,
317917,
293343,
358880,
276961,
293346,
276964,
293352,
236013,
301562,
317951,
309764,
301575,
121352,
236043,
342541,
113167,
309779,
317971,
309781,
277011,
236056,
227877,
227879,
293417,
227882,
309804,
293421,
236082,
23094,
277054,
219714,
129603,
318020,
301639,
301643,
285265,
399955,
309844,
277080,
309849,
318055,
277100,
309871,
121458,
170619,
309885,
309888,
277122,
277128,
301706,
318092,
326285,
334476,
318094,
277136,
277139,
227992,
318108,
318110,
227998,
137889,
383658,
318128,
277170,
293555,
318132,
154292,
277173,
342707,
277177,
277181,
318144,
277187,
277194,
277196,
277201,
137946,
113378,
277223,
342760,
285417,
56043,
277232,
228081,
56059,
310015,
285441,
310020,
310029,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
318253,
293677,
285489,
301876,
293685,
285494,
301880,
301884,
293696,
293706,
277322,
310100,
301911,
277337,
301913,
301921,
236397,
310134,
15224,
236408,
277368,
416639,
416640,
113538,
310147,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
277411,
310179,
293798,
236460,
277426,
293811,
293817,
293820,
203715,
326603,
293849,
293861,
228327,
318442,
228332,
326638,
277486,
318450,
293877,
285686,
302073,
285690,
244731,
293882,
302075,
293887,
277507,
277511,
293917,
293939,
318516,
310336,
293956,
277573,
228422,
310344,
293960,
277577,
277583,
203857,
293971,
310359,
236632,
277594,
277598,
203872,
285792,
277601,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
367737,
285817,
302205,
285821,
392326,
253064,
302218,
285835,
384148,
162964,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
302258,
277687,
294072,
318651,
294076,
277695,
318657,
244930,
302275,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
302296,
384222,
310498,
285927,
318698,
302315,
294132,
138485,
228601,
204026,
228606,
64768,
310531,
138505,
228617,
318742,
277798,
130345,
113964,
285997,
285999,
113969,
318773,
318776,
286010,
417086,
302403,
294211,
384328,
326991,
179547,
146784,
302436,
294246,
327015,
310632,
327017,
351594,
351607,
310648,
310651,
310657,
310659,
351619,
294276,
327046,
253320,
310665,
318858,
310672,
310689,
130468,
228776,
277932,
310703,
310710,
130486,
310712,
310715,
302526,
228799,
302534,
245191,
310727,
64966,
302541,
302543,
310737,
228825,
163290,
286169,
310749,
310755,
187880,
286188,
310764,
310772,
40440,
212472,
40443,
286203,
310780,
40448,
286214,
228871,
302603,
302614,
302617,
286233,
302621,
146977,
187939,
40484,
294435,
40486,
286246,
40488,
294439,
294440,
40491,
294443,
294445,
40499,
212538,
40507,
40511,
40513,
228933,
327240,
40521,
286283,
40525,
40527,
400976,
212560,
228944,
40533,
147032,
40537,
40539,
40541,
278109,
40544,
40548,
40550,
40552,
286312,
40554,
310892,
40557,
40560,
294521,
343679,
294537,
310925,
286354,
122517,
278168,
179870,
327333,
229030,
302764,
278188,
278192,
319153,
278196,
302781,
319171,
302789,
294599,
302793,
294601,
319187,
286420,
278227,
229076,
286425,
319194,
278235,
229086,
278238,
294625,
294634,
319226,
286460,
278274,
302852,
278277,
302854,
311048,
352008,
311053,
302862,
319251,
278306,
188199,
294701,
319280,
319290,
229192,
302925,
188247,
188252,
237409,
294776,
360317,
294785,
327554,
40851,
294811,
319390,
237470,
40865,
319394,
294817,
311209,
180142,
294831,
188340,
40886,
294844,
294847,
237508,
393177,
294876,
294879,
294890,
311279,
278513,
237555,
311283,
237562
] |
1b36f13e30c7d92e8fffa72900b202dd97bfcc1a | c9626afb6481354f0027ee277311fe872a55c224 | /Tests/NIOTests/SystemCallWrapperHelpers.swift | 2a7a1485336628fbaa3fc8cea3f9f31ce930111b | [
"BSD-3-Clause",
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | tanner0101/swift-nio | 0f7b5a57db87d1c285986b61db7f94fa8f0633ff | f44d524d562d942fc6aa510ebf7e0cf7ccb30ad7 | refs/heads/master | 2021-03-13T14:28:18.058230 | 2020-03-11T17:31:53 | 2020-03-11T17:31:53 | 246,688,393 | 1 | 0 | Apache-2.0 | 2020-03-11T22:01:08 | 2020-03-11T22:01:07 | null | UTF-8 | Swift | false | false | 4,471 | swift | //===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 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 Foundation
#if !RUNNING_INTEGRATION_TESTS
@testable import NIO
#endif
public func measureRunTime(_ body: () throws -> Int) rethrows -> TimeInterval {
func measureOne(_ body: () throws -> Int) rethrows -> TimeInterval {
let start = Date()
_ = try body()
let end = Date()
return end.timeIntervalSince(start)
}
_ = try measureOne(body)
var measurements = Array(repeating: 0.0, count: 10)
for i in 0..<10 {
measurements[i] = try measureOne(body)
}
//return measurements.reduce(0, +) / 10.0
return measurements.min()!
}
public func measureRunTimeAndPrint(desc: String, body: () throws -> Int) rethrows -> Void {
print("measuring: \(desc)")
print("\(try measureRunTime(body))s")
}
enum TestError: Error {
case writeFailed
case wouldBlock
}
func runStandalone() {
func assertFun(condition: @autoclosure () -> Bool, string: @autoclosure () -> String, file: StaticString, line: UInt) -> Void {
if !condition() {
fatalError(string(), file: file, line: line)
}
}
do {
try runSystemCallWrapperPerformanceTest(testAssertFunction: assertFun, debugModeAllowed: false)
} catch let e {
fatalError("Error thrown: \(e)")
}
}
func runSystemCallWrapperPerformanceTest(testAssertFunction: (@autoclosure () -> Bool, @autoclosure () -> String, StaticString, UInt) -> Void,
debugModeAllowed: Bool) throws {
let fd = open("/dev/null", O_WRONLY)
precondition(fd >= 0, "couldn't open /dev/null (\(errno))")
defer {
close(fd)
}
let isDebugMode = _isDebugAssertConfiguration()
if !debugModeAllowed && isDebugMode {
fatalError("running in debug mode, release mode required")
}
let iterations = isDebugMode ? 100_000 : 1_000_000
let pointer = UnsafePointer<UInt8>(bitPattern: 0xdeadbee)!
let directCallTime = try measureRunTime { () -> Int in
/* imitate what the system call wrappers do to have a fair comparison */
var preventCompilerOptimisation: Int = 0
for _ in 0..<iterations {
while true {
let r = write(fd, pointer, 0)
if r < 0 {
let saveErrno = errno
switch saveErrno {
case EINTR:
continue
case EWOULDBLOCK:
throw TestError.wouldBlock
case EBADF, EFAULT:
fatalError()
default:
throw TestError.writeFailed
}
} else {
preventCompilerOptimisation += r
break
}
}
}
return preventCompilerOptimisation
}
let withSystemCallWrappersTime = try measureRunTime { () -> Int in
var preventCompilerOptimisation: Int = 0
for _ in 0..<iterations {
switch try Posix.write(descriptor: fd, pointer: pointer, size: 0) {
case .processed(let v):
preventCompilerOptimisation += v
case .wouldBlock:
throw TestError.wouldBlock
}
}
return preventCompilerOptimisation
}
let allowedOverheadPercent: Int = isDebugMode ? 1000 : 20
if allowedOverheadPercent > 100 {
precondition(isDebugMode)
print("WARNING: Syscall wrapper test: Over 100% overhead allowed. Running in debug assert configuration which allows \(allowedOverheadPercent)% overhead :(. Consider running in Release mode.")
}
testAssertFunction(directCallTime * (1.0 + Double(allowedOverheadPercent)/100) > withSystemCallWrappersTime,
"Posix wrapper adds more than \(allowedOverheadPercent)% overhead (with wrapper: \(withSystemCallWrappersTime), without: \(directCallTime)",
#file, #line)
}
| [
-1
] |
b3ef39a40e728b8d48854a23e4f6a220ff15b3ee | 8717857a79c3bd03881c0ac9f20a216724e69d67 | /ToDoList/Scene/Detail/DetailView.swift | a1a9e47c120c93c287b74baa5024048b27260d04 | [] | no_license | talipboke/ToDoList | 1d2d3b7026d1b3ce50d5ddd0f1ef2c00f13f79b4 | 367fb825285d029b6c68f1878fa944cd62f02fe6 | refs/heads/main | 2023-04-16T00:15:50.213613 | 2021-04-29T18:41:35 | 2021-04-29T18:41:35 | 362,913,773 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,574 | swift | //
// DetailView.swift
// GetirTodo
//
// Created by Talip Böke on 20.04.2021.
//
import UIKit
internal final class DetailView: UIView {
internal lazy var titleLabel = makeTitleLabel()
internal lazy var titleTextField = makeTitleTextField()
internal lazy var contentLabel = makeContentLabel()
internal lazy var contentTextView = makeContentTextView()
internal override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
layoutViews()
}
internal required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
}
private extension DetailView {
func layoutViews() {
addSubview(titleLabel)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
titleLabel.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: UIDimension.Spacing.xlarge),
titleLabel.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: UIDimension.Spacing.medium)
])
addSubview(titleTextField)
titleTextField.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
titleTextField.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: UIDimension.Spacing.small),
titleTextField.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor),
titleTextField.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -UIDimension.Spacing.medium),
titleTextField.heightAnchor.constraint(equalToConstant: UIDimension.TextFieldHeight.medium)
])
addSubview(contentLabel)
contentLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentLabel.topAnchor.constraint(equalTo: titleTextField.bottomAnchor, constant: UIDimension.Spacing.large),
contentLabel.leadingAnchor.constraint(equalTo: titleTextField.leadingAnchor),
])
addSubview(contentTextView)
contentTextView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentTextView.topAnchor.constraint(equalTo: contentLabel.bottomAnchor, constant: UIDimension.Spacing.small),
contentTextView.leadingAnchor.constraint(equalTo: contentLabel.leadingAnchor),
contentTextView.trailingAnchor.constraint(equalTo: titleTextField.trailingAnchor),
contentTextView.heightAnchor.constraint(equalToConstant: UIDimension.TextViewHeight.small)
])
}
func makeTitleLabel() -> UILabel {
let label = UILabel()
label.text = AppConst.title.localize()
return label
}
func makeTitleTextField() -> UITextField {
let textField = UITextField()
textField.borderStyle = .roundedRect
return textField
}
func makeContentLabel() -> UILabel {
let label = UILabel()
label.text = AppConst.content.localize()
return label
}
func makeContentTextView() -> UITextView {
let textView = UITextView()
textView.allowsEditingTextAttributes = true
textView.backgroundColor = .clear
let borderColor = UIColor(red: 0.80, green: 0.80, blue: 0.80, alpha: 1.0)
textView.layer.borderWidth = 0.5
textView.layer.borderColor = borderColor.cgColor
textView.layer.cornerRadius = 5.0
return textView
}
}
| [
-1
] |
6a3e8d74c94606662fe04df76b2b89c8af53c0ce | a6b2e9547e86f2e8a5799b366e28b897e480e40d | /ServiceWorker/ServiceWorker/SQLite/SQLiteBlobWriteStream.swift | 8f46c74f0f6bed191b5ae082f3135c73bdf553bc | [
"MIT"
] | permissive | leixjin/SWWebView | 9a271f361e9791e356f9e8e690074f20f42776f9 | cab7bd6b0c7a6a5d9a610133f71f418322e42e0f | refs/heads/master | 2023-03-19T11:56:52.506376 | 2020-07-22T14:00:30 | 2020-07-22T14:00:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,252 | swift | import Foundation
import SQLite3
/// A bridge between the a Foundation OutputStream and the SQLite C API's blob functions. Important
/// to note that the SQLite streaming functions cannot change the size of a BLOB field. It must be
/// created in an INSERT or UPDATE query beforehand.
public class SQLiteBlobWriteStream: OutputStreamImplementation {
let dbPointer: SQLiteBlobStreamPointer
init(_ db: SQLiteConnection, table: String, column: String, row: Int64) {
self.dbPointer = SQLiteBlobStreamPointer(db, table: table, column: column, row: row, isWrite: true)
// Not sure why we have to call this initializer, but we'll do it with empty data
var empty = [UInt8]()
super.init(toBuffer: &empty, capacity: 0)
self.streamStatus = .notOpen
}
public override func open() {
do {
try self.dbPointer.open()
self.emitEvent(event: .openCompleted)
self.emitEvent(event: .hasSpaceAvailable)
} catch {
self.streamStatus = .error
self.streamError = error
}
}
public override var hasSpaceAvailable: Bool {
guard let state = self.dbPointer.openState else {
// As specified in docs: https://developer.apple.com/documentation/foundation/inputstream/1409410-hasbytesavailable
// both hasSpaceAvailable and hasBytesAvailable should return true when the actual state is unknown.
return true
}
return state.currentPosition < state.blobLength
}
public override func close() {
self.dbPointer.close()
self.streamStatus = .closed
}
public override func write(_ buffer: UnsafePointer<UInt8>, maxLength len: Int) -> Int {
do {
guard let state = self.dbPointer.openState else {
throw ErrorMessage("Cannot write to a stream that is not open")
}
self.streamStatus = .writing
let bytesLeft = state.blobLength - state.currentPosition
// Same as when reading, we don't want to write more data than the blob can hold
// so we cut it off if necessary - the streaming functions cannot change the size
// of a blob, only UPDATEs/INSERTs can.
let lengthToWrite = min(Int32(len), bytesLeft)
if sqlite3_blob_write(state.pointer, buffer, lengthToWrite, state.currentPosition) != SQLITE_OK {
guard let errMsg = sqlite3_errmsg(self.dbPointer.db.db) else {
throw ErrorMessage("SQLite failed, but can't get error")
}
let str = String(cString: errMsg)
throw ErrorMessage(str)
}
// Update the position we next want to write to
state.currentPosition += lengthToWrite
if state.currentPosition == state.blobLength {
self.streamStatus = .atEnd
self.emitEvent(event: .endEncountered)
} else {
self.streamStatus = .open
self.emitEvent(event: .hasSpaceAvailable)
}
return Int(lengthToWrite)
} catch {
self.throwError(error)
return -1
}
}
}
| [
-1
] |
0e4a000eb39c64bf50b17ef75bb2bdbc82376633 | 78f8dd0c498784f194c81312247adbb477335dfd | /RopossoChallenge/DetailViewController.swift | 33987308743006e54d7bf4fc40a76104b66d63ff | [] | no_license | crickabhi/RopossoChallenge | 60303a1f74d493fe4185aca6768a43768c88cd3b | ab57d82fa0e6c4f6d3ecb9425705de69a2ec8582 | refs/heads/master | 2020-07-03T18:48:38.527286 | 2017-02-16T15:10:00 | 2017-02-16T15:10:00 | 74,238,429 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 6,214 | swift | //
// DetailViewController.swift
// RopossoChallenge
//
// Created by Abhinav Mathur on 20/11/16.
// Copyright © 2016 Abhinav Mathur. All rights reserved.
//
import UIKit
class DetailViewController: UIViewController {
var userObjects = [AnyObject]()
var userName : UILabel!
var userImage : UIImageView!
var storyTitle : UILabel!
var storyImage : UIImageView!
var followButton : UIButton!
var userNameString : String?
var userImageUrlString : String?
var followStatus : Bool?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let gap : CGFloat = 10
let labelHeight: CGFloat = 80
let labelWidth: CGFloat = UIScreen.main.bounds.width - 20
let imageSize : CGFloat = UIScreen.main.bounds.height - 180
//view.backgroundColor = UIColor.brown
for i in 0 ..< userObjects.count
{
if self.detailItem?.value(forKey: "db")! as! String == userObjects[i].value(forKey: "id")! as! String
{
userNameString = userObjects[i].value(forKey: "username")! as? String
userImageUrlString = userObjects[i].value(forKey: "image")! as? String
let userDefaultsInfo = UserDefaults.standard
if userDefaultsInfo.value(forKey: "followedGroups") != nil
{
if (userDefaultsInfo.value(forKey: "followedGroups") as! Array<String>).contains(self.detailItem?.value(forKey: "db")! as! String)
{
followStatus = true
}
else
{
followStatus = false
}
}
else
{
followStatus = userObjects[i].value(forKey: "is_following")! as? Bool
}
}
}
userImage = UIImageView()
userImage.frame = CGRect(x: gap,y: 70, width: 44,height: 44)
userImage.sd_setImage(with: NSURL(string:(userImageUrlString)!)! as URL)
userImage.contentMode = .scaleAspectFit
userImage.layer.masksToBounds = true
userImage.layer.cornerRadius = 5
view.addSubview(userImage)
userName = UILabel()
userName.frame = CGRect(x: 75 , y: 40, width: labelWidth, height: labelHeight)
userName.textColor = UIColor.black
userName.font = UIFont(name: "HelveticaNeue", size: 16)
userName.text = userNameString!
view.addSubview(userName)
if followStatus == false
{
setupFollowButton()
}
else
{
setupFollowingButton()
}
storyTitle = UILabel()
storyTitle.frame = CGRect(x: gap, y: 100, width: labelWidth, height: labelHeight)
storyTitle.textColor = UIColor.black
storyTitle.numberOfLines = 3
storyTitle.lineBreakMode = NSLineBreakMode.byWordWrapping
if #available(iOS 8.2, *) {
storyTitle.font = UIFont.systemFont(ofSize: 14, weight: UIFontWeightSemibold)
} else {
storyTitle.font = UIFont(name: "HelveticaNeue", size: 14)
}
storyTitle.text = self.detailItem?.value(forKey: "title") as? String
storyTitle.numberOfLines = 0
view.addSubview(storyTitle)
storyImage = UIImageView()
storyImage.frame = CGRect(x: gap,y: 160, width: labelWidth,height: imageSize)
storyImage.sd_setImage(with: NSURL(string:(self.detailItem?.value(forKey: "si") as? String)!)! as URL)
storyImage.contentMode = .scaleToFill
view.addSubview(storyImage)
}
func setupFollowButton()
{
followButton = UIButton()
followButton.frame = CGRect(x:80,y: userName.frame.height + 12, width: 75,height: 30)
followButton.setTitle("Follow", for: .normal)
followButton.setTitleColor(UIColor.white, for: .normal)
followButton.isHidden = false
followButton.backgroundColor = UIColor.gray
followButton.layer.masksToBounds = true
followButton.layer.cornerRadius = 5
view.addSubview(followButton)
followButton.addTarget(self, action: #selector(DetailViewController.buttonAction(_:)), for: UIControlEvents.touchUpInside)
}
func setupFollowingButton()
{
followButton = UIButton()
followButton.frame = CGRect(x:80,y: userName.frame.height + 12, width: 100,height: 30)
followButton.setTitle("Following", for: .normal)
followButton.setTitleColor(UIColor.white, for: .normal)
followButton.isHidden = false
followButton.backgroundColor = UIColor.gray
followButton.layer.masksToBounds = true
followButton.layer.cornerRadius = 5
view.addSubview(followButton)
}
func buttonAction(_ sender: UIButton) {
followButton.setTitleColor(UIColor.blue, for: .normal)
let userDefaultsInfo = UserDefaults.standard
if userDefaultsInfo.value(forKey: "followedGroups") != nil
{
var followedGroups = userDefaultsInfo.value(forKey: "followedGroups") as! Array<String>
if followedGroups.contains(self.detailItem?.value(forKey: "db")! as! String)
{
}
else
{
followedGroups.append(self.detailItem?.value(forKey: "db")! as! String)
userDefaultsInfo.removeObject(forKey: "followedGroups")
userDefaultsInfo.set(followedGroups, forKey: "followedGroups")
}
}
else
{
userDefaultsInfo.set([self.detailItem?.value(forKey: "db")! as! String], forKey: "followedGroups")
}
setupFollowingButton()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
var detailItem: AnyObject? {
didSet {
// Update the view.
}
}
}
| [
-1
] |
7cbe0254ce1b75d51b903d788341452998494419 | 9c08e27ff7915423dd5b32542967ca3300b451bd | /Spendy/Transaction.swift | 584dee1b17260dc17c3451bb0d5578a8e5368955 | [
"MIT"
] | permissive | hoangdang1449/Spendy | 1a53db9ad24a071b1ecf9a38bfc9280eb0bb580e | ce86b2690263f41b9141b216e41992c0f6e084f2 | refs/heads/master | 2020-12-25T21:12:29.737759 | 2015-09-24T10:32:17 | 2015-09-24T10:32:17 | 43,114,985 | 1 | 0 | null | 2015-09-25T07:03:39 | 2015-09-25T07:03:39 | null | UTF-8 | Swift | false | false | 7,448 | swift | //
// Transaction.swift
// Spendy
//
// Created by Harley Trung on 9/18/15.
// Copyright (c) 2015 Cheetah. All rights reserved.
//
import Foundation
import Parse
/////////////////////////////////////////
//Schema:
//- kind (income | expense | transfer)
//- user_id
//- from_account
//- to_account (when type is ‘transfer’)
//- note
//- amount
//- category_id
//- date
/////////////////////////////////////////
var _allTransactions: [Transaction]?
// Note: I'm testing a different approach here compared to Account & Category
// which is not to inherit from PFObject and keep all Parse related communications private
// This makes it less buggy when working with Transaction from outside in
// (as long as we test Transaction carefully)
class Transaction: HTObject {
class var kinds: [String] {
return [expenseKind, incomeKind, transferKind]
}
static let expenseKind: String = "expense"
static let incomeKind: String = "income"
static let transferKind: String = "transfer"
var note: String?
var amount: NSDecimalNumber?
var categoryId: String?
var fromAccountId: String?
var toAccountId: String?
var date: NSDate?
var kind: String?
// TODO: change kind to enum .Expense, .Income, .Transfer
init(kind: String?, note: String?, amount: NSDecimalNumber?, category: Category?, account: Account?, date: NSDate?) {
super.init(parseClassName: "Transaction")
self["kind"] = kind
self["note"] = note
self["amount"] = amount
self["categoryId"] = category?.objectId
self["fromAccountId"] = account?.objectId
self["date"] = date
}
func setAccount(account: Account) {
self["fromAccountId"] = account.objectId
}
func setCategory(category: Category) {
self["categoryId"] = category.objectId
}
// MARK: - relations
// TODO: refactor logic to Account and Category
func account() -> Account? {
if (fromAccountId != nil) {
return Account.findById(fromAccountId!)
} else {
// attempt to use default account
if let account = Account.defaultAccount() {
print("account missing in transaction: setting defaultAccount for it", terminator: "\n")
setAccount(account)
return account
} else {
return nil
}
}
}
func category() -> Category? {
if categoryId != nil {
return Category.findById(categoryId!)
} else {
// attempt to use default account
if let category = Category.defaultCategory() {
print("category missing in transaction: setting defaultCategory for it", terminator: "\n")
setCategory(category)
return category
} else {
return nil
}
}
}
// MARK: - date formatter
static var dateFormatter = NSDateFormatter()
func dateToString(dateStyle: NSDateFormatterStyle? = nil, dateFormat: String? = nil) -> String? {
if let date = date {
if dateStyle != nil {
Transaction.dateFormatter.dateStyle = dateStyle!
}
if dateFormat != nil {
Transaction.dateFormatter.dateFormat = dateFormat!
}
return Transaction.dateFormatter.stringFromDate(date)
} else {
return nil
}
}
// Ex: September 21, 2015
func dateOnly() -> String? {
return dateToString(NSDateFormatterStyle.LongStyle)
}
// Ex: Thursday, 7 AM
func dayAndTime() -> String? {
return dateToString(dateFormat: "EEEE, h a")
}
func monthHeader() -> String? {
return dateToString(dateFormat: "MMMM YYYY")
}
// MARK: - unused
static var transactions: [PFObject]?
static func findAll(completion: (transactions: [PFObject]?, error: NSError?) -> ()) {
let query = PFQuery(className: "Transaction")
query.fromLocalDatastore()
query.findObjectsInBackgroundWithBlock { (results, error) -> Void in
if error != nil {
print("Error loading transactions", terminator: "\n")
completion(transactions: nil, error: error)
} else {
self.transactions = results
completion(transactions: self.transactions, error: error)
}
}
}
// MARK: - view helpers
func formattedAmount() -> String? {
if amount != nil {
return String(format: "$%.02f", amount!.doubleValue)
} else {
return nil
}
}
// MARK: - Utilities
class func all() -> [Transaction]? {
return _allTransactions
}
class func dictGroupedByMonth(trans: [Transaction]) -> [String: [Transaction]] {
var dict = [String:[Transaction]]()
for el in trans {
let key = el.monthHeader() ?? "Unknown"
dict[key] = (dict[key] ?? []) + [el]
}
return dict
}
class func listGroupedByMonth(trans: [Transaction]) -> [[Transaction]] {
let grouped = dictGroupedByMonth(trans)
var list: [[Transaction]] = []
for (key, _) in grouped {
var g:[Transaction] = grouped[key]!
// sort values in each bucket, newest first
g.sortInPlace({ $1.date! < $0.date! })
list.append(g)
}
// sort by month
list.sortInPlace({ $1[0].date! < $0[0].date! })
return list
}
class func loadAll() {
print("\n\nloading fake data for Transactions", terminator: "\n")
let defaultCategory = Category.all()?.first
let defaultAccount = Account.all()?.first
// Initialize with fake transactions
let dateFormatter = Transaction.dateFormatter
dateFormatter.dateFormat = "yyyy-MM-dd"
// TODO: load from and save to servers
_allTransactions =
[
Transaction(kind: Transaction.expenseKind, note: "Note 1", amount: 3.23, category: defaultCategory, account: defaultAccount, date: dateFormatter.dateFromString("2015-08-01")),
Transaction(kind: Transaction.expenseKind, note: "Note 2", amount: 4.23, category: defaultCategory, account: defaultAccount, date: dateFormatter.dateFromString("2015-08-02")),
Transaction(kind: Transaction.expenseKind, note: "Note 3", amount: 1.23, category: defaultCategory, account: defaultAccount, date: dateFormatter.dateFromString("2015-09-01")),
Transaction(kind: Transaction.expenseKind, note: "Note 4", amount: 2.23, category: defaultCategory, account: defaultAccount, date: dateFormatter.dateFromString("2015-09-02")),
Transaction(kind: Transaction.expenseKind, note: "Note 5", amount: 2.23, category: defaultCategory, account: defaultAccount, date: dateFormatter.dateFromString("2015-09-03"))
]
// println("post sort: \(_allTransactions!))")
}
class func add(element: Transaction) {
element.save()
_allTransactions!.append(element)
}
}
//extension Transaction: CustomStringConvertible {
// override var description: String {
// let base = super.description
// return "categoryId: \(categoryId), fromAccountId: \(fromAccountId), toAccountId: \(toAccountId), base: \(base)"
// }
//} | [
-1
] |
75854cd4ad9fc81396b8ef21ad62efbe2b8ecaf0 | c9fb2f7bee2bcc3516f5dbf906c9e425ca074d73 | /Dear Loa/UI/Scroll Views/StorefrontTableView.swift | fe0d1a54875f496f8e3de3c8e30424d7cec78d45 | [] | no_license | robowlet/dearloa | 1d2d6ef51a7497b24e60819464a7a08175b627aa | 654f892bbe824ff21cc50aba3b20c6a86e0de21f | refs/heads/master | 2020-03-24T18:08:34.842412 | 2018-10-11T17:48:57 | 2018-10-11T17:48:57 | 142,883,613 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,734 | swift | //
// StorefrontTableView.swift
// Dear Loa
//
// Created by Rob Miguel on 7/31/18.
// Copyright © 2018 robmgl. All rights reserved.
//
import UIKit
protocol StorefrontTableViewDelegate: class {
func tableViewShouldBeginPaging(_ table: StorefrontTableView) -> Bool
func tableViewWillBeginPaging(_ table: StorefrontTableView)
func tableViewDidCompletePaging(_ table: StorefrontTableView)
}
class StorefrontTableView: UITableView, Paginating {
@IBInspectable private dynamic var cellNibName: String?
weak var paginationDelegate: StorefrontTableViewDelegate?
var paginationThreshold: CGFloat = 500.0
var paginationState: PaginationState = .ready
var paginationDirection: PaginationDirection = .verical
// ----------------------------------
// MARK: - Awake -
//
override func awakeFromNib() {
super.awakeFromNib()
if let className = self.value(forKey: "cellNibName") as? String {
self.register(UINib(nibName: className, bundle: nil), forCellReuseIdentifier: className)
}
}
// ----------------------------------
// MARK: - Layout -
//
override func layoutSubviews() {
super.layoutSubviews()
self.trackPaging()
}
func shouldBeginPaging() -> Bool {
return self.paginationDelegate?.tableViewShouldBeginPaging(self) ?? false
}
func willBeginPaging() {
print("Paging table view...")
self.paginationDelegate?.tableViewWillBeginPaging(self)
}
func didCompletePaging() {
print("Finished paging table view.")
self.paginationDelegate?.tableViewDidCompletePaging(self)
}
}
| [
-1
] |
c5bdb58e549f1481319df9e703bd6ea76d327e5c | 279a3f0d73ede3bc90e62082710a0a5437840ad4 | /BudgetPlanner/FloatingMenu.swift | c6cb9590176c0580731f2457edce2815522b3c26 | [] | no_license | yuzhima98/Budget-Planner | d535d07b9e40e9eace6c0f93070e31be4bc4438b | 7aeeea569800303ca80923a28788c164f5912fea | refs/heads/master | 2023-08-13T11:55:21.524653 | 2021-09-18T07:51:55 | 2021-09-18T07:51:55 | 407,793,024 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,212 | swift | //
// FloatingMenu.swift
// BudgetPlanner
//
// Created by Yuzhi Ma on 12/8/19.
// Copyright © 2019 Yuzhi Ma. All rights reserved.
//
import SwiftUI
struct FloatingMenu: View {
//all menu items initialized as false so it doesn't show
@State var showMenuItem1 = false
@State var showMenuItem2 = false
@State var showMenuItem3 = false
var body: some View {
VStack {
Spacer()
//First menu item
if showMenuItem1 {
NavigationLink(destination: AddTransaction()) {
MenuItem(icon: "plus")
}
}
//Second menu item
if showMenuItem2 {
NavigationLink(destination: Setting()) {
MenuItem(icon: "pencil.circle.fill")
}
}
//third menu item
if showMenuItem3 {
NavigationLink(destination: Gadgets()) {
MenuItem(icon: "square.split.2x2")
}
}
//Button to show the menu
Button(action: {
//Click to show the menu
self.showMenu()
}) {
(showMenuItem1 ? Image(systemName: "chevron.down.circle.fill")
.resizable()
.frame(width: 50, height: 50)
.foregroundColor(.blue)
.shadow(color: .gray, radius: 0.2, x: 1, y: 1) : Image(systemName: "chevron.up.circle.fill")
.resizable()
.frame(width: 50, height: 50)
.foregroundColor(.blue)
.shadow(color: .gray, radius: 0.2, x: 1, y: 1))
}
}
}
func showMenu() {
//Show the menu item with animation
//MenuItem 3 will show immediately
withAnimation {
self.showMenuItem3.toggle()
}
//MenuItem 2 will show after menu item 3 with the DispatchQueue.main.asyncAfter
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
withAnimation {
self.showMenuItem2.toggle()
}
})
//MenuItem 1 will show after menu item 2 with the DispatchQueue.main.asyncAfter
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
withAnimation {
self.showMenuItem1.toggle()
}
})
}
}
struct FloatingMenu_Previews: PreviewProvider {
static var previews: some View {
FloatingMenu()
}
}
struct MenuItem: View {
//UI of the menu item
var icon: String
var body: some View {
ZStack {
Circle()
.foregroundColor(Color(red: 153/255, green: 102/255, blue: 255/255))
.frame(width: 55, height: 55)
Image(systemName: icon)
.imageScale(.large)
.foregroundColor(.white)
}
.shadow(color: .gray, radius: 0.2, x: 1, y: 1)
//Animation transition
.transition(.move(edge: .trailing))
}
}
| [
-1
] |
944a85423360cad79a826852f966a9eef8fa26a5 | 43e4dda7c98c8d9199e4bfad5c9cfc0477c97fa5 | /myFitness/Diary/Model/Diary.swift | 39d69ddc3427ee3db6863f98d9a599f6f6b7053d | [] | no_license | adong23664/myfitness | e3762bcc156bf736344728cb6f59dd6bc244fdd5 | c7df7b81cd781fc903782e7068b9db8acd2974ef | refs/heads/master | 2023-06-20T21:11:22.730218 | 2021-07-28T18:18:30 | 2021-07-28T18:18:30 | 390,465,159 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 698 | swift | //
// Diary.swift
// myFitness
//
// Created by 楊振東 on 2021/7/10.
//
import Foundation
class Diary {
var name: String
var image: String
var date: String
var description: String
var mood: String
var timestamp: String
init(name: String, image: String, date: String, description: String,mood: String = "", timestamp: String) {
self.name = name
self.image = image
self.date = date
self.description = description
self.mood = mood
self.timestamp = timestamp
}
convenience init() {
self.init(name: "", image: "", date: "", description: "", mood: "", timestamp: "")
}
}
| [
-1
] |
21bf294590e8aa40592be55f790f48872f28f8bc | acb1d492b4d59d08cebd570aaf84db0e0254e4cc | /Example/Coherence/Model/Country+CoreDataProperties.swift | 6a730fddf0231738165e3bf4a8dbf0f5f7b273ee | [
"Apache-2.0"
] | permissive | tonystone/coherence | 071e8d04b0bcf9e2668a337031da3fb313d853c3 | 501ec2f5d82dbf66af6d3ddade12bbd1c65e550d | refs/heads/master | 2021-01-17T15:03:29.691283 | 2020-01-29T23:39:57 | 2020-01-29T23:39:57 | 45,281,440 | 3 | 3 | Apache-2.0 | 2020-01-29T23:39:58 | 2015-10-30T23:26:23 | Swift | UTF-8 | Swift | false | false | 441 | swift | //
// Country+CoreDataProperties.swift
// Coherence
//
// Created by Tony Stone on 1/30/17.
// Copyright © 2017 Tony Stone. All rights reserved.
//
import Foundation
import CoreData
extension Country {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Country> {
return NSFetchRequest<Country>(entityName: "Country");
}
@NSManaged public var name: String?
@NSManaged public var region: Region?
}
| [
-1
] |
045c30d5c695d98816eb892b2258312bcffff367 | ad5083f32b995a2268387525d1581439e0051337 | /EasyKIIP/VC/MainVC/MainVC/MainRootView.swift | c7c121ff3183fc313eeacef206a001a3633e9e2b | [] | no_license | tuanback/easykiip | 22ce7b37193a93eebc9ff965c05fc9a5d272deea | 59a95304c121a1ca48dfb83425b8df71dac490e2 | refs/heads/master | 2023-04-12T19:30:02.109660 | 2020-09-28T13:24:18 | 2020-09-28T13:24:18 | 256,920,859 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,551 | swift | //
// MainRootView.swift
// EasyKIIP_iOS
//
// Created by Tuan on 2020/05/01.
// Copyright © 2020 Real Life Swift. All rights reserved.
//
import Foundation
import UIKit
import RxSwift
import RxCocoa
import SnapKit
class MainRootView: NiblessView {
private let viewModel: MainViewModel
private var collectionView: UICollectionView!
private var collectionViewFlowLayout: UICollectionViewFlowLayout!
private let cellIdentifier = "MainBookItemCVC"
private let disposeBag = DisposeBag()
init(frame: CGRect = .zero,
viewModel: MainViewModel) {
self.viewModel = viewModel
super.init(frame: frame)
setupViews()
}
private func setupViews() {
backgroundColor = UIColor.appBackground
setupCollectionViews()
}
deinit {
print("Deinit")
}
private func setupCollectionViews() {
collectionViewFlowLayout = UICollectionViewFlowLayout()
collectionView = UICollectionView(frame: .zero, collectionViewLayout: collectionViewFlowLayout)
collectionView.layer.masksToBounds = false
collectionView.backgroundColor = UIColor.appBackground
collectionView.delegate = self
addSubview(collectionView)
collectionView.snp.makeConstraints { (make) in
make.top.equalTo(safeAreaLayoutGuide).offset(16)
make.leading.equalTo(safeAreaLayoutGuide).offset(16)
make.trailing.equalTo(safeAreaLayoutGuide).offset(-16)
make.bottom.equalTo(safeAreaLayoutGuide)
}
collectionView.register(MainBookItemCVC.self, forCellWithReuseIdentifier: cellIdentifier)
viewModel.bookViewModels.bind(to: collectionView.rx.items(cellIdentifier: cellIdentifier, cellType: MainBookItemCVC.self)) {row, itemViewModel, cell in
cell.configCell(viewModel: itemViewModel)
}
.disposed(by: disposeBag)
collectionView.rx
.modelSelected(BookItemViewModel.self)
.subscribe(onNext: viewModel.handleBookItemClicked(_:))
.disposed(by: disposeBag)
}
}
extension MainRootView: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 16
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = (collectionView.frame.width - 16) / 2
let height = width * 3 / 2
return CGSize(width: width, height: height)
}
}
| [
-1
] |
6bab437db941862a946d89a313409f0cddc43ce0 | dd54d146937e948c78aee6795e1c76baad4b57a9 | /View/SecureItemDisplayView.swift | 4095215bf2bf9b18dcfd446396b75dbc87d93220 | [] | no_license | hyperiumio/vault | 2d637419cfcc0c9bf9dd49dab7fbe9e4ad493fe7 | 9fd8423003a32e6bb3cd5e002b139c6c3a61cc57 | refs/heads/master | 2021-11-12T01:48:38.828211 | 2021-10-20T15:34:39 | 2021-10-20T15:34:39 | 216,332,141 | 4 | 0 | null | 2021-01-26T14:56:28 | 2019-10-20T08:44:20 | Swift | UTF-8 | Swift | false | false | 8,734 | swift | import Localization
import SwiftUI
struct VaultItemElementDisplayView<Model>: View where Model: VaultItemModelRepresentable {
private let element: Model.Element
init(_ element: Model.Element) {
self.element = element
}
var body: some View {
switch element {
case .login(let model):
LoginView(model)
case .password(let model):
PasswordView(model)
case .file(let model):
FileView(model)
case .note(let model):
NoteView(model)
case .bankCard(let model):
BankCardView(model)
case .wifi(let model):
WifiView(model)
case .bankAccount(let model):
BankAccountView(model)
case .custom(let model):
CustomItemView(model)
}
}
}
private extension VaultItemElementDisplayView {
struct Container<Content>: View where Content: View {
private let content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
VStack(alignment: .leading, spacing: 20) {
content
}
.padding(.vertical)
}
}
struct Field<Content>: View where Content: View {
private let title: String
private let content: Content
init(_ title: String, @ViewBuilder content: () -> Content) {
self.title = title
self.content = content()
}
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.subheadline)
.foregroundColor(.secondaryLabel)
content
}
}
}
struct TextField: View {
private let title: String
private let text: String
init(_ title: String, text: String) {
self.title = title
self.text = text
}
var body: some View {
Field(title) {
Text(text)
}
}
}
struct SecureTextField: View {
private let title: String
private let text: String
@State private var secureDisplay = true
init(_ title: String, text: String) {
self.title = title
self.text = text
}
var body: some View {
HStack {
Field(title) {
Text(secureDisplay ? "••••••••" : text)
}
Spacer()
Button {
secureDisplay.toggle()
} label: {
if secureDisplay {
Image.hideSecret
} else {
Image.showSecret
}
}
.buttonStyle(BorderlessButtonStyle())
}
}
}
struct DateField: View {
private let title: String
private let date: Date
init(_ title: String, date: Date) {
self.title = title
self.date = date
}
var body: some View {
Field(title) {
Text(date, style: .date)
}
}
}
struct BankCardVendorField: View {
private let vendor: BankCardItemVendor
init(_ vendor: BankCardItemVendor) {
self.vendor = vendor
}
var body: some View {
Field(LocalizedString.bankCardVendor) {
switch vendor {
case .masterCard:
Text(LocalizedString.mastercard)
case .visa:
Text(LocalizedString.visa)
case .americanExpress:
Text(LocalizedString.americanExpress)
case .other:
Text(LocalizedString.other)
}
}
}
}
struct LoginView<Model>: View where Model: LoginModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
TextField(LocalizedString.user, text: model.username)
SecureTextField(LocalizedString.password, text: model.password)
TextField(LocalizedString.url, text: model.url)
}
}
}
struct PasswordView<Model>: View where Model: PasswordModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
SecureTextField(LocalizedString.password, text: model.password)
}
}
}
struct FileView<Model>: View where Model: FileModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
Field(LocalizedString.filename) {
switch (model.data, model.format) {
case (nil, _):
Text("Select File")
case (let data?, .pdf):
FilePDFView(data: data)
case (let data?, .image):
FileImageView(data: data)
case (.some, .unrepresentable):
FileGenericView()
}
}
}
}
}
struct NoteView<Model>: View where Model: NoteModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
TextField(LocalizedString.note, text: model.text)
}
}
}
struct BankCardView<Model>: View where Model: BankCardModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
TextField(LocalizedString.bankCardName, text: model.name)
if let vendor = model.vendor {
BankCardVendorField(vendor)
}
TextField(LocalizedString.bankCardNumber, text: model.number)
DateField(LocalizedString.bankCardExpirationDate, date: model.expirationDate)
SecureTextField(LocalizedString.bankCardPin, text: model.pin)
}
}
}
struct WifiView<Model>: View where Model: WifiModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
TextField(LocalizedString.wifiNetworkName, text: model.networkName)
SecureTextField(LocalizedString.wifiNetworkPassword, text: model.networkPassword)
}
}
}
struct BankAccountView<Model>: View where Model: BankAccountModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
SecureTextField(LocalizedString.bankAccountHolder, text: model.accountHolder)
SecureTextField(LocalizedString.bankAccountIban, text: model.iban)
SecureTextField(LocalizedString.bankAccountBic, text: model.bic)
}
}
}
struct CustomItemView<Model>: View where Model: CustomItemModelRepresentable {
@ObservedObject private var model: Model
init(_ model: Model) {
self.model = model
}
var body: some View {
Container {
TextField(model.name, text: model.value)
}
}
}
}
| [
-1
] |
08381632d5e98a137779333778d9367c75a65824 | 3788027cbc01fa9618243b440a27149f3c5014a1 | /UberCook/CollectionTVC.swift | 9400ed8bf118ab0f524342a76a6661268b8d2eea | [] | no_license | EP101G1/UberCook_IOS | 5568d3c15fa424b63d14b2dc5f0985fd005625a7 | 9fc1734606987f629699c0fe01eaea67c488d990 | refs/heads/master | 2022-12-24T00:30:24.048207 | 2020-09-26T05:47:40 | 2020-09-26T05:47:40 | 298,746,484 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 8,711 | swift | //
// CollectionTVC.swift
// UberCook
//
// Created by 超 on 2020/9/11.
//
import UIKit
class CollectionTVC: UITableViewController {
let fileManager = FileManager()
let userDefault = UserDefaults()
let url_server = URL(string: common_url + "UberCook_Servlet")
var collection = [Collection]()
var recipe_no = ""
var index = 0
var test = [Bool]()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
override func viewWillAppear(_ animated: Bool) {
getCollection()
}
func getCollection(){
let user_no = userDefault.value(forKey: "user_no")
var requestParam = [String: Any]()
requestParam["action"] = "getCollection"
requestParam["user_no"] = user_no
executeTask(url_server!, requestParam) { (data, response, error) in
let decoder = JSONDecoder()
if error == nil {
if data != nil {
//print("input: \(String(data: data!, encoding: .utf8)!)")
if let result = try? decoder.decode([Collection].self, from: data!){
self.collection = result
for index in 0...self.collection.count {
self.test.insert(true, at: index)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
}
}
@objc func onChange(sender: Any) {
// 取得這個 UISwtich 元件
let tempSwitch = sender as! UISwitch
// 依據屬性 on 來為底色變色
if tempSwitch.isOn {
test[self.index] = true
var requestParam = [String: Any]()
requestParam["action"] = "insertCollect"
requestParam["user_no"] = self.userDefault.value(forKey: "user_no")
requestParam["recipe_no"] = self.recipe_no
executeTask(url_server!, requestParam) { (data, response, error) in
if error == nil {
if data != nil {
let count = String(decoding: data!, as: UTF8.self)
if count == "1"{
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
}
}else{
test[self.index] = false
var requestParam = [String: Any]()
requestParam["action"] = "deleteCollect"
requestParam["user_no"] = self.userDefault.value(forKey: "user_no")
requestParam["recipe_no"] = self.recipe_no
executeTask(url_server!, requestParam) { (data, response, error) in
if error == nil {
if data != nil {
let count = String(decoding: data!, as: UTF8.self)
if count == "1"{
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
}
}
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return collection.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CollectionCell", for: indexPath) as! CollectionCell
let collectionList = collection[indexPath.row]
cell.index = indexPath.row
cell.completionHandler = {(index) in
self.index = index
self.recipe_no = self.collection[index].recipe_no
}
if test[indexPath.row] {
cell.collectionSwitch.isOn = true
}else{
cell.collectionSwitch.isOn = false
}
cell.collectionSwitch.addTarget(self, action: #selector(onChange(sender:)), for: .valueChanged)
cell.collectionLabel.text = collectionList.recipe_title
cell.collectionImageView.layer.cornerRadius = 10
cell.layer.cornerRadius = cell.frame.height/20
var requestParam = [String: Any]()
requestParam["action"] = "getRecipeImage"
requestParam["recipe_no"] = collectionList.recipe_no
requestParam["imageSize"] = 720
var image: UIImage?
let imageUrl = fileInCaches(fileName: collectionList.recipe_no)
if self.fileManager.fileExists(atPath: imageUrl.path) {
if let imageCaches = try? Data(contentsOf: imageUrl) {
image = UIImage(data: imageCaches)
DispatchQueue.main.async {
cell.collectionImageView.image = image
}
}
}else {
executeTask(url_server!, requestParam) { (data, response, error) in
// print("input: \(String(data: data!, encoding: .utf8)!)")
if error == nil {
if data != nil {
image = UIImage(data: data!)
DispatchQueue.main.async {
cell.collectionImageView.image = image
}
if let image = image?.jpegData(compressionQuality: 1.0) {
try? image.write(to: imageUrl, options: .atomic)
}
}
if image == nil {
image = UIImage(named: "noImage.jpg")
DispatchQueue.main.async {
cell.collectionImageView.image = image
}
}
} else {
print(error!.localizedDescription)
}
}
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let collectionDVC = self.storyboard?.instantiateViewController(withIdentifier: "RecipeDetailViewController") as! RecipeDetailViewController
let collectionList = collection[indexPath.row]
collectionDVC.collection = collectionList
self.navigationController?.pushViewController(collectionDVC, animated: true)
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// 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
] |
551195803dab0e5d597ecf0c503a21f73ff5c210 | 9b8eeeca76c728cc3db78317f72f5e51219983b8 | /自写/Test/TestAnyAndAnyClass/TestAnyAndAnyClass/AppDelegate.swift | ec4752e9848332bdb29d1af72087c778e1733156 | [] | no_license | lYcHeeM/Demo | e3b8c59a489533e2bab2546b8d0f92bfb11e14cb | 6d8ffc542e41389844e2d902385a48ce75c91f51 | refs/heads/master | 2021-07-15T20:37:15.628923 | 2021-02-22T02:45:03 | 2021-02-22T02:45:03 | 98,294,658 | 1 | 1 | null | null | null | null | UTF-8 | Swift | false | false | 2,650 | swift | //
// AppDelegate.swift
// TestAnyAndAnyClass
//
// Created by luozhijun on 2016/10/25.
// Copyright © 2016年 RickLuo. All rights reserved.
//
import UIKit
class ClassA {
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let obj = 1888
typeConvertError(convertingObj: obj, toType: [NSDate].self)
NSLog("%p", obj)
let ccc = obj.dynamicType
var dict = NSMutableDictionary()
NSLog("%p", dict)
dict.setValue("aaa", forKey: "bbb")
NSLog("%p", dict)
var dict2 = [String: String]()
NSLog("%p", dict2)
dict2.updateValue("aaa", forKey: "bbbb")
NSLog("%p", dict2)
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:.
}
}
| [
229380,
229385,
229388,
229391,
229394,
229397,
229399,
229402,
278556,
229405,
237613,
311349,
286774,
319544,
204856,
286776,
286791,
237640,
278605,
286797,
311375,
196692,
319573,
319590,
278635,
303212,
278639,
131192,
237693,
327814,
131209,
303241,
417930,
303244,
319633,
286873,
286876,
311469,
32944,
286906,
327866,
286910,
286916,
286922,
286924,
286926,
286928,
131281,
278747,
295133,
319716,
237807,
303345,
286962,
229622,
327930,
278781,
278783,
278785,
286987,
311569,
286999,
319770,
287003,
287006,
287012,
287014,
287016,
311598,
287023,
311601,
155966,
278849,
319809,
319814,
319818,
311628,
287054,
319822,
278865,
196969,
139638,
213367,
106872,
319872,
311683,
311693,
65943,
319898,
311719,
278952,
139689,
278957,
278967,
180668,
278975,
278980,
278983,
319945,
278986,
278990,
278994,
311767,
279003,
279006,
188895,
279010,
287202,
279015,
172520,
279020,
279023,
311791,
172529,
279027,
319989,
164343,
279035,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
287238,
172552,
303623,
320007,
279051,
172558,
279055,
279058,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
279084,
172591,
172598,
172607,
172609,
172612,
377413,
172618,
303690,
33357,
279124,
311911,
189034,
172655,
172656,
189039,
189040,
295538,
172660,
189044,
287349,
352880,
287355,
287360,
295553,
287365,
295557,
303751,
311942,
352905,
279178,
287371,
311946,
311951,
287377,
287381,
311957,
221850,
164509,
230045,
287390,
295583,
303773,
287394,
303780,
287398,
279208,
287400,
279212,
230061,
287409,
172721,
66227,
303797,
328381,
279231,
287423,
328384,
287427,
107208,
287436,
287440,
295633,
172755,
303827,
279255,
279258,
303835,
213724,
189149,
303838,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
205564,
303871,
230146,
295685,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
279340,
279353,
230202,
312124,
222018,
295755,
148302,
287569,
303959,
230237,
279390,
230241,
303976,
336744,
303985,
303987,
328563,
303991,
303997,
295808,
304005,
213895,
304007,
304009,
320391,
304011,
304013,
279438,
295822,
295825,
304019,
58262,
279452,
279461,
279462,
304042,
213931,
230327,
287675,
304063,
238528,
304065,
213954,
189378,
156612,
312272,
304090,
320481,
320490,
312302,
320496,
304114,
295928,
320505,
295945,
197645,
230413,
320528,
140312,
238620,
304164,
238641,
238652,
238655,
230465,
238658,
296004,
336964,
205895,
320584,
238666,
296021,
402518,
230497,
296036,
296040,
361576,
205931,
296044,
164973,
205934,
312432,
189562,
337018,
279679,
279683,
222340,
205968,
296084,
304285,
238756,
205991,
222377,
165038,
230576,
304311,
230592,
279750,
148690,
304348,
279777,
304354,
296163,
304360,
279788,
320748,
279790,
304370,
320771,
312585,
296202,
296205,
320786,
296213,
214294,
296215,
320792,
304416,
230689,
173350,
312622,
296243,
312630,
222522,
222525,
296255,
312639,
296259,
230727,
238919,
320840,
222545,
222556,
337244,
230752,
230760,
173418,
230763,
410987,
230768,
296305,
230773,
181626,
304506,
312712,
296331,
288140,
230800,
288144,
337306,
173472,
288160,
288162,
288164,
279975,
304555,
370092,
279983,
279985,
312755,
279991,
312759,
288185,
222652,
173507,
296389,
222665,
230860,
312783,
230865,
288210,
370130,
222676,
280021,
288212,
288214,
239064,
288217,
288218,
280027,
288220,
329177,
239070,
288224,
288226,
370146,
280036,
288229,
280038,
288230,
288232,
288234,
288236,
288238,
288240,
288242,
296435,
288244,
288250,
402942,
206336,
296450,
230916,
230919,
304651,
370187,
304653,
230940,
222752,
108066,
296488,
230961,
157236,
288320,
288325,
124489,
280149,
280152,
288344,
239194,
280158,
403039,
370272,
312938,
280183,
116354,
280222,
321195,
296622,
337585,
296626,
296634,
296637,
280260,
206536,
280264,
206539,
206541,
280276,
321239,
280283,
288478,
313055,
321252,
313066,
280302,
288494,
419570,
288499,
288502,
124671,
280324,
280331,
198416,
116503,
321304,
329498,
296731,
313121,
313123,
304932,
321316,
280363,
141101,
280375,
321336,
288576,
345921,
280388,
280402,
313176,
321381,
296812,
313201,
1920,
255873,
305028,
247688,
280458,
124817,
280468,
239510,
280473,
124827,
247709,
313258,
296883,
124853,
10170,
296890,
288700,
296894,
190403,
280515,
296900,
337862,
165831,
231379,
296921,
239586,
313320,
231404,
124913,
165876,
321528,
288764,
239617,
313347,
288773,
313358,
305176,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
124980,
288824,
288826,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
149599,
223327,
280671,
321634,
149603,
223341,
280687,
280691,
313464,
288895,
321670,
215175,
141455,
313498,
100520,
288940,
280755,
288947,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
280804,
280807,
280811,
280817,
157940,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
280891,
280897,
280900,
239944,
305480,
280906,
239947,
305485,
305489,
280919,
313700,
280937,
313705,
190832,
280946,
313720,
280956,
280959,
313731,
240011,
289166,
240017,
297363,
240021,
297365,
297368,
297372,
141725,
297377,
289186,
289201,
240052,
289207,
289210,
305594,
281024,
289218,
289227,
281047,
166378,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
240132,
223749,
305668,
281095,
223752,
338440,
223757,
281102,
223763,
322074,
289317,
281127,
158262,
158266,
289342,
281154,
322115,
158283,
338532,
199273,
158317,
313973,
281210,
158347,
133776,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
314029,
314033,
240309,
314047,
314051,
199364,
297671,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
322310,
322314,
322318,
281361,
281372,
322341,
215850,
281388,
281401,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
174955,
224110,
207737,
183172,
338823,
322440,
314249,
183184,
240535,
289694,
289700,
289712,
281529,
289724,
289762,
322534,
183277,
322610,
314421,
281654,
207937,
314433,
322642,
281691,
314461,
281702,
281704,
314474,
281711,
248995,
306341,
306347,
142531,
199877,
289991,
306377,
363742,
363745,
298216,
216303,
388350,
257302,
363802,
314671,
298292,
298294,
216376,
380226,
224587,
306517,
314714,
224603,
159068,
314718,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
306549,
314743,
306552,
290171,
306555,
298365,
314747,
290174,
224641,
281987,
298372,
314756,
281990,
224647,
298377,
314763,
224657,
306581,
314779,
314785,
282025,
282027,
241068,
241070,
241072,
282034,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
282089,
191985,
282098,
282101,
241142,
290298,
151036,
290302,
290305,
192008,
323084,
290321,
282133,
290325,
241175,
290328,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290356,
282186,
282195,
282201,
306778,
159324,
159330,
314979,
298598,
224875,
241260,
257658,
315016,
282249,
290445,
282255,
282261,
298651,
282269,
323229,
298655,
282277,
282300,
323266,
282310,
282319,
306897,
241362,
306904,
298714,
52959,
282337,
241380,
216806,
323304,
282345,
12011,
323318,
282364,
282367,
306945,
241412,
282376,
216842,
323345,
282388,
282392,
184090,
315167,
315169,
282402,
241448,
315176,
241450,
282410,
306988,
315190,
159545,
282425,
298811,
307009,
413506,
307012,
315211,
307027,
315221,
241496,
241498,
307035,
282465,
241509,
110438,
298860,
110445,
282478,
315253,
315255,
339838,
315267,
315269,
241544,
282505,
241546,
241548,
282514,
241556,
241560,
282520,
241563,
241565,
241567,
241569,
241574,
298922,
241581,
241583,
323504,
241586,
282547,
241588,
241590,
241592,
241598,
290751,
241600,
241605,
241610,
298975,
241632,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
299006,
282623,
241669,
282632,
282639,
282645,
241693,
102438,
217127,
282669,
282681,
282687,
159811,
315463,
315466,
192589,
307278,
307287,
315482,
217179,
315483,
192605,
200801,
217188,
299109,
315495,
45163,
307307,
315502,
192624,
307314,
233591,
307338,
233613,
241813,
299164,
184479,
299167,
184481,
307370,
307372,
307374,
307376,
299185,
323763,
176311,
184503,
307385,
258235,
176316,
307388,
299200,
307394,
299204,
307396,
184518,
323784,
307409,
307411,
233701,
307432,
282881,
282893,
291089,
282906,
233766,
307508,
307510,
332086,
307515,
282942,
307518,
282947,
282957,
233808,
315733,
323926,
233815,
315739,
299357,
242018,
299373,
315757,
242043,
315771,
299391,
291202,
299398,
242057,
291222,
315801,
291226,
242075,
61855,
291231,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
299440,
299444,
127413,
283062,
291254,
127417,
291260,
127421,
127424,
127431,
127434,
176592,
315856,
176597,
127447,
176605,
242143,
291299,
242152,
291305,
127466,
176620,
291314,
291317,
135672,
291323,
233979,
291330,
283142,
127497,
135689,
233994,
234003,
234006,
127511,
152087,
283161,
242202,
234010,
135707,
242206,
242208,
135717,
291378,
152118,
234038,
111193,
242275,
299620,
242279,
184952,
135805,
135808,
135820,
316051,
225941,
316054,
135834,
373404,
299677,
135839,
299680,
225954,
242343,
209576,
242345,
373421,
299706,
135873,
135876,
299720,
299723,
225998,
299726,
226002,
119509,
226005,
201444,
283368,
283372,
226037,
283382,
234231,
316151,
234236,
226045,
234239,
242431,
209665,
234242,
242436,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
348950,
201496,
234264,
234266,
283421,
234269,
234272,
234274,
152355,
234278,
283432,
234281,
234284,
234287,
283440,
185138,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
234309,
234313,
316233,
316235,
234316,
283468,
234319,
234321,
234324,
201557,
234333,
308063,
234336,
234338,
242530,
349027,
234341,
234344,
234347,
177004,
234350,
324464,
152435,
234356,
234362,
234364,
234368,
234370,
234373,
226182,
234375,
226185,
234379,
234384,
234390,
226200,
234393,
209818,
308123,
234396,
324504,
291742,
324508,
234401,
291747,
291748,
234405,
291750,
234407,
324518,
324520,
291754,
324522,
226220,
324527,
291760,
234417,
324531,
226230,
234422,
324536,
234428,
291773,
234431,
242623,
324544,
234434,
324546,
226245,
234437,
234443,
234446,
275406,
234449,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
234487,
324599,
234490,
234493,
234496,
316416,
234501,
308231,
234504,
234507,
234510,
234515,
234519,
234520,
316439,
234528,
234532,
300069,
234535,
234537,
234540,
234546,
275508,
234549,
300085,
300088,
234556,
234558,
316479,
234561,
160835,
234563,
308291,
316483,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
234590,
234593,
234595,
234597,
234601,
300139,
234605,
234607,
275569,
234610,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
234627,
275588,
242822,
234634,
234636,
177293,
234640,
275602,
234643,
226453,
275606,
234647,
234648,
275608,
234650,
308379,
324757,
234653,
283805,
119967,
300189,
234657,
324768,
242852,
283813,
234661,
300197,
234664,
275626,
234667,
308414,
234687,
300226,
308418,
283844,
300229,
308420,
283850,
300234,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
234726,
300263,
300265,
300267,
300270,
300272,
120053,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
300292,
300294,
275719,
177419,
300299,
300301,
242957,
275725,
283917,
177424,
349464,
283939,
259367,
283951,
292143,
300344,
226617,
243003,
283963,
300357,
357722,
316766,
218464,
316768,
292197,
316774,
136562,
324978,
275834,
275840,
316803,
316814,
226703,
234899,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
284076,
144812,
144814,
284087,
292279,
144826,
144830,
144832,
144835,
144837,
38342,
144839,
144841,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
300523,
259565,
259567,
300527,
308720,
226802,
316917,
308727,
300537,
316947,
284191,
284194,
284196,
235045,
284199,
284204,
284206,
284211,
284213,
194103,
284215,
284218,
226877,
284223,
284226,
243268,
284228,
226886,
284231,
128584,
292421,
284234,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
292433,
300628,
284245,
284247,
235097,
243290,
284249,
284251,
284253,
300638,
284255,
284258,
292452,
292454,
284263,
284265,
292458,
284267,
292461,
284272,
284274,
276086,
284278,
292470,
292473,
284283,
284286,
276095,
284288,
292479,
276098,
284290,
284292,
292481,
292485,
325250,
284297,
317066,
284299,
284301,
284303,
276114,
284306,
284308,
284312,
284314,
276127,
284320,
284322,
284327,
276137,
284329,
284331,
317098,
284333,
276144,
284337,
284339,
284343,
284346,
284350,
276160,
358080,
358083,
276166,
284358,
358089,
284362,
284368,
284370,
317138,
358098,
284377,
276187,
284379,
284381,
284384,
284386,
317158,
284392,
325353,
284394,
284397,
276206,
284399,
358128,
358135,
276216,
358140,
284413,
358142,
284418,
317187,
317191,
284428,
300816,
300819,
317207,
300828,
300830,
276255,
300832,
325408,
227109,
317221,
358183,
276268,
300845,
243504,
284469,
276280,
325436,
276291,
366406,
276295,
153417,
284499,
276308,
284502,
317271,
276315,
300912,
284529,
292721,
300915,
292729,
284540,
292734,
325512,
284564,
358292,
284566,
350106,
284572,
276386,
284579,
276388,
292776,
358312,
284585,
317353,
276395,
292784,
161718,
358326,
358330,
276411,
276418,
276433,
301009,
358360,
276446,
276448,
276455,
292839,
292843,
276460,
178161,
227314,
276466,
276472,
317435,
276476,
276479,
276482,
276485,
276490,
276496,
317456,
317458,
243733,
243740,
317472,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
235579,
276539,
235581,
178238,
325692,
276544,
284739,
292934,
243785,
350293,
350295,
194649,
227418,
309337,
194654,
227423,
350302,
178273,
227426,
276579,
194660,
309346,
309348,
276583,
309350,
350308,
276586,
309354,
350313,
350316,
276590,
301167,
227440,
350321,
284786,
276595,
350325,
350328,
292985,
292989,
317570,
350339,
317573,
350342,
276617,
350345,
350349,
317584,
325777,
350354,
350357,
350359,
350362,
276638,
350366,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
227522,
350402,
301252,
350406,
227529,
301258,
309450,
276685,
276689,
309462,
309468,
309471,
317672,
325867,
227571,
309491,
309494,
227583,
276735,
276739,
227596,
325910,
342298,
211232,
317729,
325943,
211260,
276809,
285002,
276811,
235853,
235858,
276829,
276833,
391523,
276836,
293232,
186744,
211324,
227709,
317833,
178572,
285070,
285077,
227738,
317853,
276896,
317858,
342434,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
317910,
293336,
317917,
293343,
358880,
276961,
293346,
276964,
293352,
236013,
301562,
317951,
301575,
121352,
236043,
342541,
113167,
277011,
309779,
309781,
317971,
227877,
227879,
293417,
293421,
277054,
129603,
318020,
301639,
301643,
285265,
399955,
277080,
326244,
318055,
277100,
121458,
170619,
309885,
309888,
277122,
146052,
277128,
301706,
318092,
326285,
318094,
277136,
277139,
227992,
227998,
318110,
137889,
383658,
318128,
277170,
293555,
154292,
277173,
318132,
342707,
277177,
277181,
277187,
277194,
277196,
277201,
137946,
113378,
277223,
342760,
285417,
56043,
277232,
228081,
56059,
310015,
285441,
310020,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
293677,
318253,
285489,
293685,
285494,
301880,
301884,
293696,
277314,
293706,
277322,
301911,
277337,
301913,
236397,
310134,
236408,
277368,
113538,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
310179,
293798,
236460,
277426,
293811,
293820,
293849,
293861,
228327,
318442,
277486,
326638,
293877,
285686,
56313,
302073,
285690,
244731,
293882,
302075,
293887,
277507,
277511,
293899,
302105,
293917,
293939,
318516,
293956,
277573,
228422,
293960,
277577,
310344,
277583,
203857,
293971,
236632,
277594,
277598,
285792,
277601,
310374,
318573,
203886,
187509,
285815,
285817,
285821,
302205,
253064,
302218,
285835,
162964,
384148,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
277687,
294072,
318651,
294076,
277695,
244930,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
302296,
384222,
310498,
285927,
318698,
302315,
294132,
138485,
228601,
228606,
310531,
138505,
228617,
318742,
277798,
130345,
113964,
285997,
113969,
318773,
318776,
286010,
417086,
294211,
302403,
384328,
326991,
179547,
146784,
302436,
294246,
327015,
310632,
327017,
351594,
351607,
310648,
310651,
310657,
310659,
294276,
327046,
310672,
130468,
228776,
277932,
310703,
130486,
310710,
310712,
310715,
302526,
228799,
64966,
302534,
310727,
302541,
302543,
310737,
228825,
163290,
310749,
187880,
286188,
310764,
310772,
212472,
286203,
286214,
228871,
302614,
286233,
302617,
187939,
294435,
286246,
294439,
294440,
294443,
294445,
212538,
228933,
286283,
212560,
228944,
400976,
147032,
278109,
286312,
310892,
294521,
343679,
310925,
286354,
122517,
278168,
327333,
229030,
278188,
278192,
278196,
319171,
302789,
294599,
294601,
302793,
278227,
229076,
286420,
319187,
286425,
319194,
278235,
229086,
278238,
294625,
294634,
319226,
286460,
278274,
302852,
278277,
302854,
311048,
352008,
311053,
302862,
278306,
188199,
294701,
319280,
319290,
229192,
302925,
188247,
237409,
294776,
294785,
327554,
294803,
40851,
294811,
319390,
40865,
294817,
319394,
294831,
188340,
294844,
294847,
294876,
294879,
311279,
278513,
237555,
311283,
237562
] |
78da6ae43b4f6b8206fe30ec31c27f534d3e71a7 | 176b6c9e6fde01773151dcbbfe97ca870028ff54 | /OnTheMap/MapViewController.swift | 65f0b0e5685e67fd8e9848c0dbfb1f0d19f921b4 | [] | no_license | rsrose21/OnTheMap | d2965bb7ae38cba2741e2f9aea5fa95a6ab9162c | be62735dbae93675f2245bb7f2bb6116c94dce95 | refs/heads/master | 2021-01-10T19:50:45.995674 | 2015-07-26T00:04:54 | 2015-07-26T00:04:54 | 37,820,154 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,736 | swift | //
// MapViewController.swift
// OnTheMap
//
// Created by Ryan Rose on 7/5/15.
// Copyright (c) 2015 GE. All rights reserved.
//
import UIKit
import Foundation
import MapKit
class MapViewController : UIViewController {
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
//set navigation bar buttons
navigationItem.rightBarButtonItems = setupNavBar()
navigationItem.leftBarButtonItems = setupLogoutButton()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
//load data - will pull from cache if available, otherwise calls API for fresh data
refreshLocations(false)
}
func refreshLocationsFromNav() {
//force a refresh for new data if clicked from navigation bar
refreshLocations(true)
}
func refreshLocations(refresh: Bool) {
OTMClient.sharedInstance().getStudentLocations(refresh, completionHandler: { students, error in
if let students = students {
//add pins to the map from student data returned from API
for (var i = 0; i < students.count; i += 1) {
self.mapView.addAnnotation(students[i].annotation)
}
//force a repaint of the map and center it
dispatch_async(dispatch_get_main_queue(), {
let center = self.mapView.centerCoordinate
self.mapView.centerCoordinate = center
})
} else {
self.displayError("Unable to load data")
}
})
}
} | [
-1
] |
80f117856151857c9caa2ecf4f81b5fb07c1e715 | 17687dc936135bc939b968b1a5f02089f896b627 | /Alidade/Source/Core/BoolExtension.swift | c1d93f050c628c1bc8d053e7feecd449ffb61791 | [
"MIT"
] | permissive | eugene-krinitsyn/Alidade | bcc65ba1abbe2870d9668c456276b8014c8e5134 | 1b75e42f7e8b6072e8b5a5e734925c5ad7b7a976 | refs/heads/master | 2020-05-17T01:37:58.805040 | 2019-03-21T18:53:06 | 2019-03-21T18:53:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 158 | swift | import Foundation
public extension Bool {
@available(iOS, deprecated, message: "Deprecated in swift 4.2")
static var random: Bool { return random() }
}
| [
-1
] |
2e19e277543d7262bd61d8e56689e3d8f19e0ee2 | 1d831036dd6ff24989d86a116bf1745fe9d3d3da | /ios/dummy.swift | 32787073b803a24837d75cc7fc7a7063757be1cf | [] | no_license | lghimfus/bandcamp | 4cb5e1183b5c02287743d1da799753260dfd4db8 | 248b16bd2b1f3de48fb062ceb5fd6cbb72593630 | refs/heads/master | 2022-06-11T21:22:31.077231 | 2020-05-03T22:37:33 | 2020-05-03T22:37:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 108 | swift | //
// dummy.swift
// bandcamp
//
// Created by Sebastian Sas Mangel on 19/04/2020.
//
import Foundation
| [
-1
] |
325143bd030523c1045a83e2a397f47e8b4c6f3f | 7d45c9b53a2096269ee02fd67cad3b06c516b34d | /VR on iOS v2.1/VR on iOS/Extensions.swift | b2c80640e29dc53b4d081048cdf244a84cbb66d5 | [
"MIT"
] | permissive | brandosha/vr-iOS | 62452c538a072ef4366af32693dbe30be4ea7afc | 1751c9a37ab66f06d6bbbfb5aa5068e6827c1611 | refs/heads/master | 2020-03-27T22:24:51.210782 | 2018-10-27T18:50:36 | 2018-10-27T18:50:36 | 147,228,707 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,963 | swift | //
// Extensions.swift
// VR 360 app
//
// Created by Brandon on 7/5/18.
// Copyright © 2018 test. All rights reserved.
//
import Foundation
import ARKit
import SceneKit
import Darwin
extension ARSCNView {
func setup() {
antialiasingMode = .none
preferredFramesPerSecond = 30
if let camera = pointOfView?.camera {
camera.wantsHDR = false
camera.wantsExposureAdaptation = true
camera.exposureOffset = 0
camera.minimumExposure = -1
camera.maximumExposure = 3
}
}
}
extension SCNNode {
func distance(from node: SCNNode) -> Float {
let node1Pos = node.presentation.worldPosition
let node2Pos = self.presentation.worldPosition
let distance = SCNVector3(
node2Pos.x - node1Pos.x,
node2Pos.y - node1Pos.y,
node2Pos.z - node1Pos.z
)
let length: Float = sqrtf(distance.x * distance.x + distance.y * distance.y + distance.z * distance.z)
return length
}
func setHighlighted(to: Bool) {
let highlightedBitMask = 2
if !to {
categoryBitMask = 1
} else {
categoryBitMask = highlightedBitMask
}
for child in self.childNodes {
if !to {
child.setHighlighted(to: false)
} else {
child.setHighlighted(to: true)
}
}
}
static func fromFile(named: String) -> SCNNode? {
guard let scene = SCNScene(named: named) else {
return nil
}
let newNode = scene.rootNode
return newNode
}
}
| [
-1
] |
6948397dd5c752f6cd773575cddab83cb68471f7 | c190c5c487919c64001daa469bf00bd1f9065ffe | /LionsAndTigers/Tiger.swift | 242928c0071e77a99ca046bbeeee2ead8fb5825c | [] | no_license | paolobravo/LionsAndTigers | c611c0a86ac08d8d51fcff44cb2204ec73efe004 | 288b75f6df54add262d82d333b7dcc19bb45d8e3 | refs/heads/master | 2021-05-28T05:51:42.108021 | 2014-12-17T11:52:33 | 2014-12-17T11:52:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,654 | swift | //
// Tiger.swift
// LionsAndTigers
//
// Created by Miguel Bravo on 12/14/14.
// Copyright (c) 2014 Miguel Bravo. All rights reserved.
//
import Foundation
import UIKit
//
struct Tiger {
var age = 0
var name = ""
var breed = ""
// next time initialize image
var image = UIImage(named:"")
func chuff() {
println("Tiger: Chuff chuff")
}
func chuffANumberOfTimes(numberOfTimes: Int){
for var chuff=0; chuff<numberOfTimes; ++chuff {
self.chuff()
}
}
func chuffNumberOfTimes(numberOfTimes: Int, isLoud: Bool) {
for var chuffTimes=1; chuffTimes<=numberOfTimes; chuffTimes++ {
if isLoud {
chuff()
}else{
println("Tiger: purr purr")
}
}
}
func ageInTigerYearsFromAge(regularAge: Int) -> Int {
let newAge = regularAge * 3
return newAge
}
func randomFact() -> String {
let randomNumber = Int(arc4random_uniform(UInt32(3)))
var randomFact:String
if randomNumber == 0{
randomFact = "The tiger is the biggest species in the cat family"
} else if randomNumber == 1 {
randomFact = "Tigers can reach a length of 3.3 meters"
} else {
randomFact = "A group of tigers is known as an 'ambush' or 'streak'"
}
return randomFact
}
}
| [
-1
] |
9ebe56121ca5f859073939d45276f08f5657308a | 1d40ea4b5ed95e767847bad325cc7e528e72d1ce | /SwiftProgramming/Labs/FunctionsLabTests.swift | 66bde4cb5e91ab16bffeba4f648c889b110af150 | [
"MIT"
] | permissive | AboutObjectsTraining/swift-comp-reston-2018-08 | 738f2cacc26c50717189a29d06db451a00abff0f | b2af711319b804cd29ecc9a2358d8e285a786793 | refs/heads/master | 2020-03-27T05:27:40.973763 | 2018-08-31T23:35:31 | 2018-08-31T23:35:31 | 146,021,436 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,246 | swift | // Copyright (C) 2015 About Objects, Inc. All Rights Reserved.
// See LICENSE.txt for this example's licensing information.
//
import XCTest
let temperatureValues: [Double] = [-10, 0, 10, 32, 72, 100]
func convertedToCelsius(fahrenheit: Double) -> Double {
return (fahrenheit - 32) * (5/9)
}
func convertedToFahrenheit(celsius: Double) -> Double {
return (celsius * 9/5) + 32
}
class FunctionsLabTests: XCTestCase
{
func testConvertFahrenheitToCelsiusUsingForLoop() {
for value in temperatureValues {
let celsius = convertedToCelsius(fahrenheit: value)
let formattedValue = String(format: "%.1f", celsius)
print("\(value)°F equals \(formattedValue)°C")
}
}
func testConvertCelsiusToFahrenheitUsingForLoop() {
for value in temperatureValues {
let fahrenheit = convertedToFahrenheit(celsius: value)
let formattedValue = String(format: "%.1f", fahrenheit)
print("\(value)°C equals \(formattedValue)°F")
}
}
}
// MARK: - Functional tests
let format = "\n%5.1f°F equals %5.1f°C "
extension FunctionsLabTests
{
func testConvertFahrenheitToCelsiusUsingMap() {
let celsiusValues = temperatureValues.map { convertedToCelsius(fahrenheit: $0) }
print(celsiusValues)
let formattedValues = celsiusValues.map { String(format: "%.1f", $0) }
print(formattedValues)
}
func testConvertFahrenheitToCelsiusUsingMapReduce1() {
let formattedValues = temperatureValues.map {
String(format: format, $0, convertedToCelsius(fahrenheit: $0))
}
let text = formattedValues.reduce("") { $0 + $1 }
print(text)
}
func testConvertFahrenheitToCelsiusUsingMapReduce2() {
print(temperatureValues
.map { String(format: format, $0, convertedToCelsius(fahrenheit: $0)) }
.reduce("", +))
}
func testConvertFahrenheitToCelsiusUsingTuples() {
let tuples = temperatureValues.map { (F: $0, C: convertedToCelsius(fahrenheit: $0)) }
let text = tuples.reduce("") {
$0 + String(format: format, $1.F, $1.C)
}
print(text)
}
}
| [
-1
] |
7d0e7ce7206bce1a165e5d86f57f0cb0b3837d29 | b7fe76f98d62264c3f4bd33a57a5ec46328154c0 | /LeMond CyclingTests/LeMond_CyclingTests.swift | 4b7022ed3a96d898c9711f14a93d7f00de01694c | [] | no_license | preethiChimerla/LemondApp-Demo | b3e0269c42745659e7f84d8d7b24340f38d8fdaa | 2216ed4fcdf454de800844e032675a2e7bdf26aa | refs/heads/master | 2021-03-19T10:46:16.284336 | 2016-02-19T02:35:25 | 2016-02-19T02:35:25 | 52,055,362 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 919 | swift | //
// LeMond_CyclingTests.swift
// LeMond CyclingTests
//
// Created by Nicolas Wegener on 4/8/15.
// Copyright (c) 2015 LeMond. All rights reserved.
//
import UIKit
import XCTest
class LeMond_CyclingTests: 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.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
| [
276481,
276484,
276489,
276492,
278541,
278550,
276509,
278561,
276543,
280649,
223318,
276581,
43109,
276585,
276589,
227439,
276592,
276606,
276613,
276627,
276631,
227492,
227495,
176314,
276682,
276684,
278742,
155867,
278753,
276709,
276710,
276715,
157944,
227576,
276737,
276753,
278810,
278846,
164162,
278856,
278862,
278863,
6482,
276822,
276831,
276839,
276847,
278898,
278908,
178571,
276891,
276900,
278951,
278954,
278965,
278969,
278985,
279002,
276958,
276962,
276963,
279019,
279022,
276998,
279054,
223769,
277029,
281138,
277048,
301634,
369220,
277066,
277083,
277094,
189037,
277101,
189042,
189043,
277118,
184962,
277133,
133774,
225943,
225944,
164512,
225956,
285353,
225962,
209581,
154294,
277175,
277176,
277182,
277190,
225997,
277198,
226001,
277204,
226004,
226007,
201442,
226019,
226033,
226035,
226036,
226043,
234238,
234241,
226051,
234245,
277254,
203529,
234250,
234253,
234256,
234263,
369432,
105246,
228129,
234280,
277289,
234283,
277294,
226097,
234289,
234301,
234304,
234305,
277316,
234311,
277327,
234323,
234326,
277339,
297822,
174949,
234343,
277354,
234346,
277360,
234361,
226170,
277370,
234366,
234367,
226181,
213894,
277381,
234377,
226189,
234381,
234395,
234404,
226214,
234409,
275371,
226223,
226227,
234419,
234425,
234430,
275397,
234445,
234450,
234451,
234454,
234457,
234466,
277479,
179176,
234477,
234492,
234495,
234498,
234503,
277513,
234506,
234509,
275469,
197647,
295953,
234517,
234530,
234531,
234534,
234539,
277550,
275505,
234555,
234560,
207938,
281666,
277574,
277579,
277585,
234583,
234584,
234594,
277603,
234603,
156785,
275571,
234622,
275585,
275590,
277640,
234632,
302217,
234642,
226451,
226452,
234652,
277665,
275625,
208043,
226481,
277686,
277690,
277694,
275671,
285929,
120055,
277792,
259363,
277800,
113966,
226608,
277809,
277814,
277815,
277821,
277824,
277825,
226624,
142669,
277838,
277841,
222548,
277845,
277852,
218462,
224606,
277856,
142689,
277862,
281962,
277868,
277871,
279919,
277878,
275831,
277882,
277883,
142716,
275839,
226694,
281992,
277897,
277896,
277900,
296338,
277907,
206228,
226711,
226712,
277911,
277919,
277920,
277925,
277927,
370091,
277936,
277939,
277940,
277943,
277946,
277952,
163269,
277957,
296391,
277962,
282060,
277965,
284116,
277974,
277977,
277980,
226781,
277983,
277988,
277993,
278002,
226805,
278005,
278008,
278023,
280077,
204313,
278060,
128583,
226888,
276046,
226897,
226906,
147036,
226910,
370271,
276085,
276088,
278140,
188031,
276100,
276101,
312972,
276116,
276120,
280220,
276129,
278191,
276146,
296628,
276156,
276165,
278214,
276172,
276195,
276210,
278285,
227091,
184086,
278299,
276253,
278307,
288547,
278316,
276279,
276282,
276283,
288574,
276298,
188246,
276318,
276325,
276332,
276350,
227199,
40850,
40853,
44952,
276385,
276394,
276400,
276401,
276408,
276421,
276422,
276430,
276444,
276450,
276454,
276459,
276462,
276468,
276469,
276475,
276478
] |
59ab71355a4eb52d9329ad9e63153ca7ae9b836d | c00ec61bb9d50281d73f90c143dbbe7c028abf53 | /StarterProject/StarterProject/ImageCacheManager.swift | 155b3f513e47c65841737d5c920be2386f2c57e6 | [] | no_license | deepaksrinivas/NewsApp | 546dfb34e55321f183541ed0db49954b89453b63 | aa2f038aaace1e793c1ba1753fd209bc2b01cfa7 | refs/heads/master | 2020-12-03T01:39:51.748441 | 2017-07-13T09:23:32 | 2017-07-13T09:23:32 | 95,852,966 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,601 | swift | //
// ImageCacheManager.swift
// StarterProject
//
// Created by Srinivas, Deepak - Deepak on 6/23/17.
//
//
import UIKit
class ImageCacheManager: NSObject {
static let shared = ImageCacheManager()
private override init() {
super.init()
}
private var imageCaches = [String: UIImage]()
func getImageCache(forUrl url: String) -> UIImage? {
guard let image = imageCaches[url] else {
return nil
}
return image
}
func addCache(image: UIImage, forUrl url: String) {
imageCaches[url] = image
}
func clearImageCache() {
imageCaches.removeAll()
}
@discardableResult func removeCache(forUrl url: String) -> Bool {
if let index = imageCaches.index(forKey: url) {
imageCaches.remove(at: index)
return true
}
return false
}
}
class ImageDowloader {
func getImage(forUrl urlString: String, completion: @escaping(_ image: UIImage?) -> Void) {
let queue = DispatchQueue(label: "com.news.imageCache")
queue.async {
if let url = URL(string: urlString) {
do {
let imageData = try Data(contentsOf: url)
let image = UIImage(data: imageData)
DispatchQueue.main.async {
completion(image)
}
} catch {
DispatchQueue.main.async {
completion(nil)
}
}
}
}
}
}
| [
-1
] |
3f593de958471a83b49005bb300c8d5b962b78f4 | edd1dcab52796346e822cbb54a62cfc4b4aedda4 | /BookShowWithTMDB/Controllers/SignUpViewController.swift | 33a9e69d5cb05fe1f5722377fda2de3088f3be59 | [] | no_license | simranrout/BookShowWithTMDB | f21979643d7b1e9b73364ad7f60ac2a3978937a8 | e27f658203a34f8292d807c8ce6f66039530ae6b | refs/heads/main | 2023-07-24T23:53:43.564092 | 2021-08-30T05:43:03 | 2021-08-30T05:43:03 | 395,628,298 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,685 | swift | //
// SignUpViewController.swift
// BookShowWithTMDB
//
// Created by Simran Rout on 12/08/21.
//
import Foundation
import UIKit
class SignUpViewController: UIViewController , UIImagePickerControllerDelegate , UINavigationControllerDelegate{
@IBOutlet weak var UserNameField: UITextField!
@IBOutlet weak var EmailField: UITextField!
@IBOutlet weak var PasswordField: UITextField!
@IBOutlet weak var ProfileImageView: UIImageView!
@IBOutlet weak var SignUpButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
UserNameField.autocorrectionType = .no
EmailField.autocorrectionType = .no
ProfileImageView.layer.masksToBounds = true
ProfileImageView.layer.cornerRadius = 45
ProfileImageView.contentMode = .scaleAspectFill
SignUpButton.layer.cornerRadius = 12
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
addTapGestureOnImageView()
}
//Action For SignUpButton pressed Create user
@IBAction func SignUpButtonTapped(_ sender: Any) {
guard let username = UserNameField.text ,
let emailID = EmailField.text ,
!emailID.trimmingCharacters(in: .whitespaces).isEmpty , !username.trimmingCharacters(in: .whitespaces).isEmpty ,
username.trimmingCharacters(in: .alphanumerics).isEmpty else {
let alert = UIAlertController(title: "Invalid Input", message: "Please Make Sure to Fill All Fields", preferredStyle: .actionSheet)
present(alert, animated: true
, completion: nil)
return
}
guard let password = PasswordField.text ,
password.count >= 8 ,
!password.trimmingCharacters(in: .whitespaces).isEmpty else {
let alert = UIAlertController(title: "Invalid Input", message: "Password Must Be More Than 8 Character", preferredStyle: .actionSheet)
present(alert, animated: true
, completion: nil)
return
}
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let currentVC = storyboard.instantiateViewController(withIdentifier: "MainViewVC")
currentVC.modalPresentationStyle = .fullScreen
present(currentVC, animated: true, completion: nil)
print("ID and PWD" , EmailField.text , PasswordField.text , UserNameField.text)
}
//Action For SignInButton pressed log in
@IBAction func SignInButtonPressed(_ sender: Any) {
// changViewController(storyBoardID: "SignInVC")
}
//Action For adding Tap gesture to profile image view
func addTapGestureOnImageView(){
/*
Here in this function we have added tap gesture to our
profile image , so that we can know the user tapped on the profileimageview
*/
let tap = UITapGestureRecognizer(target: self, action: #selector(imageViewTapped)) // calling imageViewTapped function
ProfileImageView.isUserInteractionEnabled = true
ProfileImageView.addGestureRecognizer(tap)
}
@objc func imageViewTapped(){
/*
Here in this function we have written logic for event that will
appear after the user have tapped on profileImageView
*/
let alert = UIAlertController(title: "Profile Picture", message: "Add Photo", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Choose Photo", style: .default, handler: {
[weak self] _ in
DispatchQueue.main.async {
let picker = UIImagePickerController()
picker.sourceType = .photoLibrary
picker.allowsEditing = true
picker.delegate = self
self?.present(picker, animated: true, completion: nil)
}
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel , handler: nil))
present(alert, animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true, completion: nil)
guard let profileImage = info[UIImagePickerController.InfoKey.editedImage] else{
return
}
ProfileImageView.image = profileImage as? UIImage
}
}
| [
-1
] |
24138a55e3b9e64126e668745a372c2211ee5f38 | 218d25e743badc8889f4ee0633226d2d6331d994 | /fearless/Modules/Wallet/History/ViewModel/TransactionHistoryViewModelFactory.swift | 81a9a12d0b8d6202502eb620a0cb2928a84bf0c7 | [
"Apache-2.0"
] | permissive | trustex/fearless-iOS | 632a12de84a58c73f5f5d154bf4faf5129bb68c2 | feda447f6c8683de77e9725a5df84d2e9f3a2d7f | refs/heads/master | 2023-06-17T01:42:18.871281 | 2021-04-09T13:24:27 | 2021-04-09T13:24:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,798 | swift | import Foundation
import CommonWallet
import SoraFoundation
import FearlessUtils
enum TransactionHistoryViewModelFactoryError: Error {
case missingAsset
case unsupportedType
}
final class TransactionHistoryViewModelFactory: HistoryItemViewModelFactoryProtocol {
let amountFormatterFactory: NumberFormatterFactoryProtocol
let dateFormatter: LocalizableResource<DateFormatter>
let assets: [WalletAsset]
let iconGenerator: PolkadotIconGenerator = PolkadotIconGenerator()
init(amountFormatterFactory: NumberFormatterFactoryProtocol,
dateFormatter: LocalizableResource<DateFormatter>,
assets: [WalletAsset]) {
self.amountFormatterFactory = amountFormatterFactory
self.dateFormatter = dateFormatter
self.assets = assets
}
func createItemFromData(_ data: AssetTransactionData,
commandFactory: WalletCommandFactoryProtocol,
locale: Locale) throws -> WalletViewModelProtocol {
guard let asset = assets.first(where: { $0.identifier == data.assetId }) else {
throw TransactionHistoryViewModelFactoryError.missingAsset
}
let amount = amountFormatterFactory.createTokenFormatter(for: asset)
.value(for: locale)
.string(from: data.amount.decimalValue)
?? ""
let details = dateFormatter.value(for: locale)
.string(from: Date(timeIntervalSince1970: TimeInterval(data.timestamp)))
let imageViewModel: WalletImageViewModelProtocol?
let icon: UIImage?
if let address = data.peerName {
icon = try? iconGenerator.generateFromAddress(address)
.imageWithFillColor(R.color.colorWhite()!,
size: CGSize(width: 32.0, height: 32.0),
contentScale: UIScreen.main.scale)
} else {
icon = nil
}
if let currentIcon = icon {
imageViewModel = WalletStaticImageViewModel(staticImage: currentIcon)
} else {
imageViewModel = nil
}
guard let transactionType = TransactionType(rawValue: data.type) else {
throw TransactionHistoryViewModelFactoryError.unsupportedType
}
let command = commandFactory.prepareTransactionDetailsCommand(with: data)
return HistoryItemViewModel(title: data.peerName ?? "",
details: details,
amount: amount,
direction: transactionType,
status: data.status,
imageViewModel: imageViewModel,
command: command)
}
}
| [
-1
] |
0e7e92e955c5217e550fa58af9d415bec325c490 | e9e59c8e4c8def4af549156629467b7bacc436f0 | /Package.swift | 90bdbc37dcf5536ac381cb654b0e01579ec7be9e | [
"MIT"
] | permissive | fullc0de/RangeSlider | c7243708b3ebfbdcbdc2910a8259006adf1df3b3 | fb42a43b4848dd40d14848611469a80b400956c3 | refs/heads/master | 2021-01-22T17:39:56.446351 | 2020-06-01T03:08:57 | 2020-06-01T03:08:57 | 85,030,456 | 0 | 2 | null | 2017-03-15T04:53:41 | 2017-03-15T04:53:41 | null | UTF-8 | Swift | false | false | 934 | swift | // swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RangeSlider",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "RangeSlider",
targets: ["RangeSlider"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "RangeSlider",
dependencies: []),
]
)
| [
324608,
340484,
432647,
415758,
35346,
237593,
154138,
369691,
192028,
214553,
217118,
159263,
201762,
224295,
201769,
402986,
201773,
321584,
213040,
321590,
33336,
162361,
321598,
242239,
173122,
201285,
151111,
339016,
378952,
389705,
352333,
332367,
168017,
341075,
248917,
376917,
327255,
296024,
384092,
295520,
392291,
261220,
139366,
345190,
258151,
205930,
194154,
62572,
362606,
373359,
2161,
192626,
298612,
2164,
170616,
347258,
271482,
2172,
2173,
2174,
245376,
339072,
160898,
339075,
2177,
160385,
339078,
201858,
204420,
339081,
357000,
323211,
204425,
339087,
339090,
258708,
339093,
330389,
2199,
264857,
380058,
2204,
222881,
393379,
343204,
2212,
248488,
260266,
315563,
336559,
388788,
240310,
108215,
173752,
153273,
225979,
295100,
350908,
373948,
222400,
315584,
225985,
153283,
315591,
66762,
421067,
257228,
66765,
159439,
256720,
253649,
66770,
339667,
265424,
366292,
223959,
266456,
340697,
266463,
317666,
411879,
177384,
264939,
409324,
337650,
211186,
360178,
194808,
353017,
379128,
395512,
356604,
425724,
178430,
162564,
374022,
208137,
249101,
338189,
338192,
379673,
336670,
311584,
259360,
342306,
201507,
334115,
341797,
348960,
52520,
259368,
248106,
415530,
325932,
273707,
341807,
130352,
347440,
328500,
377150,
250175,
384329,
344393,
244555,
134482,
253781,
339800,
341853,
253789,
416093,
111456,
253793,
198498,
246116,
211813,
357222,
253801,
151919,
21871,
1905,
362866,
337271,
357752,
249211,
189309,
259455,
299394,
269190,
106891,
214412,
349583,
215442,
200085,
355224,
1945,
393626,
321435,
1947,
1948,
253341,
1950,
355233,
1955,
1956,
1957,
178087,
1959,
1963,
258475,
158640,
235957,
1975,
201144,
398776,
225211,
326591,
329151,
344514,
294852,
24517,
254407,
24525,
373198,
1998,
340945,
355281,
184787,
380372,
363478,
45015,
2006,
262620,
319457,
241122,
145899,
247797,
200181,
432631,
432634,
342524,
411133
] |
3f0ccb5ba05cccf08d7ed3a9f59c7280e9a81f26 | 46507adf48f70c9268b9b80d9a631a9b1c68e4d6 | /Carthage/Checkouts/ProcedureKit/Sources/ProcedureKitCloud/CKAcceptSharesOperation.swift | bbe396ce0fb507e5a1c8ebc4fe5566a75b2f5f58 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | yageek/TPGWatch | c52fb79d45387728e12913ba1d05492896940ebc | 64c21fa25623c78da37195199750e7ace84dbcd2 | refs/heads/master | 2020-03-29T20:20:08.064992 | 2018-01-10T15:26:54 | 2018-01-10T15:26:54 | 66,682,359 | 7 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,550 | swift | //
// ProcedureKit
//
// Copyright © 2016 ProcedureKit. All rights reserved.
//
#if SWIFT_PACKAGE
import ProcedureKit
import Foundation
#endif
import CloudKit
/// A generic protocol which exposes the properties used by Apple's CKAcceptSharesOperation.
public protocol CKAcceptSharesOperationProtocol: CKOperationProtocol {
/// The type of the shareMetadatas property
associatedtype ShareMetadatasPropertyType
/// - returns: the share metadatas
var shareMetadatas: ShareMetadatasPropertyType { get set }
/// - returns: the block used to return accepted shares
var perShareCompletionBlock: ((ShareMetadata, Share?, Swift.Error?) -> Void)? { get set }
/// - returns: the completion block used for accepting shares
var acceptSharesCompletionBlock: ((Swift.Error?) -> Void)? { get set }
}
@available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *)
extension CKAcceptSharesOperation: CKAcceptSharesOperationProtocol, AssociatedErrorProtocol {
// The associated error type
public typealias AssociatedError = PKCKError
}
extension CKProcedure where T: CKAcceptSharesOperationProtocol, T: AssociatedErrorProtocol, T.AssociatedError: CloudKitError {
public var shareMetadatas: T.ShareMetadatasPropertyType {
get { return operation.shareMetadatas }
set { operation.shareMetadatas = newValue }
}
public var perShareCompletionBlock: CloudKitProcedure<T>.AcceptSharesPerShareCompletionBlock? {
get { return operation.perShareCompletionBlock }
set { operation.perShareCompletionBlock = newValue }
}
func setAcceptSharesCompletionBlock(_ block: @escaping CloudKitProcedure<T>.AcceptSharesCompletionBlock) {
operation.acceptSharesCompletionBlock = { [weak self] error in
if let strongSelf = self, let error = error {
strongSelf.append(error: PKCKError(underlyingError: error))
}
else {
block()
}
}
}
}
extension CloudKitProcedure where T: CKAcceptSharesOperationProtocol {
/// A typealias for the block type used by CloudKitOperation<CKAcceptSharesOperationType>
public typealias AcceptSharesPerShareCompletionBlock = (T.ShareMetadata, T.Share?, Error?) -> Void
/// A typealias for the block type used by CloudKitOperation<CKAcceptSharesOperationType>
public typealias AcceptSharesCompletionBlock = () -> Void
/// - returns: the share metadatas
public var shareMetadatas: T.ShareMetadatasPropertyType {
get { return current.shareMetadatas }
set {
current.shareMetadatas = newValue
appendConfigureBlock { $0.shareMetadatas = newValue }
}
}
/// - returns: the block used to return accepted shares
public var perShareCompletionBlock: AcceptSharesPerShareCompletionBlock? {
get { return current.perShareCompletionBlock }
set {
current.perShareCompletionBlock = newValue
appendConfigureBlock { $0.perShareCompletionBlock = newValue }
}
}
/**
Before adding the CloudKitOperation instance to a queue, set a completion block
to collect the results in the successful case. Setting this completion block also
ensures that error handling gets triggered.
- parameter block: an AcceptSharesCompletionBlock block
*/
public func setAcceptSharesCompletionBlock(block: @escaping AcceptSharesCompletionBlock) {
appendConfigureBlock { $0.setAcceptSharesCompletionBlock(block) }
}
}
| [
-1
] |
e8f92576f35be545ea5bb30deacce80ca1e55dee | 1db022c86a30df72e898a9bba4ce917c34ca9175 | /NetworkingWorkshop/Bioler Plate Code/Extensions/UITableView+ResusableCell.swift | f06703f83ac5f9268ffda8648ee7d6f928b6916a | [] | no_license | MoazHussam/NetworkingWorkshop | c55a4a571bea8025535f1e8cee2549b45ade2b17 | 986366d7fdb58e77c381cd9374ddf26e5ba1cc93 | refs/heads/master | 2020-04-01T02:22:34.761855 | 2018-10-12T17:25:15 | 2018-10-12T17:25:15 | 152,776,366 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,639 | swift | //
// UITableView+ResusableCell.swift
// AqarMap
//
// Created by Moaz Ahmed on 7/17/17.
// Copyright © 2017 AqarMap. All rights reserved.
//
import UIKit
extension UITableView {
func registerCellNib<T: UITableViewCell>(_: T.Type) where T: NibLoadableView {
let Nib = UINib(nibName: T.NibName, bundle: nil)
register(Nib, forCellReuseIdentifier: T.reuseIdentifier)
}
func registerCellClass<T: UITableViewCell>(_: T.Type) {
register(T.self, forCellReuseIdentifier: T.reuseIdentifier)
}
func registerHeaderFooterClass<T: UITableViewHeaderFooterView>(_: T.Type) {
register(T.self, forHeaderFooterViewReuseIdentifier: T.reuseIdentifier)
}
func registerHeaderFooterNib<T: UITableViewHeaderFooterView>(_: T.Type) where T: NibLoadableView {
let Nib = UINib(nibName: T.NibName, bundle: nil)
register(Nib, forHeaderFooterViewReuseIdentifier: T.reuseIdentifier)
}
func dequeueReusableCell<T: UITableViewCell>(forIndexPath indexPath: IndexPath) -> T {
guard let cell = dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as? T else {
fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)")
}
return cell
}
func dequeueReusableHeaderFooterUIView<T: UITableViewHeaderFooterView>() -> T {
guard let cell = dequeueReusableHeaderFooterView(withIdentifier: T.reuseIdentifier) as? T else {
fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)")
}
return cell
}
}
| [
-1
] |
274e72cb6b6d5b8421c6601e358d20628bed8515 | 99309623fc1e058a96190afb9934907c651d2234 | /Pods/PinpointKit/PinpointKit/PinpointKit/Sources/Core/ScreenshotCell.swift | 72224a5ecb76301aba3ba7c17c592abc271c8b64 | [
"MIT"
] | permissive | jhantelleb/Photo-Viewer-App | d002612ba030f072b0fc3a5a19f6794ab66df729 | 6d9b920a0d466828f74b3d529b2084b1341f6b3e | refs/heads/master | 2021-01-15T14:53:12.179433 | 2017-09-02T21:06:56 | 2017-09-02T21:06:56 | 99,696,464 | 0 | 2 | null | null | null | null | UTF-8 | Swift | false | false | 5,250 | swift | //
// ScreenshotCell.swift
// PinpointKit
//
// Created by Matthew Bischoff on 2/19/16.
// Copyright © 2016 Lickability. All rights reserved.
//
import UIKit
/// A view that displays a screenshot and hint text about how to edit it.
class ScreenshotCell: UITableViewCell {
/// A type of closure that is invoked when a button is tapped.
typealias TapHandler = (_ button: UIButton) -> Void
/**
* A struct encapsulating the information necessary for this view to be displayed.
*/
struct ViewModel {
let screenshot: UIImage
let hintText: String?
let hintFont: UIFont?
}
private enum DesignConstants: CGFloat {
case defaultMargin = 15
case minimumScreenshotPadding = 50
}
/// Set the `viewData` in order to update the receiver’s content.
var viewModel: ViewModel? {
didSet {
screenshotButton.setImage(viewModel?.screenshot.withRenderingMode(.alwaysOriginal), for: UIControlState())
if let screenshot = viewModel?.screenshot {
screenshotButtonHeightConstraint = screenshotButton.heightAnchor.constraint(equalTo: screenshotButton.widthAnchor, multiplier: 1.0 / screenshot.aspectRatio)
}
hintLabel.text = viewModel?.hintText
hintLabel.isHidden = viewModel?.hintText == nil || viewModel?.hintText?.isEmpty == true
hintLabel.font = viewModel?.hintFont
}
}
/// A closure that is invoked when the user taps on the screenshot.
var screenshotButtonTapHandler: TapHandler?
private let stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .center
stackView.spacing = 10
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.layoutMargins = UIEdgeInsets(top: DesignConstants.defaultMargin.rawValue, left: DesignConstants.defaultMargin.rawValue, bottom: DesignConstants.defaultMargin.rawValue, right: DesignConstants.defaultMargin.rawValue)
stackView.isLayoutMarginsRelativeArrangement = true
return stackView
}()
private lazy var screenshotButton: UIButton = {
let button = UIButton(type: .system)
button.layer.borderColor = self.tintColor.cgColor
button.layer.borderWidth = 1
return button
}()
private let hintLabel: UILabel = {
let label = UILabel()
label.textColor = .lightGray
return label
}()
private var screenshotButtonHeightConstraint: NSLayoutConstraint? {
didSet {
oldValue?.isActive = false
screenshotButtonHeightConstraint?.isActive = true
}
}
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setUp()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setUp()
}
// MARK: - UIView
override func tintColorDidChange() {
super.tintColorDidChange()
screenshotButton.layer.borderColor = tintColor.cgColor
}
override func addSubview(_ view: UIView) {
// Prevents the adding of separators to this cell.
let separatorHeight = UIScreen.main.pixelHeight
guard view.frame.height != separatorHeight else {
return
}
super.addSubview(view)
}
// MARK: - ScreenshotCell
private func setUp() {
backgroundColor = .clear
selectionStyle = .none
addSubview(stackView)
stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true
stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
stackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
stackView.addArrangedSubview(screenshotButton)
stackView.addArrangedSubview(hintLabel)
setUpScreenshotButton()
}
private func setUpScreenshotButton() {
screenshotButton.leadingAnchor.constraint(greaterThanOrEqualTo: stackView.leadingAnchor, constant: DesignConstants.minimumScreenshotPadding.rawValue).isActive = true
screenshotButton.trailingAnchor.constraint(lessThanOrEqualTo: stackView.trailingAnchor, constant: -DesignConstants.minimumScreenshotPadding.rawValue).isActive = true
screenshotButtonHeightConstraint = screenshotButton.heightAnchor.constraint(equalTo: screenshotButton.widthAnchor, multiplier: 1.0)
screenshotButton.addTarget(self, action: #selector(ScreenshotCell.screenshotButtonTapped(_:)), for: .touchUpInside)
}
@objc private func screenshotButtonTapped(_ sender: UIButton) {
screenshotButtonTapHandler?(sender)
}
}
private extension UIImage {
var aspectRatio: CGFloat {
guard size.height > 0 else { return 0 }
return size.width / size.height
}
}
| [
-1
] |
35f57ca9a76d35bc3b74d5abbb5ea958d1db7d6c | 1fe891ef6802a1fba0a717778ecadf4442d85857 | /Pods/SQLite.swift/Sources/SQLite/Typed/Coding.swift | 830e8128a20ae0c6e986afabd8466fdcb4600492 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | suruiqiang/iMeiJu_Mac | 7502074f11dcc1e3ed87401ca8154932b0691170 | ccaf3632be5836cf62618ce0d055b355aff5f824 | refs/heads/master | 2023-06-04T22:29:43.002654 | 2021-06-21T13:42:41 | 2021-06-21T13:42:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 15,239 | swift | //
// SQLite.swift
// https://github.com/stephencelis/SQLite.swift
// Copyright © 2014-2015 Stephen Celis.
//
// 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 Foundation
extension QueryType {
/// Creates an `INSERT` statement by encoding the given object
/// This method converts any custom nested types to JSON data and does not handle any sort
/// of object relationships. If you want to support relationships between objects you will
/// have to provide your own Encodable implementations that encode the correct ids.
///
/// - Parameters:
///
/// - encodable: An encodable object to insert
///
/// - userInfo: User info to be passed to encoder
///
/// - otherSetters: Any other setters to include in the insert
///
/// - Returns: An `INSERT` statement fort the encodable object
public func insert(_ encodable: Encodable, userInfo: [CodingUserInfoKey: Any] = [:], otherSetters: [Setter] = []) throws -> Insert {
let encoder = SQLiteEncoder(userInfo: userInfo)
try encodable.encode(to: encoder)
return insert(encoder.setters + otherSetters)
}
/// Creates an `UPDATE` statement by encoding the given object
/// This method converts any custom nested types to JSON data and does not handle any sort
/// of object relationships. If you want to support relationships between objects you will
/// have to provide your own Encodable implementations that encode the correct ids.
///
/// - Parameters:
///
/// - encodable: An encodable object to insert
///
/// - userInfo: User info to be passed to encoder
///
/// - otherSetters: Any other setters to include in the insert
///
/// - Returns: An `UPDATE` statement fort the encodable object
public func update(_ encodable: Encodable, userInfo: [CodingUserInfoKey: Any] = [:], otherSetters: [Setter] = []) throws -> Update {
let encoder = SQLiteEncoder(userInfo: userInfo)
try encodable.encode(to: encoder)
return update(encoder.setters + otherSetters)
}
}
extension Row {
/// Decode an object from this row
/// This method expects any custom nested types to be in the form of JSON data and does not handle
/// any sort of object relationships. If you want to support relationships between objects you will
/// have to provide your own Decodable implementations that decodes the correct columns.
///
/// - Parameter: userInfo
///
/// - Returns: a decoded object from this row
public func decode<V: Decodable>(userInfo: [CodingUserInfoKey: Any] = [:]) throws -> V {
return try V(from: decoder(userInfo: userInfo))
}
public func decoder(userInfo: [CodingUserInfoKey: Any] = [:]) -> Decoder {
return SQLiteDecoder(row: self, userInfo: userInfo)
}
}
/// Generates a list of settings for an Encodable object
private class SQLiteEncoder: Encoder {
class SQLiteKeyedEncodingContainer<MyKey: CodingKey>: KeyedEncodingContainerProtocol {
typealias Key = MyKey
let encoder: SQLiteEncoder
let codingPath: [CodingKey] = []
init(encoder: SQLiteEncoder) {
self.encoder = encoder
}
func superEncoder() -> Swift.Encoder {
fatalError("SQLiteEncoding does not support super encoders")
}
func superEncoder(forKey _: Key) -> Swift.Encoder {
fatalError("SQLiteEncoding does not support super encoders")
}
func encodeNil(forKey key: SQLiteEncoder.SQLiteKeyedEncodingContainer<Key>.Key) throws {
encoder.setters.append(Expression<String?>(key.stringValue) <- nil)
}
func encode(_ value: Int, forKey key: SQLiteEncoder.SQLiteKeyedEncodingContainer<Key>.Key) throws {
encoder.setters.append(Expression(key.stringValue) <- value)
}
func encode(_ value: Bool, forKey key: Key) throws {
encoder.setters.append(Expression(key.stringValue) <- value)
}
func encode(_ value: Float, forKey key: Key) throws {
encoder.setters.append(Expression(key.stringValue) <- Double(value))
}
func encode(_ value: Double, forKey key: Key) throws {
encoder.setters.append(Expression(key.stringValue) <- value)
}
func encode(_ value: String, forKey key: Key) throws {
encoder.setters.append(Expression(key.stringValue) <- value)
}
func encode<T>(_ value: T, forKey key: Key) throws where T: Swift.Encodable {
if let data = value as? Data {
encoder.setters.append(Expression(key.stringValue) <- data)
} else {
let encoded = try JSONEncoder().encode(value)
let string = String(data: encoded, encoding: .utf8)
encoder.setters.append(Expression(key.stringValue) <- string)
}
}
func encode(_ value: Int8, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an Int8 is not supported"))
}
func encode(_ value: Int16, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an Int16 is not supported"))
}
func encode(_ value: Int32, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an Int32 is not supported"))
}
func encode(_ value: Int64, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an Int64 is not supported"))
}
func encode(_ value: UInt, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an UInt is not supported"))
}
func encode(_ value: UInt8, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an UInt8 is not supported"))
}
func encode(_ value: UInt16, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an UInt16 is not supported"))
}
func encode(_ value: UInt32, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an UInt32 is not supported"))
}
func encode(_ value: UInt64, forKey _: Key) throws {
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "encoding an UInt64 is not supported"))
}
func nestedContainer<NestedKey>(keyedBy _: NestedKey.Type, forKey _: Key) -> KeyedEncodingContainer<NestedKey> where NestedKey: CodingKey {
fatalError("encoding a nested container is not supported")
}
func nestedUnkeyedContainer(forKey _: Key) -> UnkeyedEncodingContainer {
fatalError("encoding nested values is not supported")
}
}
fileprivate var setters: [SQLite.Setter] = []
let codingPath: [CodingKey] = []
let userInfo: [CodingUserInfoKey: Any]
init(userInfo: [CodingUserInfoKey: Any]) {
self.userInfo = userInfo
}
func singleValueContainer() -> SingleValueEncodingContainer {
fatalError("not supported")
}
func unkeyedContainer() -> UnkeyedEncodingContainer {
fatalError("not supported")
}
func container<Key>(keyedBy _: Key.Type) -> KeyedEncodingContainer<Key> where Key: CodingKey {
return KeyedEncodingContainer(SQLiteKeyedEncodingContainer(encoder: self))
}
}
private class SQLiteDecoder: Decoder {
class SQLiteKeyedDecodingContainer<MyKey: CodingKey>: KeyedDecodingContainerProtocol {
typealias Key = MyKey
let codingPath: [CodingKey] = []
let row: Row
init(row: Row) {
self.row = row
}
var allKeys: [Key] {
return row.columnNames.keys.compactMap({ Key(stringValue: $0) })
}
func contains(_ key: Key) -> Bool {
return row.hasValue(for: key.stringValue)
}
func decodeNil(forKey key: Key) throws -> Bool {
return !contains(key)
}
func decode(_: Bool.Type, forKey key: Key) throws -> Bool {
return try row.get(Expression(key.stringValue))
}
func decode(_: Int.Type, forKey key: Key) throws -> Int {
return try row.get(Expression(key.stringValue))
}
func decode(_ type: Int8.Type, forKey _: Key) throws -> Int8 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an Int8 is not supported"))
}
func decode(_ type: Int16.Type, forKey _: Key) throws -> Int16 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an Int16 is not supported"))
}
func decode(_ type: Int32.Type, forKey _: Key) throws -> Int32 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an Int32 is not supported"))
}
func decode(_ type: Int64.Type, forKey _: Key) throws -> Int64 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt64 is not supported"))
}
func decode(_ type: UInt.Type, forKey _: Key) throws -> UInt {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt is not supported"))
}
func decode(_ type: UInt8.Type, forKey _: Key) throws -> UInt8 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt8 is not supported"))
}
func decode(_ type: UInt16.Type, forKey _: Key) throws -> UInt16 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt16 is not supported"))
}
func decode(_ type: UInt32.Type, forKey _: Key) throws -> UInt32 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt32 is not supported"))
}
func decode(_ type: UInt64.Type, forKey _: Key) throws -> UInt64 {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an UInt64 is not supported"))
}
func decode(_: Float.Type, forKey key: Key) throws -> Float {
return Float(try row.get(Expression<Double>(key.stringValue)))
}
func decode(_: Double.Type, forKey key: Key) throws -> Double {
return try row.get(Expression(key.stringValue))
}
func decode(_: String.Type, forKey key: Key) throws -> String {
return try row.get(Expression(key.stringValue))
}
func decode<T>(_ type: T.Type, forKey key: Key) throws -> T where T: Swift.Decodable {
if type == Data.self {
let data = try row.get(Expression<Data>(key.stringValue))
return data as! T
}
guard let JSONString = try self.row.get(Expression<String?>(key.stringValue)) else {
throw DecodingError.typeMismatch(type, DecodingError.Context(codingPath: codingPath, debugDescription: "an unsupported type was found"))
}
guard let data = JSONString.data(using: .utf8) else {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "invalid utf8 data found"))
}
return try JSONDecoder().decode(type, from: data)
}
func nestedContainer<NestedKey>(keyedBy _: NestedKey.Type, forKey _: Key) throws -> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding nested containers is not supported"))
}
func nestedUnkeyedContainer(forKey _: Key) throws -> UnkeyedDecodingContainer {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding unkeyed containers is not supported"))
}
func superDecoder() throws -> Swift.Decoder {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding super encoders containers is not supported"))
}
func superDecoder(forKey _: Key) throws -> Swift.Decoder {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding super decoders is not supported"))
}
}
let row: Row
let codingPath: [CodingKey] = []
let userInfo: [CodingUserInfoKey: Any]
init(row: Row, userInfo: [CodingUserInfoKey: Any]) {
self.row = row
self.userInfo = userInfo
}
func container<Key>(keyedBy _: Key.Type) throws -> KeyedDecodingContainer<Key> where Key: CodingKey {
return KeyedDecodingContainer(SQLiteKeyedDecodingContainer(row: row))
}
func unkeyedContainer() throws -> UnkeyedDecodingContainer {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding an unkeyed container is not supported"))
}
func singleValueContainer() throws -> SingleValueDecodingContainer {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: codingPath, debugDescription: "decoding a single value container is not supported"))
}
}
| [
325856,
218639,
439546,
407581,
55902
] |
6b07719d69c6f82a3a2b738ed5e709380257f928 | c952a32fb63f9039662bed00d314a4488127c5b2 | /Sources/MagickWand/Wand/PixelWand/PixelWand+Color.swift | b9ad209741567f041bf7dd882a7e865962b38b7f | [
"MIT"
] | permissive | drewag/MagickWand | 398101d7c990a369c34606786210db42fa4bde83 | a8b78b2c7762c5ce2216277c803db73883b4e8df | refs/heads/master | 2021-01-19T19:54:22.746618 | 2019-10-16T02:48:16 | 2019-10-16T02:59:59 | 88,460,874 | 0 | 0 | null | 2017-04-17T02:46:50 | 2017-04-17T02:46:50 | null | UTF-8 | Swift | false | false | 5,072 | swift | // PixelWand.swift
//
// Copyright (c) 2016 Sergey Minakov
//
// 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 Foundation
#if os(Linux)
import CMagickWandLinux
#else
import CMagickWandOSX
#endif
extension PixelWand {
public struct Colors {
private var pointer: OpaquePointer
init(_ wand: PixelWand) {
self.init(wand.pointer)
}
init(_ pointer: OpaquePointer) {
self.pointer = pointer
}
public var rgba: MagickWand.RGBA {
get {
let red = PixelGetRed(self.pointer)
let green = PixelGetGreen(self.pointer)
let blue = PixelGetBlue(self.pointer)
let alpha = PixelGetAlpha(self.pointer)
return MagickWand.RGBA(red, green, blue, alpha)
}
set {
PixelSetRed(self.pointer, newValue.red)
PixelSetGreen(self.pointer, newValue.green)
PixelSetBlue(self.pointer, newValue.blue)
PixelSetAlpha(self.pointer, newValue.alpha)
}
}
public var hsl: MagickWand.HSL {
get {
var hue: Double = 0
var saturation: Double = 0
var lightness: Double = 0
PixelGetHSL(self.pointer, &hue, &saturation, &lightness)
return MagickWand.HSL(hue, saturation, lightness)
}
set {
PixelSetHSL(self.pointer, newValue.hue, newValue.saturation, newValue.lightness)
}
}
public var cmy: MagickWand.CMY {
get {
let (cyan, magenta, yellow) = (
PixelGetCyan(self.pointer),
PixelGetMagenta(self.pointer),
PixelGetYellow(self.pointer)
)
return MagickWand.CMY(cyan, magenta, yellow)
}
set {
PixelSetCyan(self.pointer, newValue.cyan)
PixelSetMagenta(self.pointer, newValue.magenta)
PixelSetYellow(self.pointer, newValue.yellow)
}
}
public var black: Double {
get {
return PixelGetBlack(self.pointer)
}
set {
PixelSetBlack(self.pointer, newValue)
}
}
public var string: String? {
return MagickWand.getString(from: self.pointer, using: PixelGetColorAsString)
}
public var normalizedString: String? {
return MagickWand.getString(from: self.pointer, using: PixelGetColorAsNormalizedString)
}
public var count: Int {
get {
return PixelGetColorCount(self.pointer)
}
set {
PixelSetColorCount(self.pointer, newValue)
}
}
public var info: MagickWand.ColorInfo {
get {
var infoPacket = MagickPixelPacket()
#if !os(Linux)
PixelGetMagickColor(self.pointer, &infoPacket)
#endif
return MagickWand.ColorInfo(infoPacket)
}
set {
var packet = newValue.info
PixelSetMagickColor(self.pointer, &packet)
}
}
}
public var colors: Colors {
get {
return Colors(self)
}
set { }
// As `Colors` struct receives `PixelWand` pointer on initialization
// A color will be changed without any other code changes.
// TODO: This part should probably be changed.
}
public var index: Quantum {
get {
return PixelGetIndex(self.pointer)
}
set {
PixelSetIndex(self.pointer, newValue)
}
}
}
| [
-1
] |
725440d87a0e72ff01119d7fc9e7f80a54a9cb7f | 75e4f85c079b4ebf2f657a6e5349580f611f6f59 | /UnitTestingLab/UnitTestingLab/EP1DetailViewController.swift | 84fd83131052bf82ab26f0b00309354517bd96e5 | [] | no_license | bienbenidoangeles/Pursuit-Core-iOS-Introduction-to-Unit-Testing-Lab | dc4ddf1f0feea50767db76e2c321a373ec98b902 | 4bf7cbca31f93336069b0a9e8615227607328491 | refs/heads/master | 2020-09-23T09:43:28.418269 | 2019-12-03T07:14:57 | 2019-12-03T07:14:57 | 225,468,963 | 0 | 0 | null | 2019-12-02T21:07:38 | 2019-12-02T21:07:37 | null | UTF-8 | Swift | false | false | 1,050 | swift | //
// EP1DetailViewController.swift
// UnitTestingLab
//
// Created by Bienbenido Angeles on 12/2/19.
// Copyright © 2019 Bienbenido Angeles. All rights reserved.
//
import UIKit
class EP1DetailViewController: UIViewController {
@IBOutlet weak var punchLineLabel: UILabel!
var passedJokesObj: JokesDataModel?
override func viewDidLoad() {
super.viewDidLoad()
updateUI()
// Do any additional setup after loading the view.
}
func updateUI(){
guard let validJoke = passedJokesObj else {
fatalError("check prepare(for: segue)")
}
punchLineLabel.text = validJoke.punchline
}
/*
// 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
] |
6734e2b8c34bf53c9f14abe1e397ea90cae8493a | be0029bce92bd2534a7c5b1e0a47092fa16b1416 | /Demoes/Demoes/Share/shareViewController.swift | ef5c50618306b3303f9f616419d6ac062114e826 | [
"Apache-2.0"
] | permissive | Gitliming/Demoes | 23c2a05eb282390d2a7fd5254137f7514793366b | 5ff9ca2757811ff0b8143535906f324d72549cba | refs/heads/master | 2020-06-15T23:19:27.928931 | 2018-03-24T15:28:38 | 2018-03-24T15:28:38 | 75,253,535 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,883 | swift | //
// shareViewController.swift
// Dispersive switch
//
// Created by xpming on 2016/11/29.
// Copyright © 2016年 xpming. All rights reserved.
//
import UIKit
class shareViewController: BaseViewController {
@IBOutlet weak var shareContentView: UIView!
var firstY:CGFloat?
override func viewDidLoad() {
super.viewDidLoad()
setUI()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setUI() {
view.frame = UIScreen.main.bounds
view.layoutIfNeeded()
shareContentView.layer.contents = UIImage(named: "share_bg")?.cgImage
firstY = shareContentView.frame.origin.y
shareContentView.frame.origin.y = view.frame.maxY
animating(self.parent!)
bindShareAction()
}
@IBAction func viewTap(_ sender: AnyObject) {
animating(self.parent!)
}
func animating(_ parentCtrl:UIViewController) {
if shareContentView.frame.maxY == view.frame.maxY{
UIView.animate(withDuration: 0.3, animations: {
self.shareContentView.frame.origin.y = self.view.frame.maxY
}, completion: { (true) in
UIViewController.unshowViewController(parentCtrl, VC: self)
})
}else{
UIView.animate(withDuration: 0.3, animations: {
self.shareContentView.frame.origin.y = self.firstY!
})
}
}
//MARK:-- 绑定分享点击事件
func bindShareAction (){
let contentViews = shareContentView.subviews
for v in contentViews {
for btn in v.subviews{
if btn.isKind(of: UIButton.self){
(btn as! UIButton).addTarget(self, action: #selector(shareViewController.shareAction(_:)), for: .touchUpInside)
}
}
}
}
func shareAction (_ button:UIButton){
switch button.tag {
case 0://QQ
print(button.tag)
// for i in 0 ..< 10000 {
// if i % 1 == 0
// && i % 2 == 1
// && i % 3 == 0
// && i % 4 == 1
// && i % 5 == 1
// && i % 6 == 3
// && i % 7 == 0
// && i % 8 == 1
// && i % 9 == 0 {
// print("符合条件的\(i)")
// }
// }
case 1://QZone
print(button.tag)
case 2://weichat
print(button.tag)
case 3://friends
print(button.tag)
case 4://xinlang
print(button.tag)
case 5://wangye
print(button.tag)
case 6://refresh
print(button.tag)
case 7://youjian
print(button.tag)
default: break
}
}
}
| [
-1
] |
692e6da758e424117b858ba235d799064df1d07e | 3961daf0ba9c7c4f9f615f2ad4d352625ecd5513 | /macgui/Views and View Controllers/Canvas View/CenteringClipView.swift | 9c274ec089ef4dc13cdcd817df88fd309d731c62 | [] | no_license | svetakrasikova/macgui | 220c7235946b3bccefaa76b42296acd24ac4b2f1 | b0f29558ea7b1f0d8bb6ba7bf045035ac360dd24 | refs/heads/master | 2023-06-08T21:53:29.855684 | 2022-02-03T22:19:06 | 2022-02-03T22:19:06 | 168,780,629 | 3 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 8,417 | swift | //
// CenteringClipView.swift
// SpinReel
//
// Sample code project: Exhibition: An Adaptive OS X App
// Abstract:
// Contains the definition for `CenteringClipView` which is a specialized clip view subclass to center its document.
//
// Version: 1.0
//
//
// IMPORTANT: This Apple software is supplied to you by Apple
// Inc. ("Apple") in consideration of your agreement to the following
// terms, and your use, installation, modification or redistribution of
// this Apple software constitutes acceptance of these terms. If you do
// not agree with these terms, please do not use, install, modify or
// redistribute this Apple software.
//
//
// In consideration of your agreement to abide by the following terms, and
// subject to these terms, Apple grants you a personal, non-exclusive
// license, under Apple's copyrights in this original Apple software (the
// "Apple Software"), to use, reproduce, modify and redistribute the Apple
// Software, with or without modifications, in source and/or binary forms;
// provided that if you redistribute the Apple Software in its entirety and
// without modifications, you must retain this notice and the following
// text and disclaimers in all such redistributions of the Apple Software.
// Neither the name, trademarks, service marks or logos of Apple Inc. may
// be used to endorse or promote products derived from the Apple Software
// without specific prior written permission from Apple. Except as
// expressly stated in this notice, no other rights or licenses, express or
// implied, are granted by Apple herein, including but not limited to any
// patent rights that may be infringed by your derivative works or by other
// works in which the Apple Software may be incorporated.
//
//
// The Apple Software is provided by Apple on an "AS IS" basis. APPLE
// MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
// THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
// OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
//
//
// IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
// MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
// AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
// STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (C) 2015 Apple Inc. All Rights Reserved.
import Cocoa
/**
`CenteringClipView` is a clip view subclass that centers smaller documents views
within its inset clip bounds (as described by the set `contentInsets`).
*/
class CenteringClipView: NSClipView {
override func constrainBoundsRect(_ proposedBounds: NSRect) -> NSRect {
guard let documentView = documentView else { return super.constrainBoundsRect(proposedBounds) }
var newClipBoundsRect = super.constrainBoundsRect(proposedBounds)
// Get the `contentInsets` scaled to the future bounds size.
let insets = convertedContentInsetsToProposedBoundsSize(proposedBoundsSize: newClipBoundsRect.size)
// Get the insets in terms of the view geometry edges, accounting for flippedness.
let minYInset = isFlipped ? insets.top : insets.bottom
let maxYInset = isFlipped ? insets.bottom : insets.top
let minXInset = insets.left
let maxXInset = insets.right
/*
Get and outset the `documentView`'s frame by the scaled contentInsets.
The outset frame is used to align and constrain the `newClipBoundsRect`.
*/
let documentFrame = documentView.frame
let outsetDocumentFrame = NSRect(x: documentFrame.minX - minXInset,
y: documentFrame.minY - minYInset,
width: (documentFrame.width + (minXInset + maxXInset)),
height: documentFrame.height + (minYInset + maxYInset))
if newClipBoundsRect.width > outsetDocumentFrame.width {
/*
If the clip bounds width is larger than the document, center the
bounds around the document.
*/
newClipBoundsRect.origin.x = outsetDocumentFrame.minX - (newClipBoundsRect.width - outsetDocumentFrame.width) / 2.0
}
else if newClipBoundsRect.width < outsetDocumentFrame.width {
/*
Otherwise, the document is wider than the clip rect. Make sure that
the clip rect stays within the document frame.
*/
if newClipBoundsRect.maxX > outsetDocumentFrame.maxX {
// The clip rect is outside the maxX edge of the document, bring it in.
newClipBoundsRect.origin.x = outsetDocumentFrame.maxX - newClipBoundsRect.width
}
else if newClipBoundsRect.minX < outsetDocumentFrame.minX {
// The clip rect is outside the minX edge of the document, bring it in.
newClipBoundsRect.origin.x = outsetDocumentFrame.minX
}
}
if newClipBoundsRect.height > outsetDocumentFrame.height {
/*
If the clip bounds height is larger than the document, center the
bounds around the document.
*/
newClipBoundsRect.origin.y = outsetDocumentFrame.minY - (newClipBoundsRect.height - outsetDocumentFrame.height) / 2.0
}
else if newClipBoundsRect.height < outsetDocumentFrame.height {
/*
Otherwise, the document is taller than the clip rect. Make sure
that the clip rect stays within the document frame.
*/
if newClipBoundsRect.maxY > outsetDocumentFrame.maxY {
// The clip rect is outside the maxY edge of the document, bring it in.
newClipBoundsRect.origin.y = outsetDocumentFrame.maxY - newClipBoundsRect.height
}
else if newClipBoundsRect.minY < outsetDocumentFrame.minY {
// The clip rect is outside the minY edge of the document, bring it in.
newClipBoundsRect.origin.y = outsetDocumentFrame.minY
}
}
return backingAlignedRect(newClipBoundsRect, options: .alignAllEdgesNearest)
}
/**
The `contentInsets` scaled to the scale factor of a new potential bounds
rect. Used by `constrainBoundsRect(NSRect)`.
*/
private func convertedContentInsetsToProposedBoundsSize(proposedBoundsSize: NSSize) -> NSEdgeInsets {
// Base the scale factor on the width scale factor to the new proposedBounds.
let fromBoundsToProposedBoundsFactor = bounds.width > 0 ? (proposedBoundsSize.width / bounds.width) : 1.0
// Scale the set `contentInsets` by the width scale factor.
var newContentInsets = contentInsets
newContentInsets.top *= fromBoundsToProposedBoundsFactor
newContentInsets.left *= fromBoundsToProposedBoundsFactor
newContentInsets.bottom *= fromBoundsToProposedBoundsFactor
newContentInsets.right *= fromBoundsToProposedBoundsFactor
return newContentInsets
}
}
| [
-1
] |
43940178bed8935dfa111127da88b55e28b9b085 | aec85402c117af58d108e580e7542917d4394cac | /Basic TabView/Controller/BlueViewController.swift.swift | 52408fc1a6dbdbaef553b71375ad987135e532ff | [] | no_license | JB3991/Basic-TabView | c8a39f7fb02799a7f8c87a47dfd1dbd57c3172f5 | a04d7ed6d7c60c6923070b1f9ac8c2d0f93885e2 | refs/heads/main | 2023-02-24T11:48:16.882756 | 2021-01-26T16:50:14 | 2021-01-26T16:50:14 | 331,377,109 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 263 | swift | //
// BlueViewController.swift.swift
// Basic TabView
//
// Created by Jonathan Burnett on 20/01/2021.
//
import Foundation
import UIKit
class BlueViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
| [
-1
] |
1edb355d34645546c9d36b12a4e9013d945511a0 | 222d8272c91e87fb6e2c939c9af46d4fd9d330db | /LibPretixSync/SecurityProfiles/PXDeviceInitialization.swift | e35883f2b1f3b13048a46e607d6576fdc30a49b3 | [
"Apache-2.0",
"MIT"
] | permissive | pretix/pretixscan-ios | d8ae1c8b9b1eb52e1fd6da9bfe7c339e37e143f3 | 2636c8917148a0154c302704eca5ac3de6dba12c | refs/heads/master | 2023-06-08T04:50:03.348062 | 2023-06-05T08:13:49 | 2023-06-05T08:13:49 | 195,275,512 | 11 | 8 | Apache-2.0 | 2023-09-10T21:00:15 | 2019-07-04T16:48:26 | Swift | UTF-8 | Swift | false | false | 2,167 | swift | //
// PXDeviceInitialization.swift
// pretixSCAN
//
// Created by Konstantin Kostov on 04/02/2022.
// Copyright © 2022 rami.io. All rights reserved.
//
import Foundation
import UIKit
final class PXDeviceInitialization {
private weak var configStore: ConfigStore?
var hardwareBrand: String = "Apple"
var hardwareModel: String = UIDevice.current.modelName
var softwareBrand: String = Bundle.main.infoDictionary!["CFBundleName"] as? String ?? "n/a"
var softwareVersion: String = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String ?? "n/a"
init(_ config: ConfigStore) {
self.configStore = config
}
func needsToUpdate() -> Bool {
guard let publishedSoftwareVersion = configStore?.publishedSoftwareVersion else {
// no published version
logger.warning("Needs to update: no known published version")
return true
}
logger.debug("Needs to update comparing '\(publishedSoftwareVersion)' to current '\(self.softwareVersion)'")
return softwareVersion.compare(publishedSoftwareVersion) == .orderedDescending
}
func setPublishedVersion(_ version: String) {
logger.debug("Setting last published version to '\(version)'")
configStore?.publishedSoftwareVersion = version
}
func getUpdateRequest() -> DeviceUpdateRequest? {
return DeviceUpdateRequest(hardwareBrand: hardwareBrand, hardwareModel: hardwareModel, softwareBrand: softwareBrand, softwareVersion: softwareVersion)
}
}
public struct DeviceUpdateRequest: Codable, Equatable {
/// The hardware manufacturer
public let hardwareBrand: String
/// The device model
public let hardwareModel: String
/// The software manufacturer
public let softwareBrand: String
/// The software version
public let softwareVersion: String
private enum CodingKeys: String, CodingKey {
case hardwareBrand = "hardware_brand"
case hardwareModel = "hardware_model"
case softwareBrand = "software_brand"
case softwareVersion = "software_version"
}
}
| [
-1
] |
3a3558b728cf0d2c2da2f93ef49ce6ebf371c4dc | 6185fe558337decb6c86630682246c35ea907b7a | /Virtual Tourist/Virtual Tourist/Controllers/MapViewController.swift | 6501693f65b814bd0dd1f61ca43a8277b98e53f2 | [
"MIT"
] | permissive | TiagoMaiaL/Virtual-Tourist | 9038d89904b9169961c938300e783d1d5ac7866b | 54c31daff9da9b7f20c393dab1e45378e9177fa5 | refs/heads/master | 2020-04-22T06:53:25.317518 | 2019-04-09T16:06:04 | 2019-04-09T16:06:04 | 170,205,483 | 4 | 5 | null | null | null | null | UTF-8 | Swift | false | false | 10,235 | swift | //
// MapViewController.swift
// Virtual Tourist
//
// Created by Tiago Maia Lopes on 11/02/19.
// Copyright © 2019 Tiago Maia Lopes. All rights reserved.
//
import UIKit
import MapKit
import CoreData
/// The view controller showing the pins entered by the user in a map.
class MapViewController: UIViewController {
// MARK: Properties
/// The data controller of the app.
var dataController: DataController!
/// The pin store used to create a new pin.
var pinStore: PinMOStoreProtocol!
/// The album store used to handle the photos for a pin.
var albumStore: AlbumMOStoreProtocol!
/// The service in charge of getting images from Flickr and turning them into photos inside an album.
var flickrService: FlickrServiceProtocol!
/// The main map view.
@IBOutlet weak var mapView: MKMapView!
// MARK: Life Cycle
deinit {
stopObservingNotifications()
}
override func viewDidLoad() {
super.viewDidLoad()
precondition(dataController != nil)
precondition(pinStore != nil)
precondition(albumStore != nil)
precondition(flickrService != nil)
configureNavigationController()
startObservingNotification(withName: .NSManagedObjectContextDidSave,
usingSelector: #selector(updateViewContext(fromNotification:)))
mapView.delegate = self
mapView.setRegion(
MKCoordinateRegion(center: mapView.region.center,
span: MKCoordinateSpan(latitudeDelta: 60, longitudeDelta: 40)
), animated: false)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
displayPins()
}
// MARK: Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == SegueIdentifiers.ShowPhotoAlbumManager {
guard let selectedPinAnnotation = mapView.selectedAnnotations.first as? PinAnnotation,
let albumManagerController = segue.destination as? PhotoAlbumManagerViewController else {
assertionFailure("Couldn't prepare the album controller.")
return
}
let selectedPin = selectedPinAnnotation.pin
albumManagerController.pin = selectedPin
albumManagerController.flickrService = flickrService
albumManagerController.dataController = dataController
albumManagerController.photoStore = albumStore.photoStore
}
}
// MARK: Actions
/// Updates the view context with the changes of any background context.
@objc private func updateViewContext(fromNotification notification: Notification) {
dataController.viewContext.mergeChanges(fromContextDidSave: notification)
}
@IBAction func addPin(_ sender: UILongPressGestureRecognizer) {
switch sender.state {
case .began:
let pressMapCoordinate = mapView.convert(sender.location(in: mapView), toCoordinateFrom: mapView)
createPin(forCoordinate: pressMapCoordinate)
default:
break
}
}
// MARK: Imperatives
/// Creates a new pin and persists it using the passed coordinate.
/// - Parameter coordinate: the coordinate location of the user's press gesture.
private func createPin(forCoordinate coordinate: CLLocationCoordinate2D) {
// Geocode the coordinate to get more details about the location.
let geocoder = CLGeocoder()
let location = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
geocoder.reverseGeocodeLocation(location) { placemarks, error in
DispatchQueue.main.async {
var locationName: String?
if let placemark = placemarks?.first {
locationName = placemark.placeName
}
do {
let createdPin = self.pinStore.createPin(
usingContext: self.dataController.viewContext,
withLocationName: locationName,
andCoordinate: coordinate
)
try self.dataController.save()
self.flickrService.populatePinWithPhotosFromFlickr(createdPin) { createdPin, error in
guard error == nil, createdPin != nil else {
/* Fail silently when in the map controller. */
return
}
}
self.display(createdPin: createdPin)
} catch {
// TODO: Alert the user of the error.
}
}
}
}
/// Displays the persisted pins on the map.
private func displayPins() {
mapView.removeAllAnnotations()
// Make the fetch for pins and add them to the map.
let pinsRequest: NSFetchRequest<PinMO> = PinMO.fetchRequest()
pinsRequest.sortDescriptors = [
NSSortDescriptor(key: "creationDate", ascending: false)
]
dataController.viewContext.perform {
do {
let pins = try self.dataController.viewContext.fetch(pinsRequest)
self.mapView.addAnnotations(pins.map { PinAnnotation(pin: $0) })
} catch {
let alert = self.makeAlertController(withTitle: "Error", andMessage: "Couldn't load the added pins.")
self.present(alert, animated: true)
}
}
}
/// Adds a recently created Pin instance to the map.
/// - Parameter createdPin: the pin recently created by the user.
private func display(createdPin pin: PinMO) {
mapView.addAnnotation(PinAnnotation(pin: pin))
}
/// Configures the navigation controller to set up the delegate and other attributes.
private func configureNavigationController() {
navigationController?.delegate = self
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}
}
extension MapViewController: MKMapViewDelegate {
// MARK: MKMapViewDelegate methods
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
guard view.annotation is PinAnnotation else {
return
}
performSegue(withIdentifier: SegueIdentifiers.ShowPhotoAlbumManager, sender: self)
}
}
extension MapViewController: UINavigationControllerDelegate {
// MARK: Navigation controller delegate methods
func navigationController(
_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController
) -> UIViewControllerAnimatedTransitioning? {
switch operation {
case .push:
return PushMapDetailsAnimator()
case .pop:
return PopMapDetailsAnimator()
default:
return nil
}
}
}
private class PushMapDetailsAnimator: NSObject, UIViewControllerAnimatedTransitioning {
// MARK: UIViewControllerAnimatedTransitioning Delegate methods
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.5
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
let toView = transitionContext.view(forKey: .to)!
// Configure the details map to have the same position as the map listing the pins.
guard let currentMapController = transitionContext.viewController(forKey: .from) as? MapViewController else {
preconditionFailure("The from controller must be a map controller.")
}
let mapRegion = currentMapController.mapView.region
guard let detailsViewController = transitionContext.viewController(forKey: .to) as? PhotoAlbumManagerViewController else {
preconditionFailure("The from controller must be a album manager controller.")
}
detailsViewController.albumDisplayerController.detailsMapController.mapView.setRegion(mapRegion, animated: false)
toView.alpha = 0
containerView.addSubview(toView)
UIView.animate(withDuration: 0.5, animations: {
toView.alpha = 1
}) { _ in
transitionContext.completeTransition(true)
}
}
}
private class PopMapDetailsAnimator: NSObject, UIViewControllerAnimatedTransitioning {
// MARK: UIViewControllerAnimatedTransitioning Delegate methods
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.5
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
let toView = transitionContext.view(forKey: .to)!
guard let currentDetailsViewController = transitionContext.viewController(forKey: .from) as? PhotoAlbumManagerViewController else {
preconditionFailure("The from controller must be an album manager controller.")
}
let detailsMapRegion = currentDetailsViewController.albumDisplayerController.detailsMapController.mapView.region
guard let mapViewController = transitionContext.viewController(forKey: .to) as? MapViewController else {
preconditionFailure("The from controller must be a map view controller.")
}
mapViewController.mapView.setRegion(detailsMapRegion, animated: false)
toView.alpha = 0
containerView.addSubview(toView)
UIView.animate(withDuration: 0.5, animations: {
toView.alpha = 1
}) { _ in
mapViewController.mapView.setRegion(
MKCoordinateRegion(center: detailsMapRegion.center,
span: MKCoordinateSpan(latitudeDelta: 60, longitudeDelta: 40)),
animated: true
)
transitionContext.completeTransition(true)
}
}
}
| [
-1
] |
66577a9f8f2043f63c198005eeb85d213d650677 | fe879b7ef13d2be0a710a5d7795631076975b0f7 | /DenemeInstagram/ViewController.swift | bb0dc77004df4c7c799315d48e4fbf3eb598e66c | [] | no_license | BekirTura/DenemeInstagram | 73c13e3223b024560c64bbe86561e727dea50106 | 4c6992b029ee36a1a6bb9cb5a03b50455a700a55 | refs/heads/master | 2021-06-18T07:13:29.729600 | 2017-07-06T07:18:33 | 2017-07-06T07:18:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,482 | swift | //
// ViewController.swift
// DenemeInstagram
//
// Created by Done on 05/06/2017.
// Copyright © 2017 Done. All rights reserved.
//
import UIKit
import Parse
class ViewController: UIViewController {
@IBOutlet weak var picture: UIImageView!
let message = String()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//
/*
let data = UIImageJPEGRepresentation(picture.image!, 0.5)
let file = PFFile(name: "picture.jpg", data: data!)
let object = PFObject(className:"Message")
object["sender"] = "Bekir"
object["receiver"] = "Tura"
object["picture"] = file
object.saveInBackground { (done, error) in
if(done){
print("saved");
}
}*/
// Retrieve data
let information = PFQuery(className:"Message")
information.findObjectsInBackground { (objects:[PFObject]!, error) in
for object in objects!{
print(object)
(object["picture"] as AnyObject).getDataInBackground(block: { (data, error) in
self.picture.image = UIImage(data:data!)
})
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
| [
-1
] |
f07afb714dfc206fada4fb9c1a51aaf844d0a617 | 145b0d1316c7eb3ec9370234fd59cd87f250e2a7 | /Spotify/Resources/AppDelegate.swift | 4cb7d3e289fe37f265b8123872ea669979e40a41 | [] | no_license | EvelDevel/Spotify | b509df5c5993ddc74f7511695eae4446b5209f32 | c82718d49ce537b3bc30ecee8abfdaaf13c6a1ee | refs/heads/main | 2023-04-12T15:08:39.732076 | 2021-03-07T11:53:25 | 2021-03-07T11:53:25 | 345,332,917 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,516 | swift | //
// AppDelegate.swift
// Spotify
//
// Created by Евгений Никитин on 07.03.2021.
//
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
self.window = window
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.
}
}
| [
332161,
286850,
396551,
361868,
383374,
345267,
264660,
225076,
345915,
358941,
252799
] |
5e5952f042643a2b729960320dacf7d3ce6c413d | 735019350d98b3648ee5e9eeb2cad9d46da49e87 | /Tests/SuperstringTests/NewlineTests.swift | 95a9465681097f20254a1c8d2e67f813e1326149 | [
"MIT"
] | permissive | blessingLopes/Superstring | 76f10671e8479a7fa5a8ed7a9665bc2814c1f230 | 583fffcb997f74b173ef03627a3aaa03bdb66a76 | refs/heads/master | 2020-12-23T22:54:10.436731 | 2020-01-30T20:34:02 | 2020-01-30T20:34:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 895 | swift | //
// NewlineTests.swift
// SuperstringTests
//
// Created by manuel on 29.01.20.
//
import XCTest
#if canImport(UIKit)
import UIKit
#endif
@testable import Superstring
class NewlineTests: XCTestCase {
func test_Newline() {
let expected = NSAttributedString(string: "\n")
let result = Newline()
XCTAssertTrue(result.attributedString.isEqual(expected))
}
func test_Newline_with_font_attribute() {
let expected = NSAttributedString(string: "\n", attributes: [.font: UIFont.systemFont(ofSize: 72)])
let result = Newline()
.font(UIFont.systemFont(ofSize: 72))
XCTAssertTrue(result.attributedString.isEqual(expected))
}
static var allTests = [
("test_Newline", test_Newline),
("test_Newline_with_font_attribute", test_Newline_with_font_attribute)
]
}
| [
-1
] |
b52dbed8a039475768452a1dcf3c83e19d45fe7b | a2b28ad6d0ca2831d3929c50fab27e8bb9909177 | /Tests/SceneBoxTests/Support/MyConfigurationFile.swift | 4fb5b09d0c90677f9adf7e4c3f4c361afd1b1e91 | [
"MIT"
] | permissive | lumiasaki/SceneBox | 42801b730e6989b6023dbb1b34f99f610df0d600 | 481ce3333669e95e97214d4fb27ea2b555b0ba72 | refs/heads/main | 2023-06-29T04:22:25.356905 | 2021-07-29T08:16:18 | 2021-07-29T08:16:18 | 349,986,841 | 2 | 0 | MIT | 2021-07-29T08:16:18 | 2021-03-21T12:06:22 | Swift | UTF-8 | Swift | false | false | 500 | swift | //
// MyConfigurationFile.swift
// SceneBox
//
// Created by Lumia_Saki on 2021/7/29.
// Copyright © 2021年 tianren.zhu. All rights reserved.
//
import Foundation
import SceneBox
struct MyConfigurationFile: ConfigurationFile {
static var sceneStates: Set<Int> = Set([
SceneState.page1.rawValue,
SceneState.page2.rawValue
])
static var extensions: [Extension] = [
NavigationExtension(),
SharedStateExtension(stateValue: MyState())
]
}
| [
-1
] |
0f6d31dda14833281d722cbccf1558c3b1f8813b | 39bcafc5f6b1672f31f0f6ea9c8d6047ee432950 | /tools/swift/duckdb-swift/DuckDBPlayground.playground/Sources/SurveyLoader.swift | 9d972a09ba4c807eb588733583a3f7e5275cb376 | [
"MIT"
] | permissive | duckdb/duckdb | 315270af6b198d26eb41a20fc7a0eda04aeef294 | f89ccfe0ec01eb613af9c8ac7c264a5ef86d7c3a | refs/heads/main | 2023-09-05T08:14:21.278345 | 2023-09-05T07:28:59 | 2023-09-05T07:28:59 | 138,754,790 | 8,964 | 986 | MIT | 2023-09-14T18:42:49 | 2018-06-26T15:04:45 | C++ | UTF-8 | Swift | false | false | 2,234 | swift |
import Foundation
import PlaygroundSupport
import System
public enum SurveyLoader {
enum Failure {
case unableToDownloadSurveyContent
}
private static let localDataURL = playgroundSharedDataDirectory
.appending(component: "org.duckdb", directoryHint: .isDirectory)
.appending(component: "surveys")
public static func downloadSurveyCSV(forYear year: Int) async throws -> URL {
try await downloadSurveyIfNeeded(forYear: year)
return localSurveyDataURL(forYear: year)
.appending(component: "survey_results_public.csv")
}
public static func downloadSurveySchemaCSV(forYear year: Int) async throws -> URL {
try await downloadSurveyIfNeeded(forYear: year)
return localSurveyDataURL(forYear: year)
.appending(component: "survey_results_schema.csv")
}
public static func downloadSurveyIfNeeded(forYear year: Int) async throws {
let surveyDataURL = localSurveyDataURL(forYear: year)
if FileManager.default.fileExists(atPath: surveyDataURL.path) {
// survey already exists. skipping.
return
}
let surveyURL = remoteSurveyDataZipURL(forYear: year)
let (zipFileURL, _) = try await URLSession.shared.download(from: surveyURL)
try FileManager.default.createDirectory(
at: surveyDataURL, withIntermediateDirectories: true)
try Shell.execute("unzip '\(zipFileURL.path)' -d '\(surveyDataURL.path)'")
}
private static func localSurveyDataURL(forYear year: Int) -> URL {
localDataURL.appending(component: "\(year)")
}
private static func remoteSurveyDataZipURL(forYear year: Int) -> URL {
URL(string: "https://info.stackoverflowsolutions.com/rs/719-EMH-566/images/stack-overflow-developer-survey-\(year).zip")!
}
}
fileprivate enum Shell {
@discardableResult
static func execute(_ command: String) throws -> String {
let process = Process()
let pipe = Pipe()
process.executableURL = URL(fileURLWithPath: "/bin/zsh")
process.arguments = ["-c", command]
process.standardOutput = pipe
process.standardError = pipe
try process.run()
process.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: .utf8)!
}
}
| [
-1
] |
bdedffbefc6e0f04e7d43d41227cbaff424d4dc7 | 4700a16160b183c94ae11dc34f8e96a69c50f584 | /PullToRefreshKit-master 自定义刷新控件/PullToRefreshKit/TaoBaoRefreshHeader.swift | cf306d1ba6421109b82923ee41c01f1e30d0a801 | [
"MIT",
"Apache-2.0"
] | permissive | qinting513/SwiftNote | cf184591055118eadeb59c65fc72d197a0654c12 | bacc050866ca7558fee77ffab3fde8d60fc9d219 | refs/heads/master | 2020-07-30T21:49:15.775827 | 2016-12-10T07:20:37 | 2016-12-10T07:20:37 | 73,618,802 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,857 | swift | //
// TaoBaoRefreshHeader.swift
// PullToRefreshKit
//
// Created by huangwenchen on 16/7/14.
// Copyright © 2016年 Leo. All rights reserved.
//
import Foundation
import UIKit
class TaoBaoRefreshHeader:UIView,RefreshableHeader{
fileprivate let circleLayer = CAShapeLayer()
fileprivate let arrowLayer = CAShapeLayer()
fileprivate let textLabel = UILabel()
fileprivate let strokeColor = UIColor(red: 135.0/255.0, green: 136.0/255.0, blue: 137.0/255.0, alpha: 1.0)
override init(frame: CGRect) {
super.init(frame: frame)
setUpCircleLayer()
setUpArrowLayer()
textLabel.frame = CGRect(x: 0,y: 0,width: 120, height: 40)
textLabel.textAlignment = .center
textLabel.textColor = UIColor.lightGray
textLabel.font = UIFont.systemFont(ofSize: 14)
textLabel.text = "下拉即可刷新..."
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 230, height: 35))
imageView.image = UIImage(named: "taobaoLogo")
self.addSubview(imageView)
self.addSubview(textLabel)
//放置Views和Layer
imageView.center = CGPoint(x: frame.width/2, y: frame.height - 60 - 18)
textLabel.center = CGPoint(x: frame.width/2 + 20, y: frame.height - 30)
self.arrowLayer.position = CGPoint(x: frame.width/2 - 60, y: frame.height - 30)
self.circleLayer.position = CGPoint(x: frame.width/2 - 60, y: frame.height - 30)
}
func setUpArrowLayer(){
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 20, y: 15))
bezierPath.addLine(to: CGPoint(x: 20, y: 25))
bezierPath.addLine(to: CGPoint(x: 25,y: 20))
bezierPath.move(to: CGPoint(x: 20, y: 25))
bezierPath.addLine(to: CGPoint(x: 15, y: 20))
self.arrowLayer.path = bezierPath.cgPath
self.arrowLayer.strokeColor = UIColor.lightGray.cgColor
self.arrowLayer.fillColor = UIColor.clear.cgColor
self.arrowLayer.lineWidth = 1.0
self.arrowLayer.lineCap = kCALineCapRound
self.arrowLayer.bounds = CGRect(x: 0, y: 0,width: 40, height: 40)
self.arrowLayer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
self.layer.addSublayer(self.arrowLayer)
}
func setUpCircleLayer(){
let bezierPath = UIBezierPath(arcCenter: CGPoint(x: 20, y: 20),
radius: 12.0,
startAngle:CGFloat(-M_PI/2),
endAngle: CGFloat(M_PI_2 * 3),
clockwise: true)
self.circleLayer.path = bezierPath.cgPath
self.circleLayer.strokeColor = UIColor.lightGray.cgColor
self.circleLayer.fillColor = UIColor.clear.cgColor
self.circleLayer.strokeStart = 0.05
self.circleLayer.strokeEnd = 0.05
self.circleLayer.lineWidth = 1.0
self.circleLayer.lineCap = kCALineCapRound
self.circleLayer.bounds = CGRect(x: 0, y: 0,width: 40, height: 40)
self.circleLayer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
self.layer.addSublayer(self.circleLayer)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - RefreshableHeader -
func heightForRefreshingState()->CGFloat{
return 60
}
func percentUpdateDuringScrolling(_ percent:CGFloat){
let adjustPercent = max(min(1.0, percent),0.0)
if adjustPercent == 1.0{
textLabel.text = "释放即可刷新..."
}else{
textLabel.text = "下拉即可刷新..."
}
self.circleLayer.strokeEnd = 0.05 + 0.9 * adjustPercent
}
func didBeginRefreshingState(){
self.circleLayer.strokeEnd = 0.95
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotateAnimation.toValue = NSNumber(value: M_PI * 2.0 as Double)
rotateAnimation.duration = 0.6
rotateAnimation.isCumulative = true
rotateAnimation.repeatCount = 10000000
self.circleLayer.add(rotateAnimation, forKey: "rotate")
self.arrowLayer.isHidden = true
textLabel.text = "刷新中..."
}
func didBeginEndRefershingAnimation(_ result:RefreshResult){
transitionWithOutAnimation {
self.circleLayer.strokeEnd = 0.05
};
self.circleLayer.removeAllAnimations()
}
func didCompleteEndRefershingAnimation(_ result:RefreshResult){
transitionWithOutAnimation {
self.circleLayer.strokeEnd = 0.05
};
self.arrowLayer.isHidden = false
textLabel.text = "下拉即可刷新"
}
func transitionWithOutAnimation(_ clousre:()->()){
CATransaction.begin()
CATransaction.setDisableActions(true)
clousre()
CATransaction.commit()
}
}
| [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.