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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
077a9b5337c7f3755f3cfc0aa9286f77001e35dc | d22e4fd3f26ff8566829b4faf740141d24913404 | /BoreDDealer/Activity.swift | b2015fda04bf047286d0313c940cebde89ed94c3 | [] | no_license | elisashanghai/BoreDDealer | 7f32e7882ccf2ba2592d0bdb3b54ce8b78dc1bfe | ae3cb285c4d8a4d1868aaf78d47d126c77112df7 | refs/heads/master | 2021-01-19T01:17:30.377350 | 2016-07-08T21:34:03 | 2016-07-08T21:34:03 | 62,671,762 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,938 | swift | //
// Activity.swift
// BoreDDealer
//
// Created by Brittiny Tran on 7/7/16.
// Copyright © 2016 WhenYouBored. All rights reserved.
//
import Foundation
enum ActivityDuration: Int {
case ThirtyMin = 30, SixtyMin = 60
}
class Activity {
let duration: ActivityDuration
let title: String
init(title: String, duration: ActivityDuration) {
self.title = title
self.duration = duration
}
// array of short activities
static var shortArray = [Activity(title: "Read a new book!", duration: .ThirtyMin),
Activity(title: "Make a bucket list of 20 things you want to do before you die!", duration: .ThirtyMin),
Activity(title: "Start watching a new TV Series!", duration: .ThirtyMin),
Activity(title: "Bake something!", duration: .ThirtyMin),
Activity(title: "Write a letter for someone you care about!", duration: .ThirtyMin),
Activity(title: "Go biking in a park near you!", duration: .ThirtyMin),
Activity(title: "Take a 30 minute nap and feel refreshed!", duration: .ThirtyMin),
Activity(title: "Learn about a sport that's popular in another country besides the one you reside in!", duration: .ThirtyMin),
Activity(title: "Make a drawing of the first thing you see when you step outside", duration: .ThirtyMin),
Activity(title: "Make a video of something you'd like to tell your 'future self'!", duration: .ThirtyMin),
Activity(title: "Learn a new type of dance (something that's foreign to where you're from)!", duration: .ThirtyMin)]
func getShortActivityTitle() {
for activity in Activity.shortArray {
print(activity.title)
}
}
// array of long activities
static var longArray = [Activity(title: "Watch a movie that you've never watched before!", duration: .SixtyMin),
Activity(title: "Cook a special meal for your loved one(s)", duration: .SixtyMin),
Activity(title: "'Spring' cleaning time while having a dance party for 1!", duration: .SixtyMin),
Activity(title: "Learn the basics of how to code in iOS or Android!", duration: .SixtyMin),
Activity(title: "Make a scrapbook of your most memorable times!", duration: .SixtyMin),
Activity(title: "Try doing Zumba!", duration: .SixtyMin),
Activity(title: "Treat yourself to a 'Me Day'! Go spoil yourself!", duration: .SixtyMin),
Activity(title: "Play one of your favorite games from your childhood!", duration: .SixtyMin),
Activity(title: "Look up funny videos on YouTube!", duration: .SixtyMin),
Activity(title: "Plan the 'perfect' vacation getaway that you'd like to go on!", duration: .SixtyMin)]
func getLongActivityTitle() {
for option in Activity.longArray {
print(option.title)
}
}
func pickActivity(choice: Int) -> String {
if choice == 1 {
let randomIndex = Int(arc4random_uniform(UInt32(Activity.shortArray.count)))
let removeActivity = Activity.shortArray.removeAtIndex(randomIndex)
return removeActivity.title
}
else {
let randomIndex2 = Int(arc4random_uniform(UInt32(Activity.longArray.count)))
let removeActivity2 = Activity.longArray.removeAtIndex(randomIndex2)
return removeActivity2.title
}
}
} | [
-1
] |
a44a5eda33afb21869471e47b48003ccb88a2dac | 3d144a23e67c839a4df1c073c6a2c842508f16b2 | /test/multifile/protocol-extension-init.swift | a0736c3b6f099913bdc9b71e37278044bbcf1e49 | [
"Apache-2.0",
"Swift-exception"
] | permissive | apple/swift | c2724e388959f6623cf6e4ad6dc1cdd875fd0592 | 98ada1b200a43d090311b72eb45fe8ecebc97f81 | refs/heads/main | 2023-08-16T10:48:25.985330 | 2023-08-16T09:00:42 | 2023-08-16T09:00:42 | 44,838,949 | 78,897 | 15,074 | Apache-2.0 | 2023-09-14T21:19:23 | 2015-10-23T21:15:07 | C++ | UTF-8 | Swift | false | false | 263 | swift | // RUN: %target-swift-frontend -emit-ir -module-name test %S/Inputs/protocol-extension-init-helper.swift -primary-file %s
// SE-9233: compute layout when emitting an other-constructor reference
extension P {
public init(possibly: Bool) {
self.init()
}
}
| [
84649
] |
69caf544555fbeeb0b4d8f6b1406b1e577690a98 | ac40a5004e985effec2cd8ff6f0504bc3c1a2380 | /Calling Workflow/Controllers/CallingDetailsTableViewController.swift | c2bd36f631e0c0aed4062de06c4496ee5539c8ef | [] | no_license | mstauff/cwf-ios | 35d1a18478002706d765ecafb01b04fb687bd179 | 43e795b692ec21f695cee4aadf1567418aabbd14 | refs/heads/master | 2020-12-25T13:51:19.882415 | 2018-06-18T17:39:00 | 2018-06-18T17:39:00 | 64,969,759 | 0 | 0 | null | 2018-06-08T23:05:45 | 2016-08-04T21:54:26 | Swift | UTF-8 | Swift | false | false | 41,667 | swift | //
// CallingDetailsTableViewController.swift
// Calling Workflow
//
// Created by Chad Olsen on 1/23/17.
// Copyright © 2017 colsen. All rights reserved.
//
import UIKit
class CallingDetailsTableViewController: CWFBaseViewController, UITableViewDelegate, UITableViewDataSource, MemberPickerDelegate, StatusPickerDelegate, ProcessingSpinner, AlertBox {
//MARK: - Class Members
var callingToDisplay : Calling? = nil {
didSet {
tableView.reloadData()
}
}
var unitLevelOrg : Org? = nil
var titleBarString : String? = nil
var tableView = UITableView(frame: CGRect.zero, style: .grouped)
var isDirty = false
var originalCalling : Calling? = nil
var memberDetailView : MemberInfoView? = nil
var delegate : CallingsTableViewControllerDelegate?
// var spinnerView : CWFSpinnerView? = nil
weak var callingMgr : CWFCallingManagerService? = nil
var isEditable = false
struct keyboardInfoStruct {
var isUp : Bool = false
var height : CGFloat = 0.0
}
var keyboardInfo = keyboardInfoStruct.init(isUp: false, height: 0)
var notesCell : NotesTableViewCell? = nil
//MARK: - Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: .UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: .UIKeyboardWillHide, object: nil)
setupTableView()
guard let calling = callingToDisplay else {
return
}
let appDelegate = UIApplication.shared.delegate as? AppDelegate
self.callingMgr = appDelegate?.callingManager
originalCalling = calling
if let viewTitle = titleBarString {
navigationItem.title = viewTitle
}
setupNavBarButtons()
// check permissions to see if we need to display options to edit the calling
if let parentOrg = calling.parentOrg, let callingMgr = self.callingMgr, let rootOrg = callingMgr.unitLevelOrg(forSubOrg: parentOrg.id) {
unitLevelOrg = rootOrg
let authOrg = AuthorizableOrg(fromSubOrg: parentOrg, inUnitLevelOrg: rootOrg)
if callingMgr.permissionMgr.isAuthorized(unitRoles: callingMgr.userRoles, domain: .PotentialCalling, permission: .Update, targetData: authOrg ) {
let saveButton = UIBarButtonItem(title: "Save", style: UIBarButtonItemStyle.plain, target: self, action: #selector(saveAndReturn))
navigationItem.setRightBarButton(saveButton, animated: true)
isEditable = true
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Setup
func setupNavBarButtons() {
let button = UIButton(type: .custom)
button.setImage(UIImage.init(named: "backButton"), for: .normal)
button.addTarget(self, action: #selector(backButtonPressed), for: .touchUpInside)
button.frame = CGRect(x: 0, y: 0, width: 53.0, height: 31.0)
// let label = UILabel(frame: CGRect(x: 0, y: 0, width: 53.0, height: 31.0))
// label.font = UIFont(name: "Arial", size: 15)
// label.textColor = UIColor.white
// label.backgroundColor = UIColor.clear
// label.textAlignment = .center
// label.text = NSLocalizedString("Back", comment: "back button")
// button.addSubview(label)
let backButton = UIBarButtonItem(customView: button)
// let backButton = UIBarButtonItem(image: UIImage.init(named:"backButton"), style:.plain, target: self, action: #selector(backButtonPressed) )
// backButton.title = NSLocalizedString("Back", comment: "back button")
navigationItem.setLeftBarButton(backButton, animated: true)
}
func setupTableView() {
tableView.delegate = self
tableView.dataSource = self
tableView.translatesAutoresizingMaskIntoConstraints = false
let headerView = UIView(frame: CGRect(x: 0, y: -2, width: self.view.frame.width, height: 0.1))
headerView.backgroundColor = UIColor.orange
tableView.tableHeaderView = headerView
self.view.addSubview(self.tableView)
let xConstraint = NSLayoutConstraint(item: tableView, attribute: .left, relatedBy: .equal, toItem: self.view, attribute: .left, multiplier: 1, constant: 0)
let yConstraint = NSLayoutConstraint(item: tableView, attribute: .top, relatedBy: .equal, toItem: self.view, attribute: .top, multiplier: 1, constant: 0)
let wConstraint = NSLayoutConstraint(item: tableView, attribute: .right, relatedBy: .equal, toItem: self.view, attribute: .right, multiplier: 1, constant: 0)
let hConstraint = NSLayoutConstraint(item: tableView, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottom, multiplier: 1, constant: 0)
self.view.addConstraints([xConstraint, yConstraint, wConstraint, hConstraint])
// initi these UI elements before we do the guard check to make sure we have a calling
tableView.register(DataSubdataTableViewCell.self, forCellReuseIdentifier: "dataSubdata")
tableView.register(LeftTitleRightLabelTableViewCell.self, forCellReuseIdentifier: "middleCell")
tableView.register(OneRightTwoLeftTableViewCell.self, forCellReuseIdentifier: "oneRightTwoLeftCell")
tableView.register(NotesTableViewCell.self, forCellReuseIdentifier: "noteCell")
tableView.register(CWFButtonTableViewCell.self, forCellReuseIdentifier: "buttonCell")
}
// MARK: - Table view data source
func numberOfSections(in tableView: UITableView) -> Int {
//Return 2 sections if the user only can view 4 if they can edit
if isEditable {
return 4
}
else{
return 2
}
}
func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
switch section {
case 0:// we don't want a header on the first section
return 1.0
default:// all other sections get a 10 px header
return 10
}
}
func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
return 1.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1.0))
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
switch section {
case 0:// we don't want a header on the first section. iOS wants a height greater than 0
return UIView(frame: CGRect(x: 0, y: -2.0, width: 0.1, height: 1.0))
default:// all other sections get a 10 px header
return UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 10.0))
}
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
default:
return ""
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return number of rows per section
switch section {
case 0: // header information
return 1
case 1: // calling details. If the user has permition to edit return more rows
if isEditable {
return 3
}
else {
return 1
}
case 2: // notes section. Only needs one row
return 1
case 3: // LCR button section, only one row needed
return 1
default:
return 0
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0: //Top header Section
return DataSubdataTableViewCell.calculateHeight()
case 1: // calling details section
switch indexPath.row {
case 0:
return OneRightTwoLeftTableViewCell.calculateHeight()
default:
return LeftTitleRightLabelTableViewCell.calculateHeight()
}
case 2: // notes section
return 170
default:
return 44
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0: // first section of the view is the title cell
let cell = tableView.dequeueReusableCell(withIdentifier: "dataSubdata", for: indexPath) as? DataSubdataTableViewCell
cell?.mainLabel.text = callingToDisplay?.parentOrg?.orgName
cell?.subLabel.text = callingToDisplay?.position.name
return cell!
case 1: // second section of the view is the information
switch indexPath.row {
// this is the currently called cell
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "oneRightTwoLeftCell", for: indexPath) as? OneRightTwoLeftTableViewCell
cell?.titleLabel.text = NSLocalizedString("Current:", comment: "Current:")
let appDelegate = UIApplication.shared.delegate as? AppDelegate
if (callingToDisplay?.existingIndId) != nil {
let currentMember = appDelegate?.callingManager.getMemberWithId(memberId: (callingToDisplay?.existingIndId)!)
cell?.dataLabel.text = currentMember?.name
if let months : Int = callingToDisplay?.existingMonthsInCalling {
cell?.subdataLabel.text = NSLocalizedString("\(months) months", comment: "months")
}
else {
cell?.subdataLabel.text = nil
}
}
return cell!
// this is the proposed individual cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "middleCell", for: indexPath) as? LeftTitleRightLabelTableViewCell
cell?.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
let accessoryButton = UIButton(type: .contactAdd)
accessoryButton.setImage(UIImage.init(named: "disclosureArrow"), for: .normal)
accessoryButton.addTarget(self, action: #selector(memberPickerButtonPressed), for: .touchUpInside)
cell?.accessoryView = accessoryButton
cell?.titleLabel.text = NSLocalizedString("Proposed:", comment: "Proposed")
// look up the name of the proposed individual
if let proposedIndId = callingToDisplay?.proposedIndId {
let appDelegate = UIApplication.shared.delegate as? AppDelegate
let proposedMember = appDelegate?.callingManager.getMemberWithId(memberId: proposedIndId)
// check to see if the member meets the position requiremenst (show a warning if they don't)
let meetsRequirements = self.meetsPositionRequirements(ofCalling: callingToDisplay, member: proposedMember)
// todo - add warning icon if the user doesn't meet the requirements for the position
if !meetsRequirements {
cell?.warningButton.isHidden = false
cell?.warningButton.addTarget(self, action: #selector(warningButtonPressed), for: .touchUpInside)
}
else {
cell?.warningButton.isHidden = true
}
cell?.dataLabel.text = proposedMember?.name
}
else {
cell?.dataLabel.text = nil
cell?.warningButton.isHidden = true
}
return cell!
// this is the status cell
case 2:
let cell = tableView.dequeueReusableCell(withIdentifier: "middleCell", for: indexPath) as? LeftTitleRightLabelTableViewCell
cell?.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
let accessoryButton = UIButton(type: .contactAdd)
accessoryButton.setImage(UIImage.init(named: "disclosureArrow"), for: .normal)
accessoryButton.addTarget(self, action: #selector(tappedTheStatus), for: .touchUpInside)
cell?.accessoryView = accessoryButton
cell?.titleLabel.text = NSLocalizedString("Status:", comment: "Status")
if callingToDisplay?.proposedStatus != CallingStatus.Unknown {
cell?.dataLabel.text = callingToDisplay?.proposedStatus.description
}
else {
cell?.dataLabel.text = NSLocalizedString("None", comment: "None")
}
return cell!
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
return cell
}
case 2: // third section is the notes
let cell = tableView.dequeueReusableCell(withIdentifier: "noteCell", for: indexPath) as? NotesTableViewCell
self.notesCell = cell
if let callingNotes = callingToDisplay?.notes, !callingNotes.isEmpty {
cell?.noteTextView.text = callingToDisplay!.notes
}
return cell!
case 3: // fourth section is the button for the lcr functions.
let cell = tableView.dequeueReusableCell(withIdentifier: "buttonCell", for: indexPath) as? CWFButtonTableViewCell
cell?.cellButton.setTitle(NSLocalizedString("Calling Actions", comment: "Calling Actions"), for: UIControlState.normal)
cell?.cellButton.addTarget(self, action: #selector(callingActionsButtonPressed), for: .touchUpInside)
if callingToDisplay?.conflict != nil || callingToDisplay?.parentOrg?.conflict != nil {
cell?.cellButton.isUserInteractionEnabled = false
cell?.tintColor = UIColor.white
cell?.backgroundColor = UIColor.lightGray
}
else {
cell?.cellButton.isUserInteractionEnabled = true
cell?.backgroundColor = UIColor.white
cell?.tintColor = UIColor.CWFGreyTextColor
}
return cell!
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
return cell
}
}
// Tap handler for current/proposed/status options in calling details
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let appDelegate = UIApplication.shared.delegate as? AppDelegate
switch indexPath.section {
case 1:
tableView.deselectRow(at: indexPath, animated: false)
self.notesCell?.noteTextView.resignFirstResponder()
switch indexPath.row {
case 0:
// Tapped the current holder - need to display the bottom sheet with contact info for the current calling holder if there is one
if let memberId = callingToDisplay?.existingIndId {
displayContactInfoForMember(member: (appDelegate?.callingManager.getMemberCallings(forMemberId: memberId))!)
}
case 1:
self.notesCell?.noteTextView.resignFirstResponder()
// Tapped the proposed calling holder. Transition to member contact info
if let proposedId = callingToDisplay?.proposedIndId, let memberCallings = appDelegate?.callingManager.getMemberCallings(forMemberId: proposedId){
self.displayContactInfoForMember(member: memberCallings)
}
// if no proposedId go to the memberPicker
else {
memberPickerButtonPressed()
}
case 2:
// Tapped the status, show the selection screen for choosing a status
tappedTheStatus()
default:
print("Default to do nothing")
}
default:
tableView.deselectRow(at: indexPath, animated: false)
}
}
//MARK: - Member Picker Delegate
func setProspectiveMember(member: Member?) {
isDirty = true
if let setMember = member {
self.callingToDisplay?.proposedIndId = setMember.individualId
let appDelegate = UIApplication.shared.delegate as? AppDelegate
var statusArray : [CallingStatus] = CallingStatus.userValues
if let excludeArray = appDelegate?.callingManager.statusToExcludeForUnit {
statusArray = statusArray.filter() { !excludeArray.contains(item: $0) }
}
if let first = statusArray.first {
self.callingToDisplay?.proposedStatus = first
}
}
else {
self.callingToDisplay?.proposedIndId = nil
self.callingToDisplay?.proposedStatus = .None
}
}
//MARK: - Status Picker Delegate
func setStatusFromPicker(status: CallingStatus) {
isDirty = true
self.callingToDisplay?.proposedStatus = status
tableView.reloadData()
}
//MARK: - Keyboard Delegates
func keyboardWillShow(_ notification: Notification) {
//If we are using a small device we want to move up the view and adjust size of view.
if !keyboardInfo.isUp {
keyboardInfo.isUp = true
if let keyboardFrame : NSValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
keyboardInfo.height = keyboardFrame.cgRectValue.height
self.view.frame = CGRect(x: self.view.frame.origin.x, y: self.view.frame.origin.y, width: self.view.frame.size.width, height: self.view.frame.size.height - keyboardInfo.height)
if self.view.frame.height < 400 {
tableView.setContentOffset(CGPoint(x: tableView.contentOffset.x, y: tableView.contentOffset.y + keyboardInfo.height), animated: true)
}
else {
tableView.setContentOffset(CGPoint(x: tableView.contentOffset.x, y: 0), animated: true)
}
}
}
}
func keyboardWillHide(_ notification: Notification) {
//Resets the view to the original size from before the keyboard appeared.
if keyboardInfo.isUp {
keyboardInfo.isUp = false
self.view.frame = CGRect(x: self.view.frame.origin.x, y: self.view.frame.origin.y, width: self.view.frame.size.width, height: (self.view.frame.size.height + keyboardInfo.height))
if self.view.frame.height < 400 + keyboardInfo.height{
var keyboardContentOffset = tableView.contentOffset.y - keyboardInfo.height
if keyboardContentOffset < -64.0 {
keyboardContentOffset = -64.0
}
tableView.setContentOffset(CGPoint(x: tableView.contentOffset.x, y: keyboardContentOffset), animated: true)
}
else {
tableView.setContentOffset(CGPoint(x: tableView.contentOffset.x, y: 0), animated: true)
}
}
}
//MARK: - Show Contact Info
func displayContactInfoForMember(member: MemberCallings) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let memberDetailView = storyboard.instantiateViewController(withIdentifier: "MemberInfoView") as? MemberInfoView
memberDetailView?.memberToView = member
memberDetailView?.modalPresentationStyle = .overCurrentContext
self.present(memberDetailView!, animated: true, completion: nil)
}
//MARK: - Actions
func tappedTheStatus () {
let statusActionSheet = getStatusActionSheet(delegate: self)
self.present(statusActionSheet, animated: true, completion: nil)
}
func memberPickerButtonPressed() {
// Tapped the proposed calling holder. Transition to member picker to select a proposed person for this calling
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let nextVC = storyboard.instantiateViewController(withIdentifier: "MemberPickerTableViewController") as? MemberPickerTableViewController
// register as the delegate for selecting a member to update the proposed person
nextVC?.delegate = self
nextVC?.currentlySelectedId = callingToDisplay?.proposedIndId
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
// setup the members to display in the picker, along with any filter options that should be preset based on the calling requirements
nextVC?.members = appDelegate.callingManager.memberCallings
let requirements = callingToDisplay?.position.metadata.requirements
let filterOptions = requirements != nil ? FilterOptions( fromPositionRequirements: requirements! ) : FilterOptions()
nextVC?.filterViewOptions = filterOptions
}
navigationController?.pushViewController(nextVC!, animated: true)
}
func backButtonPressed() {
// check if notes have changed & set isDirty if they have
if let notes = notesCell {
isDirty = isDirty || ( notes.textContents != nil && notes.textContents != callingToDisplay?.notes )
}
if isDirty {
let saveAlert = UIAlertController(title: NSLocalizedString("Discard Changes?", comment: "discard"), message: NSLocalizedString("You have unsaved changes that will be discarded if you continue.", comment: "discard message"), preferredStyle: UIAlertControllerStyle.alert)
let cancelAction = UIAlertAction(title: NSLocalizedString("Continue", comment: "Continue"), style: UIAlertActionStyle.destructive, handler: {
(alert: UIAlertAction!) -> Void in
self.navigationController?.popViewController(animated: true)
})
let saveAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel"), style: UIAlertActionStyle.default, handler: {
(alert: UIAlertAction!) -> Void in
print("cancel")
})
saveAlert.addAction(cancelAction)
saveAlert.addAction(saveAction)
present(saveAlert, animated: true, completion: nil)
print("dismiss")
// Back btn Event handler
}
else {
self.navigationController?.popViewController(animated: true)
}
}
func warningButtonPressed() {
print("Warning Pressed")
let warningTitle = NSLocalizedString("Warning", comment: "Warning")
let warningMsg = NSLocalizedString("You have selected a member that does not meet the requirements for the calling selected. You may not be able to save these changes in LCR", comment: "warning to user about position requirements")
self.showAlert(title: warningTitle, message: warningMsg, includeCancel: false)
{
(alert: UIAlertAction!) -> Void in
print("ok")
}
}
func callingActionsButtonPressed() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
let callingMgr = appDelegate.callingManager
let actionSheet = UIAlertController(title: NSLocalizedString("lds.org Actions", comment: "LCR Actions"), message: nil, preferredStyle: UIAlertControllerStyle.actionSheet)
//Only add Update option if there is a proposed individual
if callingToDisplay?.proposedIndId != nil {
let finalizeAction = UIAlertAction(title: NSLocalizedString("Finalize Change on lds.org", comment: "Finalize"), style: UIAlertActionStyle.default, handler: {
(alert: UIAlertAction!) -> Void in
//String to use as warning message when updating LCR
var alertMessage : String = ""
//If existingIndividual add release info to the alert message, otherwise add start of sentence
if let existingId = self.callingToDisplay?.existingIndId, let currentlyCalled = callingMgr.getMemberWithId(memberId: existingId), let currentName = currentlyCalled.name {
alertMessage.append(NSLocalizedString("This will release \(currentName) and ", comment: "Conf beginning"))
}
else {
alertMessage.append(NSLocalizedString("This ", comment: "this"))
}
//Add the rest of the message with proposed individual name
if let proposedId = self.callingToDisplay?.proposedIndId, let currentlyProposed = callingMgr.getMemberWithId(memberId: proposedId),let proposedName = currentlyProposed.name, let callingName = self.callingToDisplay?.position.name {
alertMessage.append(NSLocalizedString("will record \(proposedName) as \(callingName) on lds.org. This will make the change offical and public.", comment: "update calling message"))
}
//Initialize the alert with the message created
let updateAlertTitle = NSLocalizedString("Update Calling", comment: "Update Calling")
//Init the action that will run when OK is pressed
self.showAlert(title: updateAlertTitle, message: alertMessage, includeCancel: true) {
(alert: UIAlertAction!) -> Void in
self.startSpinner()
//Call to callingManager to update calling
callingMgr.updateLCRCalling(updatedCalling: self.callingToDisplay!) { (calling, error) in
guard error == nil, let validCalling = calling else {
DispatchQueue.main.async {
var errorAlertMsg = NSLocalizedString("We were unable to update this calling on lds.org. You can try again later, or try to update it directly through lds.org", comment: "Cannot Update")
if let err = error as NSError?, err.code == ErrorConstants.memberInvalid {
// we know it was a position requirements issue, now we just need to create a meaningful error message
// todo - need to factor "error" string out to constants for consistency and type safety
if let errorMsg = err.userInfo["error"] as? String {
errorAlertMsg = errorMsg
} else {
// try to use the specific details for the alert box, but as a backup just use a generic description
let callingName = self.callingToDisplay?.position.name ?? "the calling"
errorAlertMsg = NSLocalizedString("The proposed individual did not meet the requirements for \(callingName). They cannot be recorded on lds.org.", comment: "Error recording calling")
}
}
self.removeSpinner()
self.showAlert(title: NSLocalizedString("Error", comment: "Error"), message: errorAlertMsg, includeCancel: false, okCompletionHandler: nil )
}
return
}
self.callingToDisplay = validCalling
let err = error?.localizedDescription ?? "nil"
print("Release result: \(calling.debugDescription) - error: \(err)")
DispatchQueue.main.async {
self.removeSpinner()
self.returnToAux(saveFirst: false)
}
}
}
})
actionSheet.addAction(finalizeAction)
}
if let displayedCalling = callingToDisplay, displayedCalling.existingIndId != nil {
let releaseAction = UIAlertAction(title: NSLocalizedString("Release Current on lds.org", comment: "release"), style: UIAlertActionStyle.default, handler: {
(alert: UIAlertAction!) -> Void in
var releaseWarningString : String = ""
if let existingId = displayedCalling.existingIndId, let currentlyCalled = callingMgr.getMemberWithId(memberId: existingId), let name = currentlyCalled.name, let callingName = displayedCalling.position.name {
releaseWarningString = NSLocalizedString("This will release \(name) as \(callingName) on lds.org. This will make the release public (it will appear in lds.org sites, LDS Tools, etc.). Generally this should only be done after the individual has been released in Sacrament Meeting. Do you want to record the release on lds.org?", comment: "Release Warning")
}
let releaseAlertTitle = NSLocalizedString("Release From Calling", comment: "Release")
self.showAlert(title: releaseAlertTitle, message: releaseWarningString, includeCancel: true) {
(alert: UIAlertAction!) -> Void in
//call to calling manager to release individual
self.startSpinner()
callingMgr.releaseLCRCalling(callingToRelease: displayedCalling) { (success, error) in
// need to update the calling to display with the changes the user has made, so when we return we can pass this back to the delegate (parent view), so the UI is updated to reflect the change
// todo - we should modify releaseLCRCalling to return a calling (even though LCR doesn't), so the controller doesn't have to create a new calling in the correct state
self.callingToDisplay = Calling(id: nil, cwfId: nil, existingIndId: nil, existingStatus: nil, activeDate: nil, proposedIndId: displayedCalling.proposedIndId, status: displayedCalling.proposedStatus, position: displayedCalling.position, notes: displayedCalling.notes, parentOrg: displayedCalling.parentOrg, cwfOnly: false)
let err = error?.localizedDescription ?? "nil"
print("Release result: \(success) - error: \(err)")
DispatchQueue.main.async {
self.removeSpinner()
self.returnToAux(saveFirst: false)
}
}
}
})
actionSheet.addAction(releaseAction)
}
//init delete option for the action sheet
if canDeleteCalling() {
let deleteAction = UIAlertAction(title: NSLocalizedString("Delete Calling", comment: "delete calling"), style: UIAlertActionStyle.default, handler: {
(alert: UIAlertAction!) -> Void in
//Message to use for the action conformation alert
var deleteWarningMessage : String = ""
if (self.callingToDisplay?.cwfOnly == false) {
//If there is an existing individual display release warning.
if let existingId = self.callingToDisplay?.existingIndId, let existingIndividual = callingMgr.getMemberWithId(memberId: existingId), let existingName = existingIndividual.name, let callingName = self.callingToDisplay?.position.name {
deleteWarningMessage.append(NSLocalizedString("This will release \(existingName) as \(callingName) on lds.org (LCR) and remove the calling from ward lists. Do you want to record the release on lds.org?", comment: "existingIndDelete"))
}
else {
if let callingName = self.callingToDisplay?.position.name{
deleteWarningMessage.append(NSLocalizedString("This will remove \(callingName) from ward lists and directiories. Do you want to continue?", comment: "deleteWarning"))
}
}
} else {
deleteWarningMessage = "This will delete the calling. Do you want to continue?"
}
//Init the alert using the warning string
let deleteAlert = UIAlertController(title: NSLocalizedString("Delete Calling", comment: "delete"), message: deleteWarningMessage, preferredStyle: .alert)
//Init the ok button and the callback to execute
let okAction = UIAlertAction(title: NSLocalizedString("OK", comment: "OK"), style: UIAlertActionStyle.destructive, handler: {
(alert: UIAlertAction!) -> Void in
self.startSpinner()
callingMgr.deleteLCRCalling(callingToDelete: self.callingToDisplay!) { (success, error) in
let err = error?.localizedDescription ?? "nil"
print("Delete result: \(success) - error: \(err)")
DispatchQueue.main.async {
self.deleteReturn()
}
}
})
//Init the cancel button for the delete calling alert
let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel"), style: UIAlertActionStyle.cancel, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})
//Add the buttons to the alert and display to the user.
deleteAlert.addAction(okAction)
deleteAlert.addAction(cancelAction)
self.present(deleteAlert, animated: true, completion: nil)
print("Delete Current pressed")
})
actionSheet.addAction(deleteAction)
}
let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel"), style: UIAlertActionStyle.cancel, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})
actionSheet.addAction(cancelAction)
self.present(actionSheet, animated: true, completion: nil)
}
func saveAndReturn() {
returnToAux(saveFirst: true)
}
func deleteReturn() {
isDirty = false
if let calling = self.callingToDisplay {
delegate?.setDeletedCalling(calling: calling)
}
self.navigationController?.popViewController(animated: true)
}
func returnToAux( saveFirst : Bool ) {
if saveFirst {
save()
}
isDirty = false
// todo - debug this. In case where calling is added new and then saved w/o exiting org ?????
delegate?.setReturnedCalling(calling: self.callingToDisplay!)
let _ = self.navigationController?.popViewController(animated: true)
}
// todo - we either need to pass in a completion handler, or define one for the controller that can handle the result of the save operation (mostly for error handling)
func save() {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
if let validCalling = self.callingToDisplay {
self.updateNotes(self.notesCell)
// we only need the name for reporting in cases where the update fails. Default to generic "that calling" if we can't get a name
let callingName = validCalling.position.name ?? "that calling"
appDelegate.callingManager.updateCalling(updatedCalling: self.callingToDisplay!) {success, error in
// if there was an error then we need to inform the user
if error != nil || !success {
let updateErrorAlert = UIAlertController(title: NSLocalizedString("Error", comment: "Error"), message: NSLocalizedString("Unable to record changes to \(callingName). Please try again later.", comment: "Error saving changes"), preferredStyle: .alert)
let okAction = UIAlertAction(title: NSLocalizedString("OK", comment: "OK"), style: UIAlertActionStyle.cancel, handler: nil)
//Add the buttons to the alert and display to the user.
updateErrorAlert.addAction(okAction)
showAlertFromBackground(alert: updateErrorAlert, completion: nil)
// we have previously updated the calling VC with the change so it can be updated in the UI while the async update is happening. In this case, now that the update has failed we need to update it again with the calling as it was before the change was made
if self.originalCalling != nil {
self.delegate?.setReturnedCalling(calling: self.originalCalling!)
}
}
}
}
}
}
/** Update the model notes if there are any. */
func updateNotes(_ notesCell : NotesTableViewCell?) {
if let validNotes = notesCell, let noteText = validNotes.textContents{
self.callingToDisplay?.notes = noteText
}
}
/** Check if a member meets the position requirements for a calling, if there are any. Returns true if the member meets the requirements, false if there's a violation
*/
func meetsPositionRequirements( ofCalling calling: Calling?, member: Member? ) -> Bool {
guard let calling = calling, let member = member else {
return true
}
var result = true
if let requirements = calling.position.metadata.requirements {
// just use all the existing filter code to see perform the check, so we don't have to rewrite the validation code
let positionRequirementsFilter = FilterOptions( fromPositionRequirements: requirements )
result = positionRequirementsFilter.passesFilter(member: member)
}
return result
}
//MARK: - Spinner
func startSpinner() {
self.navigationItem.leftBarButtonItem?.isEnabled = false
self.navigationItem.rightBarButtonItem?.isEnabled = false
startProcessingSpinner( labelText: "Updating" )
}
func removeSpinner () {
self.navigationItem.leftBarButtonItem?.isEnabled = true
self.navigationItem.rightBarButtonItem?.isEnabled = true
removeProcessingSpinner()
}
//MARK: - Permissions
func hasPermissionToView() -> Bool {
if let appDelegete = UIApplication.shared.delegate as? AppDelegate, let parentOrg = callingToDisplay?.parentOrg, let unitLevelOrg = appDelegete.callingManager.unitLevelOrg(forSubOrg: parentOrg.id) {
let authOrg = AuthorizableOrg(fromSubOrg: parentOrg, inUnitLevelOrg: unitLevelOrg)
return appDelegete.callingManager.permissionMgr.isAuthorized(unitRoles: appDelegete.callingManager.userRoles, domain: .PotentialCalling, permission: .Update, targetData: authOrg)
}
else {
return false
}
}
func canDeleteCalling() -> Bool {
var boolToReturn = false
let appDelegate = UIApplication.shared.delegate as? AppDelegate
if let calling = callingToDisplay,let parentOrgId = calling.parentOrg?.id, let rootOrg = appDelegate?.callingManager.unitLevelOrg(forSubOrg: parentOrgId) {
// if it only exists in CWF, means was added from the app then it can always be deleted. Similarly, any custom callings can always be deleted.
if calling.cwfOnly || calling.position.custom {
boolToReturn = true
}
else {
if let parentOrgId = calling.parentOrg?.id, let parentOrg = rootOrg.getChildOrg(id: parentOrgId ) {
let callings = parentOrg.callings.filter() { $0.position.positionTypeId == calling.position.positionTypeId }
if calling.position.multiplesAllowed && callings.count > 1 {
boolToReturn = true
}
}
}
}
return boolToReturn
}
}
| [
-1
] |
007c320ae6c89ef47b83e222f796d34810d807d9 | 651ad14c91b3327419f528258522801eadbdf3d5 | /Sources/SwiftMatrix/Functions.swift | fe8a4366782354af07a1c130c3f8b8a1e00c2e14 | [
"MIT"
] | permissive | theolternative/SwiftMatrix | 3c300fecf7b981806d64d68fecbb8d32c27edd0b | f9b3fb8e86c80addd5dfddeda143695b44c15db4 | refs/heads/main | 2023-03-02T07:17:07.171828 | 2021-02-02T21:33:37 | 2021-02-02T21:33:37 | 326,226,176 | 4 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,526 | swift | //
// Functions.swift
// Log, Exp, Trigonometry and others
//
// Created by Matteo Rossi on 02/01/21.
//
import Accelerate
// MARK: - Log & Exp
public func log (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvlog( $0, $1, $2) }
}
public func log2 (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvlog2( $0, $1, $2) }
}
public func log10 (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvlog10( $0, $1, $2) }
}
public func exp (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvexp( $0, $1, $2) }
}
// MARK: - Trigonometry
public func sin (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvsin( $0, $1, $2) }
}
public func cos (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvcos( $0, $1, $2) }
}
public func tan (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvtan( $0, $1, $2) }
}
public func arcsin (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvasin( $0, $1, $2) }
}
public func arccos (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvacos( $0, $1, $2) }
}
public func arctan (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvatan( $0, $1, $2) }
}
public func sinh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvsinh( $0, $1, $2) }
}
public func cosh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvcosh( $0, $1, $2) }
}
public func tanh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvtanh( $0, $1, $2) }
}
public func arcsinh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvasinh( $0, $1, $2) }
}
public func arccosh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvacosh( $0, $1, $2) }
}
public func arctanh (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvatanh( $0, $1, $2) }
}
// MARK: - Statistics
public func abs (_ rhs : Matrix ) -> Matrix {
return withMatrix(rhs) { vvfabs( $0, $1, $2) }
}
public func min( _ lhs : Matrix ) -> Double {
return vDSP.minimum(lhs.values)
}
public func max( _ lhs : Matrix ) -> Double {
return vDSP.maximum(lhs.values)
}
public func maxel (_ lhs: Double, _ rhs: Matrix) -> Matrix {
var result = rhs
result.values = rhs.values.map { Swift.max(lhs, $0) }
return result
}
public func minel (_ lhs: Double, _ rhs: Matrix) -> Matrix {
var result = rhs
result.values = rhs.values.map { Swift.min(lhs, $0) }
return result
}
public func shuffle( _ A : Matrix, _ type : MatrixAxes ) -> Matrix {
var B = A
switch( type ) {
case .column:
let m = Array((0...(A.columns-1)).shuffled())
for i in 0..<m.count {
B[.all, i] = A[.all, m[i]]
}
break
case .row:
let m = Array((0...(A.rows-1)).shuffled())
for i in 0..<m.count {
B[i, .all] = A[m[i], .all]
}
break
default:
break
}
return B
}
public func Σ(_ lhs: Matrix, _ axes: MatrixAxes = .column) -> Matrix {
switch axes {
case .column:
var result = Matrix(rows: 1, columns: lhs.columns, repeatedValue: 0.0)
for i in 0..<lhs.columns {
result.values[i] = vDSP.sum(lhs[.all,i].values)
}
return result
case .row:
var result = Matrix(rows: lhs.rows, columns: 1, repeatedValue: 0.0)
for i in 0..<lhs.rows {
result.values[i] = vDSP.sum(lhs[i, .all].values)
}
return result
case .both:
let result = vDSP.sum(lhs.values)
return Matrix([[result]])
}
}
| [
-1
] |
52be70fe8486a49e676cd25069870d55565b6644 | 74cc1059d003090074701845188f717b94491a6d | /framework/Sources/VGSFramework/UIElements/Text Field/VGSTextFieldDelegate.swift | 68eb28d7737b1035aeb2332f3be3a6ba43da2d49 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ilovetea/vgs-collect-ios-1 | ce18816f233a87ccda209f3b39e38a1dc3d71172 | 7099adf6f6c401367f45412c6e111d723370dc66 | refs/heads/master | 2022-04-18T07:05:56.904212 | 2020-04-14T16:25:37 | 2020-04-14T16:25:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 785 | swift | //
// VGSTextFieldDelegate.swift
// VGSFramework
//
// Created by Vitalii Obertynskyi on 22.02.2020.
// Copyright © 2020 VGS. All rights reserved.
//
#if canImport(UIKit)
import UIKit
#endif
/// Delegates produced by `VGSTextField` instance.
@objc
public protocol VGSTextFieldDelegate {
// MARK: - Handle user ineraction with VGSTextField
/// VGSTextField did become first responder.
@objc optional func vgsTextFieldDidBeginEditing(_ textfield: VGSTextField)
/// VGSTextField did resign first responder.
@objc optional func vgsTextFieldDidEndEditing(_ textfield: VGSTextField)
/// VGSTextField did resign first responder on Return button pressed.
@objc optional func vgsTextFieldDidEndEditingOnReturn(_ textfield: VGSTextField)
}
| [
-1
] |
dc68886bcc13ecf66449445e88a333bf24c42f59 | c63de9f0c2d00ba0a5b220d1edeff409d2400e0b | /TestOOP/AppDelegate.swift | 15336ecd66789fcf5e9d9994adc170b114845787 | [] | no_license | NeoPollutan/TestOOP | f6a5aff156b6b646cbb9f1fcddd0f066680299b1 | a1e6f3d7536d87cc7ddcda3b3608a455abe0c23f | refs/heads/master | 2020-05-23T11:14:40.921747 | 2019-05-15T03:14:48 | 2019-05-15T03:14:48 | 186,734,161 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,199 | swift | //
// AppDelegate.swift
// TestOOP
//
// Created by Rizky Adipratama Ruddyar on 15/05/19.
// Copyright © 2019 Rizky Adipratama Ruddyar. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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,
229391,
327695,
278545,
229394,
278548,
229397,
229399,
229402,
352284,
229405,
278556,
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,
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,
295110,
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,
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,
172748,
287436,
107212,
172751,
287440,
295633,
172755,
303827,
279255,
172760,
287450,
303835,
279258,
189149,
303838,
213724,
312035,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
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,
189325,
189329,
295825,
304019,
189331,
213902,
58262,
304023,
304027,
279452,
234648,
410526,
279461,
279462,
304042,
213931,
230327,
304055,
287675,
197564,
230334,
304063,
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,
279661,
205934,
164973,
312432,
279669,
337018,
189562,
279679,
304258,
279683,
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,
296215,
320792,
230681,
230679,
214294,
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,
312712,
296331,
288140,
288144,
230800,
304533,
337306,
288154,
288160,
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,
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,
239152,
230961,
157236,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
288344,
280152,
239194,
280158,
403039,
181854,
370272,
239202,
370279,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
419489,
190118,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
419522,
313027,
280260,
419525,
206536,
280264,
206539,
206541,
206543,
313044,
280276,
321239,
280283,
313052,
18140,
288478,
313055,
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,
337732,
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,
321560,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
215090,
124980,
288824,
288826,
321595,
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,
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,
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,
436684,
281045,
281047,
215526,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
305668,
223749,
330244,
281095,
223752,
150025,
338440,
240132,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
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,
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,
142226,
289687,
240535,
224151,
297883,
289694,
289696,
289700,
289712,
281529,
289724,
52163,
183260,
420829,
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,
282127,
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,
282255,
282261,
175770,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
306856,
196133,
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,
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,
176435,
307508,
315701,
332086,
307510,
307512,
168245,
307515,
307518,
282942,
282947,
323917,
110926,
282957,
233808,
323921,
315733,
323926,
233815,
276052,
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,
127434,
315856,
176592,
127440,
315860,
176597,
127447,
283095,
299481,
127449,
176605,
242143,
127455,
127457,
291299,
340454,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
127490,
283142,
127494,
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,
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,
185074,
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,
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,
234364,
291711,
234368,
291714,
234370,
291716,
234373,
316294,
201603,
226182,
308105,
234375,
226185,
234379,
324490,
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,
234501,
275462,
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,
283805,
234657,
242852,
300197,
234661,
283813,
234664,
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,
349451,
275725,
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,
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,
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,
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,
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,
292721,
284529,
300915,
284533,
292729,
317306,
284540,
292734,
325512,
169868,
276365,
317332,
358292,
284564,
399252,
284566,
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,
276452,
292839,
276455,
350186,
292843,
276460,
292845,
276464,
178161,
227314,
325624,
350200,
276472,
317435,
276479,
276482,
350210,
276485,
317446,
178181,
276490,
350218,
292876,
350222,
317456,
276496,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
276528,
178224,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
243779,
325700,
284739,
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,
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,
309494,
243960,
276735,
227583,
227587,
276739,
211204,
276742,
227593,
227596,
325910,
309530,
342298,
211232,
317729,
276775,
211241,
325937,
325943,
211260,
260421,
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,
227810,
293346,
276964,
293352,
236013,
293364,
301562,
293370,
317951,
309764,
301575,
121352,
293387,
236043,
342541,
317963,
113167,
55822,
309779,
317971,
309781,
55837,
227877,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
219714,
129603,
301636,
318020,
301639,
301643,
277071,
285265,
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,
334488,
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,
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,
310080,
293696,
277317,
277322,
293706,
277329,
162643,
310100,
301911,
301913,
277337,
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,
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,
277804,
384302,
285999,
285997,
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,
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,
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,
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,
187936,
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,
319163,
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,
229233,
294776,
360317,
294785,
327554,
360322,
40840,
40851,
294803,
188312,
294811,
237470,
319390,
40865,
319394,
294817,
294821,
311209,
180142,
343983,
188340,
40886,
319419,
294844,
294847,
237508,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
311283,
278516,
278519,
237562
] |
90df6b17011ed6535714df2a80420c971d830a47 | c80cdb19f4a7bed83d8bec782b0ff83ed3f6d916 | /DoubleUp/View Controllers/GamesTableViewController.swift | 9f03698dcfc23b7231f20b6cf0fe4612e2ca8795 | [] | no_license | GlennOlsson/DoubleUp-App | 1150d59b510323735e0588f8ff5a8e15361cfc57 | 346060109148c74bed599a55e069f6b8ff29233c | refs/heads/master | 2021-04-03T08:15:32.203699 | 2018-03-09T21:20:25 | 2018-03-09T21:20:25 | 124,394,837 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 6,913 | swift | //
// GamesTableViewController.swift
// DoubleUp
//
// Created by Glenn Olsson on 2018-02-03.
// Copyright © 2018 Glenn Olsson. All rights reserved.
//
import Foundation
import UIKit
import SwiftyJSON
import Alamofire
class GamesTableViewController: UITableViewController {
@IBOutlet weak var createUserButton: UIButton!
var games: [Game]!
var doneGames: [Game] = []
var myTurnGames: [Game] = []
var opponentTurnGames: [Game] = []
@IBOutlet var tableViewOutlet: UITableView!
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
updateLabels()
getGames()
games = gamesList
assignGamesToLists()
self.refreshControl?.addTarget(self, action: #selector(reloadTableContent(refreshControl:)), for: UIControlEvents.valueChanged)
self.tableView.addSubview(self.refreshControl!)
tableViewOutlet.reloadData()
}
@objc func reloadTableContent(refreshControl: UIRefreshControl){
getGames()
games = gamesList
assignGamesToLists()
self.tableView.reloadData()
refreshControl.endRefreshing()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool){
super.viewWillAppear(animated)
if getUserToken() == nil{
createUserButton.isHidden = false
}
updateLabels()
getUserInfo()
print("GETTING GAME")
reloadTableContent(refreshControl: self.refreshControl!)
}
override func viewDidAppear(_ animated: Bool) {
reloadTableContent(refreshControl: self.refreshControl!)
}
override func viewWillDisappear(_ animated: Bool){
super.viewWillDisappear(animated)
print("GETTING GAME")
//getGames()
reloadTableContent(refreshControl: self.refreshControl!)
}
func updateLabels(){
}
func assignGamesToLists(){
doneGames.removeAll()
myTurnGames.removeAll()
opponentTurnGames.removeAll()
for game in games{
if game.over{
doneGames.append(game)
}
else{
if game.turn{
myTurnGames.append(game)
}
else{
opponentTurnGames.append(game)
}
}
}
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 4
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var numberOfRows = 0
switch section {
case 0:
numberOfRows = 1
case 1:
numberOfRows = myTurnGames.count
case 2:
numberOfRows = opponentTurnGames.count
default:
numberOfRows = doneGames.count
}
return numberOfRows
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
var title: String? = ""
switch section {
case 0:
title = nil
case 1:
title = "Your turn"
case 2:
title = "Opponent's turn"
default:
title = "Finished games"
}
return title
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: tableView.sectionHeaderHeight))
// Do your customization
view.backgroundColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1)
return view
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "GameCell"
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)
let row = indexPath.row
var game: Game!
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleCell", for: indexPath)
if let bank = getBank(){
cell.textLabel?.text = String(bank)
}
cell.detailTextLabel?.text = getUsername()
return cell
case 1:
game = myTurnGames[row]
case 2:
game = opponentTurnGames[row]
default:
game = doneGames[row]
}
cell.textLabel?.text = "\(game.opponent)"
cell.detailTextLabel?.text = String(game.amount)
if game.over{
let textColor = game.turn ? UIColor(red: 0, green: 1, blue: 0, alpha: 1) :
UIColor(red: 1, green: 0, blue: 0, alpha: 1)
cell.detailTextLabel?.textColor = textColor
}
else{
let textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
cell.detailTextLabel?.textColor = textColor
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt
indexPath: IndexPath) {
let row = indexPath.row
var game: Game!
switch indexPath.section {
case 0:
//Top cell
return
case 1:
game = myTurnGames[row]
case 2:
game = opponentTurnGames[row]
default:
game = doneGames[row]
}
print("ID: \(game.ID), over? \(game.over)")
performSegue(withIdentifier: "playGameStoryboard", sender: game)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "playGameStoryboard"{
let vc = segue.destination as! PlayGameViewController
let game = sender as! Game
vc.gameID = game.ID
vc.currentAmount = game.amount
vc.opponentUsername = game.opponent
vc.myTurn = game.turn
vc.isOver = game.over
}
}
@IBAction func createUserButtonPressed(_ sender: Any) {
createUserButton.isHidden = true
}
}
| [
-1
] |
f8ffaaecc5a46dd7db6ebc9b95f453ad7d3ce30d | fbf8942d3dc0b24776fc0638553d83d438252f01 | /BookHack/BookHack/Presentation Layer/Design/AppTexts.swift | dd89f2f5f60dc6102cdb9b2c66859215e7bd8141 | [] | no_license | sergeyzaytsevkaliningrad/Book-haring- | 8bb9578f2ab8b2d42f455774a1de613784efe06d | 6657ee88669de0a49de26d249d2664293b5b9956 | refs/heads/main | 2023-03-28T07:06:12.838318 | 2021-03-21T17:18:04 | 2021-03-21T17:18:04 | 349,658,784 | 0 | 0 | null | 2021-03-21T12:56:57 | 2021-03-20T07:37:49 | Swift | UTF-8 | Swift | false | false | 1,167 | swift | //
// AppTexts.swift
// Pokushats
//
// Created by Yoav Nemirovsky on 04.09.2020.
// Copyright © 2020 Yoav. All rights reserved.
//
import Foundation
enum AppTexts {
enum AuthFlow {
enum EnterPhoneNumber {
static let phonePlaceholder = "Введите номер телефона"
static let title = "Введите ваш номер телефона"
}
enum PhoneVerification {
static let title = "Введите 6-значный код, отправленный на "
static let wrongCodeError = "Вы ввели неверный код. Пожалуйста, попробуйте еще раз."
}
enum EnterName {
static let title = "Ваше имя:"
static let namePlaceHolder = ". . ."
}
static let nextButton = "Продолжить"
enum Welcome {
static let headerLabel = "Чтобы забрать книжку, нужно зарегистрироваться :)"
static let firstButtonTitle = "Далее"
}
}
}
| [
-1
] |
17f498c69b23e5d90a85ed304085fcadcfe53d8f | 97792f117463df10c1c4cefa50a355007cb17015 | /AzureAuth/Source/AzureAuth.swift | f5b4ff281e01924b0f229fab58709d88e41bc777 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | aksharS/Azure.iOS | 88f98de2050f732489d3dacc4c7e9279734e1ef3 | 92f52dc11f80eabca7b989476f369396307317ed | refs/heads/master | 2020-06-24T16:44:45.049284 | 2019-07-18T12:30:02 | 2019-07-18T12:30:02 | 199,020,258 | 1 | 0 | MIT | 2019-07-26T13:20:36 | 2019-07-26T13:20:36 | null | UTF-8 | Swift | false | false | 1,061 | swift | //
// AzureAuth.swift
// AzureAuth
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
import Foundation
import AzureCore
public class AzureAuth {
public static var user: AuthUser? {
return AuthClient.shared.user
}
public static func authHeader() throws -> (key:String, value:String) {
return try AuthClient.shared.authHeader()
}
public static func login(to service: URL, with provider: IdentityProvider, completion: @escaping (Response<AuthUser>) -> Void) {
return AuthClient.shared.login(to: service, with: provider, completion: completion)
}
public static func refresh(for service: URL, completion: @escaping (Response<AuthUser>) -> Void) {
return AuthClient.shared.refresh(for: service, completion: completion)
}
}
extension URLRequest {
public mutating func addAuthHeader() throws {
let header = try AuthClient.shared.authHeader()
addValue(header.value, forHTTPHeaderField: header.key)
}
}
| [
-1
] |
4fef887d7731a95b7b91e66d3ec545327162021c | d80084eb932cbeec024b0919fd346c585b51ac5b | /Fixed/FB9127171 - Keyboard will not appear after UIResponder.resignFirstResponder/XCTestTextFieldDemo/SceneDelegate.swift | 9dac72200f697ccf2faeec43da20feddf046277d | [] | no_license | mkalmes/feedbackassistant.apple.com | 2f9398a670b8170e544bdd772b4296dd9eb66976 | 83e44184ab56646911453762c4167bf94919f948 | refs/heads/master | 2023-06-24T20:09:50.443411 | 2021-07-29T10:45:46 | 2021-07-29T10:45:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 689 | swift | 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 }
}
}
| [
372748,
347438,
360335,
326963,
391455
] |
d4efd01ec4358fe1420aade656acaf95a665157c | f73aa868178c7c792963604cda2554f122663f77 | /tableViewTest/TableViewCell.swift | 18275c4d987c26fd9ef4b63e2817ffdae94318f6 | [] | no_license | HenryPearson1/tableViewTest | d82258dc67a223db29ab2d406f96f848c761ea3c | d0c72bd09fa326fedf3cc0f26860e4ab367e6d09 | refs/heads/master | 2021-09-06T07:17:44.807758 | 2018-02-03T09:38:15 | 2018-02-03T09:38:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 589 | swift | //
// TableViewCell.swift
// tableViewTest
//
// Created by Henry Pearson on 03/02/2018.
// Copyright © 2018 Henry Pearson. All rights reserved.
//
import UIKit
class TableViewCell: UITableViewCell {
@IBOutlet weak var nameOutlet: UILabel!
@IBOutlet weak var imageOutlet: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
| [
379140,
277904,
283152,
307219,
278303,
258720,
284450,
337317,
313389,
310840,
393537,
349123,
327370,
289226,
276814,
278228,
213096,
249067,
277355,
271089,
222835,
244602,
305659
] |
8183f1e7fcf4e2b5c2cfdbc2f74d3663592d9d94 | 5118e021d07f024272f8dc82f7f30a0e11a55dc0 | /youtube-easy-app/Helpers/CacheManager.swift | 247f745a1fef316cdb886ecd47e1c35c9b7db484 | [] | no_license | CodeCorner-Grafingegno/youtube-easy-app | b1d3f1875c29fc7950a8f1928359f2d4f8167547 | 991738c79bfd8251060e9f830c071bf5a12f8382 | refs/heads/main | 2023-01-02T09:20:04.347940 | 2020-10-21T08:47:37 | 2020-10-21T08:47:37 | 304,659,033 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 403 | swift | //
// CacheManager.swift
// youtube-easy-app
//
// Created by Gianluca Gandini on 19/10/2020.
//
import Foundation
class CacheManager {
static var cache = [String:Data]()
static func setVideoCache(_ url:String, _ data:Data) {
cache[url] = data
}
static func getVideoCache(_ url:String) -> Data? {
return cache[url]
}
}
| [
-1
] |
15040d91fd0f77bb5199c23e805ef2d72c12825e | 2b7fea211edec6fb6329b978a44012c9f6234a24 | /DemoApp/viewCells/BrandTblCell.swift | df7814dbe911a899d763264954b8b214d2490429 | [] | no_license | rabeehkp/OnlineShoping | 621d076867cca3268ebd67908da98d9595e8b125 | a458a8439ae167276729e80bae506fafe00e6701 | refs/heads/master | 2021-05-10T20:05:36.121032 | 2018-01-21T10:44:29 | 2018-01-21T10:44:29 | 118,173,968 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 375 | swift | //
// BrandTblCell.swift
// DemoApp
//
// Created by Rabeeh KP on 06/01/18.
// Copyright © 2018 Rabeeh KP. All rights reserved.
//
import UIKit
class BrandTblCell: UITableViewCell {
//MARK: -Outlets
@IBOutlet weak var brandNameLbl: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
| [
-1
] |
04ec02feaf78d22b8e3a2275743ac9a7ec1806e7 | 9b0bfdd42944aa63df0f7b04ac32ce50759c3b60 | /Alchemie/Cells/Options/CreateSubOptionTableViewCell.swift | 3798bf65ac3647c5e064c384b0167ef5a7f31866 | [] | no_license | steven7/EducationApp | cd80a1b61f66ddeaf4a1da55c1f82856c36da74e | c9019011535a0d2ca9695df5c2dc3d545216f8f0 | refs/heads/master | 2018-11-09T07:06:15.056276 | 2018-08-21T00:37:19 | 2018-08-21T00:37:19 | 115,132,931 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 516 | swift | //
// CreateSubOptionTableViewCell.swift
// Alchemie
//
// Created by Steven Kanceruk on 12/20/17.
// Copyright © 2017 steve. All rights reserved.
//
import UIKit
class CreateSubOptionTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
| [
259202,
322306,
240008,
307465,
287242,
398865,
245522,
328220,
283040,
131748,
283048,
337321,
228144,
327344,
64691,
303540,
180676,
300356,
379078,
311754,
312531,
312535,
155614,
37218,
217069,
317933,
258931,
244599,
283900,
196093
] |
226679222ef9607dc23f3f43f6c7972b8cb1ff2e | 0beab62395c1042260e38589717c297bd243814a | /VisualizingAPointCloudUsingSceneDepth/SceneDepthPointCloud/ViewController.swift | 86b1a77f98ccb579ac462c2587c560651a003214 | [] | no_license | YellowOrz/ExportDataFromAppleLadar | e0a498cec111344690b1858b95edab21ba45241e | 99ef264554c9376164ffdeb936e66518d49ced0f | refs/heads/master | 2023-04-30T04:13:45.733026 | 2020-09-14T08:09:07 | 2020-09-14T08:09:07 | 280,296,240 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 6,871 | swift | /*
See LICENSE folder for this sample’s licensing information.
Abstract:
Main view controller for the AR experience.
*/
import UIKit
import Metal
import MetalKit
import ARKit
final class ViewController: UIViewController, ARSessionDelegate {
// 开关
@IBOutlet weak var saveCamera: UISwitch!
@IBOutlet weak var saveRGB: UISwitch!
@IBOutlet weak var saveConf: UISwitch!
@IBOutlet weak var saveDepthPNG: UISwitch!
@IBOutlet weak var saveDepthTXT: UISwitch!
// 数据保存选项
var saveCamerEnable:Bool = true
var saveRGBEnable:Bool = true
var saveConfEnable:Bool = true
var saveDepthPNGEnable:Bool = true
var saveDepthTXTEnable:Bool = true
private let isUIEnabled = true
private let confidenceControl = UISegmentedControl(items: ["Low", "Medium", "High"])
private let rgbRadiusSlider = UISlider()
private let session = ARSession()
private var renderer: Renderer!
// 开关操作触发
@IBAction func changeCameraEnable(_ sender: UISwitch) {
saveCamerEnable = sender.isOn
}
@IBAction func changeRGBEnable(_ sender: UISwitch) {
saveRGBEnable = sender.isOn
}
@IBAction func changeConfEnable(_ sender: UISwitch) {
saveConfEnable = sender.isOn
}
@IBAction func changeDepthPNGEnable(_ sender: UISwitch) {
saveDepthPNGEnable = sender.isOn
}
@IBAction func changeDepthTXTEnable(_ sender: UISwitch) {
saveDepthPNGEnable = sender.isOn
}
override func viewDidLoad() {
super.viewDidLoad()
guard let device = MTLCreateSystemDefaultDevice() else {
print("Metal is not supported on this device")
return
}
session.delegate = self
// Set the view to use the default device
if let view = view as? MTKView {
view.device = device
view.backgroundColor = UIColor.clear
// we need this to enable depth test
view.depthStencilPixelFormat = .depth32Float
view.contentScaleFactor = 1
view.delegate = self
// Configure the renderer to draw to the view
renderer = Renderer(session: session, metalDevice: device, renderDestination: view)
renderer.drawRectResized(size: view.bounds.size)
}
// Confidence control
confidenceControl.backgroundColor = .white
confidenceControl.selectedSegmentIndex = renderer.confidenceThreshold
confidenceControl.addTarget(self, action: #selector(viewValueChanged), for: .valueChanged)
// RGB Radius control
rgbRadiusSlider.minimumValue = 0
rgbRadiusSlider.maximumValue = 1.5
rgbRadiusSlider.isContinuous = true
rgbRadiusSlider.value = renderer.rgbRadius
rgbRadiusSlider.addTarget(self, action: #selector(viewValueChanged), for: .valueChanged)
let stackView = UIStackView(arrangedSubviews: [confidenceControl, rgbRadiusSlider])
stackView.isHidden = !isUIEnabled
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 20
view.addSubview(stackView)
NSLayoutConstraint.activate([
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -50)
])
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a world-tracking configuration, and
// enable the scene depth frame-semantic.
let configuration = ARWorldTrackingConfiguration()
configuration.frameSemantics = .sceneDepth
// Run the view's session
session.run(configuration)
// The screen shouldn't dim during AR experiences.
UIApplication.shared.isIdleTimerDisabled = true
}
@objc
private func viewValueChanged(view: UIView) {
switch view {
case confidenceControl:
renderer.confidenceThreshold = confidenceControl.selectedSegmentIndex
case rgbRadiusSlider:
renderer.rgbRadius = rgbRadiusSlider.value
default:
break
}
}
// Auto-hide the home indicator to maximize immersion in AR experiences.
override var prefersHomeIndicatorAutoHidden: Bool {
return true
}
// Hide the status bar to maximize immersion in AR experiences.
override var prefersStatusBarHidden: Bool {
return true
}
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user.
guard error is ARError else { return }
let errorWithInfo = error as NSError
let messages = [
errorWithInfo.localizedDescription,
errorWithInfo.localizedFailureReason,
errorWithInfo.localizedRecoverySuggestion
]
let errorMessage = messages.compactMap({ $0 }).joined(separator: "\n")
DispatchQueue.main.async {
// Present an alert informing about the error that has occurred.
let alertController = UIAlertController(title: "The AR session failed.", message: errorMessage, preferredStyle: .alert)
let restartAction = UIAlertAction(title: "Restart Session", style: .default) { _ in
alertController.dismiss(animated: true, completion: nil)
if let configuration = self.session.configuration {
self.session.run(configuration, options: .resetSceneReconstruction)
}
}
alertController.addAction(restartAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
// MARK: - MTKViewDelegate
extension ViewController: MTKViewDelegate {
// Called whenever view changes orientation or layout is changed
func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) {
renderer.drawRectResized(size: size)
}
// Called whenever the view needs to render
func draw(in view: MTKView) {
renderer.draw(camera: saveCamerEnable, RGB: saveRGBEnable, Conf: saveConfEnable, DepthPNG: saveDepthPNGEnable, DepthTXT: saveDepthTXTEnable)
}
}
// MARK: - RenderDestinationProvider
protocol RenderDestinationProvider {
var currentRenderPassDescriptor: MTLRenderPassDescriptor? { get }
var currentDrawable: CAMetalDrawable? { get }
var colorPixelFormat: MTLPixelFormat { get set }
var depthStencilPixelFormat: MTLPixelFormat { get set }
var sampleCount: Int { get set }
}
extension MTKView: RenderDestinationProvider {
}
| [
-1
] |
7771c0ec4fc8455c199ce46585b32cb33b3bd1d9 | eaed9cbc786faf87d580c6699bcb46e34ae49fe7 | /ImageDownloader/CoreData/ImageInformation+CoreDataProperties.swift | 8a151dc4bd5dd504d08d2cb22aac6c3603fb0592 | [] | no_license | abhijeetbarge/ImageDownloader | ee0cd627cf3ef3c0e8b4d7624f02fd842456d226 | a761ded9832258b52028537f36ef7eb98b821a5d | refs/heads/master | 2020-03-18T10:03:22.335194 | 2018-05-23T16:24:59 | 2018-05-23T16:24:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 526 | swift | //
// ImageInformation+CoreDataProperties.swift
// ImageDownloader
//
// Created by Abhijeet on 23/05/18.
//
//
import Foundation
import CoreData
extension ImageInformation {
@nonobjc public class func fetchRequest() -> NSFetchRequest<ImageInformation> {
return NSFetchRequest<ImageInformation>(entityName: "ImageInformation")
}
@NSManaged public var imageURL: String?
@NSManaged public var imageData: NSData?
@NSManaged public var isDownloaded: Bool
@NSManaged public var id: Int64
}
| [
-1
] |
399b524b59bb8afdca7eff06f9f055a19d0f3594 | f2327ceea18bc064d4849cd862bf83716aabc9f0 | /Pomodoro/ViewController.swift | 5629ce38682b5bce901f7537686719d3660d9405 | [] | no_license | shannoncoyne/pomodoro | a4de52c69fc4e0c7da162e26952905cc77a6cec2 | 1d16a4cb3dc0c1f0329c9ef91d090c9cbc5ddf37 | refs/heads/master | 2020-05-02T17:55:33.560211 | 2015-08-14T00:48:11 | 2015-08-14T00:48:11 | 40,688,355 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,360 | swift | //
// ViewController.swift
// Pomodoro
//
// Created by Shannon Coyne on 8/1/15.
// Copyright (c) 2015 Shannon Coyne. All rights reserved.
//
import Foundation
class ViewController: UIViewController {
@IBOutlet weak var loginButton: FBSDKLoginButton! {
didSet {
loginButton.readPermissions = ["public_profile", "email", "user_friends"]
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let accessToken = FBSDKAccessToken.currentAccessToken() {
// user is logged in
println("User's ID is \(accessToken.userID)")
println("permissions: \(accessToken.permissions)")
getFBUserData()
} else {
// user is not logged in
}
}
func getFBUserData() {
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me?fields=id,email,name,friends", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil) {
// Process error
println("Error: \(error)")
} else {
println("fetched result: \(result)")
}
})
}
} | [
-1
] |
18ad3a5af0d97d516ab1ce4153381f4ab784fa72 | 5c721a05e7038264c9fb4d28452ee0230359b626 | /源代码/7.1.3UIControl_CustomizingControl/07UIControlExample/AppDelegate.swift | e6aea5564edc21457ee5b5dcec423c893f8d2b53 | [
"MIT"
] | permissive | CoderDream/iOS_Development_From_Entry_To_Master | c7f9fb02999d8f7309c2662d7bf8ab0c775c969d | 80f63e27834302a1d85118178e2458ef89fc54c3 | refs/heads/master | 2020-04-24T12:56:11.555558 | 2019-05-27T13:15:39 | 2019-05-27T13:15:39 | 171,971,097 | 4 | 1 | null | null | null | null | UTF-8 | Swift | false | false | 2,169 | swift | //
// AppDelegate.swift
// 07UIControlExample
//
// Created by 王亮 on 16/6/7.
// Copyright © 2016年 www.coolketang.com. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
| [
229380,
229383,
229385,
278539,
229388,
278542,
229391,
278545,
229394,
278548,
229397,
229399,
229402,
278556,
229405,
278559,
278564,
237613,
286774,
204856,
319544,
286776,
286791,
237640,
278605,
286797,
311375,
196692,
319573,
278626,
319590,
278635,
303212,
278639,
131192,
237693,
327814,
131209,
303241,
417930,
311436,
303244,
319633,
286873,
286876,
311469,
32944,
286906,
327866,
286910,
286916,
286922,
286924,
319694,
286926,
286928,
131281,
278743,
278747,
295133,
155872,
319716,
237807,
303345,
286962,
229622,
327930,
278781,
278783,
278785,
278792,
286987,
311569,
286999,
319770,
287003,
287006,
287012,
287014,
287016,
311598,
287023,
262448,
311601,
155966,
278849,
319809,
319814,
311623,
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,
287238,
320007,
172550,
172552,
303623,
279051,
172558,
279055,
279058,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
279084,
172591,
172598,
279095,
172607,
172609,
172612,
377413,
172618,
303690,
33357,
279124,
262752,
311911,
189034,
295533,
189039,
189040,
172655,
172656,
295538,
189044,
172660,
287349,
352880,
287355,
287360,
295553,
287365,
295557,
303751,
311942,
352905,
279178,
287371,
311946,
311951,
287377,
287381,
311957,
221850,
164509,
287390,
295583,
230045,
303773,
287394,
303780,
287398,
287400,
279208,
279212,
172721,
287409,
66227,
303797,
328381,
279231,
287423,
328384,
287427,
107208,
107212,
287436,
287440,
295633,
172755,
303827,
279255,
279258,
303835,
213724,
189149,
303838,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
205564,
303871,
230146,
295685,
328453,
33548,
312077,
295695,
295701,
369433,
230169,
295707,
328476,
295710,
230175,
279340,
279353,
230202,
312124,
222018,
295755,
148302,
287569,
303959,
230237,
279390,
230241,
303976,
336744,
303985,
328563,
303987,
303991,
303997,
295808,
304005,
320391,
213895,
304007,
304009,
304011,
304013,
213902,
279438,
295822,
295825,
304019,
279445,
58262,
304023,
279452,
279461,
279462,
304042,
213931,
230327,
287675,
304063,
238528,
304065,
189378,
213954,
156612,
312272,
304084,
304090,
320481,
320490,
312302,
320496,
304114,
295928,
320505,
295945,
197645,
295949,
230413,
320528,
140312,
238620,
304164,
189479,
238641,
238652,
238655,
230465,
238658,
296004,
336964,
205895,
320584,
238666,
296021,
402518,
230497,
296036,
296040,
361576,
205931,
296044,
164973,
205934,
279661,
312432,
279669,
189562,
337018,
279679,
279683,
205968,
296084,
304285,
238756,
205991,
222377,
165035,
165038,
230576,
304311,
230592,
279750,
312518,
148690,
279769,
304348,
304354,
296163,
279781,
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,
296267,
296271,
222545,
222556,
337244,
230752,
230760,
173418,
410987,
230763,
230768,
296305,
230773,
279929,
181626,
304506,
296331,
288140,
230800,
288144,
337306,
288160,
173472,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
279985,
312755,
296373,
279991,
337335,
312759,
288185,
222652,
173507,
296389,
222665,
230860,
312783,
230865,
288210,
370130,
288212,
280021,
288214,
222676,
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,
370187,
304651,
304653,
230940,
222752,
108066,
296486,
296488,
230961,
288320,
288325,
124489,
280140,
280149,
288344,
280152,
239194,
280158,
403039,
370272,
312938,
280183,
280185,
280188,
280191,
280194,
116354,
280208,
280211,
280218,
280222,
321195,
296622,
337585,
296626,
296634,
296637,
280260,
280264,
206536,
206539,
206541,
206543,
280276,
321239,
280283,
288478,
313055,
321252,
313066,
280302,
288494,
419570,
288499,
288502,
280314,
124671,
67330,
280324,
280331,
198416,
116503,
321304,
329498,
296731,
313121,
313123,
304932,
321316,
280363,
141101,
280375,
321336,
288576,
345921,
280388,
280402,
280419,
321381,
296812,
313201,
1920,
255873,
305028,
247688,
280464,
124817,
280468,
239510,
280473,
124827,
247709,
280487,
313258,
296883,
124853,
10170,
296890,
288700,
296894,
280515,
190403,
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,
321595,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
288848,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
280671,
223327,
149599,
321634,
149603,
280681,
313451,
223341,
280687,
280691,
313464,
280702,
288895,
321670,
215175,
141455,
280725,
313498,
288936,
100520,
280747,
288940,
280755,
288947,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
280804,
280807,
157930,
280811,
280817,
280819,
157940,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
280835,
125187,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
305464,
280891,
280897,
280900,
239944,
305480,
280906,
239947,
305485,
305489,
280919,
313700,
280937,
313705,
280940,
190832,
280946,
313720,
280956,
280959,
313731,
240011,
289166,
240017,
297363,
190868,
240021,
297365,
297368,
297372,
141725,
297377,
289186,
289201,
240052,
289207,
289210,
305594,
281024,
289218,
289221,
289227,
281045,
281047,
215526,
166378,
281075,
174580,
281084,
240124,
305662,
305664,
240129,
305666,
240132,
223749,
305668,
281095,
338440,
223752,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
281135,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
199262,
338532,
199273,
281196,
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,
207661,
289593,
281401,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207737,
183172,
338823,
322440,
314249,
183184,
240535,
297883,
289694,
289700,
289712,
281529,
289724,
281567,
289762,
322534,
297961,
183277,
134142,
322610,
314421,
281654,
207937,
314433,
322642,
281691,
314461,
281702,
281704,
281711,
289912,
248995,
306341,
306347,
142531,
199877,
289991,
306377,
363742,
363745,
298216,
216303,
388350,
363802,
314671,
298292,
298294,
216376,
380226,
224584,
224587,
224594,
306517,
150870,
314714,
224603,
159068,
314718,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
306549,
314743,
306552,
290171,
306555,
314747,
290174,
224641,
281987,
298372,
314756,
281990,
224647,
298377,
314763,
142733,
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,
175621,
192008,
323084,
282127,
290321,
282130,
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,
282261,
298651,
282269,
323229,
298655,
282277,
282295,
282300,
323266,
282310,
282319,
306897,
241362,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
282376,
216842,
323345,
282388,
282392,
184090,
315167,
315169,
282402,
241448,
315176,
282410,
241450,
306988,
315190,
282425,
159545,
298811,
307009,
413506,
307012,
315211,
307027,
315221,
282454,
241496,
241498,
307035,
282465,
241509,
110438,
298860,
110445,
282478,
282481,
110450,
315251,
315253,
315255,
339838,
282499,
315267,
315269,
241544,
282505,
241546,
241548,
282514,
241556,
282520,
241560,
241563,
241565,
241567,
241569,
282531,
241574,
282537,
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,
241669,
282632,
282639,
282645,
241693,
282654,
102438,
217127,
282669,
282681,
282687,
159811,
315463,
315466,
192589,
307278,
307287,
315482,
217179,
315483,
192605,
200801,
299105,
217188,
299109,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
307338,
233613,
241813,
299164,
184479,
299167,
184481,
307370,
307372,
307374,
307376,
323763,
184503,
176311,
307385,
307386,
258235,
176316,
307388,
299200,
307394,
307396,
184518,
323784,
307409,
307411,
176343,
233701,
307432,
282881,
282893,
291089,
282906,
233766,
307508,
307510,
332086,
151864,
307512,
307515,
282942,
307518,
151874,
282947,
282957,
110926,
233808,
315733,
323926,
233815,
315739,
299357,
242018,
299373,
315757,
242043,
315771,
299391,
291202,
299398,
242057,
291222,
283033,
291226,
242075,
291231,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
299440,
299444,
127413,
283062,
291254,
127417,
291260,
283069,
127421,
127424,
291269,
127431,
176592,
315856,
176597,
283095,
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,
291378,
152118,
234038,
70213,
111193,
242275,
299620,
242279,
184952,
135805,
291456,
135808,
373383,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
135839,
299680,
225954,
242343,
209576,
242345,
373421,
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,
283452,
160572,
234302,
234307,
234309,
234313,
316233,
316235,
283468,
234316,
234319,
234321,
234324,
201557,
234329,
234333,
308063,
234336,
234338,
242530,
349027,
234341,
234344,
234347,
177004,
234350,
324464,
152435,
234356,
234362,
234368,
234370,
234373,
226182,
234375,
226185,
234379,
234384,
234388,
234390,
226200,
234393,
209818,
308123,
234396,
324504,
234398,
291742,
324508,
234401,
291747,
291748,
234405,
291750,
234407,
324518,
324520,
291754,
324522,
226220,
234414,
324527,
291760,
234417,
324531,
226230,
234422,
275384,
324536,
234428,
291773,
226239,
234431,
242623,
324544,
234434,
324546,
226245,
234437,
234439,
234443,
193486,
275406,
193488,
234446,
234449,
234452,
234455,
234459,
234461,
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,
234523,
234528,
234532,
300069,
234535,
234537,
234540,
234546,
275508,
234549,
300085,
300088,
234556,
234558,
316479,
234561,
234563,
308291,
316483,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
234590,
234593,
234595,
234597,
234601,
300139,
234605,
234607,
160879,
275569,
234610,
300148,
234614,
398455,
234618,
144506,
234620,
275579,
234623,
226433,
234627,
275588,
234634,
234636,
177293,
234640,
275602,
234643,
226453,
275606,
234647,
275608,
234648,
234650,
308379,
324757,
283805,
234653,
119967,
300189,
234657,
324768,
242852,
283813,
234661,
300197,
234664,
275626,
234667,
308414,
234687,
316610,
300226,
283844,
308418,
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,
283917,
242957,
275725,
177424,
300301,
349464,
283939,
259367,
283951,
292143,
300344,
243003,
283963,
226628,
283973,
300357,
283983,
357722,
316766,
218464,
316768,
292197,
316774,
136562,
324978,
275834,
275840,
316803,
316814,
226703,
234899,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
284076,
144814,
284084,
284087,
292279,
144826,
144828,
144830,
144832,
284099,
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,
284226,
243268,
284228,
226886,
284231,
128584,
292421,
284234,
366155,
276043,
317004,
284238,
226895,
284241,
194130,
292433,
276052,
276053,
300628,
284245,
284247,
235097,
243290,
284251,
284249,
284253,
300638,
284255,
284258,
292452,
292454,
284263,
284265,
292458,
284267,
292461,
284272,
284274,
276086,
284278,
292470,
292473,
284283,
276093,
284286,
276095,
284288,
292479,
276098,
284290,
284292,
292481,
292485,
325250,
284297,
317066,
284299,
276109,
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,
276170,
284362,
284368,
284370,
317138,
358098,
284377,
276187,
284379,
284381,
284384,
284386,
276197,
317158,
284392,
325353,
284394,
284397,
276206,
284399,
358128,
358135,
276216,
358140,
284413,
358142,
284418,
317187,
317191,
284428,
300816,
300819,
317207,
284440,
186139,
300828,
300830,
276255,
300832,
284449,
300834,
325408,
227109,
317221,
358183,
276268,
300845,
194351,
243504,
284469,
276280,
325436,
276291,
366406,
276295,
153417,
276308,
284502,
317271,
276315,
284511,
227175,
300912,
284529,
292721,
300915,
292729,
284540,
292734,
325512,
284564,
358292,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
284585,
317353,
276395,
292784,
161718,
358326,
276410,
358330,
276411,
276418,
301009,
358360,
276446,
153568,
276448,
276452,
276455,
292839,
292843,
276460,
276464,
178161,
276466,
227314,
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,
276553,
243785,
350293,
350295,
194649,
227418,
309337,
194654,
227423,
350302,
178273,
227426,
276579,
194660,
309346,
227430,
276583,
309348,
309350,
350308,
276586,
309354,
350313,
276590,
350316,
227440,
301167,
284786,
276595,
350321,
350325,
350328,
292985,
292989,
317570,
350339,
317573,
350342,
350345,
350349,
317584,
325777,
350354,
350357,
350359,
350362,
276638,
350366,
284837,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
227522,
350402,
301252,
350406,
227529,
301258,
309450,
276685,
276689,
309462,
301272,
309468,
309471,
317672,
276713,
325867,
227571,
309491,
309494,
243960,
227583,
276735,
276739,
276742,
227593,
227596,
325910,
342298,
276766,
211232,
317729,
276775,
325943,
211260,
260421,
276809,
285002,
276811,
235853,
235858,
276829,
276833,
391523,
276836,
276848,
293232,
186744,
211324,
227709,
317833,
178572,
285070,
285077,
227738,
317853,
276896,
317858,
342434,
285093,
285098,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
317910,
293336,
317917,
293343,
358880,
276961,
227810,
293346,
276964,
293352,
236013,
301562,
317951,
301575,
121352,
236043,
342541,
113167,
277011,
309779,
309781,
317971,
227877,
227879,
293417,
293421,
285236,
277054,
129603,
318020,
301639,
301643,
277071,
285265,
399955,
277080,
285277,
285282,
318055,
277100,
309871,
277106,
121458,
170618,
170619,
309885,
309888,
277122,
285320,
277128,
301706,
318092,
326285,
318094,
277136,
277139,
227992,
285340,
318108,
227998,
318110,
137889,
383658,
285357,
318128,
277170,
293555,
154292,
277173,
318132,
342707,
285368,
277177,
277181,
277187,
277191,
277194,
277196,
277201,
137946,
113378,
228069,
277223,
342760,
285417,
56043,
277232,
228081,
56059,
310015,
285441,
310020,
285448,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
293677,
318253,
285489,
293685,
285494,
301880,
301884,
293696,
277317,
277322,
301911,
301913,
277337,
236397,
310134,
277368,
236408,
113538,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
310179,
293798,
236460,
277426,
293811,
293820,
293849,
293861,
228327,
228328,
228330,
318442,
228332,
277486,
326638,
293877,
285686,
302073,
285690,
244731,
293882,
302075,
293887,
277504,
277507,
277511,
277519,
293917,
293939,
277564,
293956,
277573,
228422,
310344,
293960,
277577,
277583,
203857,
293971,
236632,
277594,
277598,
285792,
277601,
310374,
228460,
318573,
203886,
187509,
285815,
285817,
285821,
302205,
285831,
253064,
302218,
285835,
162964,
384148,
302231,
302233,
285849,
285852,
302237,
285854,
285856,
277671,
302248,
64682,
228526,
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,
195822,
228592,
294132,
138485,
228601,
228606,
204031,
310531,
228617,
138505,
318742,
204067,
277798,
130345,
113964,
285997,
113969,
318773,
318776,
286010,
417086,
286016,
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,
245191,
163272,
302534,
310727,
302541,
302543,
310737,
286169,
228825,
163290,
310749,
187880,
286188,
310764,
310772,
212472,
286203,
286214,
228871,
302614,
286233,
302617,
187939,
294435,
286246,
294439,
286248,
294440,
294443,
294445,
212538,
228933,
286283,
228944,
212560,
400976,
147032,
278109,
286312,
286313,
294521,
343679,
310925,
286354,
278163,
122517,
278168,
327333,
229030,
278188,
278192,
278196,
319171,
302789,
294599,
278216,
294601,
302793,
278227,
229076,
286420,
319187,
286425,
319194,
278235,
229086,
278238,
286432,
294625,
294634,
319226,
171774,
278274,
302852,
278277,
302854,
311048,
352008,
311053,
302862,
278306,
188199,
294701,
278320,
319280,
319290,
229192,
302925,
188247,
237409,
294776,
294785,
327554,
40851,
294811,
319390,
294817,
40865,
319394,
294831,
188340,
40886,
294844,
294847,
294876,
294879,
311279,
278513,
237555,
278516,
311283,
278519,
237562
] |
4fca677dc54667e54849362984fa3e646cfa4c54 | 7d137ad4e752491b6dc43004faeadf84ae983a6d | /FunMatchGame/ThirdView.swift | 409744fe953de8080be9cf61ae94d1ca2be1de26 | [] | no_license | GeorgeVytka/FunMatchGame | 1b50c250986f98e7c0695e882e6226fabdd58321 | 807e622da1a230ac54436929d6bbd37f958be09d | refs/heads/master | 2020-04-30T12:35:50.389337 | 2019-03-20T23:02:44 | 2019-03-20T23:02:44 | 176,830,415 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 211 | swift | //
// ThirdView.swift
// FunMatchGame
//
// Created by George Vytka on 1/17/19.
// Copyright © 2019 George Vytka. All rights reserved.
//
import Foundation
import UIKit
class ThirdView{
}
| [
-1
] |
74c3eb1711241f8bc754e3e5d5b8073753c77bd5 | f9c377eb6d979ed264c678e88778162fda01c089 | /Tronald Dump/Controllers/TagListCollectionViewController.swift | ebc0be03f3ec79162ddcb97f52ec50ca54920565 | [] | no_license | allanweir/TronaldDump | 23f936c31c244539bd7ee06eace0f3c5281aa71c | 01b38e348e71341964d9492547e79d2aa1de9c46 | refs/heads/master | 2021-05-14T08:15:47.195389 | 2018-01-04T17:37:39 | 2018-01-04T17:37:39 | 116,289,683 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,913 | swift | //
// TagListCollectionViewController.swift
// Tronald Dump
//
// Created by Allan Weir on 04/01/2018.
// Copyright © 2018 Allan Weir. All rights reserved.
//
import UIKit
class TagListCollectionViewController: TronaldCollectionViewController {
private let cellIdentifierTagList = "TagListCell"
var dataAdapter = TagListCollectionDataAdapter()
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Tronald Dump Tags"
self.collectionView.register(SimpleTextCollectionViewCell.self, forCellWithReuseIdentifier: cellIdentifierTagList)
self.loadData()
}
override func loadData(isRefreshing: Bool = false) {
super.loadData(isRefreshing: isRefreshing)
self.dataAdapter.load { [weak self] (success, error) in
guard let strongSelf = self else {
return
}
if !success && !strongSelf.dataAdapter.tagsAvailable {
strongSelf.loadingState = .error(error)
} else {
strongSelf.didLoadData()
}
}
}
private func didLoadData() {
self.collectionView.reloadData()
self.loadingState = .ready
}
}
// MARK: UICollectionViewDataSource
extension TagListCollectionViewController {
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.dataAdapter.tags.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifierTagList, for: indexPath) as? SimpleTextCollectionViewCell
// Configure the cell
let tag = self.dataAdapter.tagNameAt(index: indexPath.row) ?? ""
cell?.setLabel(tag)
return cell!
}
}
// MARK: UICollectionVIewDelegate
extension TagListCollectionViewController {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let tagName = self.dataAdapter.tagNameAt(index: indexPath.row) else {
return
}
let controller = ControllerFactory.getController(forType: .tagDetail(tagName: tagName))
self.navigationController?.pushViewController(controller, animated: true)
}
}
// MARK: UICollectionViewDelegateFlowLayout
extension TagListCollectionViewController {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: self.view.frame.width, height: TronaldStyles.UI.Cell.SimpleTextCell.height)
}
}
| [
-1
] |
bd0f1b02b79ab375a919871ac949a7a5e55e6f37 | d571867a426667591863158cff63ef94a8bfd2e0 | /Rememberer/Model/Values.swift | 16567da1ec19453844cae1516b2061d0ee3fb918 | [] | no_license | BRobat/Rememberer | d2784fd3ccede502cc2828f2bad55c836628ddfd | 3748928c81585ea9f69bac9774c213ed14633e3b | refs/heads/master | 2020-03-11T21:47:51.969326 | 2018-04-19T21:33:27 | 2018-04-19T21:33:27 | 111,460,306 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 392 | swift | //
// Values.swift
// Rememberer
//
// Created by Tohil on 05/11/2017.
// Copyright © 2017 Tohil. All rights reserved.
//
import Foundation
import UIKit
struct Values {
static var thatNumber = Int()
static var level = 1
static var levelSpd = 1
static var experience = 0
static var lives = 3
static var breakTime = 3
static var breakTimeSpd = 3
}
| [
-1
] |
06a8ac20c888f33915c43678866769ad40b86ec4 | 3350e0fde88c355ad0ee2e8b6ea181b5dae63284 | /test/Driver/Dependencies/one-way-merge-module-fine.swift | 0554723ad399a94c1bd7837c560631828c8e63d3 | [
"Apache-2.0",
"Swift-exception"
] | permissive | filip-sakel/swift | e248c2ba4cf22eaa42d3154cf2ed20469b9c1fef | fbe2ca9f19fdc9beb6841c6a16c383f105c4bfc5 | refs/heads/main | 2023-05-07T07:57:43.857130 | 2021-04-06T21:02:30 | 2021-04-06T21:02:30 | 354,375,548 | 0 | 0 | Apache-2.0 | 2021-04-03T19:20:37 | 2021-04-03T19:20:36 | null | UTF-8 | Swift | false | false | 1,238 | swift | /// other ==> main
// REQUIRES: rdar76238077
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/one-way-fine/* %t
// RUN: touch -t 201401240005 %t/*
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v 2>&1 | %FileCheck -check-prefix=CHECK-FIRST %s
// CHECK-FIRST-NOT: warning
// CHECK-FIRST: Handled main.swift
// CHECK-FIRST: Handled other.swift
// CHECK-FIRST: Produced master.swiftmodule
// swift-driver checks existence of all outputs
// RUN: touch -t 201401240006 %t/{main,other}.swift{module,doc,sourceinfo}
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v 2>&1 | %FileCheck -check-prefix=CHECK-SECOND %s
// CHECK-SECOND-NOT: warning
// CHECK-SECOND-NOT: Handled
// CHECK-SECOND-NOT: Produced master.swiftmodule
| [
82177,
82149,
82183,
82153,
82154,
82155,
82185,
82161,
82166,
82167
] |
8d4fef22318acac157346f523474e1c91bb0f666 | ac1cbae06886e6db6c1b08a87be999567f5b95cc | /C4SwiftExamples/C4ExampleFactory.swift | 345f23f0b36869223804baf4dad176adb7a8c84e | [] | no_license | Ollstar/C4SwiftExamples | dba080fca03fcb5340a8b2e857da4acbc8da549e | 1efc7ddba2beb3c4be5e732fd13e5f2de5f2b6a7 | refs/heads/master | 2020-04-09T16:35:35.473642 | 2015-09-02T11:31:42 | 2015-09-02T11:31:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,905 | swift | // Copyright © 2015 C4
//
// 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
import C4
// TODO: replace these with actual examples
private let C4Examples = [ NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest02),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest01),
NSStringFromClass(C4ExampleTest02)]
class C4ExampleFactory {
class var numberOfExamples: Int {
get {
return C4Examples.count
}
}
class func createExample(index: Int) -> C4CanvasController {
let aClass = NSClassFromString(C4Examples[index]) as! C4CanvasController.Type
return aClass.init()
}
} | [
194560,
196636,
98341,
98346,
98347,
98349,
59445,
124987,
327749,
174152,
174159,
354400,
235658,
229526,
229532,
125086,
125087,
215205,
241846,
241851,
241852,
191,
262357,
262359,
106713,
241881,
106715,
241884,
106719,
35040,
106737,
176369,
176370,
106741,
260342,
106750,
141566,
141576,
141578,
141588,
12565,
141591,
141592,
227608,
227610,
141595,
141596,
141597,
141598,
141600,
141601,
241952,
141603,
241954,
241962,
289068,
289071,
289074,
141627,
141628,
141629,
141632,
141634,
141639,
141640,
141641,
141642,
241994,
241999,
141649,
141654,
141655,
242006,
168285,
141663,
215396,
141670,
375153,
287090,
375155,
334196,
375163,
375164,
375166,
375171,
141701,
375173,
375181,
197018,
197021,
213421,
303550,
305637,
305638,
223741,
125456,
191006,
57893,
328232,
57901,
336450,
336451,
336455,
336459,
336460,
55886,
336464,
336467,
336469,
336470,
336471,
336473,
336479,
336480,
336481,
336482,
336489,
297620,
135860,
135861,
242361,
242364,
299713,
66261,
334563,
334564,
172784,
244469,
111356,
66302,
142078,
244480,
142081,
142083,
142085,
142087,
142089,
334601,
318220,
318223,
142097,
318233,
203551,
318246,
187176,
396095,
396098,
279366,
299858,
396115,
396118,
396127,
396134,
299884,
248696,
297858,
60304,
201617,
201619,
60312,
60319,
60323,
23473,
60337,
23481,
23487,
23493,
23501,
23508,
259036,
23519,
259039,
23531,
203755,
433131,
23554,
23555,
437252,
23557,
23559,
23560,
23562,
437258,
437266,
437267,
23572,
23573,
23575,
437273,
23580,
437277,
23582,
437281,
3119,
189488,
187442,
189490,
187444,
187445,
189492,
187447,
144440,
189493,
437305,
144443,
144435,
144441,
341054,
341055,
144442,
144447,
341059,
222278,
341063,
341066,
23636,
437333,
285781,
285783,
23640,
285784,
437338,
285787,
312412,
437340,
312417,
185446,
437353,
185451,
437356,
115820,
185454,
185452,
185453,
185457,
142450,
437364,
437369,
437371,
142463,
294015,
294016,
437384,
437390,
248975,
437392,
189590,
312473,
189594,
312476,
189598,
40095,
228512,
312478,
40098,
312479,
437412,
437415,
437416,
437423,
437426,
312499,
312501,
312502,
437431,
437433,
322751,
437440,
437445,
292041,
437458,
203993,
204000,
204003,
281832,
152821,
294138,
206094,
206098,
206104,
206107,
206108,
206109,
27943,
27945,
27948,
173368,
152909,
290126,
290135,
171363,
222566,
228717,
222581,
222582,
222594,
279944,
363913,
279954,
54678,
173465,
54692,
298431,
157151,
222692,
157157,
112115,
65016,
112120,
280063,
40450,
206344,
280074,
40459,
355859,
40471,
40482,
34359,
34362,
316993,
173635,
173640,
173641,
263755,
106082,
106085,
319088,
300662,
52855,
52884,
394910,
52896,
394930,
108245,
212694,
34531,
192229,
192230,
296679,
34535,
34537,
192234,
34538,
155377,
296691,
296700,
216829,
276227,
276236,
311055,
227116,
210756,
120655,
218960,
120656,
120657,
180059,
292708,
292709,
223081,
227179,
227180,
223087,
116600,
108436,
169881,
290767,
59349,
141272,
141284,
141292,
174063,
174067,
237559,
194558,
194559
] |
142c5f414ca0643848a3024eb35a343eb01984de | 4055d6a1e08380f3dd049472943ba93a36b9bb29 | /submodules/TelegramUI/TelegramUI/ChatBotStartInputPanelNode.swift | 450c47aebe52feb7f8b4293d3e72cfa50a43d58d | [] | no_license | ks1707/Telegram-iOS | 3a4d2da74235d939ac12826074c8e4285bd7ecac | 9b3b894d3ff0b016db16202aeb2400eee8eb0ae6 | refs/heads/master | 2021-10-13T07:50:39.241823 | 2019-08-02T06:59:52 | 2019-08-02T06:59:52 | 200,121,631 | 1 | 1 | null | 2021-10-12T23:39:01 | 2019-08-01T21:30:28 | C | UTF-8 | Swift | false | false | 4,843 | swift | import Foundation
import UIKit
import AsyncDisplayKit
import Display
import TelegramCore
import Postbox
import SwiftSignalKit
import TelegramPresentationData
final class ChatBotStartInputPanelNode: ChatInputPanelNode {
private let button: HighlightableButtonNode
private let activityIndicator: UIActivityIndicatorView
private var statusDisposable: Disposable?
private var presentationInterfaceState: ChatPresentationInterfaceState?
override var interfaceInteraction: ChatPanelInterfaceInteraction? {
didSet {
if let _ = self.interfaceInteraction {
if self.statusDisposable == nil {
if let startingBot = self.interfaceInteraction?.statuses?.startingBot {
self.statusDisposable = (startingBot |> deliverOnMainQueue).start(next: { [weak self] value in
if let strongSelf = self {
if value != !strongSelf.activityIndicator.isHidden {
if value {
strongSelf.activityIndicator.isHidden = false
strongSelf.activityIndicator.startAnimating()
} else {
strongSelf.activityIndicator.isHidden = true
strongSelf.activityIndicator.stopAnimating()
}
}
}
})
}
}
}
}
}
private var theme: PresentationTheme
private var strings: PresentationStrings
init(theme: PresentationTheme, strings: PresentationStrings) {
self.theme = theme
self.strings = strings
self.button = HighlightableButtonNode()
self.activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
self.activityIndicator.isHidden = true
super.init()
self.addSubnode(self.button)
self.view.addSubview(self.activityIndicator)
self.button.setAttributedTitle(NSAttributedString(string: strings.Bot_Start, font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlAccentColor), for: [])
self.button.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: [.touchUpInside])
}
deinit {
self.statusDisposable?.dispose()
}
func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
if self.theme !== theme || self.strings !== strings {
self.theme = theme
self.strings = strings
self.button.setAttributedTitle(NSAttributedString(string: strings.Bot_Start, font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlAccentColor), for: [])
}
}
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if self.bounds.contains(point) {
return self.button.view
} else {
return nil
}
}
@objc func buttonPressed() {
guard let context = self.context, let presentationInterfaceState = self.presentationInterfaceState, let peer = presentationInterfaceState.renderedPeer?.peer else {
return
}
self.interfaceInteraction?.sendBotStart(presentationInterfaceState.botStartPayload)
}
override func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, maxHeight: CGFloat, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, metrics: LayoutMetrics) -> CGFloat {
if self.presentationInterfaceState != interfaceState {
let previousState = self.presentationInterfaceState
self.presentationInterfaceState = interfaceState
}
let buttonSize = self.button.measure(CGSize(width: width - 80.0, height: 100.0))
let panelHeight = defaultHeight(metrics: metrics)
self.button.frame = CGRect(origin: CGPoint(x: leftInset + floor((width - leftInset - rightInset - buttonSize.width) / 2.0), y: floor((panelHeight - buttonSize.height) / 2.0)), size: buttonSize)
let indicatorSize = self.activityIndicator.bounds.size
self.activityIndicator.frame = CGRect(origin: CGPoint(x: width - rightInset - indicatorSize.width - 12.0, y: floor((panelHeight - indicatorSize.height) / 2.0)), size: indicatorSize)
return panelHeight
}
override func minimalHeight(interfaceState: ChatPresentationInterfaceState, metrics: LayoutMetrics) -> CGFloat {
return defaultHeight(metrics: metrics)
}
}
| [
-1
] |
e5e4b801cb0a228bc1623c311082fb90a29bbe74 | 6e61df4f200949ce6cce65ca5cd417ace9c21a00 | /DiscoveryApp/SceneDelegate.swift | 22717f955f01e7afdd28cc77a90c74d549181f74 | [] | no_license | Gianglucy/DiscoveryApp | fb76960b1c2d5741a406d9c4c6f69d549a453609 | 545e48477ef0723e33cce0f04d43b4fd24f8e7ab | refs/heads/master | 2023-05-23T18:09:49.000412 | 2021-06-19T13:12:55 | 2021-06-19T13:12:55 | 378,413,613 | 0 | 1 | null | null | null | null | UTF-8 | Swift | false | false | 2,248 | swift | //
// SceneDelegate.swift
// DiscoveryApp
//
// Created by Apple on 6/19/21.
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
let homeViewController = HomeViewController(nibName: "HomeViewController", bundle: nil)
window?.rootViewController = homeViewController
window?.makeKeyAndVisible()
}
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 necessarily 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.
}
}
| [
343168,
372481,
415362,
224898,
389507,
266757,
375297,
210696,
264585,
330890,
391691,
379915,
393613,
380433,
351382,
206489,
206490,
386074,
381212,
344736,
397089,
357793,
262702,
340910,
345906,
370611,
264502,
333499,
345916,
260925,
333374,
266815,
386366,
392129,
418367,
104636,
334276,
372166,
244552,
398280,
396874,
346317,
370254,
386259,
358100,
437588,
332118,
329816,
211161,
383323,
248799,
423393,
108386,
250211,
340452,
346340,
369254,
325359,
368753,
173170,
387314,
334322,
372977,
333176,
341114,
257021,
194942
] |
9f97be5fb318240fe490c15a031141ec36544f7a | cd6a5aa67f6658671ce227a8b0b9dec754ceaee9 | /LibsTest/AppDelegate.swift | d3200218cda5055d8812fd4b94c8b220b79debb4 | [] | no_license | tomoyuki-ito/LibsTest-iOS | 64a6166d56762757d053fbbcd36935539c986a0a | 6f9973152a4154d26bb014154bdac15af96c1eae | refs/heads/master | 2021-08-28T10:48:53.672335 | 2017-12-12T01:32:43 | 2017-12-12T01:32:43 | 111,345,679 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,922 | swift | //
// AppDelegate.swift
// LibsTest
//
// Created by Tomoyuki Ito on 2017/11/18.
// Copyright © 2017 Nagisa Inc. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
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:.
}
// MARK: - Split view
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
if topAsDetailController.detailItem == nil {
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
return true
}
return false
}
}
| [
229380,
229383,
229385,
294924,
229388,
229391,
327695,
229394,
229397,
229399,
229402,
229405,
229408,
294950,
229415,
229417,
237613,
229422,
229426,
237618,
229428,
286774,
229432,
286776,
319544,
286791,
237640,
237646,
311375,
163920,
311383,
319590,
311400,
303212,
131192,
237693,
327814,
303241,
311436,
319633,
286873,
286876,
311460,
32944,
327862,
286906,
180413,
286910,
131264,
286922,
286924,
286926,
319694,
131281,
278743,
229595,
278747,
295133,
155872,
319716,
237807,
303345,
131314,
286962,
327930,
278781,
278783,
278785,
237826,
319751,
278792,
286987,
319757,
311569,
286999,
287003,
287006,
287009,
287012,
287014,
287019,
278829,
311598,
287032,
155966,
278849,
319809,
319810,
319814,
311628,
229709,
287054,
319822,
278865,
229717,
196963,
196969,
139638,
213367,
106872,
319872,
311683,
65943,
311719,
278952,
139689,
278957,
311728,
278963,
278967,
180668,
311741,
278975,
319938,
98756,
278980,
319945,
278986,
319947,
278990,
278994,
172512,
279010,
279015,
172520,
319978,
172526,
279023,
311791,
279027,
319989,
180727,
164343,
311804,
287230,
279040,
303617,
287234,
172550,
287238,
172552,
303623,
320007,
279051,
172558,
303632,
279058,
303637,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
311850,
279084,
279087,
172591,
279090,
172598,
279095,
172607,
172612,
377413,
172614,
287303,
172618,
303690,
33357,
287309,
279124,
172634,
262752,
311911,
295533,
172655,
172656,
352880,
295538,
172660,
287349,
287355,
287360,
295553,
279173,
287365,
311942,
303751,
352905,
279178,
287371,
311946,
287377,
311957,
221850,
287386,
164509,
172702,
230045,
287390,
172705,
287394,
172707,
303773,
303780,
287398,
279208,
287400,
172714,
295595,
279212,
189102,
172721,
287409,
303797,
189114,
287419,
303804,
328381,
279231,
287423,
287427,
312006,
107212,
172748,
287436,
172751,
295633,
172755,
303827,
279255,
172760,
279258,
287450,
213724,
189149,
303835,
303838,
279267,
312035,
295654,
279272,
312048,
312050,
230131,
279287,
205564,
295685,
230154,
312077,
295695,
369433,
295707,
328476,
295710,
303914,
279340,
205613,
279353,
230202,
222018,
295755,
377676,
287569,
230241,
279394,
303976,
336744,
303985,
303987,
328563,
279413,
303991,
303997,
295806,
295808,
295813,
304005,
213895,
304007,
304009,
320391,
304011,
230284,
304013,
279438,
295822,
189329,
189331,
58262,
279452,
410526,
279461,
304042,
213931,
230327,
304055,
304063,
295873,
189378,
213954,
304065,
213963,
304084,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
312321,
295945,
197645,
230413,
295949,
140312,
238620,
197663,
304164,
304170,
238641,
312374,
238652,
230465,
238658,
296004,
336964,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
361576,
164973,
279669,
337018,
222340,
296084,
238745,
304285,
238756,
205991,
165035,
337067,
165038,
238766,
304311,
230592,
279750,
230600,
230607,
148690,
279769,
304348,
279777,
304354,
296163,
279781,
304360,
279788,
320748,
279790,
320771,
312585,
230674,
320786,
230677,
296213,
296215,
320792,
230681,
173350,
312622,
296243,
312630,
222522,
230718,
296255,
378181,
230727,
222545,
230739,
312663,
222556,
337244,
312676,
230760,
173418,
230763,
230768,
296305,
230773,
304505,
304506,
181631,
312711,
288140,
230800,
288144,
304533,
288154,
337306,
288160,
288162,
279975,
304555,
370092,
279983,
173488,
312755,
296373,
279991,
312759,
337335,
173507,
296389,
222665,
230860,
230865,
370130,
148946,
288210,
222676,
280021,
288212,
288214,
239064,
288217,
288218,
329177,
288220,
239070,
288224,
280034,
288226,
280036,
288229,
280038,
288230,
288232,
320998,
288234,
370146,
288238,
288240,
288242,
296435,
288244,
288250,
148990,
296446,
206336,
321022,
296450,
402942,
230916,
214535,
230919,
304651,
222752,
108066,
296488,
239152,
230961,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
280152,
288344,
239194,
181854,
280158,
370272,
403039,
239202,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
190118,
321195,
321200,
296634,
280260,
280264,
280276,
313044,
321239,
280283,
288478,
321252,
313066,
280302,
288494,
280304,
313073,
419570,
288499,
288502,
288510,
67330,
280324,
198416,
280337,
296723,
321304,
329498,
296731,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
321336,
296767,
345921,
304968,
280393,
280402,
313176,
280419,
321381,
296812,
313201,
1920,
255873,
305028,
247688,
280464,
124817,
280473,
124827,
214940,
247709,
280487,
313258,
321458,
296883,
124853,
214966,
10170,
296890,
288700,
296894,
190403,
280515,
296900,
337862,
165831,
280521,
296921,
239586,
313320,
231404,
124913,
165876,
321528,
239612,
288764,
239617,
313347,
288773,
313358,
305176,
313371,
354338,
305191,
313386,
354348,
124978,
215090,
124980,
288826,
313406,
288831,
67654,
280651,
280654,
354382,
288848,
354390,
280669,
223327,
280671,
321634,
149603,
329830,
280681,
313451,
280687,
215154,
280691,
313458,
313464,
321659,
280702,
288895,
141446,
215175,
321670,
141455,
141459,
280725,
313498,
100520,
288936,
280747,
288940,
321717,
280764,
280769,
280771,
280774,
280783,
280786,
280793,
280796,
338147,
280804,
280807,
157930,
280811,
280817,
125171,
157940,
280825,
280827,
280830,
280831,
125187,
280835,
125191,
125207,
125209,
321817,
321842,
223539,
280888,
289087,
280897,
239944,
305480,
239947,
305485,
305489,
379218,
280919,
354653,
313700,
280937,
280946,
223606,
313720,
280956,
280959,
313731,
199051,
240011,
289169,
240017,
190868,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
289210,
305594,
281024,
289221,
289227,
281045,
281047,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
240132,
305668,
281095,
223752,
338440,
150025,
223757,
281102,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
150066,
158262,
158266,
281154,
322115,
281163,
281179,
338528,
281190,
281196,
19053,
158317,
313973,
281210,
297594,
158347,
133776,
117398,
314007,
289436,
174754,
330404,
174764,
240309,
133817,
314045,
314047,
199364,
297671,
158409,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322318,
281372,
322341,
215850,
281388,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
158596,
183172,
240519,
322440,
314249,
240535,
289687,
289694,
289696,
289724,
52163,
281547,
281567,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
175134,
322599,
322610,
314421,
281654,
314427,
207937,
314433,
314441,
207949,
322642,
281691,
314461,
281702,
281704,
314474,
281708,
281711,
248995,
306341,
306344,
306347,
208048,
306354,
142531,
289991,
249045,
363745,
298216,
126190,
216303,
322801,
257302,
363802,
199976,
199978,
298292,
257334,
298306,
224584,
224587,
224594,
216404,
150870,
224603,
265568,
281960,
306539,
290161,
216436,
306549,
298358,
306552,
290171,
298365,
290174,
224641,
281987,
265604,
298372,
281990,
298377,
142733,
298381,
224657,
306581,
282025,
282027,
241068,
241070,
241072,
282034,
241077,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
339431,
282089,
191985,
282098,
290291,
282101,
151036,
290302,
282111,
290305,
175621,
192008,
323084,
257550,
290321,
282130,
323090,
282133,
290325,
241175,
290328,
282137,
290332,
241181,
282144,
290344,
290349,
290351,
290356,
224849,
282195,
282199,
282201,
306778,
159330,
314979,
224875,
241260,
323181,
257658,
315016,
282249,
290445,
282261,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
306856,
282295,
282300,
323260,
323266,
282310,
323273,
282319,
306897,
241362,
282328,
298714,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
323349,
282392,
184090,
315167,
282402,
315174,
241450,
282410,
306991,
315184,
323376,
315190,
241464,
282425,
307009,
241475,
307012,
315211,
282446,
315221,
323414,
315223,
241496,
241498,
307035,
307040,
110433,
241509,
110438,
110445,
282478,
282481,
110450,
315249,
315251,
315253,
315255,
339838,
282499,
315267,
315269,
241544,
282505,
241546,
241548,
298896,
282514,
298898,
241556,
298901,
241560,
241563,
241565,
241567,
241569,
298916,
241574,
282537,
298922,
36779,
241581,
282542,
241583,
323504,
241586,
282547,
241588,
290739,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
241640,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
299006,
282623,
241669,
315397,
282632,
282639,
290835,
282645,
241693,
282654,
217127,
282669,
323630,
290870,
282681,
290877,
282687,
159811,
315463,
315466,
192589,
192596,
176213,
307287,
315482,
315483,
192605,
233567,
200801,
217188,
299109,
307303,
45163,
307307,
315502,
307314,
323700,
299126,
233591,
299136,
307329,
307338,
233613,
307352,
299164,
315557,
184486,
307370,
184492,
307372,
307374,
307376,
176311,
184503,
307386,
258235,
176316,
307388,
307390,
184512,
307394,
299204,
184518,
323784,
307409,
176343,
299225,
233701,
184572,
184579,
282893,
291089,
282906,
233766,
176435,
168245,
307510,
315701,
332086,
307515,
282942,
307518,
176450,
282957,
110926,
323917,
233808,
323921,
315733,
315739,
323932,
299357,
242018,
242024,
299373,
315757,
250231,
315771,
299388,
299398,
242057,
291212,
299405,
291222,
283033,
242075,
61855,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
291254,
127417,
291260,
127421,
127429,
315856,
315860,
176597,
127447,
299481,
176605,
242143,
291299,
242152,
291305,
176620,
291314,
291317,
135672,
233979,
291323,
291330,
283142,
127497,
135689,
233994,
291341,
233998,
234003,
234006,
234010,
135707,
242206,
135710,
291361,
242220,
291378,
152118,
234038,
70213,
111193,
242275,
299620,
168562,
184952,
135805,
135808,
291456,
299655,
373383,
316051,
225941,
316054,
299672,
135834,
225948,
373404,
135839,
299680,
225954,
299684,
242343,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
225998,
226002,
226005,
226008,
242396,
299740,
201444,
299750,
283368,
234219,
283372,
226037,
283382,
234231,
234236,
242431,
209665,
234242,
242436,
234246,
226056,
234248,
291593,
242443,
242445,
234254,
234258,
242450,
242452,
283416,
201496,
234269,
234272,
234274,
152355,
234278,
299814,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
160572,
283452,
234302,
234307,
242499,
234309,
234313,
316235,
234316,
283468,
234319,
242511,
234321,
234324,
201557,
234329,
234333,
308063,
234336,
234338,
242530,
349027,
234344,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
291711,
234368,
234370,
291714,
291716,
234373,
226182,
234375,
226185,
308105,
234384,
226193,
234388,
234390,
226200,
234393,
308123,
234396,
324508,
291742,
209823,
234401,
291748,
234405,
291750,
234407,
324518,
324520,
291754,
226220,
291756,
234414,
291760,
201650,
226230,
234422,
275384,
234428,
291773,
226239,
234431,
242623,
234434,
324548,
226245,
234437,
234439,
234443,
291788,
193486,
234446,
193488,
234449,
275406,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234478,
234481,
234484,
234485,
234487,
234493,
234496,
316416,
234501,
308231,
234504,
234507,
234515,
300054,
234519,
234520,
316439,
234523,
234528,
300066,
234532,
234535,
234537,
234540,
234543,
275508,
234549,
300085,
300088,
234558,
316479,
234561,
234563,
316483,
234568,
234570,
316491,
234572,
300108,
300115,
234580,
234581,
234585,
242777,
275545,
234595,
234597,
300133,
300139,
234605,
160879,
234607,
275569,
234610,
234614,
144506,
234618,
234620,
275579,
234623,
226433,
234627,
275588,
234634,
234636,
234640,
275602,
234643,
324757,
226453,
275606,
234647,
234648,
275608,
234650,
308373,
308379,
234653,
283805,
119967,
300189,
234657,
324766,
242852,
300197,
275626,
316596,
234687,
300226,
234692,
283844,
300229,
308420,
283850,
300234,
300238,
300241,
316625,
300243,
300245,
300248,
300253,
300256,
300258,
300260,
234726,
300263,
300265,
161003,
300267,
300270,
300272,
120053,
300278,
316663,
300284,
275710,
300287,
300289,
300292,
300294,
275719,
177419,
300299,
242957,
275725,
283917,
177424,
349464,
283939,
259367,
283951,
300344,
226617,
243003,
226628,
300357,
177482,
283983,
316758,
357722,
316766,
218464,
316768,
292197,
243046,
316774,
218473,
136562,
275834,
333178,
275836,
275840,
316806,
226696,
226699,
316811,
292240,
300433,
234899,
300436,
357783,
316826,
300448,
144810,
144812,
144814,
144820,
284084,
284087,
292279,
144826,
144828,
144830,
144832,
144835,
144839,
144841,
300491,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
292329,
300523,
259565,
259567,
300527,
316917,
308727,
300537,
308757,
308762,
284194,
284196,
235045,
284199,
284206,
284209,
284211,
194101,
284213,
194103,
284215,
284218,
226877,
284223,
284226,
284228,
292421,
226886,
284231,
284234,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
284243,
284245,
276053,
284247,
317015,
284249,
243290,
226908,
284253,
243293,
284255,
300638,
284258,
292452,
177766,
292454,
292458,
284267,
292461,
284274,
276086,
284278,
292470,
292473,
276090,
284283,
276093,
284286,
292479,
284288,
276098,
284290,
284292,
292485,
325250,
276103,
284297,
317066,
284299,
317068,
284301,
284303,
276114,
284306,
284308,
284312,
284314,
284316,
276127,
284322,
284327,
276137,
284329,
284331,
317098,
284333,
284335,
284337,
284339,
300726,
284343,
284346,
284350,
276160,
358080,
284354,
284358,
358089,
276170,
284362,
276175,
284368,
276177,
284370,
317138,
284372,
358098,
284377,
358116,
276197,
325353,
358122,
276206,
358126,
358128,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
284418,
317187,
358146,
317191,
284428,
300816,
317207,
300828,
300830,
276255,
300832,
227109,
317221,
186151,
358183,
276268,
243504,
284469,
276280,
325436,
358206,
276291,
366406,
276295,
300872,
153417,
284499,
276308,
178006,
284502,
317271,
276315,
292700,
284511,
227175,
292715,
284529,
292721,
300915,
284533,
317306,
284540,
292734,
325512,
169868,
350106,
284572,
276386,
284579,
276388,
292776,
284585,
358312,
276395,
276402,
161718,
358326,
358330,
276411,
276425,
301009,
301011,
301013,
301015,
358360,
301017,
292828,
153568,
292843,
227314,
325624,
317435,
292876,
276496,
317456,
317458,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
325689,
235579,
276539,
325692,
178238,
309337,
227418,
227423,
178273,
227426,
276579,
194660,
227430,
292968,
309352,
276586,
301163,
309354,
227440,
284786,
276595,
292985,
301178,
292989,
292993,
301185,
301199,
350354,
350359,
129178,
276638,
153765,
284837,
227520,
227522,
301252,
227529,
301258,
276685,
276689,
301272,
276699,
194780,
309468,
301283,
317672,
243948,
194801,
309494,
243960,
227583,
276735,
276739,
211204,
276742,
227596,
325910,
309530,
342298,
211232,
211241,
325937,
325943,
284995,
260421,
285002,
276811,
276816,
235858,
276829,
276833,
276836,
276843,
293227,
276848,
293232,
186744,
211324,
317833,
227723,
178572,
285070,
227728,
178583,
227738,
317853,
317858,
342434,
285093,
285098,
276907,
293304,
293314,
293325,
317910,
293336,
235996,
317917,
293343,
358880,
276961,
293346,
276964,
293352,
236013,
293364,
317951,
309764,
236043,
317963,
342541,
55822,
113167,
317971,
309781,
55837,
227879,
227882,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
301636,
285265,
277080,
309849,
285277,
285282,
326244,
277100,
121458,
170618,
170619,
309885,
309888,
277122,
227975,
277128,
285320,
301706,
318092,
326285,
318094,
334476,
277136,
277139,
227992,
285340,
318108,
227998,
318110,
285357,
318128,
277170,
293555,
154292,
277173,
342707,
277177,
277181,
318144,
277187,
277191,
277194,
277196,
277201,
137946,
187105,
113378,
203491,
228069,
277223,
342760,
56041,
285417,
277232,
228081,
56059,
310015,
310020,
310029,
228113,
285459,
277273,
326430,
228135,
318248,
277291,
318253,
285489,
293685,
285494,
285499,
301884,
310080,
277317,
277329,
162643,
310100,
301911,
277337,
301921,
400236,
236397,
277358,
162671,
326514,
228212,
15224,
236408,
277368,
416639,
416640,
113538,
416643,
310147,
416648,
39817,
187274,
277385,
301972,
424853,
310179,
293798,
293802,
236460,
293811,
293817,
293820,
203715,
326603,
293849,
293861,
228327,
228328,
318442,
277486,
326638,
318450,
293877,
285686,
302073,
121850,
293882,
302075,
293887,
277504,
277507,
277511,
277519,
293908,
293917,
293939,
318516,
277561,
277564,
7232,
310336,
293956,
277573,
228422,
293960,
277577,
310344,
277583,
203857,
293971,
310359,
236632,
277594,
138332,
277598,
203872,
277601,
285792,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
285817,
367737,
302205,
294026,
285835,
302218,
162964,
384148,
187542,
302231,
302233,
285852,
302237,
285854,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
302258,
294072,
318651,
277692,
277695,
318657,
302275,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
302296,
384222,
310498,
285927,
318698,
302315,
228592,
294132,
138485,
204026,
228606,
204031,
64768,
310531,
138505,
228617,
318742,
204067,
277801,
277804,
285997,
277807,
285999,
113969,
277811,
318773,
277816,
318776,
286010,
277819,
294204,
277822,
417086,
294211,
302403,
277832,
277836,
277839,
326991,
277842,
277847,
277850,
179547,
277853,
277857,
277860,
302436,
294246,
327015,
277864,
310632,
327017,
351594,
277869,
277872,
351607,
277880,
310648,
310651,
277884,
277888,
310657,
310659,
277892,
294276,
277894,
327046,
253320,
310665,
277898,
318858,
351619,
277903,
310672,
277905,
351633,
277908,
277917,
277921,
310689,
130468,
277928,
277932,
310703,
277937,
130486,
310710,
277944,
310712,
277947,
310715,
277950,
277953,
64966,
245191,
277959,
302534,
310727,
277963,
277966,
302543,
277971,
228825,
277978,
277981,
310749,
277984,
310755,
277989,
277991,
277995,
286188,
310764,
278000,
228851,
278003,
278006,
40440,
212472,
278009,
40443,
286203,
228864,
286214,
302603,
302614,
286233,
286240,
146977,
187939,
40484,
294435,
40486,
286246,
40488,
286248,
294439,
40491,
294440,
294443,
294445,
310831,
212538,
228923,
40507,
40511,
40513,
40521,
286283,
40525,
40527,
212560,
228944,
400976,
40533,
40537,
40541,
278109,
40544,
40548,
40550,
40552,
286313,
40554,
310892,
40557,
40560,
188022,
122488,
294521,
343679,
310925,
286354,
278163,
302740,
278168,
327333,
229030,
212648,
278188,
302764,
319153,
278196,
319171,
302789,
294599,
278216,
294601,
319187,
229076,
286425,
319194,
229086,
286432,
294625,
294634,
302838,
319226,
286460,
302852,
302854,
294664,
311048,
319243,
311053,
294682,
278306,
294701,
278320,
319280,
319290,
229192,
302925,
237409,
360317,
327554,
40840,
311184,
40851,
294803,
188312,
294811,
319390,
40865,
294817,
319394,
294821,
180142,
188340,
40886,
319419,
294844,
294847,
393177,
294876,
294879,
294883,
294890,
311279,
278513,
237555,
278516,
237562
] |
a065781cd2cb601f12d72f92a2b5e7658bb4feed | 125463b0c93f44f0d34b196f17f0857da1eb4929 | /FoodTracker/MyFoodtracker/Meal.swift | 90ee322c1c7c0bec7d60394ed6c8b4dd4eb418cc | [] | no_license | huxinqian/11 | 624b6050693548c8f58f9c78e52fe0e338da1e7a | 0c73c09ced550e03c754726181cdee3caace29d2 | refs/heads/master | 2020-04-11T21:01:22.667190 | 2018-12-18T06:27:25 | 2018-12-18T06:27:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 774 | swift | //
// Meal.swift
// MyFoodtracker
//
// Created by student on 2018/12/17.
// Copyright © 2018年 2016110314. All rights reserved.
//
import UIKit
class Meal {
//MARK: Properties
var name: String
var photo: UIImage?
var rating: Int
//MARK: Initialization
init?(name: String, photo: UIImage?, rating: Int) {
// The name must not be empty
guard !name.isEmpty else {
return nil
}
// The rating must be between 0 and 5 inclusively
guard (rating >= 0) && (rating <= 5) else {
return nil
}
// Initialize stored properties.
self.name = name
self.photo = photo
self.rating = rating
}
}
| [
280153,
298715,
293347
] |
82f28270ffd9a8287af186e28412ca357f02c769 | a169a203933115f56544dadbbeabf6934e6346a1 | /validation-test/Reflection/reflect_NSArray.swift | 7abeb2c33585d39399e99ef96cca671b7c7694b3 | [
"Apache-2.0",
"Swift-exception"
] | permissive | Ajisaputrars/swift | 023d54839b703de7dcd8044f415c13ec46fd9e6b | 0c66535c99e7e7a20e3f512f9749b9b130f4c820 | refs/heads/master | 2021-10-16T10:12:31.877034 | 2019-02-10T10:08:29 | 2019-02-10T10:08:29 | 105,532,260 | 1 | 0 | Apache-2.0 | 2019-02-10T10:08:30 | 2017-10-02T12:35:41 | C++ | UTF-8 | Swift | false | false | 1,330 | swift | // RUN: %empty-directory(%t)
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_NSArray
// RUN: %target-run %target-swift-reflection-test %t/reflect_NSArray 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// REQUIRES: objc_interop
// REQUIRES: executable_test
import SwiftReflectionTest
import Foundation
class TestClass {
var t: NSArray
init(t: NSArray) {
self.t = t
}
}
var obj = TestClass(t: [1, 2, 3])
reflect(object: obj)
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (class reflect_NSArray.TestClass)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0
// CHECK-64: (field name=t offset=16
// CHECK-64: (reference kind=strong refcounting=unknown)))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (class reflect_NSArray.TestClass)
// CHECK-32: Type info:
// CHECK-32: (class_instance size=16 alignment=4 stride=16 num_extra_inhabitants=0
// CHECK-32: (field name=t offset=12
// CHECK-32: (reference kind=strong refcounting=unknown)))
doneReflecting()
// CHECK-64: Done.
// CHECK-32: Done.
| [
74518,
88332,
74508,
91534,
91535,
74509,
74510,
74512,
91537,
91540,
74517,
88333,
91543,
88344,
74519,
74514,
74515,
74516,
88335,
88343,
91551,
74528,
91552,
88336,
88337,
88338,
91557,
74525,
74535,
91560,
74529,
74538,
88355,
88364,
88340,
88357,
74526,
88365,
88341,
88376,
88379,
91550,
91541,
91553,
88348,
91533,
91539
] |
a74e7289da5e4bb113be61947ca9cdf4739f9934 | 58653c3b1a1f32521d8a2f51ec8c94571232226c | /TruthOrDare/Cells/PackInfoTableViewCell.swift | a5f7b98377afcfa8442a506fd53a4ddba656c964 | [] | no_license | AlexeyGorbunov72/TruthOrDare | aa30c1efe00e1a6461a0a5722d895e32c55d8762 | 3b7cf031aa594a7f668927d766b052ac9461d72e | refs/heads/master | 2022-12-08T12:53:59.664186 | 2020-09-02T00:53:30 | 2020-09-02T00:53:30 | 287,105,308 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,489 | swift | //
// PackInfoTableViewCell.swift
// TruthOrDare
//
// Created by Alexey on 14.08.2020.
// Copyright © 2020 Alexey. All rights reserved.
//
import UIKit
class PackInfoTableViewCell: UITableViewCell {
let contentLabel = UILabel()
let markLabel = UILabel()
var contentOfTask: Task? {
set(task){
if let task = task{
if(task.isTruth == 1){
markLabel.text = "🤫"
} else {
markLabel.text = "🤼♀️"
}
contentLabel.text = task.content
setup()
}
}
get{
return self.contentOfTask
}
}
override func awakeFromNib() {
super.awakeFromNib()
}
func setup(){
contentView.backgroundColor = .systemIndigo
contentView.layer.cornerRadius = 20
contentLabel.translatesAutoresizingMaskIntoConstraints = false
markLabel.translatesAutoresizingMaskIntoConstraints = false
markLabel.numberOfLines = 0
contentLabel.numberOfLines = 0
contentLabel.textColor = .white
contentView.addSubview(markLabel)
contentView.addSubview(contentLabel)
NSLayoutConstraint.activate([
contentLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
contentLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
contentLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -20),
contentLabel.leadingAnchor.constraint(equalTo: markLabel.trailingAnchor, constant: 20),
markLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
markLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
])
}
/* func setupLabels(_ task: Task){
let content = UILabel()
let hardLevel = UILabel()
content.numberOfLines = 0
hardLevel.numberOfLines = 0
content.font = .boldSystemFont(ofSize: 30)
content.text = task.content
hardLevel.text = task.levelOfHard
content.translatesAutoresizingMaskIntoConstraints = false
hardLevel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(content)
// contentView.addSubview(hardLevel)
NSLayoutConstraint.activate(
[content.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
content.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
content.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 20),
content.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: 20)])
// hardLevel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
// hardLevel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
// hardLevel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 20),]
//content.trailingAnchor.constraint(equalTo: hardLevel.leadingAnchor, constant: -20).isActive = true
}
*/
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
| [
-1
] |
be6586281e5e80b9f41928c40f7e444fcdda9381 | 5b77df4df9dcb3ac30eb64010658d633c990eb41 | /XXLineChartDemo/XXUIColorExtension.swift | 3639e74409d77aecea6c8542cd29d2fcd5ec17fa | [
"Apache-2.0"
] | permissive | aitim/XXLineChart | ba5329125174080e8df04b2e56bf9d1c5c79b40d | 941773803052aaad91ebf79983b635a24f31b6f6 | refs/heads/master | 2016-09-05T16:34:22.036787 | 2015-03-06T10:11:22 | 2015-03-06T10:11:22 | 31,763,177 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,237 | swift | //
// Created by xin.xin on 2/28/15.
// Copyright (c) 2015 Arthur GUIBERT. All rights reserved.
//
import UIKit
extension UIColor{
class func xxRed()->UIColor{
return UIColor(red: 1.0,green: 0.22,blue: 0.22,alpha: 1.0)
}
class func xxOrange()->UIColor{
return UIColor(red: 1.0,green: 0.58,blue: 0.21,alpha: 1)
}
class func xxYellow()->UIColor{
return UIColor(red: 1.0,green: 0.79,blue: 0.28,alpha: 1.0)
}
class func xxGreen()->UIColor{
return UIColor(red: 0.27,green: 0.85,blue: 0.46,alpha: 1.0)
}
class func xxLightBlue()->UIColor{
return UIColor(red: 0.18,green: 0.67,blue: 0.84,alpha: 1.0)
}
class func xxDarkBlue()->UIColor{
return UIColor(red: 0,green: 0.49,blue: 0.96,alpha: 1.0)
}
class func xxPurple()->UIColor{
return UIColor(red: 0.35,green: 0.35,blue: 0.81,alpha: 1.0)
}
class func xxPink()->UIColor{
return UIColor(red: 1.0,green: 0.17,blue: 0.34,alpha: 1.0)
}
class func xxDarkGray()->UIColor{
return UIColor(red: 0.56,green: 0.56,blue: 0.58,alpha: 1.0)
}
class func xxLightGray()->UIColor{
return UIColor(red: 0.78,green: 0.78,blue: 0.8,alpha: 1.0)
}
} | [
-1
] |
ceea72780f80f728601ed54a0bf3c3312d3f36c9 | 3d144a23e67c839a4df1c073c6a2c842508f16b2 | /test/Interpreter/SDK/cf_extensions.swift | 91d37d51497962fb160f0bf869839a80f12d542f | [
"Apache-2.0",
"Swift-exception"
] | permissive | apple/swift | c2724e388959f6623cf6e4ad6dc1cdd875fd0592 | 98ada1b200a43d090311b72eb45fe8ecebc97f81 | refs/heads/main | 2023-08-16T10:48:25.985330 | 2023-08-16T09:00:42 | 2023-08-16T09:00:42 | 44,838,949 | 78,897 | 15,074 | Apache-2.0 | 2023-09-14T21:19:23 | 2015-10-23T21:15:07 | C++ | UTF-8 | Swift | false | false | 1,887 | swift | // RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop
import Foundation
import StdlibUnittest
#if canImport(AppKit)
import AppKit
#elseif canImport(UIKit)
import UIKit
#else
#error("Unsupported platform")
#endif
extension CGColorSpace {
class func deviceRGB() -> CGColorSpace {
return CGColorSpaceCreateDeviceRGB()
}
}
extension CGColor {
class func create(colorSpace: CGColorSpace, components: [CGFloat])
-> CGColor {
return CGColor(colorSpace: colorSpace, components: components)!
}
var r: CGFloat { return components![0] }
var g: CGFloat { return components![1] }
var b: CGFloat { return components![2] }
}
var CFTestSuite = TestSuite("CFExtensions")
CFTestSuite.test("methods") {
let pink = CGColor.create(colorSpace: .deviceRGB(),
components: [1.0, 0.5, 0.25, 1.0])
expectEqual(1.0, pink.r)
expectEqual(0.5, pink.g)
expectEqual(0.25, pink.b)
}
protocol SwiftProto {
func doTheThing() -> AnyObject
}
extension CGColor: SwiftProto {
func doTheThing() -> AnyObject { return self }
}
func callTheThing<T: SwiftProto>(_ instance: T) -> AnyObject {
return instance.doTheThing()
}
CFTestSuite.test("protocols") {
let pink = CGColor.create(colorSpace: .deviceRGB(),
components: [1.0, 0.5, 0.25, 1.0])
expectTrue(pink === pink.doTheThing())
let protoObj: SwiftProto = pink
expectTrue(pink === protoObj.doTheThing())
expectTrue(pink === callTheThing(pink))
}
CFTestSuite.test("protocols/downcast")
.xfail(.always("unimplemented"))
.code {
let pink = CGColor.create(colorSpace: .deviceRGB(),
components: [1.0, 0.5, 0.25, 1.0])
let opaquePink: AnyObject = pink
let downcasted = opaquePink as? SwiftProto
expectNotNil(downcasted)
expectTrue(pink === downcasted!.doTheThing())
}
runAllTests()
| [
71336,
82574,
89808
] |
8405c3027a206505a423807cca49ec311d151229 | 6943ac600ae985175ec47c222f8dc4f47cee3d25 | /CoreLocationCLI/CLPlacemark+CNPostalAddress.swift | 1770a761356d8030048c26edb666e699a193e6e2 | [
"MIT"
] | permissive | Daij-Djan/corelocationcli | 240d00d526d3685c1dde83599a163b6f88733476 | d7518bac10bafe798ce551adee06c10acefb3008 | refs/heads/master | 2021-01-14T13:21:58.267867 | 2016-05-23T12:40:26 | 2016-05-23T12:40:26 | 59,481,085 | 0 | 0 | null | 2016-05-23T12:30:48 | 2016-05-23T12:30:47 | null | UTF-8 | Swift | false | false | 855 | swift | //
// CLPlacemark+CNPostalAddress.swift
//
// Created by Dominik Pich on 5/23/16.
// Copyright © 2016 William Entriken. All rights reserved.
//
import CoreLocation
import Contacts
extension CLPlacemark {
var postalAddress : CNPostalAddress? {
get {
guard let addressdictionary = self.addressDictionary else {
return nil
}
let address = CNMutablePostalAddress()
address.street = addressdictionary["Street"] as? String ?? ""
address.state = addressdictionary["State"] as? String ?? ""
address.city = addressdictionary["City"] as? String ?? ""
address.country = addressdictionary["Country"] as? String ?? ""
address.postalCode = addressdictionary["ZIP"] as? String ?? ""
return address
}
}
} | [
-1
] |
ae63c3e240cfde445de1f0e16d09de942d1dfb2d | 10372ad22765397ac23f2ce492dc3b25de7eb724 | /MoBetterBluetooth/BeaconRegion.swift | ef98f7dbd5aa4f799f4eac8d97958d4a3774f048 | [
"MIT"
] | permissive | carabina/MoBetterBluetooth | c4ebd12d4fcdc542fe14d7af28f677f148611094 | 7b1483e3b7d4e6610dfe0edd16b2b8c249bb0571 | refs/heads/master | 2021-01-21T06:24:31.393517 | 2017-02-26T16:28:54 | 2017-02-26T16:28:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 17,246 | swift | //
// BeaconRegion.swift
// BluetoothExplorer
//
// Created by Robert Vaessen on 12/23/15.
// Copyright © 2015 Robert Vaessen. All rights reserved.
//
import Foundation
import CoreLocation
import VerticonsToolbox
func ==(lhs: BeaconRegion, rhs: BeaconRegion) -> Bool { return lhs.uuid == rhs.uuid }
open class BeaconRegion : NSObject, NSCoding {
// Types *********************************************************************************************************
public enum Event {
case startedMonitoring
case enteredRegion
case startedRanging
case addedBeacon
case changedBeaconProximity
case stoppedRanging
case exitedRegion
case stoppedMonitoring
public func describeEvent(_ region: BeaconRegion, beacon: BeaconRegion.Beacon?) -> String {
switch self {
case .enteredRegion:
return "The \(region.name) region was entered"
case .startedMonitoring:
return "Monitoring of the \(region.name) region started"
case .startedRanging:
return "Ranging of the \(region.name) region started"
case .addedBeacon:
return "\(region.name) beacon \(beacon!.identifier) was added with proximity \(nameForProximity(beacon!.currentProximity))"
case .changedBeaconProximity:
return "\(region.name) beacon \(beacon!.identifier)'s proximity was changed to \(nameForProximity(beacon!.currentProximity))"
case .stoppedRanging:
return "Ranging of the \(region.name) region stopped"
case .stoppedMonitoring:
return "Monitoring of the \(region.name) region stopped"
case .exitedRegion:
return "The \(region.name) region was exited"
}
}
}
open class Beacon {
fileprivate static var nextBeaconIndex = 0
class func beaconAtIndex(_ index: Int) -> BeaconRegion? {
return index < regions.count ? regions.filter() { $0.1.index == index }[0].1 : nil
}
class func makeKey(_ identifier: (major: Int, minor: Int)) -> Int {
return identifier.major << 16 + identifier.minor
}
open let index: Int
open let identifier: (major: Int, minor: Int)
let beacon: CLBeacon
let parent: BeaconRegion
init(beacon: CLBeacon, identifier: (major: Int, minor: Int), region: BeaconRegion) {
self.beacon = beacon
self.identifier = identifier
currentProximity = beacon.proximity
self.parent = region
index = Beacon.nextBeaconIndex
Beacon.nextBeaconIndex += 1
}
open fileprivate(set) var currentProximity: CLProximity {
didSet(oldValue) {
if currentProximity != oldValue {
parent.fireEvent(.changedBeaconProximity, beacon: self)
}
}
}
}
public typealias Listener = (BeaconRegion, Event, Beacon?) -> ()
fileprivate class LocationManagerDelegate: NSObject, CLLocationManagerDelegate {
// Even though the documentation states that this callback is only invoked when the authorization
// status changes, testing reveals that it is always called upon startup regardless of any changes.
@objc func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print("LocationManagerDelegate - Authorization status updated to \(nameForAuthorizationStatus(status)).")
switch status {
case CLAuthorizationStatus.notDetermined:
manager.requestAlwaysAuthorization()
break
case CLAuthorizationStatus.authorizedAlways:
break
default:
alertUser(title: "Location Services Needed", body: "Please set location access to \"Always\" so that beacons can be reliably detected")
break
}
}
@objc func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("LocationManagerDelegate - Location manager failure, error: \(error)")
}
@objc func locationManager(_ manager: CLLocationManager, didStartMonitoringFor region: CLRegion) {
print("LocationManagerDelegate - Monitoring of the \"\(region.identifier)\" region has started")
}
@objc func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {
print("LocationManagerDelegate - The state of the \(region.identifier) \(type(of: region)) region is \(nameForRegionState(state))")
if let clRegion = region as? CLBeaconRegion, let beaconRegion = BeaconRegion.regions[clRegion.proximityUUID] {
switch state {
case CLRegionState.inside:
beaconRegion.locatedInside = true
case CLRegionState.outside:
beaconRegion.locatedInside = false
case CLRegionState.unknown:
break
}
}
}
@objc func locationManager(_ manager: CLLocationManager, monitoringDidFailFor region: CLRegion?, withError error: Error) {
print("LocationManagerDelegate - Monitoring failed for the \"\(region?.identifier)\" region: \(error)")
}
@objc func locationManager(_ manager: CLLocationManager, rangingBeaconsDidFailFor region: CLBeaconRegion, withError error: Error) {
print("LocationManagerDelegate - Beacon ranging failed for the \"\(region.identifier)\", \(region.proximityUUID) region: \(error)")
}
@objc func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
if let region = BeaconRegion.regions[region.proximityUUID] {
for clBeacon in beacons {
region.addOrUpdateBeacon(clBeacon)
}
}
else {
print("LocationManagerDelegate - An unknown region was ranged: identifier= \(region.identifier), UUID = \(region.proximityUUID)")
}
}
}
// Class Members *************************************************************************************************
open static let invalidListenerKey = -1
fileprivate static var locationManagerDelegate: LocationManagerDelegate? // Retain the delegate
fileprivate static var locationManager: CLLocationManager? = {
if CLLocationManager.locationServicesEnabled() {
if (CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self)) {
if CLLocationManager.isRangingAvailable() {
let manager = CLLocationManager()
//manager.distanceFilter = 0.5
// Setup the manager such that beacon ranging can occur in the background
manager.desiredAccuracy = kCLLocationAccuracyThreeKilometers
manager.allowsBackgroundLocationUpdates = true
manager.startUpdatingLocation()
locationManagerDelegate = LocationManagerDelegate()
manager.delegate = locationManagerDelegate
return manager
}
else {
alertUser(title: "Cannot Work With Beacons", body: "Ranging is not available.")
}
}
else {
alertUser(title: "Cannot Work With Beacons", body: "Region monitoring is not available.")
}
}
else {
alertUser(title: "Cannot Work With Beacons", body: "Location services are not enabled.")
}
return nil
}()
fileprivate static var nextListenerKey = 0
fileprivate static var listeners: [Int : Listener] = [:]
fileprivate static var nextRegionIndex = 0
fileprivate static let regionsArchiveFilePath: String = {
let fileName = "BeaconRegion.archive";
let pathes = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true);
let url = URL(fileURLWithPath: pathes[0]).appendingPathComponent(fileName)
return url.path
}()
fileprivate static var regions: [UUID : BeaconRegion] = {
var regions = [UUID : BeaconRegion]()
if let manager = locationManager {
func addRegion(_ region: AnyObject) {
var localRegion = region
if let clBeaconRegion = localRegion as? CLBeaconRegion {
localRegion = BeaconRegion(region: clBeaconRegion, manager: manager)
}
if let beaconRegion = localRegion as? BeaconRegion {
if regions[beaconRegion.uuid] == nil {
beaconRegion.index = nextRegionIndex
nextRegionIndex += 1
regions[beaconRegion.uuid] = beaconRegion;
}
}
}
for monitoredRegion in manager.monitoredRegions {
addRegion(monitoredRegion)
manager.requestState(for: monitoredRegion)
}
for rangedRegion in manager.rangedRegions {
addRegion(rangedRegion)
}
if let archivedRegions = NSKeyedUnarchiver.unarchiveObject(withFile: regionsArchiveFilePath) as? [BeaconRegion] {
for archivedRegion in archivedRegions {
addRegion(archivedRegion)
}
}
var message = "There \(regions.count == 1 ? "is" : "are") \(regions.count) beacon \(regions.count == 1 ? "region" : "regions")"
for (uuid, region) in regions {
message.append("\n\t\(region.name) <\(region.uuid.uuidString)> - monitored \(region.isMonitoring ? "yes": "no"), ranged \(region.isRanging ? "yes": "no")")
}
print(message)
}
else {
print("BeaconRegion - a Location Manager cnnnot be obtained; one or more of the required capabilities are not available")
}
return regions
}()
fileprivate static let nameKey = "Name"
fileprivate static let uuidKey = "UUID"
// This needs some more thought ...
open class func restore() -> Int {
return numberOfRegions
}
open class var numberOfRegions: Int {
get {
return regions.count
}
}
open class func addRegion(_ name: String, uuid: UUID, errorDescription: inout String) -> BeaconRegion? {
if let manager = locationManager {
if regions[uuid] == nil {
let region = BeaconRegion(name: name, uuid: uuid, manager: manager)
region.index = nextRegionIndex; nextRegionIndex += 1
regions[uuid] = region
saveRegions()
return region
}
else {
errorDescription = "The \"\(name)\" region's UUID [\(uuid.uuidString)] is already being used by the \"\(regions[uuid]!.name)\" region"
return nil
}
}
else {
errorDescription = "Cannot obtain a Location Manager: one or more of the required capabilities are not available"
return nil
}
}
open class func regionAtIndex(_ index: Int) -> BeaconRegion? {
return index < numberOfRegions ? regions.filter() { $0.1.index == index }[0].1 : nil
}
// The listener will be called for an event on any and all regions.
// The returned value can be used to remove the listener
open class func addListener(_ listener: @escaping Listener) -> Int {
let key = nextListenerKey; nextListenerKey += 1
listeners[key] = listener
return key
}
open class func removeListener(_ key: Int) -> Bool {
return listeners.removeValue(forKey: key) != nil ? true : false
}
fileprivate class func saveRegions() {
NSKeyedArchiver.archiveRootObject(Array(regions.values), toFile: regionsArchiveFilePath)
}
// Instance Members **********************************************************************************************
open var index: Int!
fileprivate let manager: CLLocationManager
fileprivate let clRegion: CLBeaconRegion
fileprivate var beacons = [Int : Beacon]()
fileprivate var nextListenerKey = 0
fileprivate var listeners: [Int : Listener] = [:]
fileprivate init(region: CLBeaconRegion, manager: CLLocationManager) {
clRegion = region
self.manager = manager
super.init()
}
fileprivate convenience init(name: String, uuid: UUID, manager: CLLocationManager) {
let region = CLBeaconRegion(proximityUUID: uuid, identifier: name)
region.notifyEntryStateOnDisplay = true
region.notifyOnEntry = true
region.notifyOnExit = true
self.init(region: region, manager: manager)
}
@objc required convenience public init?(coder decoder: NSCoder) {
guard let name = decoder.decodeObject(forKey: BeaconRegion.nameKey) as? String,
let uuid = decoder.decodeObject(forKey: BeaconRegion.uuidKey) as? UUID,
let manager = BeaconRegion.locationManager
else { return nil }
self.init(name: name, uuid: uuid, manager: manager)
}
@objc open func encode(with coder: NSCoder) {
coder.encode(name, forKey: BeaconRegion.nameKey)
coder.encode(uuid, forKey: BeaconRegion.uuidKey)
}
fileprivate func addOrUpdateBeacon(_ clBeacon: CLBeacon) {
let id = (clBeacon.major.intValue, clBeacon.minor.intValue)
let key = Beacon.makeKey(id)
if let beacon = beacons[key] {
beacon.currentProximity = clBeacon.proximity
}
else {
let beacon = Beacon(beacon: clBeacon, identifier: id, region: self)
beacons[key] = beacon
fireEvent(.addedBeacon, beacon: beacon)
}
}
// The returned value can be used to remove the listener
open func addListener(_ listener: @escaping Listener) -> Int {
return lockObject(self) {
let key = self.nextListenerKey; self.nextListenerKey += 1
self.listeners[key] = listener
return key
} as! Int
}
open func removeListener(_ key: Int) -> Bool {
return lockObject(self) {
self.listeners.removeValue(forKey: key) != nil ? true : false
} as! Bool
}
open func beaconAtIndex(_ index: Int) -> BeaconRegion.Beacon? {
return index < numberOfBeacons ? beacons.filter() { $0.1.index == index }[0].1 : nil
}
open var name: String {
get {
return clRegion.identifier
}
}
open var uuid: UUID {
get {
return clRegion.proximityUUID
}
}
open var numberOfBeacons: Int {
get {
return beacons.count
}
}
open var isMonitoring: Bool {
get {
return manager.monitoredRegions.contains(clRegion)
}
}
open var isRanging: Bool {
get {
return manager.rangedRegions.contains(clRegion)
}
}
open fileprivate(set) var locatedInside = false {
didSet {
if locatedInside != oldValue {
if !locatedInside {
beacons.removeAll()
}
fireEvent(locatedInside ? .enteredRegion : .exitedRegion, beacon: nil)
}
}
}
open func startMonitoring() {
manager.startMonitoring(for: clRegion)
fireEvent(.startedMonitoring, beacon: nil)
}
open func stopMonitoring() {
manager.stopMonitoring(for: clRegion)
fireEvent(.stoppedMonitoring, beacon: nil)
}
open func startRanging() {
manager.startRangingBeacons(in: clRegion)
fireEvent(.startedRanging, beacon: nil)
}
open func stopRanging() {
// Should I remove all beacons. What does iOS do with the beacons that it is tracking
manager.stopRangingBeacons(in: clRegion)
fireEvent(.stoppedRanging, beacon: nil)
}
fileprivate func fireEvent(_ event: Event, beacon: Beacon?) {
print(event.describeEvent(self, beacon: beacon))
_ = lockObject(BeaconRegion.self) {
for (_, listener) in BeaconRegion.listeners {
listener(self, event, beacon)
}
return nil
}
_ = lockObject(self) {
for (_, listener) in self.listeners {
listener(self, event, beacon)
}
return nil
}
}
}
| [
-1
] |
f8f531ef497a40a72b9a90f3182de509f00cccc3 | 70fe5fb70ca74bad7defc7f2946747f57cd0ffb9 | /Package.swift | 4aafdbd6e72edf7e090fb5b7da3695f5f3f9c3c7 | [
"MIT"
] | permissive | Dimillian/SkeletonView | 641b73c5e9811ed19481727dc33d1c5db905e90d | 8e49eb305da1da788f2f4d17f8b556e79837ada6 | refs/heads/master | 2022-08-13T17:18:46.049360 | 2020-03-31T07:38:09 | 2020-03-31T07:38:09 | 275,109,008 | 1 | 0 | MIT | 2020-06-26T08:29:52 | 2020-06-26T08:29:51 | null | UTF-8 | Swift | false | false | 384 | swift | // swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "SkeletonView",
platforms: [
.iOS(.v9),
.tvOS(.v9)
],
products: [
.library(
name: "SkeletonView",
targets: ["SkeletonView"])
],
targets: [
.target(
name: "SkeletonView",
dependencies: [],
path: "Sources")
],
swiftLanguageVersions: [.v5]
)
| [
-1
] |
c4b372cf42a24958ecda54ac0d0f0e5bc3d4ee68 | 44074a86d15825be04152a0753e49d4f376c448d | /App/Sources/Global/Extensions/DateFormatterExtension.swift | c36ab9cf0054b6c23bdaa6a60811035ad97d1547 | [] | no_license | RamyRizkalla/tractiveWeather | 0c61a5ff1f14fb2b8194931d87c783cc9f88254e | da98a0633779bf027afa8689566b369dd9196803 | refs/heads/master | 2023-01-28T07:01:09.380314 | 2020-12-03T02:18:05 | 2020-12-03T03:35:02 | 316,486,999 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 258 | swift | //Copyright © 2020 Tractive. All rights reserved.
import Foundation
extension DateFormatter {
static var shortTimeFormatter: DateFormatter {
let formatter = DateFormatter()
formatter.timeStyle = .short
return formatter
}
}
| [
-1
] |
084ee12a683a0daf8fdca64833b84f02785a77f0 | aebf7cc9df3fdc633424cba66e8a70c2d9071757 | /HoneyDew/MeasurementHelper.swift | 40f3c6b68d561cabce9369b3d9e427cb5346c323 | [] | no_license | TennantShaw/ToDoUsingFirebase | 8f2b9984c1fafaedbed67988eb989c312909a086 | 6ddb5f633ada0e6f282513c12bdbd9190ded6c32 | refs/heads/master | 2021-01-21T18:57:15.928273 | 2017-05-23T23:58:35 | 2017-05-23T23:58:35 | 92,094,201 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 513 | swift | //
// MeasurementHelper.swift
// HoneyDew
//
// Created by Tennant Shaw on 5/23/17.
// Copyright © 2017 Tennant Shaw. All rights reserved.
//
import Firebase
class MeasurementHelper: NSObject {
static func sendLoginEvent() {
Analytics.logEvent(AnalyticsEventLogin, parameters: nil)
}
static func sendLogoutEvent() {
Analytics.logEvent("logout", parameters: nil)
}
static func sendMessageEvent() {
Analytics.logEvent("message", parameters: nil)
}
}
| [
-1
] |
fe6ec920a48dce1c6f0c75bc4dcd4ae66c4f4914 | 5275d9a48d7aa53a44d02891056582060090212e | /Filmes/Scenes/Home/HomeModels.swift | 4da31be61b4d954e823e01c09c698848139b0691 | [] | no_license | filipero/Filmes | 41a3c576c1ab1f7eaa34e77ad029dc4d2ea7e888 | 608119b7815658fd6ea11a220286759384ad6d89 | refs/heads/main | 2023-08-23T09:41:52.863487 | 2021-10-30T06:51:27 | 2021-10-30T06:51:27 | 415,378,683 | 0 | 1 | null | null | null | null | UTF-8 | Swift | false | false | 3,010 | swift | //
// HomeModels.swift
// Filmes
//
// Created by Filipe Oliveira on 07/10/21.
struct HomeModels {
struct PopularMoviesResponse: Codable {
let page: Int
let results: [Result]
let totalPages, totalResults: Int
enum CodingKeys: String, CodingKey {
case page, results
case totalPages = "total_pages"
case totalResults = "total_results"
}
}
// MARK: - Result
struct Result: Codable {
let adult: Bool
let backdropPath: String
let genreIDS: [Int]
let id: Int
let originalLanguage: String
let originalTitle, overview: String
let popularity: Double
let posterPath, releaseDate, title: String
let video: Bool
let voteAverage: Double
let voteCount: Int
enum CodingKeys: String, CodingKey {
case adult
case backdropPath = "backdrop_path"
case genreIDS = "genre_ids"
case id
case originalLanguage = "original_language"
case originalTitle = "original_title"
case overview, popularity
case posterPath = "poster_path"
case releaseDate = "release_date"
case title, video
case voteAverage = "vote_average"
case voteCount = "vote_count"
}
}
struct Image: Codable {
let images: Images
let changeKeys: [String]
enum CodingKeys: String, CodingKey {
case images
case changeKeys = "change_keys"
}
}
// MARK: - Images
struct Images: Codable {
let baseURL: String
let secureBaseURL: String
let backdropSizes, logoSizes, posterSizes, profileSizes: [String]
let stillSizes: [String]
enum CodingKeys: String, CodingKey {
case baseURL = "base_url"
case secureBaseURL = "secure_base_url"
case backdropSizes = "backdrop_sizes"
case logoSizes = "logo_sizes"
case posterSizes = "poster_sizes"
case profileSizes = "profile_sizes"
case stillSizes = "still_sizes"
}
}
struct NowPlayingResponse: Codable {
let dates: Dates
let page: Int
let results: [Result]
let totalPages, totalResults: Int
enum CodingKeys: String, CodingKey {
case dates, page, results
case totalPages = "total_pages"
case totalResults = "total_results"
}
}
struct Dates: Codable {
let maximum, minimum: String
}
struct GenresResponse: Codable {
let genres: [Genre]
enum CodingKeys: String, CodingKey {
case genres
}
}
struct MovieData: Codable {
let adult: Bool
let backdropPath: String
let genreIDS: [Int]
let id: Int
let originalLanguage: String
let originalTitle, overview: String
let popularity: Double
let posterPath, releaseDate, title: String
let video: Bool
let voteAverage: Double
let voteCount: Int
}
struct Genre: Codable {
let id: Int
let name: String
}
}
| [
-1
] |
f53bf769abd6f2d66d5274a5993aff08a4338d4a | ae2f76f17d2d7e59f5ae21568dd14cf61ffdd0f6 | /Ramda/Classes/allPass.swift | 091471bcee07f80ae0892779f12e53240851e7a0 | [
"MIT"
] | permissive | tonnylitao/RamdaSwift | fac947d9bf2fd6ac4e76f39ba36fa3e33a85600a | f8a2f1c0aa22ce11e18002e730789936a33163cf | refs/heads/master | 2022-12-10T10:32:01.472838 | 2020-08-25T00:11:06 | 2020-08-25T00:11:06 | 289,597,827 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 252 | swift | //
// allPass.swift
// RamdaSwift
//
// Created by Tonny on 22/08/20.
//
import Foundation
extension Ramda {
static func allPass<A>(_ a: [(A) -> Bool]) -> (A) -> Bool {
{ b in
a.allSatisfy { $0(b) }
}
}
}
| [
-1
] |
1294c0c6e8a7f81e3a4b5ac3322babd27744281b | 6bc66b364b22d148e2960c2647debb8552c60f26 | /InstagramImagePicker/AppDelegate.swift | f8e36b3034606e882e7636dc9d3f3ebfd186a813 | [] | no_license | YukiMorishita/InstagramImagePicker | 419b3f05443c1cdb5bbb879bacc4b478a9e40656 | 29607f7042f2a336347bacf6ebd61f48b5ba359c | refs/heads/master | 2022-04-13T20:24:01.949971 | 2020-04-06T09:42:07 | 2020-04-06T09:42:07 | 250,363,117 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,681 | swift | //
// AppDelegate.swift
// InstagramImagePicker
//
// Created by admin on 2020/03/24.
// Copyright © 2020 admin. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 13.0, *) {
// Scene delegate
} else {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = RootViewController()
}
// usleep(800000)
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.
}
}
| [
342915,
268298,
333708,
330768,
209943,
210071,
345625,
333594,
210077,
210080,
345762,
210084,
210088,
209965,
333997,
210095,
210098,
209971,
184244,
340275,
209975,
337592,
188987,
345915,
249920,
254018,
209987,
210115,
330189,
333009,
263508,
368735,
333413,
338664,
338409,
210027,
247789,
211825,
330610,
334321,
358259,
328689,
380918,
210039,
210044,
339710,
252799
] |
c8104af9b034cac54ac47cef283ee07ddd1e7cce | 82470b2e968fd50d0f081b852097944b39e24747 | /Projects/SoundMuseumTests/Sources/TestUtils/ASCollectionNode+Test.swift | 1fc900a42b388645e805db0b12b9407ee0b72210 | [] | no_license | Team-DND/SoundMuseum | 55bd3eae2b2dc02e95e487971a287eab335f3f6f | de8e53c1bee1d7b370cfaf583e11f455daa09a78 | refs/heads/main | 2023-02-09T06:02:16.964683 | 2021-01-05T13:54:29 | 2021-01-05T13:54:29 | 307,046,132 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,592 | swift | //
// ASCollectionNode+Test.swift
// SoundMuseumTests
//
// Created by Gunter on 2020/11/22.
//
import AsyncDisplayKit
extension Test where Base: ASCollectionNode {
func numberOfSections() -> Int? {
guard let dataSource = self.base.dataSource else { return nil }
return dataSource.numberOfSections?(in: self.base)
}
func numberOfItems(at section: Int) -> Int? {
guard let dataSource = self.base.dataSource else { return nil }
return dataSource.collectionNode?(self.base, numberOfItemsInSection: section)
}
func node<C: ASCellNode>(_ type: C.Type, at indexPath: IndexPath) -> C? {
guard let dataSource = self.base.dataSource else { return nil }
if let nodeBlock = dataSource.collectionNode?(self.base, nodeBlockForItemAt: indexPath) {
return nodeBlock() as? C
} else {
return dataSource.collectionNode?(self.base, nodeForItemAt: indexPath) as? C
}
}
func node<C: ASCellNode>(_ type: C.Type, at section: Int, _ item: Int) -> C? {
let indexPath = IndexPath(item: item, section: section)
return self.node(type, at: indexPath)
}
func supplementaryNode<C: ASCellNode>(_ type: C.Type, supplementaryElementOfKind kind: String, at indexPath: IndexPath) -> C? {
guard let dataSource = self.base.dataSource else { return nil }
if let nodeBlock = dataSource.collectionNode?(self.base, nodeBlockForSupplementaryElementOfKind: kind, at: indexPath) {
return nodeBlock() as? C
} else {
return dataSource.collectionNode?(self.base, nodeForSupplementaryElementOfKind: kind, at: indexPath) as? C
}
}
}
| [
-1
] |
757fcf2e2a8dc6384d4d7f2fafa3794a1d1aa268 | 7ae0371dc6ec86255f3b30522dcc104e19967447 | /DicodingPemula/Extension/UIKit/Utilities.swift | 2b71a7281fe64273d69a0dcda62b9ac7ee26b59b | [] | no_license | sayyidmaulana/CatReview | 693996b749514d1e213cc896d67c5523cfbe1d7a | fe4ffce0d31298f9891303c4d5d2d3a010b6d967 | refs/heads/master | 2022-04-21T05:08:29.232058 | 2020-04-15T06:33:14 | 2020-04-15T06:33:14 | 255,826,065 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 866 | swift | //
// Utilities.swift
// DicodingPemula
//
// Created by Sayyid Maulana Khakul Y on 14/04/20.
// Copyright © 2020 Dicoding. All rights reserved.
//
import UIKit
class Utilities {
static func shadow (controller: UIViewController, yourView : UIView){
yourView.layer.shadowOpacity = 0.3
yourView.layer.shadowOffset = CGSize(width: 1, height: 1)
yourView.layer.shadowRadius = 3.0
yourView.layer.shadowColor = UIColor.darkGray.cgColor
}
static func cornerRadius3(controller: UIViewController, yourView: UIView) {
yourView.layer.cornerRadius = 3
}
static func cornerRadius5(controller: UIViewController, yourView: UIView) {
yourView.layer.cornerRadius = 5
}
static func cornerRadius10(controller: UIViewController, yourView: UIView) {
yourView.layer.cornerRadius = 10
}
}
| [
-1
] |
ad581ab07a3acde6c631aa0ac61c5217d3cb165b | 4d509811892ec1d2de31129d334b265761ee6190 | /OldAppStore/Models/AppCategory.swift | e07473c946485972654c135982884ad54e493884 | [] | no_license | NorthmanV/OldAppStore | 4e129ea57096748a0bc6d6469d49de0b0127fdb9 | b008815b4a19f9a4727983ca23ff7b862ad6c1f0 | refs/heads/master | 2020-03-15T00:45:48.970041 | 2018-05-14T18:59:27 | 2018-05-14T18:59:27 | 131,877,188 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,152 | swift | //
// AppCategory.swift
// OldAppStore
//
// Created by Руслан Акберов on 05.05.2018.
// Copyright © 2018 Ruslan Akberov. All rights reserved.
//
import Foundation
struct Categories: Decodable {
var bannerCategory: AppCategory?
var categories: [AppCategory]?
}
struct AppCategory: Decodable {
var name: String?
var type: String?
var apps: [App]?
static func fetchFeaturedApps(completion: @escaping (Categories) -> Void) {
let urlString = "https://api.letsbuildthatapp.com/appstore/featured"
let session = URLSession.shared.dataTask(with: URL(string: urlString)!) { (data, response, error) in
if error != nil {
print(error!.localizedDescription)
return
}
do {
let decodedCategories = try JSONDecoder().decode(Categories.self, from: data!)
DispatchQueue.main.async {
completion(decodedCategories)
}
} catch let error{
print(error.localizedDescription)
}
}
session.resume()
}
}
| [
-1
] |
7f34be7572c4e90cc86190e9e799e64a161eee3f | 6ae12596775b59b2a03f6471f567209441aee36d | /Sources/randa.swift | 4495964c4dd12483791bd71a2e4b37b281edb683 | [
"Apache-2.0"
] | permissive | sbooker/Nifty | 44a03508ee9d97f195f9c1c2b19497e53a37e14f | 7d3d61cfde195f698106435b3432ac18a4cedd87 | refs/heads/master | 2020-09-28T14:47:36.587198 | 2019-12-09T20:25:07 | 2019-12-09T20:25:07 | 226,799,400 | 0 | 0 | Apache-2.0 | 2019-12-09T06:20:48 | 2019-12-09T06:20:47 | null | UTF-8 | Swift | false | false | 1,748 | swift |
/// Returns a random character string. By default, string is lower-case and alphabetic.
///
/// - Parameters:
/// - length: length of the string to generate
/// - case: set whether string is lower case, upper case, or mixed case
/// - withNumbers: allow numeric characters as well
/// - seed: optionally provide specific seed for generator. If threadSafe is set, this seed will
/// not be applied to global generator, but to the temporary generator instance
/// - threadSafe: if set to true, a new random generator instance will be created that will be
/// be used and exist only for the duration of this call. Otherwise, global instance is used.
/// - Returns: random string
public func randa(_ length: Int, withCase: RandomCaseOption = .mixed, withNumbers: Bool = false,
seed: UInt64? = nil, threadSafe: Bool = false) -> String
{
var min: Int
var max: Int
switch withCase
{
case .lower:
min = withNumbers ? 0 : 10
max = 35
case .upper:
min = 36
max = withNumbers ? 71 : 61
case .mixed:
min = withNumbers ? 0 : 10
max = 61
}
var s = ""
for _ in 0..<length
{
s += characters[randi(min: min, max: max, seed: seed, threadSafe: threadSafe)]
}
return s
}
public enum RandomCaseOption
{
case mixed
case lower
case upper
}
fileprivate let characters =
[
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h",
"i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
] | [
-1
] |
586c3a0613a7d76578e32661abf480233baa9a9c | 8ef4e6c60e18287e6af143f51544a1712332cab5 | /iTueneAlbums/FeedAlbumsMVVMC/Models/Album.swift | 14489be7bd3b8a1d1400863a4daa85464d7e0a43 | [] | no_license | sksuresh/itunesRssAlbumsJsonDownloader | 5d3732a92152a5f792908b41b459c0d6392efef8 | e4e84a5aca26abf4488e09e4886be7421d103940 | refs/heads/master | 2020-08-06T19:44:44.965176 | 2019-10-06T08:26:22 | 2019-10-06T08:26:22 | 213,129,439 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 539 | swift | //
// Album.swift
// jsonParsing
//
// Created by Suresh Dokula on 10/5/19.
// Copyright © 2019 mdtmac. All rights reserved.
//
import Foundation
struct Album: Codable {
let artistName:String?
let id:String?
let releaseDate:String?
let name:String?
let kind:String?
let copyright:String?
let artistId:String?
let artistUrl:String?
let artworkUrl100:String?
let url:String?
let genres:[Genres]?
}
struct Genres: Codable {
let genreId:String?
let name:String?
let url:String?
}
| [
-1
] |
25ed6a6accd5d3a7540943be3e850933beaac4d6 | 73efb23a1206e388af0c4ef196f1bc7f7247a6de | /PersonsExam/PersonsExam/Models/Persons/Person.swift | cf548626ff9df392c445636e19b8ea0a47462f46 | [] | no_license | glennposadas/persons-exam | 5f14bfffd0a38bc54508bbbd2362659cef422931 | 97a87b2032e5bb973bd9dacdccf61a07db5f26e3 | refs/heads/master | 2020-03-29T12:32:54.913709 | 2018-09-23T13:49:19 | 2018-09-23T13:49:19 | 149,883,168 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,523 | swift | //
// Person.swift
// PersonsExam
//
// Created by Glenn Von C. Posadas on 23/09/2018.
// Copyright © 2018 Glenn Von C. Posadas. All rights reserved.
//
import Foundation
import SwiftyJSON
class Person : NSObject, NSCoding{
var address : String!
var birthdate : String!
var contactPerson : String!
var contactPersonPhoneNumber : String!
var email : String!
var firstName : String!
var id : String!
var lastName : String!
var mobileNumber : String!
var picture : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
address = json["address"].stringValue
birthdate = json["birthdate"].stringValue
contactPerson = json["contactPerson"].stringValue
contactPersonPhoneNumber = json["contactPersonPhoneNumber"].stringValue
email = json["email"].stringValue
firstName = json["firstName"].stringValue
id = json["id"].stringValue
lastName = json["lastName"].stringValue
mobileNumber = json["mobileNumber"].stringValue
picture = json["picture"].stringValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if address != nil{
dictionary["address"] = address
}
if birthdate != nil{
dictionary["birthdate"] = birthdate
}
if contactPerson != nil{
dictionary["contactPerson"] = contactPerson
}
if contactPersonPhoneNumber != nil{
dictionary["contactPersonPhoneNumber"] = contactPersonPhoneNumber
}
if email != nil{
dictionary["email"] = email
}
if firstName != nil{
dictionary["firstName"] = firstName
}
if id != nil{
dictionary["id"] = id
}
if lastName != nil{
dictionary["lastName"] = lastName
}
if mobileNumber != nil{
dictionary["mobileNumber"] = mobileNumber
}
if picture != nil{
dictionary["picture"] = picture
}
return dictionary
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
address = aDecoder.decodeObject(forKey: "address") as? String
birthdate = aDecoder.decodeObject(forKey: "birthdate") as? String
contactPerson = aDecoder.decodeObject(forKey: "contactPerson") as? String
contactPersonPhoneNumber = aDecoder.decodeObject(forKey: "contactPersonPhoneNumber") as? String
email = aDecoder.decodeObject(forKey: "email") as? String
firstName = aDecoder.decodeObject(forKey: "firstName") as? String
id = aDecoder.decodeObject(forKey: "id") as? String
lastName = aDecoder.decodeObject(forKey: "lastName") as? String
mobileNumber = aDecoder.decodeObject(forKey: "mobileNumber") as? String
picture = aDecoder.decodeObject(forKey: "picture") as? String
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
func encode(with aCoder: NSCoder)
{
if address != nil{
aCoder.encode(address, forKey: "address")
}
if birthdate != nil{
aCoder.encode(birthdate, forKey: "birthdate")
}
if contactPerson != nil{
aCoder.encode(contactPerson, forKey: "contactPerson")
}
if contactPersonPhoneNumber != nil{
aCoder.encode(contactPersonPhoneNumber, forKey: "contactPersonPhoneNumber")
}
if email != nil{
aCoder.encode(email, forKey: "email")
}
if firstName != nil{
aCoder.encode(firstName, forKey: "firstName")
}
if id != nil{
aCoder.encode(id, forKey: "id")
}
if lastName != nil{
aCoder.encode(lastName, forKey: "lastName")
}
if mobileNumber != nil{
aCoder.encode(mobileNumber, forKey: "mobileNumber")
}
if picture != nil{
aCoder.encode(picture, forKey: "picture")
}
}
}
| [
-1
] |
dcb8c93570e853e2d8bcb23a9dd814ab8a372e7f | 35180035567de627831140b70f55229b9a0bd968 | /Pod/Classes/Rank.swift | 82f4bac5d480d5590a8fabeb935b09566550e4b8 | [
"MIT"
] | permissive | jearle/DeckOCards | 40d3f4938b6bf8c4c0cb7e392b51ba17dcd55af7 | f5a09f60dc900bb80d698990c3167b6bd26ed3af | refs/heads/master | 2020-05-18T17:00:49.091214 | 2015-08-06T18:41:13 | 2015-08-06T18:41:13 | 40,317,005 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,078 | swift | //
// Rank.swift
// Pods
//
// Created by Jesse Earle on 8/6/15.
//
//
public enum Rank: Int, Printable {
case Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
public var description: String {
get {
switch self {
case .Ace:
return "Ace"
case .Two:
return "Two"
case .Three:
return "Three"
case .Four:
return "Four"
case .Five:
return "Five"
case .Six:
return "Six"
case .Seven:
return "Seven"
case .Eight:
return "Eight"
case .Nine:
return "Nine"
case .Ten:
return "Ten"
case .Jack:
return "Jack"
case .Queen:
return "Queen"
case .King:
return "King"
}
}
}
} | [
-1
] |
b3d48ae955762e0470321d99d7766ce7363f221f | 2ac04303c88fb18e81d3c0f40ee9b1c3a107d04e | /I Am Rich/AppDelegate.swift | 0d91cbf3bdb29a920e0f23319825d6b08171258e | [] | no_license | kincheng/xcode | 39efdac1c005f8e8ea731755a1be3166814fee3e | e4d24f80f780af7e5f1f85a9d6ff23213c1caa17 | refs/heads/master | 2020-04-18T16:44:25.854065 | 2019-01-26T20:11:39 | 2019-01-26T20:11:39 | 167,640,059 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,169 | swift | //
// AppDelegate.swift
// I Am Rich
//
// Created by Kin Cheng on 8/19/18.
// Copyright © 2018 Kin Cheng. 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,
229391,
327695,
278545,
229394,
278548,
229397,
229399,
229402,
352284,
229405,
278556,
278559,
229408,
278564,
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,
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,
287238,
320007,
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,
287365,
311942,
303751,
352905,
279178,
287371,
311946,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
172702,
164509,
303773,
172705,
287394,
172707,
303780,
287390,
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,
328563,
303987,
279413,
303991,
303997,
295806,
295808,
295813,
304005,
320391,
213895,
304007,
304009,
304011,
230284,
304013,
295822,
279438,
213902,
189329,
295825,
304019,
189331,
58262,
304023,
304027,
279452,
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,
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,
279929,
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,
279991,
288185,
337335,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
288210,
370130,
288212,
222676,
288214,
280021,
239064,
288217,
329177,
280027,
288220,
288218,
239070,
288224,
280034,
288226,
280036,
288229,
280038,
288230,
288232,
370146,
288234,
320998,
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,
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,
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,
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,
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,
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,
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,
281135,
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,
240519,
322440,
314249,
338823,
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,
290174,
298365,
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,
324757,
282261,
175770,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
306856,
282295,
282300,
323260,
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,
148946,
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,
44948,
298901,
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,
307385,
307386,
307388,
258235,
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,
315860,
176597,
283095,
127447,
299481,
176605,
242143,
127457,
291299,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
127490,
283142,
127494,
127497,
233994,
135689,
127500,
291341,
233998,
127506,
234003,
127509,
234006,
127511,
152087,
283161,
242202,
135707,
234010,
242206,
135710,
242208,
291361,
242220,
291378,
234038,
152118,
234041,
315961,
70213,
242250,
111193,
242275,
299620,
242279,
168562,
184952,
135805,
291456,
135808,
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,
292433,
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,
234364,
291711,
234368,
291714,
234370,
291716,
234373,
201603,
226182,
234375,
308105,
226185,
234379,
324490,
234384,
234388,
234390,
324504,
234393,
209818,
308123,
324508,
234396,
291742,
226200,
234398,
234401,
291747,
291748,
234405,
291750,
234407,
324520,
324518,
324522,
234410,
291756,
226220,
291754,
324527,
291760,
234417,
201650,
324531,
234414,
234422,
226230,
275384,
324536,
234428,
291773,
242623,
324544,
234431,
234434,
324546,
324548,
226245,
234437,
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,
275462,
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,
234648,
300189,
324766,
119967,
234653,
283805,
234657,
324768,
242852,
300197,
234661,
283813,
234664,
177318,
275626,
234667,
316596,
308414,
234687,
300223,
300226,
308418,
234692,
300229,
308420,
308422,
226500,
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,
283917,
177424,
275725,
349451,
349464,
415009,
283939,
259367,
292143,
283951,
300344,
226617,
243003,
283963,
226628,
300357,
283973,
177482,
283983,
316758,
357722,
316766,
292192,
316768,
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,
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,
227440,
316917,
308727,
292343,
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,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
284243,
300628,
284245,
276053,
284247,
317015,
284249,
243290,
284251,
276052,
284253,
300638,
284255,
235097,
243293,
284258,
292452,
292454,
284263,
177766,
284265,
292458,
284267,
292461,
284272,
284274,
284278,
292470,
276086,
292473,
284283,
276093,
284286,
276095,
284288,
292481,
284290,
325250,
284292,
292485,
292479,
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,
276160,
358080,
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,
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,
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,
227426,
276579,
227430,
276583,
309354,
301167,
276590,
350321,
350313,
350316,
284786,
350325,
252022,
276595,
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,
342707,
154292,
318132,
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,
301913,
277337,
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,
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,
64966,
245191,
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,
286233,
302617,
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,
286313,
40554,
286312,
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,
278227,
286420,
229076,
286425,
319194,
278235,
301163,
278238,
229086,
286432,
294625,
294634,
302838,
319226,
286460,
278274,
302852,
278277,
302854,
294664,
311048,
352008,
319243,
311053,
302862,
319251,
294682,
278306,
188199,
294701,
278320,
319280,
319290,
229192,
302925,
188247,
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,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
278516,
311283,
278519,
237562
] |
bd1a3cfbb8bb2f8026adb8ec11fc5b9f2945a170 | 61d484ae68e40b89432f66f98164c811692ee612 | /Circle/ProfileDetailDataSource.swift | cbcf0299e1ce143dd38bf0d3f3b5c858a7a39b22 | [
"MIT"
] | permissive | getcircle/luno-ios | 2a29192c130c48415e55b50850e77a1a37f22ad1 | d18260abb537496d86cf607c170dd5e91c406f0f | refs/heads/master | 2021-05-01T04:01:52.647661 | 2016-12-05T04:54:08 | 2016-12-05T04:54:08 | 27,101,758 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 12,416 | swift | //
// ProfileDetailDataSource.swift
// Circle
//
// Created by Ravi Rani on 11/28/14.
// Copyright (c) 2014 RH Labs Inc. All rights reserved.
//
import UIKit
import ProtobufRegistry
class ProfileDetailDataSource: CardDataSource {
var profile: Services.Profile.Containers.ProfileV1!
var profileHeaderView: ProfileHeaderCollectionReusableView?
var textDataDelegate: TextValueCollectionViewDelegate?
private(set) var directReports: Array<Services.Profile.Containers.ProfileV1>?
private(set) var location: Services.Organization.Containers.LocationV1?
private(set) var manager: Services.Profile.Containers.ProfileV1?
private(set) var managesTeam: Services.Organization.Containers.TeamV1?
private(set) var peers: Array<Services.Profile.Containers.ProfileV1>?
private(set) var team: Services.Organization.Containers.TeamV1?
override class var cardSeparatorInset: UIEdgeInsets {
return UIEdgeInsetsMake(0.0, 20.0, 0.0, 0.0)
}
convenience init(profile withProfile: Services.Profile.Containers.ProfileV1) {
self.init()
profile = withProfile
}
override func getTitle() -> String {
return profile.fullName
}
override func loadData(completionHandler: (error: NSError?) -> Void) {
// If loading for the first time, add the placeholder card
if cards.count == 0 {
addPlaceholderCard()
}
var storedError: NSError!
let actionsGroup = dispatch_group_create()
dispatch_group_enter(actionsGroup)
Services.Profile.Actions.getExtendedProfile(profile.id) {
(profile, manager, peers, directReports, team, managesTeam, locations, error) -> Void in
if let error = error {
storedError = error
}
else {
self.profile = profile
self.directReports = directReports
self.location = locations?.first
self.manager = manager
self.managesTeam = managesTeam
self.peers = peers
self.team = team
}
dispatch_group_leave(actionsGroup)
completionHandler(error: error)
}
dispatch_group_notify(actionsGroup, GlobalMainQueue) { () -> Void in
self.populateData()
completionHandler(error: storedError)
}
}
// MARK: - Populate Data
internal func populateData() {
resetCards()
addPlaceholderCard()
addContactsCard()
addLocationCard()
addManagerCard()
addTeamCard()
addManagesTeamCard()
setDataInHeader()
}
internal func addPlaceholderCard() -> Card? {
// Add placeholder card to load profile header instantly
let card = Card(cardType: .Placeholder, title: "Info")
card.addHeader(headerClass: ProfileHeaderCollectionReusableView.self)
appendCard(card)
return card
}
internal func addContactsCard() -> Card? {
do {
let card = Card(cardType: .ContactMethods, title: "Contact")
card.showContentCount = false
card.addHeader(headerClass: ProfileSectionHeaderCollectionReusableView.self)
var contactMethods = Array<Services.Profile.Containers.ContactMethodV1>()
let emailContactMethod = Services.Profile.Containers.ContactMethodV1.Builder()
emailContactMethod.contactMethodType = .Email
emailContactMethod.value = profile.email
emailContactMethod.label = "Email"
contactMethods.append(try emailContactMethod.build())
contactMethods.appendContentsOf(profile.contactMethods)
var profileHasPhoneContactMethod = false
for contactMethod in contactMethods {
if contactMethod.contactMethodType == .Phone || contactMethod.contactMethodType == .CellPhone {
profileHasPhoneContactMethod = true
}
}
if !profileHasPhoneContactMethod {
let phoneContactMethod = Services.Profile.Containers.ContactMethodV1.Builder()
phoneContactMethod.contactMethodType = .Phone
phoneContactMethod.label = "Phone"
contactMethods.append(try phoneContactMethod.build())
}
card.addContent(content: contactMethods)
appendCard(card)
return card
}
catch {
print("Error: \(error)")
return nil
}
}
internal func addLocationCard() -> Card? {
if let location = location {
let card = Card(cardType: .Profiles, title: "Works at")
card.showContentCount = false
card.addHeader(headerClass: ProfileSectionHeaderCollectionReusableView.self)
card.addContent(content: [location])
appendCard(card)
return card
}
return nil
}
internal func addManagerCard() -> Card? {
var content = [AnyObject]()
if let manager = manager {
content.append(manager)
}
if content.count > 0 {
let card = Card(cardType: .Profiles, title: AppStrings.ProfileSectionManagerTitle)
card.showContentCount = false
card.addHeader(headerClass: ProfileSectionHeaderCollectionReusableView.self)
card.addContent(content: content)
appendCard(card)
return card
}
return nil
}
internal func addTeamCard() -> Card? {
var content = [AnyObject]()
if let team = team {
content.append(team)
}
if content.count > 0 {
let card = Card(cardType: .Profiles, subType: .Teams, title: "Team")
card.showContentCount = false
card.addHeader(headerClass: ProfileSectionHeaderCollectionReusableView.self)
card.addContent(content: content)
if self.peers?.count ?? 0 > 0 {
card.addDefaultFooter()
}
appendCard(card)
return card
}
return nil
}
internal func addManagesTeamCard() -> Card? {
var content = [AnyObject]()
if let managesTeam = managesTeam {
content.append(managesTeam)
}
if content.count > 0 {
let card = Card(cardType: .Profiles, subType: .ManagedTeams, title: "Manages")
card.showContentCount = false
card.addHeader(headerClass: ProfileSectionHeaderCollectionReusableView.self)
card.addContent(content: content)
card.addDefaultFooter()
appendCard(card)
return card
}
return nil
}
// MARK: - Cell Type
func typeOfCell(indexPath: NSIndexPath) -> ContentType {
let card = cards[indexPath.section]
if let rowDataDictionary = card.content[indexPath.row] as? [String: AnyObject] {
return ContentType(rawValue: (rowDataDictionary["type"] as! Int!))!
}
else if let keyValueData = card.content[indexPath.row] as? KeyValueData {
return keyValueData.type
}
return .Other
}
override func configureHeader(header: CircleCollectionReusableView, atIndexPath indexPath: NSIndexPath) {
super.configureHeader(header, atIndexPath: indexPath)
if let profileHeader = header as? ProfileHeaderCollectionReusableView {
profileHeaderView = profileHeader
setDataInHeader()
}
else if let cardHeader = header as? ProfileSectionHeaderCollectionReusableView, card = cardAtSection(indexPath.section) {
if card.type == .ContactMethods {
cardHeader.cardSubtitleLabel.hidden = false
cardHeader.cardSubtitleLabel.text = location?.officeCurrentDateAndTimeLabel()
}
cardHeader.addBottomBorder = true
}
}
override func configureFooter(footer: CircleCollectionReusableView, atIndexPath indexPath: NSIndexPath) {
super.configureFooter(footer, atIndexPath: indexPath)
if let footerView = footer as? CardFooterCollectionReusableView, card = cardAtSection(indexPath.section) {
switch card.subType {
case .Teams:
let peerCount = self.peers?.count ?? 0
var buttonTitle = NSString(format: NSLocalizedString(
"Works with %d Peers",
comment: "Text indicating number of peers a person works with"
),
peerCount
) as String
if peerCount == 1 {
buttonTitle = NSLocalizedString(
"Works with 1 Peer",
comment: "Text indicating one other person works with the user"
)
}
if peerCount == 0 {
footerView.setButtonEnabled(false)
}
footerView.setButtonTitle(buttonTitle)
case .ManagedTeams:
let directReportsCount = self.directReports?.count ?? 0
var buttonTitle = NSString(format: NSLocalizedString(
"View %d Direct Reports",
comment: "Text indicating number of direct reports a person has"
),
directReportsCount
) as String
if directReportsCount == 1 {
buttonTitle = NSLocalizedString(
"View 1 Direct Report",
comment: "Text indicating this person has one direct report"
)
}
if directReportsCount == 0 {
footerView.setButtonEnabled(false)
}
footerView.setButtonTitle(buttonTitle)
default:
break
}
}
}
override func configureCell(cell: CircleCollectionViewCell, atIndexPath indexPath: NSIndexPath) {
let cellIsBottomOfSection = cellAtIndexPathIsBottomOfSection(indexPath)
if cellIsBottomOfSection {
cell.addRoundCorners([.BottomLeft, .BottomRight], radius: 4.0)
}
else {
cell.removeRoundedCorners()
}
cell.showSeparator = !cellIsBottomOfSection
if let profileCollectionViewCell = cell as? ProfileCollectionViewCell {
profileCollectionViewCell.separatorInset = UIEdgeInsetsZero
}
else if let contactMethodCell = cell as? ContactCollectionViewCell {
contactMethodCell.contactMethodValueLabel.textColor = UIColor.appPrimaryTextColor()
contactMethodCell.separatorInset = UIEdgeInsetsMake(0.0, 72.0, 0.0, 0.0)
if let contactMethod = contentAtIndexPath(indexPath) as? Services.Profile.Containers.ContactMethodV1 where contactMethod.value.characters.count == 0 {
if isProfileLoggedInUserProfile() {
contactMethodCell.contactMethodValueLabel.text = AppStrings.ContactPlaceholderAddNumber
contactMethodCell.contactMethodValueLabel.textColor = UIColor.appMissingFieldValueColor()
}
else {
contactMethodCell.contactMethodValueLabel.text = AppStrings.ContactPlaceholderNumberNotAdded
}
}
}
else if let textDataCell = cell as? TextValueCollectionViewCell {
textDataCell.delegate = textDataDelegate
}
}
private func isProfileLoggedInUserProfile() -> Bool {
if let loggedInUserProfile = AuthenticationViewController.getLoggedInUserProfile() {
return loggedInUserProfile.id == profile.id
}
return false
}
private func setDataInHeader() {
profileHeaderView?.setProfile(profile, location: location, team: team)
}
}
| [
-1
] |
963ceab0c34032233d90776f7d7afb652db17eb0 | 0471c4c41a0b6dd3b53692b800b199cc5eada0f7 | /tips_Calculator/ViewController.swift | 55bdc89d29e22f653cb5e266284aaee3267e2739 | [
"Apache-2.0"
] | permissive | YousefKazerooni/tips_Calculator | 9c015aed834e8e38910f891f17f2fe767fa14bbf | 65d5d2bbe726d42301d6302d93e8b6cad21615d9 | refs/heads/master | 2016-08-12T09:18:28.663894 | 2015-12-31T19:04:36 | 2015-12-31T19:04:36 | 47,481,423 | 0 | 1 | null | null | null | null | UTF-8 | Swift | false | false | 6,383 | swift | //
// ViewController.swift
// tips_Calculator
//
// Created by Yousef Kazerooni on 12/2/15.
// Copyright © 2015 Yousef Kazerooni. All rights reserved.
//
import UIKit
let lastBillAmout = "Last_Bill_Amount"
let lastUsed = "Last_Used"
//Counter becomes greater than zero after the first time viewing
//It is then used to create a dark dividing line in the middle of the page
var counter = 0
class ViewController: UIViewController {
@IBOutlet weak var tipControl: UISegmentedControl!
@IBOutlet weak var billField: UITextField!
@IBOutlet weak var tipLabel: UILabel!
@IBOutlet weak var totalLabel: UILabel!
//animated UIViews
@IBOutlet weak var animatedView: UIView!
@IBOutlet weak var animatedViewRed: UIView!
@IBOutlet weak var animatedViewLowest: UIView!
let userDefaults = NSUserDefaults.standardUserDefaults()
//opportunity to save everything
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
updatePercentageTitle()
updatePercentage()
counter = counter + 1
if (counter > 1) {
let dividingLine = UIView()
// set background color to blue
dividingLine.backgroundColor = UIColor.blackColor()
// set frame (position and size) of the square
// iOS coordinate system starts at the top left of the screen
// so this square will be at top left of screen, 50x50pt
// CG in CGRect stands for Core Graphics
dividingLine.frame = CGRect(x: 0, y: 300, width: 400, height: 20)
// finally, add the square to the screen
self.view.addSubview(dividingLine)
}
}
func updatePercentageTitle ()
{
tipControl.setTitle("\(userDefaults.integerForKey(lowTipKey))%", forSegmentAtIndex:0)
tipControl.setTitle("\(userDefaults.integerForKey(midTipKey))%", forSegmentAtIndex:1)
tipControl.setTitle("\(userDefaults.integerForKey(highTipKey))%", forSegmentAtIndex:2)
}
func updatePercentage ()
{
let currencyFormatter = NSNumberFormatter()
currencyFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
currencyFormatter.locale = NSLocale.currentLocale()
let tipPercentages = [ Double(userDefaults.floatForKey(lowTipKey))/100.0, Double (userDefaults.floatForKey(midTipKey))/100.0, Double (userDefaults.floatForKey(highTipKey))/100.0]
let tipPercentage = tipPercentages[ tipControl.selectedSegmentIndex]
let billAmount = NSString(string: billField.text!).doubleValue
let tip = billAmount * tipPercentage
let total = billAmount + tip
//tipLabel.text = " $\(tip)"
//totalLabel.text = " $\(total)"
tipLabel.text = currencyFormatter.stringFromNumber(tip)
totalLabel.text = currencyFormatter.stringFromNumber(total)
}
//*********************************************
//animation fuction
func animationMain () {
//defining the final color
let blue = UIColor(red: 41.0/255.0,
green: 0.5,
blue: 185/255.0,
alpha: 1.0)
//defining repetition
let options = UIViewAnimationOptions.Repeat
//the function for animation
//animating movement and color
//and incorporating repetition
//Animating the RED UIView
UIView.animateWithDuration(2.0, delay: 0.0, options: options, animations: {
// any changes entered in this block will be animated
self.animatedViewRed.transform = CGAffineTransformTranslate( self.animatedViewRed.transform, -330.0, 0.0 )
self.animatedViewRed.backgroundColor = blue
}, completion: nil)
//Animating the WHITE UIView
UIView.animateWithDuration(3.0, delay: 0.0, options: options, animations: {
// any changes entered in this block will be animated
self.animatedView.transform = CGAffineTransformTranslate( self.animatedView.transform, 330.0, 0.0 )
self.animatedView.backgroundColor = blue
}, completion: nil)
//Animating the Lowest UIView
UIView.animateWithDuration(4.0, delay: 0.0, options: options, animations: {
// any changes entered in this block will be animated
self.animatedViewLowest.transform = CGAffineTransformTranslate( self.animatedViewLowest.transform, 330.0, 0.0 )
self.animatedViewLowest.backgroundColor = blue
}, completion: nil)
}
//*********************************************
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Checking when the app was last used
let timeNow = NSDate()
let timeLast = userDefaults.objectForKey(lastUsed) as? NSDate
if ( timeLast != nil && timeNow.timeIntervalSinceDate(timeLast!) < 600)
{
billField.text = userDefaults.stringForKey(lastBillAmout)
}
//making the textfield as the first responder
self.billField.becomeFirstResponder()
//intializing the labels on the first launch
tipLabel.text = "$0.00"
totalLabel.text = "$0.00"
//calling animation
animationMain()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func onEditingChanged(sender: AnyObject) {
updatePercentage()
}
@IBAction func onTap(sender: AnyObject) {
view.endEditing (true)
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
userDefaults.setObject(NSDate(), forKey: lastUsed)
userDefaults.setObject(billField.text, forKey: lastBillAmout)
userDefaults.synchronize()
}
}
| [
-1
] |
2bde73cdff0c4f6b0e89684674372f7d88792091 | fcf8f4ae22078af47e66ab1fe51dd345859aac08 | /Sources/APIRule.swift | 6753d2f629ea4fab6c8f4d29c5304bcc421d1e30 | [
"MIT"
] | permissive | daviejaneway/OrbitFrontend | ffbe14eaf7de7ce3ed00f2d2f2266ec637034015 | 07de0da247eabfea693f4192f73313a73a252d94 | refs/heads/master | 2020-12-30T12:24:32.370124 | 2019-02-23T14:10:44 | 2019-02-23T14:10:44 | 91,385,565 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 6,593 | swift | //
// APIRule.swift
// OrbitFrontend
//
// Created by Davie Janeway on 27/08/2017.
//
//
import Foundation
import OrbitCompilerUtils
extension OrbitError {
static func trailingWithinStatement(token: Token) -> OrbitError {
return OrbitError(message: "'within' statement missing name: \(token.type) -- \(token.value)\(token.position)")
}
}
public class WithinExpression : AbstractExpression {
public let apiRef: TypeIdentifierExpression
init(apiRef: TypeIdentifierExpression, startToken: Token) {
self.apiRef = apiRef
super.init(startToken: startToken)
}
}
public class WithinRule : ParseRule {
public let name = "Orb.Core.Grammar.Within"
public func trigger(tokens: [Token]) throws -> Bool {
guard let token = tokens.first else { throw OrbitError.ranOutOfTokens() }
return token.type == .Keyword && Keywords.within.matches(token: token)
}
public func parse(context: ParseContext) throws -> AbstractExpression {
let keyword = try context.consume()
guard Keywords.within.matches(token: keyword) else { throw OrbitError.unexpectedToken(token: keyword) }
let nameParser = TypeIdentifierRule()
do {
let apiRef = try nameParser.parse(context: context) as! TypeIdentifierExpression
return WithinExpression(apiRef: apiRef, startToken: keyword)
} catch {
throw OrbitError.trailingWithinStatement(token: keyword)
}
}
}
public class WithExpression : AbstractExpression {
public let withs: [TypeIdentifierExpression]
init(withs: [TypeIdentifierExpression], startToken: Token) {
self.withs = withs
super.init(startToken: startToken)
}
}
public class WithRule : ParseRule {
public let name = "Orb.Core.Grammar.With"
public func trigger(tokens: [Token]) throws -> Bool {
guard let token = tokens.first else { throw OrbitError.ranOutOfTokens() }
return token.type == .Keyword && Keywords.with.matches(token: token)
}
public func parse(context: ParseContext) throws -> AbstractExpression {
var names = [TypeIdentifierExpression]()
let start = try context.peek()
let nameParser = TypeIdentifierRule()
var next = start
while Keywords.with.matches(token: next) {
_ = try context.consume()
let name = try nameParser.parse(context: context) as! TypeIdentifierExpression
names.append(name)
guard context.hasMore() else { break }
next = try context.peek()
}
return WithExpression(withs: names, startToken: start)
}
}
public class ProgramExpression : AbstractExpression {
public let apis: [APIExpression]
public init(apis: [APIExpression], startToken: Token) {
self.apis = apis
super.init(startToken: startToken)
}
}
public class ProgramRule : ParseRule {
public let name = "Orb.Core.Grammar.Program"
public func trigger(tokens: [Token]) throws -> Bool {
return true
}
public func parse(context: ParseContext) throws -> AbstractExpression {
let start = try context.peek()
let apiParser = APIRule()
var apis = [APIExpression]()
var api: AbstractExpression? = nil
let annotationRule = AnnotationRule()
var annotations = [AnnotationExpression]()
while true {
if context.hasMore() {
let next = try context.peek()
if next.type == .Annotation {
let annotation = try annotationRule.parse(context: context) as! AnnotationExpression
annotations.append(annotation)
continue
}
api = try apiParser.parse(context: context)
apis.append(api! as! APIExpression)
} else {
break
}
}
let program = ProgramExpression(apis: apis, startToken: start)
annotations.forEach {
program.annotate(annotation: PhaseAnnotation(identifier: $0.annotationName.value, annotationExpression: $0))
}
return program
}
}
public class APIRule : ParseRule {
public let name = "Orb.Core.Grammar.API"
public init() {}
public func trigger(tokens: [Token]) throws -> Bool {
guard let token = tokens.first else { throw OrbitError.ranOutOfTokens() }
return token.type == .Keyword && Keywords.api.matches(token: token)
}
public func parse(context: ParseContext) throws -> AbstractExpression {
let start = try context.consume()
let nameParser = TypeIdentifierRule()
let name = try nameParser.parse(context: context) as! TypeIdentifierExpression
var next = try context.expectAny(types: [.LBrace, .Keyword])
let withinParser = WithinRule()
let withParser = WithRule()
// With & Within are optional, so we'll
let within = context.attempt(rule: withinParser) as? WithinExpression
let with = context.attempt(rule: withParser) as? WithExpression
// Consume the LBrace
_ = try context.consume()
next = try context.peek()
var body = [AbstractExpression]()
while next.type != .RBrace {
if next.type == .Keyword && Keywords.type.matches(token: next) {
// Parse type def
let expr = try TypeDefRule().parse(context: context)
body.append(expr)
} else if next.type == .LParen {
// Parse method
let expr = try MethodRule().parse(context: context)
body.append(expr)
} else if next.type == .Annotation {
let expr = try AnnotationRule().parse(context: context)
body.append(expr)
} else {
throw OrbitError.unexpectedToken(token: next)
}
next = try context.peek()
}
_ = try context.expect(type: .RBrace, overrideError: OrbitError.unclosedBlock(startToken: start))
return APIExpression(name: name, body: body, with: with, within: within, startToken: start)
}
}
| [
-1
] |
7e397f4cdffccc6cdd43633dc410018dd4b2fcd9 | af26ef1627e675eaf9b9c2f5a9c11715948d6cd0 | /YFMoreViewController/Sources/YFMoreViewDelegate.swift | de4f6cbec64018ee86dadfdf11b3489c184955b3 | [
"MIT"
] | permissive | yeziahehe/YFMoreViewController | a6566d3727ebd888166c94f78231363e34240e35 | 01f73994458635d51e517b39181fa3639687865e | refs/heads/master | 2021-01-02T09:07:09.603485 | 2019-03-15T02:11:57 | 2019-03-15T02:11:57 | 99,144,967 | 47 | 3 | null | null | null | null | UTF-8 | Swift | false | false | 631 | swift | //
// YFMoreViewDelegate.swift
// YFMoreViewController
//
// Created by 叶帆 on 2017/8/3.
// Copyright © 2017年 Suzhou Coryphaei Information&Technology Co., Ltd. All rights reserved.
//
import UIKit
public protocol YFMoreViewDelegate: class {
func moreview(_ moreview: YFMoreViewController, didSelectItemAt index: Int, type: YFMoreItemType)
func moreView(_ moreview: YFMoreViewController, didSelectItemAt tag: String, type: YFMoreItemType)
}
public extension YFMoreViewDelegate {
func moreview(_ moreview: YFMoreViewController, didSelectItemAt index: Int, type: YFMoreItemType) {
}
}
| [
34458
] |
648a7355ea445612f7501b771209ead187f848ca | 284dcc3f5f0f459fd834f91fe9f21b29cfb737e5 | /labs-iOS/lab-03/pretty pixels/pretty pixels/AppDelegate.swift | 4b546483f4634e196c2250ebb4b02e624418807b | [] | no_license | eroeber/Elsa_MAD | 997370ef1aae07b36f573798f5ba70c72bffb761 | 1578c80584d2c8bb80c730ffbf0d7a5a0bbf10ff | refs/heads/master | 2020-07-20T09:56:36.999604 | 2019-12-17T23:16:07 | 2019-12-17T23:16:07 | 206,619,159 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,178 | swift | //
// AppDelegate.swift
// pretty pixels
//
// Created by Elsa Roeber on 9/22/19.
// Copyright © 2019 Elsa Roeber. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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,
229388,
294924,
278542,
327695,
229391,
278545,
229394,
278548,
229397,
229399,
229402,
352284,
229405,
278556,
278559,
229408,
229415,
229417,
327722,
237613,
229422,
360496,
237618,
229426,
229428,
286774,
286776,
229432,
204856,
319544,
352318,
286791,
237640,
286797,
278605,
311375,
163920,
196692,
319573,
311383,
278623,
278626,
319590,
278635,
278639,
131192,
278648,
237693,
327814,
303241,
131209,
417930,
311436,
303244,
319633,
286873,
286876,
311460,
311469,
32944,
286906,
327866,
180413,
286910,
286916,
286922,
286924,
286926,
319694,
286928,
131281,
278743,
278747,
295133,
319716,
237807,
303345,
286962,
229622,
327930,
278781,
278783,
278785,
237826,
319751,
286987,
319757,
286999,
319770,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
155966,
319809,
319810,
278849,
319814,
311623,
319818,
311628,
229709,
287054,
319822,
278865,
229717,
196963,
196969,
139638,
213367,
106872,
319872,
311683,
311693,
65943,
319898,
311719,
278952,
139689,
311728,
278967,
311741,
278975,
319938,
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,
320007,
172552,
303623,
287238,
279051,
172558,
279055,
303632,
279058,
303637,
279063,
279067,
172572,
172577,
295459,
172581,
295461,
279082,
311850,
279084,
172591,
172598,
172607,
172612,
377413,
172614,
303690,
172618,
33357,
303696,
279124,
172634,
262752,
172644,
311911,
189034,
295533,
189039,
352880,
172656,
295538,
189040,
172660,
189044,
287349,
287355,
287360,
295553,
295557,
311942,
303751,
287365,
352905,
311946,
287371,
311951,
287377,
172691,
311957,
287381,
287386,
221850,
230045,
172702,
287390,
303773,
172705,
287394,
172707,
303780,
164509,
287398,
287400,
279208,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
328381,
287423,
328384,
287427,
312005,
312006,
172748,
287436,
295633,
172755,
303827,
279255,
287450,
279258,
303835,
189149,
303838,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
205564,
303871,
230146,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
295707,
328476,
295710,
230175,
303914,
279353,
230202,
312124,
328508,
222018,
295755,
377676,
148302,
287569,
303959,
230237,
279390,
230241,
303976,
336744,
303985,
303987,
328563,
303991,
303997,
295806,
295808,
304005,
295813,
304007,
320391,
304009,
213895,
304011,
189325,
304013,
295822,
213902,
189329,
279438,
304019,
58262,
304023,
279452,
279462,
304042,
213931,
304055,
230327,
287675,
304063,
304065,
213954,
189378,
156612,
312272,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
295945,
230413,
197645,
295949,
320528,
140312,
295961,
238620,
304164,
304170,
238641,
238652,
238655,
230465,
238658,
296004,
336964,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
205931,
164973,
205934,
279661,
312432,
279669,
337018,
279683,
205968,
296084,
304285,
238756,
205991,
222377,
165035,
337067,
165038,
238766,
230576,
238770,
304311,
230592,
312518,
279750,
230600,
230607,
148690,
320727,
279769,
304348,
304354,
296163,
320740,
304360,
320748,
279788,
279790,
304370,
296189,
320771,
312585,
296205,
230674,
320786,
230677,
296213,
230679,
320792,
230681,
296215,
230689,
312622,
296243,
312630,
222522,
296253,
222525,
296255,
312639,
296259,
296262,
230727,
296264,
320840,
238919,
296267,
296271,
222545,
230739,
312663,
222556,
337244,
230752,
312676,
230760,
173418,
230763,
410987,
230768,
296305,
312692,
230773,
279929,
181626,
304506,
304505,
181631,
312711,
296331,
288140,
288144,
230800,
288154,
337306,
288160,
288162,
288164,
279975,
279983,
173488,
288176,
279985,
312755,
296373,
312759,
279991,
288185,
337335,
222652,
312766,
173507,
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,
288242,
296435,
288244,
288250,
296446,
402942,
148990,
321022,
296450,
230916,
230919,
304651,
370187,
230923,
304653,
402969,
230940,
222752,
108066,
296486,
296488,
157229,
230961,
157236,
288320,
288325,
124489,
280145,
288338,
280149,
288344,
280152,
239194,
280158,
403039,
239202,
370279,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
419489,
190118,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
419522,
280260,
419525,
206536,
206539,
206541,
206543,
280276,
321239,
280283,
288478,
313055,
321252,
313066,
288494,
280302,
419570,
288499,
288502,
280314,
288510,
67330,
280324,
280331,
198416,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
321336,
288576,
345921,
337732,
304968,
280402,
173907,
313176,
42842,
280419,
321381,
296812,
313201,
1920,
305028,
280454,
247688,
124817,
280468,
239510,
124827,
247709,
214944,
321458,
296883,
124853,
296890,
288700,
296894,
190403,
296900,
280515,
337862,
165831,
280521,
231379,
296921,
354265,
354270,
239586,
354281,
231404,
124913,
165876,
288764,
239612,
313340,
239617,
313347,
313358,
321560,
305176,
313371,
354338,
305191,
223273,
313386,
354348,
215090,
124978,
124980,
288824,
288826,
321595,
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,
215154,
313458,
149618,
280691,
313464,
321659,
288895,
321670,
215175,
141455,
280725,
313498,
100520,
288936,
280747,
288940,
288947,
280755,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
321740,
313548,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
280811,
280817,
280819,
157940,
125171,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125191,
125207,
321817,
125209,
125218,
321842,
223539,
125239,
280888,
305464,
280891,
289087,
280897,
280900,
239944,
305480,
280906,
239947,
305485,
305489,
280919,
248153,
215387,
354653,
354656,
313700,
190832,
223606,
313720,
280956,
280959,
313731,
199051,
240011,
289166,
240017,
297363,
190868,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
305594,
289210,
281024,
289218,
289221,
289227,
436684,
166378,
305647,
281075,
174580,
240124,
305662,
305664,
240129,
305666,
305668,
330244,
240132,
223749,
223752,
338440,
150025,
223757,
281102,
223763,
223765,
322074,
281116,
182819,
281135,
150066,
158262,
158266,
289342,
322115,
158283,
281163,
338528,
338532,
199273,
281196,
19053,
158317,
313973,
297594,
281210,
158347,
264845,
182926,
133776,
182929,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
174764,
314029,
314033,
240309,
314047,
314051,
297671,
158409,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322314,
322318,
281361,
281372,
215850,
281388,
289593,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
183172,
338823,
322440,
314249,
224151,
240535,
289687,
289694,
289696,
289700,
289712,
281529,
289724,
183260,
420829,
289762,
322534,
297961,
183277,
322550,
322563,
330764,
175134,
322599,
322610,
314421,
281654,
314427,
207937,
314433,
322642,
314456,
281691,
314461,
281704,
314474,
281711,
289912,
248995,
306341,
306347,
322734,
306354,
142531,
199877,
289991,
306377,
289997,
249045,
363742,
363745,
298216,
330988,
216303,
322801,
388350,
363802,
199976,
199978,
314671,
298292,
298294,
216376,
298306,
380226,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314718,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
298358,
314743,
306552,
290171,
314747,
298365,
290174,
306555,
224641,
281987,
298372,
314756,
281990,
298377,
314763,
314768,
224657,
314773,
306581,
314779,
314785,
314793,
282025,
282027,
241068,
241070,
241072,
282034,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
282089,
191985,
282101,
241142,
191992,
290298,
151036,
290302,
290305,
192008,
323084,
282127,
290321,
323090,
282130,
290325,
282133,
241175,
290328,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290351,
290356,
224849,
282195,
306778,
159324,
159330,
314979,
298598,
323176,
241260,
257658,
315016,
290445,
282255,
282261,
175770,
298651,
323229,
282269,
323231,
298655,
61092,
282277,
282295,
323260,
282300,
323266,
282310,
306897,
241362,
306904,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
241450,
282410,
306988,
306991,
323376,
315184,
315190,
241464,
159545,
307009,
241475,
307012,
315211,
307027,
315221,
315223,
241496,
241498,
307035,
307040,
110433,
282465,
110438,
298860,
110445,
282478,
315249,
315253,
315255,
339838,
315267,
282499,
315269,
241544,
282505,
241546,
241548,
298896,
298898,
282514,
44948,
241556,
298901,
241560,
282520,
241563,
241565,
241567,
241569,
282531,
241574,
282537,
298922,
241581,
241583,
323504,
241586,
282547,
241588,
290739,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
241661,
299006,
282623,
315396,
241669,
315397,
307211,
282639,
241693,
102438,
217127,
323630,
282681,
290877,
159811,
315463,
315466,
192589,
307278,
307287,
315482,
315483,
217179,
192605,
233567,
200801,
299105,
217188,
299109,
307303,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
323700,
299126,
233591,
307329,
307338,
233613,
241813,
307352,
299164,
299167,
184479,
184481,
184486,
307370,
307372,
307374,
307376,
323763,
299191,
176311,
307385,
258235,
307388,
176316,
307390,
299200,
307394,
299204,
307396,
184518,
307399,
323784,
307409,
307411,
299225,
233701,
307432,
282881,
291089,
291104,
233766,
307508,
315701,
307510,
332086,
307512,
307518,
282942,
282947,
323917,
282957,
233808,
323921,
315733,
323926,
233815,
315739,
299357,
242018,
242024,
299373,
315757,
250231,
315771,
242043,
299391,
291202,
299398,
242057,
291212,
299405,
291222,
315801,
291226,
242075,
283033,
291231,
61855,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
299444,
127413,
291254,
283062,
127417,
291260,
127421,
127424,
299457,
127429,
127431,
315856,
127440,
315860,
176597,
127447,
283095,
127449,
299481,
176605,
242143,
127455,
291299,
127460,
340454,
127463,
242152,
291305,
127466,
176620,
127469,
291314,
127474,
291317,
135672,
127480,
233979,
291323,
127485,
127490,
291330,
127494,
127497,
233994,
135689,
127500,
233998,
234003,
127509,
234006,
127511,
152087,
283161,
242202,
135707,
234010,
135710,
242206,
242208,
291361,
242220,
152118,
234038,
234041,
315961,
70213,
242250,
111193,
242275,
299620,
242279,
184952,
135805,
135808,
291456,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
135839,
299680,
225954,
135844,
299684,
242343,
209576,
242345,
373421,
135870,
135873,
135876,
135879,
299723,
299726,
225998,
226002,
119509,
226005,
226008,
201444,
299750,
234219,
283372,
185074,
283382,
316151,
234231,
234236,
226045,
234239,
242431,
209665,
299778,
234242,
242436,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
201496,
234264,
234266,
234269,
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,
201557,
234329,
234333,
308063,
234336,
242530,
234338,
349027,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
226171,
291711,
234368,
234370,
234373,
226182,
234375,
308105,
226185,
234379,
234384,
234388,
234390,
226200,
234393,
209818,
308123,
234396,
324504,
291742,
324508,
234398,
234401,
291747,
291748,
234405,
324518,
291750,
324520,
234407,
234410,
324522,
291754,
291756,
226220,
324527,
234414,
234417,
201650,
324531,
291760,
234422,
324536,
234428,
291773,
234431,
242623,
324544,
234434,
324546,
324548,
226239,
226245,
234437,
234439,
234443,
291788,
193486,
234446,
193488,
234449,
275406,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
234487,
234490,
234493,
234496,
316416,
234501,
275462,
234504,
234507,
234510,
234515,
300054,
234519,
234520,
316439,
234523,
234526,
234528,
300066,
234532,
300069,
234535,
234537,
234540,
234543,
234546,
275508,
300085,
234549,
300088,
234553,
234556,
234558,
316479,
234561,
308291,
234563,
316483,
160835,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
234590,
234593,
234595,
234597,
300133,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
316530,
300148,
398455,
144506,
234618,
234620,
275579,
234623,
226433,
275588,
234629,
242822,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
324757,
226453,
234647,
234648,
234650,
308379,
275608,
234653,
300189,
119967,
324766,
324768,
283805,
234657,
300197,
234661,
283813,
234664,
275626,
234667,
316596,
234687,
300223,
300226,
234692,
283844,
300229,
308422,
308420,
283850,
300234,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
300263,
300265,
300267,
300270,
300272,
120053,
300278,
316663,
275703,
300284,
275710,
300287,
292097,
300289,
161027,
300292,
300294,
275719,
177419,
300299,
300301,
349451,
242957,
177424,
275725,
283917,
349464,
415009,
292143,
283951,
300344,
243003,
283963,
226628,
300357,
283973,
177482,
283983,
316758,
357722,
316766,
316768,
292192,
292197,
243046,
316774,
218473,
284010,
136562,
324978,
333178,
275840,
316803,
316806,
316811,
316814,
226703,
300433,
234899,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
144814,
144820,
374196,
284084,
292279,
144826,
144828,
144830,
144832,
144835,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
226787,
218597,
292329,
300523,
300527,
308720,
292338,
316917,
292343,
308727,
300537,
316933,
316947,
308757,
316959,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
284213,
316983,
284215,
194103,
284218,
226877,
284223,
284226,
243268,
284228,
292421,
284231,
226886,
128584,
284234,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
284243,
300628,
284245,
276052,
276053,
284247,
235097,
243290,
284249,
284251,
317015,
300638,
284253,
284258,
292452,
292454,
284263,
284265,
292458,
292461,
284272,
284274,
284278,
292470,
276086,
292473,
284283,
276093,
284286,
292479,
284288,
292481,
284290,
325250,
284292,
292485,
325251,
276095,
276098,
284297,
317066,
284299,
317068,
276109,
284301,
284303,
284306,
276114,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
284329,
317098,
284331,
276137,
284333,
284335,
284337,
284339,
300726,
284343,
284346,
284350,
358080,
284354,
358083,
284358,
358089,
284362,
276170,
276175,
284368,
276177,
284370,
358098,
284372,
317138,
284379,
284381,
284384,
358114,
284386,
358116,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
284399,
276206,
358128,
358133,
358135,
276216,
358138,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
300816,
300819,
317207,
284440,
300828,
300830,
276255,
325408,
300832,
300834,
317221,
227109,
358183,
276268,
243504,
300850,
284469,
276280,
325436,
358206,
366406,
276295,
153417,
292681,
276308,
284502,
317271,
276315,
292700,
284511,
292715,
292721,
284529,
300915,
292729,
317306,
284540,
292734,
325512,
276365,
358292,
399252,
284564,
284566,
350106,
284572,
276386,
284579,
358312,
317353,
284585,
276395,
358326,
358330,
276411,
276418,
301009,
301011,
301013,
292823,
358360,
301015,
301017,
292828,
276446,
153568,
276452,
292839,
276455,
350186,
292843,
276460,
227314,
350200,
325624,
276472,
317435,
276479,
350210,
276482,
178181,
276485,
350218,
276490,
292876,
350222,
317456,
317458,
243733,
243740,
317468,
325666,
243751,
292904,
178224,
276528,
309298,
243762,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
243779,
284739,
292934,
243785,
276553,
350293,
350295,
309337,
227418,
350299,
350302,
194654,
227423,
178273,
309346,
227426,
194660,
350308,
309348,
309350,
292968,
350313,
309354,
309352,
350316,
227430,
276583,
301167,
276590,
350321,
284786,
276595,
350325,
350328,
292985,
301178,
292989,
301185,
292993,
350339,
317570,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
350375,
350379,
350381,
350383,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
301252,
350406,
227529,
301258,
309450,
276685,
276689,
309462,
301272,
194780,
309471,
301283,
317672,
317674,
325867,
243960,
227583,
276735,
227587,
276739,
276742,
227596,
325910,
309530,
342298,
317729,
276775,
211241,
325937,
325943,
211260,
260421,
276811,
235853,
235858,
276829,
276833,
391523,
276836,
293227,
293232,
276848,
186744,
211324,
227709,
285061,
366983,
317833,
178572,
285070,
285077,
317853,
276896,
342434,
317858,
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,
293370,
301562,
317951,
309764,
301575,
121352,
236043,
342541,
113167,
309779,
317971,
309781,
227877,
227879,
293417,
227882,
293421,
105007,
236082,
23094,
277054,
219714,
129603,
318020,
301636,
301639,
301643,
285265,
309844,
277080,
309849,
285277,
285282,
318055,
277100,
121458,
277106,
309885,
309888,
277122,
277128,
301706,
334476,
326285,
318094,
318092,
277136,
277139,
227992,
318108,
285340,
318110,
383658,
285357,
318128,
293555,
342707,
154292,
285368,
318144,
277187,
277201,
342745,
137946,
342747,
113378,
228069,
277223,
342760,
285417,
56043,
56045,
277232,
228081,
56059,
310015,
310020,
285448,
310029,
228113,
277273,
293659,
326430,
228128,
293666,
318248,
277291,
293677,
318253,
293685,
285494,
301880,
301884,
293696,
277317,
310100,
301911,
301913,
277337,
301921,
236397,
162671,
310134,
236408,
277368,
416639,
416640,
113538,
416648,
277385,
301972,
424853,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
293811,
293820,
203715,
342994,
293849,
293861,
228328,
318442,
228330,
228332,
326638,
277486,
351217,
318450,
293876,
293877,
285686,
302073,
121850,
293882,
244731,
285690,
302075,
293887,
277504,
277507,
277511,
277519,
293908,
293917,
293939,
318516,
277561,
277564,
310336,
293956,
277573,
228422,
293960,
310344,
277577,
203857,
293971,
310355,
310359,
236632,
277594,
203872,
277601,
285792,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
367737,
285817,
302205,
285821,
392326,
285831,
302218,
285835,
162964,
384148,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
277671,
302248,
64682,
294063,
294065,
302258,
277687,
294072,
318651,
294076,
277695,
318657,
244930,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
302296,
384222,
310498,
285927,
318698,
302315,
228592,
294132,
138485,
228601,
204026,
228606,
64768,
310531,
138505,
228617,
318742,
204067,
277798,
130345,
384302,
285999,
113969,
318773,
318776,
286010,
417086,
286016,
294211,
302403,
384328,
146765,
294221,
326991,
294223,
179547,
302436,
294246,
327015,
310632,
327017,
351594,
310648,
310651,
310657,
310659,
351619,
294276,
253320,
310665,
318858,
310672,
351633,
310689,
130468,
277932,
310703,
130486,
310710,
310712,
310715,
302526,
228799,
302534,
245191,
310727,
302541,
302543,
310737,
228825,
310749,
310755,
187880,
310764,
286188,
310772,
40440,
40443,
310780,
286203,
40448,
228864,
286214,
228871,
302603,
302614,
302617,
286233,
302621,
187936,
146977,
187939,
40484,
294435,
40486,
286246,
40488,
245288,
294439,
40491,
294440,
294443,
294445,
310831,
40499,
40502,
212538,
40507,
40511,
228933,
40521,
286283,
40525,
40527,
212560,
400976,
228944,
40533,
40537,
40539,
40541,
278109,
40544,
40550,
40552,
286312,
40554,
286313,
40557,
294521,
343679,
294537,
310925,
286354,
278163,
122517,
278168,
179870,
327333,
229030,
212648,
302764,
278188,
319153,
278196,
319163,
302781,
319171,
302789,
294599,
278216,
294601,
343757,
212690,
319187,
286420,
278227,
286425,
319194,
278235,
229086,
278238,
294625,
294634,
302838,
319226,
286460,
278274,
302852,
278277,
302854,
311048,
294664,
352008,
319243,
311053,
302862,
319251,
294682,
278306,
188199,
294701,
319280,
278320,
319290,
229192,
302925,
188247,
188252,
237409,
294776,
294785,
327554,
360322,
294811,
319390,
40865,
319394,
294817,
294821,
311209,
343983,
188340,
40886,
294844,
294847,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
311283,
278516,
278519
] |
70e63f9cfea14376464444415f1b6d03fb423e3e | 025ad593053fbc22d5a9b3f352be32b5b12c1556 | /UIControls/UIControls/Source/Views/AlertView.swift | 5e60b5aaae9c9797b0cef3cb52defc19ad4c7059 | [
"MIT"
] | permissive | todun/SwiftUI-UIControls | 27702afacd31e7092bd12352708809814a88e3d7 | d8d5565bb2b73aaa1dd395cd2ca918c048e8c29e | refs/heads/master | 2020-06-08T21:14:22.299708 | 2019-06-21T15:57:53 | 2019-06-21T15:57:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,395 | swift | //
// AlertView.swift
// UIControls
//
// Created by Sud on 6/21/19.
// Copyright © 2019 MyCompany. All rights reserved.
//
import SwiftUI
struct AlertView : View {
@State var actionSheet: ActionSheet?
var body: some View {
VStack {
// Button(action: {
// let alert = Alert(title: Text("Showing Alert"),
// message: Text("Message"),
// primaryButton: Alert.Button.default(Text("OK")),
// secondaryButton: Alert.Button.destructive(Text("Remove")))
// }) {
// Text("Show Alert")
// }
Button(action: {
self.actionSheet = ActionSheet(title: Text("Showing ActionSheet"),
message: Text("Message"),
buttons: [Alert.Button.default(Text("OK")),
Alert.Button.cancel(),
Alert.Button.destructive(Text("Delete"))])
}) {
Text("Show ActionSheet")
}
.presentation(actionSheet)
}
}
}
#if DEBUG
struct AlertView_Previews : PreviewProvider {
static var previews: some View {
AlertView()
}
}
#endif
| [
-1
] |
fe9c99c3b8524f6b3e8375daf0c890804feb54d0 | 6cd053eb1d5873980f9369156305cd08828da00e | /Falcon/PlacesManager.swift | da70ea61ba514968e417a52fe811f8b993cea8df | [] | no_license | floranpagliai/Falcon | 1c902607b76a368d8647fad22682cfca2e1a137a | d96a16faaa026ebc6576da1667f38a2023e1c587 | refs/heads/master | 2021-06-07T22:58:44.370010 | 2016-03-12T15:15:24 | 2016-03-12T15:15:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,004 | swift | //
// PlacesManager.swift
// Falcon
//
// Created by Floran Pagliai on 18/02/2016.
// Copyright © 2016 Falcon. All rights reserved.
//
import GoogleMaps
class PlacesManager {
// MARK: Properties
let placesClient = GMSPlacesClient()
let ref = FirebaseManager()
let eWalletManager = EWalletManager()
func fetchNearPlaces(withCompletionBlock: (places: [Place]) -> Void) {
self.placesClient.currentPlaceWithCallback { (likelihoodList, error) -> Void in
if error != nil {
print("[\(self.dynamicType)] Error: \(error!.localizedDescription)")
return
}
var places: [Place] = [Place]()
for likelihood in likelihoodList!.likelihoods {
if let likelihood = likelihood as? GMSPlaceLikelihood {
let placeType = self.convertPlaceType(likelihood.place.types as! [String])
let placeRef = self.ref.getPathRef("places/"+likelihood.place.placeID)
placeRef.observeEventType(.Value, withBlock: {
(snapshot) in
if snapshot.value is NSNull {
let place = Place(
id: likelihood.place.placeID,
name: likelihood.place.name,
address: likelihood.place.formattedAddress,
type: placeType,
coordinate: likelihood.place.coordinate
)
if place.type != PlaceType.unknow {
places.append(place)
self.savePlace(place)
}
} else {
let place = Place(snapshot: snapshot)
if place.type != PlaceType.unknow {
places.append(place)
self.updatePlace(place)
}
}
withCompletionBlock(places: places)
})
}
}
}
}
func savePlace(place: Place) {
let placesRef = ref.getPathRef("places")
ref.update(placesRef, key: place.id, data: place.toAnyObject())
self.eWalletManager.newPlaceAdress(place.id)
}
func updatePlace(place: Place) {
let placesRef = ref.getPathRef("places")
ref.update(placesRef, key: place.id, data: place.toAnyObject())
}
func savePlaces(places: [Place]) {
let placesRef = ref.getPathRef("places")
for place in places {
ref.update(placesRef, key: place.id, data: place.toAnyObject())
//self.eWalletManager.newPlaceAdress(place.id)
}
}
func convertPlaceType(types: [String]) -> PlaceType {
var placeType: PlaceType = PlaceType.unknow
for type in types {
switch type {
case "bank":
placeType = PlaceType.bank
break
case "restaurant":
placeType = PlaceType.restaurant
break
case "school":
placeType = PlaceType.school
break
case "store":
placeType = PlaceType.store
break
default: break
}
}
return placeType
}
func convertPlaceType(type: String) -> PlaceType {
var placeType: PlaceType = PlaceType.unknow
switch type {
case "bank":
placeType = PlaceType.bank
break
case "restaurant":
placeType = PlaceType.restaurant
break
case "school":
placeType = PlaceType.school
break
case "store":
placeType = PlaceType.store
break
default: break
}
return placeType
}
}
| [
-1
] |
ae6363bbd9165c8039c1fdee9640b3d350db0f27 | b58ce409860acfed11c60fcd202aa258b426f7ca | /Package.swift | 5d6e71a2f8953995be5fc522b8efa8f94ee30d60 | [
"MIT"
] | permissive | badibadiola/macos-launch-application | f8dea2a1e6cba646ee2b0343582f12284b0605d7 | 54351fb5cecf3a5cfbd47bebf786e74fca8b10ad | refs/heads/master | 2022-04-22T22:44:54.695442 | 2020-04-29T16:32:31 | 2020-04-29T16:32:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 393 | swift | // swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "macos-launch-application",
platforms: [
.macOS(.v10_12)
],
products: [
.executable(
name: "launch-app",
targets: [
"LaunchApp"
]
),
.executable(
name: "kill-app",
targets: [
"KillApp"
]
)
],
targets: [
.target(name: "LaunchApp"),
.target(name: "KillApp")
]
) | [
-1
] |
27fa721af695256e54d5a2f221bd4c631a16025b | 565c293ac0f6240c5d80c07d9702df19695a25d2 | /Social-Feedback-App/SpecificMessageTableViewController.swift | ffe136040da238bd28f0112a04c0432ebc0c44cd | [] | no_license | kalolad1/Uncoated | 749fc5412c925645f90b7bf34e5b4380ae083384 | 8b55fe2efca882f19a197888940362af10e13f4c | refs/heads/master | 2021-01-02T22:59:50.226992 | 2017-09-23T18:32:51 | 2017-09-23T18:32:51 | 99,434,222 | 2 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,694 | swift | //
// SpecificMessageTableViewController.swift
// Social-Feedback-App
//
// Created by Darshan Kalola on 8/7/17.
// Copyright © 2017 Darshan Kalola. All rights reserved.
//
import UIKit
import Firebase
class SpecificMessageTableViewController: UITableViewController {
// MARK: — Model
var userModel: SendingUserModel!
var messageConstant = MessageConstants()
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let currentGenre = userModel.genreOfMessage
return messageConstant.allBasicGenreMessage[currentGenre!]!.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "messageCell", for: indexPath) as! SpecificMessageTableViewCell
let specificMessageArray = [String](messageConstant.allBasicGenreMessage[userModel.genreOfMessage!]!)
cell.cellLabel.text = specificMessageArray[indexPath.row]
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// We want to send the message to the given account, and return back to the home screen
let sendingID = userModel.userID
let uniqueIDMessage = NSUUID().uuidString
userModel.specificMessage = messageConstant.allBasicGenreMessage[userModel.genreOfMessage!]?[indexPath.row]
// Allow user to confirm message one last time
confirmMessage(uniqueIDMessage, sendingID: sendingID!, forIndexPath: indexPath)
}
// MARK: - Alerts
func confirmMessage(_ uniqueID: String, sendingID: String, forIndexPath: IndexPath) {
let alertController = UIAlertController(title: "Confirm", message: "Are you sure you wish to send this message?", preferredStyle: .actionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
let confirmAction = UIAlertAction(title: "Yes", style: .default) { (action) in
// Upload that message to firebase with key of the sending ID
let ref = FIRDatabase.database().reference().child("user-messages").child(sendingID)
let valuesDict = [uniqueID: self.userModel.specificMessage!]
ref.updateChildValues(valuesDict) { (error, ref) in
if error != nil {
print(error!)
return
}
}
DispatchQueue.main.async {
self.showConfirmationMessage()
}
}
alertController.addAction(cancelAction)
alertController.addAction(confirmAction)
present(alertController, animated: true) {
self.tableView.deselectRow(at: forIndexPath, animated: true)
}
}
func showConfirmationMessage() {
let alert = UIAlertController(title: "Message Sent!", message: nil, preferredStyle: .alert)
present(alert, animated: true, completion: nil)
perform(#selector(dismissConfirmationMessage), with: nil, afterDelay: 1.0)
}
func dismissConfirmationMessage() {
dismiss(animated: true, completion: nil)
}
// MARK: - VC life cycle
override func viewDidLoad() {
super.viewDidLoad()
// Set the size for the rows
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 140
}
}
| [
-1
] |
061c9ea753aadd197daacbf530dc46b995c73610 | 08e8af0099fd9674e60a285c1f5890355dc306b3 | /EcoDatumAmazon/Models/SoilDataType+Codable.swift | 33f404e12bb839c6a3515a831a0c452dc9335f01 | [] | no_license | kwingerden/EcoDatumAmazon | 56611b42570a571c13c82c5cba9f80088536935c | cc6ff4c6c3f4d7c70c6ec283dacf8e9340987aca | refs/heads/master | 2021-06-30T19:25:21.354232 | 2019-01-04T19:45:36 | 2019-01-04T19:45:36 | 137,440,846 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 462 | swift | //
// SoilDataType.swift
// EcoDatumAmazon
//
// Created by Kenneth Wingerden on 6/14/18.
// Copyright © 2018 Kenneth Wingerden. All rights reserved.
//
import Foundation
enum SoilDataType: String, Codable {
case Nitrogen
case Phosphorus
case Potassium
case Moisture
case Texture
case Temperature
static let all: [SoilDataType] = [
.Nitrogen,
.Phosphorus,
.Potassium,
.Moisture,
.Texture,
.Temperature
]
}
| [
-1
] |
6e5ad8d28c248a77ffbd50e613583829f01904bd | 425cadaa58d90fdd4fe1a2c01ff7d1eeb81fabff | /Pods/PusherSwift/Sources/Services/PusherConnection.swift | 93957df604ebab635d565eaa57d2b7971c9c1606 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | rangerlabs/Ranger.Swift.Demo | f795e2d9b08c1665c20c90075275812ff628a042 | 11e410a15a88ecf6c58d1af70e7654610d4bf1ff | refs/heads/master | 2023-02-19T06:31:54.049520 | 2021-01-13T22:45:09 | 2021-01-13T22:45:09 | 327,686,780 | 2 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 39,472 | swift | import Foundation
import NWWebSocket
// swiftlint:disable file_length type_body_length
@objcMembers
@objc open class PusherConnection: NSObject {
public let url: String
public let key: String
open var options: PusherClientOptions
open var globalChannel: GlobalChannel!
open var socketId: String?
open var connectionState = ConnectionState.disconnected
open var channels = PusherChannels()
open var socket: NWWebSocket!
open var URLSession: Foundation.URLSession
open var userDataFetcher: (() -> PusherPresenceChannelMember)?
open var reconnectAttemptsMax: Int?
open var reconnectAttempts: Int = 0
open var maxReconnectGapInSeconds: Double? = 120
open weak var delegate: PusherDelegate?
open var pongResponseTimeoutInterval: TimeInterval = 30
open var activityTimeoutInterval: TimeInterval
var reconnectTimer: Timer?
var pongResponseTimeoutTimer: Timer?
var activityTimeoutTimer: Timer?
var intentionalDisconnect: Bool = false
var eventQueue: PusherEventQueue
var eventFactory: PusherEventFactory
var socketConnected: Bool = false {
didSet {
setConnectionStateToConnectedAndAttemptSubscriptions()
}
}
var connectionEstablishedMessageReceived: Bool = false {
didSet {
setConnectionStateToConnectedAndAttemptSubscriptions()
}
}
/**
Initializes a new PusherConnection with an app key, websocket, URL, options and URLSession
- parameter key: The Pusher app key
- parameter socket: The websocket object
- parameter url: The URL the connection is made to
- parameter options: A PusherClientOptions instance containing all of the user-specified
client options
- parameter URLSession: An NSURLSession instance for the connection to use for making
authentication requests
- returns: A new PusherConnection instance
*/
public init(
key: String,
socket: NWWebSocket,
url: String,
options: PusherClientOptions,
URLSession: Foundation.URLSession = Foundation.URLSession.shared
) {
self.url = url
self.key = key
self.options = options
self.URLSession = URLSession
self.socket = socket
self.activityTimeoutInterval = options.activityTimeout ?? 60
self.eventFactory = PusherConcreteEventFactory()
self.eventQueue = PusherConcreteEventQueue(eventFactory: eventFactory, channels: channels)
super.init()
self.eventQueue.delegate = self
self.socket.delegate = self
}
deinit {
self.reconnectTimer?.invalidate()
self.activityTimeoutTimer?.invalidate()
self.pongResponseTimeoutTimer?.invalidate()
}
/**
Initializes a new PusherChannel with a given name
- parameter channelName: The name of the channel
- parameter auth: A PusherAuth value if subscription is being made to an
authenticated channel without using the default auth methods
- parameter onMemberAdded: A function that will be called with information about the
member who has just joined the presence channel
- parameter onMemberRemoved: A function that will be called with information about the
member who has just left the presence channel
- returns: A new PusherChannel instance
*/
internal func subscribe(
channelName: String,
auth: PusherAuth? = nil,
onMemberAdded: ((PusherPresenceChannelMember) -> Void)? = nil,
onMemberRemoved: ((PusherPresenceChannelMember) -> Void)? = nil
) -> PusherChannel {
let newChannel = channels.add(
name: channelName,
connection: self,
auth: auth,
onMemberAdded: onMemberAdded,
onMemberRemoved: onMemberRemoved
)
guard self.connectionState == .connected else { return newChannel }
if !self.authorize(newChannel, auth: auth) {
print("Unable to subscribe to channel: \(newChannel.name)")
}
return newChannel
}
/**
Initializes a new PusherChannel with a given name
- parameter channelName: The name of the channel
- parameter auth: A PusherAuth value if subscription is being made to an
authenticated channel without using the default auth methods
- parameter onMemberAdded: A function that will be called with information about the
member who has just joined the presence channel
- parameter onMemberRemoved: A function that will be called with information about the
member who has just left the presence channel
- returns: A new PusherChannel instance
*/
internal func subscribeToPresenceChannel(
channelName: String,
auth: PusherAuth? = nil,
onMemberAdded: ((PusherPresenceChannelMember) -> Void)? = nil,
onMemberRemoved: ((PusherPresenceChannelMember) -> Void)? = nil
) -> PusherPresenceChannel {
let newChannel = channels.addPresence(
channelName: channelName,
connection: self,
auth: auth,
onMemberAdded: onMemberAdded,
onMemberRemoved: onMemberRemoved
)
guard self.connectionState == .connected else { return newChannel }
if !self.authorize(newChannel, auth: auth) {
print("Unable to subscribe to channel: \(newChannel.name)")
}
return newChannel
}
/**
Unsubscribes from a PusherChannel with a given name
- parameter channelName: The name of the channel
*/
internal func unsubscribe(channelName: String) {
if let chan = self.channels.find(name: channelName), chan.subscribed {
self.sendEvent(event: Constants.Events.Pusher.unsubscribe,
data: [
Constants.JSONKeys.channel: channelName
] as [String: Any]
)
self.channels.remove(name: channelName)
}
}
/**
Unsubscribes from all PusherChannels
*/
internal func unsubscribeAll() {
for (_, channel) in channels.channels {
unsubscribe(channelName: channel.name)
}
}
/**
Either writes a string directly to the websocket with the given event name
and data, or calls a client event to be sent if the event is prefixed with
"client"
- parameter event: The name of the event
- parameter data: The data to be stringified and sent
- parameter channel: The name of the channel
*/
open func sendEvent(event: String, data: Any, channel: PusherChannel? = nil) {
if event.components(separatedBy: "-")[0] == Constants.EventTypes.client {
sendClientEvent(event: event, data: data, channel: channel)
} else {
let dataString = JSONStringify([Constants.JSONKeys.event: event,
Constants.JSONKeys.data: data])
self.delegate?.debugLog?(message: PusherLogger.debug(for: .eventSent,
context: dataString))
self.socket.send(string: dataString)
}
}
/**
Sends a client event with the given event, data, and channel name
- parameter event: The name of the event
- parameter data: The data to be stringified and sent
- parameter channel: The name of the channel
*/
fileprivate func sendClientEvent(event: String, data: Any, channel: PusherChannel?) {
if let channel = channel {
if channel.type == .presence || channel.type == .private {
let dataString = JSONStringify([Constants.JSONKeys.event: event,
Constants.JSONKeys.data: data,
Constants.JSONKeys.channel: channel.name] as [String: Any])
self.delegate?.debugLog?(message: PusherLogger.debug(for: .clientEventSent,
context: dataString))
self.socket.send(string: dataString)
} else {
print("You must be subscribed to a private or presence channel to send client events")
}
}
}
/**
JSON stringifies an object
- parameter value: The value to be JSON stringified
- returns: A JSON-stringified version of the value
*/
fileprivate func JSONStringify(_ value: Any) -> String {
if JSONSerialization.isValidJSONObject(value) {
do {
let data = try JSONSerialization.data(withJSONObject: value, options: [])
let string = String(data: data, encoding: .utf8)
if string != nil {
return string!
}
} catch _ {
}
}
return ""
}
/**
Disconnects the websocket
*/
open func disconnect() {
if self.connectionState == .connected {
intentionalDisconnect = true
updateConnectionState(to: .disconnecting)
self.socket.disconnect()
}
}
/**
Establish a websocket connection
*/
open func connect() {
// reset the intentional disconnect state
intentionalDisconnect = false
if self.connectionState == .connected {
return
} else {
updateConnectionState(to: .connecting)
self.socket.connect()
}
}
/**
Instantiate a new GlobalChannel instance for the connection
*/
internal func createGlobalChannel() {
self.globalChannel = GlobalChannel(connection: self)
}
/**
Add callback to the connection's global channel
- parameter callback: The callback to be stored
- returns: A callbackId that can be used to remove the callback from the connection
*/
internal func addCallbackToGlobalChannel(_ callback: @escaping (PusherEvent) -> Void) -> String {
return globalChannel.bind(callback)
}
/**
Add legacy callback to the connection's global channel
- parameter callback: The callback to be stored
- returns: A callbackId that can be used to remove the callback from the connection
*/
internal func addLegacyCallbackToGlobalChannel(_ callback: @escaping (Any?) -> Void) -> String {
return globalChannel.bindLegacy(callback)
}
/**
Remove the callback with id of callbackId from the connection's global channel
- parameter callbackId: The unique string representing the callback to be removed
*/
internal func removeCallbackFromGlobalChannel(callbackId: String) {
globalChannel.unbind(callbackId: callbackId)
}
/**
Remove all callbacks from the connection's global channel
*/
internal func removeAllCallbacksFromGlobalChannel() {
globalChannel.unbindAll()
}
/**
Set the connection state and call the stateChangeDelegate, if set
- parameter newState: The new ConnectionState value
*/
internal func updateConnectionState(to newState: ConnectionState) {
let oldState = self.connectionState
self.connectionState = newState
self.delegate?.changedConnectionState?(from: oldState, to: newState)
}
/**
Update connection state and attempt subscriptions to unsubscribed channels
*/
fileprivate func setConnectionStateToConnectedAndAttemptSubscriptions() {
if self.connectionEstablishedMessageReceived &&
self.socketConnected &&
self.connectionState != .connected {
updateConnectionState(to: .connected)
attemptSubscriptionsToUnsubscribedChannels()
}
}
/**
Set the connection state to disconnected, mark channels as unsubscribed,
reset connection-related state to initial state, and initiate reconnect
process
*/
fileprivate func resetConnectionAndAttemptReconnect() {
if connectionState != .disconnected {
updateConnectionState(to: .disconnected)
}
for (_, channel) in self.channels.channels {
channel.subscribed = false
}
cleanUpActivityAndPongResponseTimeoutTimers()
socketConnected = false
connectionEstablishedMessageReceived = false
socketId = nil
attemptReconnect()
}
/**
Reset the activity timeout timer
*/
func resetActivityTimeoutTimer() {
cleanUpActivityAndPongResponseTimeoutTimers()
establishActivityTimeoutTimer()
}
/**
Clean up the activity timeout and pong response timers
*/
func cleanUpActivityAndPongResponseTimeoutTimers() {
activityTimeoutTimer?.invalidate()
activityTimeoutTimer = nil
pongResponseTimeoutTimer?.invalidate()
pongResponseTimeoutTimer = nil
}
/**
Schedule a timer to be fired if no activity occurs over the socket within
the activityTimeoutInterval
*/
fileprivate func establishActivityTimeoutTimer() {
self.activityTimeoutTimer = Timer.scheduledTimer(
timeInterval: self.activityTimeoutInterval,
target: self,
selector: #selector(self.sendPing),
userInfo: nil,
repeats: false
)
}
/**
Send a ping to the server
*/
@objc fileprivate func sendPing() {
socket.ping()
self.delegate?.debugLog?(message: PusherLogger.debug(for: .pingSent))
self.setupPongResponseTimeoutTimer()
}
/**
Schedule a timer that will fire if no pong response is received within the
pongResponseTimeoutInterval
*/
fileprivate func setupPongResponseTimeoutTimer() {
pongResponseTimeoutTimer = Timer.scheduledTimer(
timeInterval: pongResponseTimeoutInterval,
target: self,
selector: #selector(cleanupAfterNoPongResponse),
userInfo: nil,
repeats: false
)
}
/**
Invalidate the pongResponseTimeoutTimer and set connection state to disconnected
as well as marking channels as unsubscribed
*/
@objc fileprivate func cleanupAfterNoPongResponse() {
pongResponseTimeoutTimer?.invalidate()
pongResponseTimeoutTimer = nil
resetConnectionAndAttemptReconnect()
}
/**
Handle setting channel state and triggering unsent client events, if applicable,
upon receiving a successful subscription event
- parameter json: The PusherEventJSON containing successful subscription data
*/
fileprivate func handleSubscriptionSucceededEvent(event: PusherEvent) {
if let channelName = event.channelName, let chan = self.channels.find(name: channelName) {
chan.subscribed = true
guard event.data != nil else {
self.delegate?.debugLog?(message: PusherLogger.debug(for: .subscriptionSucceededNoDataInPayload))
return
}
if PusherChannelType.isPresenceChannel(name: channelName) {
if let presChan = self.channels.find(name: channelName) as? PusherPresenceChannel {
if let dataJSON = event.dataToJSONObject() as? [String: Any],
let presenceData = dataJSON[Constants.JSONKeys.presence] as? [String: AnyObject],
let presenceHash = presenceData[Constants.JSONKeys.hash] as? [String: AnyObject] {
presChan.addExistingMembers(memberHash: presenceHash)
}
}
}
let subscriptionEvent = event.copy(withEventName: Constants.Events.Pusher.subscriptionSucceeded)
callGlobalCallbacks(event: subscriptionEvent)
chan.handleEvent(event: subscriptionEvent)
self.delegate?.subscribedToChannel?(name: channelName)
chan.auth = nil
while chan.unsentEvents.count > 0 {
if let pusherEvent = chan.unsentEvents.popLast() {
chan.trigger(eventName: pusherEvent.name, data: pusherEvent.data)
}
}
}
}
/**
Handle setting connection state and making subscriptions that couldn't be
attempted while the connection was not in a connected state
- parameter event: The event to be processed
*/
fileprivate func handleConnectionEstablishedEvent(event: PusherEvent) {
if let connectionData = event.dataToJSONObject() as? [String: Any],
let socketId = connectionData[Constants.JSONKeys.socketId] as? String {
self.socketId = socketId
self.delegate?.debugLog?(message: PusherLogger.debug(for: .connectionEstablished,
context: socketId))
self.reconnectAttempts = 0
self.reconnectTimer?.invalidate()
if options.activityTimeout == nil,
let activityTimeoutFromServer = connectionData["activity_timeout"] as? TimeInterval {
self.activityTimeoutInterval = activityTimeoutFromServer
}
self.connectionEstablishedMessageReceived = true
}
}
/**
Attempts to make subscriptions that couldn't be attempted while the
connection was not in a connected state
*/
fileprivate func attemptSubscriptionsToUnsubscribedChannels() {
for (_, channel) in self.channels.channels {
if !self.authorize(channel, auth: channel.auth) {
print("Unable to subscribe to channel: \(channel.name)")
}
}
}
/**
Handle a new member subscribing to a presence channel
- parameter event: The event to be processed
*/
fileprivate func handleMemberAddedEvent(event: PusherEvent) {
if let channelName = event.channelName,
let chan = self.channels.find(name: channelName) as? PusherPresenceChannel {
if let memberJSON = event.dataToJSONObject() as? [String: Any] {
chan.addMember(memberJSON: memberJSON)
} else {
print("Unable to add member")
}
}
}
/**
Handle a member unsubscribing from a presence channel
- parameter event: The event to be processed
*/
fileprivate func handleMemberRemovedEvent(event: PusherEvent) {
if let channelName = event.channelName,
let chan = self.channels.find(name: channelName) as? PusherPresenceChannel {
if let memberJSON = event.dataToJSONObject() as? [String: Any] {
chan.removeMember(memberJSON: memberJSON)
} else {
print("Unable to remove member")
}
}
}
/**
Handles incoming error
- parameter error: The incoming error to be processed
*/
open func handleError(error: PusherError) {
resetActivityTimeoutTimer()
self.delegate?.receivedError?(error: error)
self.globalChannel?.handleGlobalEventLegacy(event: error.raw)
}
/**
Handle failure of our auth endpoint
- parameter channelName: The name of channel for which authorization failed
- parameter data: The error returned by the auth endpoint
*/
fileprivate func handleAuthorizationError(forChannel channelName: String, error: PusherAuthError) {
let eventName = Constants.Events.Pusher.subscriptionError
let json = [
Constants.JSONKeys.event: eventName,
Constants.JSONKeys.channel: channelName,
Constants.JSONKeys.data: error.data ?? ""
]
if let event = try? self.eventFactory.makeEvent(fromJSON: json, withDecryptionKey: nil) {
DispatchQueue.main.async {
// TODO: Consider removing in favour of exclusively using delegate
self.handleEvent(event: event)
}
if let message = error.message {
print(message)
}
self.delegate?.failedToSubscribeToChannel?(name: channelName,
response: error.response,
data: error.data,
error: error.error)
}
}
/**
Handles incoming events and passes them on to be handled by the appropriate function
- parameter event: The incoming event to be processed
*/
open func handleEvent(event: PusherEvent) {
resetActivityTimeoutTimer()
switch event.eventName {
case Constants.Events.PusherInternal.subscriptionSucceeded:
handleSubscriptionSucceededEvent(event: event)
case Constants.Events.Pusher.connectionEstablished:
handleConnectionEstablishedEvent(event: event)
case Constants.Events.PusherInternal.memberAdded:
handleMemberAddedEvent(event: event)
case Constants.Events.PusherInternal.memberRemoved:
handleMemberRemovedEvent(event: event)
default:
callGlobalCallbacks(event: event)
if let channelName = event.channelName, let internalChannel = self.channels.find(name: channelName) {
internalChannel.handleEvent(event: event)
}
}
}
/**
Call any global callbacks
- parameter event: The incoming event
*/
fileprivate func callGlobalCallbacks(event: PusherEvent) {
globalChannel?.handleGlobalEvent(event: event)
globalChannel?.handleGlobalEventLegacy(event: event.raw)
}
/**
Uses the appropriate authentication method to authenticate subscriptions to private and
presence channels
- parameter channel: The PusherChannel to authenticate
- parameter auth: A PusherAuth value if subscription is being made to an
authenticated channel without using the default auth methods
- returns: A Bool indicating whether or not the authentication request was made
successfully
*/
fileprivate func authorize(_ channel: PusherChannel, auth: PusherAuth? = nil) -> Bool {
if channel.type != .presence && channel.type != .private {
subscribeToNormalChannel(channel)
return true
} else if let auth = auth {
// Don't go through normal auth flow if auth value provided
if channel.type == .private {
self.handlePrivateChannelAuth(authValue: auth.auth, channel: channel)
} else if let channelData = auth.channelData {
self.handlePresenceChannelAuth(authValue: auth.auth, channel: channel, channelData: channelData)
} else {
self.delegate?.debugLog?(message: PusherLogger.debug(for: .presenceChannelSubscriptionAttemptWithoutChannelData))
return false
}
return true
} else {
return requestPusherAuthFromAuthMethod(channel: channel) { [weak self] pusherAuth, error in
if let error = error {
self?.handleAuthorizationError(forChannel: channel.name, error: error)
} else if let pusherAuth = pusherAuth {
self?.handleAuthInfo(pusherAuth: pusherAuth, channel: channel)
}
}
}
}
fileprivate func requestPusherAuthFromAuthMethod(channel: PusherChannel,
completionHandler: @escaping (PusherAuth?, PusherAuthError?) -> Void) -> Bool {
guard let socketId = self.socketId else {
let message = "socketId value not found. You may not be connected."
completionHandler(nil, PusherAuthError(kind: .notConnected, message: message))
return false
}
switch self.options.authMethod {
case .noMethod:
let errorMessage = "Authentication method required for private / presence channels but none provided."
let error = NSError(domain: "com.pusher.PusherSwift",
code: 0,
userInfo: [NSLocalizedFailureReasonErrorKey: errorMessage])
completionHandler(nil, PusherAuthError(kind: .noMethod, message: errorMessage, error: error))
return false
case .endpoint(authEndpoint: let authEndpoint):
let request = requestForAuthValue(from: authEndpoint, socketId: socketId, channelName: channel.name)
sendAuthorizationRequest(request: request, channel: channel, completionHandler: completionHandler)
return true
case .authRequestBuilder(authRequestBuilder: let builder):
if let request = builder.requestFor?(socketID: socketId, channelName: channel.name) {
sendAuthorizationRequest(request: request, channel: channel, completionHandler: completionHandler)
return true
} else {
let errorMessage = "Authentication request could not be built"
let error = NSError(domain: "com.pusher.PusherSwift",
code: 0,
userInfo: [NSLocalizedFailureReasonErrorKey: errorMessage])
completionHandler(nil, PusherAuthError(kind: .couldNotBuildRequest,
message: errorMessage,
error: error))
return false
}
case .authorizer(authorizer: let authorizer):
authorizer.fetchAuthValue(socketID: socketId, channelName: channel.name) { pusherAuth in
if pusherAuth == nil {
print("Auth info passed to authorizer completionHandler was nil")
}
completionHandler(pusherAuth, nil)
}
return true
case .inline(secret: let secret):
var message = ""
var channelData = ""
if channel.type == .presence {
channelData = getUserDataJSON()
message = "\(self.socketId!):\(channel.name):\(channelData)"
} else {
message = "\(self.socketId!):\(channel.name)"
}
let signature = PusherCrypto.generateSHA256HMAC(secret: secret, message: message)
let auth = "\(self.key):\(signature)".lowercased()
var pusherAuth: PusherAuth
if channel.type == .private {
pusherAuth = PusherAuth(auth: auth)
} else {
pusherAuth = PusherAuth(auth: auth, channelData: channelData)
}
completionHandler(pusherAuth, nil)
return true
}
}
/**
Calls the provided userDataFetcher function, if provided, otherwise will
use the socketId as the user_id and return that stringified
- returns: A JSON stringified user data object
*/
fileprivate func getUserDataJSON() -> String {
if let userDataFetcher = self.userDataFetcher {
let userData = userDataFetcher()
if let userInfo: Any = userData.userInfo {
return JSONStringify([Constants.JSONKeys.userId: userData.userId,
Constants.JSONKeys.userInfo: userInfo])
} else {
return JSONStringify([Constants.JSONKeys.userId: userData.userId])
}
} else {
if let socketId = self.socketId {
return JSONStringify([Constants.JSONKeys.userId: socketId])
} else {
print("Authentication failed. You may not be connected")
return ""
}
}
}
/**
Send subscription event for subscribing to a public channel
- parameter channel: The PusherChannel to subscribe to
*/
fileprivate func subscribeToNormalChannel(_ channel: PusherChannel) {
self.sendEvent(
event: Constants.Events.Pusher.subscribe,
data: [
Constants.JSONKeys.channel: channel.name
]
)
}
/**
Creates an authentication request for the given authEndpoint
- parameter endpoint: The authEndpoint to which the request will be made
- parameter socketId: The socketId of the connection's websocket
- parameter channel: The PusherChannel to authenticate subscription for
- returns: URLRequest object to be used by the function making the auth request
*/
fileprivate func requestForAuthValue(from endpoint: String, socketId: String, channelName: String) -> URLRequest {
let allowedCharacterSet = CharacterSet(charactersIn: "!*'();:@&=+$,/?%#[] ").inverted
let encodedChannelName = channelName.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) ?? channelName
var request = URLRequest(url: URL(string: endpoint)!)
request.httpMethod = "POST"
request.httpBody = "socket_id=\(socketId)&channel_name=\(encodedChannelName)".data(using: String.Encoding.utf8)
return request
}
/**
Send authentication request to the authEndpoint specified
- parameter request: The request to send
- parameter channel: The PusherChannel to authenticate subscription for
*/
fileprivate func sendAuthorizationRequest(request: URLRequest,
channel: PusherChannel,
completionHandler: @escaping (PusherAuth?, PusherAuthError?) -> Void) {
let task = URLSession.dataTask(with: request, completionHandler: { data, response, sessionError in
if let error = sessionError {
let message = "Error authorizing channel [\(channel.name)]: \(error)"
completionHandler(nil, PusherAuthError(kind: .requestFailure,
message: message,
response: response,
error: error as NSError?))
return
}
guard let data = data else {
let message = "Error authorizing channel [\(channel.name)]"
completionHandler(nil, PusherAuthError(kind: .invalidAuthResponse,
message: message,
response: response))
return
}
guard let httpResponse = response as? HTTPURLResponse,
(httpResponse.statusCode == 200 || httpResponse.statusCode == 201) else {
let dataString = String(data: data, encoding: String.Encoding.utf8)
let message = "Error authorizing channel [\(channel.name)]: \(String(describing: dataString))"
completionHandler(nil, PusherAuthError(kind: .invalidAuthResponse,
message: message,
response: response,
data: dataString))
return
}
guard let jsonObject = try? JSONSerialization.jsonObject(with: data,
options: []),
let json = jsonObject as? [String: AnyObject] else {
let message = "Error authorizing channel [\(channel.name)]: Could not parse response from auth endpoint"
completionHandler(nil, PusherAuthError(kind: .invalidAuthResponse,
message: message,
response: httpResponse))
return
}
guard let auth = json[Constants.JSONKeys.auth] as? String else {
let message = "Error authorizing channel [\(channel.name)]: No auth field in response"
completionHandler(nil, PusherAuthError(kind: .invalidAuthResponse,
message: message,
response: httpResponse))
return
}
let pusherAuth = PusherAuth(
auth: auth,
channelData: json[Constants.JSONKeys.channelData] as? String,
sharedSecret: json[Constants.JSONKeys.sharedSecret] as? String
)
completionHandler(pusherAuth, nil)
})
task.resume()
}
/**
Handle authorizer info and call appropriate handle function
- parameter authString: The auth response as a dictionary
- parameter channelData: The channelData to send along with the auth request
- parameter channel: The PusherChannel to authorize the subscription for
*/
fileprivate func handleAuthInfo(pusherAuth: PusherAuth, channel: PusherChannel) {
if let decryptionKey = pusherAuth.sharedSecret {
channel.decryptionKey = decryptionKey
}
if let channelData = pusherAuth.channelData {
handlePresenceChannelAuth(authValue: pusherAuth.auth, channel: channel, channelData: channelData)
} else {
handlePrivateChannelAuth(authValue: pusherAuth.auth, channel: channel)
}
}
/**
Handle presence channel auth response and send subscribe message to Pusher API
- parameter auth: The auth string
- parameter channel: The PusherChannel to authorize subscription for
- parameter channelData: The channelData to send along with the auth request
*/
fileprivate func handlePresenceChannelAuth(
authValue: String,
channel: PusherChannel,
channelData: String
) {
(channel as? PusherPresenceChannel)?.setMyUserId(channelData: channelData)
self.sendEvent(
event: Constants.Events.Pusher.subscribe,
data: [
Constants.JSONKeys.channel: channel.name,
Constants.JSONKeys.auth: authValue,
Constants.JSONKeys.channelData: channelData
]
)
}
/**
Handle private channel auth response and send subscribe message to Pusher API
- parameter auth: The auth string
- parameter channel: The PusherChannel to authenticate subscription for
*/
fileprivate func handlePrivateChannelAuth(authValue auth: String, channel: PusherChannel) {
self.sendEvent(
event: Constants.Events.Pusher.subscribe,
data: [
Constants.JSONKeys.channel: channel.name,
Constants.JSONKeys.auth: auth
]
)
}
}
extension PusherConnection: PusherEventQueueDelegate {
func eventQueue(_ eventQueue: PusherEventQueue, didReceiveInvalidEventWithPayload payload: PusherEventPayload) {
DispatchQueue.main.async {
self.delegate?.debugLog?(message: PusherLogger.debug(for: .unableToHandleIncomingMessage,
context: payload))
}
}
func eventQueue(_ eventQueue: PusherEventQueue,
didFailToDecryptEventWithPayload payload: PusherEventPayload,
forChannelName channelName: String) {
DispatchQueue.main.async {
if let eventName = payload[Constants.JSONKeys.event] as? String {
let data = payload[Constants.JSONKeys.data] as? String
self.delegate?.failedToDecryptEvent?(eventName: eventName, channelName: channelName, data: data)
}
self.delegate?.debugLog?(message: PusherLogger.debug(for: .skippedEventAfterDecryptionFailure,
context: channelName))
}
}
func eventQueue(_ eventQueue: PusherEventQueue,
didReceiveEvent event: PusherEvent,
forChannelName channelName: String?) {
DispatchQueue.main.async {
self.handleEvent(event: event)
}
}
/**
Synchronously reloads the decryption key from the auth endpoint. This should be called from the event
queue's dispatch queue. This method should NOT be called from the main thread as it will cause deadlock.
- parameter eventQueue: The event queue that is requesting the reload
- parameter channel: The PusherChannel for which the key is being reloaded
*/
func eventQueue(_ eventQueue: PusherEventQueue, reloadDecryptionKeySyncForChannel channel: PusherChannel) {
let group = DispatchGroup()
group.enter()
// Schedule the loading of the key on the main thread
DispatchQueue.main.async {
_ = self.requestPusherAuthFromAuthMethod(channel: channel) { pusherAuth, error in
if let pusherAuth = pusherAuth,
let decryptionKey = pusherAuth.sharedSecret,
error == nil {
channel.decryptionKey = decryptionKey
} else {
channel.decryptionKey = nil
}
// Once we've updated the key, release the event queue thread to continue processing events
group.leave()
}
}
// Pause the event queue thread until we have the response from the auth endpoint
group.wait()
}
}
internal struct PusherAuthError: Error {
enum Kind {
case notConnected
case noMethod
case couldNotBuildRequest
case invalidAuthResponse
case requestFailure
}
let kind: Kind
var message: String?
var response: URLResponse?
var data: String?
var error: NSError?
}
@objc public class PusherAuth: NSObject {
public let auth: String
public let channelData: String?
public let sharedSecret: String?
public init(auth: String, channelData: String? = nil, sharedSecret: String? = nil) {
self.auth = auth
self.channelData = channelData
self.sharedSecret = sharedSecret
}
}
@objc public enum ConnectionState: Int {
case connecting
case connected
case disconnecting
case disconnected
case reconnecting
static let connectionStates = [
connecting: "connecting",
connected: "connected",
disconnecting: "disconnecting",
disconnected: "disconnected",
reconnecting: "reconnecting"
]
public func stringValue() -> String {
return ConnectionState.connectionStates[self]!
}
}
| [
-1
] |
09ab0c01ed8afcd03a7ff84b3671ad665cb079e0 | 702b10ef3cb8c50428f0cb445f6bc7c85a0361e8 | /Taskee/Extensions/UIViewController+Extensions.swift | 180040f532bcf9d7673031d3518358d76b587597 | [] | no_license | anikamorris/Taskee | 99cd63951752db61c36fcffd14f3c3b64fd0416d | 203574baa2e14e5bced188a7cb2c9b6d07d85a7f | refs/heads/master | 2022-12-28T05:09:09.110720 | 2020-10-06T20:59:38 | 2020-10-06T20:59:38 | 297,789,981 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 578 | swift | //
// UIViewController+Extensions.swift
// Taskee
//
// Created by Anika Morris on 10/5/20.
// Copyright © 2020 Anika Morris. All rights reserved.
//
import Foundation
import UIKit
extension UIViewController {
func presentAlert(title: String, message: String = "") {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(OKAction)
self.present(alertController, animated: true, completion: nil)
}
}
| [
-1
] |
dc6936398352a543f75d57c2f80b68bbb393ac86 | 36b9672ce731ba0a36bac81805fd99cdefb5525e | /GymApp/SceneDelegate.swift | b4eb010bbeed968382fc05ca05757a4fe47502d3 | [] | no_license | island-1-2-3-4-5/GymApp | b0ae6bcfacd5cfece88bd145f90c72c1f0a3bf0c | 7488043ec498d70ef05c1b4e1a62fb83135d0bf8 | refs/heads/master | 2022-04-25T16:01:19.350182 | 2020-04-27T12:31:00 | 2020-04-27T12:31:00 | 259,313,238 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,527 | swift | //
// SceneDelegate.swift
// GymApp
//
// Created by Roman on 23.04.2020.
// Copyright © 2020 Roman. 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.
// Save changes in the application's managed object context when the application transitions to the background.
(UIApplication.shared.delegate as? AppDelegate)?.saveContext()
}
}
| [
393221,
163849,
393228,
393231,
393251,
352294,
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,
336140,
164107,
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,
328204,
328207,
410129,
393748,
377372,
188959,
385571,
377384,
197160,
33322,
352822,
270905,
197178,
418364,
188990,
369224,
270922,
385610,
352844,
385617,
352865,
262761,
352875,
344694,
352888,
336513,
377473,
336517,
344710,
385671,
148106,
377485,
352919,
98969,
336549,
344745,
361130,
336556,
434868,
164535,
336568,
164539,
328379,
328387,
352969,
418508,
385743,
385749,
189154,
369382,
361196,
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,
222129,
345036,
386004,
345046,
386012,
386019,
386023,
328690,
435188,
328703,
328710,
418822,
377867,
328715,
386070,
336922,
345119,
377888,
328747,
214060,
345134,
345139,
361525,
361537,
377931,
197708,
189525,
156762,
402523,
361568,
148580,
345200,
361591,
361594,
410746,
214150,
345224,
386187,
337048,
345247,
361645,
337072,
345268,
337076,
402615,
361657,
402636,
328925,
165086,
165092,
328933,
222438,
328942,
386286,
386292,
206084,
115973,
328967,
345377,
345380,
353572,
345383,
337207,
345400,
378170,
369979,
386366,
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,
419360,
370208,
394787,
419363,
370214,
419369,
394796,
419377,
419386,
206397,
419401,
353868,
419404,
173648,
419408,
214611,
419412,
403040,
345702,
222831,
370298,
353920,
345737,
198282,
403085,
403092,
345750,
419484,
345758,
345763,
419492,
345766,
419498,
419502,
370351,
419507,
337588,
419510,
419513,
419518,
403139,
337607,
419528,
419531,
419536,
272083,
394967,
419543,
419545,
345819,
419548,
181982,
419551,
345829,
419560,
337643,
419564,
337647,
370416,
141052,
337661,
337671,
362249,
362252,
395022,
362256,
321300,
345888,
116512,
362274,
378664,
354107,
354112,
247618,
370504,
329545,
345932,
354124,
370510,
247639,
337751,
370520,
313181,
182110,
354143,
354157,
345965,
345968,
345971,
345975,
182136,
403321,
1914,
354173,
395148,
247692,
337809,
247701,
329625,
436127,
436133,
247720,
337834,
362414,
337845,
190393,
247760,
346064,
346069,
329699,
354275,
190440,
247790,
354314,
346140,
337980,
436290,
395340,
378956,
436307,
338005,
329816,
100454,
329833,
329853,
329857,
329868,
411806,
329886,
346273,
362661,
100525,
387250,
379067,
387261,
256193,
395467,
346317,
411862,
411865,
411869,
411874,
379108,
411877,
387303,
395496,
346344,
338154,
387307,
346350,
338161,
436474,
321787,
379135,
411905,
411917,
43279,
379154,
395539,
387350,
387353,
338201,
182559,
338212,
248112,
362823,
436556,
321880,
362844,
379234,
354674,
182642,
321911,
420237,
379279,
272787,
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,
338661,
338665,
264942,
330479,
363252,
338680,
207620,
264965,
191240,
338701,
199455,
396067,
346917,
396070,
215854,
355123,
355141,
355144,
338764,
330581,
330585,
387929,
355167,
265056,
265059,
355176,
355180,
355185,
330612,
330643,
412600,
207809,
379849,
347082,
396246,
330711,
248794,
248799,
437219,
257009,
265208,
330750,
199681,
379908,
338951,
330761,
330769,
330775,
248863,
158759,
396329,
347178,
404526,
396337,
330803,
396340,
339002,
388155,
339010,
347208,
248905,
330827,
330830,
248915,
183384,
412765,
339037,
257121,
322660,
265321,
330869,
248952,
420985,
330886,
330890,
347288,
248986,
44199,
380071,
339118,
249018,
339133,
126148,
322763,
330959,
330966,
265433,
265438,
388320,
363757,
339199,
396552,
175376,
175397,
208167,
273709,
372016,
437553,
347442,
199989,
175416,
396601,
208189,
437567,
175425,
437571,
437576,
437584,
331089,
396634,
175451,
437596,
429408,
175458,
208228,
175461,
175464,
265581,
331124,
175478,
249210,
175484,
175487,
249215,
175491,
249219,
249225,
249228,
249235,
175514,
175517,
396703,
396706,
175523,
355749,
396723,
388543,
380353,
339401,
380364,
339406,
372177,
339414,
249303,
413143,
339418,
339421,
249310,
339425,
249313,
339429,
339435,
249329,
69114,
372229,
339464,
249355,
208399,
175637,
134689,
339504,
265779,
421442,
413251,
265796,
265806,
224854,
224858,
339553,
257636,
224871,
372328,
257647,
372338,
339572,
224885,
224888,
224891,
224895,
126597,
421509,
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,
397089,
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,
257881,
225113,
257884,
257887,
225120,
257891,
413539,
225128,
257897,
225138,
339827,
257909,
372598,
225142,
257914,
257917,
225150,
257922,
380803,
225156,
339845,
257927,
225166,
397201,
225171,
380823,
225176,
225183,
184245,
372698,
372704,
372707,
356336,
380919,
393215,
372739,
405534,
266295,
266298,
217158,
421961,
200786,
356440,
217180,
430181,
266351,
356467,
266365,
192640,
266375,
381069,
225425,
250003,
225430,
250008,
356507,
250012,
225439,
135328,
192674,
225442,
438434,
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,
225515,
225519,
381177,
397572,
389381,
356631,
356638,
356641,
356644,
356647,
266537,
389417,
356650,
356656,
332081,
307507,
340276,
356662,
397623,
332091,
225599,
332098,
201030,
348489,
332107,
151884,
430422,
348503,
332118,
332130,
250211,
340328,
250217,
348523,
348528,
332153,
356734,
389503,
332158,
438657,
250239,
332162,
348548,
356741,
332175,
160152,
373146,
373149,
70048,
356783,
266688,
324032,
201158,
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,
348745,
381513,
324171,
324174,
324177,
389724,
332381,
373344,
340580,
348777,
381546,
119432,
340628,
184983,
373399,
340639,
258723,
332455,
332460,
332464,
332473,
381626,
332484,
332487,
332494,
357070,
357074,
332512,
332521,
340724,
332534,
348926,
389927,
348979,
152371,
398141,
127815,
357202,
389971,
357208,
136024,
389979,
430940,
357212,
357215,
201580,
201583,
349041,
340850,
201589,
381815,
430967,
324473,
398202,
340859,
324476,
430973,
119675,
324479,
340863,
324482,
324485,
324488,
185226,
381834,
324493,
324496,
324499,
430996,
324502,
324511,
422817,
324514,
201638,
373672,
324525,
5040,
324534,
5047,
324539,
324542,
398280,
349129,
340940,
209874,
340958,
431073,
398307,
340964,
209896,
201712,
209904,
349173,
381947,
201724,
349181,
431100,
431107,
349203,
209944,
209948,
250915,
250917,
169002,
357419,
209966,
209969,
209973,
209976,
209980,
209988,
209991,
431180,
209996,
349268,
177238,
250968,
210011,
373853,
341094,
210026,
210028,
210032,
349296,
210037,
210042,
210045,
349309,
160896,
349313,
152704,
210053,
210056,
349320,
259217,
373905,
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,
357793,
333222,
210357,
259516,
415168,
366035,
415187,
366039,
415192,
415194,
415197,
415200,
333285,
415208,
366057,
366064,
415217,
415225,
415258,
415264,
366118,
415271,
382503,
349739,
144940,
415279,
415282,
349748,
415286,
210488,
415291,
415295,
333387,
333396,
374359,
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,
366384,
358192,
210740,
366388,
358201,
399166,
325441,
366403,
325447,
341831,
341835,
341839,
341844,
415574,
358235,
341852,
350046,
399200,
399208,
268144,
358256,
358260,
399222,
325494,
186233,
333690,
243584,
325505,
333699,
399244,
333709,
333725,
333737,
382891,
333767,
358348,
333777,
219094,
358372,
350190,
350194,
333819,
350204,
325633,
325637,
350214,
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,
350426,
334047,
350449,
375027,
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,
268669,
194942,
391564,
366991,
342431,
375209,
326059,
375220,
342453,
334263,
326087,
358857,
195041,
334306,
334312,
104940,
375279,
162289,
416255,
350724,
186898,
342546,
350740,
342551,
334359,
342555,
334364,
416294,
350762,
252463,
358962,
334386,
334397,
252483,
219719,
399957,
244309,
334425,
326240,
375401,
334466,
334469,
391813,
162446,
326291,
342680,
342685,
260767,
342711,
244410,
260798,
334530,
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,
375616,
326468,
244552,
342857,
326474,
326479,
326486,
416599,
342875,
244572,
326494,
326503,
433001,
326508,
400238,
326511,
211826,
211832,
392061,
351102,
252801,
260993,
400260,
211846,
342921,
342931,
252823,
400279,
392092,
400286,
359335,
211885,
400307,
351169,
359362,
351172,
170950,
187335,
326599,
359367,
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,
384152,
384158,
384161,
351399,
384169,
367795,
384182,
384189,
384192,
343232,
351424,
244934,
367817,
244938,
384202,
253132,
326858,
343246,
384209,
146644,
351450,
384225,
359650,
343272,
351467,
359660,
384247,
351480,
384250,
351483,
343307,
384270,
359695,
261391,
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,
138865,
155255,
155274,
409237,
368289,
245410,
425639,
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,
384831,
360262,
155463,
155477,
376665,
155484,
261982,
425823,
155488,
376672,
155492,
327532,
261997,
376686,
262000,
262003,
425846,
262006,
147319,
262009,
327542,
262012,
155517,
155523,
155526,
360327,
376715,
155532,
262028,
262031,
262034,
262037,
262040,
262043,
155550,
262046,
253854,
262049,
262052,
327590,
155560,
155563,
155566,
327613,
393152,
311244,
212945,
393170,
155604,
155620,
253924,
155622,
253927,
327655,
360432,
393204,
360439,
253944,
393209,
155647
] |
2102ab1318a25ce7314b96f0a119275aa63ce3e3 | df6ae45df1cede1b2dcfb6023ae8384cceadc064 | /week5/BoxOffice/BoxOffice/Detail/Comment/CommentTableViewCell.swift | 58d56a0a3a6fdbae6904887888f351afc6b9e44a | [] | no_license | younoah/BoostCourse | 493bc8b93f7e7042b78b869a4eb77591716446d4 | 8c2debb54d73f88e5f2972677752c1b894ac8e34 | refs/heads/master | 2023-01-03T07:42:48.517291 | 2020-10-26T14:44:42 | 2020-10-26T14:44:42 | 296,319,555 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 662 | swift | //
// CommentTableViewCell.swift
// BoxOffice
//
// Created by uno on 2020/10/17.
//
import UIKit
class CommentTableViewCell: UITableViewCell {
// MARK:- Properties
@IBOutlet weak var writerNameLabel: UILabel!
@IBOutlet weak var dateTimeLabel: UILabel!
@IBOutlet weak var contentLabel: UILabel!
@IBOutlet weak var movieGradeLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
| [
247662,
290007
] |
e35565800bfff5b6675ae9fdc89ed33068a9966b | 13977d55a58d78da2ac8c7249c69441711df8b5e | /NestedScrollViewExampleTests/NestedScrollViewExampleTests.swift | 39b8c35c159d892e4ab75b1c454fb64aff5d4a0a | [] | no_license | andreyyoshua/NestedDraggableBottomSheet | e3e07d2e84b8c84e37f3c3fccdfcb18213fbb231 | 0a92589415926fd2f97a2b0758fba8d3a037af1e | refs/heads/master | 2021-05-18T12:01:51.138402 | 2020-04-03T06:38:16 | 2020-04-03T06:38:16 | 251,236,073 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 968 | swift | //
// NestedScrollViewExampleTests.swift
// NestedScrollViewExampleTests
//
// Created by Andrey Yoshua Manik on 18/02/20.
// Copyright © 2020 Brid. All rights reserved.
//
import XCTest
@testable import NestedScrollViewExample
class NestedScrollViewExampleTests: XCTestCase {
override func 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.
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
| [
333828,
43014,
358410,
354316,
313357,
360462,
399373,
317467,
241692,
145435,
16419,
229413,
204840,
315432,
325674,
344107,
315434,
102445,
155694,
176175,
233517,
243759,
346162,
321583,
129076,
241716,
229430,
243767,
163896,
180280,
358456,
319542,
288828,
436285,
376894,
124984,
241720,
288833,
288834,
352315,
436292,
403525,
352326,
225351,
315465,
436301,
338001,
196691,
338003,
280661,
329814,
180311,
180312,
307289,
385116,
237663,
254048,
315487,
356447,
280675,
280677,
43110,
319591,
321637,
436329,
194666,
221290,
438377,
329829,
260207,
432240,
204916,
233589,
266357,
131191,
333940,
215164,
215166,
422019,
333955,
280712,
415881,
104587,
235662,
241808,
381073,
325776,
323729,
317587,
196760,
284826,
426138,
346271,
436383,
362659,
299174,
333991,
333996,
239793,
377009,
299187,
405687,
182456,
295098,
258239,
379071,
389313,
299203,
149703,
299209,
346314,
372941,
266449,
321745,
139479,
229597,
194782,
301279,
311519,
317664,
280802,
379106,
387296,
346346,
205035,
307435,
321772,
385262,
438511,
381172,
436470,
325694,
327929,
243962,
344313,
356602,
184575,
149760,
375039,
411906,
194820,
147717,
368905,
125199,
325905,
254226,
272658,
368916,
262421,
334103,
325912,
381208,
377114,
315673,
151839,
237856,
237857,
233762,
211235,
217380,
432421,
211238,
125217,
151847,
338218,
311597,
358703,
321840,
98610,
332083,
379186,
332085,
358709,
180535,
336183,
332089,
321860,
332101,
438596,
323913,
348492,
323916,
319821,
323920,
344401,
366930,
377169,
348500,
368981,
155990,
289110,
368984,
168281,
215385,
332123,
363163,
272729,
332127,
106847,
98657,
383332,
242023,
383336,
270701,
160110,
242033,
270706,
354676,
139640,
291192,
246137,
106874,
211326,
313727,
436608,
362881,
240002,
436611,
248194,
311685,
225670,
332167,
317831,
106888,
340357,
242058,
385417,
373134,
385422,
108944,
252308,
190871,
213403,
149916,
121245,
242078,
420253,
141728,
39324,
315810,
315811,
381347,
289189,
108972,
272813,
340398,
385454,
377264,
311727,
342450,
338356,
436661,
293303,
311738,
33211,
336317,
293310,
299456,
336320,
311745,
127427,
342466,
416197,
254406,
188871,
324039,
129483,
342476,
373197,
317901,
6606,
289232,
334290,
328152,
242139,
256477,
287198,
160225,
342498,
358882,
334309,
195045,
391655,
330218,
432618,
375276,
319981,
291311,
319987,
254456,
377338,
377343,
174593,
254465,
291333,
342536,
340490,
348682,
139792,
420369,
303636,
258581,
393751,
254488,
416286,
322078,
377376,
207393,
375333,
377386,
244269,
197167,
375343,
385588,
289332,
234036,
375351,
174648,
338489,
338490,
244281,
315960,
242237,
348732,
352829,
70209,
115270,
70215,
293448,
55881,
301638,
309830,
348742,
381517,
348749,
385615,
426576,
369235,
416341,
297560,
332378,
201308,
416351,
139872,
436832,
436834,
268899,
354911,
242277,
111208,
39530,
184940,
373358,
420463,
346737,
389745,
313971,
139892,
346740,
420471,
287352,
344696,
209530,
244347,
373375,
152195,
311941,
336518,
348806,
311945,
369289,
330379,
344715,
311949,
287374,
326287,
375440,
316049,
311954,
334481,
117396,
111253,
316053,
346772,
230040,
264856,
111258,
111259,
271000,
289434,
303771,
205471,
318106,
318107,
342682,
139939,
344738,
377500,
176808,
205487,
303793,
318130,
299699,
293556,
336564,
383667,
314040,
287417,
39614,
287422,
377539,
422596,
422599,
291530,
225995,
363211,
164560,
242386,
334547,
385747,
361176,
418520,
422617,
287452,
363230,
264928,
422626,
375526,
338662,
234217,
330474,
342762,
293612,
342763,
289518,
312047,
299759,
369385,
377489,
418546,
312052,
154359,
172792,
344827,
221948,
432893,
205568,
162561,
291585,
295682,
430849,
191235,
291592,
264968,
197386,
383754,
62220,
117517,
434957,
322319,
322316,
422673,
377497,
430865,
166676,
291604,
310036,
197399,
207640,
422680,
426774,
426775,
326429,
293664,
326433,
197411,
400166,
289576,
293672,
295724,
152365,
197422,
353070,
164656,
295729,
422703,
191283,
422709,
152374,
197431,
273207,
375609,
355130,
160571,
289598,
160575,
336702,
430910,
342847,
355139,
160580,
252741,
355146,
381773,
201551,
293711,
355154,
353109,
377686,
244568,
230234,
189275,
244570,
322395,
355165,
435039,
295776,
242529,
349026,
357218,
303972,
385893,
351077,
342887,
326505,
355178,
308076,
242541,
330609,
246643,
207732,
295798,
246648,
361337,
269178,
177019,
185211,
308092,
398206,
400252,
291712,
158593,
254850,
359298,
260996,
359299,
113542,
369538,
381829,
316298,
392074,
349067,
426895,
295824,
224145,
349072,
355217,
256922,
289690,
318364,
390045,
310176,
185250,
310178,
420773,
185254,
289703,
293800,
256935,
353195,
140204,
236461,
363438,
347055,
377772,
252847,
304051,
326581,
373687,
326587,
230332,
377790,
289727,
273344,
330689,
353215,
363458,
379844,
213957,
19399,
326601,
345033,
373706,
316364,
330708,
359381,
386006,
418776,
433115,
248796,
343005,
248797,
50143,
347103,
64485,
52200,
123881,
326635,
187374,
383983,
383982,
347123,
240630,
271350,
201720,
127992,
295927,
349175,
328700,
318461,
293886,
257024,
328706,
330754,
320516,
293893,
295942,
357379,
386056,
410627,
353290,
330763,
377869,
433165,
320527,
384016,
238610,
308243,
330772,
418837,
140310,
433174,
201755,
252958,
369701,
357414,
248872,
345132,
238639,
300084,
312373,
203830,
359478,
324666,
238651,
324667,
308287,
377926,
361543,
218186,
314448,
341073,
205906,
339030,
439384,
304222,
392290,
314467,
253029,
257125,
300135,
316520,
273515,
173166,
357486,
144496,
351344,
404593,
377972,
285814,
291959,
300150,
300151,
363641,
160891,
363644,
300158,
377983,
392318,
150657,
248961,
384131,
349316,
402565,
349318,
330888,
302216,
386189,
373903,
169104,
177296,
326804,
363669,
238743,
119962,
300187,
300188,
339100,
351390,
199839,
380061,
429214,
265379,
343203,
300201,
249002,
253099,
253100,
238765,
3246,
300202,
306346,
238769,
318639,
402613,
367799,
421048,
373945,
113850,
294074,
302274,
367810,
259268,
265412,
343234,
353479,
353481,
402634,
353482,
283852,
259280,
290000,
316627,
333011,
189653,
419029,
148696,
296153,
357595,
304351,
195808,
298208,
310497,
359647,
298212,
298213,
222440,
330984,
328940,
298221,
298228,
302325,
234742,
386294,
128251,
386301,
261377,
320770,
386306,
437505,
322824,
439562,
292107,
328971,
242954,
414990,
353551,
251153,
177428,
349462,
257305,
245019,
320796,
126237,
222494,
253216,
339234,
369956,
109861,
372009,
412971,
130348,
353584,
261425,
351537,
382258,
345396,
300343,
386359,
116026,
378172,
286013,
306494,
382269,
216386,
312648,
337225,
304456,
230729,
146762,
224586,
177484,
294218,
259406,
234831,
238927,
294219,
331090,
353616,
406861,
318805,
314710,
372054,
425304,
159066,
374109,
316765,
314720,
378209,
163175,
333160,
386412,
380271,
327024,
312689,
296307,
116084,
208244,
249204,
316787,
314739,
314741,
290173,
306559,
314751,
318848,
337281,
148867,
357762,
253317,
298374,
314758,
314760,
142729,
296329,
368011,
384393,
388487,
314766,
296335,
318864,
112017,
234898,
9619,
259475,
275859,
318868,
370071,
357786,
290207,
314783,
251298,
310692,
314789,
333220,
314791,
396711,
245161,
396712,
374191,
286129,
380337,
173491,
286132,
150965,
304564,
353719,
380338,
228795,
425405,
302531,
380357,
339398,
361927,
300489,
425418,
306639,
413137,
23092,
210390,
210391,
210393,
210392,
286172,
144867,
271843,
429542,
245223,
361963,
54765,
296433,
251378,
308723,
321009,
300536,
286202,
359930,
302590,
372227,
323080,
329225,
253451,
253452,
296461,
359950,
259599,
304656,
329232,
323089,
146964,
308756,
370197,
175639,
253463,
374296,
388632,
374299,
308764,
396827,
134686,
349726,
431649,
187938,
286244,
245287,
402985,
394794,
245292,
169518,
347694,
431663,
288309,
312889,
194110,
425535,
349763,
196164,
265798,
288327,
218696,
292425,
128587,
265804,
333388,
333393,
396882,
128599,
179801,
44635,
239198,
343647,
333408,
396895,
99938,
300644,
323172,
374372,
310889,
415338,
243307,
312940,
54893,
204397,
138863,
188016,
222832,
325231,
224883,
314998,
333430,
247416,
323196,
325245,
337534,
337535,
339584,
339585,
263809,
294529,
194180,
175741,
224901,
288392,
229001,
415375,
188048,
239250,
419478,
345752,
425626,
255649,
302754,
153251,
298661,
40614,
300714,
210603,
321199,
364207,
224946,
337591,
384695,
110268,
415420,
224958,
327358,
333503,
323264,
274115,
259781,
333509,
319177,
306890,
403148,
212685,
333517,
9936,
9937,
241361,
302802,
333520,
272085,
345814,
370388,
384720,
241365,
181975,
345821,
321247,
298720,
321249,
325346,
153319,
325352,
345833,
345834,
212716,
212717,
294638,
360177,
67315,
173814,
325371,
288512,
319233,
339715,
288516,
360195,
323331,
339720,
243472,
372496,
323346,
321302,
345879,
366360,
398869,
325404,
286494,
321310,
255776,
339745,
341796,
257830,
247590,
421672,
333610,
362283,
378668,
399147,
431916,
300848,
409394,
296755,
319288,
259899,
319292,
360252,
325439,
345919,
436031,
403267,
153415,
360264,
345929,
339783,
341836,
415567,
325457,
337745,
317269,
18262,
216918,
241495,
341847,
362327,
346779,
350044,
128862,
245599,
345951,
362337,
376669,
345955,
425825,
296806,
276327,
292712,
425833,
423789,
214895,
313199,
362352,
325492,
276341,
417654,
341879,
241528,
317304,
333688,
112509,
124798,
55167,
182144,
325503,
305026,
339841,
188292,
333701,
327557,
243591,
315273,
315274,
325515,
325518,
372626,
380821,
329622,
294807,
337815,
239514,
333722,
376732,
118685,
298909,
311199,
319392,
350109,
253856,
292771,
436131,
354212,
294823,
415655,
436137,
327596,
362417,
323507,
243637,
290745,
294843,
188348,
362431,
237504,
294850,
274371,
384964,
214984,
151497,
321480,
362443,
344013,
212942,
301008,
153554,
24532,
212951,
372701,
329695,
436191,
360417,
292836,
292837,
298980,
313319,
317415,
337895,
380908,
436205,
362480,
311281,
311282,
325619,
432116,
333817,
292858,
415741,
352917
] |
98449d491b1d6b39c160ff61fa56fd488f7b8429 | bb29d08d9b4f0f667b3e03591393fd21551da305 | /MCIndex/WarningMessage.swift | 4ab4f596fd23198ce07aca118dbf940772b96b29 | [] | no_license | simongardener/MCIndex | ddb52fdfbd18fe6a1a7ab8484d0f28c14d392f01 | 90a2513fe42d649adaa57247ee5c25f3a3f7eb44 | refs/heads/master | 2020-05-17T01:00:44.340327 | 2019-11-06T18:22:00 | 2019-11-06T18:22:00 | 183,414,263 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,268 | swift | //
// WarningMessage.swift
// Dredd Mega Index
//
// Created by Simon Gardener on 16/03/2019.
// Copyright © 2019 Simon Gardener. All rights reserved.
//
import Foundation
import UIKit
struct Warning {
static func message()->UIAlertController{
let warningMessage = """
The 'from' and 'to' fields need to be whole numbers in range 1 to 90.
Both need to have a number.
The 'to' field must be greater or equal to the 'from' field.
"""
let alert = UIAlertController(title: "Bad numbers", message: warningMessage, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
return alert
}
static func confirm(message: String, completion : ())-> UIAlertController {
let alertController = UIAlertController(title: "Confirm Changes", message: message, preferredStyle: .alert )
let continueAction = UIAlertAction(title: "Go ahead", style: .default, handler:{ _ in
completion
})
let cancelAction = UIAlertAction(title: "cancel", style: .cancel, handler: nil)
alertController.addAction(continueAction)
alertController.addAction(cancelAction)
return alertController
}
}
| [
-1
] |
498f009c3a84963748c3e5bb3a4aba756ace29be | 04a961cecf671dc51dd737b453a26f94ef5f9739 | /random/random/randomApp.swift | 0d15473f258d11509cc248395d2a8937a6cf2835 | [] | no_license | 00657106-ios/bonus_random_APP | 9d0bcef98fe5109f54b919e911b6b6cd303499cd | 988080835abb447efc023827a5476942b56c7baf | refs/heads/main | 2023-02-13T01:53:31.356462 | 2021-01-15T08:57:47 | 2021-01-15T08:57:47 | 329,858,691 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 216 | swift | //
// randomApp.swift
// random
//
// Created by User13 on 2021/1/15.
//
import SwiftUI
@main
struct randomApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
| [
156546,
359813,
156422,
360969,
380940,
383634,
387348,
156568,
383640,
268444,
419103,
403488,
386471,
156463,
352820,
360249,
352323,
417998,
259284,
257621,
197462,
348757,
378196,
370524,
156514,
156387,
383592,
352367,
359791,
339443,
359801
] |
59020308d1c871d751047ebb46e2582fa8f02437 | 7f346ee850e7bb352b0219abf3f9a99191565d1e | /swift/acmicpc/acmicpc11021/acmicpc11021/main.swift | 1989cbbb233a6d29827ea79fd345b0b9c3619d3e | [] | no_license | hyhwa414/Algorithm | 86809201e53238d92b5c5004d5f0429aaa2ffc61 | e46632723c67383ca652a4f5132144801c6930a8 | refs/heads/master | 2022-05-02T03:21:14.193161 | 2022-04-29T15:06:37 | 2022-04-29T15:06:37 | 210,100,761 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 295 | swift | //
// main.swift
// acmicpc11021
//
// Created by 정현화 on 2022/04/03.
//
import Foundation
let T = Int(readLine()!)!
for i in 1...T {
let input = readLine()!.components(separatedBy: " ")
let A = Int(input[0])!
let B = Int(input[1])!
print("Case #\(i): \(A+B)")
}
| [
-1
] |
aa77be04d1a2d0c42b1c89945e535300da14d765 | ab1d7c009bd12ff4e2f2e323c43f8c3e40312a97 | /Virtual Tourist/MapViewController.swift | fcd69a513ca15ea528cd12808df37aad6d8cd53a | [] | no_license | adusumillipranavi/VirtualTourist | eb4ef28f2dc5123826dbceb41319301cf5cd1027 | dcc8c68b40e180a5d68d49366216389b02cdb3bf | refs/heads/master | 2021-01-11T01:59:46.737344 | 2016-10-13T16:11:13 | 2016-10-13T16:11:13 | 70,824,895 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 9,316 | swift | //
// ViewController.swift
// Virtual Tourist
//
// Created by Pranavi Adusumilli on 10/11/16.
// Copyright © 2016 MeaMobile. All rights reserved.
//
import UIKit
import MapKit
import CoreData
class MapViewController: UIViewController {
var stack: CoreDataStack!
var editLabel: UILabel!
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// set gesture recognizer
let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressDetected(_:)))
mapView.addGestureRecognizer(longPressGestureRecognizer)
// position map around last known region
loadMostRecentMapRegion()
// get core data stack
let delegate = UIApplication.shared.delegate as! AppDelegate
stack = delegate.stack
// set edit button
navigationItem.rightBarButtonItem = editButtonItem
// create edit label for slide-out
editLabel = UILabel(frame: editLabelFrameForSize(view.frame.size))
editLabel.backgroundColor = UIColor.white
editLabel.textColor = UIColor.red
editLabel.textAlignment = NSTextAlignment.center
editLabel.text = "Tap Pins to Delete"
editLabel.font = UIFont.boldSystemFont(ofSize: 16)
self.view.addSubview(editLabel)
// load annotations
loadAnnotations()
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { context -> Void in
self.editLabel.frame = self.editLabelFrameForSize(size)
self.mapView.frame = self.mapFrameForSize(size)
}, completion: nil)
}
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
let yOffset: CGFloat = 70 * (editing ? -1 : 1)
if (animated) {
UIView.animate(withDuration: 0.15, animations: {
self.mapView.frame = self.mapView.frame.offsetBy(dx: 0, dy: yOffset)
self.editLabel.frame = self.editLabel.frame.offsetBy(dx: 0, dy: yOffset)
})
} else {
mapView.frame = mapView.frame.offsetBy(dx: 0, dy: yOffset)
editLabel.frame = editLabel.frame.offsetBy(dx: 0, dy: yOffset)
}
}
func editLabelFrameForSize(_ size: CGSize) -> CGRect {
let editingShift: CGFloat = 70 * (isEditing ? -1 : 0)
let labelRect = CGRect(x: 0, y: size.height + editingShift, width: size.width, height: 70)
return labelRect
}
func mapFrameForSize(_ size: CGSize) -> CGRect {
let editingShift: CGFloat = 70 * (isEditing ? -1 : 0)
let labelRect = CGRect(x: 0, y: editingShift, width: size.width, height: size.height)
return labelRect
}
func longPressDetected(_ longPress: UIGestureRecognizer!) {
if longPress.state == .began && !isEditing {
// get touch coordinate
let touchPoint = longPress.location(in: self.mapView)
let touchMapCoordinate = mapView.convert(touchPoint, toCoordinateFrom: mapView)
addPin(touchMapCoordinate)
}
}
func addPin(_ location: CLLocationCoordinate2D) {
let pin = Pin(latitude: location.latitude, longitude: location.longitude, context: stack.mainContext)
let pinAnnotation = PinAnnotation(objectID: pin.objectID, title: nil, subtitle: nil, coordinate: location)
mapView.addAnnotation(pinAnnotation)
}
func loadMostRecentMapRegion() {
let defaults = UserDefaults.standard
if let mapLat = defaults.object(forKey: AppConstants.Defaults.mapLatitude) as? CLLocationDegrees,
let mapLon = defaults.object(forKey: AppConstants.Defaults.mapLongitude) as? CLLocationDegrees,
let mapLatDelta = defaults.object(forKey: AppConstants.Defaults.mapLatitudeDelta) as? CLLocationDegrees,
let mapLonDelta = defaults.object(forKey: AppConstants.Defaults.mapLongitudeDelta) as? CLLocationDegrees {
mapView.region.center = CLLocationCoordinate2D(latitude: mapLat, longitude: mapLon)
mapView.region.span = MKCoordinateSpanMake(mapLatDelta, mapLonDelta)
}
}
func saveMostRecentMapRegion() {
let defaults = UserDefaults.standard
defaults.set(mapView.region.center.latitude, forKey: AppConstants.Defaults.mapLatitude)
defaults.set(mapView.region.center.longitude, forKey: AppConstants.Defaults.mapLongitude)
defaults.set(mapView.region.span.latitudeDelta, forKey: AppConstants.Defaults.mapLatitudeDelta)
defaults.set(mapView.region.span.longitudeDelta, forKey: AppConstants.Defaults.mapLongitudeDelta)
}
// MARK: Add Annotations
func loadAnnotations() {
// create fetch request
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Pin")
do {
print(stack)
print(stack.mainContext)
if let pins = try? stack.mainContext.fetch(fetchRequest) as! [Pin] {
var pinAnnotations = [PinAnnotation]()
// create annotations for pins
for pin in pins {
let latitude = CLLocationDegrees(pin.latitude!)
let longitude = CLLocationDegrees(pin.longitude!)
let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
pinAnnotations.append(PinAnnotation(objectID: pin.objectID, title: nil, subtitle: nil, coordinate: coordinate))
}
// add annotations to the map
mapView.addAnnotations(pinAnnotations)
}
}
}
}
extension MapViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
saveMostRecentMapRegion()
}
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
for annotationView in views {
// don't pin drop if annotation is user location
if annotationView.isKind(of: MKUserLocation.self) {
continue
}
// check if current annotation is inside visible map rect, else go to next one
let point = MKMapPointForCoordinate(annotationView.annotation!.coordinate)
if !MKMapRectContainsPoint(self.mapView.visibleMapRect, point) {
continue
}
let destinedFrame = annotationView.frame
// move annotation out of view
annotationView.frame = CGRect(x: annotationView.frame.origin.x, y: annotationView.frame.origin.y - self.view.frame.size.height, width: annotationView.frame.size.width, height: annotationView.frame.size.height)
// animate drop
UIView.animate(withDuration: 0.5, delay: 0.04 * Double(views.index(of: annotationView)!), options: .curveLinear, animations: {
annotationView.frame = destinedFrame
}, completion: nil)
}
}
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
// deselect the pin annotation
mapView.deselectAnnotation(view.annotation, animated: false)
// get annotation and pin
var pin: Pin!
do {
let pinAnnotation = view.annotation as! PinAnnotation
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Pin")
let predicate = NSPredicate(format: "latitude == %@ AND longitude == %@", argumentArray: [pinAnnotation.coordinate.latitude, pinAnnotation.coordinate.longitude])
fetchRequest.predicate = predicate
let pins = try stack.mainContext.fetch(fetchRequest) as? [Pin]
pin = pins![0]
} catch let error as NSError {
print("failed to get pin by object id")
print(error.localizedDescription)
return
}
// if in edit mode, then delete pin
guard !self.isEditing else {
mapView.removeAnnotation(view.annotation!)
stack.mainContext.delete(pin)
stack.save()
return
}
// otherwise, create/show photo album view controller
let photoAlbumViewController = storyboard!.instantiateViewController(withIdentifier: "PhotoAlbumViewController") as! PhotoAlbumViewController
photoAlbumViewController.mapView = mapView
photoAlbumViewController.pin = pin
print(pin!.photos)
if let photos = pin.photos?.allObjects as? [Photo] {
let sortedPhotos = photos.sorted(by: { ($0 as AnyObject).path! < ($1 as AnyObject).path! })
photoAlbumViewController.photos = sortedPhotos
}
navigationController!.pushViewController(photoAlbumViewController, animated: true)
}
}
| [
-1
] |
dda2cc422221438760656f4733daac212faf1eb3 | 769511a8e7cb72a5d92627c7fe0d8aa56c358aa5 | /Creative Softwares Task/Cell/OpenTaskTableViewCell.swift | 042a475a8ec2d12d59d43405447f977e6c03c607 | [] | no_license | luqmang316/Creative-Softwares-Task | ec370e2536a7606905a51315a68a8c0f58cb1d5d | f4fa729e7b15a365c9af4b7704eea875c67bdf5f | refs/heads/main | 2023-01-07T09:15:46.127691 | 2020-10-30T12:20:17 | 2020-10-30T12:20:17 | 308,622,197 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,118 | swift | //
// OpenTaskTableViewCell.swift
// Creative Softwares Task
//
// Created by Muhammad Luqman on 10/29/20.
//
import UIKit
import CoreData
protocol reloadtableView: AnyObject {
func reload(cell: UITableViewCell)
}
class OpenTaskTableViewCell: UITableViewCell {
weak var delegate:reloadtableView?
//MARK:-OutLets
@IBOutlet weak var hieght: NSLayoutConstraint!
@IBOutlet weak var checkBox: UIButton!
@IBOutlet weak var btnLow: UIButton!
@IBOutlet weak var btnMedium: UIButton!
@IBOutlet weak var btnHeight: UIButton!
@IBOutlet weak var btnCancle: UIButton!
@IBOutlet weak var btnCalender: UIButton!
@IBOutlet weak var topView: UIView!
@IBOutlet weak var bottomView: UIView!
@IBOutlet weak var lblName: UILabel!
@IBOutlet weak var lblDateTimeOpen: UILabel!
@IBOutlet weak var lblDateTimeClose: UILabel!
var task = NSManagedObject()
//MARK:-Button Action
@IBAction func btnCancle(_ sender: Any) {
CoreDataManager.sharedManager.update(isCompleted: true, task: self.task as! Task)
delegate?.reload(cell: self)
}
@IBAction func btnCalender(_ sender: Any) {
}
@IBAction func btnLow(_ sender: Any) {
self.task.setValue(Priority.Low.rawValue, forKey: TaskKyes.priority.rawValue)
delegate?.reload(cell: self)
}
@IBAction func btnMedium(_ sender: Any) {
self.task.setValue(Priority.Medium.rawValue, forKey: TaskKyes.priority.rawValue)
delegate?.reload(cell: self)
}
@IBAction func btnHeight(_ sender: Any) {
self.task.setValue(Priority.Height.rawValue, forKey: TaskKyes.priority.rawValue)
delegate?.reload(cell: self)
}
@IBAction public func buttonTapped(_ sender: Any) {
// Update checkbox image
self.checkBox.isSelected = !self.checkBox.isSelected
// hide and unhide bottom View
self.bottomView.isHidden = self.checkBox.isSelected
self.lblDateTimeClose.isHidden = !self.checkBox.isSelected
// update constraint of cell
self.hieght.constant = self.hieght.constant == 50 ? 122:50
self.layoutIfNeeded()
// Post notification to update tableview
NotificationCenter.default.post(name: Notification.Name(NotificationCenterKey.updateTableView.rawValue), object: nil)
}
//MARK:-Initialization
override func awakeFromNib() {
super.awakeFromNib()
self.lblDateTimeClose.isHidden = true
self.buttonCornerRadius(button: self.btnLow)
self.buttonCornerRadius(button: self.btnMedium)
self.buttonCornerRadius(button: self.btnHeight)
// Initialization code
}
private func buttonCornerRadius(button: UIButton){
button.layer.cornerRadius = 15
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
| [
-1
] |
25a769084cda87893f416794c73c109d92916a60 | f59ed09aedaf813355a36b6c60cb8500af764746 | /Github/Classes/OpenAPIs/APIs/LicensesAPI.swift | 1687ccf27db8958f5b449aad87b4908b13875997 | [] | no_license | gilserrap/github-api-client | 173d2010ac1fa0f9cd83c1a08cda1b4ef40d6217 | e75124ef325a6c979e4757ee92a7ccad1867ba32 | refs/heads/main | 2023-02-23T04:47:37.393616 | 2021-01-30T14:58:33 | 2021-01-30T14:58:33 | 334,423,480 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 7,026 | swift | //
// LicensesAPI.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//
import Foundation
open class LicensesAPI {
/**
Get a license
- parameter license: (path)
- parameter apiResponseQueue: The queue on which api response is dispatched.
- parameter completion: completion handler to receive the data and the error objects
*/
open class func licensesGet(license: String, apiResponseQueue: DispatchQueue = GithubAPI.apiResponseQueue, completion: @escaping ((_ data: License?,_ error: Error?) -> Void)) {
licensesGetWithRequestBuilder(license: license).execute(apiResponseQueue) { result -> Void in
switch result {
case let .success(response):
completion(response.body, nil)
case let .failure(error):
completion(nil, error)
}
}
}
/**
Get a license
- GET /licenses/{license}
- externalDocs: class ExternalDocumentation {
description: API method documentation
url: https://docs.github.com/[email protected]/v3/licenses/#get-a-license
}
- parameter license: (path)
- returns: RequestBuilder<License>
*/
open class func licensesGetWithRequestBuilder(license: String) -> RequestBuilder<License> {
var path = "/licenses/{license}"
let licensePreEscape = "\(APIHelper.mapValueToPathItem(license))"
let licensePostEscape = licensePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{license}", with: licensePostEscape, options: .literal, range: nil)
let URLString = GithubAPI.basePath + path
let parameters: [String:Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<License>.Type = GithubAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
/**
Get all commonly used licenses
- parameter featured: (query) (optional)
- parameter perPage: (query) Results per page (max 100) (optional, default to 30)
- parameter apiResponseQueue: The queue on which api response is dispatched.
- parameter completion: completion handler to receive the data and the error objects
*/
open class func licensesGetAllCommonlyUsed(featured: Bool? = nil, perPage: Int? = nil, apiResponseQueue: DispatchQueue = GithubAPI.apiResponseQueue, completion: @escaping ((_ data: [LicenseSimple]?,_ error: Error?) -> Void)) {
licensesGetAllCommonlyUsedWithRequestBuilder(featured: featured, perPage: perPage).execute(apiResponseQueue) { result -> Void in
switch result {
case let .success(response):
completion(response.body, nil)
case let .failure(error):
completion(nil, error)
}
}
}
/**
Get all commonly used licenses
- GET /licenses
- externalDocs: class ExternalDocumentation {
description: API method documentation
url: https://docs.github.com/[email protected]/v3/licenses/#get-all-commonly-used-licenses
}
- parameter featured: (query) (optional)
- parameter perPage: (query) Results per page (max 100) (optional, default to 30)
- returns: RequestBuilder<[LicenseSimple]>
*/
open class func licensesGetAllCommonlyUsedWithRequestBuilder(featured: Bool? = nil, perPage: Int? = nil) -> RequestBuilder<[LicenseSimple]> {
let path = "/licenses"
let URLString = GithubAPI.basePath + path
let parameters: [String:Any]? = nil
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"featured": featured?.encodeToJSON(),
"per_page": perPage?.encodeToJSON()
])
let requestBuilder: RequestBuilder<[LicenseSimple]>.Type = GithubAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
/**
Get the license for a repository
- parameter owner: (path)
- parameter repo: (path)
- parameter apiResponseQueue: The queue on which api response is dispatched.
- parameter completion: completion handler to receive the data and the error objects
*/
open class func licensesGetForRepo(owner: String, repo: String, apiResponseQueue: DispatchQueue = GithubAPI.apiResponseQueue, completion: @escaping ((_ data: LicenseContent?,_ error: Error?) -> Void)) {
licensesGetForRepoWithRequestBuilder(owner: owner, repo: repo).execute(apiResponseQueue) { result -> Void in
switch result {
case let .success(response):
completion(response.body, nil)
case let .failure(error):
completion(nil, error)
}
}
}
/**
Get the license for a repository
- GET /repos/{owner}/{repo}/license
- This method returns the contents of the repository's license file, if one is detected. Similar to [Get repository content](https://docs.github.com/[email protected]/rest/reference/repos#get-repository-content), this method also supports [custom media types](https://docs.github.com/[email protected]/rest/overview/media-types) for retrieving the raw license content or rendered license HTML.
- externalDocs: class ExternalDocumentation {
description: API method documentation
url: https://docs.github.com/[email protected]/v3/licenses/#get-the-license-for-a-repository
}
- parameter owner: (path)
- parameter repo: (path)
- returns: RequestBuilder<LicenseContent>
*/
open class func licensesGetForRepoWithRequestBuilder(owner: String, repo: String) -> RequestBuilder<LicenseContent> {
var path = "/repos/{owner}/{repo}/license"
let ownerPreEscape = "\(APIHelper.mapValueToPathItem(owner))"
let ownerPostEscape = ownerPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{owner}", with: ownerPostEscape, options: .literal, range: nil)
let repoPreEscape = "\(APIHelper.mapValueToPathItem(repo))"
let repoPostEscape = repoPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{repo}", with: repoPostEscape, options: .literal, range: nil)
let URLString = GithubAPI.basePath + path
let parameters: [String:Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<LicenseContent>.Type = GithubAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
}
| [
-1
] |
7437b27e6490775055d2b61ed1c40f9005a053c5 | 2165f125ab66925ce8930dbba8785eaa690abd93 | /Holidays/AppDelegate.swift | c3df04f045b73741b698831af57452fb08bf87fc | [] | no_license | trsneed/Holidays | b55bed8d7691f948941f9a1904c095a07e8959ae | 44f747852bf01e3aa895e97319b20f6c44750117 | refs/heads/master | 2016-09-15T22:11:50.350672 | 2015-09-03T02:18:16 | 2015-09-03T02:18:16 | 41,608,506 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,748 | swift | //
// AppDelegate.swift
// Holidays
//
// Created by Tim Sneed on 8/28/15.
// Copyright (c) 2015 Sneed. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var repository:Repository?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let dataAccess = DataAccess()
repository = Repository()
// application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
return true
}
// func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// let countryCode = NSUserDefaults.standardUserDefaults().objectForKey(StorageKeys.selectedCounty.rawValue) as? String
// if let countryCode = countryCode{
// Repository().checkIfHolidayAndRetrieveHoliday(countryCode, completionHandler: { (result) -> Void in
// completionHandler(result)
// })
// } else {
// completionHandler(UIBackgroundFetchResult.NoData)
// }
// }
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:.
}
}
| [
234695
] |
75358ed7d9d75de0a446af5e76ca3f458938e841 | 624b66015d176ba7544f2b5aceaccdf340c50050 | /Travel/Discover/User/UsersDetailsView.swift | 20595d0f77c97f48426a2cb1ecacd41d69e5088f | [] | no_license | RomanAVolodin/TravelGuideSwiftUI | b0cb0a9181d39a80a6ab2912e6bb335595c754a5 | 2646de180f694e177b55d9dc346fbeaa0e25ceb3 | refs/heads/main | 2023-02-01T11:37:20.593656 | 2020-12-07T11:17:03 | 2020-12-07T11:17:03 | 310,937,954 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,618 | swift | //
// UsersDetailsView.swift
// Travel
//
// Created by Roman Vol on 07.12.2020.
//
import SwiftUI
import KingfisherSwiftUI
struct UserDetails: Decodable {
let username, firstName, lastName, profileImage: String
let followers, following: Int
let posts: [Post]
}
struct Post: Decodable, Hashable {
let title, imageUrl, views: String
let hashtags: [String]
}
class UserDetailsViewModel: ObservableObject {
@Published var isLoading = true
@Published var details: UserDetails?
@Published var errorMessage = ""
init(userId: Int) {
guard let url = URL(string: "https://travel.letsbuildthatapp.com/travel_discovery/user?id=\(userId)") else {return}
URLSession.shared.dataTask(with: url) { (data, resp, err) in
DispatchQueue.main.async {
if let statusCode = (resp as? HTTPURLResponse)?.statusCode, statusCode >= 400 {
self.isLoading = false
self.errorMessage = "Bad Status: \(statusCode)"
return
}
guard let data = data else {return}
do {
self.details = try JSONDecoder().decode(UserDetails.self, from: data)
} catch {
print("Failed to decode JSON", error)
self.errorMessage = error.localizedDescription
}
self.isLoading = false
}
}.resume()
}
}
struct UsersDetailsView: View {
@ObservedObject var vm: UserDetailsViewModel
init(user: User) {
self.user = user
self.vm = .init(userId: user.id)
}
let user: User
var body: some View {
ScrollView {
VStack(spacing: 12) {
if let details = vm.details {
UserDetailsHeaderView(userDetails: details)
}
ForEach(vm.details?.posts ?? [], id: \.self) { post in
VStack(alignment: .leading) {
KFImage(URL(string: post.imageUrl))
.resizable()
.scaledToFill()
.frame(height: 200)
.clipped()
HStack {
KFImage(URL(string: vm.details?.profileImage ?? ""))
.resizable()
.scaledToFit()
.frame(height: 34)
.clipShape(Circle())
VStack(alignment: .leading) {
Text(post.title)
.font(.system(size: 13, weight: .semibold))
Text(post.views)
.font(.system(size: 12, weight: .regular))
.foregroundColor(.gray)
}
}.padding(.horizontal, 8)
HStack {
ForEach(post.hashtags, id: \.self) { hashtag in
Text(hashtag)
.foregroundColor(Color(#colorLiteral(red: 0.362208277, green: 0.6089759469, blue: 0.8800933957, alpha: 1)))
.font(.system(size: 14, weight: .semibold))
.padding(.horizontal, 12)
.padding(.vertical, 4)
.background(Color(#colorLiteral(red: 0.9028977752, green: 0.9474882483, blue: 0.990914166, alpha: 1)))
.cornerRadius(20)
}
}.padding(.bottom)
.padding(.horizontal, 8)
}
.background(Color(white: 1))
.cornerRadius(12)
.shadow(color: .init(white: 0.8), radius: 5, x: 0, y: 4)
}
}.padding(.horizontal)
.navigationBarTitle("\(vm.details?.firstName ?? "") \(vm.details?.lastName ?? "")", displayMode: .inline)
}
}
}
struct UsersDetailsView_Previews: PreviewProvider {
static var previews: some View {
DiscoverView()
NavigationView {
UsersDetailsView(user: .init(id: 0, name: "Amy Adams", imageName: "amy"))
}
}
}
| [
-1
] |
b8753ea6b214eda4b86c73dfd9c3806524da6f53 | 44435976885ce54f174997e256e151f2014bd3f3 | /PanelChat/NewsFeedDetailsController.swift | 9577fbf2cfbad42ab9c80ea6cd70089ab8e70ea9 | [] | no_license | johnstrumbos/PanelChat | 86df0bb9705a54e6277a0679ccc56a8c892c6b80 | a4bf2be8f51b895bad0cb8c1ed0cc7c7f0774bf0 | refs/heads/master | 2016-08-03T15:54:05.925991 | 2015-03-01T16:07:25 | 2015-03-01T16:07:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 779 | swift | //
// NewsFeedDetailsController.swift
// PanelChat
//
// Created by Dashon Howard on 2/28/15.
// Copyright (c) 2015 PanelChat. All rights reserved.
//
import Foundation
import UIKit
class NewsFeedDetailViewController : UIViewController{
@IBOutlet weak var UserImage: UIImageView!
@IBOutlet weak var UserName: UILabel!
@IBOutlet weak var FollowBtn: UIButton!
@IBOutlet weak var HashTags: UILabel!
@IBOutlet weak var Comment: UILabel!
@IBOutlet weak var StoryView: UIView!
var panel:Panel?
override func viewDidLoad() {
if let comment = panel!.Title{
self.Comment.text = comment
}
if let hash = panel!.HashTag{
self.Comment.text = hash
}
}
} | [
-1
] |
8a8b3bc0dad484c7d36c21fea14ea9cc6999295b | 3a487236df02027838ca8f69f87ccf877705935e | /Tests/NSAttributedStringDebugTests.swift | cce44ba9e8b50c65c4f80e530826b55747e849de | [
"MIT"
] | permissive | Rightpoint/BonMot | bca84983d03fb658951a68fbbbafbf344a771e70 | 001139aad601ed8009b49a0e868e21df3dea979c | refs/heads/master | 2023-08-31T06:51:57.772506 | 2023-06-12T21:29:04 | 2023-06-12T21:29:04 | 35,981,629 | 1,247 | 83 | MIT | 2023-08-29T13:53:20 | 2015-05-21T00:32:35 | Swift | UTF-8 | Swift | false | false | 4,728 | swift | //
// NSAttributedStringDebugTests.swift
// BonMot
//
// Created by Brian King on 9/1/16.
// Copyright © 2016 Rightpoint. All rights reserved.
//
@testable import BonMot
import XCTest
class NSAttributedStringDebugTests: XCTestCase {
func robotImage() throws -> BONImage {
#if os(OSX)
let imageForTest = testBundle.image(forResource: "robot")
#else
let imageForTest = UIImage(named: "robot", in: testBundle, compatibleWith: nil)
#endif
return try XCTUnwrap(imageForTest)
}
func testSpecialFromUnicodeScalar() {
let enDash = Special(rawValue: "\u{2013}")
XCTAssertEqual(enDash, Special.enDash)
}
func testDebugRepresentationReplacements() {
let testCases: [(String, String)] = [
("BonMot", "BonMot"),
("Bon\tMot", "Bon<BON:tab/>Mot"),
("Bon\nMot", "Bon<BON:lineFeed/>Mot"),
("it ignores spaces", "it ignores spaces"),
("Pilcrow¶", "Pilcrow¶"),
("Floppy💾Disk", "Floppy💾Disk"),
("\u{000A1338}A\u{000A1339}", "<BON:unicode value='A1338'/>A<BON:unicode value='A1339'/>"),
("neonسلام🚲\u{000A1338}₫\u{000A1339}", "neonسلام🚲<BON:unicode value='A1338'/>₫<BON:unicode value='A1339'/>"),
("\n →\t", "<BON:lineFeed/> →<BON:tab/>"),
("foo\u{00a0}bar", "foo<BON:noBreakSpace/>bar"),
]
for (index, testCase) in testCases.enumerated() {
let line = UInt(#line - testCases.count - 2 + index)
let debugString = NSAttributedString(string: testCase.0).bonMotDebugString
XCTAssertEqual(testCase.1, debugString, line: line)
let fromXML = StringStyle(.xml).attributedString(from: debugString)
// Unassigned unicode replacement is not currently working. No one is actually interested in doing this so I'm going to leave it out.
if !testCase.1.contains("BON:unicode value=") {
XCTAssertEqual(testCase.0, fromXML.string, line: line)
}
}
}
func testComposedDebugRepresentation() throws {
let imageForTest = try robotImage()
let testCases: [([Composable], String, UInt)] = [
([imageForTest], "<BON:image size='36x36'/>", #line),
([Special.enDash], "<BON:enDash/>", #line),
([imageForTest, imageForTest], "<BON:image size='36x36'/><BON:image size='36x36'/>", #line),
([Special.enDash, Special.emDash], "<BON:enDash/><BON:emDash/>", #line),
([Special.enDash, imageForTest], "<BON:enDash/><BON:image size='36x36'/>", #line),
([imageForTest, Special.enDash], "<BON:image size='36x36'/><BON:enDash/>", #line),
([imageForTest, Special.noBreakSpace, "Monday", Special.enDash, "Friday"], "<BON:image size='36x36'/><BON:noBreakSpace/>Monday<BON:enDash/>Friday", #line),
]
for testCase in testCases {
let debugString = NSAttributedString.composed(of: testCase.0).bonMotDebugString
XCTAssertEqual(testCase.1, debugString, line: testCase.2)
}
}
func testThatNSAttributedStringSpeaksUTF16() {
// We don't actually need to test this - just demonstrating how it works
let string = "\u{000A1338}A"
XCTAssertEqual(string.count, 2)
XCTAssertEqual(string.utf8.count, 5)
XCTAssertEqual(string.utf16.count, 3)
let mutableAttributedString = NSMutableAttributedString(string: string)
XCTAssertEqual(mutableAttributedString.string, string)
mutableAttributedString.replaceCharacters(in: NSRange(location: 0, length: 2), with: "foo")
XCTAssertEqual(mutableAttributedString.string, "fooA")
}
// ParagraphStyles are a bit interesting, as tabs behave over a line, but multiple paragraph styles can be applied on that line.
// I'm not sure how a multi-paragraph line would behave, but this confirms that NSAttributedString doesn't do any coalescing
func testParagraphStyleBehavior() {
let style1 = NSMutableParagraphStyle()
style1.lineSpacing = 1000
let style2 = NSMutableParagraphStyle()
style2.headIndent = 1000
let string1 = NSMutableAttributedString(string: "first part ", attributes: [.paragraphStyle: style1])
let string2 = NSAttributedString(string: "second part.\n", attributes: [.paragraphStyle: style2])
string1.append(string2)
let p1 = string1.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle
let p2 = string1.attribute(.paragraphStyle, at: string1.length - 1, effectiveRange: nil) as? NSParagraphStyle
XCTAssertNotEqual(p1, p2)
}
}
| [
-1
] |
05554e805a1410777edd66f0bcd140effdedacb1 | 2b1a27581fd35ec33c0f604cea24a9ad817fb20a | /Tests/MemoryCacheTests.swift | 6197d4e9945d2ced9affa98f200043cb0c266efa | [
"MIT"
] | permissive | royhsu/tiny-storage | 1c2cbb4340b072aa8ee1c0bbb7c2e5b8db2e60ac | 96463795d453d9f579177160de76d2d7a148f057 | refs/heads/master | 2020-03-29T09:25:40.504422 | 2019-02-21T10:26:27 | 2019-02-21T10:26:27 | 149,757,860 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 6,110 | swift | //
// MemoryCacheTests.swift
// TinyStorageTests
//
// Created by Roy Hsu on 2018/9/13.
// Copyright © 2018 TinyWorld. All rights reserved.
//
// MARK: - AnyStorageTests
import XCTest
@testable import TinyStorage
#warning("Update testing that follows IndexedStorage.")
internal final class MemoryCacheTests: XCTestCase {
internal final var observation: Observation?
internal final func testInitialize() {
let cache = MemoryCache<String, String>()
XCTAssert(cache.isEmpty)
}
internal final func testExpressibleByDictionaryLiteral() {
let cache: MemoryCache = [
"hello": "world"
]
XCTAssertEqual(
cache.count,
1
)
XCTAssertEqual(
cache["hello"],
"world"
)
}
internal final func testLoad() {
let promise = expectation(description: "Load the cache.")
let cache = MemoryCache<String, String>()
XCTAssertFalse(cache.isLoaded)
cache.load { result in
promise.fulfill()
switch result {
case .success:
XCTAssert(cache.isLoaded)
XCTAssert(cache.isEmpty)
case let .failure(error): XCTFail("\(error)")
}
}
wait(
for: [ promise ],
timeout: 10.0
)
}
internal final func testSetValue() {
let promise = expectation(description: "Get notified about changes.")
var cache = MemoryCache<String, String>()
observation = cache.observe { change in
defer { promise.fulfill() }
let changes = change.currentValue
XCTAssertEqual(
changes?.count,
1
)
let helloKeyChange = changes?.first { $0.key == "hello" }
XCTAssertEqual(
helloKeyChange?.value,
"world"
)
}
cache["hello"] = "world"
XCTAssertEqual(
cache["hello"],
"world"
)
XCTAssertEqual(
cache.count,
1
)
wait(
for: [ promise ],
timeout: 10.0
)
}
internal final func testMergeValues() {
let promise = expectation(description: "Get notified about changes.")
var cache: MemoryCache = [
"existing": "value",
"replacing": "current value"
]
observation = cache.observe { change in
promise.fulfill()
let changes = change.currentValue
XCTAssertEqual(
changes?.count,
2
)
let existingKeyChange = changes?.first { $0.key == "existing" }
XCTAssert(existingKeyChange == nil)
let newKeyChange = changes?.first { $0.key == "new" }
XCTAssert(newKeyChange != nil)
XCTAssertEqual(
newKeyChange?.value,
"value"
)
let replacingKeyChange = changes?.first { $0.key == "replacing" }
XCTAssert(replacingKeyChange != nil)
XCTAssertEqual(
replacingKeyChange?.value,
"by value"
)
let nilKeyChange = changes?.first { $0.key == "nil" }
XCTAssert(nilKeyChange == nil)
}
let newElements: [ (String, String?) ] = [
("new", "value"),
("replacing", "by value"),
("nil", nil)
]
cache.merge(
AnySequence(newElements)
)
XCTAssertEqual(
cache["new"],
"value"
)
XCTAssertEqual(
cache["existing"],
"value"
)
XCTAssertEqual(
cache["replacing"],
"by value"
)
XCTAssert(
cache["nil"] == nil
)
XCTAssertEqual(
cache.count,
3
)
wait(
for: [ promise ],
timeout: 10.0
)
}
internal final func testRemoveValue() {
let promise = expectation(description: "Get notified about changes.")
var cache: MemoryCache = [ "nil": "non-nil value" ]
observation = cache.observe { change in
promise.fulfill()
let changes = change.currentValue
XCTAssertEqual(
changes?.count,
1
)
let nilKeyChange = changes?.first { $0.key == "nil" }
XCTAssert(nilKeyChange != nil)
XCTAssertEqual(
nilKeyChange?.value,
nil
)
}
cache["nil"] = nil
XCTAssert(cache.isEmpty)
wait(
for: [ promise ],
timeout: 10.0
)
}
internal final func testRemoveAllValues() {
let promise = expectation(description: "Remove all values.")
let cache: MemoryCache = [
"removing": "value"
]
observation = cache.observe { change in
promise.fulfill()
XCTAssert(cache.isEmpty)
let changes = change.currentValue
let removeKeyChange = changes?.first { $0.key == "removing" }
XCTAssert(removeKeyChange != nil)
XCTAssertEqual(
removeKeyChange?.value,
"value"
)
}
cache.removeAll()
wait(
for: [ promise ],
timeout: 10.0
)
}
internal final func testElements() {
let cache: MemoryCache = [
"hello": "world"
]
XCTAssertEqual(
cache.elements.count,
1
)
XCTAssert(
cache.elements.contains { $0.key == "hello" && $0.value == "world" }
)
}
internal final func testTypeErasable() {
let cache = MemoryCache<String, String>()
_ = AnyStorage(cache)
XCTSuccess()
}
}
| [
-1
] |
33d20c6d98027464936b6800f925c5d9b20eb93c | 6e36fc1bf900599fcf09b3b40352407f84d6fb1f | /Threes/AppDelegate.swift | fd2c5df29c830e986fe0e6f22a4053e830597108 | [] | no_license | dmaulikr/Threes_Swift | a86c4dd0b92e758efed1404f6fd14a5740ffd3e2 | c68d9b2d0e1bd7b6384ad0f3672ba3f556b48f3d | refs/heads/master | 2021-06-01T03:46:40.905835 | 2016-07-04T15:21:18 | 2016-07-04T15:21:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,146 | swift | //
// AppDelegate.swift
// Threes
//
// Created by TYRONE AVNIT on 2016/07/02.
// Copyright © 2016 TYRONE AVNIT. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
| [
229380,
229383,
229385,
278539,
229388,
294924,
278542,
229391,
327695,
278545,
229394,
278548,
229397,
229399,
229402,
278556,
229405,
352284,
278559,
278564,
229415,
229417,
327722,
237613,
360496,
229426,
237618,
229428,
286774,
229432,
286776,
286778,
319544,
204856,
286791,
237640,
278605,
311375,
163920,
196692,
319573,
311383,
278623,
278626,
319590,
311400,
278635,
278639,
278648,
131192,
237693,
327814,
131209,
417930,
303241,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
327862,
286906,
327866,
180413,
286910,
286916,
286922,
286924,
286926,
286928,
131281,
278743,
278747,
155872,
319716,
278760,
237807,
303345,
286962,
229622,
327930,
278781,
278783,
278785,
237826,
278792,
286987,
319757,
286999,
287003,
287006,
287009,
287012,
287014,
287016,
287019,
311598,
287023,
262448,
311601,
155966,
278849,
319809,
319810,
319814,
311623,
319818,
311628,
287054,
319822,
278865,
229717,
196963,
196969,
139638,
213367,
106872,
319872,
311683,
319879,
65943,
319898,
311719,
278952,
139689,
278957,
311728,
278967,
180668,
311741,
278975,
319938,
278980,
278983,
319945,
278986,
278990,
278994,
311767,
279003,
279006,
188895,
279010,
287202,
279015,
172520,
279020,
279023,
311791,
172529,
279027,
319989,
164343,
180727,
279035,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
287238,
172552,
303623,
320007,
279051,
172558,
279055,
303632,
279058,
303637,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
279084,
172591,
172598,
279095,
172607,
172612,
377413,
172614,
172618,
303690,
33357,
279124,
172634,
262752,
172644,
311911,
189034,
295533,
189039,
189040,
172655,
172656,
295538,
189044,
172660,
287349,
352880,
287355,
287360,
295553,
287365,
311942,
303751,
352905,
279178,
287371,
311946,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
164509,
303773,
295583,
172702,
230045,
287394,
287390,
303780,
172705,
287398,
172707,
279208,
287400,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
328381,
279231,
287423,
328384,
287427,
279241,
172748,
287436,
172755,
303827,
279255,
279258,
303835,
213724,
189149,
303838,
287450,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
205564,
303871,
230146,
328453,
295685,
230154,
33548,
312077,
295695,
295701,
369433,
230169,
295707,
328476,
295710,
303914,
279340,
279353,
230202,
312124,
222018,
295755,
377676,
148302,
287569,
279383,
303959,
279390,
230241,
279394,
303976,
336744,
303985,
328563,
279413,
303991,
303997,
295806,
295808,
304005,
213895,
320391,
304007,
304009,
304011,
304013,
213902,
279438,
189329,
304019,
279445,
58262,
279452,
279461,
279462,
304042,
213931,
230327,
304055,
287675,
197564,
304063,
304065,
189378,
213954,
156612,
312272,
304084,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
295945,
197645,
295949,
230413,
320528,
140312,
295961,
238620,
304164,
189479,
304170,
238641,
238652,
238655,
230465,
238658,
336964,
296004,
205895,
320584,
238666,
296021,
336987,
230497,
296036,
296040,
205931,
164973,
279661,
205934,
312432,
279669,
337018,
279679,
279683,
222340,
205968,
296084,
238745,
304285,
238756,
205991,
222377,
165035,
337067,
238766,
165038,
230576,
238770,
304311,
350308,
230592,
279750,
312518,
230600,
230607,
148690,
320727,
279769,
304348,
279777,
304354,
296163,
320740,
279781,
304360,
279788,
320748,
279790,
296189,
320771,
312585,
296205,
230674,
320786,
230677,
296213,
296215,
320792,
230681,
230679,
230689,
312622,
296243,
312630,
222522,
222525,
296253,
312639,
296255,
296259,
378181,
230727,
238919,
320840,
296264,
296267,
296271,
222545,
230739,
312663,
337244,
222556,
230752,
312676,
230760,
173418,
410987,
230763,
230768,
296305,
312692,
230773,
279929,
304506,
304505,
181626,
181631,
312711,
312712,
296331,
288140,
288144,
230800,
337306,
288160,
288162,
288164,
279975,
370092,
279983,
288176,
279985,
312755,
296373,
279991,
312759,
288185,
337335,
222652,
312766,
173507,
296389,
230860,
280014,
312783,
288208,
230865,
370130,
288210,
288212,
280021,
288214,
222676,
239064,
288217,
288218,
280027,
329177,
288220,
239070,
288224,
370146,
280034,
280036,
288226,
280038,
288229,
288230,
288232,
288234,
288236,
288238,
288240,
291754,
288242,
296435,
288244,
296439,
288250,
402942,
148990,
296446,
296450,
230916,
230919,
370187,
304651,
304653,
230940,
222752,
108066,
296486,
296488,
157229,
230961,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
280152,
288344,
239194,
280158,
403039,
370272,
312938,
280183,
280185,
280188,
280191,
280194,
116354,
280208,
280211,
288408,
280218,
280222,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
313027,
280260,
206536,
280264,
206539,
206541,
206543,
280276,
321239,
280283,
313052,
288478,
313055,
321252,
313066,
280302,
288494,
321266,
419570,
288499,
288502,
280314,
288510,
67330,
280324,
198405,
288519,
280331,
198416,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
280375,
321336,
345921,
280388,
304968,
280393,
280402,
313176,
42842,
280419,
321381,
296812,
313201,
1920,
305028,
280454,
247688,
280458,
280464,
124817,
280468,
280473,
124827,
247709,
214944,
280487,
321458,
296883,
10170,
296890,
296894,
280515,
190403,
296900,
337862,
165831,
280521,
231379,
296921,
239586,
231404,
124913,
165876,
239612,
313340,
239617,
313347,
313358,
321560,
305176,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
124980,
288824,
288826,
321595,
378941,
313406,
288831,
288836,
67654,
223303,
280651,
354382,
288848,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
223327,
280671,
149599,
321634,
149601,
149603,
313451,
223341,
313458,
280691,
313464,
329850,
321659,
280702,
288895,
321670,
215175,
141455,
141459,
313498,
288936,
100520,
288940,
280755,
288947,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
157930,
280811,
280817,
280819,
157940,
125171,
280823,
280825,
280827,
280830,
280831,
280833,
280835,
125187,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
280891,
289087,
280897,
280900,
239944,
305480,
280906,
239947,
305485,
305489,
280919,
354653,
313700,
280937,
280940,
190832,
280946,
223606,
313720,
280956,
239997,
280959,
313731,
199051,
240011,
289166,
240017,
190868,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
305594,
281024,
289218,
289221,
289227,
281045,
281047,
215526,
166378,
305647,
281075,
281084,
240124,
305662,
305664,
240129,
305666,
305668,
240132,
223749,
281095,
338440,
150025,
223752,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
281135,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
281179,
199262,
338532,
281190,
199273,
281196,
158317,
313973,
281210,
297594,
158347,
133776,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
314029,
314033,
240309,
133817,
314047,
314051,
297671,
199367,
158409,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322314,
322318,
281361,
281372,
215850,
281388,
281401,
289593,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
281435,
281438,
281442,
174955,
224110,
207737,
183172,
240519,
322440,
338823,
314249,
289687,
240535,
297883,
289694,
289696,
289700,
281529,
289724,
52163,
183260,
281567,
289762,
322534,
297961,
281581,
183277,
322550,
175134,
322599,
322610,
314421,
281654,
314427,
207937,
314433,
207949,
322642,
314456,
281691,
314461,
281702,
281704,
281708,
281711,
289912,
248995,
306341,
306347,
306354,
142531,
199877,
289991,
306377,
289997,
363742,
363745,
298216,
330988,
216303,
322801,
363802,
199976,
199978,
314671,
298292,
298294,
298306,
380226,
281923,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
298358,
314743,
306552,
290171,
314747,
306555,
290174,
224641,
281987,
298372,
281990,
298377,
314763,
224657,
306581,
314779,
314785,
282025,
314793,
282027,
241068,
241070,
241072,
282034,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
282089,
191985,
282098,
282101,
191992,
290298,
151036,
290302,
282111,
290305,
175621,
192008,
282127,
290321,
282130,
282133,
290325,
241175,
290328,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290351,
282186,
224849,
282195,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
241260,
257658,
315016,
282249,
290445,
324757,
282261,
298651,
282269,
323229,
298655,
323231,
61092,
282277,
282295,
282300,
323260,
323266,
282310,
323273,
282319,
306897,
241362,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
282410,
241450,
306988,
306991,
315184,
315190,
241464,
282425,
159545,
307009,
307012,
315211,
307027,
315221,
282454,
315223,
241496,
241498,
307035,
307040,
282465,
110438,
298860,
110445,
282478,
315249,
110450,
315251,
282481,
315253,
315255,
339838,
282499,
315267,
315269,
241544,
282505,
241546,
241548,
298896,
298898,
282514,
44948,
298901,
241556,
282520,
241560,
241563,
241565,
241567,
241569,
282531,
241574,
282537,
241581,
241583,
323504,
241586,
282547,
241588,
290739,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
241661,
282623,
315396,
241669,
315397,
282632,
282639,
282645,
241693,
241701,
102438,
282669,
323630,
282681,
290877,
282687,
159811,
315463,
315466,
192589,
307278,
307287,
315482,
315483,
217179,
192605,
200801,
299105,
217188,
299109,
307303,
315495,
356457,
45163,
307307,
315502,
192624,
307314,
323700,
299126,
233591,
307329,
307338,
233613,
241813,
307352,
299164,
184479,
299167,
184481,
184486,
307370,
307372,
307376,
323763,
176311,
299191,
307385,
307386,
258235,
176316,
307388,
307390,
299200,
307394,
307396,
184518,
307399,
323784,
307409,
307411,
176343,
299225,
233701,
307432,
282881,
282893,
291089,
282906,
291104,
233766,
282931,
307508,
315701,
307510,
332086,
307512,
151864,
307515,
282942,
307518,
151874,
282947,
282957,
323917,
110926,
233808,
323921,
315733,
323926,
233815,
315739,
299357,
242018,
242024,
299373,
315757,
250231,
242043,
315771,
299391,
291202,
299398,
242057,
291212,
299405,
283033,
291226,
242075,
315801,
291231,
283042,
291238,
291241,
127403,
127405,
291247,
299444,
127413,
283062,
291254,
283069,
127421,
127424,
299457,
283080,
176592,
315856,
315860,
176597,
127447,
283095,
299481,
176605,
242143,
291299,
127463,
242152,
291305,
176620,
127474,
291314,
291317,
135672,
233979,
291330,
283142,
127497,
233994,
135689,
233998,
234003,
234006,
152087,
127511,
283161,
242202,
234010,
135707,
242206,
135710,
242208,
291361,
234038,
234041,
70213,
242250,
111193,
242275,
299620,
242279,
168562,
184952,
135805,
291456,
135808,
373383,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
135839,
299680,
225954,
299684,
242343,
209576,
242345,
373421,
135870,
135873,
135876,
135879,
299723,
225998,
299726,
226002,
226005,
119509,
226008,
201444,
299750,
283368,
234219,
283372,
381677,
226037,
283382,
234231,
316151,
234236,
226045,
234239,
242431,
209665,
234242,
299778,
242436,
226053,
234246,
226056,
234248,
291593,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
201496,
234264,
234266,
234269,
283421,
234272,
234274,
152355,
234278,
299814,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
234298,
283452,
160572,
234302,
234307,
242499,
234309,
234313,
316233,
316235,
234316,
283468,
242511,
234319,
234321,
234324,
185173,
201557,
234329,
234333,
308063,
234336,
234338,
242530,
349027,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
226171,
234364,
291711,
234368,
234370,
201603,
234373,
226182,
234375,
226185,
308105,
234379,
234384,
234388,
234390,
226200,
324504,
234393,
209818,
308123,
324508,
234398,
234396,
291742,
234401,
291748,
234405,
291750,
234407,
324518,
324520,
234410,
324522,
226220,
291756,
234414,
324527,
291760,
234417,
201650,
324531,
226230,
234422,
275384,
324536,
234428,
291773,
234431,
242623,
324544,
324546,
226239,
324548,
226245,
234437,
234439,
234434,
234443,
275406,
234446,
193486,
234449,
316370,
193488,
234452,
234455,
234459,
234461,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
324599,
234487,
234490,
234493,
234496,
316416,
234501,
275462,
234504,
234507,
234510,
234515,
300054,
234519,
316439,
234520,
234523,
234526,
234528,
300066,
234532,
234535,
234537,
234540,
144430,
234543,
234546,
275508,
234549,
300085,
300088,
234553,
234556,
234558,
316479,
234561,
316483,
234563,
308291,
234568,
234570,
316491,
300108,
234572,
234574,
300115,
234580,
234581,
275545,
242777,
234585,
234590,
234593,
234595,
300133,
234597,
234601,
300139,
234605,
234607,
160879,
275569,
234610,
300148,
234614,
398455,
144506,
275579,
234618,
234620,
234623,
226433,
234627,
275588,
234629,
242822,
234634,
275594,
234636,
177293,
234640,
275602,
234643,
226453,
275606,
234647,
275608,
308373,
234650,
234648,
308379,
283805,
234653,
324766,
119967,
234657,
300189,
324768,
283813,
234661,
300197,
234664,
275626,
234667,
316596,
234687,
300226,
226500,
234692,
300229,
308420,
283844,
283850,
300234,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
300263,
300265,
161003,
300267,
300270,
300272,
120053,
300278,
316663,
275703,
300284,
275710,
300287,
283904,
300289,
292097,
300292,
300294,
275719,
300299,
177419,
283917,
300301,
242957,
177424,
275725,
349464,
283939,
259367,
283951,
292143,
300344,
226617,
283963,
243003,
226628,
283973,
300357,
283983,
316758,
357722,
316766,
292192,
316768,
218464,
292197,
316774,
284010,
136562,
324978,
275834,
275836,
275840,
316803,
316806,
316811,
226703,
300433,
234899,
226709,
357783,
316824,
316826,
144796,
300448,
144807,
144810,
284076,
144812,
144814,
144820,
284084,
284087,
292279,
144826,
144828,
144830,
144832,
144835,
284099,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
226787,
218597,
292329,
300523,
300527,
308720,
226802,
316917,
308727,
292343,
300537,
316947,
308757,
284191,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
284213,
284215,
284218,
226877,
284223,
284226,
243268,
292421,
226886,
284231,
128584,
284228,
284234,
276043,
317004,
366155,
284238,
226895,
284241,
194130,
284243,
276052,
276053,
284245,
284247,
317015,
284249,
243290,
284251,
300628,
284253,
235097,
284255,
300638,
284258,
292452,
284263,
284265,
292458,
284267,
292461,
284272,
284274,
276086,
284278,
292470,
292473,
284283,
276093,
284286,
276095,
284288,
292481,
276098,
284290,
325250,
284292,
292479,
292485,
284297,
317066,
284299,
317068,
276109,
284301,
284303,
276114,
284306,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
276137,
284329,
284331,
317098,
284333,
284335,
284337,
284339,
300726,
284343,
284346,
284350,
276160,
358080,
284354,
358083,
276166,
284358,
358089,
276170,
284362,
276175,
284368,
276177,
284370,
317138,
284372,
358098,
276187,
284379,
284381,
284384,
284386,
358114,
358116,
276197,
358119,
284392,
325353,
284394,
358122,
284397,
276206,
284399,
358126,
358128,
358133,
358135,
276216,
358140,
284413,
358142,
284418,
358146,
317187,
317189,
317191,
284428,
300816,
300819,
317207,
284440,
186139,
300828,
300830,
276255,
325408,
284449,
300834,
300832,
227109,
317221,
358183,
276268,
194351,
243504,
300850,
284469,
276280,
325436,
276291,
366406,
276295,
153417,
276308,
284502,
317271,
276315,
292700,
284511,
227175,
292715,
284529,
300915,
292729,
317306,
284540,
276365,
284564,
358292,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
284585,
317353,
276395,
276402,
358326,
276410,
276411,
358330,
276418,
276425,
301009,
301011,
301013,
292823,
301015,
301017,
358360,
292828,
276446,
153568,
276448,
276452,
276455,
292839,
292843,
276460,
276464,
227314,
276466,
276472,
317435,
276476,
276479,
276482,
276485,
317446,
276490,
292876,
276496,
317456,
317458,
243733,
243740,
317468,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
325689,
276539,
235579,
235581,
325692,
276544,
284739,
276553,
243785,
350293,
350295,
194649,
227418,
309337,
350302,
227423,
194654,
194657,
178273,
276579,
227426,
194660,
227430,
276583,
309346,
309348,
276586,
309350,
309352,
309354,
276590,
350313,
350316,
350321,
284786,
276595,
227440,
301167,
350325,
350328,
292985,
301178,
292989,
292993,
301185,
350339,
317573,
350342,
227463,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
276638,
350366,
284837,
350375,
350379,
350381,
350383,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
309450,
301258,
276685,
276689,
227540,
309462,
301272,
309468,
301283,
317672,
276713,
317674,
325867,
227571,
276725,
243960,
276735,
227583,
227587,
276739,
276742,
227593,
227596,
325910,
309530,
342298,
276766,
211232,
276775,
325937,
276789,
325943,
260421,
276809,
285002,
276811,
235853,
276816,
235858,
276829,
276833,
391523,
276836,
276843,
293227,
276848,
293232,
186744,
285051,
211324,
227709,
285061,
317833,
178572,
285070,
178575,
285077,
227738,
317853,
276896,
317858,
342434,
285093,
317864,
285098,
276907,
276917,
293304,
293307,
293314,
309707,
317910,
293336,
235996,
317917,
293343,
358880,
276961,
227810,
293346,
276964,
293352,
236013,
293364,
317951,
309764,
121352,
236043,
342541,
113167,
277011,
317971,
309781,
309779,
227877,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
277054,
129603,
318020,
301636,
301639,
301643,
277071,
285265,
309844,
277080,
309849,
285277,
285282,
326244,
277100,
277106,
121458,
170618,
170619,
309885,
309888,
277122,
227975,
277128,
285320,
301706,
318092,
326285,
318094,
334476,
277136,
277139,
227992,
285340,
318108,
227998,
318110,
383658,
285357,
318128,
277170,
342707,
154292,
277173,
285368,
277177,
277181,
277187,
277191,
277194,
277196,
277201,
137946,
113378,
228069,
277223,
342760,
285417,
56043,
277232,
228081,
56059,
285441,
310020,
285448,
310029,
285453,
228113,
285459,
277273,
326430,
228128,
293666,
228135,
318248,
277291,
293677,
318253,
285489,
293685,
285494,
301880,
301884,
310080,
293696,
277314,
277317,
277322,
277329,
301911,
277337,
301913,
301921,
400236,
236397,
162671,
310134,
277368,
15224,
236408,
416639,
416640,
113538,
416648,
277385,
39817,
187274,
301972,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
293811,
293820,
203715,
293849,
293861,
228327,
228328,
228330,
318442,
228332,
277486,
326638,
318450,
293876,
285686,
302073,
285690,
121850,
302075,
293887,
277504,
277507,
277511,
277519,
293908,
277526,
293917,
293939,
277561,
277564,
310336,
293956,
277573,
228422,
310344,
277577,
293960,
277583,
203857,
310355,
293971,
310359,
236632,
277594,
138332,
277598,
285792,
277601,
203872,
310374,
203879,
277608,
310376,
228460,
318573,
203886,
187509,
285815,
285817,
367737,
285821,
302205,
285824,
392326,
285831,
302218,
285835,
384148,
162964,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
277671,
302248,
64682,
277678,
228526,
294063,
302258,
277687,
294072,
318651,
277695,
318657,
244930,
302275,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
302296,
384222,
310498,
285927,
318698,
302315,
195822,
228592,
294132,
138485,
204023,
228601,
228606,
64768,
310531,
285958,
228617,
138505,
318742,
277798,
130345,
113964,
285997,
285999,
113969,
277811,
318773,
318776,
277816,
286010,
417086,
277822,
286016,
294211,
302403,
384328,
277832,
277836,
294221,
326991,
294223,
277839,
277850,
179547,
277853,
146784,
277857,
302436,
294246,
327015,
310632,
327017,
351594,
351607,
310648,
310651,
277888,
310657,
351619,
294276,
310659,
277892,
253320,
310665,
318858,
277898,
277903,
310672,
351633,
277905,
277908,
277917,
310689,
277921,
277923,
130468,
228776,
277932,
310703,
277937,
310710,
130486,
310712,
310715,
302526,
228799,
277953,
64966,
245191,
163272,
302534,
310727,
277959,
292968,
302541,
277966,
302543,
310737,
277975,
228825,
163290,
310749,
277981,
310755,
277989,
187880,
286188,
310764,
278003,
310772,
40440,
278009,
40443,
286203,
228864,
40448,
286214,
228871,
302603,
65038,
302614,
286233,
302617,
302621,
146977,
187939,
294435,
286246,
294439,
286248,
278057,
294440,
294443,
40486,
294445,
40488,
310831,
40499,
40502,
212538,
40507,
40511,
228933,
40521,
286283,
40525,
40527,
228944,
212560,
400976,
147032,
40537,
40539,
278109,
40541,
40550,
286312,
286313,
40554,
40552,
310892,
40557,
188022,
294521,
343679,
278150,
310925,
286354,
278163,
122517,
278168,
327333,
229030,
278188,
278192,
319153,
278196,
302781,
302789,
294599,
278216,
294601,
343757,
212690,
278227,
229076,
286420,
319187,
286425,
319194,
278235,
229086,
278238,
286432,
294625,
294634,
302838,
319226,
286460,
171774,
278274,
278277,
302854,
294664,
311048,
319243,
311053,
302862,
319251,
294682,
278306,
294701,
278320,
319290,
229192,
302925,
188247,
237409,
327554,
294811,
319390,
294817,
319394,
40865,
311209,
180142,
188340,
40886,
294844,
294847,
393177,
294876,
294879,
294883,
311279,
278513,
237555,
278516,
311283,
278519,
237562
] |
bc3c159a303a7bb83c8dfa8bc8ace0ed6e5b8054 | de64dc5d60786d601eabeff1f8ee583c8233bc25 | /Tests/NIOSOCKSTests/SOCKSServerHandshakeHandler+Tests.swift | c7ae79adbe40e96438ea46d4bb061338aa21d152 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | kishansuthar/swift-nio-extras | 974dacd9458dc8d36f02d86329de678b91f33fcd | 93fc12bdb73721a04ea92f727a319fd2f80c8323 | refs/heads/main | 2023-05-28T15:41:44.602818 | 2021-06-16T14:51:23 | 2021-06-16T14:51:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 9,209 | swift | //===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIO
@testable import NIOSOCKS
import XCTest
class PromiseTestHandler: ChannelInboundHandler {
typealias InboundIn = ClientMessage
let expectedGreeting: ClientGreeting
let expectedRequest: SOCKSRequest
let expectedData: ByteBuffer
var hadGreeting: Bool = false
var hadRequest: Bool = false
var hadData: Bool = false
public init(
expectedGreeting: ClientGreeting,
expectedRequest: SOCKSRequest,
expectedData: ByteBuffer
) {
self.expectedGreeting = expectedGreeting
self.expectedRequest = expectedRequest
self.expectedData = expectedData
}
func channelRead(context: ChannelHandlerContext, data: NIOAny) {
let message = self.unwrapInboundIn(data)
switch message {
case .greeting(let greeting):
XCTAssertEqual(greeting, expectedGreeting)
hadGreeting = true
case .request(let request):
XCTAssertEqual(request, expectedRequest)
hadRequest = true
case .authenticationData(let data):
XCTAssertEqual(data, expectedData)
hadData = true
}
}
}
class SOCKSServerHandlerTests: XCTestCase {
var channel: EmbeddedChannel!
var handler: SOCKSServerHandshakeHandler!
override func setUp() {
XCTAssertNil(self.channel)
self.handler = SOCKSServerHandshakeHandler()
self.channel = EmbeddedChannel(handler: self.handler)
}
override func tearDown() {
XCTAssertNotNil(self.channel)
self.channel = nil
}
func assertOutputBuffer(_ bytes: [UInt8], line: UInt = #line) {
do {
if var buffer = try self.channel.readOutbound(as: ByteBuffer.self) {
XCTAssertEqual(buffer.readBytes(length: buffer.readableBytes), bytes, line: line)
} else if bytes.count > 0 {
XCTFail("Expected bytes but found none", line: line)
}
} catch {
XCTFail("\(error)", line: line)
}
}
func writeOutbound(_ message: ServerMessage, line: UInt = #line) {
XCTAssertNoThrow(try self.channel.writeOutbound(message), line: line)
}
func writeInbound(_ bytes: [UInt8], line: UInt = #line) {
XCTAssertNoThrow(try self.channel.writeInbound(ByteBuffer(bytes: bytes)), line: line)
}
func assertInbound(_ bytes: [UInt8], line: UInt = #line) {
do {
if var buffer = try self.channel.readInbound(as: ByteBuffer.self) {
XCTAssertEqual(buffer.readBytes(length: buffer.readableBytes), bytes, line: line)
} else {
XCTAssertTrue(bytes.count == 0)
}
} catch {
XCTFail("\(error)")
}
}
func assertInbound(_ message: ClientMessage, line: UInt = #line) {
do {
if let actual = try self.channel.readInbound(as: ClientMessage.self) {
XCTAssertEqual(message, actual, line: line)
} else {
XCTFail("No message", line: line)
}
} catch {
XCTFail("\(error)", line: line)
}
}
func testTypicalWorkflow() {
let expectedGreeting = ClientGreeting(methods: [.init(value: 0xAA)])
let expectedRequest = SOCKSRequest(command: .connect, addressType: .address(try! .init(ipAddress: "127.0.0.1", port: 80)))
let expectedData = ByteBuffer(bytes: [0x01, 0x02, 0x03, 0x04])
let testHandler = PromiseTestHandler(
expectedGreeting: expectedGreeting,
expectedRequest: expectedRequest,
expectedData: expectedData
)
XCTAssertNoThrow(try self.channel.pipeline.addHandler(testHandler).wait())
// wait for the greeting
XCTAssertFalse(testHandler.hadGreeting)
self.writeInbound([0x05, 0x01, 0xAA])
XCTAssertTrue(testHandler.hadGreeting)
// write the auth selection
self.writeOutbound(.selectedAuthenticationMethod(.init(method: .init(value: 0xAA))))
self.assertOutputBuffer([0x05, 0xAA])
XCTAssertFalse(testHandler.hadData)
self.writeInbound([0x01, 0x02, 0x03, 0x04])
XCTAssertTrue(testHandler.hadData)
// finish authentication - nothing should be written
// as this is informing the state machine only
self.writeOutbound(.authenticationData(ByteBuffer(bytes: [0xFF, 0xFF]), complete: true))
self.assertOutputBuffer([0xFF, 0xFF])
// write the request
XCTAssertFalse(testHandler.hadRequest)
self.writeInbound([0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0, 80])
XCTAssertTrue(testHandler.hadRequest)
self.writeOutbound(.response(.init(reply: .succeeded, boundAddress: .address(try! .init(ipAddress: "127.0.0.1", port: 80)))))
self.assertOutputBuffer([0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0, 80])
}
// tests dripfeeding to ensure we buffer data correctly
func testTypicalWorkflowDripfeed() {
let expectedGreeting = ClientGreeting(methods: [.noneRequired])
let expectedRequest = SOCKSRequest(command: .connect, addressType: .address(try! .init(ipAddress: "127.0.0.1", port: 80)))
let expectedData = ByteBuffer(string: "1234")
let testHandler = PromiseTestHandler(
expectedGreeting: expectedGreeting,
expectedRequest: expectedRequest,
expectedData: expectedData
)
XCTAssertNoThrow(try self.channel.pipeline.addHandler(testHandler).wait())
// wait for the greeting
XCTAssertFalse(testHandler.hadGreeting)
self.writeInbound([0x05])
self.assertOutputBuffer([])
self.writeInbound([0x01])
self.assertOutputBuffer([])
self.writeInbound([0x00])
self.assertOutputBuffer([])
XCTAssertTrue(testHandler.hadGreeting)
// write the auth selection
XCTAssertNoThrow(try self.channel.writeOutbound(ServerMessage.selectedAuthenticationMethod(.init(method: .noneRequired))))
self.assertOutputBuffer([0x05, 0x00])
// finish authentication - nothing should be written
// as this is informing the state machine only
XCTAssertNoThrow(try self.channel.writeOutbound(ServerMessage.authenticationData(ByteBuffer(bytes: [0xFF, 0xFF]), complete: true)))
self.assertOutputBuffer([0xFF, 0xFF])
// write the request
XCTAssertFalse(testHandler.hadRequest)
self.writeInbound([0x05, 0x01])
self.assertOutputBuffer([])
self.writeInbound([0x00, 0x01])
self.assertOutputBuffer([])
self.writeInbound([127, 0, 0, 1, 0, 80])
XCTAssertTrue(testHandler.hadRequest)
}
// write nonsense bytes that should be caught inbound
func testInboundErrorsAreHandled() {
let buffer = ByteBuffer(bytes: [0xFF, 0xFF, 0xFF])
XCTAssertThrowsError(try self.channel.writeInbound(buffer)) { e in
XCTAssertTrue(e is SOCKSError.InvalidProtocolVersion)
}
}
// write something that will be be invalid for the state machine's
// current state, causing an error to be thrown
func testOutboundErrorsAreHandled() {
XCTAssertThrowsError(try self.channel.writeAndFlush(ServerMessage.authenticationData(ByteBuffer(bytes: [0xFF, 0xFF]), complete: true)).wait()) { e in
XCTAssertTrue(e is SOCKSError.InvalidServerState)
}
}
func testFlushOnHandlerRemoved() {
self.writeInbound([0x05, 0x01])
self.assertInbound([])
XCTAssertNoThrow(try self.channel.pipeline.removeHandler(self.handler).wait())
self.assertInbound([0x05, 0x01])
}
func testForceHandlerRemovalAfterAuth() {
// go through auth
self.writeInbound([0x05, 0x01, 0x00])
self.writeOutbound(.selectedAuthenticationMethod(.init(method: .noneRequired)))
self.assertOutputBuffer([0x05, 0x00])
XCTAssertNoThrow(try self.handler.stateMachine.authenticationComplete())
self.writeInbound([0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0, 80])
self.writeOutbound(.response(.init(reply: .succeeded, boundAddress: .address(try! .init(ipAddress: "127.0.0.1", port: 80)))))
self.assertOutputBuffer([0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0, 80])
// auth complete, try to write data without
// removing the handler, it should fail
XCTAssertThrowsError(try self.channel.writeOutbound(ServerMessage.authenticationData(ByteBuffer(string: "hello, world!"), complete: false)))
}
}
| [
-1
] |
fb2cf8d848d4d2202a2124241058959bdbe08484 | 061b46b307dd026eec00e30e3f425f7433dec137 | /ProjaBox/SignInViewController.swift | b92d316e70b580ed29bcc3565321419f88557828 | [] | no_license | alexclp/ProjaBox-iOS | a6597f21006c0d683769ef6128b73fa63d004f68 | 54db585b667da51d89872671f5165dd49feaabab | refs/heads/master | 2021-01-19T10:12:35.934046 | 2016-08-19T13:27:20 | 2016-08-19T13:27:20 | 54,049,257 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 911 | swift | //
// SignInViewController.swift
// ProjaBox
//
// Created by Alexandru Clapa on 02/06/2016.
// Copyright © 2016 Alexandru Clapa. All rights reserved.
//
import UIKit
import SwiftSpinner
class SignInViewController: UIViewController {
@IBOutlet weak var emailTextField: UITextField?
@IBOutlet weak var passwordTextField: UITextField?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.navigationController?.navigationBar.hidden = true
self.view.layer.contents = UIImage(named:"background-proja.png")!.CGImage
}
@IBAction func singInPressed(sender: UIButton) {
SwiftSpinner.show("Logging in")
SignInHelper.signIn((emailTextField?.text)!, password: (passwordTextField?.text)!) { (response) in
if response == true {
SwiftSpinner.hide()
self.performSegueWithIdentifier("showFeedSegue", sender: self)
}
}
}
}
| [
-1
] |
ceaad151410b8cb9bff2f9b5fd824254901381e8 | 332690a71d8a5326ccf5d655f30404b33051757e | /HyperCardCommon/HyperCardCommon/LayerBlockCommonReader.swift | 8dc99afc0f15b9a408f943c72d065234b3e5b956 | [] | no_license | MaddTheSane/HyperCardPreview | a4aa47f98dd9065eba60b2bcc385e4f217b7573c | dfb9a60fb9302c9cc9dcb062f18b131e5e2924d5 | refs/heads/master | 2022-09-01T04:14:11.993894 | 2019-03-26T09:51:06 | 2019-03-26T09:51:06 | 104,672,271 | 0 | 0 | null | 2017-09-24T19:57:59 | 2017-09-24T19:57:59 | null | UTF-8 | Swift | false | false | 5,258 | swift | //
// LayerBlockReaderV2.swift
// HyperCardCommon
//
// Created by Pierre Lorenzi on 03/06/2018.
// Copyright © 2018 Pierre Lorenzi. All rights reserved.
//
/// Reads common fields between background and card blocks. The common fields are either
/// at the beginning of the block, either at the end, and the specific fields are in-between.
/// So, to build a LayerBlockReaderV2, a partOffset must be provided to locate the end of the block.
public struct LayerBlockCommonReader: LayerBlockReader {
private let data: DataRange
private let version: FileVersion
private let partOffset: Int
private static let version1Offset = -4
public init(data: DataRange, version: FileVersion, partOffset: Int) {
self.data = data
self.version = version
self.partOffset = partOffset
}
public func readIdentifier() -> Int {
return data.readUInt32(at: 0x8)
}
public func readBitmapIdentifier() -> Int? {
let value = data.readSInt32(at: 0x10 + self.computeVersionOffset())
guard value != 0 else {
return nil
}
return value
}
private func computeVersionOffset() -> Int {
return version.isTwo() ? 0 : LayerBlockCommonReader.version1Offset
}
public func readCantDelete() -> Bool {
return data.readFlag(at: 0x14 + self.computeVersionOffset(), bitOffset: 14)
}
public func readShowPict() -> Bool {
return !data.readFlag(at: 0x14 + self.computeVersionOffset(), bitOffset: 13)
}
public func readDontSearch() -> Bool {
return data.readFlag(at: 0x14 + self.computeVersionOffset(), bitOffset: 11)
}
public func readPartCount() -> Int {
return data.readUInt16(at: self.partOffset - 0xE)
}
public func readNextAvailableIdentifier() -> Int {
return data.readUInt16(at: self.partOffset - 0xC)
}
public func readPartSize() -> Int {
return data.readUInt32(at: self.partOffset - 0xA)
}
public func readContentCount() -> Int {
return data.readUInt16(at: self.partOffset - 0x6)
}
public func readContentSize() -> Int {
return data.readUInt32(at: self.partOffset - 0x4)
}
public func extractPartBlocks() -> [DataRange] {
var parts = [DataRange]()
var offset = self.partOffset
let partCount = self.readPartCount()
/* Read the parts */
for _ in 0..<partCount {
/* Read the size of the part block */
let size = data.readUInt16(at: offset)
/* Build the part block */
let dataRange = DataRange(sharedData: self.data.sharedData, offset: self.data.offset + offset, length: size)
parts.append(dataRange)
/* Move to the next part data */
offset += size
}
return parts
}
public func extractContentBlocks() -> [DataRange] {
/* Special case for v1 */
guard self.version.isTwo() else {
return self.extractContentBlocksV1()
}
var contents = [DataRange]()
let partSize = self.readPartSize()
let contentCount = self.readContentCount()
var offset = self.partOffset + partSize
for _ in 0..<contentCount {
/* Read the identifier and size */
let size = data.readUInt16(at: offset + 2)
/* Build the content block */
let dataRange = DataRange(sharedData: self.data.sharedData, offset: self.data.offset + offset, length: size + 4)
contents.append(dataRange)
/* Skip the content */
offset += size + 4
/* Round to 32 bits */
offset = upToMultiple(offset, 2)
}
return contents
}
/* The contents are all unformatted strings */
private func extractContentBlocksV1() -> [DataRange] {
var contents = [DataRange]()
let partSize = self.readPartSize()
let contentCount = self.readContentCount()
var offset = self.partOffset + partSize
for _ in 0..<contentCount {
/* Register the offset of the start of the content */
let contentOffset = offset
/* Skip the content */
offset += 2
while data.readUInt8(at: offset) != 0 {
offset += 1
}
offset += 1
/* Build the content block */
let dataRange = DataRange(sharedData: self.data.sharedData, offset: self.data.offset + contentOffset, length: offset - contentOffset)
contents.append(dataRange)
}
return contents
}
public func readName() -> HString {
return data.readString(at: self.partOffset + self.readPartSize() + self.readContentSize())
}
public func readScript() -> HString {
return data.readString(at: self.partOffset + self.readPartSize() + self.readContentSize() + self.readName().length + 1)
}
}
| [
-1
] |
660c6d5c7807792c3282847dce67fb1b9039924e | 6434e9ce86d4cb83259c3db0452802578997048b | /ParseChat/Models/Message.swift | 96abfff3e2e9bb1b3b991bed8c4bccc372adbffe | [] | no_license | ryanliszewski/ParseChatCodePathU | 8439f16c37a2cb1aacfcf2d79b092550601693bd | a88d0996068957e0ee648c7e388ac0c882dbd028 | refs/heads/master | 2021-08-24T10:29:37.993256 | 2017-12-09T06:37:28 | 2017-12-09T06:37:28 | 113,644,736 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 335 | swift | //
// Message.swift
// ParseChat
//
// Created by Ryan Liszewski on 12/8/17.
// Copyright © 2017 ImThere. All rights reserved.
//
import Foundation
import Parse
class Message: PFObject {
@NSManaged var text: String?
}
extension Message: PFSubclassing {
static func parseClassName() -> String {
return "Message"
}
}
| [
-1
] |
accf2304313de7187ffb54d5de8d88b7c872f33d | df2f7560df397a0e21ed07b19dd2762b64b6805f | /LoginForm/IQKeyboardManagerSwift/Categories/IQUIView+Hierarchy.swift | efd4d2b51c37ed513d5fc0db7bbf0ebf47b0e924 | [] | no_license | GrantGaurav/LoginForm | 920f47374da5712b5f5602b41c0b075c054ab810 | f78f3894fd32338e74c75310df9acb658bdf8ee0 | refs/heads/master | 2020-04-07T05:18:24.709412 | 2018-03-07T05:35:55 | 2018-03-07T05:35:55 | 124,184,424 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 11,368 | swift | //
// IQUIView+Hierarchy.swift
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-16 Iftekhar Qurashi.
//
// 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
/**
UIView hierarchy category.
*/
public extension UIView {
///----------------------
/// MARK: viewControllers
///----------------------
/**
Returns the UIViewController object that manages the receiver.
*/
public func viewController()->UIViewController? {
var nextResponder: UIResponder? = self
repeat {
nextResponder = nextResponder?.next
if let viewController = nextResponder as? UIViewController {
return viewController
}
} while nextResponder != nil
return nil
}
/**
Returns the topMost UIViewController object in hierarchy.
*/
@objc public func topMostController()->UIViewController? {
var controllersHierarchy = [UIViewController]()
if var topController = window?.rootViewController {
controllersHierarchy.append(topController)
while topController.presentedViewController != nil {
topController = topController.presentedViewController!
controllersHierarchy.append(topController)
}
var matchController :UIResponder? = viewController()
while matchController != nil && controllersHierarchy.contains(matchController as! UIViewController) == false {
repeat {
matchController = matchController?.next
} while matchController != nil && matchController is UIViewController == false
}
return matchController as? UIViewController
} else {
return viewController()
}
}
///-----------------------------------
/// MARK: Superviews/Subviews/Siglings
///-----------------------------------
/**
Returns the superView of provided class type.
*/
public func superviewOfClassType(_ classType:UIView.Type)->UIView? {
var superView = superview
while let unwrappedSuperView = superView {
if unwrappedSuperView.isKind(of: classType) {
//If it's UIScrollView, then validating for special cases
if unwrappedSuperView.isKind(of: UIScrollView.self) {
let classNameString = NSStringFromClass(type(of:unwrappedSuperView.self))
// If it's not UITableViewWrapperView class, this is internal class which is actually manage in UITableview. The speciality of this class is that it's superview is UITableView.
// If it's not UITableViewCellScrollView class, this is internal class which is actually manage in UITableviewCell. The speciality of this class is that it's superview is UITableViewCell.
//If it's not _UIQueuingScrollView class, actually we validate for _ prefix which usually used by Apple internal classes
if unwrappedSuperView.superview?.isKind(of: UITableView.self) == false &&
unwrappedSuperView.superview?.isKind(of: UITableViewCell.self) == false &&
classNameString.hasPrefix("_") == false {
return superView
}
}
else {
return superView
}
}
superView = unwrappedSuperView.superview
}
return nil
}
/**
Returns all siblings of the receiver which canBecomeFirstResponder.
*/
public func responderSiblings()->[UIView] {
//Array of (UITextField/UITextView's).
var tempTextFields = [UIView]()
// Getting all siblings
if let siblings = superview?.subviews {
for textField in siblings {
if textField._IQcanBecomeFirstResponder() == true {
tempTextFields.append(textField)
}
}
}
return tempTextFields
}
/**
Returns all deep subViews of the receiver which canBecomeFirstResponder.
*/
public func deepResponderViews()->[UIView] {
//Array of (UITextField/UITextView's).
var textfields = [UIView]()
for textField in subviews {
if textField._IQcanBecomeFirstResponder() == true {
textfields.append(textField)
}
//Sometimes there are hidden or disabled views and textField inside them still recorded, so we added some more validations here (Bug ID: #458)
//Uncommented else (Bug ID: #625)
if textField.subviews.count != 0 && isUserInteractionEnabled == true && isHidden == false && alpha != 0.0 {
for deepView in textField.deepResponderViews() {
textfields.append(deepView)
}
}
}
//subviews are returning in opposite order. Sorting according the frames 'y'.
return textfields.sorted(by: { (view1 : UIView, view2 : UIView) -> Bool in
let frame1 = view1.convert(view1.bounds, to: self)
let frame2 = view2.convert(view2.bounds, to: self)
let x1 = frame1.minX
let y1 = frame1.minY
let x2 = frame2.minX
let y2 = frame2.minY
if y1 != y2 {
return y1 < y2
} else {
return x1 < x2
}
})
}
fileprivate func _IQcanBecomeFirstResponder() -> Bool {
var _IQcanBecomeFirstResponder = false
// Setting toolbar to keyboard.
if let textField = self as? UITextField {
_IQcanBecomeFirstResponder = textField.isEnabled
} else if let textView = self as? UITextView {
_IQcanBecomeFirstResponder = textView.isEditable
}
if _IQcanBecomeFirstResponder == true {
_IQcanBecomeFirstResponder = (isUserInteractionEnabled == true && isHidden == false && alpha != 0.0 && isAlertViewTextField() == false && isSearchBarTextField() == false) as Bool
}
return _IQcanBecomeFirstResponder
}
///-------------------------
/// MARK: Special TextFields
///-------------------------
/**
Returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
*/
public func isSearchBarTextField()-> Bool {
var searchBar : UIResponder? = self.next
var isSearchBarTextField = false
while searchBar != nil && isSearchBarTextField == false {
if searchBar!.isKind(of: UISearchBar.self) {
isSearchBarTextField = true
break
} else if searchBar is UIViewController {
break
}
searchBar = searchBar?.next
}
return isSearchBarTextField
}
/**
Returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
*/
public func isAlertViewTextField()->Bool {
var alertViewController : UIResponder? = self.viewController()
var isAlertViewTextField = false
while alertViewController != nil && isAlertViewTextField == false {
if alertViewController!.isKind(of: UIAlertController.self) {
isAlertViewTextField = true
break
}
alertViewController = alertViewController?.next
}
return isAlertViewTextField
}
///----------------
/// MARK: Transform
///----------------
/**
Returns current view transform with respect to the 'toView'.
*/
public func convertTransformToView(_ toView:UIView?)->CGAffineTransform {
var newView = toView
if newView == nil {
newView = window
}
//My Transform
var myTransform = CGAffineTransform.identity
if let superView = superview {
myTransform = transform.concatenating(superView.convertTransformToView(nil))
} else {
myTransform = transform
}
var viewTransform = CGAffineTransform.identity
//view Transform
if let unwrappedToView = newView {
if let unwrappedSuperView = unwrappedToView.superview {
viewTransform = unwrappedToView.transform.concatenating(unwrappedSuperView.convertTransformToView(nil))
}
else {
viewTransform = unwrappedToView.transform
}
}
//Concating MyTransform and ViewTransform
return myTransform.concatenating(viewTransform.inverted())
}
///-----------------
/// TODO: Hierarchy
///-----------------
// /**
// Returns a string that represent the information about it's subview's hierarchy. You can use this method to debug the subview's positions.
// */
// func subHierarchy()->NSString {
//
// }
//
// /**
// Returns an string that represent the information about it's upper hierarchy. You can use this method to debug the superview's positions.
// */
// func superHierarchy()->NSString {
//
// }
//
// /**
// Returns an string that represent the information about it's frame positions. You can use this method to debug self positions.
// */
// func debugHierarchy()->NSString {
//
// }
fileprivate func depth()->Int {
var depth : Int = 0
if let superView = superview {
depth = superView.depth()+1
}
return depth
}
}
extension NSObject {
public func _IQDescription() -> String {
return "<\(self) \(Unmanaged.passUnretained(self).toOpaque())>"
}
}
| [
284991,
222694,
327752,
192233,
380267,
248525,
213326,
229263,
185456,
34542,
201618,
242367,
381401,
229533,
144446,
297919
] |
8cc74d3e849ee3f4ca8ea686385f33825ac90754 | 4e753739ea4b0d8f1d478760f035a26ce4c72127 | /Zalora TestingTests/Zalora_TestingTests.swift | 947fbbc96a0a60de5c40ac03fa902e251859b98e | [] | no_license | baohung02/Split-String-by-length | 63ac6ac1344ac778f3500b5776a4e778ef38efc6 | b6ffb7fd175569494415d6bf517d556edcc39369 | refs/heads/master | 2021-01-01T17:26:22.509059 | 2017-07-24T04:23:15 | 2017-07-24T04:23:15 | 98,074,239 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,111 | swift | //
// Zalora_TestingTests.swift
// Zalora TestingTests
//
// Created by Jack on 7/22/17.
// Copyright © 2017 Htuinngh. All rights reserved.
//
import XCTest
@testable import Zalora_Testing
class Zalora_TestingTests: 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 testSplitStringResultCount() {
// Sorry, I dont have exp for unit test
let inputString = "I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself.I can't believe Tweeter now supports chunking my messages, so I don't have to do it myself."
let messages = inputString.splitByLength(Config.limitedLength)
XCTAssertEqual(messages.count, 20, "Split message get wrong result")
for message in messages {
XCTAssertLessThanOrEqual(message.characters.count, Config.limitedLength, "Split message get wrong expect result")
}
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
| [
-1
] |
5f2bec122a6eaa28e95bde7abd30f30be30d44f0 | c34578670331c61b12ee211763e7a115beff845e | /SwimiTests/MIDI/Events/ChannelPressureSpec.swift | d3a8251e0f5d631116bb211ba995e0fb0ef2a081 | [
"MIT"
] | permissive | kainosk/Swimi | 486fec8c56174f37e47f3dd65969f24d647894ec | fdfb83762e583c9809b818c257976164b5f12b77 | refs/heads/main | 2022-08-28T08:21:09.763316 | 2022-07-27T08:19:30 | 2022-07-27T08:19:30 | 212,959,099 | 10 | 2 | MIT | 2022-07-27T08:19:31 | 2019-10-05T07:09:57 | Swift | UTF-8 | Swift | false | false | 1,545 | swift | //
// ChannelPressureSpec.swift
// SwimiTests
//
// Created by kai on 2020/09/15.
//
import Foundation
import Quick
import Nimble
@testable import Swimi
class ChannelPressureSpec: QuickSpec {
override func spec() {
describe("init") {
it("can be initialized with channel and pressure") {
_ = ChannelPressure(channel: 0, pressure: 123)
}
it("returns passed channel as is") {
expect(ChannelPressure(channel: 0, pressure: 123).channel) == 0
}
it("returns passed pressure as is") {
expect(ChannelPressure(channel: 5, pressure: 99).pressure) == 99
}
}
describe("bytes") {
it("returns (status type D0 | channel), pressure") {
expect(ChannelPressure(channel: 9, pressure: 126).bytes) == [
0xD0 | 9,
126
]
}
}
describe("fromData") {
context("data length is 2") {
it("returns an instance which has second byte as song number") {
expect(ChannelPressure.fromData([0xDF, 0x60]))
== ChannelPressure(channel: 0x0F, pressure: 0x60)
}
}
context("data length is not 2") {
it("assert") {
expect {
_ = ChannelPressure.fromData([0x00])
}.to(throwAssertion())
}
}
}
}
}
| [
-1
] |
804a5f4c1b70784c0e9646a83a6a250560bb43f3 | 34939cbef825ad964f758ef80d27bc280744b7ba | /Cidaas/Classes/V2/Verification/Models/AuthenticatedHistoryResponse.swift | 62f2ed715061f3113185d768a8140fb0de1d2a61 | [
"MIT"
] | permissive | Cidaas/cidaas-sdk-ios-v2 | aaf72d2450aabfa3ac45ef22d77708af5b3f9b61 | 5f9dbd5205d55f90f3c50026ba1bb6cb27602c7a | refs/heads/master | 2023-08-05T02:44:13.563391 | 2023-07-27T09:51:16 | 2023-07-27T09:51:16 | 143,137,909 | 3 | 4 | MIT | 2021-01-08T11:32:32 | 2018-08-01T09:59:19 | Swift | UTF-8 | Swift | false | false | 3,705 | swift | //
// AuthenticatedHistoryResponse.swift
// Cidaas
//
// Created by ganesh on 23/05/19.
//
import Foundation
public class AuthenticatedHistoryResponse: Codable {
public var success: Bool = false
public var status: Int32 = 0
public var data: [AuthenticatedHistoryResponseData] = []
public init() {
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.success = try container.decodeIfPresent(Bool.self, forKey: .success) ?? false
self.status = try container.decodeIfPresent(Int32.self, forKey: .status) ?? 0
self.data = try container.decodeIfPresent([AuthenticatedHistoryResponseData].self, forKey: .data) ?? []
}
}
public class AuthenticatedHistoryResponseData: Codable {
public var sub : String = ""
public var _id: String = ""
public var device_info: PushDeviceInformation = PushDeviceInformation()
public var location_details: LocationDetails = LocationDetails()
public var auth_time: String = ""
public init() {
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.sub = try container.decodeIfPresent(String.self, forKey: .sub) ?? ""
self._id = try container.decodeIfPresent(String.self, forKey: ._id) ?? ""
self.device_info = try container.decodeIfPresent(PushDeviceInformation.self, forKey: .device_info) ?? PushDeviceInformation()
self.auth_time = try container.decodeIfPresent(String.self, forKey: .auth_time) ?? ""
self.location_details = try container.decodeIfPresent(LocationDetails.self, forKey: .location_details) ?? LocationDetails()
}
}
public class LocationDetails: Codable {
public var ipaddress_info: IPAddressDetails = IPAddressDetails()
public var _id: String = ""
public var createdTime: String = ""
public var updatedTime: String = ""
public init() {
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.ipaddress_info = try container.decodeIfPresent(IPAddressDetails.self, forKey: .ipaddress_info) ?? IPAddressDetails()
self._id = try container.decodeIfPresent(String.self, forKey: ._id) ?? ""
self.createdTime = try container.decodeIfPresent(String.self, forKey: .createdTime) ?? ""
self.updatedTime = try container.decodeIfPresent(String.self, forKey: .updatedTime) ?? ""
}
}
public class IPAddressDetails: Codable {
public var ipAddress: String = ""
public var location: Location = Location()
public init() {
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.ipAddress = try container.decodeIfPresent(String.self, forKey: .ipAddress) ?? ""
self.location = try container.decodeIfPresent(Location.self, forKey: .location) ?? Location()
}
}
public class Location: Codable {
public var address: PushAddress = PushAddress()
public var lat: String = ""
public var lon: String = ""
public init() {
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.address = try container.decodeIfPresent(PushAddress.self, forKey: .address) ?? PushAddress()
self.lat = try container.decodeIfPresent(String.self, forKey: .lat) ?? ""
self.lon = try container.decodeIfPresent(String.self, forKey: .lon) ?? ""
}
}
| [
-1
] |
8034063a6b92a8d13932db55a40ba6a10bf89ad6 | 3ab88f256e0db7ca4f40c919fc871a6aa15193a2 | /TestWeather/Classes/ViewModels/Implementations/SearchLocationsViewModelImpl.swift | 5bbb96cc26da22f1aeabc7a9bea3eae806d59a3c | [] | no_license | avladut/TestWeather | 14786b8d65a3456f4e205367b373bb1511c176ad | 206799e17e8ff684041756f7fb23889b25b12080 | refs/heads/master | 2020-07-13T05:36:19.792382 | 2019-09-05T06:34:55 | 2019-09-05T06:34:55 | 205,005,345 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,549 | swift | //
// SearchLocationsViewModelImpl.swift
// TestWeather
//
// Created by Alex on 29/08/2019.
// Copyright © 2019 Alex. All rights reserved.
//
import Foundation
import RxSwift
import RxCocoa
class SearchLocationsViewModelImpl {
let searchPlacesAPI = SearchLocationInteractorImpl.getInstance()
let coreDataInteractor = CoreDataInteractorImpl.getInstanceWithManagedContext((UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext)
private let disposeBag = DisposeBag()
private var searchLocations: [LocationSearchModel] = []
let searchText = BehaviorRelay(value: "")
func searchLocation(pattern: String) -> ObservableLocations {
let locations = BehaviorRelay<[SearchLocationCellViewModel]>(value: [])
searchPlacesAPI.searchLocationsStartingWith(pattern).subscribe(onNext: {[weak self] (locationsList) in
self?.searchLocations = locationsList
guard locationsList.count > 0 else {
locations.accept([])
return
}
locations.accept(locationsList.compactMap({ (locationSearchModel) -> SearchLocationCellViewModel? in
return SearchLocationCellViewModelImpl(locationSearchModel)
}))
}, onError: { (err) in
print("in observable error \(err.localizedDescription)")
}, onCompleted: {
print("in observable completed ")
}, onDisposed: {
print("in observable disposed")
}).disposed(by: disposeBag)
return locations.asObservable()
}
}
extension SearchLocationsViewModelImpl: SearchLocationsViewModel {
var searchString: BehaviorRelay<String> {
get {
return searchText
}
}
var searchLocationsResult: Driver<[SearchLocationCellViewModel]> {
get {
return self.searchText.asObservable()
.throttle(.milliseconds(1500), scheduler: MainScheduler.instance)
.distinctUntilChanged()
.flatMapLatest(self.searchLocation)
.asDriver(onErrorJustReturn: [])
}
}
func selectLocationAtIndex(index: Int) throws {
guard index < searchLocations.count else {
throw GeneralError.indexOutOfBounds
}
do {
try coreDataInteractor.saveLocation(location: searchLocations[index])
} catch let error {
throw error
}
}
}
| [
-1
] |
72bedbea737f586519c9448df7f310a02942811b | a839d714e9e5c9962fa73b4e876af12c9102cc46 | /PatientDetail/ViewController.swift | 002de8ce9a5d815c88a3ae26ecda5a38b8abf888 | [
"Apache-2.0"
] | permissive | akhilraj-qb/PatientDetailModule | e23319b625d90702f428988ae3ef6691c6a833c0 | 6762ca3cdc028291c7fd601c433d96489ea70cad | refs/heads/master | 2021-03-27T14:57:20.713486 | 2017-08-21T05:34:52 | 2017-08-21T05:34:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 889 | swift | //
// ViewController.swift
// PatientDetail
//
// Created by Akhilraj on 27/07/17.
// Copyright © 2017 QBurst. All rights reserved.
//
import UIKit
import AppModules
//import PatientDetailModule
class ViewController: UIViewController {
let moduleConnector = ModuleConnector()
@IBOutlet weak var patientIdField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
moduleConnector.mount(module: DetailModule())
}
@IBAction func showDetails(_ sender: Any) {
let patient = self.patientIdField.text
guard let url = URL(string: "PatientDetail://patientDetailVC?patientID=\(patient ?? "")") ,
let viewController = moduleConnector.get(url: url) as? UIViewController
else { return }
navigationController?.pushViewController(viewController, animated: true)
}
}
| [
-1
] |
0b29f182c3bbd6dcbe9d83e1abda07d16cfea692 | b1243578ebe7353262e4004a0b9ba7902ea7fa58 | /Mini Challenge III/Model/Goal/GoalCore+ClassCoreData.swift | f2b387e75e9ac541fae6dda3708a03da2d4c984e | [] | no_license | ViniciusDeep/Mini-Challenge-III | 2657824a4d7ed63d101c04b06f79d5e745c5f1ae | 519f82581c291e8b10790d9b4677fad68ff4090c | refs/heads/master | 2020-05-16T05:15:17.150569 | 2019-08-07T18:41:50 | 2019-08-07T18:41:50 | 182,808,626 | 4 | 0 | null | 2019-05-29T01:32:02 | 2019-04-22T14:48:55 | Swift | UTF-8 | Swift | false | false | 278 | swift | //
// GoalCore+CoreDataClass.swift
// Mini Challenge III
//
// Created by Vinicius Mangueira Correia on 21/05/19.
// Copyright © 2019 Vinicius Mangueira Correia. All rights reserved.
//
//
import Foundation
import CoreData
public class GoalCore: NSManagedObject {
}
| [
-1
] |
53658f4876e3e786825af4f94bec148b3f404390 | 8c36df794dff4cd3c7efbdba7e8604538ac1835e | /Pods/Cache/Source/Shared/Extensions/NSData+Cache.swift | c1f1ec29c6a773aa54b96598db675324b7b4123a | [
"MIT"
] | permissive | laizhenwei/CNode | bc89db402dd75b97329ef80587979d4875f5bdc9 | ed9e3395f0a2e15f05fa73a6d3b8c94527f11e74 | refs/heads/master | 2021-06-03T04:45:05.265722 | 2016-06-30T10:17:58 | 2016-06-30T10:17:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 426 | swift | import Foundation
// MARK: - Cachable
/**
Implementation of Cachable protocol.
*/
extension NSData: Cachable {
public typealias CacheType = NSData
/**
Creates an instance from NSData
- Parameter data: Data to decode from
*/
public static func decode(data: NSData) -> CacheType? {
return data
}
/**
Encodes an instance to NSData
*/
public func encode() -> NSData? {
return self
}
}
| [
158536,
158538
] |
675252267ec8781899df94a70e5bb09991734905 | 5e19ca4fca9f95f20b12d2f1454d5e32aa3db3fd | /Extras/Extensions.swift | c29bd8592db6f2db83b3ddb2856a865f9accd41d | [] | no_license | axy1976/EvenOdd | 0cd8676aee61f5a2a12124bfb2c2c849f2596080 | 1a8b558de926f23c150b6c64c9a60583f5ca8f4f | refs/heads/main | 2023-06-01T11:44:15.149964 | 2021-06-15T03:25:34 | 2021-06-15T03:25:34 | 376,223,393 | 1 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 504 | swift | //
// Extensions.swift
// EvenOdd
//
// Created by akshay on 14/06/21.
//
import Foundation
import UIKit
extension UIView {
public var width: CGFloat{ return frame.size.width }
public var height: CGFloat{ return frame.size.height }
public var top: CGFloat{ return frame.origin.y }
public var bottom: CGFloat{ return frame.origin.y + frame.size.height }
public var left: CGFloat{ return frame.origin.x }
public var right: CGFloat{ return frame.origin.x + frame.size.width }
}
| [
-1
] |
b1ff278c51f1f22d5af27339624cc3374cbe6922 | b5049170753e1e6d750585d2b0f01764ebfb7b72 | /TestTaskSaveliyRadchyck/Services/Network/BaseNetworkService.swift | 50477bbaa096247d1a875a5d87f426b5db2729d5 | [] | no_license | SaveliyRadchyck/TestTaskSaveliyRadchyck | 550f02ed7efb154fec03a9ae0b7eea186be8d5fe | 61fc7a52b08beeb5f086e5440bd9299736aacb3b | refs/heads/master | 2020-12-10T15:57:23.036623 | 2020-01-17T12:16:54 | 2020-01-17T12:16:54 | 233,638,791 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 3,212 | swift | //
// BaseNetworkService.swift
// TestTaskSaveliyRadchyck
//
// Created by Saveliy Radchyck on 1/10/20.
// Copyright © 2020 Saveliy Radchyck. All rights reserved.
//
import Foundation
import Alamofire
protocol BaseNetworkServiceProtocol {
var headers: HTTPHeaders { get }
func request(urlEndpoint: URLEndpointProtocol, method: HTTPMethod) -> Request
func request(url: URLConvertible, method: HTTPMethod, parameters: Parameters?) -> Request
}
private extension HTTPMethod {
var encoding: ParameterEncoding {
switch self {
case .get: return URLEncoding.queryString
default: return JSONEncoding.default
}
}
}
class BaseNetworkService: BaseNetworkServiceProtocol {
var headers: HTTPHeaders {
let headers: HTTPHeaders = [:] // Default headers here
return headers
}
func request(urlEndpoint: URLEndpointProtocol, method: HTTPMethod) -> DataRequest {
return self.request(url: kUrlBase + urlEndpoint.endpoint.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlPathAllowed)!,
method: method, parameters: urlEndpoint.parameters)
}
func request(url: URLConvertible, method: HTTPMethod, parameters: Parameters? = nil) -> DataRequest {
return Alamofire.request(url, method: method, parameters: parameters, encoding: method.encoding, headers: self.headers)
}
// MARK: - Error
class func getError(from response: DefaultDataResponse) -> ErrorsDict {
if let data = response.data {
if let errorJSON = data.json {
return BaseNetworkService.parseErrors(json: errorJSON)
}
if let errorString = String.init(data: data, encoding: .utf8) {
return ErrorsDict.init(errorMessage: errorString)
}
}
if let error = response.error {
return ErrorsDict.init(error: error)
}
return ErrorsDict.init(error: NetworkErrorManager.serverError)
}
class func parseErrors<T : Any>(response: Response<T>) -> ErrorsDict? {
guard let json = response.data?.json else {
return ErrorsDict.init(error: NetworkErrorManager.parsingError)
}
return parseErrors(json: json)
}
class func parseErrors(json: JSON) -> ErrorsDict {
var errors: ErrorsDict = [:]
for (key, value) in json {
if let stringValue = value as? String {
errors[key] = AppError.custom(text: stringValue)
break
}
if let stringArrayValue = value as? Array<String> {
errors[key] = AppError.custom(text: stringArrayValue.first(where: { $0.isBlank == false }) ?? .empty)
break
}
if let jsonValue = value as? JSON {
errors.append(contentsOf: parseErrors(json: jsonValue))
break
}
if let jsonArrayValue = value as? Array<JSON> {
jsonArrayValue.forEach({ errors.append(contentsOf: parseErrors(json: $0)) })
break
}
}
return errors
}
}
| [
-1
] |
d789259d63c2aba9bcf1ea93506b378c327c6c95 | bdbfd935c0b2ed272429b1ff25b262a7882eb401 | /TopMoviesTests/State/MoviesUpdateStateSpec.swift | d038c18e7b98f1404945f7d68d097900ab239f78 | [] | no_license | santaarturio/TopMovies | 47fe291c20daf9fc79adf82f9f227223fd1084df | 460488bcafa72865f8eb3abd85c016e3f761c1d5 | refs/heads/main | 2023-04-17T14:26:22.505329 | 2021-04-21T22:10:29 | 2021-04-21T22:10:29 | 333,761,463 | 0 | 0 | null | 2021-04-25T19:49:31 | 2021-01-28T13:06:03 | Swift | UTF-8 | Swift | false | false | 2,639 | swift | //
// MoviesUpdateStateSpec.swift
// TopMoviesTests
//
// Created by Macbook Pro on 24.03.2021.
//
@testable import TopMovies
import Quick
import Nimble
class MoviesUpdateStateSpec: QuickSpec {
override func spec() {
describe("MoviesUpdateStateSpec") {
var state: MoviesUpdateState!
beforeEach {
state = .init(relational: [:])
}
context("request movie update action should be reduced") {
it("should add or update key&value pair into relational with value .requested") {
let action = RequestMovieUpdateAction(movieId: mockMoviePreview.id)
state = MoviesUpdateState.reduce(action: action, state: state)
expect(state.relational.count) == 1
expect(state.relational[mockMoviePreview.id]?.isRequested).to(beTrue())
}
}
context("downloading movie update action should be reduced") {
it("should add or update key&value pair into relational with value .downloading") {
let action = DownloadingMovieUpdateAction(movieId: mockMoviePreview.id)
state = MoviesUpdateState.reduce(action: action, state: state)
expect(state.relational.count) == 1
expect(state.relational[mockMoviePreview.id]?.isDownloading).to(beTrue())
}
}
context("completed movie update action should be reduced") {
it("should add or update key&value pair into relational with value .isInitial") {
let action = CompletedMovieUpdateAction(movie: mockUpdatedMovie)
state = MoviesUpdateState.reduce(action: action, state: state)
expect(state.relational.count) == 1
expect(state.relational[mockMoviePreview.id]?.isInitial).to(beTrue())
}
}
context("failed movie detail action should be reduced") {
it("should add or update key&value pair into relational with value .failed(error)") {
let mockError = MockError(description: "failed movie update error")
let action = FailedMovieUpdateAction(movieId: mockMoviePreview.id,
error: mockError)
state = MoviesUpdateState.reduce(action: action, state: state)
expect(state.relational.count) == 1
let storedError = state.relational[mockMoviePreview.id]?.failed
expect({
guard
let myError = storedError as? MockError,
myError.description == mockError.description
else { return { .failed(reason: "wrong error associated value") } }
return { .succeeded }
}).to(succeed())
}
}
}
}
}
| [
-1
] |
ed8cf4e6c7feaffcaaee35d12907c88ae0ed524e | 7c7b7a2c52f515fe4271531c692112bc1daea5a9 | /WeatherViewController.swift | 8d221d8d82cba5900943a98c79a6baf2f2e8b0f4 | [] | no_license | arwebber/ChatApp | 4b775df641be33298a5ab34fc4d5115b0e1ec477 | b0fd9eaf811e7fe7a19aacaa97aa4afc36c811eb | refs/heads/master | 2021-07-12T12:10:32.260460 | 2017-10-08T21:30:55 | 2017-10-08T21:30:55 | 106,211,357 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,216 | swift | //
// WeatherViewController.swift
// ChatApp
//
// Created by Andrew Webber on 10/8/17.
// Copyright © 2017 Andrew Webber. All rights reserved.
//
import UIKit
import Firebase
class WeatherViewController: 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.
}
@IBOutlet weak var lblWelcome: UILabel!
@IBOutlet weak var btnSunny: UIButton!
@IBOutlet weak var btnFoggy: UIButton!
@IBAction func btnSunny_TouchUpInside(_ sender: Any) {
weatherNodeRef.setValue("Sunny")
}
@IBAction func btnFoggy_TouchUpInside(_ sender: Any) {
weatherNodeRef.setValue("Foggy")
}
let weatherNodeRef = FIRDatabase.database().reference().child("weatherCondition")
override func viewDidAppear(_ animated: Bool) {
weatherNodeRef.observe(.value, with: { (snapshot: FIRDataSnapshot) in
self.lblWelcome.text = (snapshot.value as AnyObject).debugDescription
})
}
}
| [
-1
] |
6e8f9a5a5e3dd4be68c46bd94edf93e535bc2204 | b285da95757a79237ebd0cf8adb571449b651bdc | /Markdown/内容/NoteManager.swift | c328171cc5023a5c5bfccb2a0144a239ed297726 | [] | no_license | ganyi0127/markdown | 414d300f27b8b9d007f9ee57fa54ba9d015e5ea5 | e6c59021a83a7a586235eb1774ca9d64800e2553 | refs/heads/master | 2021-09-20T17:32:50.082692 | 2018-08-13T13:59:38 | 2018-08-13T13:59:38 | 108,105,721 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 5,484 | swift | //
// NoteManager.swift
// Markdown
//
// Created by YiGan on 17/12/2017.
// Copyright © 2017 YiGan. All rights reserved.
//
import Foundation
//根据时间划分类型
enum NoteType {
case past([Note])
case today([Note])
case future([Note])
//返回标题
func name() -> String{
var result = ""
switch self {
case .past(_):
result = "历史"
case .today(_):
result = "今日"
case .future(_):
result = "往后"
}
return result
}
//返回数组
func list() -> [Note]{
var noteList = [Note]()
switch self {
case .past(let list):
noteList = list
case .today(let list):
noteList = list
case .future(let list):
noteList = list
}
return noteList
}
}
//根据时间分类
func sortAndEnumNotesByDate(withOriginNotes originNotes: [Note]) -> [NoteType]{
var resultList = [NoteType]()
let pastList = originNotes.filter { (note) -> Bool in
guard let beginDate = note.beginDate, note.hasDate else{
return false
}
var component = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date())
component.hour = 0
component.minute = 0
component.second = 0
let today = calendar.date(from: component) ?? Date()
let result = beginDate.compare(today)
return result == ComparisonResult.orderedAscending
}
let sortPastList = sortNotesByDate(withOriginNotes: pastList)
if !sortPastList.isEmpty{
resultList.append(NoteType.past(sortPastList))
}
let todayList = originNotes.filter { (note) -> Bool in
guard let beginDate = note.beginDate, note.hasDate else{
return true
}
return beginDate.isToday()
}
let todaySortList = sortNotesByDate(withOriginNotes: todayList)
if !todaySortList.isEmpty{
resultList.append(NoteType.today(todaySortList))
}
let futureList = originNotes.filter { (note) -> Bool in
guard let beginDate = note.beginDate, note.hasDate else{
return false
}
var component = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date())
component.hour = 0
component.minute = 0
component.second = 0
let today = calendar.date(from: component)?.offset(with: 1) ?? Date().offset(with: 1)
let result = beginDate.compare(today)
return result == ComparisonResult.orderedDescending
}
let futureSortList = sortNotesByDate(withOriginNotes: futureList)
if !futureSortList.isEmpty{
resultList.append(NoteType.future(futureSortList))
}
return resultList
}
typealias YearTuple = (year: Int, notes: [Note])
///根据年份分类
func getYearTupleList(closure: @escaping ([YearTuple])->()) {
DispatchQueue.global().async {
let dataHandler = CoredataHandler.share()
let noteList = dataHandler.selectNotes()
//升序
let sortedNoteList = noteList.sorted { (note0, note1) -> Bool in
let noteDate0 = note0.beginDate ?? note0.date!
let noteDate1 = note1.beginDate ?? note1.date!
let result = noteDate0.compare(noteDate1)
if result == ComparisonResult.orderedAscending{
return true
}
return false
}
guard let firstNote = sortedNoteList.first,
let lastNote = sortedNoteList.last else{
DispatchQueue.main.async {
closure([])
}
return
}
let firstDate = firstNote.beginDate ?? firstNote.date!
let firstYear = calendar.component(.year, from: firstDate)
let lastDate = lastNote.beginDate ?? lastNote.date!
let lastYear = calendar.component(.year, from: lastDate)
var resultList = [YearTuple]()
for year in firstYear...lastYear{
let thisYearNoteList = sortedNoteList.filter({ (note) -> Bool in
let date = note.beginDate ?? note.date!
let y = calendar.component(.year, from: date)
return y == year
})
if !thisYearNoteList.isEmpty{
resultList.append((year: year, notes: thisYearNoteList))
}
}
DispatchQueue.main.async {
closure(resultList)
}
}
}
//根据时间排序
private func sortNotesByDate(withOriginNotes originNotes: [Note]) -> [Note]{
return originNotes.sorted(by: { (note0, note1) -> Bool in
if let beginDate0 = note0.beginDate, let beginDate1 = note1.beginDate{
let result = beginDate0.compare(beginDate1)
if case result = ComparisonResult.orderedAscending{
return true
}else{
return false
}
}else if note0.beginDate != nil{
return true
}else if note1.beginDate != nil{
return false
}else{
let date0 = note0.date!
let date1 = note1.date!
let result = date0.compare(date1)
switch result{
case .orderedAscending:
return true
default:
return false
}
}
})
}
| [
-1
] |
90e87172797b78901bc8862aa22207527f48b407 | 716c5e1f26f18aaad26f52fcf0d6e77110bf8542 | /ShareEducation/Classes/Mine/Controller/CouponListViewController.swift | 36db01f0de2776138973962b8d6cc4e2d9df17fb | [
"MIT"
] | permissive | q195945056/ShareEducation | 62f4a0927a7d907960b44e7b55d5c8fadb9b2690 | f7bb4e687dbea6a66bc30f9e55aefb5011c24fcc | refs/heads/master | 2021-07-21T03:47:04.686591 | 2020-07-28T11:09:44 | 2020-07-28T11:09:44 | 216,769,699 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,596 | swift | //
// CouponListViewController.swift
//
//
// Created by 严明俊 on 2019/12/5.
//
import UIKit
class CouponListViewController: UIViewController {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: true)
}
func setupUI() {
navigationItem.title = "优惠券"
tableView.register(UINib(nibName: "CouponCell", bundle: nil), forCellReuseIdentifier: CouponCell.reuseIdentifier)
}
/*
// 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.
}
*/
}
extension CouponListViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: CouponCell.reuseIdentifier, for: indexPath) as! CouponCell
return cell
}
}
extension CouponListViewController: UITableViewDelegate {
}
| [
-1
] |
9cea41096bbdd2dfd4c398e5650f80b9a8d545f2 | eea3a0c370e0b61c4c0e4a88a4341749af2415ee | /douyuTV/douyuTV/View/PageTitleView/LiveViewCell.swift | 4c5ec3c0fe27c0455718b90709861a2459060777 | [
"MIT"
] | permissive | wuzer/douyuTV | 8f2846a6740721ccdc11d854efb4b3179b17ba36 | b575a41d9eb937aa76f0c2cff6e1d2870bdcf732 | refs/heads/master | 2021-01-17T15:26:19.006191 | 2016-11-07T10:45:59 | 2016-11-07T10:45:59 | 69,867,101 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 4,090 | swift | //
// LiveViewCell.swift
// douyuTV
//
// Created by Jefferson on 2016/10/21.
// Copyright © 2016年 Jefferson. All rights reserved.
//
import UIKit
class LiveViewCell: UICollectionViewCell {
fileprivate lazy var iconView : UIImageView = {
let iconview = UIImageView()
iconview.image = UIImage.init(named: "home_live_cate_normal")
return iconview
}()
fileprivate lazy var titleView : UILabel = {
let titleLabel = UILabel()
titleLabel.text = "中国女孩成都海选"
titleLabel.font = UIFont.systemFont(ofSize: 12)
return titleLabel
}()
fileprivate lazy var userLabel : UILabel = {
let titleLabel = UILabel()
titleLabel.text = "jefferson"
titleLabel.textColor = UIColor.white
titleLabel.font = UIFont.systemFont(ofSize: 12)
return titleLabel
}()
fileprivate lazy var onlineButton : UIButton = {
let onlineButton = UIButton()
onlineButton.setTitle("10000人在线", for: .normal)
onlineButton.titleLabel?.font = UIFont.systemFont(ofSize: 12)
onlineButton.titleLabel?.textColor = UIColor.white
return onlineButton
}()
fileprivate lazy var liveImage : UIImageView = {
let liveImage = UIImageView()
liveImage.image = UIImage.init(named: "Img_default")
liveImage.layer.cornerRadius = 5
liveImage.layer.masksToBounds = true
return liveImage
}()
// model
var anchor: AnchorModel? {
didSet {
guard anchor != nil else { return }
var onlineString: String = ""
if (anchor?.online)! >= 10000 {
onlineString = "\(Int((anchor?.online)! / 10000))在线"
} else {
onlineString = "\((anchor?.online)!)在线"
}
onlineButton.setTitle(onlineString, for: .normal)
// nickname
userLabel.text = anchor?.nickname
// icon
guard let iconUrl = URL.init(string: (anchor?.vertical_src)!) else { return }
liveImage.kf.setImage(with: iconUrl, placeholder: UIImage.init(named: "Img_default"))
titleView.text = anchor?.room_name
}
}
override init(frame: CGRect) {
super.init(frame: frame)
setupSubviews()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension LiveViewCell {
func setupSubviews() {
addSubview(liveImage)
addSubview(iconView)
addSubview(titleView)
liveImage.addSubview(userLabel)
liveImage.addSubview(onlineButton)
iconView.snp.makeConstraints { (make) in
make.left.equalToSuperview()
make.bottom.equalToSuperview().offset(-5)
make.size.equalTo(CGSize(width: 14, height: 14))
}
titleView.snp.makeConstraints { (make) in
make.left.equalTo(iconView.snp.right).offset(5)
make.centerY.equalTo(iconView.snp.centerY)
make.height.equalTo(21)
make.right.equalToSuperview().offset(-10)
}
liveImage.snp.makeConstraints { (make) in
make.top.left.right.equalToSuperview()
make.bottom.equalTo(iconView.snp.top).offset(-5)
}
userLabel.snp.makeConstraints { (make) in
make.left.equalToSuperview().offset(5)
make.bottom.equalToSuperview().offset(-3)
make.height.equalTo(20)
make.width.lessThanOrEqualTo(100)
}
onlineButton.snp.makeConstraints { (make) in
make.right.equalToSuperview().offset(-5)
make.bottom.equalToSuperview().offset(-3)
make.height.equalTo(20)
make.width.lessThanOrEqualTo(100)
}
}
}
| [
-1
] |
f773cc62573f47a822ae1837690afb87258e0350 | b49bb32eafeea931b86ddfc44ef43c01e81a9128 | /Sources/Foundation/ByteCountFormatter.swift | 70ab9247306ba248018ba5d40d121db34fb83df4 | [
"Apache-2.0",
"Swift-exception"
] | permissive | apple/swift-corelibs-foundation | a70e9d95bc69de33ea26343efde3941c5d4d7c85 | 9f53cc551e065d73b327a80147895822bc8f89e0 | refs/heads/main | 2023-08-18T01:25:02.154068 | 2023-08-11T20:54:56 | 2023-08-11T20:54:56 | 45,863,890 | 5,583 | 1,542 | Apache-2.0 | 2023-09-12T00:47:36 | 2015-11-09T20:12:23 | Swift | UTF-8 | Swift | false | false | 21,298 | swift | // This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
extension ByteCountFormatter {
public struct Units : OptionSet {
public let rawValue : UInt
public init(rawValue: UInt) { self.rawValue = rawValue }
// Specifying any of the following causes the specified units to be used in showing the number.
public static let useBytes = Units(rawValue: 1 << 0)
public static let useKB = Units(rawValue: 1 << 1)
public static let useMB = Units(rawValue: 1 << 2)
public static let useGB = Units(rawValue: 1 << 3)
public static let useTB = Units(rawValue: 1 << 4)
public static let usePB = Units(rawValue: 1 << 5)
public static let useEB = Units(rawValue: 1 << 6)
public static let useZB = Units(rawValue: 1 << 7)
public static let useYBOrHigher = Units(rawValue: 0x0FF << 8)
// Can use any unit in showing the number.
public static let useAll = Units(rawValue: 0x0FFFF)
}
public enum CountStyle : Int {
// Specifies display of file or storage byte counts. The actual behavior for this is platform-specific; on OS X 10.8, this uses the decimal style, but that may change over time.
case file
// Specifies display of memory byte counts. The actual behavior for this is platform-specific; on OS X 10.8, this uses the binary style, but that may change over time.
case memory
// The following two allow specifying the number of bytes for KB explicitly. It's better to use one of the above values in most cases.
case decimal // 1000 bytes are shown as 1 KB
case binary // 1024 bytes are shown as 1 KB
}
}
open class ByteCountFormatter : Formatter {
public override init() {
super.init()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
precondition(coder.allowsKeyedCoding)
if let context = Formatter.Context(rawValue: Int(coder.decodeInt32(forKey: "NSFormattingContext"))) {
self.formattingContext = context
}
self.allowedUnits = Units(rawValue: UInt(coder.decodeInt32(forKey: "NSUnits")))
if let countStyle = CountStyle(rawValue: Int(coder.decodeInt32(forKey: "NSKBSize"))) {
self.countStyle = countStyle
}
self.zeroPadsFractionDigits = coder.decodeBool(forKey: "NSZeroPad")
self.includesActualByteCount = coder.decodeBool(forKey: "NSActual")
// These are written in the reverse sense
self.allowsNonnumericFormatting = !coder.decodeBool(forKey: "NSNoNonnumeric")
self.includesUnit = !coder.decodeBool(forKey: "NSNoUnit")
self.includesCount = !coder.decodeBool(forKey: "NSNoCount")
self.isAdaptive = !coder.decodeBool(forKey: "NSNoAdaptive")
}
open override func encode(with coder: NSCoder) {
super.encode(with: coder)
precondition(coder.allowsKeyedCoding)
// The following have 0 as a sentinel raw value, so check
if self.allowedUnits.rawValue != 0 {
coder.encode(Int32(self.allowedUnits.rawValue), forKey: "NSUnits")
}
if self.countStyle.rawValue != 0 {
coder.encode(Int32(self.countStyle.rawValue), forKey: "NSKBSize")
}
if self.formattingContext.rawValue != 0 {
coder.encode(Int32(self.formattingContext.rawValue), forKey: "NSFormattingContext")
}
if self.zeroPadsFractionDigits {
coder.encode(true, forKey: "NSZeroPad")
}
if self.includesActualByteCount {
coder.encode(true, forKey: "NSActual")
}
// The following have true as their default values, so check and write the reverse sense
if !self.allowsNonnumericFormatting {
coder.encode(true, forKey: "NSNoNonnumeric")
}
if !self.includesUnit {
coder.encode(true, forKey: "NSNoUnit")
}
if !self.includesCount {
coder.encode(true, forKey: "NSNoCount")
}
if !self.isAdaptive {
coder.encode(true, forKey: "NSNoAdaptive")
}
}
/* Specify the units that can be used in the output. If ByteCountFormatter.Units is empty, uses platform-appropriate settings; otherwise will only use the specified units. This is the default value. Note that ZB and YB cannot be covered by the range of possible values, but you can still choose to use these units to get fractional display ("0.0035 ZB" for instance).
*/
open var allowedUnits: Units = []
/* Specify how the count is displayed by indicating the number of bytes to be used for kilobyte. The default setting is ByteCountFormatter.CountStyle.fileCount, which is the system specific value for file and storage sizes.
*/
open var countStyle: CountStyle = .file
/* Choose whether to allow more natural display of some values, such as zero, where it may be displayed as "Zero KB," ignoring all other flags or options (with the exception of ByteCountFormatter.Units.useBytes, which would generate "Zero bytes"). The result is appropriate for standalone output. Default value is YES. Special handling of certain values such as zero is especially important in some languages, so it's highly recommended that this property be left in its default state.
*/
open var allowsNonnumericFormatting: Bool = true
/* Choose whether to include the number or the units in the resulting formatted string. (For example, instead of 723 KB, returns "723" or "KB".) You can call the API twice to get both parts, separately. But note that putting them together yourself via string concatenation may be wrong for some locales; so use this functionality with care. Both of these values are YES by default. Setting both to NO will unsurprisingly result in an empty string.
*/
open var includesUnit: Bool = true
open var includesCount: Bool = true
/* Choose whether to parenthetically (localized as appropriate) display the actual number of bytes as well, for instance "723 KB (722,842 bytes)". This will happen only if needed, that is, the first part is already not showing the exact byte count. If includesUnit or includesCount are NO, then this setting has no effect. Default value is NO.
*/
open var includesActualByteCount: Bool = false
/* Choose the display style. The "adaptive" algorithm is platform specific and uses a different number of fraction digits based on the magnitude (in 10.8: 0 fraction digits for bytes and KB; 1 fraction digits for MB; 2 for GB and above). Otherwise the result always tries to show at least three significant digits, introducing fraction digits as necessary. Default is YES.
*/
open var isAdaptive: Bool = true
/* Choose whether to zero pad fraction digits so a consistent number of fraction digits are displayed, causing updating displays to remain more stable. For instance, if the adaptive algorithm is used, this option formats 1.19 and 1.2 GB as "1.19 GB" and "1.20 GB" respectively, while without the option the latter would be displayed as "1.2 GB". Default value is NO.
*/
open var zeroPadsFractionDigits: Bool = false
/* Specify the formatting context for the formatted string. Default is NSFormattingContextUnknown.
*/
open var formattingContext: Context = .unknown
/* A variable to store the actual bytes passed into the methods. This value is used if the includesActualByteCount property is set.
*/
private var actualBytes: String = ""
/* Create an instance of NumberFormatter for use in various methods
*/
private let numberFormatter = NumberFormatter()
/* Shortcut for converting a byte count into a string without creating an ByteCountFormatter and an NSNumber. If you need to specify options other than countStyle, create an instance of ByteCountFormatter first.
*/
open class func string(fromByteCount byteCount: Int64, countStyle: ByteCountFormatter.CountStyle) -> String {
let formatter = ByteCountFormatter()
formatter.countStyle = countStyle
return formatter.string(fromByteCount: byteCount)
}
/* Convenience method on string(for:):. Convert a byte count into a string without creating an NSNumber.
*/
open func string(fromByteCount byteCount: Int64) -> String {
//Convert actual bytes to a formatted string for use later
numberFormatter.numberStyle = .decimal
actualBytes = numberFormatter.string(from: NSNumber(value: byteCount))!
if countStyle == .decimal || countStyle == .file {
return convertValue(fromByteCount: byteCount, for: decimalByteSize)
} else {
return convertValue(fromByteCount: byteCount, for: binaryByteSize)
}
}
/* Convenience method on string(for:):. Convert a byte count into a string without creating an NSNumber.
*/
open override func string(for obj: Any?) -> String? {
guard let value = obj as? Double else {
return nil
}
return string(fromByteCount: Int64(value))
}
/* This method accepts a byteCount and a byteSize value. Checks to see what range the byteCount falls into and then converts to the units determined by that range. The range to be used is decided by the byteSize parameter. The conversion is done by making use of the divide method.
*/
private func convertValue(fromByteCount byteCount: Int64, for byteSize: [Unit: Double]) -> String {
let byte = Double(byteCount)
if byte == 0, allowsNonnumericFormatting, allowedUnits == [], includesUnit, includesCount {
return partsToIncludeFor(value: "Zero", unit: .KB)
} else if allowedUnits.contains(.useAll) || allowedUnits == [] {
if byte == 1 || byte == -1 {
return formatNumberFor(bytes: byte, unit: .byte)
} else if byte < byteSize[.KB]! && byte > -byteSize[.KB]! {
return formatNumberFor(bytes: byte, unit: .bytes)
} else if byte < byteSize[.MB]! && byte > -byteSize[.MB]! {
return divide(byte, by: byteSize, for: .KB)
} else if byte < byteSize[.GB]! && byte > -byteSize[.GB]! {
return divide(byte, by: byteSize, for: .MB)
} else if byte < byteSize[.TB]! && byte > -byteSize[.TB]! {
return divide(byte, by: byteSize, for: .GB)
} else if byte < byteSize[.PB]! && byte > -byteSize[.PB]! {
return divide(byte, by: byteSize, for: .TB)
} else if byte < byteSize[.EB]! && byte > -byteSize[.EB]! {
return divide(byte, by: byteSize, for: .PB)
} else {
return divide(byte, by: byteSize, for: .EB)
}
}
return valueToUseFor(byteCount: byte, unit: allowedUnits)
}
/*
A helper method to deal with the Option Set, caters for setting an individual value or passing in an array of values.
Returns the correct value based on the units that are allowed for use.
*/
private func valueToUseFor(byteCount: Double, unit: ByteCountFormatter.Units) -> String {
var byteSize: [Unit: Double]
//Check to see whether we're using 1000bytes per KB or 1024 per KB
if countStyle == .decimal || countStyle == .file {
byteSize = decimalByteSize
} else {
byteSize = binaryByteSize
}
if byteCount == 0, allowsNonnumericFormatting, includesCount, includesUnit {
return partsToIncludeFor(value: "Zero", unit: .KB)
}
//Handles the cases where allowedUnits is set to a specific individual value. e.g. allowedUnits = .useTB
switch allowedUnits {
case .useBytes: return partsToIncludeFor(value: actualBytes, unit: .bytes)
case .useKB: return divide(byteCount, by: byteSize, for: .KB)
case .useMB: return divide(byteCount, by: byteSize, for: .MB)
case .useGB: return divide(byteCount, by: byteSize, for: .GB)
case .useTB: return divide(byteCount, by: byteSize, for: .TB)
case .usePB: return divide(byteCount, by: byteSize, for: .PB)
case .useEB: return divide(byteCount, by: byteSize, for: .EB)
case .useZB: return divide(byteCount, by: byteSize, for: .ZB)
case .useYBOrHigher: return divide(byteCount, by: byteSize, for: .YB)
default: break
}
//Initialise an array that will hold all the units we can use
var unitsToUse: [Unit] = []
//Based on what units have been selected for use, build an array out of them.
if unit.contains(.useBytes) && byteCount == 1 {
unitsToUse.append(.byte)
} else if unit.contains(.useBytes) {
unitsToUse.append(.bytes)
}
if unit.contains(.useKB) {
unitsToUse.append(.KB)
}
if unit.contains(.useMB) {
unitsToUse.append(.MB)
}
if unit.contains(.useGB) {
unitsToUse.append(.GB)
}
if unit.contains(.useTB) {
unitsToUse.append(.TB)
}
if unit.contains(.usePB) {
unitsToUse.append(.PB)
}
if unit.contains(.useEB) {
unitsToUse.append(.EB)
}
if unit.contains(.useZB) {
unitsToUse.append(.ZB)
}
if unit.contains(.useYBOrHigher) {
unitsToUse.append(.YB)
}
var counter = 0
for _ in unitsToUse {
counter += 1
if counter > unitsToUse.count - 1 {
counter = unitsToUse.count - 1
}
/*
The units are appended to the array in ascending order, so if the value for byteCount is smaller than the byteSize value of the next unit
in the Array we use the previous unit. e.g. if byteCount = 1000, and AllowedUnits = [.useKB, .useGB] check to see if byteCount is smaller
than a GB in bytes(pow(1000, 3)) and if so, we'll use the previous unit which is KB in this case.
*/
if byteCount < byteSize[unitsToUse[counter]]! {
return divide(byteCount, by: byteSize, for: unitsToUse[counter - 1])
}
}
return divide(byteCount, by: byteSize, for: unitsToUse[counter])
}
// Coverts the number of bytes to the correct value given a specified unit, then passes the value and unit to formattedValue
private func divide(_ bytes: Double, by byteSize: [Unit: Double], for unit: Unit) -> String {
guard let byteSizeUnit = byteSize[unit] else {
fatalError("Cannot find value \(unit)")
}
let result = bytes/byteSizeUnit
return formatNumberFor(bytes: result, unit: unit)
}
//Formats the byte value using the NumberFormatter class based on set properties and the unit passed in as a parameter.
private func formatNumberFor(bytes: Double, unit: Unit) -> String {
switch (zeroPadsFractionDigits, isAdaptive) {
//zeroPadsFractionDigits is true, isAdaptive is true
case (true, true):
switch unit {
case .bytes, .byte, .KB:
let result = String(format: "%.0f", bytes)
return partsToIncludeFor(value: result, unit: unit)
case .MB:
let result = String(format: "%.1f", bytes)
return partsToIncludeFor(value: result, unit: unit)
default:
let result = String(format: "%.2f", bytes)
return partsToIncludeFor(value: result, unit: unit)
}
//zeroPadsFractionDigits is true, isAdaptive is false
case (true, false):
if unit == .byte || unit == .bytes {
numberFormatter.maximumFractionDigits = 0
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
} else {
if lengthOfInt(number: Int(bytes)) == 3 {
numberFormatter.usesSignificantDigits = false
numberFormatter.maximumFractionDigits = 0
} else {
numberFormatter.maximumSignificantDigits = 3
numberFormatter.minimumSignificantDigits = 3
}
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
}
//zeroPadsFractionDigits is false, isAdaptive is true
case (false, true):
switch unit {
case .bytes, .byte, .KB:
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = 0
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
case .MB:
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = 1
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
default:
let result: String
//Need to add in an extra case for negative numbers as NumberFormatter formats 0.005 to 0 rather than
// 0.01
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = 2
if bytes < 0 {
let negBytes = round(bytes * 100) / 100
result = numberFormatter.string(from: NSNumber(value: negBytes))!
} else {
result = numberFormatter.string(from: NSNumber(value: bytes))!
}
return partsToIncludeFor(value: result, unit: unit)
}
//zeroPadsFractionDigits is false, isAdaptive is false
case (false, false):
if unit == .byte || unit == .bytes {
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = 0
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
} else {
if lengthOfInt(number: Int(bytes)) > 3 {
numberFormatter.maximumFractionDigits = 0
} else {
numberFormatter.maximumSignificantDigits = 3
}
let result = numberFormatter.string(from: NSNumber(value: bytes))
return partsToIncludeFor(value: result!, unit: unit)
}
}
}
// A helper method to return the length of an int
private func lengthOfInt(number: Int) -> Int {
guard number != 0 else {
return 1
}
var num = abs(number)
var length = 0
while num > 0 {
length += 1
num /= 10
}
return length
}
// Returns the correct string based on the includesValue and includesUnit properties
private func partsToIncludeFor(value: String, unit: Unit) -> String {
if includesActualByteCount, includesUnit, includesCount {
switch unit {
case .byte, .bytes: return "\(value) \(unit)"
default: return "\(value) \(unit) (\(actualBytes) \(Unit.bytes))"
}
} else if includesCount, includesUnit {
return "\(value) \(unit)"
} else if includesCount, !includesUnit {
if value == "Zero", allowedUnits == [] {
return "0"
} else {
return value
}
} else if !includesCount, includesUnit {
return "\(unit)"
} else {
return ""
}
}
//Enum containing available byte units
private enum Unit: String {
case byte
case bytes
case KB
case MB
case GB
case TB
case PB
case EB
case ZB
case YB
}
// Maps each unit to it's corresponding value in bytes for decimal
private let decimalByteSize: [Unit: Double] = [.byte: 1, .bytes: 1, .KB: 1000, .MB: pow(1000, 2), .GB: pow(1000, 3), .TB: pow(1000, 4), .PB: pow(1000, 5), .EB: pow(1000, 6), .ZB: pow(1000, 7), .YB: pow(1000, 8)]
// Maps each unit to it's corresponding value in bytes for binary
private let binaryByteSize: [Unit: Double] = [.byte: 1, .bytes: 1, .KB: 1024, .MB: pow(1024, 2), .GB: pow(1024, 3), .TB: pow(1024, 4), .PB: pow(1024, 5), .EB: pow(1024, 6), .ZB: pow(1024, 7), .YB: pow(1024, 8)]
}
| [
-1
] |
292756d80ae8262f7c8757f13f6c69ccb1c9880c | 455264e22aed01d459603643c0cc2e4f3108a11c | /APHRODITE/UITabBarViewController.swift | 8abe361dfdd9fa32231ecf959605c0d62f5b5295 | [] | no_license | sneakyvince/ZIN_EN_ZWANGER_IOS_APP | 54b53c361619f77399b8b9b57cc470fb950da308 | 7f30247e81c06a14fcd0d131fb584cfaec5b46f7 | refs/heads/master | 2021-08-20T06:53:03.805727 | 2017-11-28T12:33:56 | 2017-11-28T12:33:56 | 112,332,934 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,357 | swift | //
// UITabBarViewController.swift
// APHRODITE
//
// Created by Vincent van der Palen on 06-06-16.
// Copyright © 2016 Vincent van der Palen. All rights reserved.
//
import UIKit
class UITabBarViewController: UIViewController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
override func viewDidLoad() {
super.viewDidLoad()
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("tabBar2") as! UITabBarController
nextViewController.selectedIndex = 1;
self.presentViewController(nextViewController, animated:true, completion: nil)
// 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 prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
| [
-1
] |
d96c33024bea33b7464d058fddeeabba6680261f | 63d3ada5de548b2708d9b60dd70c41437d898c76 | /GistDemo/Cell/CommentTableViewCell.swift | 8d53aec101692de38f59fb64fbf31727f3611aa1 | [] | no_license | creativeportfolio-ios/GistDemo | 4686b19204654b65d2fa557738a71f314895f918 | becec8db9b32e7af553b5bd26555d1f097256685 | refs/heads/master | 2020-03-23T04:39:53.988590 | 2018-07-16T12:21:41 | 2018-07-16T12:21:41 | 141,097,716 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,205 | swift |
import UIKit
class CommentTableViewCell: UITableViewCell {
@IBOutlet weak var userImageView: UIImageView!
@IBOutlet weak var userNameLabel: UILabel!
@IBOutlet weak var commentLabel: UILabel!
@IBOutlet weak var commentDateLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
if let _ = self.userImageView {
self.userImageView.layer.cornerRadius = self.userImageView.frame.size.width / 2
self.userImageView.layer.borderColor = UIColor.white.cgColor
self.userImageView.layer.borderWidth = 1.0
self.userImageView.clipsToBounds = true
}
}
func configureCell(comment: GistComment) {
userNameLabel.text = comment.userName ?? ""
commentLabel.text = comment.comment ?? ""
commentDateLabel.text = comment.createdDate?.getCommentTime ?? ""
if let imageUrl = comment.profileUrl {
userImageView.sd_setShowActivityIndicatorView(true)
userImageView.sd_setIndicatorStyle(.gray)
userImageView.sd_setImage(with: URL(string: imageUrl), placeholderImage: UIImage(named: "profile"))
}
}
}
| [
-1
] |
c965065989ac215d3283bd7b203ebb2623d4760f | d8f05b8205443728626b6b43675d4afe57be7091 | /voluxe-driver/voluxe-driver/Controller/Request/InspectionNotesViewController.swift | daa523e1ae812ef0ada7107e06a574abb0b89022 | [] | no_license | JohnNguyen411/JohnTestGithub2 | ddb5308be14b03b4541e03ed9e5a2a8a03777d33 | f77220fcd0847f70ef34a6a8940cde0b9bc5b86e | refs/heads/master | 2020-05-06T15:38:08.232524 | 2019-04-04T21:52:08 | 2019-04-04T21:52:08 | 180,200,511 | 0 | 0 | null | 2019-04-12T22:28:05 | 2019-04-08T17:35:08 | Swift | UTF-8 | Swift | false | false | 4,294 | swift | //
// InspectionNotesViewController.swift
// voluxe-driver
//
// Created by Johan Giroux on 2/1/19.
// Copyright © 2019 Luxe By Volvo. All rights reserved.
//
import Foundation
import UIKit
class InspectionNotesViewController: RequestStepViewController {
private let customerLabel = Label.taskText()
private let serviceLabel = Label.taskText()
private let tallLabel = Label.taskText()
private let pickupNotesLabel = Label.taskText(with: "\(String.localized(.viewInspectNotesDescriptionHint)):")
var originalNotes = ""
private let notesTextField: UITextView = {
let field = UITextView()
field.isEditable = true
field.backgroundColor = .clear
field.textContainer.maximumNumberOfLines = 10
field.textContainer.lineBreakMode = .byTruncatingTail
field.layer.borderWidth = 0.5
field.layer.borderColor = UIColor.Volvo.grey1.cgColor
field.layer.cornerRadius = 5.0
field.font = Font.Intermediate.regular
return field
}()
override func viewDidLoad() {
super.viewDidLoad()
guard let contentView = self.contentView, let scrollView = self.scrollView else {
return
}
scrollView.keyboardDismissMode = .onDrag
contentView.clipsToBounds = false
self.addViews([self.customerLabel, self.serviceLabel])
self.addView(self.pickupNotesLabel, below: self.serviceLabel, spacing: 20)
self.addView(self.notesTextField, below: self.pickupNotesLabel, spacing: 10)
self.notesTextField.constrain(height: 120)
self.notesTextField.layoutIfNeeded()
self.view.layoutSubviews()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let contentView = self.contentView, tallLabel.superview == nil, notesTextField.frame.origin.y > 0 {
let t = self.view.frame.size.height - (notesTextField.frame.origin.y + notesTextField.frame.size.height)
tallLabel.heightAnchor.constraint(equalToConstant: t+2).isActive = true
contentView.addSubview(self.tallLabel)
tallLabel.pinTopToBottomOf(view: notesTextField)
Layout.addSpacerView(pinToBottomOf: tallLabel, pinToSuperviewBottom: true)
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
}
override func fillWithRequest(request: Request) {
super.fillWithRequest(request: request)
self.titleLabel.text = .localized(.inspectVehicles)
self.titleLabel.font = Font.Medium.medium
let customerString = NSMutableAttributedString()
self.customerLabel.attributedText = customerString.append(.localized(.customerColon), with: self.customerLabel.font).append("\(request.booking?.customer.fullName() ?? "")" , with: self.intermediateMediumFont())
if let repairOrders = request.booking?.repairOrderRequests, repairOrders.count > 0 {
let addressString = NSMutableAttributedString()
self.serviceLabel.attributedText = addressString.append(.localized(.serviceColon), with: self.serviceLabel.font).append("\(request.booking?.repairOrderNames() ?? "")" , with: self.intermediateMediumFont())
if let ro = repairOrders.first, let roNotes = ro.notes {
self.originalNotes = roNotes
self.notesTextField.text = roNotes
}
}
}
override func swipeNext(completion: ((Bool) -> ())?) {
// check if notes are updated, and update them if needed, otherwise just continue
if let repairOrders = self.request?.booking?.repairOrderRequests, repairOrders.count > 0,
let repairRequest = repairOrders.first, originalNotes != self.notesTextField.text {
DriverAPI.updateNotes(repairOrderRequestId: repairRequest.id, notes: self.notesTextField.text, completion: { error in
// TODO handle error and queue
super.swipeNext(completion: completion)
})
} else {
super.swipeNext(completion: completion)
}
}
}
| [
-1
] |
674c94d570ce700522b11b23e7a69aefc0ec4f32 | aaa477335d636425a459d28f04650580400798d4 | /TheWeatherApp/StandartViewController.swift | edeca224ad091aafcb0e61ff4d276ac3d4ae41b6 | [] | no_license | rbest15/WeatherRbest15 | 35b513dba42176d871b24c4635ee9d43fd5b5482 | 86ab4a46beeec6bb968b7cbe8baf9f65468e0398 | refs/heads/master | 2020-12-26T20:09:29.137518 | 2020-03-31T17:08:15 | 2020-03-31T17:08:15 | 237,627,735 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 2,883 | swift | import UIKit
class StandartViewController: UIViewController {
@IBOutlet weak var standartTableView: UICollectionView!
@IBOutlet weak var tempLabel: UILabel!
@IBOutlet weak var cityNameLabel: UILabel!
@IBOutlet weak var tableView: UICollectionView!
let cityName = "Krasnodar"
var weatherDecoded: ForecastDecoder?
override func viewDidLoad() {
super.viewDidLoad()
tempLabel.text = "\(Saver.shared.temp)"
weatherUpdater()
}
}
extension StandartViewController: UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return weatherDecoded?.list.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = standartTableView.dequeueReusableCell(withReuseIdentifier: "standartCell", for: indexPath) as! StandartCollectionViewCell
let dt = Double(weatherDecoded?.list[indexPath.row].dt ?? 0)
let date = Date(timeIntervalSince1970: dt)
let dateFormated = DateFormatter()
dateFormated.dateFormat = "MMM dd HH:mm"
cell.dtLabel.text = dateFormated.string(from: date)
cell.tempLabel.text = "\(NSString(format: "%.2f",(weatherDecoded!.list[indexPath.row].main?.temp)! - 273.15))" + " ℃"
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 100, height: 100)
}
}
extension StandartViewController {
func weatherUpdater() {
let api = "399e9ee290d3b3f3a2b179c3162f9b41"
let urlString = "https://api.openweathermap.org/data/2.5/forecast?q=\(cityName)&appid=\(api)"
guard let url = URL(string: urlString) else { return }
URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let data = data else { return }
guard error == nil else { return }
do {
let currentWeather = try JSONDecoder().decode(ForecastDecoder.self, from: data)
self.weatherDecoded = currentWeather
DispatchQueue.main.async {
let normalTemp = "\(NSString(format: "%.2f",(currentWeather.list[0].main?.temp)! - 273.15))" as String
Saver.shared.temp = normalTemp
self.tempLabel.text = normalTemp + " ℃"
self.cityNameLabel.text = self.cityName
self.standartTableView.reloadData()
}
} catch { print("Error after download") }
}.resume()
}
}
| [
-1
] |
6484b20b560fe799eec4ae2aa50ffda71475064e | e36ee02db0f239afd56fa630b065b015a14a4a6a | /二分法-开根号/二分法-开根号/ViewController.swift | 719fd97531e3e6740c688d14cde2dcae416132e5 | [] | no_license | liangxiaosong/Data-structure-in-algorithm | 95b44f99c7eb6617943b558eb107a103ea9e8370 | c0d71c77edc2bbf1b27040d086cbafdb8646f5d0 | refs/heads/master | 2022-04-20T00:06:16.812373 | 2020-04-22T15:22:15 | 2020-04-22T15:22:15 | 257,542,794 | 0 | 0 | null | null | null | null | UTF-8 | Swift | false | false | 1,212 | swift | //
// ViewController.swift
// 二分法-开根号
//
// Created by xj on 2020/3/24.
// Copyright © 2020 xj. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print(String(format: "%.6f", squareRoot(10)))
}
func squareRoot(_ number:Int) -> Double {
var low:Double = 1.0
let num:Double = Double(number)
var hight:Double = Double(number)
var quit:Bool = true
var squaer:Double = 0.0
var count = 0
while quit {
let mid = (hight - low)/2 + low
//为什么不使用 mid * mid > num呢?主要是要堆站溢出
if mid > num / mid {
hight = mid
}else if mid < num / mid {
low = mid
}else {
squaer = mid
quit = false
}
//hight - low < 0.000001 此处确保小数点后精确位数
if hight - low < 0.000001 {
quit = false
squaer = mid
break
}
count += 1
}
print(count)
return squaer
}
}
| [
-1
] |
09945191ba48a26389f71fc09cbf0fa9280288b7 | 122e29049a57a8541d0e9cb06c33abba8bacb336 | /daysleft WatchKit Extension/ComplicationsDataSource.swift | fa16f93098a9d3918519edcd9714fb0a4df76bf9 | [
"MIT"
] | permissive | bravelocation/daysleft | 58a654d696bd5b59ef9b4a4d40eb97df67b98a0d | 9a58ac61096da293eee3f50dfb05a50f8b8a1629 | refs/heads/main | 2022-12-09T09:28:44.245565 | 2022-11-26T10:42:38 | 2022-11-26T10:42:38 | 30,653,727 | 9 | 2 | MIT | 2022-10-03T16:14:18 | 2015-02-11T15:17:21 | Swift | UTF-8 | Swift | false | false | 18,802 | swift | //
// ComplicationsDataSource.swift
// daysleft
//
// Created by John Pollard on 12/10/2015.
// Copyright © 2015 Brave Location Software. All rights reserved.
//
import Foundation
import WatchKit
import ClockKit
// swiftlint:disable type_body_length
/// Legacy complications data source
@available(watchOS, deprecated: 9.0, message: "Remove legacy complications data source once people have updated")
class ComplicationsDataSource: NSObject, CLKComplicationDataSource {
/// App settings
let appSettings = AppSettingsDataManager().appSettings
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
let entry = self.createTimeLineEntry(complication.family, date: Date())
handler(entry)
}
func getNextRequestedUpdateDate(handler: @escaping (Date?) -> Void) {
// Update at the start of tomorrow
let nextUpdate = Date().addDays(1).startOfDay
print("Setting next extension update to be at \(nextUpdate)")
handler(nextUpdate)
}
func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
let mySupportedFamilies = CLKComplicationFamily.allCases
let daysLeftDescriptor = CLKComplicationDescriptor(
identifier: "ComplicationDaysLeft",
displayName: "Count The Days Left",
supportedFamilies: mySupportedFamilies)
handler([daysLeftDescriptor])
}
// swiftlint:disable cyclomatic_complexity
// swiftlint:disable function_body_length
func getLocalizableSampleTemplate(for complication: CLKComplication,
withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
let appTintColor = UIColor(red: 203/255, green: 237/255, blue: 142/255, alpha: 1.0)
switch complication.family {
case .circularSmall:
let template = CLKComplicationTemplateCircularSmallRingText(textProvider: CLKSimpleTextProvider(text: "--"),
fillFraction: 0.7,
ringStyle: CLKComplicationRingStyle.open)
handler(template)
case .modularSmall:
let template = CLKComplicationTemplateModularSmallRingText(textProvider: CLKSimpleTextProvider(text: "--"),
fillFraction: 0.7,
ringStyle: CLKComplicationRingStyle.open)
handler(template)
case .utilitarianSmall:
let template = CLKComplicationTemplateUtilitarianSmallRingText(textProvider: CLKSimpleTextProvider(text: "--"),
fillFraction: 0.7,
ringStyle: CLKComplicationRingStyle.open)
handler(template)
case .utilitarianSmallFlat:
let template = CLKComplicationTemplateUtilitarianSmallFlat(textProvider: CLKSimpleTextProvider(text: "--"))
handler(template)
case .utilitarianLarge:
let template = CLKComplicationTemplateUtilitarianLargeFlat(textProvider: CLKSimpleTextProvider(text: "--"))
handler(template)
case .extraLarge:
let template = CLKComplicationTemplateExtraLargeRingText(textProvider: CLKSimpleTextProvider(text: "--"),
fillFraction: 0.7,
ringStyle: CLKComplicationRingStyle.open)
handler(template)
case .modularLarge:
let template = CLKComplicationTemplateModularLargeStandardBody(headerTextProvider: CLKSimpleTextProvider(text: "Christmas"),
body1TextProvider: CLKSimpleTextProvider(text: "30 days"),
body2TextProvider: CLKSimpleTextProvider(text: "10% done"))
handler(template)
case .graphicBezel:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: 0.1)
let gaugeProvider = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText(gaugeProvider: gauge,
bottomTextProvider: CLKSimpleTextProvider(text: String(format: "%d%%", 10)),
centerTextProvider: CLKSimpleTextProvider(text: String("20")))
let template = CLKComplicationTemplateGraphicBezelCircularText(circularTemplate: gaugeProvider,
textProvider: CLKSimpleTextProvider(text: "20 days until Christmas"))
template.tintColor = appTintColor
handler(template)
case .graphicCorner:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: 0.1)
let template = CLKComplicationTemplateGraphicCornerGaugeText(gaugeProvider: gauge,
outerTextProvider: CLKSimpleTextProvider(text: "20 days"))
template.tintColor = appTintColor
handler(template)
case .graphicCircular:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: 0.1)
let template = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText(gaugeProvider: gauge,
bottomTextProvider: CLKSimpleTextProvider(text: String(format: "%d%%", 10)),
centerTextProvider: CLKSimpleTextProvider(text: "20"))
template.tintColor = appTintColor
handler(template)
case .graphicRectangular:
let template = CLKComplicationTemplateGraphicRectangularStandardBody(headerTextProvider: CLKSimpleTextProvider(text: "Christmas"),
body1TextProvider: CLKSimpleTextProvider(text: "20 days"),
body2TextProvider: CLKSimpleTextProvider(text: String(format: "%d%% done", 0.1)))
template.tintColor = appTintColor
handler(template)
case .graphicExtraLarge:
if #available(watchOS 7, *) {
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: 0.1)
let template = CLKComplicationTemplateGraphicExtraLargeCircularOpenGaugeRangeText(gaugeProvider: gauge,
leadingTextProvider: CLKSimpleTextProvider(text: ""),
trailingTextProvider: CLKSimpleTextProvider(text: ""),
centerTextProvider: CLKSimpleTextProvider(text: "20"))
template.tintColor = appTintColor
handler(template)
}
default:
handler(nil)
}
}
func getPrivacyBehavior(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) {
// Show the complication on the lock screen
handler(CLKComplicationPrivacyBehavior.hideOnLockScreen)
}
// --- Timeline functions ---
func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
print("Getting timeline: \(limit) before \(date)")
var entries: [CLKComplicationTimelineEntry] = []
for i in (1...limit).reversed() {
// Calculate the entry i * 5 mins ago (in chronological order)
let previousDate = date.addingTimeInterval(-1*60*5*Double(i))
let entry = self.createTimeLineEntry(complication.family, date: previousDate)
if entry != nil {
entries.append(entry!)
}
}
handler(entries)
}
func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
print("Getting timeline: \(limit) before \(date)")
var entries: [CLKComplicationTimelineEntry] = []
for i in 1...limit {
// Calculate the entry i x 5 mins ahead
let previousDate = date.addingTimeInterval(60*5*Double(i))
let entry = self.createTimeLineEntry(complication.family, date: previousDate)
if entry != nil {
entries.append(entry!)
}
}
handler(entries)
}
func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
handler([CLKComplicationTimeTravelDirections.backward, CLKComplicationTimeTravelDirections.forward])
}
func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
handler(self.appSettings.start as Date)
}
func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
handler(self.appSettings.end as Date)
}
func getTimelineAnimationBehavior(for complication: CLKComplication,
withHandler handler: @escaping (CLKComplicationTimelineAnimationBehavior) -> Void) {
handler(CLKComplicationTimelineAnimationBehavior.always)
}
// swiftlint:disable cyclomatic_complexity
// swiftlint:disable function_body_length
fileprivate func createTimeLineEntry(_ family: CLKComplicationFamily, date: Date) -> CLKComplicationTimelineEntry? {
let currentDaysLeft: Int = self.appSettings.daysLeft(date)
let percentageDone: Float = (Float(self.appSettings.daysGone(date)) / Float(self.appSettings.daysLength)).clamped(to: 0.0...1.0)
let displayPercentageDone: Int = (Int) (percentageDone * 100)
let appTintColor = UIColor(red: 203/255, green: 237/255, blue: 142/255, alpha: 1.0)
var entry: CLKComplicationTimelineEntry?
switch family {
case .circularSmall:
let template = CLKComplicationTemplateCircularSmallRingText(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)),
fillFraction: percentageDone,
ringStyle: CLKComplicationRingStyle.open)
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .modularSmall:
let template = CLKComplicationTemplateModularSmallRingText(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)),
fillFraction: percentageDone,
ringStyle: CLKComplicationRingStyle.open)
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .utilitarianSmall:
let template = CLKComplicationTemplateUtilitarianSmallRingText(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)),
fillFraction: percentageDone,
ringStyle: CLKComplicationRingStyle.open)
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .utilitarianSmallFlat:
let template = CLKComplicationTemplateUtilitarianSmallFlat(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .utilitarianLarge:
let template = CLKComplicationTemplateUtilitarianLargeFlat(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .extraLarge:
let template = CLKComplicationTemplateExtraLargeRingText(textProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)),
fillFraction: percentageDone,
ringStyle: CLKComplicationRingStyle.open)
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .modularLarge:
let template = CLKComplicationTemplateModularLargeStandardBody(headerTextProvider: CLKSimpleTextProvider(text: self.appSettings.title),
body1TextProvider: CLKSimpleTextProvider(text: String(format: "%d days", currentDaysLeft)),
body2TextProvider: CLKSimpleTextProvider(text: String(format: "%d%% done", displayPercentageDone)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .graphicBezel:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: percentageDone)
let gaugeProvider = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText(gaugeProvider: gauge,
bottomTextProvider: CLKSimpleTextProvider(text: String(format: "%d%%", displayPercentageDone)),
centerTextProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)))
let longDesc = String(format: "%d %@ until %@", currentDaysLeft, self.appSettings.weekdaysOnly ? "weekdays" : "days", self.appSettings.title)
let template = CLKComplicationTemplateGraphicBezelCircularText(circularTemplate: gaugeProvider,
textProvider: CLKSimpleTextProvider(text: longDesc))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .graphicCorner:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: percentageDone)
let daysDesc = String(format: "%d days", currentDaysLeft)
let template = CLKComplicationTemplateGraphicCornerGaugeText(gaugeProvider: gauge,
outerTextProvider: CLKSimpleTextProvider(text: daysDesc))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .graphicCircular:
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: percentageDone)
let template = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText(gaugeProvider: gauge,
bottomTextProvider: CLKSimpleTextProvider(text: String(format: "%d%%", displayPercentageDone)),
centerTextProvider: CLKSimpleTextProvider(text: String(currentDaysLeft)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .graphicRectangular:
let template = CLKComplicationTemplateGraphicRectangularStandardBody(headerTextProvider: CLKSimpleTextProvider(text: self.appSettings.title),
body1TextProvider: CLKSimpleTextProvider(text: String(format: "%d days", currentDaysLeft)),
body2TextProvider: CLKSimpleTextProvider(text: String(format: "%d%% done", displayPercentageDone)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
case .graphicExtraLarge:
if #available(watchOS 7, *) {
let gauge = CLKSimpleGaugeProvider(style: .fill, gaugeColor: appTintColor, fillFraction: 0.1)
let template = CLKComplicationTemplateGraphicExtraLargeCircularOpenGaugeRangeText(gaugeProvider: gauge,
leadingTextProvider: CLKSimpleTextProvider(text: ""),
trailingTextProvider: CLKSimpleTextProvider(text: ""),
centerTextProvider: CLKSimpleTextProvider(text: String(format: "%d", currentDaysLeft)))
template.tintColor = appTintColor
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
}
default:
break
}
return(entry)
}
}
extension Comparable {
func clamped(to limits: ClosedRange<Self>) -> Self {
return min(max(self, limits.lowerBound), limits.upperBound)
}
}
| [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.