blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
625
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
47
| license_type
stringclasses 2
values | repo_name
stringlengths 5
116
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 643
values | visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 80.4k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 16
values | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_language
stringclasses 85
values | src_encoding
stringclasses 7
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 4
6.44M
| extension
stringclasses 17
values | content
stringlengths 4
6.44M
| duplicates
listlengths 1
9.02k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b5f917e2368c6f52ea678cbd6442d240a0bb8a23
|
08b98602ef133c2f77a80c0360920fa7685057fe
|
/GourmetApp/GourmetApp/Domain/Models/BaseRealmModel.swift
|
9234f47909eca4b1e2497ff0e89a963634c759e0
|
[] |
no_license
|
nyanc0/iOS
|
706cec2558245b05ca2412b5902df736ef04b66f
|
66e47432c286f8716a7dd4fe53d11230cab22630
|
refs/heads/master
| 2020-04-07T15:35:00.835908 | 2019-05-10T01:53:56 | 2019-05-10T01:53:56 | 158,491,848 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 345 |
swift
|
//
// BaseRealmModel.swift
// GourmetApp
//
// Created by yurina fukuoka on 2019/03/26.
// Copyright © 2019年 yurina fukuoka. All rights reserved.
//
import Foundation
import RealmSwift
class BaseRealmModel: Object {
@objc dynamic var createdDate: Date = NSDate() as Date
@objc dynamic var updatedDate: Date = NSDate() as Date
}
|
[
-1
] |
cb0a76cfdd5bb43d7beac8aeca4ef7b47e938526
|
83b98b8b50852935c3836d683aba4499949dc32a
|
/Homework-2.playground/Contents.swift
|
cdff70d369716946c94fc5f26a50ec304eb6252f
|
[] |
no_license
|
outdoorsole/cs212
|
0959116e05b2089683a32dc0934f91bd09550e3f
|
9c1a1c9ec78fa3b0e9d9211c286c0e5e6f3d769c
|
refs/heads/master
| 2021-05-10T14:54:31.158058 | 2018-02-06T01:55:26 | 2018-02-06T01:55:26 | 118,534,913 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 7,016 |
swift
|
/*:
---
## 1. Counting nils
The `generateRandomArrayOfIntsAndNils` function creates an array that is a random mix of Int values and nils.
Write code that counts the number of nil values in array1 and prints this number to the debug area
*/
let array1: [Int?]
array1 = generateRandomArrayOfIntsAndNils()
var total: Int = 0
// Your Swift code for question 1 here:
var nilValues = 0
for num in array1 {
if num == nil {
total += 1
}
}
print("Total nil values: \(total)")
print("---------------")
/*:
---
## 2. Mean
Write code that calculates the mean (average) value of the non-nil elements in array2, and prints the mean out to the debug area. Note that the answer might include decimal places.
*/
let array2 = generateRandomArrayOfIntsAndNils()
// Your Swift code for question 2 here:
var numCountArray2 = 0
var sumArray2 = 0
var average: Double
for value in array2 {
if value != nil {
// increment the count of non-nil elements
numCountArray2 += 1
// include value of non-nil element to sum
sumArray2 += value!
}
}
// calculate the average of non-nil elements in array2
average = Double(sumArray2) / Double(numCountArray2)
print("The average is: \(average)")
print("---------------")
/*:
---
## 3. New Array
Write code that adds values to the array named nilFree3 so that it has the same elements
as array3, except without the nil values. The elements in nilFree3 should be
Ints, not Int optionals.
*/
let array3 = generateRandomArrayOfIntsAndNils()
var nilFree3 = [Int]()
// Your Swift code for question 3 here:
for value in array3 {
if value != nil {
nilFree3.append(value!)
}
}
/*:
---
## 4. Airline
There are two dictionaries defined for two different fictional airlines, NorcalAir
and SocalAir named `norcal` and `socal`, respectively, representing the airports and
cities that the two airlines serve.
The key is a String containing the airport code, e.g. "SFO", and the value
is a String containing the name of the city that the airport serves, e.g. "San
Francisco".
NorcalAir has decided to acquire SocalAir and make a new airline called
CaliAir, which serves all of the cities that the existing airlines serve.
Your job is to create a new dictionary named `cali` which contains all
of the cities that CaliAir serves, i.e. all cities that either NorcalAir
or SocalAir serve. If both NorcalAir and SocalAir serve the same city,
`cali` should contain the name of the city from `norcal`. Like the existing
dictionaries, its key and value should both be of type String.
Once you have created `cali`, print out all entries to the debug area. Order
doesn't matter.
Hint: you might want to print out all entries in `norcal` and `socal` first to
see what's in the dictionaries and help verify your answer.
Note: your code should work for any given `norcal` and `socal` dictionaries.
In other words, I should be able add a city to `norcal` and your solution should
still work.
*/
// Your Swift code for question 4 here:
// Create new dictionary
var caliair = [String: String]()
print("NorcalAir airports and cities:")
for (key, value) in norcal {
print("Airport code: \(key), Airport name: \(value)")
// Add NorcalAir airport codes and cities first
caliair[key] = value
}
print("")
print("SocalAir airports and cities:")
for (key, value) in socal {
print("Airport code: \(key), Airport name: \(value)")
}
print("")
for (socalKey, socalValue) in socal {
// Check if CaliAir dictionary already contains airport code (already exists)
if caliair.keys.contains(socalKey) {
// Do nothing, default will be NorcalAir information
} else {
// Create new key in caliair dictionary and add value
caliair[socalKey] = socalValue
}
}
// Print new combined dictionary
print("CaliAir serves the following airports (with codes and cities): \(caliair)")
print("---------------")
/*:
---
## 5. Sort array
Write code that will sort array4 using your own logic. You might want to
review the logic for Selection Sort or Bubble Sort online. Find a sort
algorithm that you like in a language that you are familiar with and then
translate it to Swift. Resist the temptation to find a sort online that
is already written in Swift and copy and paste it. Do not use Swift's sort
method.
Note that array4 is declared with var, so that it is a mutable array, i.e. it
can be modified.
*/
var array4 = generateRandomArrayOfIntsAndNils()
// Your Swift code for question 5 here:
// BUBBLE SORT
// Explanation (from Wikipedia.org):
// start at the beginning of the list
// compare every adjacent pair
// swap the position of the pair if not in the right order
// after each iteration, compare one less element from the list (last item will be the largest)
// Original array:
print("Array4: \(array4)")
// Sorting
print("BUBBLE SORT")
// Create variable that will temporarily store the value to be swapped (smaller value)
var temp: Int?
// Create a variable to store the number of times to pass through the array
// Sort iterations will begin with 1 less than the total array size
var countdown = array4.count - 1
print("Countdown (iterations) starts at: \(countdown)")
// Continue to loop until all unsorted elements have been sorted
while countdown > 0 {
for index in 0..<array4.count {
// // Check to make sure that the last value to compare is within the array range (not out of bounds)
if index + 1 < array4.count {
// Check if both of the elements in the pair are nil
if array4[index] == nil || array4[index + 1] == nil {
if array4[index] == nil && array4[index + 1] == nil {
// 1) Do nothing; both elements are nil, leave them in place.
} else if array4[index] == nil {
// 2) Do nothing, both elements are in the correct order
} else {
// 3) Move the nil element to the left
temp = nil
array4[index + 1] = array4[index]!
array4[index] = temp
}
} else {
// Both elements contain a value
// Compare the two adjacent pairs; see if left value is greater than the value on the right
if array4[index]! > array4[index + 1]! {
// Store the smaller value (value on the right) in the temporary variable
temp = array4[index + 1]
// Replace the value on the right with the value on the left (larger value)
array4[index + 1] = array4[index]
// Replace the value on the left with the smaller value (from the temp variable)
array4[index] = temp
}
}
}
}
// Decrement the iterations after one pass of the entire array is complete
countdown -= 1
}
print("Array after sorting: \(array4)")
|
[
-1
] |
9d45783415a28f32213b12435303a5bfd6008b1b
|
c13a69adda4e076b7a2d11afd0da0081db14e718
|
/PillTimeUITests/PillTimeUITests.swift
|
5513fdc9535e7f9a0628474dbf94a9841773021e
|
[] |
no_license
|
luxorv/PillTime
|
7979913f1f55c19443ba8efdb7773106e1ec7366
|
01becbc6d52e6530434e6532c6472d763bac575b
|
refs/heads/master
| 2020-04-01T21:03:29.697479 | 2016-06-11T17:34:43 | 2016-06-11T17:34:43 | 60,862,220 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,266 |
swift
|
//
// PillTimeUITests.swift
// PillTimeUITests
//
// Created by Victor Manuel Polanco on 6/9/16.
// Copyright © 2016 Victor Manuel Polanco. All rights reserved.
//
import XCTest
class PillTimeUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
155665,
237599,
229414,
278571,
229425,
229431,
180279,
319543,
213051,
286787,
237638,
311373,
196687,
278607,
311377,
368732,
180317,
278637,
319599,
278642,
131190,
131199,
278669,
278676,
311447,
327834,
278684,
278690,
311459,
278698,
278703,
278707,
180409,
278713,
295099,
139459,
131270,
229591,
147679,
311520,
147680,
319719,
295147,
286957,
319764,
278805,
311582,
278817,
311596,
336177,
98611,
278843,
287040,
319812,
311622,
229716,
278895,
287089,
139641,
311679,
311692,
106893,
156069,
311723,
377265,
311739,
319931,
278974,
336319,
311744,
278979,
336323,
278988,
278992,
279000,
369121,
279009,
188899,
279014,
319976,
279017,
311787,
319986,
279030,
311800,
279033,
279042,
287237,
377352,
279053,
303634,
303635,
279060,
279061,
279066,
188954,
279092,
377419,
303693,
115287,
189016,
295518,
287327,
279143,
279150,
287345,
287348,
189054,
287359,
303743,
164487,
279176,
311944,
344714,
311948,
311950,
311953,
336531,
287379,
295575,
303772,
221853,
205469,
279207,
295591,
295598,
279215,
279218,
287412,
164532,
287418,
303802,
66243,
287434,
287438,
279249,
303826,
279253,
369365,
369366,
230105,
295653,
230120,
279278,
312046,
230133,
279293,
205566,
295688,
312076,
295698,
221980,
336678,
262952,
262953,
279337,
262957,
164655,
328495,
303921,
230198,
222017,
295745,
279379,
295769,
230238,
230239,
279393,
303973,
279398,
295797,
295799,
279418,
336765,
287623,
279434,
320394,
189327,
189349,
279465,
304050,
189373,
213956,
345030,
213961,
279499,
304086,
304104,
123880,
320492,
320495,
287730,
320504,
214009,
312313,
312317,
328701,
328705,
418819,
320520,
230411,
320526,
238611,
140311,
238617,
197658,
336930,
132140,
189487,
312372,
238646,
238650,
320571,
336962,
238663,
205911,
296023,
156763,
230500,
214116,
279659,
230514,
238706,
312435,
279666,
279686,
222344,
337037,
296091,
238764,
148674,
312519,
279752,
148687,
189651,
279766,
189656,
279775,
304352,
304353,
279780,
279789,
279803,
320769,
312588,
320795,
320802,
304422,
312628,
345398,
222523,
181568,
279872,
279874,
304457,
345418,
230730,
337228,
296269,
222542,
238928,
296274,
230757,
296304,
312688,
230772,
337280,
296328,
296330,
304523,
9618,
279955,
148899,
279979,
279980,
173492,
279988,
280003,
370122,
337359,
329168,
312785,
222674,
329170,
280020,
280025,
239069,
320997,
280042,
280043,
329198,
337391,
296434,
288248,
288252,
312830,
230922,
329231,
304655,
230933,
222754,
312879,
230960,
288305,
239159,
157246,
288319,
288322,
280131,
124486,
288328,
230999,
239192,
99937,
345697,
312937,
312941,
206447,
288377,
337533,
280193,
239238,
288391,
239251,
280217,
198304,
337590,
280252,
280253,
296636,
321217,
280259,
321220,
296649,
239305,
280266,
9935,
313042,
280279,
18139,
280285,
321250,
337638,
181992,
288492,
34547,
67316,
313082,
288508,
288515,
280326,
116491,
280333,
124691,
116502,
321308,
321309,
280367,
280373,
280377,
321338,
280381,
345918,
280386,
280391,
280396,
337746,
18263,
370526,
296807,
296815,
313200,
313204,
124795,
182145,
280451,
67464,
305032,
124816,
214936,
337816,
124826,
329627,
239515,
214943,
313257,
288698,
214978,
280517,
280518,
214983,
231382,
329696,
190437,
313322,
329707,
174058,
296942,
124912,
313338,
239610,
182277,
313356,
305173,
223269,
354342,
354346,
313388,
124974,
321589,
215095,
288829,
288835,
313415,
239689,
354386,
280660,
223317,
329812,
321632,
280674,
280676,
313446,
215144,
288878,
288890,
215165,
280708,
329884,
215204,
125108,
280761,
223418,
280767,
338118,
280779,
321744,
280792,
280803,
182503,
338151,
125166,
125170,
395511,
313595,
125180,
125184,
125192,
125197,
125200,
125204,
338196,
125215,
125225,
338217,
321839,
125236,
280903,
289109,
379224,
239973,
313703,
280938,
321901,
354671,
354672,
199030,
223611,
248188,
313726,
240003,
158087,
313736,
240020,
190870,
190872,
289185,
305572,
289195,
338359,
289229,
281038,
281039,
281071,
322057,
182802,
322077,
289328,
338491,
322119,
281165,
281170,
281200,
297600,
289435,
314020,
248494,
166581,
314043,
363212,
158424,
322269,
338658,
289511,
330473,
330476,
289517,
215790,
125683,
199415,
322302,
289534,
35584,
322312,
346889,
264971,
322320,
166677,
207639,
281378,
289580,
281407,
289599,
281426,
281434,
322396,
281444,
207735,
314240,
158594,
330627,
240517,
289691,
240543,
289699,
289704,
289720,
289723,
281541,
19398,
191445,
183254,
207839,
142309,
314343,
183276,
289773,
248815,
240631,
330759,
322571,
330766,
330789,
248871,
281647,
322609,
314437,
207954,
339031,
314458,
281698,
281699,
322664,
314493,
150656,
347286,
330912,
339106,
306339,
249003,
208044,
322733,
3243,
339131,
290001,
339167,
298209,
290030,
208123,
322826,
126229,
298290,
208179,
159033,
216387,
372039,
224591,
331091,
314708,
150868,
314711,
314721,
281958,
314727,
134504,
306541,
314734,
314740,
314742,
314745,
290170,
224637,
306558,
290176,
306561,
314752,
314759,
298378,
314765,
314771,
306580,
224662,
282008,
314776,
282013,
290206,
314788,
314790,
282023,
298406,
241067,
314797,
306630,
306634,
339403,
191980,
282097,
306678,
191991,
290304,
323079,
323083,
323088,
282132,
282135,
175640,
282147,
306730,
290359,
323132,
282182,
224848,
224852,
290391,
306777,
323171,
282214,
224874,
314997,
290425,
339579,
282244,
323208,
282248,
323226,
282272,
282279,
298664,
298666,
306875,
282302,
323262,
323265,
282309,
306891,
241360,
282321,
241366,
282330,
282336,
12009,
282347,
282349,
323315,
200444,
282366,
249606,
282375,
323335,
282379,
216844,
118549,
282390,
282399,
241440,
282401,
339746,
315172,
216868,
241447,
282418,
282424,
282428,
413500,
241471,
315209,
159563,
307024,
307030,
241494,
307038,
282471,
282476,
339840,
315265,
282503,
315272,
315275,
184207,
282517,
298912,
118693,
298921,
126896,
200628,
282572,
282573,
323554,
298987,
282634,
241695,
315431,
102441,
315433,
102446,
282671,
241717,
307269,
233548,
315468,
315477,
200795,
323678,
315488,
315489,
45154,
217194,
233578,
307306,
249976,
241809,
323730,
299166,
233635,
299176,
184489,
323761,
184498,
258233,
299197,
299202,
176325,
299208,
233678,
282832,
356575,
307431,
184574,
217352,
315674,
282908,
299294,
282912,
233761,
282920,
315698,
332084,
282938,
307514,
127292,
168251,
323914,
201037,
282959,
250196,
168280,
323934,
381286,
242027,
242028,
250227,
315768,
315769,
291193,
291194,
291200,
242059,
315798,
291225,
242079,
283039,
299449,
291266,
373196,
283088,
283089,
242138,
176602,
160224,
291297,
242150,
283138,
233987,
324098,
340489,
283154,
291359,
283185,
234037,
340539,
332379,
111197,
242274,
291455,
316044,
184974,
316048,
316050,
340645,
176810,
299698,
291529,
225996,
135888,
242385,
299737,
234216,
234233,
242428,
291584,
299777,
291591,
291605,
283418,
234276,
283431,
242481,
234290,
201534,
283466,
234330,
201562,
275294,
349025,
357219,
177002,
308075,
242540,
242542,
201590,
177018,
308093,
291713,
340865,
299912,
316299,
234382,
308111,
308113,
209820,
283551,
177074,
127945,
340960,
234469,
340967,
324587,
234476,
201721,
234499,
234513,
316441,
300087,
21567,
308288,
160834,
349254,
300109,
234578,
250965,
234588,
250982,
234606,
300145,
300147,
234626,
234635,
177297,
308375,
324761,
119965,
234655,
300192,
234662,
300200,
324790,
300215,
283841,
283846,
283849,
316628,
251124,
316661,
283894,
234741,
292092,
234756,
242955,
177420,
292145,
300342,
333114,
333115,
193858,
300355,
300354,
234830,
283990,
357720,
300378,
300379,
316764,
292194,
284015,
234864,
316786,
243073,
112019,
234902,
333224,
284086,
259513,
284090,
54719,
415170,
292291,
300488,
300490,
234957,
144862,
300526,
308722,
300539,
210429,
292359,
218632,
316951,
374297,
235069,
349764,
194118,
292424,
292426,
333389,
349780,
128600,
235096,
300643,
300645,
243306,
325246,
333438,
235136,
317102,
300725,
300729,
333508,
333522,
325345,
153318,
333543,
284410,
284425,
300810,
300812,
284430,
161553,
284436,
325403,
341791,
325411,
186148,
186149,
333609,
284460,
300849,
325444,
153416,
325449,
317268,
325460,
341846,
284508,
300893,
284515,
276326,
292713,
292719,
325491,
333687,
317305,
317308,
325508,
333700,
243590,
243592,
325514,
350091,
350092,
350102,
333727,
219046,
333734,
284584,
292783,
300983,
153553,
292835,
6116,
292838,
317416,
325620,
333827,
243720,
292901,
325675,
243763,
325695,
333902,
227432,
194667,
284789,
284790,
227459,
194692,
235661,
333968,
153752,
284827,
333990,
284840,
284843,
227517,
309443,
227525,
301255,
227536,
301270,
301271,
325857,
334049,
317676,
309504,
194832,
227601,
325904,
334104,
211239,
334121,
317738,
325930,
227655,
383309,
391521,
285031,
416103,
227702,
211327,
227721,
285074,
227730,
285083,
293275,
317851,
227743,
285089,
293281,
301482,
375211,
334259,
293309,
317889,
326083,
129484,
326093,
285152,
195044,
334315,
236020,
293368,
317949,
342537,
309770,
334345,
342560,
227881,
293420,
236080,
23093,
244279,
244280,
301635,
309831,
55880,
301647,
326229,
309847,
244311,
244326,
277095,
301688,
244345,
301702,
334473,
326288,
227991,
285348,
318127,
293552,
285360,
285362,
342705,
154295,
342757,
285419,
170735,
342775,
375552,
228099,
285443,
285450,
326413,
285457,
285467,
326428,
318247,
203560,
293673,
318251,
301872,
285493,
285496,
301883,
342846,
293702,
318279,
244569,
301919,
293729,
351078,
310132,
228214,
269179,
228232,
416649,
236427,
252812,
293780,
310166,
310177,
293801,
326571,
326580,
326586,
359365,
211913,
326602,
56270,
203758,
293894,
293911,
326684,
113710,
318515,
203829,
285795,
228457,
318571,
187508,
302202,
285819,
285823,
285833,
318602,
285834,
228492,
162962,
187539,
326803,
285850,
302239,
302251,
294069,
294075,
64699,
228541,
343230,
310496,
228587,
302319,
228608,
318732,
245018,
318746,
130342,
130344,
130347,
286012,
294210,
318804,
294236,
327023,
327030,
310650,
179586,
294278,
368012,
318860,
318876,
343457,
245160,
286128,
286133,
310714,
302523,
228796,
302530,
228804,
310725,
310731,
302539,
310735,
327122,
310747,
286176,
187877,
310758,
40439,
286201,
359931,
245249,
228868,
302602,
294413,
359949,
302613,
302620,
245291,
130622,
310853,
286281,
196184,
212574,
204386,
204394,
138862,
310896,
294517,
286344,
179853,
286351,
188049,
229011,
179868,
229021,
302751,
245413,
212649,
286387,
286392,
302778,
286400,
212684,
302798,
286419,
278232,
278237,
294621,
278241,
294629,
286457,
286463,
319232,
278292,
278294,
294699,
286507,
319289,
237397,
188250,
237411,
327556,
188293,
311183,
294806,
294808,
319393,
294820,
294824,
343993,
98240,
294849,
294887,
278507,
311277,
327666,
278515
] |
a9d080c517a4260a650e7a5829b5303dc77ed8b6
|
ac143458a1c1951146874feec5c9230d4637c155
|
/ReactiveCocoa/Swift/Disposable.swift
|
995894fbf91b4a5f2d35afbfa738e3a34919f6b8
|
[
"MIT"
] |
permissive
|
feifei-123/ReactiveCocoa
|
93438202202a03611a200e539a3af7d28488a271
|
635a8a5929a0606fe1362edbb3426db367318774
|
refs/heads/master
| 2020-12-11T03:37:46.506777 | 2016-08-09T16:28:52 | 2016-08-09T16:28:52 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 7,552 |
swift
|
//
// Disposable.swift
// ReactiveCocoa
//
// Created by Justin Spahr-Summers on 2014-06-02.
// Copyright (c) 2014 GitHub. All rights reserved.
//
/// Represents something that can be “disposed”, usually associated with freeing
/// resources or canceling work.
public protocol Disposable: class {
/// Whether this disposable has been disposed already.
var isDisposed: Bool { get }
/// Method for disposing of resources when appropriate.
func dispose()
}
/// A disposable that only flips `isDisposed` upon disposal, and performs no other
/// work.
public final class SimpleDisposable: Disposable {
private let _isDisposed = Atomic(false)
public var isDisposed: Bool {
return _isDisposed.value
}
public init() {}
public func dispose() {
_isDisposed.value = true
}
}
/// A disposable that will run an action upon disposal.
public final class ActionDisposable: Disposable {
private let action: Atomic<(() -> Void)?>
public var isDisposed: Bool {
return action.value == nil
}
/// Initialize the disposable to run the given action upon disposal.
///
/// - parameters:
/// - action: A closure to run when calling `dispose()`.
public init(action: () -> Void) {
self.action = Atomic(action)
}
public func dispose() {
let oldAction = action.swap(nil)
oldAction?()
}
}
/// A disposable that will dispose of any number of other disposables.
public final class CompositeDisposable: Disposable {
private let disposables: Atomic<Bag<Disposable>?>
/// Represents a handle to a disposable previously added to a
/// CompositeDisposable.
public final class DisposableHandle {
private let bagToken: Atomic<RemovalToken?>
private weak var disposable: CompositeDisposable?
private static let empty = DisposableHandle()
private init() {
self.bagToken = Atomic(nil)
}
private init(bagToken: RemovalToken, disposable: CompositeDisposable) {
self.bagToken = Atomic(bagToken)
self.disposable = disposable
}
/// Remove the pointed-to disposable from its `CompositeDisposable`.
///
/// - note: This is useful to minimize memory growth, by removing
/// disposables that are no longer needed.
public func remove() {
if let token = bagToken.swap(nil) {
_ = disposable?.disposables.modify { bag in
bag?.remove(using: token)
}
}
}
}
public var isDisposed: Bool {
return disposables.value == nil
}
/// Initialize a `CompositeDisposable` containing the given sequence of
/// disposables.
///
/// - parameters:
/// - disposables: A collection of objects conforming to the `Disposable`
/// protocol
public init<S: Sequence where S.Iterator.Element == Disposable>(_ disposables: S) {
var bag: Bag<Disposable> = Bag()
for disposable in disposables {
bag.insert(disposable)
}
self.disposables = Atomic(bag)
}
/// Initialize a `CompositeDisposable` containing the given sequence of
/// disposables.
///
/// - parameters:
/// - disposables: A collection of objects conforming to the `Disposable`
/// protocol
public convenience init<S: Sequence where S.Iterator.Element == Disposable?>(_ disposables: S) {
self.init(disposables.flatMap { $0 })
}
/// Initializes an empty `CompositeDisposable`.
public convenience init() {
self.init([Disposable]())
}
public func dispose() {
if let ds = disposables.swap(nil) {
for d in ds.reversed() {
d.dispose()
}
}
}
/// Add the given disposable to the list, then return a handle which can
/// be used to opaquely remove the disposable later (if desired).
///
/// - parameters:
/// - d: Optional disposable.
///
/// - returns: An instance of `DisposableHandle` that can be used to
/// opaquely remove the disposable later (if desired).
@discardableResult
public func add(_ d: Disposable?) -> DisposableHandle {
guard let d = d else {
return DisposableHandle.empty
}
var handle: DisposableHandle? = nil
disposables.modify { ds in
if let token = ds?.insert(d) {
handle = DisposableHandle(bagToken: token, disposable: self)
}
}
if let handle = handle {
return handle
} else {
d.dispose()
return DisposableHandle.empty
}
}
/// Add an ActionDisposable to the list.
///
/// - parameters:
/// - action: A closure that will be invoked when `dispose()` is called.
///
/// - returns: An instance of `DisposableHandle` that can be used to
/// opaquely remove the disposable later (if desired).
public func add(_ action: () -> Void) -> DisposableHandle {
return add(ActionDisposable(action: action))
}
}
/// A disposable that, upon deinitialization, will automatically dispose of
/// another disposable.
public final class ScopedDisposable: Disposable {
/// The disposable which will be disposed when the ScopedDisposable
/// deinitializes.
public let innerDisposable: Disposable
public var isDisposed: Bool {
return innerDisposable.isDisposed
}
/// Initialize the receiver to dispose of the argument upon
/// deinitialization.
///
/// - parameters:
/// - disposable: A disposable to dispose of when deinitializing.
public init(_ disposable: Disposable) {
innerDisposable = disposable
}
deinit {
dispose()
}
public func dispose() {
innerDisposable.dispose()
}
}
/// A disposable that will optionally dispose of another disposable.
public final class SerialDisposable: Disposable {
private struct State {
var innerDisposable: Disposable? = nil
var isDisposed = false
}
private let state = Atomic(State())
public var isDisposed: Bool {
return state.value.isDisposed
}
/// The inner disposable to dispose of.
///
/// Whenever this property is set (even to the same value!), the previous
/// disposable is automatically disposed.
public var innerDisposable: Disposable? {
get {
return state.value.innerDisposable
}
set(d) {
let oldState = state.modify { state in
state.innerDisposable = d
}
oldState.innerDisposable?.dispose()
if oldState.isDisposed {
d?.dispose()
}
}
}
/// Initializes the receiver to dispose of the argument when the
/// SerialDisposable is disposed.
///
/// - parameters:
/// - disposable: Optional disposable.
public init(_ disposable: Disposable? = nil) {
innerDisposable = disposable
}
public func dispose() {
let orig = state.swap(State(innerDisposable: nil, isDisposed: true))
orig.innerDisposable?.dispose()
}
}
/// Adds the right-hand-side disposable to the left-hand-side
/// `CompositeDisposable`.
///
/// ````
/// disposable += producer
/// .filter { ... }
/// .map { ... }
/// .start(observer)
/// ````
///
/// - parameters:
/// - lhs: Disposable to add to.
/// - rhs: Disposable to add.
///
/// - returns: An instance of `DisposableHandle` that can be used to opaquely
/// remove the disposable later (if desired).
@discardableResult
public func +=(lhs: CompositeDisposable, rhs: Disposable?) -> CompositeDisposable.DisposableHandle {
return lhs.add(rhs)
}
/// Adds the right-hand-side `ActionDisposable` to the left-hand-side
/// `CompositeDisposable`.
///
/// ````
/// disposable += { ... }
/// ````
///
/// - parameters:
/// - lhs: Disposable to add to.
/// - rhs: Closure to add as a disposable.
///
/// - returns: An instance of `DisposableHandle` that can be used to opaquely
/// remove the disposable later (if desired).
@discardableResult
public func +=(lhs: CompositeDisposable, rhs: () -> ()) -> CompositeDisposable.DisposableHandle {
return lhs.add(rhs)
}
|
[
-1
] |
f7ce9175bf7559cb2af135cc244b6426717d473d
|
2c639563858bd55b52aa9640f664c0e9599c5a96
|
/sBlueUITests/sBlueUITests.swift
|
e02bb4a2d07919c44a021e156767031e61ba4a07
|
[] |
no_license
|
hleise/sBlue
|
03174f0bb019d352348f8c33effa8000775fd9b7
|
d8a25ac33a2ca12bddd4be3c6fe09ffa50cb45a4
|
refs/heads/master
| 2021-03-30T18:29:32.606004 | 2016-08-12T00:55:23 | 2016-08-12T00:55:23 | 62,479,309 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,245 |
swift
|
//
// sBlueUITests.swift
// sBlueUITests
//
// Created by Hunter Leise on 7/21/16.
// Copyright © 2016 Vivo Applications. All rights reserved.
//
import XCTest
class sBlueUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
333827,
243720,
282634,
313356,
155665,
237599,
241695,
223269,
354342,
229414,
315431,
315433,
354346,
278571,
325675,
102441,
102446,
282671,
229425,
241717,
180279,
229431,
215095,
213051,
288829,
325695,
288835,
307269,
237638,
313415,
315468,
233548,
333902,
196687,
278607,
311377,
354386,
311373,
329812,
315477,
223317,
200795,
323678,
315488,
315489,
45154,
321632,
280676,
313446,
215144,
233578,
194667,
307306,
278637,
288878,
278642,
284789,
284790,
131190,
288890,
215165,
131199,
194692,
235661,
278669,
241809,
323730,
278676,
311447,
153752,
327834,
284827,
278684,
329884,
299166,
278690,
311459,
215204,
233635,
284840,
299176,
278698,
284843,
184489,
278703,
184498,
278707,
258233,
278713,
280761,
180409,
223418,
227517,
280767,
295099,
299197,
299202,
139459,
309443,
176325,
131270,
301255,
227525,
299208,
280779,
233678,
282832,
321744,
227536,
301270,
229591,
280792,
301271,
311520,
325857,
334049,
280803,
307431,
182503,
338151,
295147,
317676,
286957,
125170,
313595,
309504,
217352,
194832,
227601,
325904,
319764,
278805,
282908,
311582,
299294,
282912,
278817,
233761,
211239,
282920,
317738,
311596,
321839,
315698,
98611,
332084,
282938,
278843,
307514,
287040,
319812,
311622,
227655,
280903,
323914,
201037,
229716,
289109,
168280,
379224,
323934,
391521,
239973,
381286,
285031,
416103,
313703,
280938,
242027,
242028,
321901,
354671,
278895,
287089,
199030,
227702,
315768,
315769,
291194,
223611,
248188,
139641,
291193,
211327,
291200,
311679,
313726,
240003,
158087,
313736,
227721,
242059,
311692,
227730,
285074,
240020,
190870,
190872,
291225,
293275,
285083,
317851,
227743,
242079,
293281,
283039,
285089,
289185,
301482,
311723,
289195,
377265,
338359,
311739,
319931,
293309,
278974,
311744,
317889,
278979,
326083,
278988,
289229,
281038,
281039,
278992,
283088,
283089,
326093,
279000,
242138,
285152,
279009,
369121,
160224,
195044,
291297,
279014,
319976,
279017,
281071,
319986,
236020,
279030,
311800,
279033,
317949,
279042,
283138,
233987,
287237,
377352,
322057,
309770,
342537,
279053,
283154,
303634,
303635,
279061,
182802,
279060,
279066,
188954,
322077,
291359,
227881,
293420,
236080,
283185,
279092,
23093,
234037,
244279,
338491,
301635,
309831,
55880,
322119,
377419,
281165,
303693,
301647,
281170,
326229,
115287,
309847,
332379,
111197,
295518,
287327,
279143,
279150,
281200,
287345,
313970,
301688,
244345,
189054,
287359,
297600,
303743,
291455,
301702,
164487,
311944,
334473,
279176,
316044,
311948,
311950,
184974,
316048,
311953,
316050,
287379,
326288,
227991,
295575,
289435,
303772,
205469,
221853,
285348,
314020,
279207,
295591,
248494,
279215,
293552,
295598,
299698,
318127,
164532,
166581,
342705,
154295,
285360,
287412,
303802,
314043,
66243,
291529,
287434,
225996,
287438,
242385,
303826,
279253,
158424,
230105,
299737,
295653,
342757,
289511,
230120,
330473,
310731,
285419,
330476,
289517,
312046,
170735,
279278,
125683,
230133,
199415,
234233,
242428,
279293,
205566,
322302,
289534,
299777,
291584,
228099,
285443,
291591,
322312,
295688,
285450,
264971,
312076,
326413,
322320,
285457,
295698,
166677,
283418,
285467,
326428,
221980,
281378,
234276,
283431,
318247,
279337,
293673,
318251,
289580,
164655,
301872,
303921,
234290,
328495,
285493,
230198,
285496,
301883,
201534,
281407,
289599,
295745,
342846,
222017,
293702,
318279,
283466,
281426,
279379,
244569,
281434,
295769,
322396,
201562,
230238,
230239,
275294,
279393,
293729,
349025,
281444,
303973,
279398,
301919,
351078,
308075,
242540,
310132,
295797,
201590,
228214,
295799,
207735,
177018,
269179,
279418,
308093,
314240,
291713,
158594,
240517,
287623,
299912,
416649,
279434,
316299,
252812,
228232,
320394,
308111,
189327,
308113,
234382,
293780,
310166,
289691,
209820,
283551,
310177,
289699,
189349,
293801,
279465,
326571,
304050,
326580,
289720,
326586,
289723,
189373,
281541,
19398,
213961,
279499,
56270,
183254,
304086,
234469,
314343,
304104,
324587,
183276,
234476,
320492,
289773,
320495,
287730,
240631,
320504,
214009,
312313,
312317,
328701,
328705,
234499,
293894,
320520,
230411,
322571,
320526,
330766,
234513,
238611,
140311,
293911,
238617,
197658,
113710,
281647,
189487,
322609,
312372,
203829,
238646,
300087,
238650,
320571,
21567,
308288,
160834,
336962,
314437,
349254,
238663,
300109,
234578,
207954,
205911,
296023,
314458,
156763,
281698,
285795,
214116,
230500,
281699,
322664,
228457,
279659,
318571,
234606,
300145,
279666,
312435,
187508,
230514,
238706,
302202,
285819,
314493,
285823,
150656,
234626,
279686,
222344,
285833,
318602,
234635,
228492,
337037,
285834,
177297,
162962,
187539,
326803,
308375,
324761,
285850,
296091,
119965,
302239,
300192,
234655,
339106,
306339,
234662,
300200,
249003,
208044,
238764,
322733,
3243,
302251,
300215,
294075,
64699,
228541,
283841,
283846,
312519,
283849,
148687,
290001,
189651,
316628,
279766,
189656,
279775,
304352,
298209,
310496,
304353,
279780,
228587,
279789,
290030,
302319,
251124,
316661,
283894,
234741,
208123,
292092,
279803,
228608,
320769,
322826,
242955,
177420,
312588,
318732,
126229,
245018,
320795,
320802,
239610,
130342,
304422,
130344,
292145,
298290,
312628,
300342,
159033,
333114,
333115,
286012,
279872,
181568,
193858,
216387,
279874,
300354,
300355,
372039,
294210,
230730,
294220,
296269,
234830,
224591,
238928,
222542,
296274,
314708,
318804,
283990,
314711,
357720,
300378,
300379,
294236,
234330,
314721,
292194,
230757,
281958,
314727,
134504,
306541,
327023,
296304,
234864,
312688,
316786,
314740,
230772,
327030,
284015,
314745,
310650,
224637,
306558,
243073,
314759,
296328,
296330,
298378,
368012,
314765,
318860,
292242,
279955,
112019,
306580,
224662,
234902,
282008,
314776,
318876,
282013,
290206,
148899,
314788,
298406,
314790,
245160,
333224,
282023,
241067,
279979,
314797,
286128,
173492,
286133,
310714,
284090,
228796,
54719,
302530,
292291,
228804,
415170,
306630,
300488,
370122,
302539,
339403,
300490,
306634,
234957,
329168,
312785,
222674,
327122,
280020,
329170,
310735,
280025,
239069,
144862,
286176,
187877,
320997,
310758,
280042,
280043,
191980,
329198,
337391,
282097,
296434,
308722,
306678,
40439,
191991,
288248,
286201,
300539,
288252,
312830,
290304,
245249,
228868,
323079,
218632,
230922,
302602,
323083,
294413,
304655,
329231,
323088,
282132,
230933,
302613,
316951,
282135,
374297,
302620,
222754,
282147,
306730,
245291,
312879,
230960,
288305,
239159,
290359,
323132,
235069,
157246,
288319,
288322,
280131,
349764,
310853,
282182,
194118,
288328,
286281,
292426,
333389,
224848,
224852,
290391,
128600,
196184,
235096,
306777,
212574,
204386,
300643,
300645,
282214,
204394,
312941,
206447,
310896,
314997,
294517,
288377,
290425,
325246,
333438,
235136,
280193,
282244,
239238,
288391,
282248,
286344,
179853,
286351,
188049,
229011,
239251,
280217,
323226,
179868,
229021,
302751,
198304,
282272,
282279,
298664,
212649,
317102,
286387,
300725,
337590,
286392,
300729,
302778,
306875,
280252,
280253,
282302,
323262,
286400,
321217,
296636,
280259,
321220,
333508,
282309,
239305,
296649,
280266,
212684,
306891,
302798,
9935,
241360,
282321,
313042,
286419,
241366,
280279,
282330,
18139,
294621,
282336,
321250,
294629,
153318,
333543,
181992,
337638,
12009,
282347,
288492,
282349,
323315,
67316,
34547,
286457,
284410,
288508,
282366,
286463,
319232,
288515,
280326,
323335,
282375,
300810,
116491,
216844,
280333,
300812,
284430,
282379,
161553,
278292,
118549,
116502,
278294,
284436,
282390,
325403,
321308,
321309,
282399,
241440,
282401,
325411,
315172,
186149,
186148,
241447,
333609,
286507,
294699,
284460,
280367,
300849,
282418,
280373,
282424,
280377,
321338,
282428,
280381,
345918,
241471,
280386,
280391,
153416,
315209,
325449,
159563,
280396,
307024,
317268,
237397,
241494,
18263,
307030,
188250,
284508,
300893,
307038,
237411,
284515,
276326,
282471,
296807,
292713,
282476,
292719,
313200,
325491,
313204,
333687,
317305,
317308,
339840,
315265,
280451,
188293,
243590,
282503,
67464,
305032,
315272,
315275,
325514,
243592,
184207,
311183,
282517,
294806,
337816,
294808,
239515,
214943,
298912,
319393,
333727,
294820,
333734,
284584,
294824,
313257,
292783,
126896,
200628,
300983,
343993,
288698,
294849,
214978,
280517,
280518,
282572,
282573,
153553,
24531,
231382,
329696,
292835,
6116,
190437,
292838,
294887,
317416,
313322,
329707,
278507,
298987,
296942,
311277,
327666,
278515,
325620,
313338
] |
f1052e2b313ea1884c319796004a0a7c9e5ab418
|
51ebb11cf89907341c66084a046454045cbf7fab
|
/HealthBeam/HealthBeam/Services/Networking/Core/Request.swift
|
5a29a9006eb367f02fe87da14449c9ec974e2831
|
[
"MIT"
] |
permissive
|
naandonov/healthbeam-ios
|
271e23eaf45df0114d1754a307fee3d48a5102f7
|
e98229fff4b2327dac9a4d190cba63fd5335c83d
|
refs/heads/master
| 2022-09-25T12:43:52.471039 | 2019-03-10T18:21:56 | 2019-03-10T18:21:56 | 163,161,454 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 927 |
swift
|
//
// Request.swift
// MinerStats
//
// Created by Nikolay Andonov on 30.09.18.
// Copyright © 2018 HealthBeam. All rights reserved.
//
import Foundation
public class Request: RequestProtocol {
public var context: URLSession?
public var invalidationToken: URLSessionDataTask?
public var endpoint: String
public var body: RequestBody?
public var method: RequestMethod?
public var fields: ParametersDict?
public var urlParams: ParametersDict?
public var headers: HeadersDict?
public var cachePolicy: URLRequest.CachePolicy?
public var timeout: TimeInterval?
public init(method: RequestMethod = .get, endpoint:String = "", params: ParametersDict? = nil, fields: ParametersDict? = nil, body: RequestBody? = nil) {
self.method = method
self.endpoint = endpoint
self.urlParams = params
self.fields = fields
self.body = body
}
}
|
[
-1
] |
0ee40e873ce85d41548cc8bc569d714ae2094f34
|
e22026243fea765dfce63295eae47ea6816d6e4f
|
/BPNBTV/DetailAlertViewController.swift
|
281e2596b06d0a7d140f942cffbf7a42a32f4aa4
|
[] |
no_license
|
asepandria/bnpbtv-ios
|
229f87861374f55e04e0b44c1d7a4d7674a4003d
|
37d5ea47bcc0e66d9f5150106c75dd4e2a176d25
|
refs/heads/master
| 2021-01-19T17:37:11.610051 | 2017-10-18T15:59:58 | 2017-10-18T15:59:58 | 101,074,624 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 8,914 |
swift
|
//
// DetailAlertViewController.swift
// BPNBTV
//
// Created by Raditya on 7/10/17.
// Copyright © 2017 Radith. All rights reserved.
//
import UIKit
import GoogleMaps
import SideMenu
import ImageSlideshow
import Social
class DetailAlertViewController: UIViewController {
@IBOutlet weak var mapContainer: UIView!
@IBOutlet weak var typeLabel: UILabel!
@IBOutlet weak var addressLabel: UILabel!
@IBOutlet weak var slideShow: ImageSlideshow!
@IBOutlet weak var detailTypeLabel: UILabel!
var alertModel:AlertModel!
var longitude:CLLocationDegrees = 0
var latitude:CLLocationDegrees = 0
var zoomScale:Float = 15
@IBOutlet weak var earthQuakeLabelScale: UILabel!
@IBOutlet weak var fatalitiesLabel: UILabel!
@IBOutlet weak var woundLabel: UILabel!
//@IBOutlet weak var contentLabelHeightConstraint: NSLayoutConstraint!
//@IBOutlet weak var slideShowHeightConstraint: NSLayoutConstraint!
//@IBOutlet weak var scrollContainerHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var scrollContainer: UIScrollView!
@IBOutlet weak var innerScrollContainer: UIView!
@IBOutlet weak var contentLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
var imageAlert:UIImageView!
var isFromPush = false
var pushId = ""
override func viewDidLoad() {
super.viewDidLoad()
setupView()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func setupSlideShow(){
slideShow.activityIndicator = DefaultActivityIndicator()
slideShow.backgroundColor = UIColor.black
slideShow.contentScaleMode = UIViewContentMode.scaleAspectFit
if alertModel.imageSliderURLArr.count > 0{
var kfSource = [KingfisherSource]()
imageAlert = UIImageView()
imageAlert.frame = CGRect(x: 0, y: 0, width: getScreenWidth()/4, height: getScreenWidth()/4)
imageAlert.kf.setImage(with: URL(string: alertModel.imageSliderURLArr.first ?? ""))
for aim in alertModel.imageSliderURLArr{
kfSource.append(KingfisherSource(url: URL(string: aim)!))
}
slideShow.setImageInputs(kfSource)
}else{
slideShow.setImageInputs([KingfisherSource(url:URL(string:alertModel.imageSliderSingle)!)])
}
}
func setupView(){
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 44, height: getScreenWidth()/3))
imageView.contentMode = .scaleAspectFit
let image = UIImage(named: "bnpbtv")
imageView.image = image
navigationItem.titleView = imageView
if let _ = alertModel{
setupSlideShow()
titleLabel?.text = alertModel.title ?? ""
let tempLabel = UILabel()
tempLabel.frame = CGRect(x: 0, y: 0, width: getScreenWidth()/2, height: CGFloat.greatestFiniteMagnitude)
tempLabel.numberOfLines = 0
tempLabel.font = UIFont(name: "Helvetica", size: 13.5)
tempLabel.text = alertModel.description ?? ""
tempLabel.sizeToFit()
//scontentLabel.translatesAutoresizingMaskIntoConstraints = false
contentLabel.text = (alertModel.description ?? "")
contentLabel.numberOfLines = 0
typeLabel?.text = alertModel.type ?? ""
detailTypeLabel?.text = alertModel.type ?? ""
addressLabel?.text = alertModel.address ?? ""
if let _longLat = alertModel.longlat{
if _longLat != ""{
let splitLongLat = _longLat.components(separatedBy: "/")
if splitLongLat.count > 1{
longitude = (splitLongLat[1] as NSString).doubleValue
latitude = (splitLongLat[0] as NSString).doubleValue
}
}
}
if longitude == 0 && latitude == 0{
getLongLatFromGoogleMapsURL(urlString: alertModel.googleMaps)
}
earthQuakeLabelScale.text = "Earthquake scale : "+alertModel.scale
fatalitiesLabel.text = "Fatalities : "+alertModel.fatalities
woundLabel.text = "Wound : "+alertModel.wound
DispatchQueue.main.async {[weak self] in
self?.contentLabel.frame.size.height = tempLabel.frame.height
self?.contentLabel.setNeedsLayout()
self?.contentLabel.setNeedsDisplay()
//self?.innerScrollContainer.translatesAutoresizingMaskIntoConstraints = false
self?.scrollContainer.contentSize.height = (self?.slideShow.frame.height)! + (self?.titleLabel.frame.height)! + (self?.contentLabel.frame.height)! + 100
self?.scrollContainer.setNeedsLayout()
}
//scrollContainer.resizeScrollViewContentSize()
}
setupMap()
}
func getLongLatFromGoogleMapsURL(urlString:String){
let regexp = "/@(-?\\d+\\.\\d+,-?\\d+\\.\\d+,\\d+)"
if let range = alertModel.googleMaps!.range(of: regexp, options: String.CompareOptions.regularExpression){
let resultLonglat = alertModel.googleMaps!.substring(with: range)
let resultLongLatFix = resultLonglat.replacingOccurrences(of:"/@", with: "")
let splitLongLat = resultLongLatFix.components(separatedBy: ",")
if splitLongLat.count > 1{
longitude = (splitLongLat[1] as NSString).doubleValue
latitude = (splitLongLat[0] as NSString).doubleValue
}
if splitLongLat.count > 2{
zoomScale = Float((splitLongLat[2] as NSString).doubleValue)
}
}
}
func setupMap(){
let camera = GMSCameraPosition.camera(withLatitude: latitude, longitude: longitude, zoom: zoomScale)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapContainer.addSubview(mapView)
mapView.snp.makeConstraints({make in
make.top.equalTo(mapContainer)
make.left.right.equalTo(mapContainer)
make.height.equalTo(mapContainer).offset(-50)
})
mapView.center = mapContainer.center
//mapContainer = mapView
// Create a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
marker.title = alertModel.address
//marker.snippet = alertModel.address
marker.map = mapView
}
@IBAction func backAction(_ sender: UIBarButtonItem) {
navigationController?.popViewController(animated: true)
}
@IBAction func searchAction(_ sender: UIBarButtonItem) {
present(SideMenuManager.menuLeftNavigationController!, animated: true, completion: nil)
}
@IBAction func shareAction(_ sender: UIButton) {
switch sender.tag{
case ShareButtonTag.Facebook.rawValue:
//printLog(content: "Share Facebook")
if let vc = SLComposeViewController(forServiceType:SLServiceTypeFacebook){
vc.add(imageAlert?.image)
vc.add(URL(string: alertModel.shortURL))
vc.setInitialText(alertModel.title)
self.present(vc, animated: true, completion: nil)
}
case ShareButtonTag.Twitter.rawValue:
//printLog(content: "Share Twitter")
if let vc = SLComposeViewController(forServiceType:SLServiceTypeTwitter){
vc.add(imageAlert?.image)
vc.add(URL(string: alertModel.shortURL))
vc.setInitialText(alertModel.title)
self.present(vc, animated: true, completion: nil)
}
case ShareButtonTag.More.rawValue:
//printLog(content: "Share More")
let shareJudul = alertModel.title ?? ""
let activityVC = UIActivityViewController(activityItems: [shareJudul,URL(string: alertModel.shortURL ?? "") as Any,imageAlert.image as Any], applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityType.assignToContact,
UIActivityType.addToReadingList,
UIActivityType.print,
UIActivityType.openInIBooks,
UIActivityType.saveToCameraRoll]
present(activityVC, animated: true, completion: nil)
default:
break
}
}
deinit {
printLog(content: "DETAIL ALERT DEINIT...")
}
}
|
[
-1
] |
e8ff6f3a1187e981d84dff81ad5b00bec954bd9b
|
caf2784ee5b0dd81e9ccaa1b23846a5ab5f039a8
|
/MarshrouteTests/Sources/PeekAndPopSupport/PeekAndPopUtilityImplTests/Support/DummyViewControllerPreviewing.swift
|
205b6ecc748d13b0816bab9a713b8f9a590a0a43
|
[
"MIT"
] |
permissive
|
sng1996/Marshroute
|
47b4e00dbe7f13560a92a563cf132cd7d82cafc8
|
00be922c507080636f8438af21686499cee9e91c
|
refs/heads/master
| 2021-07-02T22:44:07.012538 | 2017-09-13T08:52:16 | 2017-09-13T08:52:16 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,143 |
swift
|
import UIKit
final class DummyViewControllerPreviewing: NSObject, UIViewControllerPreviewing {
@available(iOS 9.0, *)
var sourceRect: CGRect {
get { return _sourceRect }
set { _sourceRect = newValue }
}
var delegate: UIViewControllerPreviewingDelegate {
return _delegate!
}
weak var _delegate: UIViewControllerPreviewingDelegate?
let previewingGestureRecognizerForFailureRelationship: UIGestureRecognizer = TestableGestureRecognizer()
var _sourceRect: CGRect = .zero
let sourceView: UIView
init(
delegate: UIViewControllerPreviewingDelegate,
sourceView: UIView)
{
self._delegate = delegate
self.sourceView = sourceView
super.init()
}
func unregister() {
// Required to avoid the following crash:
// `[MarshrouteTests.DummyViewControllerPreviewing unregister]: unrecognized selector sent to instance ...`
//
// It occures during unregistering view controller from previewing:
// `viewController.unregisterForPreviewing(withContext: previewingContext)`
}
}
|
[
-1
] |
e4e21a447ddaacd4caba9b85b34f5e7871f864c7
|
f9ca54dd8285d355e092fc63816e57688c1801f2
|
/LemonLime/Nodes/LLLabelNode.swift
|
9002af9afef332762bf42bd08a2f870a2adc610f
|
[] |
no_license
|
kevinwo/LemonLime
|
fe44a77490b5a2674610a662f3c5047eb081847b
|
08eb32a9d0f70d5dbb74bcc93bcfbe97cbf16fc9
|
refs/heads/master
| 2021-01-10T08:18:40.079386 | 2015-11-13T09:23:57 | 2015-11-13T09:23:57 | 46,112,399 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,143 |
swift
|
//
// LLLabelNode.swift
// LemonLime
//
// Created by Kevin Wolkober on 10/17/15.
// Copyright © 2015 Kevin Wolkober. All rights reserved.
//
import SpriteKit
class LLLabelNode: SKLabelNode {
init(text: String = "", name: String = "", fontSize: CGFloat = 48.0, smallFontSize: CGFloat = 0, visible: Bool = true) {
super.init()
self.text = text
self.name = name
self.alpha = visible ? 1 : 0
#if os(tvOS)
self.fontSize = fontSize
#else
if smallFontSize > 0 {
self.fontSize = smallFontSize
} else {
self.fontSize = fontSize * 0.52173913
}
#endif
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func addChild(node: SKNode) {
if node.respondsToSelector("willAddToParent:") {
node.performSelector("willAddToParent:", withObject: self)
}
super.addChild(node)
if node.respondsToSelector("didAddToParent:") {
node.performSelector("didAddToParent:", withObject: self)
}
}
}
|
[
-1
] |
fa87b600e359bc69a6bce38d04b596fa174866d4
|
f464e0981c09f9cb97e5c2fff361e6d5e820ab08
|
/boredApp/Views/CardDetail.swift
|
6655c345355a1515251d85fb2922f684b257612c
|
[] |
no_license
|
amandatavares/boredApp
|
c15a2c1e15c20fbfa57e464f62463c76a2c966fc
|
eb4edc340606f1d2ae0130a42a1efd2350c8625b
|
refs/heads/master
| 2020-06-04T02:57:14.186742 | 2019-06-17T12:40:30 | 2019-06-17T12:40:30 | 191,844,718 | 0 | 0 | null | 2019-10-14T18:33:37 | 2019-06-13T23:11:02 |
Swift
|
UTF-8
|
Swift
| false | false | 1,138 |
swift
|
//
// CardDetail.swift
// boredApp
//
// Created by Amanda Tavares on 13/06/19.
// Copyright © 2019 Amanda Tavares. All rights reserved.
//
import SwiftUI
struct CardDetail : View {
let activity: Activity
var body: some View {
VStack(alignment: .leading, spacing: 10) {
Text(activity.type)
.font(.title)
.color(.secondary)
Divider()
HStack {
List {
Text("Participants")
Text("Acessibility ")
Text("Expensive")
}
List {
Text("\(activity.participants)")
Text("\(activity.accessibility)")
Text("\(activity.price)")
}
}
.padding(.horizontal)
.relativeHeight(0.9)
}
.navigationBarTitle(Text(activity.activity))
.padding(.horizontal)
}
}
#if DEBUG
struct CardDetail_Previews : PreviewProvider {
static var previews: some View {
CardDetail(activity: activityTest)
}
}
#endif
|
[
-1
] |
4d40086546ffa69586cac849a81d631e85d27073
|
cd85ca0feb3fd84117050972d1f2c32ee84dc1f0
|
/Examples/TestSupport/Mocks.swift
|
40b80a9d0532a238509eca0c8457b32db71dffe0
|
[
"MIT"
] |
permissive
|
aferodeveloper/AferoSwiftSDK
|
184e934a22cd6b49192065b2715315fd8c4dcca7
|
b23fa2ef4e4d06058dff5d11be7ba6e758b575ff
|
refs/heads/master
| 2023-04-29T06:39:48.243017 | 2023-04-20T22:03:16 | 2023-04-20T22:03:16 | 94,582,943 | 2 | 1 |
MIT
| 2023-04-20T21:59:10 | 2017-06-16T21:36:10 |
Swift
|
UTF-8
|
Swift
| false | false | 11,742 |
swift
|
//
// Mocks.swift
// iTokui
//
// Created by Justin Middleton on 6/6/17.
// Copyright © 2017 Kiban Labs, Inc. All rights reserved.
//
import Foundation
import PromiseKit
import OHHTTPStubs
import ReactiveSwift
import HTTPStatusCodes
@testable import Afero
// MARK: - MockDeviceCloudSupporting
class MockDeviceCloudSupporting: AferoCloudSupporting {
let persisting = MockDeviceTagPersisting()
func persistTag(tag: DeviceTagPersisting.DeviceTag, for deviceId: String, in accountId: String) -> Promise<DeviceTagPersisting.DeviceTag> {
return Promise {
fulfill, reject in
persisting.persist(tag: tag) {
maybeTag, maybeError in
if let error = maybeError {
reject(error)
return
}
if let tag = maybeTag {
fulfill(tag)
}
reject("No tag, but no error either.")
}
}
}
func purgeTag(with id: DeviceStreamEvent.Peripheral.DeviceTag.Id, for deviceId: String, in accountId: String) -> Promise<DeviceStreamEvent.Peripheral.DeviceTag.Id> {
return Promise {
fulfill, reject in
persisting.purgeTag(with: id) {
maybeId, maybeError in
if let error = maybeError {
reject(error)
return
}
if let id = maybeId {
fulfill(id)
}
reject("No tag, but no error either.")
}
}
}
var setLocationWasInvoked: Bool = false
var lastSetLocationArgsProvided: (location: DeviceLocation?, deviceId: String, accountId: String)?
var setLocationErrorToReturn: Error?
func setLocation(as location: DeviceLocation?, for deviceId: String, in accountId: String) -> Promise<Void> {
setLocationWasInvoked = true
if let error = setLocationErrorToReturn {
return Promise { _, reject in reject(error) }
}
return Promise { fulfill, _ in fulfill(()) }
}
var setTimezoneWasInvoked: Bool = false
var setTimeZoneResultToReturn: SetTimeZoneResult?
var settimeZoneErrorToReturn: Error?
func setTimeZone(as timeZone: TimeZone, isUserOverride: Bool, for deviceId: String, in accountId: String) -> Promise<SetTimeZoneResult> {
setTimezoneWasInvoked = true
if let error = settimeZoneErrorToReturn {
return Promise { _, reject in reject(error) }
}
guard let result = setTimeZoneResultToReturn else {
return Promise { _, reject in reject("Missing both result and error; pathological case.") }
}
return Promise { fulfill, _ in fulfill(result) }
}
var postResultsToReturn: DeviceBatchAction.Results?
var postErrorToReturn: Error?
var postWasInvoked: Bool = false
var postedActions: [DeviceBatchAction.Request] = []
func post(actions: [DeviceBatchAction.Request], forDeviceId deviceId: String, withAccountId accountId: String, onDone: @escaping WriteAttributeOnDone) {
postWasInvoked = true
postedActions = actions
onDone(postResultsToReturn, postErrorToReturn)
}
}
// MARK: - MockDeviceAccountProfileSource
class MockDeviceAccountProfilesSource: DeviceAccountProfilesSource {
var errorToReturn: Error?
var profileToReturn: DeviceProfile?
var fetchCompleteBlock: (()->())?
var fetchProfileByProfileIdRequestCount: Int = 0
func fetchProfile(accountId: String, profileId: String, onDone: @escaping FetchProfileOnDone) {
self.fetchProfileByProfileIdRequestCount += 1
DispatchQueue.global(qos: .userInitiated).async {
[weak self] in
if let errorToReturn = self?.errorToReturn {
onDone(nil, errorToReturn)
} else {
onDone(self?.profileToReturn, nil)
}
self?.fetchCompleteBlock?()
}
}
var fetchProfileByDeviceIdRequestCount: Int = 0
func fetchProfile(accountId: String, deviceId: String, onDone: @escaping FetchProfileOnDone) {
fetchProfileByDeviceIdRequestCount += 1
DispatchQueue.global(qos: .userInitiated).async {
[weak self] in
if let errorToReturn = self?.errorToReturn {
onDone(nil, errorToReturn)
} else {
onDone(self?.profileToReturn, nil)
}
self?.fetchCompleteBlock?()
}
}
var accountProfilesToReturn: [String: [DeviceProfile]] = [:]
var fetchProfilesByAccountIdRequestCount: Int = 0
func fetchProfiles(accountId: String, onDone: @escaping FetchProfilesOnDone) {
fetchProfilesByAccountIdRequestCount += 1
DispatchQueue.global(qos: .userInitiated).async {
[weak self] in
if let errorToReturn = self?.errorToReturn {
onDone(nil, errorToReturn)
} else {
onDone(self?.accountProfilesToReturn[accountId], nil)
}
self?.fetchCompleteBlock?()
}
}
}
// MARK: - MockDeviceCollectionDelegate
/// Mock class for testing consumers of `DeviceCollectionDelegate`.
//class MockDeviceCollectionDelegate: DeviceCollectionDelegate {
//
// convenience init(traceEnabledAccounts: [String] = [], shouldStartAccounts: [String] = []) {
// self.init()
// traceEnabledAccounts.forEach { traceTable[$0] = true }
// shouldStartAccounts.forEach { shouldStartTable[$0] = true }
// }
//
// var traceTable: [String: Bool] = [:]
//
// func setTraceEnabled(_ enabled: Bool, for accountId: String) {
// traceTable[accountId] = enabled
// }
//
// func clearTraceTable() { traceTable.removeAll() }
//
// var isTraceEnabledCallCount: Int = 0
//
// func isTraceEnabled(for accountId: String) -> Bool {
// isTraceEnabledCallCount += 1
// return traceTable[accountId] ?? false
// }
//
// var shouldStartTable: [String: Bool] = [:]
//
// func setShouldStart(_ shouldStart: Bool, for deviceCollection: DeviceCollection) {
// shouldStartTable[deviceCollection.accountId] = shouldStart
// }
//
// func clearShouldStartTable() { shouldStartTable.removeAll() }
//
// var shouldStartCallCount: Int = 0
//
// func deviceCollectionShouldStart(_ deviceCollection: DeviceCollection) -> Bool {
// shouldStartCallCount += 1
// return shouldStartTable[deviceCollection.accountId] ?? false
// }
//
//}
// MARK: - MockDeviceEventStreamable
class MockDeviceEventStreamable: DeviceEventStreamable {
var clientId: String
var accountId: String
init(clientId: String, accountId: String) {
self.clientId = clientId
self.accountId = accountId
}
/// The pipe which casts `DeviceStreamEvent`s.
lazy private final var eventPipe: DeviceStreamEventPipe = {
return DeviceStreamEventSignal.pipe()
}()
/// The `Signal` on which `DeviceStreamEvent`s can be received.
var eventSignal: DeviceStreamEventSignal? {
return eventPipe.0
}
/**
The `Sink` to which `DeviceStreamEvent`s are broadcast.
*/
var eventSink: DeviceStreamEventSink {
return eventPipe.1
}
private(set) var isStarted: Bool = false
var startError: Error?
var isTraceEnabled: Bool = false
func start(_ trace: Bool, onDone: @escaping (Error?) -> ()) {
isTraceEnabled = trace
isStarted = true
onDone(startError)
}
func stop() {
isStarted = false
}
func publishDeviceListRequest() { /* do nothing; for proto conformance */ }
var isViewingSet: Set<String> = []
func publishIsViewingNotification(_ isViewing: Bool, deviceId: String) {
guard isViewing else {
isViewingSet.remove(deviceId)
return
}
isViewingSet.insert(deviceId)
}
var lastMetrics: DeviceEventStreamable.Metrics?
func publish(metrics: DeviceEventStreamable.Metrics) {
lastMetrics = metrics
}
}
class MockAPIClient: AferoAPIClientProto {
// We stub out all of our calls using OHHTTPStubs, so we'll go through a real
// client, and just wrap those calls to inspect things like call verification
// where necessary.
private var realClient = AFNetworkingAferoAPIClient(
config: AFNetworkingAferoAPIClient.Config(
softhubService: "",
authenticatorCert: "",
oAuthAuthURL: "",
oAuthTokenURL: "",
oauthClientId: "mockClient123",
oauthClientSecret: "mockClient789"
)
)
// MARK: Testy Bits
private(set) var refreshOauthCount: Int = 0
func clearRefreshOauthCount() {
refreshOauthCount = 0
}
private(set) var signOutCount: Int = 0
func clearSignOutCount() {
signOutCount = 0
}
// MARK: <APIClientProto>
func doRefreshOAuth(passthroughError: Error?, success: @escaping () -> Void, failure: @escaping (Error) -> Void) {
refreshOauthCount += 1
realClient.doRefreshOAuth(passthroughError: passthroughError, success: success, failure: failure)
}
func doSignOut(error: Error?, completion: @escaping () -> Void) {
signOutCount += 1
realClient.doSignOut(error: error, completion: completion)
}
func doPut(urlString: String, parameters: Any?, httpRequestHeaders: HTTPRequestHeaders? = nil, success: @escaping AferoAPIClientProto.AferoAPIClientProtoSuccess, failure: @escaping AferoAPIClientProto.AferoAPIClientProtoFailure) -> URLSessionDataTask? {
return realClient.doPut(urlString: urlString, parameters: parameters, httpRequestHeaders: httpRequestHeaders, success: success, failure: failure)
}
func doPost(urlString: String, parameters: Any?, httpRequestHeaders: HTTPRequestHeaders? = nil, success: @escaping AferoAPIClientProto.AferoAPIClientProtoSuccess, failure: @escaping AferoAPIClientProto.AferoAPIClientProtoFailure) -> URLSessionDataTask? {
return realClient.doPost(urlString: urlString, parameters: parameters, httpRequestHeaders: httpRequestHeaders, success: success, failure: failure)
}
func doGet(urlString: String, parameters: Any?, httpRequestHeaders: HTTPRequestHeaders? = nil, success: @escaping AferoAPIClientProto.AferoAPIClientProtoSuccess, failure: @escaping AferoAPIClientProto.AferoAPIClientProtoFailure) -> URLSessionDataTask? {
return realClient.doGet(urlString: urlString, parameters: parameters, httpRequestHeaders: httpRequestHeaders, success: success, failure: failure)
}
func doDelete(urlString: String, parameters: Any?, httpRequestHeaders: HTTPRequestHeaders? = nil, success: @escaping AferoAPIClientProto.AferoAPIClientProtoSuccess, failure: @escaping AferoAPIClientProto.AferoAPIClientProtoFailure) -> URLSessionDataTask? {
return realClient.doDelete(urlString: urlString, parameters: parameters, httpRequestHeaders: httpRequestHeaders, success: success, failure: failure)
}
}
|
[
-1
] |
c8a6e135378cd501c7f0f726416e3bebfbc375d6
|
1dcecb07b3f898368a800f4c8aa2e9b7d84893ac
|
/TypetalkSwift/Requests/GetAccount.swift
|
dbb7c83ad12d05ff4b8dd59c7cfcabe794bb0d01
|
[
"MIT"
] |
permissive
|
dataich/TypetalkSwift
|
3f50c4d37e1b2c5c832c5569f25e45622972956b
|
6b6b565a10f167beee90a1a0127b25a06375aa91
|
refs/heads/master
| 2021-07-15T00:17:16.292370 | 2017-10-19T14:47:51 | 2017-10-20T06:27:11 | 107,558,745 | 1 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 767 |
swift
|
//
// GetAccount.swift
// TypetalkSwift
//
// Created by Taichiro Yoshida on 2017/10/15.
// Copyright © 2017 Nulab Inc. All rights reserved.
//
import Alamofire
// sourcery: AutoInit
public struct GetAccount: Request {
public let nameOrEmailAddress: String
public typealias Response = GetAccountResponse
public var path: String {
return "/search/accounts"
}
public var parameters: Parameters? {
var parameters: Parameters = [:]
parameters["nameOrEmailAddress"] = self.nameOrEmailAddress
return parameters
}
// sourcery:inline:auto:GetAccount.AutoInit
public init(nameOrEmailAddress: String) {
self.nameOrEmailAddress = nameOrEmailAddress
}
// sourcery:end
}
public typealias GetAccountResponse = AccountTrait
|
[
-1
] |
bb7ef345f1d16dc37295bc5e3fdf25b93c528ebc
|
fcddb5eb2ae7dfb7e29de7a78d3cd36d9bcca9de
|
/Source/MorphPlateauTabView.swift
|
15769cd9d2469d6164fa6237ea98f6cc6f054f1e
|
[
"MIT"
] |
permissive
|
Kaakati/SETabView
|
d94682cb4f4f8a82df7e70a9257ced831f5f54b9
|
9f34a4371ec522c01315321928e2f595054c1ad6
|
refs/heads/master
| 2022-11-30T09:35:13.553917 | 2020-08-12T22:43:48 | 2020-08-12T22:43:48 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 9,641 |
swift
|
//
// MorphPlateauTabView.swift
// SETabViewControl
//
// Created by Srivinayak Chaitanya Eshwa on 11/08/20.
// Copyright © 2020 Srivinayak Chaitanya Eshwa. All rights reserved.
//
import UIKit
class MorphPlateauTabView: UIView, AnimatedTabView {
// MARK: Properties: Tab
/// Specifies the current tab index selected
public var selectedTabIndex: Int = 0 {
didSet {
moveToSelectedTab()
}
}
private var previousTabIndex: Int = -1
/// Images for the tabBar icons
public var tabImages = [UIImage]() {
willSet {
if !tabImages.isEmpty {
fatalError("Tab images cannot be set multiple times")
}
}
didSet {
addTabImages()
}
}
private var numberOfTabs: Int {
return tabImages.count
}
/// the object that acts as the delegate of the SETabView
public weak var delegate: SETabViewDelegate?
// MARK: Properties: Layer
private var tabShapeLayer = SEShapeLayer()
private let ballLayer = SELayer()
private var ballLayerReplica = SELayer()
private var tabImageLayers = [SELayer]()
// MARK: Properties: Path
private var invertedPlateauPath: CGPath?
private var rectangularMorphPath: CGPath?
private var bumpPath: CGPath?
// MARK: Properties: Size
private var sectionWidth: CGFloat {
bounds.width / CGFloat(numberOfTabs)
}
private var sectionHeight: CGFloat {
bounds.height
}
private var itemWidth: CGFloat {
sectionWidth > 100 ? 100: sectionWidth
}
private var ballSize: CGFloat {
itemWidth / 2.0
}
private var iconSize: CGFloat {
ballSize / 1.8
}
private var itemHeight: CGFloat {
let height = bounds.height
return height > ballSize ? ballSize : height
}
private var heightScalingFactor: CGFloat {
itemWidth / 100
}
// MARK: Properties: Misc
public var isSetup = false
public var closureAfterSetup: (() -> Void)?
// MARK: Functions: Init
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
// MARK: Functions: Lifecycle
override open func layoutSubviews() {
super.layoutSubviews()
if !isSetup {
setupTabLayers()
isSetup = true
closureAfterSetup?()
}
}
}
// MARK: Setup
extension MorphPlateauTabView {
// sets up different layers of the tabBar
private func setupView() {
ballLayer.backgroundColor = SETabSettings.current.ballColor.cgColor
layer.addSublayer(ballLayer)
ballLayerReplica.backgroundColor = SETabSettings.current.ballColor.cgColor
layer.insertSublayer(ballLayerReplica, below: ballLayer)
tabShapeLayer.fillColor = SETabSettings.current.tabColor.cgColor
tabShapeLayer.lineWidth = 0.5
tabShapeLayer.position = CGPoint(x: 0, y: 0) // 10, 10 originally
backgroundColor = UIColor.clear
layer.addSublayer(tabShapeLayer)
previousTabIndex = 0
}
// adds the images as layers to the tabBar
private func addTabImages() {
tabImages.map { (image) -> CALayer in
let maskLayer = CALayer()
maskLayer.contents = image.cgImage
maskLayer.contentsGravity = .resizeAspect
let imageLayer = SELayer()
imageLayer.mask = maskLayer
tabImageLayers.append(imageLayer)
return imageLayer
}.forEach(layer.addSublayer(_:))
}
private func setupTabLayers() {
// setup ball layer
let ballLayerX = sectionWidth * 0.5 - (ballSize * 0.5) + (CGFloat(selectedTabIndex) * sectionWidth)
let ballLayerY = itemHeight * 0.25 - (ballSize * 0.5)
ballLayer.frame = CGRect(x: ballLayerX, y: ballLayerY, width: ballSize, height: ballSize)
ballLayer.cornerRadius = ballSize / 2.0
// setup shape layer
tabShapeLayer.frame = bounds
tabShapeLayer.path = createInvertedPlateauPath(withOffset: true)
// setup replica ball layer
ballLayerReplica.frame = CGRect(x: 200, y: 200, width: ballLayer.bounds.width, height: ballLayer.bounds.height)
ballLayerReplica.cornerRadius = ballSize / 2.0
self.invertedPlateauPath = self.createInvertedPlateauPath(withOffset: true)
self.bumpPath = self.createBumpMorph()
self.rectangularMorphPath = self.createRectangularMorphForPlateau()
// setup images
tabImageLayers.enumerated().forEach { (offset, imageLayer) in
let y = offset == Int(selectedTabIndex) ? 0 : (bounds.height / 2) - (iconSize / 2)
let x = (CGFloat(offset) * sectionWidth) + (sectionWidth / 2.0) - (iconSize / 2.0)
imageLayer.frame = CGRect(x: x, y: y, width: iconSize, height: iconSize)
imageLayer.mask?.frame = imageLayer.bounds
imageLayer.backgroundColor = offset == Int(selectedTabIndex) ? SETabSettings.current.selectedTabTintColor.cgColor : SETabSettings.current.deselectedTabTintColor.cgColor
}
}
}
// MARK: Paths
extension MorphPlateauTabView {
private func createInvertedPlateauPath(withOffset: Bool) -> CGPath {
var startOffset: CGFloat{
if withOffset {
return CGFloat(selectedTabIndex) * sectionWidth + ((sectionWidth - itemWidth) / 2)
}
else {
return 0
}
}
let coverOffset = CGFloat(numberOfTabs - 1) * sectionWidth
return SEPathProvider.getInvertedPlateauPath(for: bounds, startOffset: startOffset, coverOffset: coverOffset, itemWidth: itemWidth, sectionHeight: sectionHeight, heightScalingFactor: heightScalingFactor)
}
private func createRectangularMorphForPlateau() -> CGPath{
let startOffset: CGFloat = 0.0
let coverOffset = CGFloat(numberOfTabs - 1) * sectionWidth
return SEPathProvider.getRectangularMorphForPlateau(for: bounds, startOffset: startOffset, coverOffset: coverOffset, itemWidth: itemWidth, sectionHeight: sectionHeight)
}
private func createBumpMorph() -> CGPath {
let startOffset: CGFloat = 0.0
let coverOffset = CGFloat(numberOfTabs - 1) * sectionWidth
return SEPathProvider.getBumpMorph(for: bounds, startOffset: startOffset, coverOffset: coverOffset, itemWidth: itemWidth, sectionHeight: sectionHeight, heightScalingFactor: heightScalingFactor)
}
private func createRotateBallPaths() -> [String: CGPath] {
return SEPathProvider.createRotateBallPaths(forSelectedIndex: selectedTabIndex, previousTabIndex: previousTabIndex, sectionWidth: sectionWidth, ballLayerYPosition: ballLayer.position.y)
}
}
// MARK: Animations
extension MorphPlateauTabView {
private func moveToSelectedTab() {
if (selectedTabIndex == previousTabIndex) {
previousTabIndex = selectedTabIndex
return
}
translateShapeLayer()
if (abs(previousTabIndex - selectedTabIndex) == 1) {
rotateBall()
}
else {
morphShapeLayer()
translateBallLinear()
}
changeTintColor()
previousTabIndex = selectedTabIndex
}
private func translateShapeLayer() {
let toValue = CGFloat(selectedTabIndex) * sectionWidth + tabShapeLayer.position.x
tabShapeLayer.translate(to: toValue)
}
private func morphShapeLayer() {
tabShapeLayer.morph(using: [invertedPlateauPath!, rectangularMorphPath!, bumpPath!, bumpPath!, rectangularMorphPath!, invertedPlateauPath!])
}
private func translateBallLinear() {
let ballLayerX = sectionWidth * 0.5 - (ballSize * 0.5) + (CGFloat(selectedTabIndex) * sectionWidth)
let toValue = ballLayerX + ballSize / 2
ballLayer.translateLinear(to: toValue)
}
private func rotateBall() {
let rotatePaths = createRotateBallPaths()
ballLayerReplica.moveInPath(rotatePaths["hide"])
ballLayer.moveInPath(rotatePaths["show"], fillMode: .both)
}
private func changeTintColor() {
// apply animations
tabImageLayers
.enumerated()
.filter({ $0.offset != Int(selectedTabIndex) })
.forEach({
$0.element.removeHighlight()
$0.element.moveDown(to: sectionHeight / 2)
})
let selectedTabButton = tabImageLayers[Int(selectedTabIndex)]
selectedTabButton.highlight()
selectedTabButton.moveUp(to: iconSize / 2)
}
}
// MARK: Functions: Touches
extension MorphPlateauTabView {
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
guard let x = touches.first?.location(in: self).x else {
return
}
let index = floor(x/sectionWidth)
delegate?.didSelectTab(at: Int(index))
}
}
|
[
-1
] |
b408882ce272dd8dcbd209a468409fb3de873350
|
28f9eafb39ffa97771cbce183233bd26e745d934
|
/4_MyShoppingList/4_MyShoppingList/Item.swift
|
f217cb0155318512d34a71b95e5591364d50a5a3
|
[] |
no_license
|
181860006/IOS_Homework
|
ec702b32d7d4867d63a5e66f8148267ce6985f14
|
69cd62bf88468abf7d2d5c0c5ffb90d4c509a8d8
|
refs/heads/master
| 2023-02-23T01:13:41.346711 | 2021-01-25T11:36:07 | 2021-01-25T11:36:07 | 298,430,107 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 476 |
swift
|
//
// Item.swift
// 4_MyShoppingList
//
// Created by 陈劭彬 on 2020/11/13.
//
import UIKit
class Item
{
var name:String
var reason:String?
var wish:String?
var photo:UIImage?
init?(_ name:String, _ reason:String?, _ wish:String?, _ photo:UIImage?)
{
guard !name.isEmpty else
{
return nil
}
self.name = name
self.photo = photo
self.wish = wish
self.photo = photo
}
}
|
[
-1
] |
e31b6d853ecd34347aa1d338c60043007d226e14
|
d457d8634ce73c1321e44b5d4fa051be4c0b222e
|
/TagSafe/ViewController.swift
|
db4099dfa2ba01ab9050b50439434713c61a10df
|
[] |
no_license
|
jarnovanholsbeeck/TagSafe
|
18fc8acf4930145f43b4b664856397408255f978
|
4b9150a7477c7c07343a0d9c2008cb9145019560
|
refs/heads/master
| 2020-05-24T09:32:08.692956 | 2019-05-20T13:04:08 | 2019-05-20T13:04:08 | 187,208,559 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 4,853 |
swift
|
//
// ViewController.swift
// TagSafe
//
// Created by Jarno Van Holsbeeck on 17/05/2019.
// Copyright © 2019 Erasmix4. All rights reserved.
//
import UIKit
import Firebase
import TagListView
class ViewController: UIViewController, TagListViewDelegate {
@IBOutlet weak var SearchBar: UISearchBar!
@IBOutlet weak var AddButton: UIButton!
@IBOutlet weak var RecordAudioButton: UIButton!
@IBOutlet weak var RecordVideoButton: UIButton!
@IBOutlet weak var TakeNoteButton: UIButton!
@IBOutlet weak var tagListView: TagListView!
@IBOutlet weak var scrollView: UIScrollView!
var audioButtonCenter: CGPoint!
var videoButtonCenter: CGPoint!
var noteButtonCenter: CGPoint!
var db: Firestore?
override func viewDidLoad() {
super.viewDidLoad()
db = Firestore.firestore()
db!.collection("tags").getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
print("\(document.documentID) => \(document.data())")
}
}
}
editSearchBar()
addRecentTags()
addRecentStories()
audioButtonCenter = RecordAudioButton.center
videoButtonCenter = RecordVideoButton.center
noteButtonCenter = TakeNoteButton.center
RecordAudioButton.center = AddButton.center
RecordVideoButton.center = AddButton.center
TakeNoteButton.center = AddButton.center
}
func editSearchBar() {
if let textfield = SearchBar.value(forKey: "searchField") as? UITextField {
textfield.backgroundColor = UIColor(red:1.00, green:1.00, blue:1.00, alpha:1.0)
textfield.borderStyle = .none
textfield.borderStyle = .roundedRect
textfield.font = UIFont(name: "calibretest_regular", size: 14)
if let leftView = textfield.leftView as? UIImageView {
leftView.image = leftView.image?.withRenderingMode(.alwaysTemplate)
leftView.tintColor = UIColor(red:0.00, green:0.42, blue:1.00, alpha:1.0)
}
}
}
func addRecentTags() {
self.tagListView.addTags(["Accident", "Traffic", "Politics", "Economy", "Domestic Violence", "Environment", "Climate", "Traffic", "Politics", "Economy"])
}
func addRecentStories() {
var scrollWidth = 0
for n in 0...4 {
let startX = 8 + (n * 158)
scrollWidth = startX + 158
let story = StoryCardController(frame: CGRect(x: startX, y: 8, width: 150, height: 220), image: UIImage(named: "TestStory")!, name: "Traffic Jam", date: "15-06-2019", hasImage: true, hasVideo: true, hasAudio: true, hasNote: false)
scrollView.addSubview(story)
}
self.scrollView.contentSize = CGSize(width: scrollWidth, height: 236)
}
func tagPressed(_ title: String, tagView: TagView, sender: TagListView) {
tagView.isSelected = !tagView.isSelected
tagView.selectedBackgroundColor = UIColor.darkGray
}
@IBAction func addButtonClicked(_ sender: UIButton) {
if sender.currentImage == UIImage(named: "addicon") {
UIView.transition(with: sender, duration: 0.4, options: .transitionCrossDissolve, animations: {
sender.setImage(UIImage(named: "closeicon"), for: .normal)
}, completion: nil)
// expand buttons
UIView.animate(withDuration: 0.4, animations: {
self.RecordAudioButton.alpha = 1
self.RecordVideoButton.alpha = 1
self.TakeNoteButton.alpha = 1
self.RecordAudioButton.center = self.audioButtonCenter
self.RecordVideoButton.center = self.videoButtonCenter
self.TakeNoteButton.center = self.noteButtonCenter
})
} else {
UIView.transition(with: sender, duration: 0.4, options: .transitionCrossDissolve, animations: {
sender.setImage(UIImage(named: "addicon"), for: .normal)
}, completion: nil)
// hide buttons
UIView.animate(withDuration: 0.4, animations: {
self.RecordAudioButton.alpha = 0
self.RecordVideoButton.alpha = 0
self.TakeNoteButton.alpha = 0
self.RecordAudioButton.center = self.AddButton.center
self.RecordVideoButton.center = self.AddButton.center
self.TakeNoteButton.center = self.AddButton.center
})
}
}
}
|
[
-1
] |
de2c317ade1ea2ff89d31b3dab3011768b50798f
|
861115b2696f63130d152f3245b45a76b1ee708f
|
/SWUtils/Operators.swift
|
657aee5e3b34c0355c754f55b4bcfaa32dc216da
|
[
"MIT"
] |
permissive
|
mhtranbn/SWUtils
|
70b95af9bc9dd3fb690ff86289d0232dc0a38fe1
|
bd55f34dc5c1f87fcad78e554881cb852715b31d
|
refs/heads/master
| 2021-08-11T07:43:50.061375 | 2017-11-13T10:28:19 | 2017-11-13T10:28:19 | 110,501,998 | 2 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 15,202 |
swift
|
//
// Operators.swift
// SWUtils
//
// Created by mhtran on 11/13/17.
// Copyright © 2017 mhtran. All rights reserved.
//
import Foundation
public typealias SWInt = NSNumber
public typealias SWFloat = NSNumber
public typealias SWDouble = NSNumber
public typealias NUM = NSNumber
// MARK: - Number operations
public func %(left: Float, right: Float) -> Float {
return left.truncatingRemainder(dividingBy: right)
}
public func %(left: Double, right: Double) -> Double {
return left.truncatingRemainder(dividingBy: right)
}
public func %(left: Float, right: Double) -> Double {
return Double(left).truncatingRemainder(dividingBy: right)
}
public func %(left: Double, right: Float) -> Double {
return left.truncatingRemainder(dividingBy: Double(right))
}
public func %(left: Int, right: Double) -> Double {
return Double(left).truncatingRemainder(dividingBy: right)
}
public func %(left: Double, right: Int) -> Double {
return left.truncatingRemainder(dividingBy: Double(right))
}
public func %(left: Int, right: Float) -> Float {
return Float(left).truncatingRemainder(dividingBy: right)
}
public func %(left: Float, right: Int) -> Float {
return left.truncatingRemainder(dividingBy: Float(right))
}
public func ceilToInt(_ val: Float) -> Int {
return Int(ceilf(val))
}
public func ceilToInt(_ val: Double) -> Int {
return Int(ceil(val))
}
public func floorToInt(_ val: Float) -> Int {
return Int(floorf(val))
}
public func floorToInt(_ val: Double) -> Int {
return Int(floor(val))
}
public func roundToInt(_ val: Float) -> Int {
return Int(roundf(val))
}
public func roundToInt(_ val: Double) -> Int {
return Int(round(val))
}
// MARK: - NSNumber operations
public func +(left: NSNumber, right: Int) -> NSNumber {
return NSNumber(value: left.intValue + right)
}
public func +(left: Int, right: NSNumber) -> Int {
return left + right.intValue
}
public func -(left: NSNumber, right: Int) -> NSNumber {
return NSNumber(value: left.intValue - right)
}
public func -(left: Int, right: NSNumber) -> Int {
return left - right.intValue
}
public func *(left: NSNumber, right: Int) -> NSNumber {
return NSNumber(value: left.intValue * right)
}
public func *(left: Int, right: NSNumber) -> Int {
return left * right.intValue
}
public func /(left: NSNumber, right: Int) -> NSNumber {
return NSNumber(value: left.intValue / right)
}
public func /(left: Int, right: NSNumber) -> Int {
return left / right.intValue
}
public func %(left: NSNumber, right: Int) -> NSNumber {
return NSNumber(value: left.intValue % right)
}
public func %(left: Int, right: NSNumber) -> Int {
return left % right.intValue
}
public func +=(left: inout NSNumber, right: Int) {
left = NSNumber(value: left.intValue + right)
}
public func +=(left: inout Int, right: NSNumber) {
left = left + right.intValue
}
public func -=(left: inout NSNumber, right: Int) {
left = NSNumber(value: left.intValue - right)
}
public func -(left: inout Int, right: NSNumber) {
left = left - right.intValue
}
public func *(left: inout NSNumber, right: Int) {
left = NSNumber(value: left.intValue * right)
}
public func *(left: inout Int, right: NSNumber) {
left = left * right.intValue
}
public func /(left: inout NSNumber, right: Int) {
left = NSNumber(value: left.intValue / right)
}
public func /(left: inout Int, right: NSNumber) {
left = left / right.intValue
}
public func +(left: NSNumber, right: Float) -> NSNumber {
return NSNumber(value: left.floatValue + right)
}
public func +(left: Float, right: NSNumber) -> Float {
return left + right.floatValue
}
public func -(left: NSNumber, right: Float) -> NSNumber {
return NSNumber(value: left.floatValue - right)
}
public func -(left: Float, right: NSNumber) -> Float {
return left - right.floatValue
}
public func *(left: NSNumber, right: Float) -> NSNumber {
return NSNumber(value: left.floatValue * right)
}
public func *(left: Float, right: NSNumber) -> Float {
return left * right.floatValue
}
public func /(left: NSNumber, right: Float) -> NSNumber {
return NSNumber(value: left.floatValue / right)
}
public func /(left: Float, right: NSNumber) -> Float {
return left / right.floatValue
}
public func %(left: NSNumber, right: Float) -> NSNumber {
return NSNumber(value: left.floatValue % right)
}
public func %(left: Float, right: NSNumber) -> Float {
return left % right.floatValue
}
public func +=(left: inout NSNumber, right: Float) {
left = NSNumber(value: left.floatValue + right)
}
public func +=(left: inout Float, right: NSNumber) {
left = left + right.floatValue
}
public func -=(left: inout NSNumber, right: Float) {
left = NSNumber(value: left.floatValue - right)
}
public func -(left: inout Float, right: NSNumber) {
left = left - right.floatValue
}
public func *(left: inout NSNumber, right: Float) {
left = NSNumber(value: left.floatValue * right)
}
public func *(left: inout Float, right: NSNumber) {
left = left * right.floatValue
}
public func /(left: inout NSNumber, right: Float) {
left = NSNumber(value: left.floatValue / right)
}
public func /(left: inout Float, right: NSNumber) {
left = left / right.floatValue
}
public func +(left: NSNumber, right: Double) -> NSNumber {
return NSNumber(value: left.doubleValue + right)
}
public func +(left: Double, right: NSNumber) -> Double {
return left + right.doubleValue
}
public func -(left: NSNumber, right: Double) -> NSNumber {
return NSNumber(value: left.doubleValue - right)
}
public func -(left: Double, right: NSNumber) -> Double {
return left - right.doubleValue
}
public func *(left: NSNumber, right: Double) -> NSNumber {
return NSNumber(value: left.doubleValue * right)
}
public func *(left: Double, right: NSNumber) -> Double {
return left * right.doubleValue
}
public func /(left: NSNumber, right: Double) -> NSNumber {
return NSNumber(value: left.doubleValue / right)
}
public func /(left: Double, right: NSNumber) -> Double {
return left / right.doubleValue
}
public func %(left: NSNumber, right: Double) -> NSNumber {
return NSNumber(value: left.doubleValue % right)
}
public func %(left: Double, right: NSNumber) -> Double {
return left % right.doubleValue
}
public func +=(left: inout NSNumber, right: Double) {
left = NSNumber(value: left.doubleValue + right)
}
public func +=(left: inout Double, right: NSNumber) {
left = left + right.doubleValue
}
public func -=(left: inout NSNumber, right: Double) {
left = NSNumber(value: left.doubleValue - right)
}
public func -(left: inout Double, right: NSNumber) {
left = left - right.doubleValue
}
public func *(left: inout NSNumber, right: Double) {
left = NSNumber(value: left.doubleValue * right)
}
public func *(left: inout Double, right: NSNumber) {
left = left * right.doubleValue
}
public func /(left: inout NSNumber, right: Double) {
left = NSNumber(value: left.doubleValue / right)
}
public func /(left: inout Double, right: NSNumber) {
left = left / right.doubleValue
}
// MARK: - NSNumber comparison
public func ==(left: NSNumber, right: Int) -> Bool {
return left.intValue == right
}
public func !=(left: NSNumber, right: Int) -> Bool {
return left.intValue != right
}
public func <(left: NSNumber, right: Int) -> Bool {
return left.intValue < right
}
public func <=(left: NSNumber, right: Int) -> Bool {
return left.intValue <= right
}
public func >(left: NSNumber, right: Int) -> Bool {
return left.intValue > right
}
public func >=(left: NSNumber, right: Int) -> Bool {
return left.intValue >= right
}
public func ==(left: Int, right: NSNumber) -> Bool {
return left == right.intValue
}
public func !=(left: Int, right: NSNumber) -> Bool {
return left != right.intValue
}
public func <(left: Int, right: NSNumber) -> Bool {
return left < right.intValue
}
public func <=(left: Int, right: NSNumber) -> Bool {
return left <= right.intValue
}
public func >(left: Int, right: NSNumber) -> Bool {
return left > right.intValue
}
public func >=(left: Int, right: NSNumber) -> Bool {
return left >= right.intValue
}
public func ==(left: NSNumber, right: Double) -> Bool {
return left.doubleValue == right
}
public func !=(left: NSNumber, right: Double) -> Bool {
return left.doubleValue != right
}
public func <(left: NSNumber, right: Double) -> Bool {
return left.doubleValue < right
}
public func <=(left: NSNumber, right: Double) -> Bool {
return left.doubleValue <= right
}
public func >(left: NSNumber, right: Double) -> Bool {
return left.doubleValue > right
}
public func >=(left: NSNumber, right: Double) -> Bool {
return left.doubleValue >= right
}
public func ==(left: Double, right: NSNumber) -> Bool {
return left == right.doubleValue
}
public func !=(left: Double, right: NSNumber) -> Bool {
return left != right.doubleValue
}
public func <(left: Double, right: NSNumber) -> Bool {
return left < right.doubleValue
}
public func <=(left: Double, right: NSNumber) -> Bool {
return left <= right.doubleValue
}
public func >(left: Double, right: NSNumber) -> Bool {
return left > right.doubleValue
}
public func >=(left: Double, right: NSNumber) -> Bool {
return left >= right.doubleValue
}
public func ==(left: NSNumber, right: Float) -> Bool {
return left.floatValue == right
}
public func !=(left: NSNumber, right: Float) -> Bool {
return left.floatValue != right
}
public func <(left: NSNumber, right: Float) -> Bool {
return left.floatValue < right
}
public func <=(left: NSNumber, right: Float) -> Bool {
return left.floatValue <= right
}
public func >(left: NSNumber, right: Float) -> Bool {
return left.floatValue > right
}
public func >=(left: NSNumber, right: Float) -> Bool {
return left.floatValue >= right
}
public func ==(left: Float, right: NSNumber) -> Bool {
return left == right.floatValue
}
public func !=(left: Float, right: NSNumber) -> Bool {
return left != right.floatValue
}
public func <(left: Float, right: NSNumber) -> Bool {
return left < right.floatValue
}
public func <=(left: Float, right: NSNumber) -> Bool {
return left <= right.floatValue
}
public func >(left: Float, right: NSNumber) -> Bool {
return left > right.floatValue
}
public func >=(left: Float, right: NSNumber) -> Bool {
return left >= right.floatValue
}
// MARK: - Geometry value operations
/// - parameter left: Left rect
/// - parameter right: Right rect
///
/// - returns: Union of 2 rects
public func +(left: CGRect, right: CGRect) -> CGRect {
return left.union(right)
}
/// - parameter left: Left rect
/// - parameter right: Right rect
///
/// - returns: Intersection of 2 rects
public func %(left: CGRect, right: CGRect) -> CGRect {
return left.intersection(right)
}
/// - parameter left: Left rect
/// - parameter right: Size to inset
///
/// - returns: left.insetBy(right)
public func +(left: CGRect, right: CGSize) -> CGRect {
return left.insetBy(dx: right.width, dy: right.height)
}
/// - parameter left: Left rect
/// - parameter right: Size to offset
///
/// - returns: left.offsetBy(right)
public func +(left: CGRect, right: CGPoint) -> CGRect {
return left.offsetBy(dx: right.x, dy: right.y)
}
// MARK: - Geometry value comparison
public func ==(left: CGPoint, right: CGPoint) -> Bool {
return left.equalTo(right)
}
public func ==(left: CGSize, right: CGSize) -> Bool {
return left.equalTo(right)
}
public func ==(left: CGRect, right: CGRect) -> Bool {
return left.equalTo(right)
}
// MARK: - Collection operations
/**
Make an new dicitonary with given dicitonary
- parameter left: Left dic
- parameter right: Right dic
- returns: Dic from left & right dic. If left & right have same keys, use values from right
*/
public func +<Key: Hashable, Value>(left: Dictionary<Key, Value>, right: Dictionary<Key, Value>) -> Dictionary<Key, Value> {
var result = Dictionary<Key, Value>()
for key in left.keys {
result[key] = left[key]
}
for key in right.keys {
result[key] = right[key]
}
return result
}
/**
Import key-value from right dic into left dic
- parameter left: Left dic
- parameter right: Right dic
*/
public func +=<Key: Hashable, Value>(left: inout Dictionary<Key, Value>, right: Dictionary<Key, Value>) {
for key in right.keys {
left[key] = right[key]
}
}
/**
Remove values from dictionary
- parameter left: Dictionary to remove value
- parameter right: List of values to remove
- returns: New dictionary
*/
public func -<Key: Hashable, Value: Equatable>(left: Dictionary<Key, Value>, right: Array<Value>) -> Dictionary<Key, Value> {
var result = Dictionary<Key, Value>()
for key in left.keys {
let val = left[key]!
if !right.contains(val) {
result[key] = val
}
}
return result
}
/**
Remove value from dictionary
- parameter left: Dictionary to remove values
- parameter right: List of values to remove
*/
public func -=<Key: Hashable, Value: Equatable>(left: inout Dictionary<Key, Value>, right: Array<Value>) {
var keyToRemove = [Key]()
for key in left.keys {
let val = left[key]!
if right.contains(val) {
keyToRemove.append(key)
}
}
for key in keyToRemove {
left[key] = nil
}
}
// MARK: - Collections comparison
/// Compare 2 Any object
///
/// - parameter left: Left object
/// - parameter right: Right object
/// - parameter t: Any class you want
///
/// - returns: true if 2 objects are equal following Equaltable protocol
//public func equalAny<T: Equatable>(left: Any, right: Any, _ t: T.Type) -> Bool {
// if let l = left as? [Any], let r = right as? [Any] {
// return l == r
// }
// if let l = left as? [AnyHashable: Any], let r = right as? [AnyHashable: Any] {
// return l == r
// }
// if let l = left as? T, let r = right as? T {
// return l == r
// }
// if let l = left as? CGPoint, let r = right as? CGPoint {
// return l == r
// }
// if let l = left as? CGSize, let r = right as? CGSize {
// return l == r
// }
// if let l = left as? CGRect, let r = right as? CGRect {
// return l == r
// }
// return false
//}
//
//public func ==(left: [Any], right: [Any]) -> Bool {
// if left.count == right.count {
// for i in 0 ..< left.count {
// if !equalAny(left: left[i], right: right[i], NSObject.self) {
// return false
// }
// }
// return true
// }
// return false
//}
//public func ==(left: [AnyHashable: Any], right: [AnyHashable: Any]) -> Bool {
// let lKeys = [AnyHashable](left.keys)
// if left.count == right.count, lKeys == [AnyHashable](right.keys) {
// for k in lKeys {
// if !equalAny(left: left[k]!, right: right[k]!, NSObject.self) {
// return false
// }
// }
// return true
// }
// return false
//}
|
[
-1
] |
369d8c97db6f951faec709af8f5ce91347c0410f
|
f8d96a309c055298510324f92ae411c5557e46bd
|
/Demo/ImageContainerView.swift
|
1988df2fe33af19028071e666085e6bae5b65c49
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
tomaculum/Neon
|
65d4d15c9744b70fb5a37b835af8dc2368bc5c7f
|
8afec45105a53b662ef041824d5a84380283f9ed
|
refs/heads/master
| 2021-05-26T04:05:38.257098 | 2020-04-08T10:16:58 | 2020-04-08T10:16:58 | 254,045,829 | 0 | 1 |
MIT
| 2020-04-08T09:39:35 | 2020-04-08T09:39:34 | null |
UTF-8
|
Swift
| false | false | 1,124 |
swift
|
//
// ImageContainerView.swift
// Neon
//
// Created by Mike on 9/26/15.
// Copyright © 2015 Mike Amaral. All rights reserved.
//
import UIKit
import Neon
class ImageContainerView: UIView {
let imageView : UIImageView = UIImageView()
let label : UILabel = UILabel()
convenience init() {
self.init(frame: CGRect.zero)
self.backgroundColor = UIColor.white
self.layer.cornerRadius = 4.0
self.layer.borderWidth = 1.0
self.layer.borderColor = UIColor(white: 0.68, alpha: 1.0).cgColor
self.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
self.addSubview(imageView)
label.textAlignment = .center
label.textColor = UIColor.black
label.font = UIFont.boldSystemFont(ofSize: 14.0)
self.addSubview(label)
}
override func layoutSubviews() {
super.layoutSubviews()
imageView.anchorAndFillEdge(.top, xPad: 0, yPad: 0, otherSize: self.height * 0.7)
label.alignAndFill(align: .underCentered, relativeTo: imageView, padding: 0)
}
}
|
[
-1
] |
de41de45f20f8c88d6ddc824e7d83b046c201c22
|
1bfbead3737a2677de4fcf60b76b66ceb915c758
|
/ToDoListUITests/ToDoListUITests.swift
|
bae8f916a7f33d42c99d942b881b5d543192fcd3
|
[] |
no_license
|
Adnan1990/toDoList
|
a82f2e5a2ec3d67e49d91f23082229f94c1f2a71
|
9f33d7b4d77fd4e30de874703967703d0e2ae2c7
|
refs/heads/master
| 2020-08-06T06:43:21.307522 | 2019-10-05T08:29:03 | 2019-10-05T08:29:03 | 212,876,071 | 1 | 0 | null | 2019-10-04T18:11:11 | 2019-10-04T18:11:10 | null |
UTF-8
|
Swift
| false | false | 1,252 |
swift
|
//
// ToDoListUITests.swift
// ToDoListUITests
//
// Created by Ishaq Shafiq on 11/09/2017.
// Copyright © 2017 Ishaq Shafiq. All rights reserved.
//
import XCTest
class ToDoListUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
155665,
237599,
229414,
278571,
229425,
229431,
180279,
319543,
213051,
286787,
237638,
311373,
196687,
278607,
311377,
368732,
180317,
278637,
319599,
278642,
131190,
131199,
278669,
278676,
311447,
327834,
278684,
278690,
311459,
278698,
278703,
278707,
180409,
278713,
295099,
139459,
131270,
229591,
147679,
311520,
147680,
319719,
295147,
286957,
319764,
278805,
311582,
278817,
311596,
336177,
98611,
278843,
287040,
319812,
311622,
229716,
278895,
287089,
139641,
311679,
311692,
106893,
156069,
311723,
377265,
311739,
319931,
278974,
336319,
311744,
278979,
336323,
278988,
278992,
279000,
369121,
279009,
188899,
279014,
319976,
279017,
311787,
319986,
279030,
311800,
279033,
279042,
287237,
377352,
279053,
303634,
303635,
279060,
279061,
279066,
188954,
279092,
377419,
303693,
115287,
189016,
287319,
295518,
287327,
279143,
279150,
287345,
287348,
189054,
287359,
303743,
164487,
279176,
311944,
344714,
311948,
311950,
311953,
336531,
287379,
295575,
303772,
221853,
205469,
279207,
295591,
295598,
279215,
279218,
164532,
287412,
287418,
303802,
66243,
287434,
287438,
279249,
303826,
369365,
369366,
279253,
230105,
295653,
230120,
312046,
279278,
230133,
279293,
205566,
295688,
312076,
295698,
221980,
336678,
262952,
262953,
279337,
262957,
164655,
328495,
303921,
230198,
222017,
295745,
279379,
295769,
230238,
230239,
279393,
303973,
279398,
295797,
295799,
279418,
336765,
287623,
279434,
320394,
189327,
189349,
279465,
304050,
189373,
213956,
345030,
213961,
279499,
304086,
304104,
123880,
320492,
320495,
287730,
320504,
312313,
214009,
312317,
328701,
328705,
418819,
320520,
230411,
320526,
238611,
140311,
238617,
197658,
336930,
132140,
189487,
312372,
238646,
238650,
320571,
336962,
238663,
205911,
296023,
156763,
230500,
214116,
279659,
279666,
312435,
230514,
238706,
279686,
222344,
337037,
296091,
238764,
148674,
312519,
279752,
148687,
189651,
279766,
189656,
279775,
304352,
304353,
279780,
279789,
279803,
320769,
312588,
320795,
320802,
304422,
312628,
345398,
222523,
181568,
279872,
279874,
304457,
345418,
230730,
337228,
296269,
222542,
238928,
296274,
230757,
296304,
312688,
230772,
337280,
296328,
296330,
304523,
9618,
279955,
148899,
279979,
279980,
173492,
279988,
280003,
370122,
280011,
337359,
329168,
312785,
222674,
329170,
280020,
280025,
239069,
320997,
280042,
280043,
329198,
337391,
296434,
288248,
288252,
312830,
230922,
329231,
304655,
230933,
222754,
312879,
230960,
288305,
239159,
157246,
288319,
288322,
280131,
124486,
288328,
230999,
239192,
99937,
345697,
312937,
312941,
206447,
288377,
337533,
280193,
239238,
288391,
239251,
280217,
198304,
337590,
280252,
280253,
296636,
321217,
280259,
321220,
296649,
239305,
280266,
9935,
313042,
280279,
18139,
280285,
321250,
337638,
181992,
288492,
34547,
67316,
313082,
288508,
288515,
280326,
116491,
280333,
124691,
116502,
321308,
321309,
280367,
280373,
280377,
321338,
280381,
345918,
280386,
280391,
280396,
337746,
18263,
370526,
296807,
296815,
313200,
313204,
124795,
182145,
280451,
67464,
305032,
214936,
337816,
329627,
239515,
214943,
313257,
288698,
214978,
280517,
280518,
214983,
231382,
329696,
190437,
313322,
329707,
174058,
296942,
124912,
313338,
239610,
182277,
313356,
305173,
223269,
354342,
354346,
313388,
124974,
321589,
215095,
288829,
288835,
313415,
239689,
354386,
329812,
223317,
321632,
280676,
313446,
215144,
288878,
288890,
215165,
329884,
215204,
125108,
280761,
223418,
280767,
338118,
280779,
321744,
280792,
280803,
182503,
338151,
125166,
125170,
395511,
313595,
125184,
125192,
125197,
125200,
125204,
338196,
125215,
125225,
338217,
321839,
125236,
280903,
289109,
379224,
239973,
313703,
280938,
321901,
354671,
354672,
199030,
223611,
248188,
313726,
240003,
158087,
313736,
240020,
190870,
190872,
289185,
305572,
289195,
338359,
289229,
281038,
281039,
281071,
322057,
182802,
322077,
289328,
338491,
322119,
281165,
281170,
281200,
313970,
297600,
289435,
314020,
248494,
166581,
314043,
363212,
158424,
322269,
338658,
289511,
330473,
330476,
289517,
215790,
125683,
199415,
289534,
322302,
35584,
322312,
346889,
264971,
322320,
166677,
207639,
281378,
289580,
281407,
289599,
281426,
281434,
322396,
281444,
207735,
314240,
158594,
330627,
240517,
289691,
240543,
289699,
289704,
289720,
289723,
281541,
19398,
191445,
183254,
207839,
314343,
183276,
289773,
248815,
240631,
330759,
330766,
330789,
248871,
281647,
322609,
314437,
207954,
339031,
314458,
281698,
281699,
322664,
314493,
150656,
347286,
330912,
339106,
306339,
249003,
208044,
322733,
3243,
339131,
290001,
339167,
298209,
290030,
208123,
322826,
126229,
298290,
208179,
159033,
216387,
372039,
224591,
331091,
314708,
150868,
314711,
314721,
281958,
314727,
134504,
306541,
314734,
314740,
314742,
314745,
290170,
224637,
306558,
290176,
314752,
306561,
314759,
298378,
314765,
314771,
306580,
224662,
282008,
314776,
282013,
290206,
314788,
314790,
282023,
298406,
241067,
314797,
306630,
306634,
339403,
191980,
282097,
306678,
191991,
290304,
323079,
323083,
323088,
282132,
282135,
175640,
282147,
306730,
290359,
323132,
282182,
224848,
224852,
290391,
306777,
323171,
282214,
224874,
314997,
290425,
339579,
282244,
323208,
282248,
323226,
282272,
282279,
298664,
298666,
306875,
282302,
323262,
323265,
282309,
306891,
241360,
282321,
241366,
282330,
282336,
12009,
282347,
282349,
323315,
200444,
282366,
249606,
282375,
323335,
282379,
216844,
118549,
282390,
282399,
241440,
282401,
339746,
315172,
216868,
241447,
282418,
282424,
282428,
413500,
241471,
315209,
159563,
307024,
307030,
241494,
307038,
282471,
282476,
339840,
315265,
282503,
315272,
315275,
184207,
282517,
298912,
118693,
298921,
126896,
200628,
282572,
282573,
323554,
298987,
282634,
241695,
315431,
315433,
102441,
102446,
282671,
241717,
307269,
233548,
315468,
315477,
200795,
323678,
315488,
315489,
45154,
217194,
233578,
307306,
249976,
241809,
323730,
299166,
233635,
299176,
184489,
323761,
184498,
258233,
299197,
299202,
176325,
299208,
233678,
282832,
356575,
307431,
184574,
217352,
315674,
282908,
299294,
282912,
233761,
282920,
315698,
332084,
282938,
168251,
127292,
307514,
323914,
201037,
282959,
250196,
168280,
323934,
381286,
242027,
242028,
250227,
315768,
315769,
291194,
291193,
291200,
242059,
315798,
291225,
242079,
283039,
299449,
291266,
373196,
283088,
283089,
242138,
176602,
160224,
291297,
283138,
233987,
324098,
340489,
283154,
291359,
283185,
234037,
340539,
332379,
111197,
242274,
291455,
316044,
184974,
316048,
316050,
340645,
176810,
299698,
291529,
225996,
135888,
242385,
299737,
234216,
234233,
242428,
291584,
299777,
291591,
291605,
283418,
234276,
283431,
234290,
201534,
283466,
201562,
234330,
275294,
349025,
357219,
177002,
308075,
242540,
242542,
201590,
177018,
308093,
291713,
340865,
299912,
316299,
234382,
308111,
308113,
209820,
283551,
177074,
127945,
340960,
234469,
340967,
324587,
234476,
201721,
234499,
234513,
316441,
300087,
21567,
308288,
160834,
349254,
300109,
234578,
250965,
250982,
234606,
300145,
300147,
234626,
234635,
177297,
308375,
324761,
119965,
234655,
300192,
234662,
300200,
324790,
300215,
283841,
283846,
283849,
316628,
251124,
316661,
283894,
234741,
292092,
234756,
242955,
177420,
292145,
300342,
333114,
333115,
193858,
300354,
300355,
234830,
283990,
357720,
300378,
300379,
316764,
292194,
284015,
234864,
316786,
243073,
292242,
112019,
234902,
333224,
284086,
259513,
284090,
54719,
415170,
292291,
300488,
300490,
234957,
144862,
300526,
308722,
300539,
210429,
292359,
218632,
316951,
374297,
235069,
349764,
194118,
292424,
292426,
333389,
349780,
128600,
235096,
300643,
300645,
243306,
325246,
333438,
235136,
317102,
300729,
333508,
333522,
325345,
153318,
333543,
284410,
284425,
300810,
300812,
284430,
161553,
284436,
325403,
341791,
325411,
186148,
186149,
333609,
284460,
300849,
325444,
153416,
325449,
317268,
325460,
341846,
284508,
300893,
284515,
276326,
292713,
292719,
325491,
333687,
317305,
317308,
325508,
333700,
243590,
243592,
325514,
350091,
350092,
350102,
333727,
219046,
333734,
284584,
292783,
300983,
153553,
292835,
6116,
292838,
317416,
325620,
333827,
243720,
292901,
325675,
243763,
325695,
333902,
194667,
284789,
284790,
292987,
194692,
235661,
333968,
153752,
284827,
333990,
284840,
284843,
227517,
309443,
227525,
301255,
227536,
301270,
301271,
325857,
334049,
317676,
309504,
194832,
227601,
325904,
334104,
211239,
334121,
317738,
325930,
227655,
383309,
391521,
285031,
416103,
227702,
211327,
227721,
285074,
227730,
285083,
293275,
317851,
227743,
285089,
293281,
301482,
375211,
334259,
293309,
317889,
326083,
129484,
326093,
285152,
195044,
334315,
236020,
293368,
317949,
342537,
309770,
334345,
342560,
227881,
293420,
236080,
23093,
244279,
244280,
301635,
309831,
55880,
301647,
326229,
309847,
244311,
244326,
301688,
244345,
301702,
334473,
326288,
227991,
285348,
318127,
285360,
293552,
285362,
342705,
154295,
342757,
285419,
170735,
342775,
375552,
228099,
285443,
285450,
326413,
285457,
285467,
326428,
318247,
293673,
318251,
301872,
285493,
285496,
301883,
342846,
293702,
318279,
244569,
301919,
293729,
351078,
310132,
228214,
269179,
228232,
416649,
236427,
252812,
293780,
310166,
310177,
293801,
326571,
326580,
326586,
359365,
211913,
326602,
56270,
203758,
293894,
293911,
326684,
113710,
318515,
203829,
285795,
228457,
318571,
187508,
302202,
285819,
285823,
285833,
318602,
285834,
228492,
162962,
187539,
326803,
285850,
302239,
302251,
294069,
294075,
64699,
228541,
343230,
310496,
228587,
302319,
228608,
318732,
245018,
318746,
130342,
130344,
130347,
286012,
294210,
294220,
318804,
294236,
327023,
327030,
310650,
179586,
294278,
318860,
368012,
318876,
343457,
245160,
286128,
286133,
310714,
302523,
228796,
302530,
228804,
310725,
302539,
310731,
310735,
327122,
310747,
286176,
187877,
310758,
40439,
286201,
359931,
245249,
228868,
302602,
294413,
359949,
302613,
302620,
245291,
310853,
286281,
196184,
212574,
204386,
204394,
138862,
310896,
294517,
286344,
179853,
286351,
188049,
229011,
179868,
229021,
302751,
245413,
212649,
286387,
286392,
302778,
286400,
212684,
302798,
286419,
294621,
294629,
286457,
286463,
319232,
278292,
278294,
294699,
286507,
319289,
237397,
188250,
237411,
327556,
188293,
311183,
294806,
294808,
319393,
294820,
294824,
343993,
98240,
294849,
24531,
294887,
278507,
311277,
327666,
278515
] |
2f11c8a3fdc330c1df25da0d8447abfc859c7267
|
5a560902da67d6bd3062f272e01a5c9d421cbff5
|
/Sources/Extensions/UIKit/UINavigationController+Extensions.swift
|
0cd2bf1189df9966af6bf70491fd62934f4b49a2
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
andrewmalek27/xcore.swift
|
9c20902e936e834f01c0b5d294f3bdbdf15013d9
|
ed1d453fa77a887c8ee5b4079ddda963d6b02f3a
|
refs/heads/master
| 2021-01-24T10:05:54.419448 | 2018-02-20T02:59:55 | 2018-02-20T02:59:55 | 82,718,610 | 0 | 0 | null | 2017-02-21T19:29:37 | 2017-02-21T19:29:37 | null |
UTF-8
|
Swift
| false | false | 7,332 |
swift
|
//
// UINavigationController+Extensions.swift
//
// Copyright © 2014 Zeeshan Mian
//
// 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
extension UINavigationController {
/// Initializes and returns a newly created navigation controller that uses your custom bar subclasses.
///
/// - parameter rootViewController: The view controller that resides at the bottom of the navigation stack. This object cannot be an instance of the `UITabBarController` class.
/// - parameter navigationBarClass: Specify the custom `UINavigationBar` subclass you want to use, or specify `nil` to use the standard `UINavigationBar` class.
/// - parameter toolbarClass: Specify the custom `UIToolbar` subclass you want to use, or specify `nil` to use the standard `UIToolbar` class.
///
/// - returns: The initialized navigation controller object.
public convenience init(rootViewController: UIViewController, navigationBarClass: AnyClass?, toolbarClass: AnyClass?) {
self.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
self.rootViewController = rootViewController
}
/// A convenience property to set root view controller without animation.
open var rootViewController: UIViewController? {
get { return viewControllers.first }
set {
var rvc: [UIViewController] = []
if let vc = newValue {
rvc = [vc]
}
setViewControllers(rvc, animated: false)
}
}
}
extension UINavigationController {
/// A convenience method to pop to view controller of specified subclass of `UIViewController` type.
///
/// - parameter type: The View controller type to pop to.
/// - parameter animated: Set this value to `true` to animate the transition.
/// Pass `false` if you are setting up a navigation controller
/// before its view is displayed.
/// - parameter isReversedOrder: If multiple view controllers of specified type exists it
/// pop the latest of type by default. Pass `false` to reverse the behavior.
///
/// - returns: An array containing the view controllers that were popped from the stack.
@discardableResult
open func popToViewController(_ type: UIViewController.Type, animated: Bool, isReversedOrder: Bool = true) -> [UIViewController]? {
let viewControllers = isReversedOrder ? self.viewControllers.reversed() : self.viewControllers
for viewController in viewControllers {
if viewController.isKind(of: type) {
return popToViewController(viewController, animated: animated)
}
}
return nil
}
/// A convenience method to pop view controllers until the one at specified index is on top. Returns the popped controllers.
///
/// - parameter index: The View controller type to pop to.
/// - parameter animated: Set this value to `true` to animate the transition.
/// Pass `false` if you are setting up a navigation controller
/// before its view is displayed.
///
/// - returns: An array containing the view controllers that were popped from the stack.
@discardableResult
open func popToViewController(at index: Int, animated: Bool) -> [UIViewController]? {
guard let viewController = viewControllers.at(index) else {
return nil
}
return popToViewController(viewController, animated: animated)
}
open func pushOnFirstViewController(_ viewController: UIViewController, animated: Bool = true) {
var vcs = [UIViewController]()
if let firstViewController = viewControllers.first {
vcs.append(firstViewController)
}
vcs.append(viewController)
setViewControllers(vcs, animated: animated)
}
}
extension UINavigationController {
// Autorotation Fix. Simply override `supportedInterfaceOrientations`
// method in any view controller and it would respect that orientation
// setting per view controller.
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return topViewController?.preferredInterfaceOrientations ?? preferredInterfaceOrientations ?? topViewController?.supportedInterfaceOrientations ?? super.supportedInterfaceOrientations
}
open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return topViewController?.interfaceOrientationForPresentation ?? interfaceOrientationForPresentation ?? topViewController?.preferredInterfaceOrientationForPresentation ?? super.preferredInterfaceOrientationForPresentation
}
// Setting `preferredStatusBarStyle` works.
open override var childViewControllerForStatusBarStyle: UIViewController? {
if topViewController?.statusBarStyle != nil || statusBarStyle != nil {
return nil
} else {
return topViewController
}
}
// Setting `prefersStatusBarHidden` works.
open override var childViewControllerForStatusBarHidden: UIViewController? {
if topViewController?.isStatusBarHidden != nil || isStatusBarHidden != nil {
return nil
} else {
return topViewController
}
}
open override var shouldAutorotate: Bool {
return topViewController?.enableAutorotate ?? enableAutorotate ?? topViewController?.shouldAutorotate ?? super.shouldAutorotate
}
open override var preferredStatusBarStyle: UIStatusBarStyle {
return topViewController?.statusBarStyle ?? statusBarStyle ?? topViewController?.preferredStatusBarStyle ?? super.preferredStatusBarStyle
}
open override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
return topViewController?.statusBarUpdateAnimation ?? statusBarUpdateAnimation ?? topViewController?.preferredStatusBarUpdateAnimation ?? super.preferredStatusBarUpdateAnimation
}
open override var prefersStatusBarHidden: Bool {
return topViewController?.isStatusBarHidden ?? isStatusBarHidden ?? topViewController?.prefersStatusBarHidden ?? super.prefersStatusBarHidden
}
}
|
[
-1
] |
600a8dbce4b1d4870b0881b30578d78cae8ab289
|
140ff1b2d3e607d1548bcd87ae98bafcf496c850
|
/AlphaWallet/WalletConnect/Providers/v1/WalletConnectV1Client.swift
|
8d50a8f4640a2854b3f300d1a1b400167baf1651
|
[
"LicenseRef-scancode-proprietary-license",
"MIT"
] |
permissive
|
AlphaWallet/alpha-wallet-ios
|
d020a77c4ab0a2986328506a808fd7604cd096fc
|
10efbb5280f8af660a65252a0167a1505e0e7c96
|
refs/heads/master
| 2023-09-01T17:54:03.813487 | 2023-09-01T15:26:03 | 2023-09-01T15:32:10 | 120,623,733 | 552 | 378 |
MIT
| 2023-09-13T01:14:48 | 2018-02-07T14:13:09 |
Swift
|
UTF-8
|
Swift
| false | false | 6,952 |
swift
|
//
// WalletConnectV1Client.swift
// AlphaWallet
//
// Created by Vladyslav Shepitko on 06.01.2023.
//
import Foundation
import WalletConnectSwift
import AlphaWalletFoundation
import AlphaWalletLogger
protocol WalletConnectV1ClientDelegate: AnyObject {
func server(_ server: Server, didReceiveRequest: Request)
func server(_ server: Server, tookTooLongToConnectToUrl url: WCURL)
func server(_ server: Server, didFailToConnect url: WCURL)
func server(_ server: Server, shouldStart session: Session, completion: @escaping (Session.WalletInfo?) -> Void)
func server(_ server: Server, didConnect session: Session)
func server(_ server: Server, didDisconnect session: Session)
func server(_ server: Server, didUpdate session: Session)
}
protocol WalletConnectV1Client: AnyObject {
var delegate: WalletConnectV1ClientDelegate? { get set }
func updateSession(_ session: Session, with walletInfo: Session.WalletInfo) throws
func connect(to url: WCURL) throws
func reconnect(to session: Session) throws
func disconnect(from session: Session) throws
func send(_ response: Response)
func send(_ request: Request)
func openSessions() -> [Session]
}
final class WalletConnectV1NativeClient: WalletConnectV1Client {
enum ClientError: Error {
case connectionTimeout
case serverError(Error)
}
static let walletMeta: Session.ClientMeta = {
let client = Session.ClientMeta(
name: Constants.WalletConnect.server,
description: nil,
icons: Constants.WalletConnect.icons.compactMap { URL(string: $0) },
url: Constants.WalletConnect.websiteUrl
)
return client
}()
private var walletInfoForCancellation: Session.WalletInfo {
Session.WalletInfo(
approved: false,
accounts: [],
//When there's no server (because user chose to cancel), it shouldn't matter whether the fallback (mainnet) is enabled
chainId: RPCServer.main.chainID,
peerId: String(),
peerMeta: WalletConnectV1NativeClient.walletMeta)
}
private lazy var server = Server(delegate: self)
private let queue: DispatchQueue = .main
private lazy var requestHandler: RequestHandlerToAvoidMemoryLeak = { [weak self] in
let handler = RequestHandlerToAvoidMemoryLeak()
handler.delegate = self
return handler
}()
private var connectionTimeoutTimers: [WCURL: Timer] = .init()
var connectionTimeout: TimeInterval = 10
weak var delegate: WalletConnectV1ClientDelegate?
init() {
server.register(handler: requestHandler)
}
deinit {
server.unregister(handler: requestHandler)
}
func register(_ requestHandler: RequestHandler) {
server.register(handler: requestHandler)
}
func unregister(_ requestHandler: RequestHandler) {
server.unregister(handler: requestHandler)
}
func updateSession(_ session: Session, with walletInfo: Session.WalletInfo) throws {
try server.updateSession(session, with: walletInfo)
}
func connect(to url: WCURL) throws {
let timer = Timer.scheduledTimer(withTimeInterval: connectionTimeout, repeats: false) { _ in
let isStillWatching = self.connectionTimeoutTimers[url] != nil
debugLog("[WalletConnect] app-enforced connection timer is up for: \(url.absoluteString) isStillWatching: \(isStillWatching)")
if isStillWatching {
//TODO be good if we can do `server.communicator.disconnect(from: url)` here on in the delegate. But `communicator` is not accessible
self.delegate?.server(self.server, tookTooLongToConnectToUrl: url)
} else {
//no-op
}
}
connectionTimeoutTimers[url] = timer
try server.connect(to: url)
}
func reconnect(to session: Session) throws {
try server.reconnect(to: session)
}
func disconnect(from session: Session) throws {
try server.disconnect(from: session)
}
func send(_ response: Response) {
server.send(response)
}
func send(_ request: Request) {
server.send(request)
}
func openSessions() -> [Session] {
server.openSessions()
}
}
extension WalletConnectV1NativeClient: WalletConnectV1ServerRequestHandlerDelegate {
func handler(_ handler: RequestHandlerToAvoidMemoryLeak, request: WalletConnectV1Request) {
queue.async {
self.delegate?.server(self.server, didReceiveRequest: request)
}
}
func handler(_ handler: RequestHandlerToAvoidMemoryLeak, canHandle request: WalletConnectV1Request) -> Bool {
return true
}
}
extension WalletConnectV1NativeClient: ServerDelegate {
func server(_ server: Server, didFailToConnect url: WCURL) {
queue.async {
self.connectionTimeoutTimers[url] = nil
self.delegate?.server(server, didFailToConnect: url)
}
}
func server(_ server: Server, shouldStart session: Session, completion: @escaping (Session.WalletInfo) -> Void) {
queue.async {
self.connectionTimeoutTimers[session.url] = nil
self.delegate?.server(server, shouldStart: session, completion: { info in
completion(info ?? self.walletInfoForCancellation)
})
}
}
func server(_ server: Server, didConnect session: Session) {
queue.async {
self.delegate?.server(server, didConnect: session)
}
}
func server(_ server: Server, didDisconnect session: Session) {
queue.async {
self.delegate?.server(server, didDisconnect: session)
}
}
func server(_ server: Server, didUpdate session: Session) {
queue.async {
self.delegate?.server(server, didUpdate: session)
}
}
}
extension Session {
func updatingWalletInfo(with accounts: [String], chainId: Int) -> Session {
guard let walletInfo = walletInfo else {
let walletInfo = Session.WalletInfo(
approved: true,
accounts: accounts,
chainId: chainId,
peerId: UUID().uuidString,
peerMeta: WalletConnectV1NativeClient.walletMeta)
return Session(url: url, dAppInfo: dAppInfo, walletInfo: walletInfo)
}
let newWalletInfo = Session.WalletInfo(
approved: walletInfo.approved,
accounts: accounts,
chainId: chainId,
peerId: walletInfo.peerId,
peerMeta: walletInfo.peerMeta)
let dAppInfo = DAppInfo(
peerId: dAppInfo.peerId,
peerMeta: dAppInfo.peerMeta,
chainId: chainId,
approved: dAppInfo.approved)
return Session(url: url, dAppInfo: dAppInfo, walletInfo: newWalletInfo)
}
}
|
[
-1
] |
084f3250bee072e7a7fe5ec254a23b54ab297eef
|
9344cfdffa20c63ed7a7fb43cc0601f51513fd00
|
/CorrectMe/AppDelegate.swift
|
90af7743bd776ce6c025ac7caa1ac3e8e40354ee
|
[] |
no_license
|
ramjaunTech/CorrectMe
|
3f1c8ab682bd849603e5fa8e4d85c705ddd396a5
|
5fd05621f8f75728ff5159a5d86dbae584018bd5
|
refs/heads/master
| 2020-04-25T08:19:36.513789 | 2019-09-21T02:37:20 | 2019-09-21T02:37:20 | 172,643,638 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,183 |
swift
|
//
// AppDelegate.swift
// CorrectMe
//
// Created by shoaib ramjaun on 2019-02-21.
// Copyright © 2019 shoaib ramjaun. 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,
294924,
229388,
278542,
327695,
229391,
278545,
229394,
278548,
229397,
229399,
229402,
278556,
229405,
278559,
229408,
294950,
229415,
229417,
327722,
237613,
229422,
360496,
229426,
237618,
229428,
311349,
286774,
319544,
204856,
229432,
286776,
286791,
237640,
278605,
237646,
311375,
163920,
196692,
319573,
311383,
319590,
311400,
278635,
303212,
278639,
131192,
278648,
237693,
327814,
131209,
303241,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
131264,
286916,
286922,
286924,
286926,
319694,
131281,
278743,
278747,
295133,
155872,
319716,
237807,
303345,
286962,
131314,
229622,
327930,
278781,
278783,
278785,
237826,
319751,
278792,
286987,
319757,
311569,
286999,
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,
98756,
278980,
278983,
319945,
278986,
319947,
278990,
278994,
279003,
279006,
188895,
172512,
287202,
279010,
279015,
172520,
319978,
279020,
172526,
311791,
279023,
172529,
279027,
319989,
180727,
164343,
311804,
287230,
279040,
303617,
287234,
279045,
172550,
303623,
320007,
172552,
287238,
279051,
172558,
279055,
303632,
279058,
303637,
279063,
279067,
172572,
279072,
172577,
295459,
172581,
295461,
279082,
311850,
279084,
172591,
172598,
279095,
172607,
172609,
172612,
377413,
172614,
172618,
303690,
33357,
287309,
279124,
172634,
262752,
172644,
311911,
189034,
295533,
172655,
172656,
352880,
295538,
189039,
172660,
189044,
287349,
287355,
287360,
295553,
295557,
311942,
303751,
287365,
352905,
311946,
287371,
279178,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
287390,
303773,
172702,
172705,
287394,
172707,
303780,
164509,
287398,
205479,
287400,
279208,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
303804,
328381,
287423,
328384,
279231,
287427,
312005,
312006,
107212,
172748,
287436,
172751,
295633,
172755,
303827,
279255,
172760,
287450,
303835,
279258,
189149,
303838,
213724,
279267,
312035,
295654,
279272,
312048,
230128,
312050,
230131,
205564,
303871,
230146,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
303914,
279340,
205613,
279353,
230202,
312124,
328508,
222018,
295755,
377676,
148302,
287569,
303959,
230237,
230241,
279394,
303976,
336744,
303985,
303987,
328563,
279413,
303991,
303997,
295806,
295808,
304005,
295813,
304007,
320391,
304009,
213895,
304011,
230284,
304013,
295822,
279438,
189329,
189331,
304019,
58262,
304023,
279452,
234648,
410526,
279461,
304042,
213931,
304055,
230327,
287675,
230334,
304063,
304065,
213954,
295873,
156612,
189378,
213963,
312272,
304084,
304090,
320481,
304106,
320490,
312302,
328687,
320496,
304114,
295928,
320505,
312321,
295945,
230413,
197645,
295949,
320528,
140312,
295961,
238620,
197663,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
230465,
238658,
296004,
132165,
336964,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
361576,
296040,
205931,
164973,
205934,
279661,
312432,
279669,
337018,
304258,
279683,
222340,
205968,
296084,
238745,
304285,
238756,
205991,
222377,
165035,
337067,
165038,
238766,
238770,
304311,
230592,
312518,
279750,
230600,
230607,
148690,
320727,
279769,
304348,
279777,
304354,
296163,
320740,
279781,
304360,
320748,
279788,
279790,
304370,
296189,
320771,
312585,
296205,
230674,
320786,
230677,
296213,
296215,
320792,
230681,
230679,
230689,
173350,
312622,
296243,
312630,
222522,
296253,
230718,
296255,
312639,
296259,
378181,
296262,
230727,
296264,
238919,
320840,
296267,
296271,
222545,
230739,
312663,
222556,
337244,
230752,
312676,
230760,
173418,
410987,
230763,
148843,
230768,
296305,
312692,
230773,
304505,
181626,
304506,
181631,
148865,
312711,
312712,
296331,
288140,
288144,
230800,
304533,
288154,
337306,
288160,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
288176,
312755,
296373,
312759,
337335,
288185,
279991,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
148946,
370130,
222676,
288210,
288212,
288214,
239064,
329177,
288218,
280021,
288220,
288217,
239070,
288224,
370146,
288226,
280034,
288229,
280038,
288230,
288232,
280036,
320998,
288234,
288236,
288238,
288240,
288242,
296435,
288244,
288250,
148990,
321022,
206336,
402942,
296446,
296450,
230916,
230919,
214535,
304651,
370187,
230923,
304653,
230940,
222752,
108066,
296486,
296488,
157229,
230961,
157236,
288320,
288325,
124489,
280140,
280145,
288338,
280149,
288344,
280152,
239194,
181854,
403039,
280158,
370272,
239202,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
190118,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
280260,
206536,
280264,
206539,
206541,
206543,
280276,
313044,
321239,
280283,
18140,
313052,
288478,
313055,
321252,
313066,
288494,
280302,
280304,
313073,
419570,
288499,
288502,
280314,
288510,
67330,
280324,
198416,
280337,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
321336,
296767,
288576,
345921,
304968,
280393,
194130,
280402,
173907,
313176,
280419,
321381,
296809,
296812,
313201,
1920,
255873,
305028,
280454,
247688,
280464,
124817,
280468,
239510,
280473,
124827,
214940,
247709,
214944,
280487,
313258,
321458,
296883,
124853,
214966,
10170,
296890,
288700,
296894,
190403,
296900,
280515,
337862,
165831,
280521,
231379,
296921,
239586,
313320,
231404,
124913,
165876,
321528,
313340,
239612,
288764,
239617,
313347,
288773,
313358,
305176,
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,
215154,
313458,
149618,
280691,
313464,
321659,
280702,
288895,
321670,
215175,
141446,
288909,
141455,
141459,
280725,
313498,
100520,
288936,
280747,
288940,
321717,
280759,
280764,
280769,
280771,
280774,
321740,
313548,
280783,
280786,
313557,
280793,
280796,
338147,
280804,
280807,
157930,
280811,
280817,
125171,
157940,
280825,
280827,
280830,
280831,
125187,
280835,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
280888,
289087,
280897,
239944,
305480,
280906,
239947,
305485,
305489,
379218,
280919,
354653,
354656,
313700,
313705,
280937,
190832,
280946,
223606,
313720,
280956,
280959,
313731,
240011,
199051,
289166,
240017,
297363,
190868,
297365,
297368,
297372,
141725,
297377,
289186,
297391,
289201,
240052,
289207,
305594,
289210,
281024,
289218,
289221,
289227,
281045,
281047,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
240132,
223749,
305668,
281095,
223752,
150025,
338440,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
281179,
338528,
338532,
281190,
199273,
281196,
158317,
19053,
313973,
297594,
281210,
158347,
133776,
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,
281372,
322341,
215850,
281388,
289593,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
183172,
158596,
338823,
322440,
314249,
240519,
183184,
240535,
289687,
297883,
289694,
289696,
289700,
281529,
289724,
52163,
183260,
281567,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
314372,
175134,
322599,
322610,
314421,
281654,
314427,
314433,
207937,
314441,
207949,
322642,
314456,
281691,
314461,
281702,
281704,
314474,
281708,
281711,
248995,
306341,
306344,
306347,
306354,
142531,
199877,
289991,
306377,
289997,
249045,
363742,
363745,
298216,
330988,
126190,
216303,
322801,
388350,
257302,
363802,
199976,
199978,
298292,
298294,
257334,
298306,
380226,
224584,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
314718,
265568,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
306549,
298358,
314743,
306552,
306555,
314747,
298365,
290171,
290174,
224641,
281987,
314756,
298372,
281990,
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,
192008,
323084,
257550,
290321,
282130,
323090,
290325,
282133,
241175,
290328,
282137,
290332,
241181,
282142,
282144,
290344,
290349,
290351,
290356,
28219,
224849,
282195,
282199,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
224875,
241260,
323181,
257658,
315016,
282249,
290445,
282261,
298651,
323229,
282269,
298655,
323231,
61092,
282277,
306856,
282295,
323260,
282300,
323266,
282310,
323273,
282319,
306897,
241362,
306904,
282328,
298714,
52959,
216801,
282337,
241380,
216806,
323304,
282345,
12011,
282356,
323318,
282364,
282367,
306945,
241412,
323333,
282376,
216842,
323345,
282388,
323349,
282392,
184090,
315167,
315169,
282402,
315174,
323367,
241448,
315176,
241450,
282410,
306988,
306991,
315184,
323376,
315190,
241464,
159545,
282425,
307009,
413506,
241475,
307012,
298822,
315211,
282446,
307027,
315221,
323414,
315223,
241496,
241498,
307035,
307040,
110433,
241509,
110438,
298860,
110445,
282478,
315249,
282481,
110450,
315251,
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,
290739,
241588,
282547,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241640,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
241661,
299006,
282623,
315396,
241669,
315397,
282632,
282639,
290835,
282645,
241693,
282654,
241701,
102438,
217127,
282669,
323630,
282681,
290877,
282687,
159811,
315463,
315466,
192589,
307278,
192596,
176213,
307287,
315482,
217179,
315483,
192605,
233567,
299105,
200801,
217188,
299109,
307303,
315495,
356457,
307307,
45163,
315502,
192624,
307314,
323700,
299126,
233591,
299136,
307329,
307338,
233613,
241813,
307352,
299164,
299167,
315557,
184486,
307370,
307372,
184492,
307374,
307376,
323763,
299191,
176311,
307385,
307386,
258235,
307388,
176316,
307390,
184503,
299200,
184512,
307394,
307396,
299204,
184518,
307399,
323784,
307409,
307411,
176343,
299225,
233701,
307432,
184572,
184579,
282893,
291089,
282906,
291104,
233766,
176435,
315701,
332086,
307510,
307512,
168245,
307515,
307518,
282942,
323917,
282957,
110926,
233808,
323921,
315733,
323926,
233815,
315739,
323932,
299357,
242018,
242024,
299373,
315757,
250231,
315771,
242043,
299388,
299391,
291202,
299398,
242057,
291212,
299405,
291222,
315801,
283033,
242075,
61855,
291231,
283042,
291238,
291241,
127403,
127405,
127407,
291247,
127413,
283062,
291254,
127417,
291260,
127421,
127424,
299457,
127429,
315856,
127440,
315860,
176597,
283095,
127447,
127449,
299481,
176605,
127455,
242143,
127457,
291299,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
135672,
127480,
233979,
291323,
127485,
291330,
127494,
283142,
135689,
233994,
127497,
127500,
291341,
233998,
127506,
234003,
234006,
127511,
152087,
234010,
135707,
135710,
242206,
242208,
291361,
242220,
291378,
152118,
234038,
234041,
315961,
70213,
111193,
242275,
299620,
168562,
184952,
135805,
135808,
291456,
373383,
299655,
135820,
316051,
225941,
316054,
299672,
135834,
373404,
299677,
225948,
135839,
299680,
225954,
135844,
299684,
242343,
242345,
373421,
135870,
135873,
135876,
135879,
299720,
299723,
299726,
225998,
226002,
119509,
226005,
226008,
242396,
299740,
201444,
299750,
283368,
234219,
283372,
226037,
283382,
316151,
234231,
234236,
226045,
242431,
209665,
234242,
299778,
242436,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
242450,
234258,
242452,
234261,
201496,
234264,
234266,
234269,
234272,
234274,
152355,
234278,
299814,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
242499,
234309,
316233,
234313,
316235,
234316,
283468,
242511,
234319,
234321,
234324,
201557,
234329,
234333,
308063,
234336,
242530,
349027,
234338,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
234364,
291711,
234368,
234370,
201603,
291714,
234373,
316294,
234375,
291716,
308105,
324490,
226185,
234379,
226182,
234384,
234388,
234390,
324504,
234393,
209818,
308123,
234396,
324508,
291742,
226200,
234398,
234401,
291747,
291748,
234405,
291750,
324518,
324520,
234407,
234410,
291754,
291756,
324522,
226220,
324527,
291760,
234417,
201650,
324531,
234414,
234422,
226230,
324536,
275384,
234428,
291773,
234431,
242623,
324544,
324546,
226239,
324548,
234437,
234434,
226245,
234439,
234443,
291788,
234446,
193486,
193488,
234449,
275406,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
324599,
234487,
234490,
234493,
234496,
316416,
234501,
308231,
234504,
234507,
234510,
234515,
300054,
234519,
234520,
316439,
234523,
234526,
234528,
300066,
234532,
234535,
234537,
234540,
234543,
234546,
275508,
234549,
300085,
300088,
234553,
234558,
316479,
234561,
308291,
316483,
160835,
234563,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
242777,
275545,
234590,
234595,
234597,
300133,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
316530,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
226433,
234627,
275588,
234629,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
324757,
234647,
226453,
275608,
234650,
308379,
275606,
234653,
300189,
119967,
324766,
324768,
234657,
283805,
242852,
234661,
300197,
234664,
275626,
234667,
316596,
300223,
234687,
300226,
283844,
300229,
308420,
308422,
234692,
283850,
300234,
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,
300292,
300294,
275719,
300299,
177419,
242957,
275725,
283917,
177424,
349464,
283939,
259367,
292143,
283951,
300344,
226617,
243003,
283963,
226628,
283973,
300357,
177482,
283983,
316758,
357722,
316766,
316768,
292192,
218464,
292197,
316774,
243046,
218473,
284010,
324978,
136562,
333178,
275834,
275836,
275840,
316803,
316806,
226696,
316811,
226699,
316814,
226703,
300433,
234899,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
144814,
144820,
284084,
292279,
284087,
144826,
144828,
144830,
144832,
227430,
144835,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
292329,
300523,
259565,
300527,
308720,
259567,
292338,
316917,
292343,
308727,
300537,
316933,
316947,
308757,
308762,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
284213,
194101,
284215,
316983,
194103,
284218,
226877,
292414,
284223,
284226,
284228,
243268,
292421,
284231,
226886,
284234,
366155,
317004,
276043,
284238,
226895,
284241,
292433,
284243,
300628,
284245,
276053,
284247,
317015,
235097,
243290,
284249,
284253,
300638,
243293,
284255,
284258,
292452,
292454,
284263,
177766,
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,
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,
276160,
284354,
358083,
284358,
358089,
284362,
276170,
276175,
284368,
276177,
284370,
358098,
284372,
317138,
284377,
284379,
284384,
358114,
284386,
358116,
276197,
317158,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
276206,
358128,
284399,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
284428,
300816,
300819,
317207,
284440,
300828,
300830,
276255,
325408,
300832,
300834,
317221,
227109,
358183,
186151,
276268,
243504,
300850,
284469,
276280,
325436,
358206,
276291,
366406,
276295,
300872,
153417,
292681,
284499,
276308,
284502,
317271,
178006,
276315,
292700,
284511,
227175,
292715,
292721,
284529,
300915,
284533,
292729,
317306,
284540,
292734,
325512,
169868,
276365,
358292,
284564,
317332,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
292776,
284585,
276395,
292784,
276402,
358326,
161718,
358330,
276411,
276425,
301009,
301011,
301013,
292823,
358360,
301015,
301017,
292828,
276446,
276448,
153568,
276452,
292839,
276455,
292843,
276460,
227314,
325624,
276472,
317435,
276476,
276479,
276482,
276485,
276490,
292876,
317456,
276496,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
276528,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
284739,
292934,
243785,
276553,
350293,
350295,
309337,
227418,
350302,
194654,
227423,
178273,
309346,
227426,
309348,
350308,
309350,
194660,
309352,
350313,
309354,
301163,
350316,
292968,
276583,
301167,
276586,
350321,
227440,
284786,
276595,
350325,
350328,
292985,
301178,
350332,
292989,
301185,
292993,
350339,
317573,
350342,
350345,
350349,
301199,
317584,
325777,
350354,
350357,
350359,
350362,
350366,
276638,
153765,
284837,
350375,
350379,
350381,
350383,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
301258,
309450,
276685,
309455,
276689,
309462,
301272,
276699,
309468,
194780,
309471,
301283,
317672,
317674,
325867,
243948,
194801,
309494,
243960,
227583,
276735,
276739,
211204,
276742,
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,
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,
293346,
276964,
293352,
236013,
293364,
301562,
293370,
317951,
309764,
301575,
121352,
236043,
317963,
342541,
55822,
113167,
309779,
317971,
309781,
55837,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
129603,
318020,
301636,
301639,
301643,
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,
318108,
285340,
318110,
227998,
137889,
383658,
285357,
318128,
277170,
342707,
318132,
293555,
154292,
277173,
285368,
277177,
277181,
318144,
277187,
277191,
277194,
277196,
277201,
137946,
113378,
203491,
228069,
277223,
342760,
56041,
285417,
56043,
277232,
228081,
56059,
310015,
310020,
310029,
228113,
285459,
277273,
326430,
228128,
293666,
228135,
318248,
277291,
318253,
293677,
285489,
301876,
293685,
285494,
301880,
285499,
301884,
293696,
310080,
277317,
277329,
162643,
310100,
301911,
277337,
301921,
400236,
236397,
162671,
326514,
310134,
15224,
236408,
277368,
416639,
416640,
113538,
310147,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
293811,
276579,
293817,
293820,
203715,
326603,
293849,
293861,
228327,
228328,
318442,
228332,
326638,
277486,
318450,
293876,
293877,
285686,
302073,
293882,
244731,
121850,
285690,
302075,
293887,
277504,
277507,
277511,
293899,
277519,
293908,
302105,
293917,
293939,
318516,
277561,
277564,
310336,
7232,
293956,
277573,
228422,
310344,
293960,
277577,
277583,
203857,
293971,
310355,
310359,
236632,
277594,
138332,
277598,
203872,
285792,
277601,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
367737,
285817,
302205,
285821,
392326,
302218,
285835,
294026,
384148,
162964,
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,
302296,
384222,
310498,
285927,
318698,
302315,
228592,
294132,
138485,
204026,
228606,
204031,
64768,
310531,
138505,
228617,
318742,
204067,
277798,
130345,
277801,
277804,
285997,
285999,
277807,
113969,
277811,
318773,
318776,
277816,
286010,
277819,
294204,
417086,
277822,
302403,
294211,
384328,
277832,
277836,
294221,
326991,
277839,
277842,
277847,
277850,
179547,
277853,
277857,
302436,
277860,
294246,
327015,
310632,
327017,
351594,
277864,
277869,
277872,
351607,
277880,
310648,
310651,
277884,
277888,
310657,
310659,
351619,
294276,
327046,
277892,
253320,
310665,
318858,
277894,
277898,
277903,
310672,
277905,
351633,
277908,
277917,
310689,
277921,
130468,
277928,
277932,
310703,
277937,
130486,
310710,
310712,
277944,
310715,
277947,
277950,
228799,
277953,
302534,
245191,
310727,
64966,
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,
302603,
302614,
302617,
286233,
302621,
286240,
146977,
187939,
40484,
294435,
40486,
286246,
40488,
294439,
294440,
40491,
294443,
294445,
286248,
310831,
40499,
40502,
212538,
40507,
40511,
40513,
228933,
327240,
40521,
286283,
40525,
40527,
400976,
212560,
228944,
40533,
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,
319153,
278196,
302781,
319171,
302789,
294599,
278216,
302793,
294601,
212690,
319187,
286420,
229076,
286425,
319194,
278235,
278238,
229086,
286432,
294625,
294634,
302838,
319226,
286460,
278274,
302852,
278277,
302854,
311048,
294664,
319243,
311053,
302862,
319251,
294682,
278306,
294701,
319280,
278320,
319290,
229192,
302925,
188247,
188252,
237409,
360317,
327554,
40840,
40851,
294803,
188312,
294811,
319390,
40865,
319394,
294817,
294821,
311209,
180142,
188340,
40886,
319419,
294844,
294847,
237508,
393177,
294876,
294879,
294883,
294890,
311279,
278513,
237555,
311283,
278516,
278519,
237562
] |
edb2a6c83fe2a00776b4e1ba8c30f86660b4e036
|
cd8e43e27ac540e9d816579406edb45fc635b151
|
/WRPDFModel/Classes/Model/ContentParser/pdf/fonts/SimpleFonts/TrueTypeFontFile/TrueTypeCMAPSubTables.swift
|
b2c8d6c1c82c4f83072e0bd87fec50c373b3060b
|
[
"MIT"
] |
permissive
|
GodFighter/WRPDFModel
|
8b6ac87da931fc0c0a09dfe9cd9f82cbf7c7565c
|
9cc6fd23fe9bea5f3f2786f91b5fcb8ffda66e19
|
refs/heads/master
| 2020-12-12T02:04:38.165338 | 2020-01-22T02:43:43 | 2020-01-22T02:43:43 | 234,016,683 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,142 |
swift
|
//
// TrueTypeCMAPFormat.swift
// PDFParser
//
// Created by Benjamin Garrigues on 20/07/2018.
//
import Foundation
//MARK: - CMAP Subtables in all formats
/*
As specification mentions:
Many of the cmap formats are either obsolete or were designed to meet anticipated needs which never materialized. Modern font generation tools need not be able to write general-purpose cmaps in formats other than 4, 6, and 12. Formats 13 and 14 are both for specialized uses. Of the two, only support for format 14 is likely to be needed
So, implementation will focus on formats 4, 6 and 12.
*/
struct TTCMapSubtableFormat0 {
let format : UInt16 // Set to 0
let length : UInt16 // Length in bytes of the subtable (set to 262 for format 0)
let language : UInt16 // Language code (see above)
var glyphIndexArray : [UInt8] // [256] array that maps character codes to glyph index values
}
struct TTCMapSubtableFormat2 {
struct SubHeader {
let firstCode : UInt16
let entryCode : UInt16
let idDelta : UInt16
let idRangeOffset : UInt16
}
let format : UInt16 // Set to 2
let length : UInt16 // Length in bytes
let language : UInt16 // Language code (see above)
let subHeaderKeys : [UInt16] // [256] array that maps high bytes to subHeaders: value is index * 8
let subHeaders : [SubHeader] // Variable length array of subHeader structures
let glyphIndexArray : [UInt16] // Variable length array containing subarrays
}
struct TTCMapSubtableFormat4 {
let format : UInt16 // Set to 4
let length : UInt16 // Length in bytes
let language : UInt16 // Language code (see above)
let segCountX2 : UInt16 // 2 * segCount
let searchRange : UInt16 // 2 * (2**FLOOR(log2(segCount)))
let entrySelector : UInt16 // log2(searchRange/2)
let rangeShift : UInt16 // 2 * segCount) - searchRange
var endCode : [UInt16] // Ending character code for each segment, last = 0xFFFF.
var reservedPad : UInt16 // This value should be zero
var startCode : [UInt16] // Starting character code for each segment
var idDelta : [UInt16] // Delta for all character codes in segment
var idRangeOffset : [UInt16] // Offset in bytes to glyph indexArray, or 0
var glyphIndexArray : [UInt16] // Glyph index array
}
struct TTCMapSubtableFormat6 {
let format : UInt16 // Set to 6
let length : UInt16 // Length in bytes of the subtable (set to 262 for format 0)
let language : UInt16 // Language code (see above)
let firstCode : UInt16 // First character code of subrange
let entryCount : UInt16 // Number of character codes in subrange
var glyphIndexArray : [UInt16] // Array of glyph index values for character codes in the range
}
struct TTCMapSubtableFormat8 {
struct Group {
let startCharCode : UInt32
let endCharCode : UInt32
let startGlyphCode : UInt32
}
let format : UInt16 // Set to 8
let formatPadding : UInt16 // Always 0
let length : UInt32 // Length in bytes of the subtable (set to 262 for format 0)
let language : UInt32 // Language code (see above)
let is32 : [UInt8] //[65536] Tightly packed array of bits (8K bytes total) indicating whether the particular 16-bit (index) value is the start of a 32-bit character code
let nGroups : UInt32
let groups : [Group]
}
//RARE format. Not supported.
struct TTCMapSubtableFormat10 {
let format : UInt16 // Set to 10
let formatPadding : UInt16 // Always 0
let length : UInt32 // Length in bytes of the subtable (set to 262 for format 0)
let language : UInt32 // Language code (see above)
let startCharCode : UInt32 // First character code covered
let numChars : UInt32 // Number of character codes covered
let glyphs : [UInt16] // Array of glyph indices for the character codes covered
}
/*
- Format 12.0 is required for Unicode fonts covering characters above U+FFFF on Windows. It is the most useful of the cmap formats with 32-bit support.
- Format 13.0 is a modified version of the type 12.0 'cmap' subtable, used internally by Apple for its LastResort font. It would, in general, not be appropriate for any font other than a last resort font.
*/
struct TTCMapSubtableFormat12Or13 {
struct Group {
let startCharCode : UInt32
let endCharCode : UInt32
let startGlyphCode : UInt32
}
let format : UInt16 // Set to 12 or 13
let formatPadding : UInt16 // Always 0
let length : UInt32 // Length in bytes of the subtable (set to 262 for format 0)
let language : UInt32 // Language code (see above)
let nGroups : UInt32 // Number of groupings which follow
var groups : [Group]
}
struct TTCMapSubtableFormat14 {
struct Header {
let format : UInt16
let length : UInt32
let numVarSelectorRecords: UInt32 //Number of variation Selector Records
let selectorRecords : [VariationSelectorRecord]
}
struct VariationSelectorRecord {
let varSelector : UInt24 // Variation selector
let defaultUVSOffset : UInt32 // Offset to Default UVS Table. May be 0.
let nonDefaultUVSOffset : UInt32 // Offset to Non-Default UVS Table. May be 0.
}
struct DefaultUVSTable {
struct UnicodeValueRange {
let startUnicodeValue : UInt24 // First value in this range
let additionalCount : UInt8 // Number of additional values in this range
}
let numUnicodeValueRanges : UInt32
let valueRanges : [UnicodeValueRange]
}
struct NonDefaultUVSTable {
struct UVSMapping {
let unicodeValue : UInt24
let glyphID : UInt16
}
let numUVSMappings : UInt32
let uvsMappings : [UVSMapping]
}
}
|
[
-1
] |
fe5298d83c8cbbbf513b058aa987bbb6a7994f36
|
f295a2c2000363cdf8374b9f1aa28405f768b173
|
/Fun2Order/CustomCell/Entity/GROUP_MEMBER+CoreDataClass.swift
|
035a7e68e5d2c0aed3fe3a9a11565f60156efc17
|
[] |
no_license
|
IEW-CCS/Fun2Order
|
760a8088f245e1fa66d7c0989cf023fb4654ee83
|
b6d7b13bea2e0db9076ee392532802bd8a888b2f
|
refs/heads/master
| 2021-07-16T15:22:18.195815 | 2020-09-27T13:04:28 | 2020-09-27T13:04:28 | 213,815,931 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 201 |
swift
|
//
// GROUP_MEMBER+CoreDataClass.swift
//
//
// Created by Lo Fang Chou on 2019/12/27.
//
//
import Foundation
import CoreData
@objc(GROUP_MEMBER)
public class GROUP_MEMBER: NSManagedObject {
}
|
[
-1
] |
e1aa74bb0faf6d5c5cb6230957053597d65a04f9
|
4bcb254532cbb033b8e207140664adfd825ec97c
|
/RcloneOSX/ViewControllers/Sheetviews/ViewControllerInformation.swift
|
4152e1b4168721f60bdde6e82f02241c86988deb
|
[
"MIT"
] |
permissive
|
eveloson/rcloneosx
|
d2c1cb445cd78d499535501fdfd4473bab887417
|
20556f6059e1ce6ad00bf59f635b2d043331d828
|
refs/heads/master
| 2023-02-13T01:10:32.207040 | 2021-01-07T06:09:08 | 2021-01-07T06:09:08 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,457 |
swift
|
//
// ViewControllerInformation.swift
// rcloneOSX
//
// Created by Thomas Evensen on 24/08/2016.
// Copyright © 2016 Thomas Evensen. All rights reserved.
//
// swiftlint:disable line_length
import Cocoa
import Foundation
class ViewControllerInformation: NSViewController, SetDismisser, OutPut {
@IBOutlet var detailsTable: NSTableView!
var output: [String]?
override func viewDidLoad() {
super.viewDidLoad()
detailsTable.delegate = self
detailsTable.dataSource = self
}
override func viewDidAppear() {
super.viewDidAppear()
self.output = self.getinfo()
globalMainQueue.async { () -> Void in
self.detailsTable.reloadData()
}
}
@IBAction func close(_: NSButton) {
self.dismissview(viewcontroller: self, vcontroller: .vctabmain)
}
}
extension ViewControllerInformation: NSTableViewDataSource {
func numberOfRows(in _: NSTableView) -> Int {
return self.output?.count ?? 0
}
}
extension ViewControllerInformation: NSTableViewDelegate {
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "outputID"), owner: nil) as? NSTableCellView {
cell.textField?.stringValue = self.output?[row] ?? ""
return cell
} else {
return nil
}
}
}
|
[
-1
] |
7805f2a1ae6ccb7751cb4e34b0128b88c24e9abd
|
d3fcabc7c5082cfe2fc1b1bffb0fe21db4efcb90
|
/Swift/FunFacts/FunFacts/FactBook.swift
|
79fcbf527556d9c3ea0296627e0bf61eaeae0e00
|
[] |
no_license
|
keroyu/Practice
|
04ad75dfd19f67c3c5fffc22153246c09c8954ac
|
3cbc079ea8335b807db18d0b5cc86a57a6c3bbfe
|
refs/heads/master
| 2016-09-05T23:35:57.888447 | 2015-01-14T07:14:04 | 2015-01-14T07:14:04 | 27,603,626 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,079 |
swift
|
//
// FactBook.swift
// FunFacts
//
// Created by Chi-Jou Yu on 12/6/14.
// Copyright (c) 2014 keroyu. All rights reserved.
//
import Foundation
struct FactBook {
let factsArray = [
"Ants stretch when they wake up in the morning.",
"Ostriches can run faster than horses.",
"Olympic gold medals are actually made mostly of silver.",
"You are born with 300 bones; by the time you are an adult you will have 206.",
"It takes about 8 minutes for light from the Sun to reach Earth.",
"Some bamboo plants can grow almost a meter in just one day.",
"The state of Florida is bigger than England.",
"Some penguins can leap 2-3 meters out of the water.",
"On average, it takes 66 days to form a new habit.",
"Mammoths still walked the earth when the Great Pyramid was being built." ]
func randomFact() -> String {
var unsignedArrayCount = UInt32(factsArray.count)
var unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
var randomNumber = Int(unsignedRandomNumber)
return factsArray[randomNumber]
}
}
|
[
-1
] |
1e19037785208a38b9b1c0d9c26cb6886fb579c2
|
c5f6a260c0d99aa3931eb21d1eb379a164fd08f7
|
/HappyHouse/HappyHouse/CommonRoutine/Extension/CRSetData.swift
|
8f16aa1a75a91ee54bfe387194be405328d8cfca
|
[] |
no_license
|
DoGood-Hackathon-2/HappyHouse
|
9e3b9f43217015fa9123ab573da039271262467b
|
ae58f9189598007984047552880cfba84fc35143
|
refs/heads/main
| 2023-08-21T22:56:38.544504 | 2021-10-23T14:03:50 | 2021-10-23T14:03:50 | 395,842,651 | 1 | 1 | null | 2021-09-17T08:30:18 | 2021-08-14T00:45:20 |
Swift
|
UTF-8
|
Swift
| false | false | 11,473 |
swift
|
//
// CRSetData.swift
// HappyHouse
//
// Created by Hamlit Jason on 2021/10/18.
//
import Foundation
import UIKit
import RxSwift
import RxCocoa
import SnapKit
import Then
import UserNotifications
// MARK::: setData UI Then이용하여 처리
extension CommonRoutineViewController {
func setData() {
viewModel.dummyObsrvable
.bind(to: CRcollectionView.rx
.items(
cellIdentifier: "CRCell",
cellType: CRCollectionViewCell.self)
) { index, item, cell in
cell.initUI(of: item)
}.disposed(by: bag)
YearTextField.rx.text.orEmpty
.skip(1) // 구독 시 bind코드가 적용되는데 밑줄이 우리가 포커스를 잡은 시점부터 나타나길 바래서
.observe(on: MainScheduler.asyncInstance)
.bind{
self.YearTextField4($0)
self.Yearborder.isHidden = false
} // 에러 방출할 일 없으니 bind로 사용해보자
.disposed(by: bag) // 메모리 누수를 막읍시다.
MonthTextField.rx.text.orEmpty
.skip(1)
.observe(on: MainScheduler.asyncInstance)
.subscribe(onNext: {
self.MonthTextField2($0)
self.Monthborder.isHidden = false
})
.disposed(by: bag)
DayTextField.rx.text.orEmpty
.skip(1)
.observe(on: MainScheduler.asyncInstance)
.bind{
self.DayTextField2($0)
self.Dayborder.isHidden = false
} // 에러 방출할 일 없으니 bind로 사용해보자
.disposed(by: bag)
HourTextField.rx.text.orEmpty
.skip(1)
.observe(on: MainScheduler.asyncInstance)
.bind{
self.HourTextField2($0)
self.Hourborder.isHidden = false
} // 에러 방출할 일 없으니 bind로 사용해보자
.disposed(by: bag)
MinuteTextField.rx.text.orEmpty
.skip(1)
.observe(on: MainScheduler.asyncInstance)
.bind{
self.MinuteTextField2($0)
self.Minuteborder.isHidden = false
} // 에러 방출할 일 없으니 bind로 사용해보자
.disposed(by: bag)
AMButton.rx.tap
.bind{
self.AMButton.setTitleColor(.black, for: .normal)
self.PMButton.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}.disposed(by: bag)
PMButton.rx.tap
.bind{
self.PMButton.setTitleColor(.black, for: .normal)
self.AMButton.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}.disposed(by: bag)
TimeActivationButton.rx.tap
.bind{
if self.TimeActivationButton.image(for: .normal) == UIImage(systemName: "plus.circle") { // 비활성화 상태 -> 활성화 상태
if self.nowDateTime(5) == "AM" {
self.AMButton.setTitleColor(.black, for: .normal)
self.PMButton.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
} else {
self.PMButton.setTitleColor(.black, for: .normal)
self.AMButton.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
self.TimeActivationButton.setImage(UIImage(systemName: "xmark.circle"), for: .normal)
self.PMButton.isEnabled = true
self.AMButton.isEnabled = true
self.MinuteTextField.isEnabled = true
self.MinuteTextField.textColor = .black
self.Minuteborder.isHidden = false
self.HourTextField.isEnabled = true
self.HourTextField.textColor = .black
self.Hourborder.isHidden = false
self.ClockIcon.tintColor = .black
} else { // 활성화 상태 -> 비활성화 상태
self.TimeActivationButton.setImage(UIImage(systemName: "plus.circle"), for: .normal)
self.PMButton.isEnabled = false
self.PMButton.setTitleColor(.gray, for: .normal)
self.AMButton.isEnabled = false
self.AMButton.setTitleColor(.gray, for: .normal)
self.MinuteTextField.isEnabled = false
self.MinuteTextField.textColor = .gray
self.Minuteborder.isHidden = true
self.HourTextField.isEnabled = false
self.HourTextField.textColor = .gray
self.Hourborder.isHidden = true
self.ClockIcon.tintColor = .gray
}
}.disposed(by: bag)
// MARK:: WeekendButtonClick 상태 확인
WeekStackIndex0.rx.tap
.bind{
if self.WeekStackIndex0.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex0.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex0.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex1.rx.tap
.bind{
if self.WeekStackIndex1.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex1.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex1.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex2.rx.tap
.bind{
if self.WeekStackIndex2.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex2.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex2.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex3.rx.tap
.bind{
if self.WeekStackIndex3.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex3.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex3.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex4.rx.tap
.bind{
if self.WeekStackIndex4.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex4.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex4.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex5.rx.tap
.bind{
if self.WeekStackIndex5.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex5.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex5.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex6.rx.tap
.bind{
if self.WeekStackIndex6.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex6.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex6.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
WeekStackIndex7.rx.tap
.bind{
if self.WeekStackIndex7.currentTitleColor == UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1) {
self.WeekStackIndex7.setTitleColor(.black, for: .normal)
} else {
self.WeekStackIndex7.setTitleColor(UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1), for: .normal)
}
}
.disposed(by: bag)
RequestTextView.rx.didBeginEditing
.bind{ _ in
if self.RequestTextView.text == "간단한 메시지를 적어보세요~!" {
self.RequestTextView.text = ""
}
self.RequestTextView.textColor = .black
}.disposed(by: bag)
RequestTextView.rx.didEndEditing
.bind{
if self.RequestTextView.text.count == 0 {
self.RequestTextView.text = "간단한 메시지를 적어보세요~!"
self.RequestTextView.textColor = UIColor(red: 0.675, green: 0.675, blue: 0.675, alpha: 1)
}
}.disposed(by: bag)
//
// CreateRoutineTextField.rx.controlEvent([.editingDidBegin])
// .bind{
// print("touch begin")
// }.disposed(by: bag)
ChallengeAddButton.rx.tap
.bind{
/*
확인해야하는 사항
1. 제목이 정상적으로 들어가 있는지
2. 누구와 함께할지 선택 하였는지 - 선택하지 않았다면 그냥 default
3. 날짜는 잘 들어가 있고, 오늘 날짜보다 뒤인지.
4. 시간은 어떻게 설정했는지, 아예 막았을 수도 있어서 AM,PM도 검사
5. 요일 선택은 어떻게 했는지
6. 요청 메시지는 어떻게 입력했는지. -> 요청 메시지는 없어도 돼.
*/
if self.ChallengeAddButton.currentTitle == "챌린지를 추가하세요" {
self.ChecktheOption()
} else { // 글 확인하기
// 도전 중인 챌린지에 넣거나, 데이터 모델 안에 챌린지 도전 여부를 바로 넣어서 확인한다.
self.alert("챌린지를 시작합니다") {
self.myPageTable.dummyRoutineData[self.idxpath].RChallengeState = " 챌린지 중 "
print(self.myPageTable.dummyRoutineData)
self.dismiss(animated: false) {
print("AD")
}
}
}
}.disposed(by: bag)
BackButton.rx.tap
.bind{
self.dismiss(animated: true, completion: nil)
}.disposed(by: bag)
}
}
|
[
-1
] |
b16c759a0f7ef64fc79355e5488bf6eb352a59e2
|
d488437ae46a3e377bcc2b94ca3446243fe1aa6a
|
/SwiftAll/Controller/HomeViewController.swift
|
986caf63e539599114b108c6602549c795c96517
|
[] |
no_license
|
MuRanJiangXia/SwiftWeibo
|
27ab03f64161099f9fcae1ec8079497ebafd71a9
|
06e684e909646fde7618e2b8b48e4bdceecd3946
|
refs/heads/master
| 2020-03-07T09:00:04.547943 | 2018-04-02T06:20:51 | 2018-04-02T06:20:51 | 127,395,226 | 9 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 8,128 |
swift
|
//
// HomeViewController.swift
// SwiftAll
//
// Created by cyan on 2018/3/27.
// Copyright © 2018年 cyan. All rights reserved.
//
import UIKit
import SnapKit
import MJRefresh
class HomeViewController: BaseViewController ,SinaWeiboRequestDelegate,UITableViewDelegate,UITableViewDataSource{
var cellArr = NSMutableArray()
var homeTableView : UITableView!
var layoutCell : HomeCell!
// 顶部刷新
let header = MJRefreshNormalHeader()
// 底部刷新
let footer = MJRefreshAutoNormalFooter()
//get请求字典
var paramterDic:NSMutableDictionary!
override func viewDidLoad() {
super.viewDidLoad()
self.title = "首页"
self.view.backgroundColor = UIColor.white
creatUI()
initConFigure()
self.layoutCell = HomeCell.init(style: UITableViewCellStyle(rawValue: 0)!, reuseIdentifier: "HomeCell")
if self.sinaweibo.isAuthValid() {
// headerAction()
//做本地存储用
let json = CYTools.readJson(name: "homeJson")
if json is NSNull {
headerAction()
}else{
let jsonArr:NSArray = json as! NSArray
jsonArr.enumerateObjects { (obj, int, stop) in
let weiboModel:WeiBoModel = WeiBoModel()
weiboModel.setValuesForKeys(obj as! [String : Any])
self.cellArr.add(weiboModel)
}
self.homeTableView.reloadData()
}
}else{
self.sinaweibo.logIn()
}
}
func initConFigure() {
//下拉刷新
header.setRefreshingTarget(self, refreshingAction: #selector(headerAction))
self.homeTableView.mj_header = header
//上拉刷新
footer.setRefreshingTarget(self, refreshingAction: #selector(footerAction))
self.homeTableView.mj_footer = footer
}
func creatUI() {
self.homeTableView = UITableView.init(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - 64))
// self.homeTableView.backgroundColor = UIColor.yellow
self.homeTableView.delegate = self
self.homeTableView.dataSource = self
self.homeTableView.register(HomeCell.classForCoder(), forCellReuseIdentifier: "HomeCell")
self.homeTableView.separatorStyle = .none
self.homeTableView.estimatedRowHeight = 175;
self.view.addSubview( self.homeTableView)
}
//懒加载sinaweibo
lazy var sinaweibo :SinaWeibo = {
() -> SinaWeibo in
let AppDelegate = UIApplication.shared.delegate as! AppDelegate
return AppDelegate.sinaweibo
}()
// MARK: - UITableViewDataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.cellArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:HomeCell = tableView.dequeueReusableCell(withIdentifier: "HomeCell", for: indexPath) as! HomeCell
cell.weiboModel = self.cellArr[indexPath.row] as? WeiBoModel
cell.attitudeBtn.addTarget(self, action: #selector(attitudeAction(btn:)), for: .touchUpInside)
cell.attitudeBtn.tag = 2018 + indexPath.row
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let model:WeiBoModel = self.cellArr[indexPath.row] as! WeiBoModel
if model.cellHeight == 0{
model.cellHeight = self.layoutCell.heightForModel(weiboModel: model)
}
return model.cellHeight
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
// MARK: - 点赞方法
@objc func attitudeAction(btn : UIButton){
let row = btn.tag - 2018
let model:WeiBoModel = self.cellArr[row] as! WeiBoModel
model.isFavourite = NSNumber.init(value: !model.isFavourite.boolValue)
btn.isSelected = model.isFavourite.boolValue
if model.isFavourite.boolValue {
//动画
let keyAnimation = CAKeyframeAnimation.init()
keyAnimation.keyPath = "transform.rotation"
let angle = Double.pi/10
let values = [(-angle),(0)]
keyAnimation.values = values
keyAnimation.duration = 0.2
keyAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
keyAnimation.autoreverses = true
btn.imageView?.layer.add(keyAnimation, forKey: "attitudemove")
}
}
// MARK: - 上下拉刷新方法
//下拉刷新
@objc func headerAction(){
self.cellArr = NSMutableArray()
let since_id : NSString!
if self.cellArr.count > 0{
let weiboModel:WeiBoModel = self.cellArr.firstObject as! WeiBoModel
since_id = weiboModel.id
}else{
since_id = "0"
}
let dic:NSDictionary = ["count":"20",
"access_token":self.sinaweibo.accessToken,
"since_id":since_id
]
self.paramterDic = dic.mutableCopy() as! NSMutableDictionary
self.getWeiBo()
}
//上拉刷新
@objc func footerAction(){
let max_id : NSString!
if self.cellArr.count > 0{
let weiboModel:WeiBoModel = self.cellArr.lastObject as! WeiBoModel
max_id = weiboModel.id
}else{
max_id = "0"
}
let dic:NSDictionary = ["count":"20",
"access_token":self.sinaweibo.accessToken,
"max_id":max_id
]
self.paramterDic = dic.mutableCopy() as! NSMutableDictionary
self.getWeiBo()
}
// MARK: - 获取微博
@objc func getWeiBo() {
if self.sinaweibo.isAuthValid() {
let url = NSString.init(format: "%@%@", BASEURL,HomeTimeLineURL)
self.showLoadingWithView(aView: self.view)
HttpTool.shareIntance.getRequest(urlString: url as String, params: self.paramterDic as! [String : Any], finished: { (response:[String:AnyObject]?, error:NSError?) in
self.homeTableView.mj_header.endRefreshing()
self.homeTableView.mj_footer.endRefreshing()
self.hideLoadingWithView(aView: self.view)
let dic = response! as NSDictionary
let errorStr = dic.object(forKey: "error")
if (errorStr != nil){
let error_code = dic.object(forKey: "error_code")
print("errorStr : \(String(describing: errorStr)),error_code : \(String(describing: error_code))")
}else{
let status:NSArray = dic.object(forKey: "statuses") as! NSArray
if self.cellArr.count > 0 { //返回的是包含最后一条的数据,不添加到数组
self.cellArr.removeLastObject()
}
// let isWrite = CYTools.writeJson(jsonObject: status as AnyObject, name: "homeJson")
// print(isWrite)
status.enumerateObjects { (obj, int, stop) in
let weiboModel:WeiBoModel = WeiBoModel()
weiboModel.setValuesForKeys(obj as! [String : Any])
self.cellArr .add(weiboModel)
}
self.homeTableView.reloadData()
}
})
}else{
self.sinaweibo.logIn()
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
|
[
-1
] |
011af500d2079628436ee11aeb4b8aff8f41521d
|
bc552c21cdbda4c0c5cf8cb949073629da3a921b
|
/EXPNSR-iOS/Pods/MNkSupportUtilities/Classes/UIStackView+Chain.swift
|
2bee29ae52acb450f20eeb2b3a1e3169dca20b0e
|
[
"MIT"
] |
permissive
|
Yasith-Thathsara-Senarathne/EXPNSR-iOS-App
|
4c8c6aab9c1278aa593b4d2e71ceb1a9a9b589ae
|
69ec20daa7f4e0d16913e7fc081726e6ba22a0d6
|
refs/heads/master
| 2023-04-17T05:13:40.008815 | 2021-05-06T04:19:19 | 2021-05-06T04:19:19 | 364,781,270 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,209 |
swift
|
//
// UIStackView+Chain.swift
// iDak
//
// Created by Malith Nadeeshan on 4/5/20.
// Copyright © 2020 Malith Nadeeshan. All rights reserved.
//
import UIKit
extension UIKitChain where Component:UIStackView{
public var vStack:Self{
component.axis = .vertical
return self
}
public var hStack:Self{
component.axis = .horizontal
return self
}
@discardableResult
public func distribution(_ distribution:UIStackView.Distribution)->Self{
component.distribution = distribution
return self
}
@discardableResult
public func spacing(_ space:CGFloat)->Self{
component.spacing = space
return self
}
@discardableResult
public func alignment(_ alignment: UIStackView.Alignment ) -> Self {
component.alignment = alignment
return self
}
@discardableResult
public func addArrangeSubViews(_ subViews: [UIView]) -> Self {
subViews.forEach{
component.addArrangedSubview($0)
}
return self
}
public var generalFillEqual: Self {
spacing(4)
distribution(.fillEqually)
return self
}
}
|
[
-1
] |
2932204cfff20c16685f6c6314356813b47266ed
|
abf3a1cf4902f030092edf58e097eacc5f5470af
|
/MagicWeapon-MockupTests/MagicWeapon_MockupTests.swift
|
92e6d2fbd75907be6adc6099d8a582f5c02b9c8a
|
[] |
no_license
|
soggybag/MagicWeapon-Mockup
|
76fedba63e1982b4bd2503cf48b973403c2eb8d8
|
70b8f898fd8c494b093d587b97d72befda107911
|
refs/heads/master
| 2021-01-10T03:33:34.632623 | 2015-10-01T17:56:20 | 2015-10-01T17:56:20 | 43,511,736 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,026 |
swift
|
//
// MagicWeapon_MockupTests.swift
// MagicWeapon-MockupTests
//
// Created by mitchell hudson on 10/1/15.
// Copyright © 2015 mitchell hudson. All rights reserved.
//
import XCTest
@testable import MagicWeapon_Mockup
class MagicWeapon_MockupTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}
|
[
333828,
282633,
313357,
182296,
317467,
241692,
98333,
16419,
102437,
229413,
292902,
204840,
354345,
223274,
278570,
344107,
233517,
155694,
124975,
253999,
229424,
346162,
229430,
319542,
124984,
358456,
288828,
288833,
288834,
352326,
254027,
311372,
354385,
196691,
315476,
280661,
329814,
278615,
338007,
307289,
200794,
354393,
180311,
180312,
237663,
309345,
280675,
307299,
280677,
329829,
313447,
278634,
315498,
319598,
288879,
352368,
299121,
284788,
233589,
280694,
131191,
333940,
237689,
288889,
215164,
313469,
215166,
278655,
292992,
333955,
280712,
215178,
241808,
323729,
325776,
317587,
278677,
284826,
278685,
346271,
311458,
278691,
49316,
233636,
333991,
333992,
284842,
32941,
278704,
239793,
323762,
299187,
278708,
125109,
131256,
182456,
184505,
280762,
299198,
379071,
299203,
301251,
309444,
227524,
338119,
282831,
321745,
254170,
356576,
317664,
338150,
176362,
321772,
286958,
125169,
338164,
327929,
184570,
243962,
125183,
309503,
125188,
276744,
313608,
125193,
375051,
180493,
125198,
325905,
254226,
125203,
319763,
125208,
325912,
309529,
299293,
278816,
125217,
233762,
211235,
217380,
305440,
227616,
151847,
282919,
211238,
98610,
125235,
332085,
280887,
125240,
332089,
278842,
282939,
315706,
287041,
241986,
260418,
332101,
182598,
323916,
319821,
254286,
348492,
250192,
6481,
323920,
344401,
348500,
366929,
155990,
366930,
289110,
6489,
272729,
379225,
106847,
323935,
391520,
321894,
280939,
242029,
246127,
354676,
139640,
246136,
246137,
291192,
362881,
248194,
225670,
395659,
227725,
395661,
240016,
178582,
291224,
293274,
317852,
283038,
61857,
285090,
61859,
246178,
289189,
375207,
289194,
108972,
340398,
377264,
61873,
61880,
283064,
278970,
319930,
336317,
293310,
278978,
127427,
127428,
283075,
291267,
188871,
324039,
317901,
373197,
281040,
278993,
326100,
278999,
328152,
176601,
242139,
369116,
285150,
287198,
279008,
342498,
242148,
195045,
279013,
279018,
281072,
279029,
279032,
233978,
279039,
342536,
287241,
279050,
340490,
289304,
279065,
342553,
291358,
182817,
277029,
375333,
377386,
283184,
289332,
23092,
234036,
315960,
338490,
352829,
301638,
348742,
322120,
55881,
348749,
281166,
281171,
244310,
354911,
436832,
295519,
66150,
111208,
344680,
191082,
279146,
313966,
281199,
287346,
279164,
189057,
311941,
348806,
279177,
369289,
330379,
344715,
184973,
311949,
330387,
330388,
352917,
227990,
117397,
230040,
271000,
342682,
295576,
221852,
279206,
295590,
287404,
205487,
295599,
303793,
299699,
299700,
164533,
338613,
314040,
287417,
158394,
342713,
285373,
287422,
66242,
363211,
242386,
279252,
287452,
318173,
289502,
363230,
295652,
279269,
338662,
285415,
346858,
330474,
289518,
199414,
154359,
221948,
35583,
205568,
162561,
299776,
363263,
285444,
242433,
291585,
322319,
295697,
285458,
166676,
207640,
326429,
336671,
326433,
344865,
279336,
318250,
295724,
152365,
312108,
318252,
353069,
285487,
328499,
242485,
353078,
230199,
353079,
285497,
336702,
420677,
353094,
353095,
299849,
283467,
293711,
281427,
353109,
281433,
230234,
301918,
242529,
293730,
303972,
351077,
275303,
342887,
230248,
201577,
242541,
400239,
246641,
330609,
209783,
246648,
209785,
226170,
269178,
177019,
279417,
361337,
291712,
254850,
359298,
240518,
287622,
228233,
228234,
308107,
56208,
295824,
308112,
293781,
209817,
324506,
324507,
318364,
289698,
189348,
324517,
289703,
353195,
140204,
353197,
189374,
353216,
349121,
363458,
213960,
279498,
316364,
338899,
340955,
248797,
207838,
50143,
130016,
340961,
64485,
314342,
52200,
123881,
324586,
203757,
289774,
304110,
320494,
340974,
316405,
240630,
295927,
201720,
304122,
314362,
320507,
328700,
293886,
328706,
320516,
230410,
330763,
320527,
146448,
324625,
316437,
418837,
230423,
320536,
197657,
281626,
201755,
336929,
189474,
300068,
357414,
248872,
345132,
238639,
252980,
300084,
322612,
359478,
324666,
238651,
302139,
21569,
349255,
359495,
238664,
300111,
314448,
341073,
353367,
156764,
156765,
314467,
281700,
250981,
322663,
300136,
316520,
228458,
207979,
300135,
316526,
357486,
144496,
187506,
353397,
291959,
160891,
341115,
363644,
150657,
187521,
248961,
349316,
279685,
349318,
222343,
330888,
228491,
228493,
285838,
169104,
162961,
177296,
308372,
326804,
296086,
185493,
119962,
300187,
296092,
300188,
339102,
302240,
343203,
300201,
300202,
253099,
238765,
279728,
367799,
339130,
208058,
64700,
322749,
228542,
343234,
367810,
259268,
283847,
353479,
62665,
353481,
353482,
244940,
283852,
283853,
290000,
228563,
316627,
279765,
296153,
357595,
279774,
298212,
304356,
290022,
330984,
228588,
234733,
253167,
279792,
353523,
298228,
216315,
208124,
316669,
363771,
388349,
228609,
234755,
279814,
322824,
242954,
292107,
312587,
328971,
251153,
245019,
320796,
126237,
130338,
130343,
277806,
351537,
298291,
345396,
277815,
300343,
116026,
222524,
333117,
286018,
193859,
279875,
230729,
224586,
372043,
177484,
251213,
238927,
277841,
296273,
277844,
277845,
120148,
318805,
283991,
222559,
314720,
234850,
292195,
230756,
294243,
277862,
333160,
277866,
134506,
277868,
230765,
296303,
243056,
279920,
312689,
314739,
116084,
327025,
327024,
327031,
277882,
277883,
306559,
277890,
179587,
378244,
298374,
314758,
277896,
277897,
314760,
388487,
368011,
142729,
314766,
296335,
112017,
112018,
277907,
234898,
306579,
9619,
282007,
357786,
318875,
290207,
314783,
333220,
277925,
314789,
279974,
282024,
241066,
316842,
277936,
286129,
173491,
210358,
284089,
277946,
228795,
292283,
302529,
302531,
163268,
380357,
415171,
300487,
361927,
300489,
296392,
370123,
148940,
280013,
310732,
64975,
312782,
327121,
222675,
366037,
277974,
210390,
210391,
277977,
353750,
210393,
228827,
286172,
329173,
277988,
310757,
187878,
316902,
280041,
361963,
277997,
54765,
191981,
306673,
278002,
321009,
251378,
333300,
343542,
280055,
300536,
288249,
343543,
191990,
333303,
286205,
290301,
286202,
210433,
282114,
228867,
366083,
323080,
230921,
329225,
253452,
323087,
304656,
329232,
316946,
146964,
398869,
308756,
308764,
282141,
349726,
230943,
333343,
282146,
306723,
286244,
245287,
245292,
349741,
169518,
230959,
286254,
288309,
290358,
235070,
288318,
280130,
349763,
124485,
56902,
288326,
288327,
292425,
243274,
128587,
333388,
333393,
280147,
290390,
235095,
300630,
306776,
196187,
343647,
333408,
286306,
374372,
282213,
323178,
54893,
138863,
222832,
314998,
247416,
366203,
175741,
325245,
337535,
294529,
224901,
282245,
282246,
288392,
229001,
286343,
290443,
310923,
188048,
323217,
239250,
282259,
345752,
229020,
255649,
282273,
245412,
40613,
40614,
40615,
229029,
282280,
298661,
323236,
321207,
296632,
319162,
280251,
282303,
286399,
280257,
218819,
321219,
306890,
280267,
212685,
333517,
282318,
333520,
241361,
245457,
302802,
333521,
333523,
280278,
241365,
280280,
298712,
18138,
278234,
286423,
294622,
321247,
278240,
282339,
12010,
212716,
212717,
280300,
282348,
284401,
282358,
313081,
286459,
325371,
124669,
194303,
278272,
175873,
319233,
323331,
323332,
288512,
280327,
280329,
284429,
284431,
278291,
278293,
294678,
321302,
366360,
116505,
249626,
284442,
325404,
321310,
282400,
241441,
325410,
339745,
341796,
247590,
257830,
333610,
317232,
282417,
296755,
321337,
282427,
360252,
325439,
315202,
307011,
282434,
282438,
345929,
341836,
323406,
307025,
325457,
18262,
370522,
188251,
280410,
345951,
362337,
284514,
345955,
296806,
276327,
292712,
282474,
288619,
325484,
280430,
296814,
292720,
362352,
282480,
313203,
325492,
300918,
241528,
317304,
194429,
124798,
325503,
182144,
305026,
241540,
253829,
333701,
67463,
243591,
325515,
243597,
325518,
110480,
282518,
282519,
124824,
214937,
329622,
294807,
294809,
118685,
298909,
319392,
292771,
354212,
294823,
333735,
284587,
124852,
243637,
282549,
288697,
290746,
214977,
163781,
284619,
247757,
344013,
212946,
24532,
219101,
280541,
329695,
292836,
298980,
294886,
337895,
247785,
253929,
327661,
362480,
325619,
333817,
313339
] |
eba5952182bde627d4c3c352e1a53bc714d36f60
|
39aed9b6e68a72e984a55b75d8bbd8244512f980
|
/ForAppStore/Wish_List/Money_History_Controller.swift
|
a67782be75fb8be013789d26d228602aa1d389f8
|
[] |
no_license
|
ProjectInTheClass/Wish_List
|
22e55d4755dd60ce0532f02d5675bd56d3554c56
|
02a0ed3b41a32a9a49637bff0a604eda878e7dc8
|
refs/heads/master
| 2020-03-16T18:16:37.973422 | 2018-06-27T06:59:12 | 2018-06-27T06:59:12 | 132,866,654 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,239 |
swift
|
//
// Money_History_Controller.swift
// Wish_List
//
// Created by 소스1 on 2018. 6. 19..
// Copyright © 2018년 test. All rights reserved.
//
import UIKit
class History_info_CellView:UITableViewCell{
@IBOutlet weak var Reason : UILabel?
@IBOutlet weak var Day : UILabel?
@IBOutlet weak var Money : UILabel?
override func awakeFromNib() {
super.awakeFromNib()
Reason?.adjustsFontSizeToFitWidth = true
Reason?.minimumScaleFactor = 0.2
Day?.adjustsFontSizeToFitWidth = true
Day?.minimumScaleFactor = 0.2
Money?.adjustsFontSizeToFitWidth = true
Money?.minimumScaleFactor = 0.2
}
override func prepareForReuse() {
super.prepareForReuse()
Reason?.text = nil
Day?.text = nil
Money?.text = nil
}
}
class Money_History_Controller: UIViewController{
var data : Wish_Item?
@IBOutlet weak var D_day : UILabel? //d-day
@IBOutlet weak var Save : UILabel? //넣은 돈
@IBOutlet weak var Lists : UITableView?
@IBOutlet weak var Navibar: UINavigationBar?
var mode : Int?
var adds:Array<history>?
var minuses:Array<history>?
override func viewDidLoad() {
super.viewDidLoad()
Navibar?.topItem?.title = data?.name
Save?.text = (data?.save.description)! + "원"
Save?.adjustsFontSizeToFitWidth = true
Save?.minimumScaleFactor = 0.2
Lists?.dataSource = self
Lists?.delegate = self
mode = 0
var interval : Double
var s = "-"
interval = (data?.d_day?.timeIntervalSinceNow)! + 86399
interval = interval / 86400
if interval < 0 {
interval = interval * -1
s = "+"
}
D_day?.text = "D " + s + " " + (Int(interval)).description
adds = []
minuses = []
for entry in (data?.m_info)!{
if entry.is_input == true{
adds?.append(entry)
}
else{
minuses?.append(entry)
}
}
}
@IBAction func out(){
self.dismiss(animated: true, completion: nil)
}
@IBAction func show_all(){
mode = 0
self.Lists?.reloadData()
}
@IBAction func show_in(){
mode = 1
self.Lists?.reloadData()
}
@IBAction func show_out(){
mode = 2
self.Lists?.reloadData()
}
// 뷰 컨트롤러 내에서 오버라이드하여 사용합니다.
override var shouldAutorotate: Bool {
return false // or false
}
}
extension Money_History_Controller: UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//return proj.count
if mode == 0 {
return (data?.m_info.count)!
}
else if mode == 1{
return (adds?.count)!
}
else{
return (minuses?.count)!
}
}
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
//return 4
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// 첫 번째 인자로 등록한 identifier, cell은 as 키워드로 앞서 만든 custom cell class화 해준다.
let cell = Lists?.dequeueReusableCell(withIdentifier: "histories", for: indexPath as IndexPath) as! History_info_CellView // 위 작업을 마치면 커스텀 클래스의 outlet을 사용할 수 있다.
if mode == 0{
let index = (data?.m_info.count)! - 1 - indexPath.row
if data?.m_info[index].is_input == true{
cell.Money?.textColor = UIColor.blue
cell.Reason?.textColor = UIColor.blue
}
else{
cell.Money?.textColor = UIColor.red
cell.Reason?.textColor = UIColor.red
}
cell.Day?.text = formatter.string(from: (data?.m_info[index].date)!)
cell.Money?.text = data?.m_info[index].money.description
cell.Reason?.text = data?.m_info[index].info
return cell
}
else if mode == 1 {
let index = (adds?.count)! - 1 - indexPath.row
cell.Money?.textColor = UIColor.blue
cell.Reason?.textColor = UIColor.blue
cell.Day?.text = formatter.string(from: (adds?[index].date)!)
cell.Money?.text = adds?[index].money.description
cell.Reason?.text = adds?[index].info
return cell
}
else{
let index = (minuses?.count)! - 1 - indexPath.row
cell.Money?.textColor = UIColor.red
cell.Reason?.textColor = UIColor.red
cell.Day?.text = formatter.string(from: (minuses?[index].date)!)
cell.Money?.text = minuses?[index].money.description
cell.Reason?.text = minuses?[index].info
return cell
}
}
}
extension Money_History_Controller: UITableViewDelegate{
}
|
[
-1
] |
c67d1256f00c78cc98043b91d7f471214a7a8010
|
317562cb5db946754232ffbc6a8fe1e4072e0842
|
/SwiftyCompanion/Controller/SkillsTableViewController.swift
|
ca8c3b9151c3df9324666418b7abb98440cfcd32
|
[] |
no_license
|
rghirell/SwiftyCompanion
|
d7c372e9d174e36e6c5da44491ecb54eee660731
|
5b96f7917c8282c407b6b3eb8543acdd0bab557d
|
refs/heads/master
| 2020-05-17T15:38:33.761900 | 2019-04-29T11:30:47 | 2019-04-29T11:30:47 | 183,795,993 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,043 |
swift
|
//
// SkillsTableViewController.swift
// SwiftyCompanion
//
// Created by Raphael GHIRELLI on 6/13/18.
// Copyright © 2018 Raphael GHIRELLI. All rights reserved.
//
import UIKit
class SkillsTableViewController: UITableViewController {
var skills: [Skills]?
var flag: [Bool]?
let image: UIImageView = {
let image = UIImageView()
image.translatesAutoresizingMaskIntoConstraints = false
image.image = UIImage(named: "sad")
image.contentMode = .scaleAspectFit
return image
}()
override func viewDidLoad() {
super.viewDidLoad()
flag = [Bool](repeatElement(false, count: skills?.count ?? 0))
self.tableView?.rowHeight = 73.0
self.tableView.tableFooterView = UIView()
if (skills!.count == 0){
setupImage()
}
}
func setupImage() {
view.addSubview(image)
NSLayoutConstraint.activate([image.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -50),
image.centerXAnchor.constraint(equalTo: view.centerXAnchor),
image.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.5),
image.widthAnchor.constraint(equalTo: image.heightAnchor)])
}
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
guard let flag = self.flag else { return }
if !flag[indexPath.item] {
let skillsCell = cell as! SkillsTableViewCell
skillsCell.backgroundColor = .clear
let progressLevelBar = skillsCell.progressBarL.frame
skillsCell.progressBarL.frame = CGRect(x: 0, y: 0, width: 0, height: progressLevelBar.height)
UIView.animate(withDuration: 2) {
skillsCell.progressBarL.frame = CGRect(x: 0, y: 0, width: progressLevelBar.width, height: progressLevelBar.height)
}
self.flag![indexPath.item] = true
}
}
override var prefersStatusBarHidden: Bool {
return true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let backgroundImage = UIImage(named: "default")
let imageView = UIImageView(image: backgroundImage)
imageView.contentMode = .scaleAspectFill
self.tableView.backgroundView = imageView
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return skills?.count ?? 0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "skillCell", for: indexPath) as! SkillsTableViewCell
cell.skills = skills?[indexPath.item]
return cell
}
}
|
[
-1
] |
69f502d13e8dcb1881c4c8bf01a12528efd877d2
|
f2cbf5672bbbe3522f038f166501e559d876c5f1
|
/Personal TranslatorUITests/Personal_TranslatorUITests.swift
|
4172335cc4ed190430c48590a46579be99ec5306
|
[
"Apache-2.0"
] |
permissive
|
curia007/Personal-Translator
|
25f8b780b363f8677b7536cfdd99abe1733343aa
|
da7ae4818d95877026104ab5ac7fdb9d8453c201
|
refs/heads/master
| 2021-03-27T10:05:00.200663 | 2017-12-06T00:48:40 | 2017-12-06T00:48:40 | 65,624,229 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,288 |
swift
|
//
// Personal_TranslatorUITests.swift
// Personal TranslatorUITests
//
// Created by Carmelo I. Uria on 6/26/16.
// Copyright © 2016 Carmelo I. Uria. All rights reserved.
//
import XCTest
class Personal_TranslatorUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
|
[
333827,
243720,
282634,
313356,
155665,
305173,
241695,
237599,
223269,
229414,
315431,
354342,
315433,
354346,
325675,
278571,
313388,
124974,
282671,
102446,
229425,
102441,
243763,
321589,
229431,
180279,
319543,
213051,
288829,
325695,
286787,
288835,
307269,
237638,
313415,
239689,
233548,
315468,
333902,
196687,
278607,
311377,
354386,
311373,
329812,
315477,
223317,
200795,
323678,
315488,
315489,
45154,
280676,
313446,
215144,
217194,
194667,
233578,
278637,
307306,
319599,
288878,
278642,
284789,
284790,
131190,
249976,
288890,
215165,
131199,
194692,
278669,
235661,
241809,
323730,
278676,
311447,
153752,
327834,
284827,
329884,
278684,
299166,
278690,
233635,
215204,
284840,
299176,
278698,
284843,
184489,
278703,
184498,
278707,
125108,
180409,
280761,
278713,
223418,
227517,
258233,
280767,
295099,
299197,
299202,
139459,
309443,
176325,
131270,
301255,
227525,
280779,
233678,
282832,
321744,
227536,
301270,
301271,
229591,
280792,
356575,
311520,
325857,
334049,
280803,
182503,
338151,
307431,
295147,
317676,
286957,
125166,
125170,
313595,
125180,
184574,
125184,
309504,
125192,
125200,
194832,
227601,
325904,
125204,
319764,
278805,
334104,
315674,
282908,
311582,
125215,
282912,
278817,
299294,
233761,
282920,
125225,
317738,
325930,
311596,
321839,
315698,
98611,
125236,
332084,
282938,
307514,
168251,
278843,
287040,
319812,
311622,
227655,
280903,
323914,
201037,
282959,
229716,
289109,
168280,
379224,
323934,
391521,
239973,
381286,
285031,
313703,
416103,
280938,
242027,
242028,
321901,
354671,
354672,
287089,
278895,
227702,
199030,
315768,
315769,
291193,
223611,
291194,
248188,
313726,
211327,
291200,
311679,
240003,
158087,
313736,
227721,
242059,
311692,
285074,
227730,
240020,
190870,
315798,
190872,
291225,
285083,
293275,
317851,
242079,
283039,
285089,
293281,
227743,
305572,
156069,
301482,
311723,
289195,
377265,
338359,
299449,
311739,
319931,
293309,
278974,
311744,
317889,
291266,
278979,
326083,
278988,
289229,
281038,
326093,
278992,
283089,
373196,
281039,
283088,
279000,
242138,
176602,
285152,
369121,
160224,
279009,
195044,
291297,
279014,
242150,
319976,
279017,
281071,
319986,
236020,
279030,
311800,
279033,
317949,
279042,
283138,
233987,
287237,
377352,
322057,
309770,
342537,
279053,
283154,
303635,
303634,
279061,
279060,
279066,
188954,
322077,
291359,
227881,
293420,
289328,
236080,
283185,
279092,
23093,
244279,
338491,
301635,
309831,
55880,
377419,
281165,
303693,
281170,
115287,
189016,
309847,
287319,
332379,
111197,
295518,
287327,
242274,
244326,
279143,
279150,
281200,
287345,
287348,
301688,
244345,
189054,
287359,
291455,
297600,
303743,
301702,
164487,
279176,
311944,
316044,
311948,
311950,
184974,
316048,
311953,
316050,
336531,
287379,
326288,
295575,
227991,
289435,
303772,
221853,
205469,
285348,
279207,
295591,
248494,
318127,
293552,
279215,
285362,
299698,
295598,
166581,
164532,
342705,
154295,
285360,
287418,
314043,
287412,
303802,
66243,
291529,
287434,
363212,
287438,
242385,
279249,
303826,
279253,
158424,
230105,
299737,
295653,
342757,
289511,
230120,
330473,
234216,
285419,
330476,
289517,
279278,
170735,
312046,
215790,
125683,
230133,
199415,
242428,
279293,
205566,
322302,
289534,
299777,
291584,
228099,
285443,
295688,
346889,
285450,
322312,
264971,
326413,
312076,
322320,
285457,
295698,
291605,
166677,
283418,
285467,
326428,
221980,
281378,
234276,
283431,
262952,
262953,
279337,
318247,
318251,
262957,
203560,
164655,
328495,
293673,
289580,
301872,
303921,
234290,
230198,
285493,
285496,
301883,
201534,
281407,
289599,
222017,
295745,
342846,
293702,
283466,
279379,
244569,
234330,
281434,
322396,
201562,
230238,
275294,
301919,
279393,
230239,
293729,
281444,
349025,
303973,
279398,
351078,
308075,
242540,
242542,
310132,
295797,
201590,
207735,
228214,
295799,
177018,
269179,
279418,
308093,
314240,
291713,
158594,
330627,
240517,
287623,
228232,
416649,
279434,
236427,
320394,
299912,
234382,
189327,
316299,
308113,
252812,
308111,
293780,
310166,
289691,
209820,
240543,
283551,
310177,
289699,
189349,
289704,
293801,
326571,
177074,
326580,
289720,
326586,
289723,
189373,
281541,
345030,
19398,
213961,
326602,
279499,
56270,
183254,
304086,
234469,
340967,
314343,
304104,
324587,
183276,
289773,
203758,
234476,
320492,
287730,
240631,
214009,
312313,
312317,
328701,
328705,
234499,
293894,
320520,
322571,
230411,
320526,
330766,
234513,
238611,
140311,
293911,
238617,
197658,
316441,
330789,
248871,
113710,
189487,
281647,
322609,
312372,
203829,
238646,
300087,
238650,
320571,
21567,
308288,
160834,
336962,
314437,
349254,
238663,
300109,
207954,
234578,
205911,
296023,
314458,
156763,
281698,
281699,
230500,
285795,
214116,
322664,
228457,
279659,
300145,
230514,
238706,
187508,
312435,
279666,
302202,
285819,
314493,
285823,
150656,
234626,
222344,
318602,
234635,
228492,
337037,
177297,
162962,
187539,
326803,
308375,
324761,
285850,
296091,
234655,
330912,
300192,
302239,
306339,
339106,
234662,
300200,
249003,
208044,
238764,
302251,
322733,
294069,
294075,
339131,
228541,
64699,
283841,
148674,
283846,
312519,
279752,
283849,
148687,
290001,
189651,
316628,
279766,
189656,
295769,
279775,
304352,
298209,
310496,
304353,
279780,
228587,
279789,
290030,
302319,
251124,
316661,
283894,
234741,
279803,
208123,
292092,
228608,
320769,
234756,
322826,
242955,
312588,
177420,
318732,
245018,
320795,
318746,
320802,
304422,
130342,
130344,
292145,
298290,
312628,
345398,
300342,
159033,
333114,
333115,
286012,
181568,
279872,
279874,
300355,
193858,
216387,
300354,
372039,
294210,
304457,
345418,
230730,
296269,
234830,
224591,
238928,
222542,
296274,
314708,
318804,
283990,
314711,
357720,
300378,
300379,
316764,
294236,
314721,
292194,
230757,
281958,
314727,
134504,
306541,
314734,
284015,
234864,
296304,
316786,
327023,
314740,
230772,
314742,
327030,
314745,
290170,
310650,
224637,
306558,
306561,
243073,
294278,
314759,
296328,
296330,
298378,
368012,
304523,
279955,
306580,
112019,
224662,
234902,
282008,
314776,
318876,
282013,
148899,
314788,
314790,
282023,
333224,
298406,
245160,
241067,
279980,
314797,
279979,
286128,
173492,
279988,
286133,
284090,
310714,
228796,
302523,
54719,
415170,
292291,
302530,
280003,
228804,
300488,
306634,
339403,
370122,
302539,
280011,
234957,
329168,
312785,
327122,
222674,
280020,
329170,
280025,
310747,
239069,
144862,
286176,
320997,
310758,
187877,
280042,
280043,
191980,
300526,
329198,
337391,
282097,
308722,
296434,
306678,
40439,
191991,
288248,
286201,
300539,
288252,
312830,
290304,
245249,
228868,
292359,
218632,
230922,
302602,
323083,
294413,
329231,
304655,
282132,
230933,
302613,
316951,
282135,
302620,
313338,
222754,
245291,
312879,
230960,
288305,
239159,
290359,
323132,
235069,
157246,
288319,
288322,
280131,
349764,
310853,
124486,
282182,
288328,
286281,
292426,
194118,
333389,
224848,
224852,
290391,
196184,
239192,
306777,
128600,
235096,
212574,
99937,
204386,
323171,
345697,
300643,
282214,
300645,
204394,
224874,
243306,
312941,
206447,
310896,
294517,
314997,
290425,
288377,
325246,
235136,
280193,
282244,
239238,
288391,
323208,
282248,
286344,
179853,
188049,
239251,
229011,
280217,
323226,
179868,
229021,
302751,
198304,
282272,
245413,
282279,
298664,
212649,
298666,
317102,
286387,
300725,
337590,
286392,
300729,
306875,
280252,
280253,
282302,
323262,
286400,
323265,
321217,
296636,
333508,
282309,
321220,
280259,
296649,
239305,
306891,
280266,
212684,
302798,
9935,
282321,
333522,
286419,
313042,
241366,
280279,
282330,
18139,
280285,
294621,
282336,
325345,
321250,
294629,
153318,
333543,
181992,
12009,
337638,
282347,
288492,
282349,
34547,
67316,
323315,
286457,
284410,
200444,
288508,
282366,
286463,
319232,
288515,
280326,
282375,
323335,
284425,
300810,
282379,
216844,
280333,
284430,
116491,
300812,
161553,
124691,
278292,
118549,
278294,
282390,
116502,
284436,
325403,
321309,
282399,
282401,
325411,
186148,
186149,
315172,
241447,
333609,
294699,
286507,
280367,
300849,
282418,
280373,
282424,
280377,
321338,
282428,
280381,
345918,
241471,
413500,
280386,
325444,
280391,
153416,
325449,
315209,
159563,
280396,
307024,
337746,
317268,
325460,
307030,
18263,
237397,
241494,
188250,
284508,
300893,
307038,
237411,
284515,
276326,
282471,
296807,
292713,
282476,
292719,
296815,
325491,
313204,
333687,
317305,
124795,
317308,
339840,
182145,
315265,
280451,
325508,
333700,
243590,
282503,
67464,
188293,
305032,
315272,
315275,
243592,
325514,
184207,
311183,
124816,
282517,
294806,
214936,
337816,
124826,
329627,
239515,
214943,
298912,
319393,
333727,
294820,
219046,
333734,
294824,
298921,
284584,
313257,
292783,
126896,
200628,
300983,
343993,
288698,
294849,
214978,
280517,
280518,
214983,
282572,
282573,
153553,
24531,
231382,
329696,
323554,
292835,
6116,
190437,
292838,
294887,
317416,
313322,
278507,
329707,
298987,
296942,
311277,
124912,
327666,
278515,
325620,
239610
] |
4054ceeb806a9da8019d15190f5260d49dd0f92a
|
758b57b62740e5d4f31d3e03ecaeb536cb06a009
|
/DemoApp/Extensions/UIColor+Extension.swift
|
742e96a4b8e53dd7cec89f6b1f0876b32d2d6e47
|
[] |
no_license
|
fabriziosposetti/books
|
30feb9c67e74280c8bf7e3486dd5dbc71bf1b3ab
|
e42cca566be0b93d7326d4d6e7abee0272398ebc
|
refs/heads/master
| 2021-07-11T23:32:45.973782 | 2019-08-29T15:17:27 | 2019-08-29T15:17:27 | 202,620,598 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 492 |
swift
|
//
// UIColor+Extension.swift
// DemoApp
//
// Created by Fabrizio Sposetti on 15/08/2019.
// Copyright © 2019 Fabrizio Sposetti. All rights reserved.
//
import UIKit
extension UIColor {
class func greenFavouriteAdd() -> UIColor {
return UIColor(red: 131/255.0, green: 180/255.0, blue: 23/255.0, alpha: 1.0)
}
class func blueEmptyTable() -> UIColor {
return UIColor(red: 22.0/255.0, green: 106.0/255.0, blue: 176.0/255.0, alpha: 1.0)
}
}
|
[
-1
] |
892341ef86500eb8245846e8448735b5b730fd98
|
76eb030d140b1a6b312030d6b678333642893722
|
/HopperBus/Utility/Constants.swift
|
597254b72a7b5d299b359a99f058a7f4f3bdbad1
|
[] |
no_license
|
Milstein/HopperBus-iOS
|
c3acd888f7b5c4c3d1f9992d198062a793efc250
|
aef70e9a76ab631d4a65391265a0b0dcd43be7ff
|
refs/heads/master
| 2021-01-09T07:36:08.990973 | 2015-02-08T21:10:49 | 2015-02-08T21:10:49 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 935 |
swift
|
//
// Constants.swift
// HopperBus
//
// Created by Tosin Afolabi on 02/10/2014.
// Copyright (c) 2014 Tosin Afolabi. All rights reserved.
//
let kHasHomeViewBeenDisplayedYetKey = "hasHomwViewBeenDisplayedYet"
private let Device = UIDevice.currentDevice()
private let iosVersion = NSString(string: Device.systemVersion).doubleValue
let iOS8 = iosVersion >= 8
let iOS7 = iosVersion >= 7 && iosVersion < 8
let iPhone6Or6Plus = UIScreen.mainScreen().bounds.width > 320
let iPhone6P = UIScreen.mainScreen().bounds.height == 736.0
let iPhone6 = UIScreen.mainScreen().bounds.height == 667.0
let iPhone5 = UIScreen.mainScreen().bounds.height == 568.0
let iPhone4S = UIScreen.mainScreen().bounds.height == 480.0
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}
|
[
-1
] |
6af0b2c08208263974e6f2dbfd982f588d2699a2
|
7cdcda34a07a83bcf9f649adb749fc8044d30474
|
/MobiquityAssignment/Controller/SearchViewController.swift
|
6c499b90b5a71389c4f942a81eccb65f8177ebdc
|
[] |
no_license
|
Vibha2286/MobiquityAssignment
|
ec837c6187d3f925ea872b85949782937cbaa298
|
39c6faa0659c74f8e3152e3b4c9cc0fd7b50b90b
|
refs/heads/main
| 2023-07-18T18:16:50.808042 | 2021-09-21T22:31:10 | 2021-09-21T22:31:10 | 408,983,645 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,110 |
swift
|
//
// SearchViewController.swift
// MobiquityAssignment
//
// Created by Vibha Mangrulkar (ZA) on 2021/09/17.
//
import UIKit
import ProgressHUD
final class SearchViewController: UICollectionViewController {
@IBOutlet weak var searchTextField: UITextField!
private lazy var viewModel = SearchViewModel(delegate: self,
searchImageInteractor: SearchFlickrImageInteractor())
override func viewDidLoad() {
super.viewDidLoad()
configureUI()
}
/// configure ui by retriving images from server
private func configureUI() {
fetchImages(tag: viewModel.tag)
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "history.Button.title".localized(),
style: .plain,
target: self,
action: #selector(historyButtonTapped))
}
fileprivate func configureList(title: String) {
viewModel.resetImagesData
viewModel.tag = title
searchTextField.resignFirstResponder()
searchTextField.text = title
collectionView?.reloadData()
}
/// present history controller by tapping on history button
@objc private func historyButtonTapped() {
searchTextField.resignFirstResponder()
performSegue(withIdentifier: "HistorySegue", sender: nil)
}
/// prepare segue to navigate
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
if segue.identifier == "HistorySegue" {
guard let historyViewController = segue.destination as? HistoryViewController else { return }
historyViewController.setData(delegate: self)
}
}
}
// MARK: - Data Source
extension SearchViewController {
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return viewModel.imageData.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Constants.reuseIdentifier, for: indexPath) as! FlickrImageCell
guard viewModel.imageData.count != 0 else { return cell }
let urlString = viewModel.imageData[indexPath.row].imagePath() ?? ""
viewModel.retriveImageFromString(urlString) { (image) in
cell.imageView.image = image
} failure: {_ in
DispatchQueue.main.async {
cell.imageView.image = UIImage(named: "placeholder")
}
}
return cell
}
override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if indexPath.row == viewModel.imageData.count - Constants.reloadCount {
fetchImages(tag: viewModel.tag)
}
}
}
// MARK: - Flow Layout Delegate
extension SearchViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let padding: CGFloat = 30
let collectionViewSize = collectionView.frame.size.width - padding
return CGSize(width: collectionViewSize/2, height: collectionViewSize/2)
}
}
// Mark:- Fetch image data from API
extension SearchViewController {
func fetchImages(tag: String) {
viewModel.pageCount += 1
ProgressHUD.show("loading.Image".localized())
viewModel.fetchImageWithString(tag) {
DispatchQueue.main.async { [weak self] in
ProgressHUD.dismiss()
self?.collectionView?.reloadData()
}
} failure: {_ in
ProgressHUD.dismiss()
}
}
}
// Mark:- UITextFieldDelegate
extension SearchViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
configureList(title: textField.text ?? "kitten")
guard let text = textField.text, !text.isEmpty else { return true }
fetchImages(tag: viewModel.tag)
return true
}
}
// Mark:- SearchViewModelDelegate
extension SearchViewController: SearchViewModelDelegate {
func reloadWithHistoryTag(_ title: String) {
configureList(title: title)
fetchImages(tag: viewModel.tag)
}
func showErrorMessage(_ errorMessage: String?) {
DispatchQueue.main.async {
let alert = UIAlertController(title: "error.alert.title".localized(), message: errorMessage, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "ok.Button.title".localized(), style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
|
[
-1
] |
0ce14ce744189d3737ec92b5227573c95b753fa7
|
c6e3d97f94055d0de0b13186e33794112027e8b3
|
/draggableViews/draggableViews/ViewController.swift
|
b182e16d1616dd558f7aec803b39dbe25cdfefc1
|
[] |
no_license
|
vijaytholpadi/draggableViews-Swift-exp
|
74500cf586822e5a445e6451e85cbfd0cd0e97ad
|
ddf29543f007e45f54d477f578e465d9ffe29e1c
|
refs/heads/master
| 2021-01-22T04:34:32.749780 | 2014-07-25T18:01:18 | 2014-07-25T18:01:18 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 878 |
swift
|
//
// ViewController.swift
// draggableViews
//
// Created by Vijay Tholpadi on 7/24/14.
// Copyright (c) 2014 TheGeekProjekt. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func objectAdded(theButton: UIButton!) {
var frame = CGRectMake(100, 100, 44, 44)
var newView = ObjectView(frame: frame)
newView.userInteractionEnabled = true
newView.image = UIImage(named: theButton.titleLabel.text)
newView.contentMode = .ScaleAspectFit
self.view.addSubview(newView)
}
}
|
[
-1
] |
bc0b67b7b33dd0433973e08fe1a5468c8befb521
|
a38f67705c06637591c07a65f294fa4ba7151cab
|
/AqrDomain/APIManager.swift
|
ffb863c5749a205f1c3c7cfffe171d6a0bb2c01b
|
[] |
no_license
|
mmmanishs/AqrDomain
|
bd73a75141ab044a3d91aa4af4ae04971c3f3e0c
|
32b7d9ecc89d9cc3f61b643bd6ccab01f802a3fd
|
refs/heads/master
| 2020-12-24T12:00:45.997048 | 2017-01-01T22:41:43 | 2017-01-01T22:41:43 | 73,103,686 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,137 |
swift
|
//
// APIManager.swift
// AqrDomain
//
// Created by Singh,Manish on 11/6/16.
// Copyright © 2016 Singh,Manish. All rights reserved.
//
import Foundation
class APIManager: NSObject {
static let sharedInstance = APIManager()
let session = URLSession(configuration: URLSessionConfiguration.default)
var currentTask:URLSessionTask?
func searchDomainName(query:String,completion: @escaping ((_ success:Bool, _ dataReceived :[SearchSuggestion]?)->Void)) {
if AppManager.sharedInstance.appSettings.useNetwork == false {
completion(true, DataController.sharedInstance.parseSearchSuggestionJson(LocalDataManager.sharedInstance.getSearchDataFromLocal()))
return
}
if currentTask != nil {
currentTask?.cancel()
}
let urlString = "https://domainr.p.mashape.com/v2/search?mashape-key=&query="+query
let encodedUrlString = urlString.addingPercentEncoding( withAllowedCharacters: CharacterSet.urlQueryAllowed)
guard let url = URL(string: encodedUrlString!) else{
print("Cannot make a url out of it.")
return
}
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("czbdyylahJmsh86PI5jfI8VS7yjUp1eP9B8jsn4eRqCz33C2Nj", forHTTPHeaderField: "X-Mashape-Key")
request.setValue("application/json", forHTTPHeaderField: "Accept")
let task = session.dataTask(with: request, completionHandler: { (data, response, error) -> Void in
guard let data = data else{
completion(false, nil)
return
}
LocalDataManager.sharedInstance.saveDataToLocal(data)
do {
let json = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
completion(true, DataController.sharedInstance.parseSearchSuggestionJson(json as AnyObject?))
}
catch {
print("Unable to convert data to json")
}
})
task.resume()
currentTask = task
}
}
|
[
-1
] |
ec98115c2e803f4b09b5cdd85da389a3ccd7b271
|
2c6d7800b5d010404d9963e25624331eaf56d72e
|
/AgeCalculator/Controllers/ViewController.swift
|
97b7053ed1ba55947950ffade7220b33e3c969a9
|
[] |
no_license
|
hatchman007/myCalculator
|
70d823bea316148e5769edb265e36da5443c74c1
|
fbc68d0bc54c918330b44fcd5b3c4c62f7fb37c0
|
refs/heads/master
| 2021-01-02T13:08:36.585639 | 2020-02-10T23:44:46 | 2020-02-10T23:44:46 | 239,636,896 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,698 |
swift
|
//
// ViewController.swift
// AgeCalculator
//
// Created by Adam Hatch on 2/10/20.
// Copyright © 2020 Adam Hatch. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var lblAge: UILabel!
@IBOutlet weak var datePicker: UIDatePicker!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnCalculateHandler (_ sender: UIButton)
{
//1 - get selected date from date picker
let birthDate = self.datePicker.date
//2 - get today's date
let today = Date()
//3 - create an instance of the user's current calendar
let calendar = Calendar.current
//4 - use calendar to get difference between two dates
let components = calendar.dateComponents([.year, .month, .day], from: birthDate, to: today)
let ageYears = components.year
let ageMonths = components.month
let ageDays = components.day
//5 - display age in label
self.lblAge.text = "\(ageYears!) years, \(ageMonths!) months, \(ageDays!) days"
//check our birth date is earlier than today
if birthDate >= today
{
//display error and return
let alertView = UIAlertController(title: "Error", message: "Please enter a valid date", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alertView.addAction(action)
self.present(alertView, animated: false, completion: nil)
return
}
}
}
|
[
-1
] |
5857b1564d572b7ddda3a5087f01f27e0da324ce
|
a76205e8f2545808cd676ed32c323dc7bc6d1e47
|
/Flash Chat iOS13/Controllers/RegisterViewController.swift
|
802a6193e8d3e789b33f169ea39de6cb74b920b1
|
[] |
no_license
|
Srijan1998/Flash-Chat
|
4a1d8e434046189f22f74100f26b88215d06d3a6
|
545b3b1ea0f4864ad303bd73686172cda63dcb37
|
refs/heads/main
| 2023-01-04T14:15:02.852949 | 2020-11-01T15:10:42 | 2020-11-01T15:10:42 | 309,121,860 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 963 |
swift
|
//
// RegisterViewController.swift
// Flash Chat iOS13
//
// Created by Angela Yu on 21/10/2019.
// Copyright © 2019 Angela Yu. All rights reserved.
//
import UIKit
import Firebase
class RegisterViewController: UIViewController {
@IBOutlet weak var emailTextfield: UITextField!
@IBOutlet weak var passwordTextfield: UITextField!
@IBAction func registerPressed(_ sender: UIButton) {
if let email = emailTextfield.text, let password = passwordTextfield.text {
Auth.auth().createUser(withEmail: email, password: password) { [weak self] authResult, error in
guard let strongSelf = self else { return }
if error != nil {
print(error!.localizedDescription)
}
else
{
strongSelf.performSegue(withIdentifier:Constants.registerSegue , sender: strongSelf)
}
}
}
}
}
|
[
-1
] |
97c4845f110c6430b97dff7b4979131b75041a41
|
1d00ff11b286614168d9ed6c4afd8c6f3c0bbe3c
|
/Stripway/ViewControllers/Feeds/SharePostVC.swift
|
6894703360b56ed2a16a172b6459186cc56bc616
|
[] |
no_license
|
stripwayscammer/stripway
|
ade8574c4897011446d39e50662f726874cc4e07
|
46ce6f6acb9810636cb81058621073d71be48fea
|
refs/heads/main
| 2023-01-20T11:40:49.674772 | 2020-11-30T09:58:02 | 2020-11-30T09:58:02 | 317,169,318 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 13,768 |
swift
|
//
// CommentViewController.swift
// Stripway
//
// Created by Drew Dennistoun on 10/3/18.
// Copyright © 2018 Stripway. All rights reserved.
//
import UIKit
import FirebaseDatabase
class SharePostVC: UIViewController {
@IBOutlet weak var scrollTopView: UIView!
@IBOutlet weak var searchView: UIView!
@IBOutlet weak var bottomView: UIView!
@IBOutlet weak var textView: UITextView!
@IBOutlet var tableViewTapGestureRecognizer: UITapGestureRecognizer!
@IBOutlet weak var textFieldBottomConstraint: NSLayoutConstraint!
@IBOutlet weak var postButton: UIButton!
@IBOutlet weak var searchBar: UISearchBar!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var suggestionsContainerView: UIView!
var post: StripwayPost!
var users: [StripwayUser] = []
var searchedUsers: [StripwayUser] = []
var selectedUsers: [Bool] = []
var tappedUser: StripwayUser!
var profileOwner: StripwayUser!
var delegate: SharePostVCDelegate?
var suggestionsTableViewController: SuggestionsTableViewController?
var mentionedUIDs = [String]()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
tableView.estimatedRowHeight = 69
tableView.rowHeight = UITableView.automaticDimension
// Do any additional setup after loading the view.
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
handleTextField()
loadFollowings()
}
override func viewDidAppear(_ animated: Bool) {
}
func handleTextField() {
// textView.addTarget(self, action: #selector(self.textFieldDidChange), for: .editingChanged)
}
func loadFollowings() {
self.users.removeAll()
self.searchedUsers.removeAll()
self.selectedUsers.removeAll()
self.tableView.reloadData()
API.Follow.fetchFollowings(forUserID: Constants.currentUser!.uid) { (user, error) in
if let error = error {
return
} else if let user = user {
self.isFollowing(userID: user.uid, completion: { (value) in
user.isFollowing = value
self.users.append(user)
self.searchedUsers.append(user)
self.selectedUsers.append(false)
self.tableView.reloadData()
})
}
}
}
func isFollowing(userID: String, completion: @escaping (Bool)->()) {
API.Follow.isFollowing(userID: userID, completion: completion)
}
func doSearch() {
var searchText = searchBar.text?.lowercased()
if searchText == nil {
searchText = ""
}
print("SEARCHING WITH TEXT: |\(searchText)|")
self.searchedUsers.removeAll()
self.tableView.reloadData()
for user in self.users {
if searchText! == "" {
self.searchedUsers.append(user)
}
else if user.username.lowercased().contains(searchText!){
self.searchedUsers.append(user)
}
}
self.tableView.reloadData()
}
@objc func textFieldDidChange() {
return
}
@IBAction func handlePan(recognizer:UIPanGestureRecognizer) {
if recognizer.state == UIGestureRecognizer.State.ended {
let velocity = recognizer.velocity(in: self.view)
if (velocity.y > VELOCITY_LIMIT_SWIPE) {
textView.resignFirstResponder()
self.dismiss(animated: true, completion: nil)
}
let magnitude = sqrt(velocity.y * velocity.y)
let slideMultiplier = magnitude / 200
let slideFactor = 0.1 * slideMultiplier //Increase for more of a slide
var finalPoint = CGPoint(x:recognizer.view!.center.x,
y:recognizer.view!.center.y + (velocity.y * slideFactor))
finalPoint.x = min(max(finalPoint.x, 0), self.view.bounds.size.width)
let finalY = recognizer.view!.center.y
if finalY < UIScreen.main.bounds.height {
finalPoint.y = UIScreen.main.bounds.height * 0.625
}
else {
textView.resignFirstResponder()
self.dismiss(animated: true, completion: nil)
}
UIView.animate(withDuration: Double(slideFactor),
delay: 0,
// 6
options: UIView.AnimationOptions.curveEaseOut,
animations: {recognizer.view!.center = finalPoint },
completion: nil)
}
let translation = recognizer.translation(in: self.view)
if let view = recognizer.view {
print("translation Y", translation.y)
view.center = CGPoint(x:view.center.x,
y:view.center.y + translation.y)
}
recognizer.setTranslation(CGPoint.zero, in: self.view)
}
func setupUI() {
bottomView.layer.cornerRadius = 20
bottomView.layer.shadowOffset = CGSize(width: 4, height: 4)
bottomView.layer.shadowRadius = 6
bottomView.layer.shadowOpacity = 0.5
searchBar.delegate = self
searchBar.searchBarStyle = .minimal
searchBar.autocapitalizationType = .none
searchBar.sizeToFit()
searchBar.placeholder = "Search by username"
}
@IBAction func topViewTapped(_ sender: Any) {
textView.resignFirstResponder()
self.dismiss(animated: true, completion: nil)
}
@IBAction func tableViewGestureTapped(_ sender: Any) {
textView.resignFirstResponder()
}
@objc func keyboardWillShow(notification: NSNotification) {
tableViewTapGestureRecognizer.isEnabled = true
let info = notification.userInfo!
let keyboardFrame: CGRect = (info[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
print("Here's keyboardFrame in keyboardWillShow: \(keyboardFrame)")
let difference = bottomView.superview!.frame.maxY - bottomView.frame.maxY
UIView.animate(withDuration: 0.05) {
self.textFieldBottomConstraint.constant = keyboardFrame.size.height - difference - 150
self.view.layoutIfNeeded()
}
}
@objc func keyboardWillHide() {
UIView.animate(withDuration: 0.05) {
self.textFieldBottomConstraint.constant = -150
self.view.layoutIfNeeded()
}
}
func sendPostMessage() {
var comment:String = ""
if self.textView.text != "Write a message..." {
comment = self.textView.text
}
for index in 0..<self.selectedUsers.count {
if selectedUsers[index] == true {
API.Messages.sendPost(post: self.post, comment:comment, senderUser: profileOwner, receiverUser: searchedUsers[index])
}
}
self.textView.resignFirstResponder()
self.dismiss(animated: true, completion: nil)
postButton.isEnabled = true
}
@IBAction func postButtonPressed(_ sender: Any) {
postButton.isEnabled = false
if self.profileOwner == nil {
API.User.observeCurrentUser { (currentUser) in
self.profileOwner = currentUser
self.sendPostMessage()
}
}
else {
self.sendPostMessage()
}
}
@IBAction func xButtonPressed(_ sender: Any) {
textView.resignFirstResponder()
self.dismiss(animated: true, completion: nil)
}
}
extension SharePostVC: UISearchBarDelegate {
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
searchBar.setShowsCancelButton(true, animated: true)
print(searchBar.text)
doSearch()
}
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
print(searchBar.text)
doSearch()
searchBar.resignFirstResponder()
}
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
print("cancel pressed")
searchBar.text = ""
doSearch()
}
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
searchBar.setShowsCancelButton(true, animated: true)
}
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
print("cancel pressed")
searchBar.text = ""
searchBar.resignFirstResponder()
searchBar.setShowsCancelButton(false, animated: true)
doSearch()
}
}
extension SharePostVC: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return searchedUsers.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SharePersonCell", for: indexPath) as! SharePersonCell
// cell.user = users[indexPath.row]
cell.cellIndex = indexPath.row
cell.delegate = self
cell.user = searchedUsers[indexPath.row]
cell.selectButton.setImage(UIImage(named: "unselected_share"), for: UIControl.State.normal)
return cell
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
}
extension SharePostVC: SharePersonCellDelegate {
func selectPerson(_ cellIndex: Int, _ status: Bool) {
self.selectedUsers[cellIndex] = status
}
}
extension SharePostVC: SuggestionsTableViewControllerDelegate {
func autoComplete(withSuggestion suggestion: String, andUID uid: String?) {
print("replacing with suggestion")
textView.autoComplete(withSuggestion: suggestion)
self.textViewDidChange(textView)
if let uid = uid {
mentionedUIDs.append(uid)
}
}
// func autoComplete(withSuggestion suggestion: String) {
// print("replacing with suggestion")
// textView.autoComplete(withSuggestion: suggestion)
// self.textViewDidChange(textView)
// }
}
extension SharePostVC: UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
// var newURL = URL.absoluteString
// let segueType = newURL.prefix(4)
// newURL.removeFirst(5)
// if segueType == "hash" {
// print("Should segue to page for hashtag: \(newURL)")
// delegate?.segueToHashtag(hashtag: newURL, fromVC: self)
// } else if segueType == "user" {
// print("Should segue to profile for user: \(newURL)")
// delegate?.segueToProfileFor(username: newURL, fromVC: self)
// }
return false
}
func textViewDidBeginEditing(_ textView: UITextView) {
print("textViewDidBeginEditing")
if textView.tag == 0 {
textView.tag = 1
textView.text = ""
textView.textColor = UIColor.black
}
}
func textViewDidChange(_ textView: UITextView) {
textFieldDidChange()
guard let word = textView.currentWord else {
suggestionsContainerView.isHidden = true
return
}
guard let suggestionsTableViewController = self.suggestionsTableViewController else { return }
if word.hasPrefix("#") || word.hasPrefix("@") {
suggestionsTableViewController.searchWithText(text: word)
suggestionsContainerView.isHidden = false
} else {
suggestionsContainerView.isHidden = true
}
}
}
extension SharePostVC: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
print("This thing should run")
//detecting a direction
if let recognizer = gestureRecognizer as? UIPanGestureRecognizer {
let velocity = recognizer.velocity(in: self.view)
if abs(velocity.y) > abs(velocity.x) {
// this is swipe up/down so you can handle that gesture
return true
} else {
//this is swipe left/right
//do nothing for that gesture
return false
}
}
return true
}
// override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
//
// //detecting a direction
// if let recognizer = gestureRecognizer as? UIPanGestureRecognizer {
// let velocity = recognizer.velocity(in: self.view)
//
// if fabs(velocity.y) > fabs(velocity.x) {
// // this is swipe up/down so you can handle that gesture
// return true
// } else {
// //this is swipe left/right
// //do nothing for that gesture
// return false
// }
// }
// return true
// }
}
protocol SharePostVCDelegate {
}
|
[
-1
] |
eb6e4e8f43e3599437af51f54671ad9a318a53a8
|
65cc24ce4d487527a9739ba7b692ec42c3ef6116
|
/UI Test/AppDelegate.swift
|
087719e9a77256b42f2d67d1e7f6410b48b7f5bf
|
[] |
no_license
|
HelloKarla/UITest
|
b0c5c9169a22163a02c1682883435b296b5e4244
|
3cc65b73f8801b88729fe32702233ff900c44394
|
refs/heads/master
| 2021-05-02T05:21:11.862131 | 2018-02-09T15:03:18 | 2018-02-09T15:03:18 | 120,919,139 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,167 |
swift
|
//
// AppDelegate.swift
// UI Test
//
// Created by 陳怡璇 on 2018/2/9.
// Copyright © 2018年 Karen. 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,
294924,
229388,
278542,
327695,
229391,
278545,
229394,
278548,
229397,
229399,
229402,
278556,
229405,
278559,
229408,
294950,
229415,
229417,
327722,
237613,
229422,
360496,
229426,
237618,
229428,
311349,
286774,
286776,
319544,
286778,
204856,
229432,
352318,
286791,
237640,
286797,
278605,
311375,
163920,
237646,
196692,
319573,
311383,
319590,
311400,
278635,
303212,
278639,
131192,
278648,
237693,
303230,
327814,
303241,
131209,
417930,
303244,
311436,
319633,
286873,
286876,
311460,
311469,
32944,
327862,
286906,
327866,
180413,
286910,
131264,
286916,
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,
254563,
172644,
311911,
189034,
295533,
172655,
172656,
352880,
295538,
189039,
172660,
287349,
189044,
189040,
287355,
287360,
295553,
172675,
295557,
311942,
303751,
287365,
352905,
311946,
287371,
279178,
311951,
287377,
172691,
287381,
311957,
221850,
287386,
230045,
172702,
287390,
303773,
172705,
287394,
172707,
303780,
164509,
287398,
205479,
287400,
279208,
172714,
295595,
279212,
189102,
172721,
287409,
66227,
303797,
189114,
287419,
303804,
328381,
287423,
328384,
172737,
279231,
287427,
312005,
312006,
107208,
172748,
287436,
107212,
172751,
287440,
295633,
172755,
303827,
279255,
172760,
287450,
303835,
279258,
189149,
303838,
213724,
312035,
279267,
295654,
279272,
230128,
312048,
312050,
230131,
189169,
205564,
303871,
230146,
328453,
295685,
230154,
33548,
312077,
295695,
295701,
230169,
369433,
295707,
328476,
295710,
230175,
295720,
303914,
279340,
205613,
279353,
230202,
312124,
328508,
222018,
295755,
377676,
148302,
287569,
303959,
230237,
279390,
230241,
279394,
303976,
336744,
303981,
303985,
303987,
328563,
279413,
303991,
303997,
295806,
295808,
295813,
304005,
320391,
304007,
304009,
213895,
304011,
230284,
304013,
295822,
189325,
279438,
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,
197645,
295949,
320528,
140312,
295961,
238620,
197663,
304164,
304170,
304175,
238641,
312374,
238652,
238655,
230465,
238658,
336964,
132165,
296004,
205895,
320584,
238666,
296021,
402518,
336987,
230497,
296036,
296040,
361576,
205931,
296044,
164973,
205934,
279661,
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,
230679,
320792,
230681,
296215,
214294,
304416,
230689,
173350,
312622,
296243,
312630,
222522,
296253,
222525,
296255,
312639,
230718,
296259,
378181,
296262,
230727,
238919,
296264,
320840,
296267,
296271,
222545,
230739,
312663,
222556,
337244,
230752,
312676,
230760,
173418,
148843,
410987,
230763,
230768,
296305,
312692,
230773,
304505,
304506,
181626,
181631,
148865,
312711,
312712,
296331,
288140,
288144,
230800,
304533,
288154,
337306,
288160,
173472,
288162,
288164,
279975,
304555,
370092,
279983,
173488,
288176,
279985,
312755,
296373,
312759,
337335,
288185,
279991,
222652,
312766,
173507,
296389,
222665,
230860,
312783,
288208,
230865,
148946,
370130,
222676,
288210,
288212,
288214,
239064,
329177,
288218,
280021,
288220,
288217,
239070,
280027,
288224,
370146,
288226,
280036,
288229,
280038,
288230,
288232,
320998,
288234,
280034,
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,
370272,
181854,
239202,
370279,
312938,
280183,
280185,
280188,
280191,
116354,
280194,
280208,
280211,
288408,
280218,
280222,
419489,
190118,
198310,
321195,
296622,
321200,
337585,
296626,
296634,
296637,
419522,
313027,
280260,
419525,
206536,
280264,
206539,
206541,
206543,
263888,
313044,
280276,
321239,
280283,
313052,
18140,
288478,
313055,
419555,
321252,
313066,
288494,
280302,
280304,
313073,
321266,
419570,
288499,
288502,
280314,
288510,
124671,
67330,
280324,
198405,
288519,
280331,
198416,
280337,
296723,
116503,
321304,
329498,
296731,
321311,
313121,
313123,
304932,
321316,
280363,
141101,
165678,
280375,
321336,
296767,
288576,
345921,
337732,
280388,
304968,
280393,
280402,
173907,
313171,
313176,
280419,
321381,
296809,
296812,
313201,
1920,
255873,
305028,
280454,
247688,
280464,
124817,
280468,
239510,
280473,
124827,
214940,
247709,
214944,
280487,
313258,
321458,
296883,
124853,
214966,
296890,
10170,
288700,
296894,
190403,
296900,
280515,
337862,
165831,
280521,
231379,
296921,
354265,
354270,
239586,
313320,
354281,
231404,
124913,
165876,
321528,
239612,
313340,
288764,
239617,
313347,
288773,
313358,
305176,
313371,
354338,
305191,
223273,
313386,
354348,
124978,
215090,
124980,
288824,
288826,
321595,
378941,
313406,
288831,
288836,
67654,
280651,
354382,
288848,
280658,
215123,
354390,
288855,
288859,
280669,
313438,
149599,
280671,
149601,
321634,
149603,
223327,
329830,
280681,
313451,
223341,
280687,
149618,
215154,
313458,
280691,
313464,
329850,
321659,
280702,
288895,
321670,
215175,
141446,
288909,
141455,
275606,
141459,
280725,
313498,
100520,
288936,
280747,
288940,
288947,
280755,
321717,
280759,
280764,
280769,
280771,
280774,
280776,
313548,
321740,
280783,
280786,
280788,
313557,
280793,
280796,
280798,
338147,
280804,
280807,
157930,
280811,
280817,
125171,
157940,
182517,
280823,
280825,
280827,
280830,
280831,
280833,
125187,
280835,
125191,
125207,
125209,
321817,
125218,
321842,
223539,
125239,
305464,
280888,
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,
166378,
305647,
281075,
174580,
240124,
281084,
305662,
305664,
240129,
305666,
305668,
223749,
330244,
240132,
223752,
150025,
338440,
281095,
223757,
281102,
223763,
223765,
281113,
322074,
281116,
281121,
182819,
281127,
150066,
158262,
158266,
289342,
281154,
322115,
158283,
281163,
281179,
338528,
338532,
281190,
199273,
281196,
19053,
158317,
313973,
297594,
281210,
158347,
264845,
182926,
133776,
182929,
314003,
117398,
314007,
289436,
174754,
330404,
289448,
133801,
174764,
314029,
314033,
240309,
133817,
314045,
314047,
314051,
199364,
297671,
158409,
256716,
289493,
363234,
289513,
289522,
289525,
289532,
322303,
289537,
322310,
264969,
322314,
322318,
281361,
281372,
322341,
215850,
281388,
289593,
281401,
289601,
281410,
281413,
281414,
240458,
281420,
240468,
281430,
322393,
297818,
281435,
281438,
281442,
174955,
224110,
207733,
207737,
158596,
183172,
338823,
322440,
314249,
240519,
183184,
142226,
289687,
240535,
224151,
297883,
289694,
289696,
289700,
289712,
281529,
289724,
52163,
183260,
420829,
281567,
289762,
322534,
297961,
183277,
322550,
134142,
322563,
314372,
330764,
175134,
322599,
322610,
314421,
281654,
314427,
314433,
207937,
314441,
207949,
322642,
314456,
281691,
314461,
281702,
281704,
314474,
281708,
281711,
248995,
306341,
306344,
306347,
322734,
306354,
142531,
199877,
289991,
306377,
289997,
249045,
363742,
363745,
298216,
330988,
126190,
216303,
322801,
388350,
257302,
363802,
199976,
199978,
314671,
298292,
298294,
257334,
216376,
380226,
298306,
224584,
224587,
224594,
216404,
306517,
150870,
314714,
224603,
159068,
314718,
265568,
314723,
281960,
150890,
306539,
314732,
314736,
290161,
216436,
306549,
298358,
314743,
306552,
290171,
314747,
306555,
298365,
290174,
224641,
281987,
298372,
314756,
281990,
224647,
265604,
298377,
314763,
142733,
298381,
314768,
224657,
306581,
314773,
314779,
314785,
314793,
282025,
282027,
241068,
241070,
241072,
282034,
241077,
150966,
298424,
306618,
282044,
323015,
306635,
306640,
290263,
290270,
290275,
339431,
282089,
191985,
282098,
290291,
282101,
241142,
191992,
290298,
151036,
290302,
282111,
290305,
175621,
306694,
192008,
323084,
257550,
290321,
282130,
323090,
290325,
282133,
241175,
290328,
282137,
290332,
241181,
282142,
282144,
290344,
306731,
290349,
290351,
290356,
28219,
282186,
224849,
282195,
282199,
282201,
306778,
159324,
159330,
314979,
298598,
323176,
224875,
241260,
323181,
257658,
315016,
282249,
290445,
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,
282337,
216801,
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,
282481,
110450,
315251,
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,
290739,
241588,
282547,
241590,
241592,
241598,
290751,
241600,
241605,
151495,
241610,
298975,
241632,
298984,
241640,
241643,
298988,
241646,
241649,
241652,
323574,
290807,
299003,
241661,
299006,
282623,
315396,
241669,
315397,
282632,
307211,
282639,
290835,
282645,
241693,
282654,
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,
299191,
307385,
307386,
258235,
307388,
176311,
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,
291226,
242075,
283033,
61855,
291231,
283042,
291238,
291241,
127403,
127405,
291247,
299440,
127407,
299444,
127413,
291254,
283062,
127417,
291260,
127421,
127424,
299457,
127429,
127431,
127434,
315856,
127440,
176592,
315860,
176597,
283095,
127447,
299481,
127449,
176605,
242143,
127455,
127457,
291299,
340454,
127463,
242152,
291305,
127466,
176620,
127469,
127474,
291314,
291317,
127480,
135672,
291323,
233979,
127485,
291330,
127490,
127494,
283142,
127497,
233994,
135689,
127500,
291341,
233998,
127506,
234003,
127509,
234006,
127511,
152087,
283161,
242202,
234010,
135707,
135710,
242206,
242208,
291361,
242220,
291378,
152118,
234038,
234041,
315961,
70213,
242250,
111193,
242275,
299620,
242279,
168562,
184952,
135805,
135808,
291456,
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,
234246,
226056,
291593,
234248,
242443,
234252,
242445,
234254,
291601,
234258,
242450,
242452,
234261,
348950,
201496,
234264,
234266,
234269,
283421,
234272,
234274,
152355,
299814,
234278,
283432,
234281,
234284,
234287,
283440,
185138,
242483,
234292,
234296,
234298,
160572,
283452,
234302,
234307,
242499,
234309,
316233,
234313,
316235,
234316,
283468,
234319,
242511,
234321,
234324,
185173,
201557,
234329,
234333,
308063,
234336,
242530,
349027,
234338,
234341,
234344,
234347,
177004,
234350,
324464,
234353,
152435,
177011,
234356,
234358,
234362,
234364,
291711,
234368,
291714,
234370,
291716,
234373,
316294,
201603,
234375,
308105,
324490,
226185,
234379,
226182,
234384,
234388,
234390,
324504,
234393,
209818,
308123,
234396,
324508,
291742,
226200,
234398,
234401,
291747,
291748,
234405,
291750,
324518,
324520,
234407,
324522,
234410,
291756,
291754,
226220,
324527,
291760,
234417,
201650,
324531,
234414,
234422,
226230,
324536,
275384,
234428,
291773,
242623,
324544,
234431,
234434,
324546,
324548,
234437,
226239,
226245,
234439,
234443,
291788,
234446,
193486,
193488,
234449,
316370,
275406,
234452,
234455,
234459,
234461,
234464,
234467,
234470,
168935,
5096,
324585,
234475,
234478,
316400,
234481,
316403,
234484,
234485,
234487,
324599,
234490,
234493,
316416,
234496,
308226,
234501,
308231,
234504,
234507,
234510,
234515,
300054,
316439,
234520,
234519,
234523,
234526,
234528,
300066,
234532,
300069,
234535,
234537,
234540,
234543,
234546,
275508,
300085,
234549,
300088,
234553,
234556,
234558,
316479,
234561,
316483,
160835,
234563,
308291,
234568,
234570,
316491,
234572,
300108,
234574,
300115,
234580,
234581,
234585,
275545,
242777,
234590,
234593,
234595,
234597,
300133,
234601,
300139,
234605,
160879,
234607,
275569,
234610,
316530,
300148,
234614,
398455,
144506,
234618,
234620,
275579,
234623,
226433,
234627,
275588,
234629,
242822,
234634,
234636,
177293,
234640,
275602,
234643,
308373,
324757,
234647,
226453,
275608,
234650,
308379,
234648,
300189,
324766,
119967,
234653,
324768,
234657,
283805,
242852,
300197,
234661,
283813,
234664,
177318,
275626,
234667,
316596,
308414,
234687,
300223,
300226,
308418,
234692,
300229,
308420,
308422,
283844,
300234,
283850,
300238,
300241,
316625,
300243,
300245,
316630,
300248,
300253,
300256,
300258,
300260,
234726,
300263,
300265,
300267,
161003,
300270,
300272,
120053,
300278,
275703,
316663,
300284,
275710,
300287,
292097,
300289,
161027,
300292,
300294,
275719,
234760,
177419,
300299,
242957,
300301,
349451,
177424,
275725,
283917,
349464,
415009,
283939,
259367,
292143,
283951,
300344,
226617,
243003,
283963,
226628,
300357,
283973,
177482,
283983,
316758,
357722,
316766,
316768,
292192,
218464,
292197,
316774,
243046,
218473,
284010,
136562,
324978,
333178,
275834,
275836,
275840,
316803,
316806,
226696,
316811,
226699,
316814,
226703,
300433,
234899,
300436,
226709,
357783,
316824,
316826,
300448,
144807,
144810,
144812,
284076,
144814,
227426,
144820,
374196,
284084,
292279,
284087,
144826,
144828,
144830,
144832,
227430,
144835,
144837,
38342,
144839,
144841,
144844,
144847,
144852,
144855,
103899,
300507,
333280,
218597,
292329,
300523,
259565,
300527,
308720,
259567,
292338,
226802,
316917,
292343,
308727,
300537,
316933,
316947,
308757,
308762,
284191,
316959,
284194,
284196,
235045,
284199,
284204,
284206,
284209,
284211,
194101,
284213,
316983,
194103,
284215,
308790,
284218,
226877,
292414,
284223,
284226,
284228,
243268,
292421,
284231,
226886,
128584,
284234,
366155,
317004,
276043,
284238,
226895,
284241,
194130,
284243,
300628,
284245,
292433,
284247,
317015,
235097,
243290,
284249,
276053,
284253,
300638,
284251,
284255,
243293,
284258,
292452,
292454,
284263,
177766,
284265,
292458,
284267,
292461,
284272,
284274,
284278,
292470,
276086,
292473,
284283,
276093,
284286,
292479,
284288,
292481,
284290,
325250,
284292,
292485,
325251,
276095,
276098,
284297,
317066,
284299,
317068,
284301,
276109,
284303,
284306,
276114,
284308,
284312,
284314,
284316,
276127,
284320,
284322,
284327,
284329,
317098,
284331,
276137,
284333,
284335,
276144,
284337,
284339,
300726,
284343,
284346,
284350,
358080,
276160,
284354,
358083,
284358,
276166,
358089,
284362,
276170,
284365,
276175,
284368,
276177,
284370,
358098,
284372,
317138,
284377,
284379,
284381,
284384,
358114,
284386,
358116,
276197,
317158,
358119,
284392,
325353,
358122,
284394,
284397,
358126,
276206,
358128,
284399,
358133,
358135,
276216,
358138,
300795,
358140,
284413,
358142,
358146,
317187,
284418,
317189,
317191,
284428,
300816,
300819,
317207,
284440,
300828,
300830,
276255,
300832,
325408,
300834,
317221,
227109,
358183,
186151,
276268,
300845,
243504,
300850,
284469,
276280,
325436,
358206,
276291,
366406,
276295,
300872,
292681,
153417,
358224,
284499,
276308,
284502,
317271,
178006,
276315,
292700,
317279,
284511,
227175,
292715,
300912,
292721,
284529,
300915,
284533,
292729,
317306,
284540,
292734,
325512,
169868,
276365,
317332,
358292,
284564,
399252,
284566,
350106,
284572,
276386,
284579,
276388,
358312,
317353,
284585,
276395,
292776,
292784,
276402,
358326,
161718,
358330,
276411,
276418,
276425,
301009,
301011,
301013,
292823,
358360,
301017,
301015,
292828,
276446,
153568,
276448,
276452,
292839,
276455,
350186,
292843,
276460,
292845,
178161,
227314,
276466,
325624,
276472,
350200,
317435,
276476,
276479,
350210,
276482,
178181,
317446,
276485,
350218,
276490,
292876,
350222,
317456,
276496,
317458,
178195,
243733,
243740,
317468,
317472,
325666,
243751,
292904,
178224,
276528,
243762,
309298,
325685,
325689,
235579,
325692,
235581,
178238,
276539,
276544,
243779,
325700,
284739,
292934,
243785,
276553,
350293,
350295,
309337,
194649,
350299,
227418,
350302,
194654,
350304,
178273,
309346,
227423,
194660,
350308,
309350,
309348,
292968,
309352,
309354,
301163,
350313,
350316,
276583,
301167,
276586,
350321,
276590,
227440,
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,
153765,
284837,
350375,
350379,
350381,
350383,
129200,
350385,
350387,
350389,
350395,
350397,
350399,
227520,
350402,
227522,
301252,
350406,
227529,
301258,
309450,
276685,
309455,
276689,
309462,
301272,
276699,
194780,
309468,
309471,
301283,
317672,
317674,
325867,
243948,
194801,
309491,
227571,
309494,
243960,
227583,
276735,
276739,
211204,
276742,
227596,
325910,
309530,
342298,
211232,
317729,
276775,
211241,
325937,
325943,
211260,
260421,
276809,
285002,
276811,
235853,
276816,
235858,
276829,
276833,
391523,
276836,
293227,
276843,
293232,
276848,
186744,
211324,
227709,
285061,
366983,
317833,
178572,
285070,
285077,
178583,
227738,
317853,
276896,
317858,
342434,
285093,
317864,
285098,
276907,
235955,
276917,
293304,
293307,
293314,
309707,
293325,
129486,
317910,
293336,
235996,
317917,
293343,
358880,
276961,
293346,
276964,
293352,
236013,
293364,
301562,
293370,
317951,
309764,
301575,
121352,
293387,
236043,
342541,
317963,
113167,
55822,
309779,
317971,
309781,
277011,
55837,
227877,
227879,
293417,
227882,
309804,
293421,
105007,
236082,
285236,
23094,
277054,
244288,
219714,
129603,
301636,
318020,
301639,
301643,
285265,
399955,
309844,
277080,
309849,
285277,
285282,
326244,
318055,
277100,
309871,
121458,
277106,
170618,
170619,
309885,
309888,
277122,
227975,
277128,
285320,
301706,
318092,
326285,
334476,
318094,
277136,
277139,
227992,
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,
342749,
113378,
203491,
228069,
277223,
342760,
285417,
56041,
56043,
56045,
277232,
228081,
56059,
310015,
285441,
310020,
310029,
228113,
285459,
277273,
293659,
326430,
228128,
285474,
293666,
228135,
318248,
277291,
318253,
293677,
285489,
301876,
293685,
285494,
301880,
285499,
301884,
293696,
310080,
277317,
293706,
277322,
277329,
162643,
310100,
301911,
277337,
301913,
301921,
400236,
236397,
162671,
326514,
310134,
236408,
15224,
277368,
416639,
416640,
113538,
310147,
416648,
39817,
187274,
277385,
301972,
424853,
277405,
277411,
310179,
293798,
293802,
236460,
277426,
293811,
276579,
293817,
293820,
203715,
326603,
342994,
293849,
293861,
228327,
228328,
318442,
228332,
326638,
277486,
351217,
318450,
293876,
293877,
285686,
302073,
121850,
293882,
302075,
244731,
285690,
293887,
277504,
277507,
277511,
293899,
277519,
293908,
302105,
293917,
293939,
318516,
277561,
277564,
310336,
7232,
293956,
277573,
228422,
293960,
310344,
277577,
277583,
203857,
293971,
310355,
310359,
236632,
277594,
138332,
277598,
203872,
285792,
277601,
310374,
203879,
310376,
228460,
318573,
203886,
187509,
285815,
367737,
285817,
302205,
285821,
392326,
253064,
294026,
302218,
285835,
162964,
384148,
187542,
302231,
285849,
302233,
285852,
302237,
285854,
285856,
302241,
285862,
277671,
302248,
64682,
277678,
294063,
294065,
302258,
277687,
294072,
318651,
294076,
277695,
318657,
244930,
302275,
130244,
302277,
228550,
302282,
310476,
302285,
302288,
310481,
302290,
203987,
302292,
302294,
310486,
302296,
384222,
310498,
285927,
318698,
302315,
228592,
294132,
138485,
228601,
204026,
228606,
204031,
64768,
310531,
138505,
228617,
318742,
204067,
277798,
130345,
277801,
113964,
285997,
384302,
285999,
277804,
113969,
277807,
277811,
318773,
318776,
277816,
286010,
277819,
294204,
417086,
277822,
302403,
294211,
384328,
277832,
277836,
294221,
146765,
294223,
326991,
277839,
277842,
277847,
277850,
179547,
277853,
146784,
277857,
302436,
277860,
294246,
327015,
310632,
327017,
351594,
277864,
277869,
277872,
351607,
310648,
277880,
310651,
277884,
277888,
310657,
351619,
294276,
310659,
327046,
277892,
253320,
310665,
318858,
277894,
277898,
277903,
310672,
351633,
277905,
277908,
277917,
310689,
277921,
130468,
228776,
277928,
277932,
310703,
277937,
310710,
130486,
310712,
277944,
310715,
277947,
302526,
228799,
277950,
277953,
302534,
310727,
245191,
64966,
277959,
277963,
302541,
277966,
302543,
310737,
277971,
228825,
163290,
277978,
310749,
277981,
277984,
310755,
277989,
277991,
187880,
277995,
310764,
286188,
278000,
228851,
310772,
278003,
278006,
40440,
212472,
278009,
40443,
286203,
310780,
40448,
228864,
286214,
228871,
302603,
302614,
302617,
286233,
302621,
286240,
146977,
187936,
187939,
40484,
294435,
40486,
286246,
294440,
40488,
294439,
294443,
40491,
294445,
245288,
310831,
286248,
40499,
40502,
212538,
40507,
40511,
40513,
228933,
327240,
40521,
286283,
40525,
40527,
212560,
400976,
228944,
40533,
147032,
40537,
40539,
40541,
278109,
40544,
40548,
40550,
40552,
286312,
40554,
286313,
310892,
40557,
40560,
188022,
122488,
294521,
343679,
294537,
310925,
286354,
278163,
302740,
122517,
278168,
179870,
327333,
229030,
212648,
302764,
278188,
278192,
319153,
278196,
302781,
319171,
302789,
294599,
278216,
294601,
302793,
343757,
212690,
319187,
286420,
278227,
229076,
286425,
319194,
278235,
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,
188252,
237409,
229233,
294776,
360317,
294785,
327554,
360322,
40840,
40851,
294803,
188312,
294811,
237470,
319390,
40865,
319394,
294817,
294821,
311209,
180142,
343983,
294831,
188340,
40886,
319419,
294844,
294847,
237508,
393177,
294876,
294879,
294883,
393190,
294890,
311279,
278513,
237555,
311283,
278516,
278519,
237562
] |
7135dab6801fe1738fa625bdd650b149be4711d8
|
a31232cf051eb292b75ad2c25d908c1526b375d6
|
/ximalaya_swift_demo/ximalaya_swift_demo/ViewController.swift
|
772145ffef196320901db9a2488a9debeb87e1e3
|
[] |
no_license
|
zhangting360/ximalaya
|
bf23c240d911a6198d755a9cc0d102b4da3bc31b
|
aaaf72c6f41bc9a77fdbd099cab56be4d340c3c2
|
refs/heads/master
| 2021-01-01T06:30:52.504504 | 2017-07-17T07:15:25 | 2017-07-17T07:15:25 | 97,446,063 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 514 |
swift
|
//
// ViewController.swift
// ximalaya_swift_demo
//
// Created by 张挺 on 2017/7/17.
// Copyright © 2017年 zhangting. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
|
[
279046,
309264,
279064,
295460,
286249,
197677,
300089,
226878,
277057,
288321,
286786,
300107,
288332,
278606,
212561,
300116,
300629,
276054,
237655,
200802,
286314,
164974,
284276,
284277,
294518,
314996,
284287,
278657,
281218,
284289,
281221,
284293,
284298,
303242,
311437,
227984,
303760,
278675,
226454,
226455,
226456,
226458,
278686,
284323,
278693,
284328,
284336,
280760,
277180,
283839,
280772,
228551,
280775,
298189,
290004,
284373,
290006,
189655,
226009,
298202,
298204,
280797,
298207,
278752,
290016,
298211,
290020,
284391,
280808,
234223,
358127,
312049,
286963,
289524,
280821,
226038,
286965,
333048,
288501,
358139,
280832,
230147,
358147,
278791,
299786,
300817,
278298,
287005,
287007,
295711,
281380,
152356,
315177,
130346,
282922,
289578,
312107,
282926,
113972,
159541,
289596,
283453,
289600,
283461,
234829,
298830,
279380,
295766,
279386,
298843,
241499,
308064,
200549,
227688,
296811,
162672,
216433,
199024,
290166,
292730,
333179,
290175,
224643,
313733,
183173,
304012,
304015,
300432,
310673,
275358,
289697,
284586,
276396,
277420,
277422,
279982,
286126,
297903,
305582,
230323,
277429,
277430,
277432,
277433,
277434,
278973,
291774,
295874,
296901,
298951,
280015,
292824,
280029,
286175,
286189,
183278,
298989,
237556,
292341,
290299,
286204,
290303
] |
4d17590c540e037610cb4c5748b1ed998cb79829
|
08b3c1022e0078eb211c02597ac80700870150a7
|
/Tests/RealmEndpointTests/RealmArrayEndpointTests.swift
|
c2e28e553f660cbb3c9ffdb4fbf33a57e8612aaf
|
[
"MIT"
] |
permissive
|
OakCityLabs/RealmEndpoint
|
4315c78bd276aa39a664f1fa19bb514349d0c587
|
4d72ba129373eafd3d590c094bc7bc52dd0e2e21
|
refs/heads/master
| 2022-06-27T18:19:07.595761 | 2020-05-05T18:17:20 | 2020-05-05T18:17:20 | 219,828,206 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,233 |
swift
|
//
// RealmArrayEndpointTests.swift
// RealmEndpointTests
//
// Created by Jay Lyerly on 11/5/19.
// Copyright © 2019 Oak City Labs. All rights reserved.
//
import RealmEndpoint
import RealmSwift
import XCTest
class RealmArrayEndpointTests: XCTestCase {
var realm: Realm!
var config: Realm.Configuration!
let serverUrl = URL(string: "http://oakcity.io/api")!
override func setUp() {
super.setUp()
config = Realm.Configuration(inMemoryIdentifier: UUID().uuidString)
realm = try! Realm(configuration: config)
}
override func tearDown() {
config = nil
realm = nil
super.tearDown()
}
func testParse() {
let endpoint = RealmArrayEndpoint<User>(realmConfig: config,
serverUrl: serverUrl,
pathPrefix: "")
let data = User.sampleJsonListData!
XCTAssertEqual(realm.objects(User.self).count, 0)
XCTAssertEqual(endpoint.results?.count, 0)
// parse and check the returned object
do {
let users = try! endpoint.parse(data: data)
XCTAssertEqual(users.count, 3)
XCTAssertEqual(users[0].firstName, "Conner")
XCTAssertEqual(users[1].firstName, "Barry")
XCTAssertEqual(users[2].firstName, "Wally")
}
// check the User objects in realm
do {
let users = realm.objects(User.self)
XCTAssertEqual(users.count, 3)
let user = users.first!
XCTAssertEqual(user.firstName, "Conner")
XCTAssertEqual(user.lastName, "Kent")
XCTAssertEqual(user.objId, "949-456")
}
// check the results object
do {
XCTAssertNotNil(endpoint.results)
let users = endpoint.results!
XCTAssertEqual(users.count, 3)
XCTAssertEqual(users[0].firstName, "Conner")
XCTAssertEqual(users[0].lastName, "Kent")
XCTAssertEqual(users[0].objId, "949-456")
XCTAssertEqual(users[1].firstName, "Barry")
XCTAssertEqual(users[1].lastName, "Allen")
XCTAssertEqual(users[1].objId, "949-494")
XCTAssertEqual(users[2].firstName, "Wally")
XCTAssertEqual(users[2].lastName, "West")
XCTAssertEqual(users[2].objId, "949-123")
}
}
func testTag() {
try! RealmTag.create(fromTags: DataTag.allCases, in: realm)
let endpoint = RealmArrayEndpoint<User>(realmConfig: config, serverUrl: serverUrl, pathPrefix: "")
let taggedUsers = realm.objects(User.self).filter("ANY realmTags.objId = %@", DataTag.ours.objId)
// initial condition
XCTAssertEqual(realm.objects(User.self).count, 0)
try! endpoint.parse(data: User.sampleJsonListData!)
// loaded 3 users
XCTAssertEqual(realm.objects(User.self).count, 3)
// no users are tagged
XCTAssertEqual(taggedUsers.count, 0)
let taggedEndpoint = RealmArrayEndpoint<User>(realmConfig: config,
dataTags: [DataTag.ours],
serverUrl: serverUrl,
pathPrefix: "")
try! taggedEndpoint.parse(data: User.sampleJsonListData!)
// still have 3 users
XCTAssertEqual(realm.objects(User.self).count, 3)
// all three are tagged
XCTAssertEqual(taggedUsers.count, 3)
}
func testResultFactory() {
let resultsFactory: ((Realm) -> Results<User>)? = {
$0.objects(User.self).sorted(byKeyPath: #keyPath(User.firstName), ascending: true)
}
let endpoint = RealmArrayEndpoint<User>(realmConfig: config,
resultsFactory: resultsFactory,
serverUrl: serverUrl,
pathPrefix: "")
let data = User.sampleJsonListData!
XCTAssertEqual(realm.objects(User.self).count, 0)
XCTAssertEqual(endpoint.results?.count, 0)
try! endpoint.parse(data: data)
// results should be sorted by first name
XCTAssertNotNil(endpoint.results)
let users = endpoint.results!
XCTAssertEqual(users.count, 3)
XCTAssertEqual(users[0].firstName, "Barry")
XCTAssertEqual(users[0].lastName, "Allen")
XCTAssertEqual(users[0].objId, "949-494")
XCTAssertEqual(users[1].firstName, "Conner")
XCTAssertEqual(users[1].lastName, "Kent")
XCTAssertEqual(users[1].objId, "949-456")
XCTAssertEqual(users[2].firstName, "Wally")
XCTAssertEqual(users[2].lastName, "West")
XCTAssertEqual(users[2].objId, "949-123")
}
func testPostParse() {
let postParse: (([User], Realm) -> Void) = { users, realm in
for user in users {
user.firstName = String(user.firstName.reversed())
}
}
let endpoint = RealmArrayEndpoint<User>(realmConfig: config,
serverUrl: serverUrl,
pathPrefix: "",
postParse: postParse)
let data = User.sampleJsonListData!
XCTAssertEqual(realm.objects(User.self).count, 0)
XCTAssertEqual(endpoint.results?.count, 0)
try! endpoint.parse(data: data)
// results should have first name reversed
XCTAssertNotNil(endpoint.results)
let users = endpoint.results!
XCTAssertEqual(users.count, 3)
XCTAssertEqual(users[0].firstName, "rennoC")
XCTAssertEqual(users[1].firstName, "yrraB")
XCTAssertEqual(users[2].firstName, "yllaW")
}
static var allTests = [
("testParse", testParse),
("testTag", testTag),
("testResultFactory", testResultFactory),
("testPostParse", testPostParse)
]
}
|
[
-1
] |
9e0ea47aaeb95067ab435a12058ee75cf025c1ed
|
d2d33c32d0409649ba94692f73eea5156b410b0b
|
/Aklaty/ViewControllers/HomeViewController/CollectionViewCells/MenuCollectionViewCell.swift
|
6349192bd34611eeff794e20de9ab08126dba170
|
[] |
no_license
|
AmmarAliSayed/Aklaty
|
b8d6ac28a28afdff59b748b28fcd25bda3b5ff29
|
0c5b97b57d39f653ea73cc933209dcf40aa51385
|
refs/heads/main
| 2023-08-06T21:03:18.691359 | 2021-09-15T07:23:52 | 2021-09-15T07:23:52 | 406,480,970 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 752 |
swift
|
//
// MenuCollectionViewCell.swift
// Aklaty
//
// Created by Macbook on 15/07/2021.
//
import UIKit
class MenuCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var menuView: UIView!
@IBOutlet weak var menuPriceLabel: UILabel!
@IBOutlet weak var menuNameLabel: UILabel!
@IBOutlet weak var menuImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// contentView.backgroundColor = UIColor.white
contentView.layer.borderWidth = 3
contentView.layer.borderColor = UIColor.white.cgColor
contentView.layer.masksToBounds = true
contentView.clipsToBounds = true
contentView.layer.cornerRadius = 10
}
}
|
[
-1
] |
1cdc9f31560f8090afb42c74cd05991aadb14ad3
|
8c1cbee9c19712fd410044c7b28291e7f3421e2b
|
/AGAudioPlayer/UI/AGAudioPlayerViewController.swift
|
5f423c49b7c75b7ea580309c64b5025cd273190d
|
[
"MIT"
] |
permissive
|
lukeswitz/AGAudioPlayer
|
9f818b5bef50a557a85ecd819512320be0f52f41
|
0a6ec1836ee47238dd6a38c12533110a782204b2
|
refs/heads/master
| 2021-07-21T09:17:27.054696 | 2021-07-05T13:04:22 | 2021-07-05T13:04:22 | 236,539,588 | 1 | 0 |
MIT
| 2021-07-04T12:27:56 | 2020-01-27T16:44:02 |
Swift
|
UTF-8
|
Swift
| false | false | 34,026 |
swift
|
//
// AGAudioPlayerViewController.swift
// AGAudioPlayer
//
// Created by Alec Gorge on 1/19/17.
// Copyright © 2017 Alec Gorge. All rights reserved.
//
import UIKit
import QuartzCore
import MediaPlayer
import Interpolate
import MarqueeLabel
import NapySlider
public struct AGAudioPlayerColors {
let main: UIColor
let accent: UIColor
let accentWeak: UIColor
let barNothing: UIColor
let barDownloads: UIColor
let barPlaybackElapsed: UIColor
let scrubberHandle: UIColor
public init() {
let main = UIColor(red:0.149, green:0.608, blue:0.737, alpha:1)
let accent = UIColor.white
self.init(main: main, accent: accent)
}
public init(main: UIColor, accent: UIColor) {
self.main = main
self.accent = accent
accentWeak = accent.withAlphaComponent(0.7)
barNothing = accent.withAlphaComponent(0.3)
barDownloads = accent.withAlphaComponent(0.4)
barPlaybackElapsed = accent
scrubberHandle = accent
}
}
@objc public class AGAudioPlayerViewController: UIViewController {
@IBOutlet var uiPanGestureClose: VerticalPanDirectionGestureRecognizer!
@IBOutlet var uiPanGestureOpen: VerticalPanDirectionGestureRecognizer!
@IBOutlet weak var uiTable: UITableView!
@IBOutlet weak var uiHeaderView: UIView!
@IBOutlet weak var uiFooterView: UIView!
@IBOutlet weak var uiProgressDownload: UIView!
@IBOutlet weak var uiProgressDownloadCompleted: UIView!
@IBOutlet weak var uiScrubber: ScrubberBar!
@IBOutlet weak var uiProgressDownloadCompletedContraint: NSLayoutConstraint!
@IBOutlet weak var uiLabelTitle: MarqueeLabel!
@IBOutlet weak var uiLabelSubtitle: MarqueeLabel!
@IBOutlet weak var uiLabelElapsed: UILabel!
@IBOutlet weak var uiLabelDuration: UILabel!
@IBOutlet weak var uiButtonShuffle: UIButton!
@IBOutlet weak var uiButtonPrevious: UIButton!
@IBOutlet weak var uiButtonPlay: UIButton!
@IBOutlet weak var uiButtonPause: UIButton!
@IBOutlet weak var uiButtonNext: UIButton!
@IBOutlet weak var uiButtonLoop: UIButton!
@IBOutlet weak var uiButtonDots: UIButton!
@IBOutlet weak var uiButtonPlus: UIButton!
@IBOutlet weak var uiSliderVolume: MPVolumeView!
@IBOutlet weak var uiSpinnerBuffering: UIActivityIndicatorView!
@IBOutlet weak var uiButtonStack: UIStackView!
@IBOutlet weak var uiWrapperEq: UIView!
@IBOutlet weak var uiSliderEqBass: NapySlider!
@IBOutlet weak var uiConstraintTopTitleSpace: NSLayoutConstraint!
@IBOutlet weak var uiConstraintSpaceBetweenPlayers: NSLayoutConstraint!
@IBOutlet weak var uiConstraintBottomBarHeight: NSLayoutConstraint!
// mini player
@IBOutlet weak var uiMiniPlayerContainerView: UIView!
public var barHeight : CGFloat {
get {
if let c = uiMiniPlayerContainerView {
let extra: CGFloat = UIApplication.shared.keyWindow!.rootViewController!.view.safeAreaInsets.bottom
return c.bounds.height + extra
}
return 64.0
}
}
@IBOutlet weak var uiMiniPlayerTopOffsetConstraint: NSLayoutConstraint!
@IBOutlet weak var uiMiniProgressDownloadCompletedView: UIView!
@IBOutlet weak var uiMiniProgressDownloadCompletedConstraint: NSLayoutConstraint!
@IBOutlet weak var uiMiniProgressPlayback: UIProgressView!
@IBOutlet weak var uiMiniButtonPlay: UIButton!
@IBOutlet weak var uiMiniButtonPause: UIButton!
@IBOutlet weak var uiMiniLabelTitle: MarqueeLabel!
@IBOutlet weak var uiMiniLabelSubtitle: MarqueeLabel!
@IBOutlet weak var uiMiniButtonStack: UIStackView!
@IBOutlet public weak var uiMiniButtonDots: UIButton!
@IBOutlet weak var uiMiniButtonPlus: UIButton!
@IBOutlet weak var uiMiniSpinnerBuffering: UIActivityIndicatorView!
// end mini player
public var presentationDelegate: AGAudioPlayerViewControllerPresentationDelegate? = nil
public var cellDataSource: AGAudioPlayerViewControllerCellDataSource? = nil
public var delegate: AGAudioPlayerViewControllerDelegate? = nil
public var shouldPublishToNowPlayingCenter: Bool = true
var remoteCommandManager : RemoteCommandManager? = nil
var dismissInteractor: DismissInteractor = DismissInteractor()
var openInteractor: OpenInteractor = OpenInteractor()
// colors
var colors = AGAudioPlayerColors()
// constants
let SectionQueue = 0
// bouncy header
var headerInterpolate: Interpolate?
var interpolateBlock: ((_ scale: Double) -> Void)?
// swipe to dismiss
static let defaultTransitionDelegate = AGAudioPlayerViewControllerTransitioningDelegate()
// non-jumpy seeking
var isCurrentlyScrubbing = false
// for delegate notifications
var lastSeenProgress: Float? = nil
let player: AGAudioPlayer
@objc required public init(player: AGAudioPlayer) {
self.player = player
let bundle = Bundle(path: Bundle(for: AGAudioPlayerViewController.self).path(forResource: "AGAudioPlayer", ofType: "bundle")!)
super.init(nibName: String(describing: AGAudioPlayerViewController.self), bundle: bundle)
self.transitioningDelegate = AGAudioPlayerViewController.defaultTransitionDelegate
setupPlayer()
dismissInteractor.viewController = self
openInteractor.viewController = self
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override public func viewDidLoad() {
super.viewDidLoad()
uiMiniButtonStack.removeArrangedSubview(uiMiniButtonPlus)
uiMiniButtonPlus.isHidden = true
uiButtonPlus.alpha = 0.0
setupTable()
setupColors()
setupPlayerUiActions()
}
override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
setupStretchyHeader()
self.view.layoutIfNeeded()
viewWillAppear_StretchyHeader()
viewWillAppear_Table()
updateUI()
uiSliderVolume.isHidden = false
}
public override func viewDidDisappear(_ animated: Bool) {
uiSliderVolume.isHidden = true
}
}
extension AGAudioPlayerViewController : UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
let pt = touch.location(in: uiHeaderView)
return uiHeaderView.frame.contains(pt);
}
}
extension AGAudioPlayerViewController : AGAudioPlayerDelegate {
func setupPlayer() {
player.delegate = self
player.prepareAudioSession()
publishToNowPlayingCenter()
}
public func audioPlayerAudioSessionSetUp(_ audioPlayer: AGAudioPlayer) {
remoteCommandManager = RemoteCommandManager(player: audioPlayer)
remoteCommandManager?.activatePlaybackCommands(true)
}
func updateUI() {
updatePlayPauseButtons()
updateShuffleLoopButtons()
updateNonTimeLabels()
updateTimeLabels()
updatePlaybackProgress()
updatePreviousNextButtons()
}
func updatePlayPauseButtons() {
guard uiButtonPause != nil, uiButtonPlay != nil,
uiMiniButtonPause != nil, uiMiniButtonPlay != nil,
uiSpinnerBuffering != nil, uiMiniSpinnerBuffering != nil else {
return
}
if player.isBuffering {
uiButtonPause.isHidden = true
uiButtonPlay.isHidden = true
uiMiniButtonPause.isHidden = true
uiMiniButtonPlay.isHidden = true
uiMiniSpinnerBuffering.isHidden = false
uiSpinnerBuffering.isHidden = false
return
}
uiMiniSpinnerBuffering.isHidden = true
uiSpinnerBuffering.isHidden = true
uiButtonPause.isHidden = !player.isPlaying && !player.isBuffering
uiButtonPlay.isHidden = player.isPlaying
uiMiniButtonPause.isHidden = uiButtonPause.isHidden
uiMiniButtonPlay.isHidden = uiButtonPlay.isHidden
}
func updatePreviousNextButtons() {
guard uiButtonPrevious != nil, uiButtonNext != nil else {
return
}
uiButtonPrevious.isEnabled = !player.isPlayingFirstItem
uiButtonNext.isEnabled = !player.isPlayingLastItem
}
func updateShuffleLoopButtons() {
guard uiButtonShuffle != nil, uiButtonLoop != nil else {
return
}
uiButtonLoop.alpha = player.loopItem ? 1.0 : 0.7
uiButtonShuffle.alpha = player.shuffle ? 1.0 : 0.7
}
func updateNonTimeLabels() {
guard uiLabelTitle != nil, uiLabelSubtitle != nil, uiMiniLabelTitle != nil, uiLabelSubtitle != nil else {
return
}
if let cur = player.currentItem {
uiLabelTitle.text = cur.displayText
uiLabelSubtitle.text = cur.displaySubtext
uiMiniLabelTitle.text = cur.displayText
uiMiniLabelSubtitle.text = cur.displaySubtext
}
else {
uiLabelTitle.text = " "
uiLabelSubtitle.text = " "
uiMiniLabelTitle.text = " "
uiMiniLabelSubtitle.text = " "
}
}
func updateTimeLabels() {
guard uiLabelElapsed != nil, uiLabelDuration != nil else {
return
}
if player.duration == 0.0 {
uiLabelElapsed.text = " "
uiLabelDuration.text = " "
}
else {
uiLabelElapsed.text = player.elapsed.formatted()
uiLabelDuration.text = player.duration.formatted()
}
}
func updatePlaybackProgress() {
guard uiScrubber != nil, uiMiniProgressPlayback != nil else {
return
}
if !isCurrentlyScrubbing {
let floatProgress = Float(player.percentElapsed)
uiScrubber.setProgress(progress: floatProgress)
uiMiniProgressPlayback.progress = floatProgress
updateTimeLabels()
// send this delegate once when it goes past 50%
if let lastProgress = lastSeenProgress, lastProgress < 0.5, floatProgress >= 0.5, let item = player.currentItem {
delegate?.audioPlayerViewController(self, passedHalfWayFor: item)
}
lastSeenProgress = floatProgress
}
}
func updateDownloadProgress(pct: Double) {
guard uiProgressDownloadCompletedContraint != nil, uiMiniProgressDownloadCompletedConstraint != nil else {
return
}
var p = pct
if p > 0.98 {
p = 1.0
}
uiProgressDownloadCompletedContraint = uiProgressDownloadCompletedContraint.setMultiplier(multiplier: CGFloat(p))
uiProgressDownload.layoutIfNeeded()
uiMiniProgressDownloadCompletedConstraint = uiMiniProgressDownloadCompletedConstraint.setMultiplier(multiplier: CGFloat(p))
uiMiniPlayerContainerView.layoutIfNeeded()
uiMiniProgressDownloadCompletedView.isHidden = p == 0.0
}
public func audioPlayer(_ audioPlayer: AGAudioPlayer, uiNeedsRedrawFor reason: AGAudioPlayerRedrawReason) {
publishToNowPlayingCenter()
switch reason {
case .buffering, .playing:
updatePlayPauseButtons()
delegate?.audioPlayerViewController(self, trackChangedState: player.currentItem)
uiTable.reloadData()
case .stopped:
uiLabelTitle.text = ""
uiLabelSubtitle.text = ""
uiMiniLabelTitle.text = ""
uiMiniLabelSubtitle.text = ""
fallthrough
case .paused, .error:
updatePlayPauseButtons()
delegate?.audioPlayerViewController(self, trackChangedState: player.currentItem)
uiTable.reloadData()
case .trackChanged:
updatePreviousNextButtons()
updateNonTimeLabels()
updateTimeLabels()
uiTable.reloadData()
delegate?.audioPlayerViewController(self, changedTrackTo: player.currentItem)
case .queueChanged:
uiTable.reloadData()
default:
break
}
self.scrollQueueToPlayingTrack()
}
public func audioPlayer(_ audioPlayer: AGAudioPlayer, errorRaised error: Error, for url: URL) {
print("CRAP")
print(error)
print(url)
publishToNowPlayingCenter()
}
public func audioPlayer(_ audioPlayer: AGAudioPlayer, downloadedBytesForActiveTrack downloadedBytes: UInt64, totalBytes: UInt64) {
guard uiProgressDownloadCompleted != nil else {
return
}
let progress = Double(downloadedBytes) / Double(totalBytes)
updateDownloadProgress(pct: progress)
}
public func audioPlayer(_ audioPlayer: AGAudioPlayer, progressChanged elapsed: TimeInterval, withTotalDuration totalDuration: TimeInterval) {
updatePlaybackProgress()
publishToNowPlayingCenter()
}
public func publishToNowPlayingCenter() {
guard shouldPublishToNowPlayingCenter else {
return
}
var nowPlayingInfo : [String : Any]? = nil
if let item = player.currentItem {
nowPlayingInfo = [
MPMediaItemPropertyMediaType : NSNumber(value: MPMediaType.music.rawValue),
MPMediaItemPropertyTitle : item.title,
MPMediaItemPropertyAlbumArtist : item.artist,
MPMediaItemPropertyArtist : item.artist,
MPMediaItemPropertyAlbumTitle : item.album,
MPMediaItemPropertyPlaybackDuration : NSNumber(value: item.duration),
MPMediaItemPropertyAlbumTrackNumber : NSNumber(value: item.trackNumber),
// MPNowPlayingInfoPropertyDefaultPlaybackRate : NSNumber(value: 1.0),
MPNowPlayingInfoPropertyElapsedPlaybackTime : NSNumber(value: player.elapsed),
MPNowPlayingInfoPropertyPlaybackProgress : NSNumber(value: Float(player.percentElapsed)),
MPNowPlayingInfoPropertyPlaybackQueueCount : NSNumber(value: player.queue.count),
MPNowPlayingInfoPropertyPlaybackQueueIndex : NSNumber(value: player.currentIndex),
MPNowPlayingInfoPropertyPlaybackRate : NSNumber(value: player.isPlaying ? 1.0 : 0.0)
]
if let albumArt = item.albumArt {
nowPlayingInfo![MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: albumArt.size, requestHandler: { (_) -> UIImage in
return albumArt
})
}
}
//print("Updating now playing info to \(nowPlayingInfo)")
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
}
}
extension AGAudioPlayerViewController : ScrubberBarDelegate {
func setupPlayerUiActions() {
uiScrubber.delegate = self
uiLabelTitle.isUserInteractionEnabled = true
uiLabelSubtitle.isUserInteractionEnabled = true
uiMiniLabelTitle.isUserInteractionEnabled = true
uiMiniLabelSubtitle.isUserInteractionEnabled = true
updateDownloadProgress(pct: 0.0)
updatePlaybackProgress()
/*
Assign in XIB as per MarqueeLabel docs
uiLabelTitle.scrollRate = 25
uiLabelTitle.trailingBuffer = 32
uiLabelTitle.animationDelay = 5
uiLabelSubtitle.scrollRate = 25
uiLabelSubtitle.trailingBuffer = 24
uiLabelSubtitle.animationDelay = 5
uiMiniLabelTitle.scrollRate = 16
uiMiniLabelTitle.trailingBuffer = 24
uiMiniLabelTitle.animationDelay = 5
uiMiniLabelSubtitle.scrollRate = 16
uiMiniLabelSubtitle.trailingBuffer = 16
uiMiniLabelSubtitle.animationDelay = 5
*/
}
public func scrubberBar(bar: ScrubberBar, didScrubToProgress: Float, finished: Bool) {
isCurrentlyScrubbing = !finished
if let elapsed = uiLabelElapsed, let mp = uiMiniProgressPlayback {
elapsed.text = TimeInterval(player.duration * Double(didScrubToProgress)).formatted()
mp.progress = didScrubToProgress
}
if finished {
player.seek(toPercent: CGFloat(didScrubToProgress))
}
}
@IBAction func uiActionToggleShuffle(_ sender: UIButton) {
player.shuffle = !player.shuffle
updateShuffleLoopButtons()
uiTable.reloadData()
updatePreviousNextButtons()
}
@IBAction func uiActionToggleLoop(_ sender: UIButton) {
player.loopItem = !player.loopItem
updateShuffleLoopButtons()
}
@IBAction func uiActionPrevious(_ sender: UIButton) {
player.backward()
}
@IBAction func uiActionPlay(_ sender: UIButton) {
player.resume()
}
@IBAction func uiActionPause(_ sender: UIButton) {
player.pause()
}
@IBAction func uiActionNext(_ sender: UIButton) {
player.forward()
}
@IBAction func uiActionDots(_ sender: UIButton) {
if let item = self.player.currentItem {
delegate?.audioPlayerViewController(self, pressedDotsForAudioItem: item)
}
}
@IBAction func uiActionPlus(_ sender: UIButton) {
if let item = self.player.currentItem {
delegate?.audioPlayerViewController(self, pressedPlusForAudioItem: item)
}
}
@IBAction func uiOpenFullUi(_ sender: UIButton) {
self.presentationDelegate?.fullPlayerRequested()
}
}
public protocol AGAudioPlayerViewControllerPresentationDelegate {
func fullPlayerRequested()
func fullPlayerDismissRequested(fromProgress: CGFloat)
func fullPlayerStartedDismissing()
func fullPlayerDismissUpdatedProgress(_ progress: CGFloat)
func fullPlayerDismissCancelled(fromProgress: CGFloat)
func fullPlayerOpenUpdatedProgress(_ progress: CGFloat)
func fullPlayerOpenCancelled(fromProgress: CGFloat)
func fullPlayerOpenRequested(fromProgress: CGFloat)
}
public protocol AGAudioPlayerViewControllerCellDataSource {
func cell(inTableView tableView: UITableView, basedOnCell cell: UITableViewCell, atIndexPath: IndexPath, forPlaybackItem playbackItem: AGAudioItem, isCurrentlyPlaying: Bool) -> UITableViewCell
func heightForCell(inTableView tableView: UITableView, atIndexPath: IndexPath, forPlaybackItem playbackItem: AGAudioItem, isCurrentlyPlaying: Bool) -> CGFloat
}
public protocol AGAudioPlayerViewControllerDelegate {
func audioPlayerViewController(_ agAudio: AGAudioPlayerViewController, trackChangedState audioItem: AGAudioItem?)
func audioPlayerViewController(_ agAudio: AGAudioPlayerViewController, changedTrackTo audioItem: AGAudioItem?)
func audioPlayerViewController(_ agAudio: AGAudioPlayerViewController, passedHalfWayFor audioItem: AGAudioItem)
func audioPlayerViewController(_ agAudio: AGAudioPlayerViewController, pressedDotsForAudioItem audioItem: AGAudioItem)
func audioPlayerViewController(_ agAudio: AGAudioPlayerViewController, pressedPlusForAudioItem audioItem: AGAudioItem)
}
extension AGAudioPlayerViewController {
public func switchToMiniPlayer(animated: Bool) {
view.layoutIfNeeded()
UIView.animate(withDuration: 0.3) {
self.switchToMiniPlayerProgress(1.0)
}
}
public func switchToFullPlayer(animated: Bool) {
view.layoutIfNeeded()
UIView.animate(withDuration: 0.3) {
self.switchToMiniPlayerProgress(0.0)
}
self.scrollQueueToPlayingTrack()
}
public func switchToMiniPlayerProgress(_ progress: CGFloat) {
let maxHeight = self.uiMiniPlayerContainerView.frame.height
self.uiMiniPlayerTopOffsetConstraint.constant = -1.0 * maxHeight * (1.0 - progress)
self.view.layoutIfNeeded()
}
}
extension AGAudioPlayerViewController {
@IBAction func handlePanToClose(_ sender: UIPanGestureRecognizer) {
let percentThreshold:CGFloat = 0.3
let inView = uiHeaderView
// convert y-position to downward pull progress (percentage)
let translation = sender.translation(in: inView)
let verticalMovement = translation.y / view.bounds.height
let downwardMovement = fmaxf(Float(verticalMovement), 0.0)
let downwardMovementPercent = fminf(downwardMovement, 1.0)
let progress = CGFloat(downwardMovementPercent)
let interactor = dismissInteractor
switch sender.state {
case .began:
uiScrubber.scrubbingEnabled = false
interactor.hasStarted = true
case .changed:
interactor.shouldFinish = progress > percentThreshold
interactor.update(progress)
case .cancelled:
uiScrubber.scrubbingEnabled = true
interactor.hasStarted = false
interactor.cancel(progress)
case .ended:
uiScrubber.scrubbingEnabled = true
interactor.hasStarted = false
if interactor.shouldFinish {
interactor.finish(progress)
}
else {
interactor.cancel(progress)
}
default:
break
}
}
@IBAction func handlePanToOpen(_ sender: UIPanGestureRecognizer) {
let percentThreshold:CGFloat = 0.15
let inView = uiMiniPlayerContainerView
// convert y-position to downward pull progress (percentage)
let translation = sender.translation(in: inView)
let verticalMovement = (-1.0 * translation.y) / view.bounds.height
let upwardMovement = fmaxf(Float(verticalMovement), 0.0)
let upwardMovementPercent = fminf(upwardMovement, 1.0)
let progress = CGFloat(upwardMovementPercent)
let interactor = openInteractor
switch sender.state {
case .began:
interactor.hasStarted = true
case .changed:
interactor.shouldFinish = progress > percentThreshold
interactor.update(progress)
case .cancelled:
interactor.hasStarted = false
interactor.cancel(progress)
case .ended:
interactor.hasStarted = false
if interactor.shouldFinish {
interactor.finish(progress)
}
else {
interactor.cancel(progress)
}
default:
break
}
}
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive press: UIPress) -> Bool {
return !isCurrentlyScrubbing
}
@IBAction func handleChevronTapped(_ sender: UIButton) {
dismissInteractor.finish(1.0)
}
}
class DismissInteractor {
var hasStarted = false
var shouldFinish = false
var viewController: AGAudioPlayerViewController? = nil
var delegate: AGAudioPlayerViewControllerPresentationDelegate? {
get {
return viewController?.presentationDelegate
}
}
public func update(_ progress: CGFloat) {
delegate?.fullPlayerDismissUpdatedProgress(progress)
}
// restore
public func cancel(_ progress: CGFloat) {
delegate?.fullPlayerDismissCancelled(fromProgress: progress)
}
// dismiss
public func finish(_ progress: CGFloat) {
delegate?.fullPlayerDismissRequested(fromProgress: progress)
}
}
class OpenInteractor : DismissInteractor {
public override func update(_ progress: CGFloat) {
delegate?.fullPlayerOpenUpdatedProgress(progress)
}
// restore
public override func cancel(_ progress: CGFloat) {
delegate?.fullPlayerOpenCancelled(fromProgress: progress)
}
// dismiss
public override func finish(_ progress: CGFloat) {
delegate?.fullPlayerOpenRequested(fromProgress: progress)
}
}
extension AGAudioPlayerViewController {
func setupStretchyHeader() {
let blk = { [weak self] (fontScale: Double) in
if let s = self {
s.uiHeaderView.transform = CGAffineTransform(scaleX: CGFloat(fontScale), y: CGFloat(fontScale))
let h = s.uiHeaderView.bounds.height * CGFloat(fontScale)
s.uiTable.scrollIndicatorInsets = UIEdgeInsets.init(top: h, left: 0, bottom: 0, right: 0)
}
}
headerInterpolate = Interpolate(from: 1.0, to: 1.3, function: BasicInterpolation.easeOut, apply: blk)
interpolateBlock = blk
let insets = UIApplication.shared.keyWindow!.rootViewController!.view.safeAreaInsets
self.uiConstraintSpaceBetweenPlayers.constant = insets.top
self.uiConstraintBottomBarHeight.constant += insets.bottom * 2
self.uiFooterView.layoutIfNeeded()
}
func viewWillAppear_StretchyHeader() {
interpolateBlock?(1.0)
let h = self.uiHeaderView.bounds.height
self.uiTable.contentInset = UIEdgeInsets.init(top: h, left: 0, bottom: 0, right: 0)
self.uiTable.contentOffset = CGPoint(x: 0, y: -h)
self.scrollQueueToPlayingTrack()
}
func scrollViewDidScroll_StretchyHeader(_ scrollView: UIScrollView) {
let y = scrollView.contentOffset.y + uiHeaderView.bounds.height
let base = view.safeAreaInsets.top
let np = CGFloat(abs(y).clamped(lower: CGFloat(base + 0), upper: CGFloat(base + 150))) / CGFloat(base + 150)
if y < 0 && headerInterpolate?.progress != np {
// headerInterpolate?.progress = np
}
}
}
extension AGAudioPlayerViewController {
func setupColors() {
applyColors(colors)
}
public func applyColors(_ colors: AGAudioPlayerColors) {
self.colors = colors
view.backgroundColor = colors.main
uiMiniPlayerContainerView.backgroundColor = colors.main
uiMiniLabelTitle.textColor = colors.accent
uiMiniLabelSubtitle.textColor = colors.accent
uiHeaderView.backgroundColor = colors.main
uiFooterView.backgroundColor = colors.main
uiLabelTitle.textColor = colors.accent
uiLabelSubtitle.textColor = colors.accent
uiLabelElapsed.textColor = colors.accentWeak
uiLabelDuration.textColor = colors.accentWeak
uiProgressDownload.backgroundColor = colors.barNothing
uiProgressDownloadCompleted.backgroundColor = colors.barDownloads
uiScrubber.elapsedColor = colors.barPlaybackElapsed
uiScrubber.dragIndicatorColor = colors.scrubberHandle
uiWrapperEq.isHidden = true
uiWrapperEq.backgroundColor = colors.main.darkenByPercentage(0.05)
uiSliderVolume.tintColor = colors.accent
/*
view.layer.masksToBounds = true
view.layer.cornerRadius = 4
*/
uiSliderEqBass.tintColor = colors.barPlaybackElapsed
uiSliderEqBass.sliderUnselectedColor = colors.barDownloads
}
public override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
extension AGAudioPlayerViewController {
func setupTable() {
uiTable.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
// uiTable.backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.size.width, height: uiHeaderView.bounds.size.height + 44 * 2))
// uiTable.backgroundView?.backgroundColor = ColorMain
uiTable.allowsSelection = true
uiTable.allowsSelectionDuringEditing = true
uiTable.allowsMultipleSelectionDuringEditing = false
uiTable.setEditing(true, animated: false)
uiTable.reloadData()
}
func viewWillAppear_Table() {
}
public func tableReloadData() {
if let t = uiTable {
t.reloadData()
}
}
}
extension AGAudioPlayerViewController : UITableViewDelegate {
/*
public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
dismissInteractor.hasStarted = true
}
*/
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
scrollViewDidScroll_StretchyHeader(scrollView)
// let progress = (scrollView.contentOffset.y - scrollView.contentOffset.y) / view.frame.size.height
//
// dismissInteractor.update(progress)
}
// public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
// dismissInteractor.hasStarted = false
//
// let progress = (scrollView.contentOffset.y - scrollView.contentOffset.y) / view.frame.size.height
//
// if progress > 0.1 {
// dismissInteractor.finish(progress)
// }
// else {
// dismissInteractor.cancel(progress)
// }
// }
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
player.currentIndex = indexPath.row
}
public func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
print("\(indexPath) deselected")
}
public func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
return indexPath.section == SectionQueue
}
public func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
if sourceIndexPath != destinationIndexPath {
player.queue.moveItem(at: sourceIndexPath.row, to: destinationIndexPath.row)
tableView.reloadData()
}
}
public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
return .delete
}
}
extension AGAudioPlayerViewController : UITableViewDataSource {
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return player.queue.count
}
public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Queue"
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
guard indexPath.row < player.queue.count else {
cell.textLabel?.text = "Error"
return cell
}
let q = player.queue.properQueue(forShuffleEnabled: player.shuffle)
let item = q[indexPath.row]
let currentlyPlaying = item.playbackGUID == player.currentItem?.playbackGUID
if let d = cellDataSource {
return d.cell(inTableView: tableView, basedOnCell: cell, atIndexPath: indexPath, forPlaybackItem: item, isCurrentlyPlaying: currentlyPlaying)
}
cell.textLabel?.text = (currentlyPlaying ? "* " : "") + item.title
return cell
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
guard indexPath.row < player.queue.count else {
return UITableView.automaticDimension
}
let q = player.queue.properQueue(forShuffleEnabled: player.shuffle)
let item = q[indexPath.row]
let currentlyPlaying = item.playbackGUID == player.currentItem?.playbackGUID
if let d = cellDataSource {
return d.heightForCell(inTableView: tableView, atIndexPath: indexPath, forPlaybackItem: item, isCurrentlyPlaying: currentlyPlaying)
}
return UITableView.automaticDimension
}
public func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
tableView.performBatchUpdates({
player.queue.removeItem(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
}, completion: nil)
}
}
fileprivate func scrollQueueToPlayingTrack() {
var itemRow = -1
let q = player.queue.properQueue(forShuffleEnabled: player.shuffle)
var curItemIndex = 0
for item in q {
if item.playbackGUID == player.currentItem?.playbackGUID {
itemRow = curItemIndex
break
}
curItemIndex += 1
}
if itemRow > -1 && itemRow < uiTable.numberOfRows(inSection: 0) {
uiTable.scrollToRow(at: IndexPath(row: max(0, itemRow-1), section: 0), at: .top, animated: true)
}
}
}
|
[
-1
] |
1c61e745018be1e86d2350a50d8e64c7c59cac29
|
8d553501363ffbfb4597b1f5ff1dc68caf1e3eda
|
/Tests/MusicXMLTests/LilyPondTests/StabatMaterTests.swift
|
77ed66885d043fc595577d886bcaac60a1b095d0
|
[
"MIT"
] |
permissive
|
dn-m/MusicXML
|
e2e2e5acd0f41833fe73b6b80050f6b8da38b768
|
bd65d614b34fb6fc842e63eca40c8cb2e975d81a
|
refs/heads/latest
| 2021-11-25T11:11:19.140292 | 2021-01-26T15:51:42 | 2021-01-26T15:51:42 | 160,274,006 | 64 | 18 |
MIT
| 2023-09-05T08:52:44 | 2018-12-04T00:49:42 |
Swift
|
UTF-8
|
Swift
| false | false | 3,699 |
swift
|
//
// StabatMaterTests.swift
// MusicXMLTests
//
// Created by James Bean on 10/9/19.
//
import MusicXML
import XCTest
import XMLCoder
class StabatMaterTests: XCTestCase {
func testWordsDirection() throws {
let xml = """
<direction placement="above">
<direction-type>
<words font-weight="bold">Largo</words>
</direction-type>
</direction>
"""
let decoded = try XMLDecoder().decode(Direction.self, from: xml.data(using: .utf8)!)
let expected = Direction(
[.words([FormattedText("Largo", printStyle: PrintStyle(font: Font(weight: .bold)))])],
placement: .above
)
XCTAssertEqual(decoded, expected)
}
func testWordsDirectionType() throws {
let xml = """
<direction-type>
<words font-weight="bold">Largo</words>
</direction-type>
"""
let decoded = try XMLDecoder().decode(DirectionType.self, from: xml.data(using: .utf8)!)
let expected = DirectionType.words(
[FormattedText("Largo", printStyle: PrintStyle(font: Font(weight: .bold)))]
)
XCTAssertEqual(decoded, expected)
}
func testWordsMultipleInDirectionType() throws {
let xml = """
<direction-type>
<words font-weight="bold">Largo</words>
<words font-weight="bold">Largo</words>
</direction-type>
"""
let decoded = try XMLDecoder().decode(DirectionType.self, from: xml.data(using: .utf8)!)
let expected = DirectionType.words(
[
FormattedText("Largo", printStyle: PrintStyle(font: Font(weight: .bold))),
FormattedText("Largo", printStyle: PrintStyle(font: Font(weight: .bold))),
]
)
XCTAssertEqual(decoded, expected)
}
func testDynamicsDirection() throws {
let xml = """
<direction placement="below">
<direction-type>
<dynamics>
<fp/>
</dynamics>
</direction-type>
<offset>3</offset>
</direction>
"""
let decoded = try XMLDecoder().decode(Direction.self, from: xml.data(using: .utf8)!)
let expected = Direction([.dynamics([Dynamics([.fp])])],
placement: .below,
offset: Offset(3))
XCTAssertEqual(decoded, expected)
}
func testDynamicsDirectionType() throws {
let xml = """
<direction-type>
<dynamics>
<fp/>
</dynamics>
</direction-type>
"""
let decoded = try XMLDecoder().decode(DirectionType.self, from: xml.data(using: .utf8)!)
let expected = DirectionType.dynamics([Dynamics([.fp])])
XCTAssertEqual(decoded, expected)
}
func testDynamicsMultipleInDirectionType() throws {
let xml = """
<direction-type>
<dynamics>
<fp/>
</dynamics>
<dynamics>
<fp/>
</dynamics>
</direction-type>
"""
let decoded = try XMLDecoder().decode(DirectionType.self, from: xml.data(using: .utf8)!)
let expected = DirectionType.dynamics([Dynamics([.fp]), Dynamics([.fp])])
XCTAssertEqual(decoded, expected)
}
func testDynamics() throws {
let xml = """
<dynamics>
<fp/>
</dynamics>
"""
let decoded = try XMLDecoder().decode(Dynamics.self, from: xml.data(using: .utf8)!)
let expected = Dynamics([.fp])
XCTAssertEqual(decoded, expected)
}
}
|
[
-1
] |
70d23bd99fb1559392d2206d08ac843df0649e1f
|
69745c409f9d9f956485394bc4d7158a96c03c0c
|
/Platform_AnimationDemo/PoqPlatform/Sources/Screens/MyProfile/Cells/SignUp/ImageTableViewCell.swift
|
1f4739a52f92aa36b507d07bfdcdc18113bffb10
|
[] |
no_license
|
balapoq/AnimationLib
|
7c1dff6f6b282e37faad43673bb1c298a39a2f77
|
989220ac39ffe06b5da0c4c7bb542590363174fb
|
refs/heads/master
| 2020-04-09T23:27:13.756489 | 2018-11-28T15:49:34 | 2018-11-28T15:49:34 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,376 |
swift
|
//
// ImageTableViewCell.swift
// Poq.iOS
//
// Created by Jun Seki on 21/04/2015.
// Copyright (c) 2015 Poq Studio. All rights reserved.
//
import UIKit
/// Table view cell containing a imageview. TODO: Make this cell a generic image view rendering cell
class ImageTableViewCell: UITableViewCell {
/// The image view that renders the card
@IBOutlet weak var cardImageView: PoqAsyncImageView?
/// Sets up the image of the card
///
/// - Parameter urlString: The url of the card image
func setUpImage(_ urlString: String?) {
guard let urlString = urlString, let url = URL(string: urlString) else {
return
}
self.cardImageView?.getImageFromURL(url, isAnimated: true, resetConstraints: true)
}
/// Prepares the cell for reuse
override func prepareForReuse() {
super.prepareForReuse()
cardImageView?.prepareForReuse()
}
}
// MARK: - MyProfileCell implements
extension ImageTableViewCell: MyProfileCell {
/// Updates the UI of the cell
///
/// - Parameters:
/// - item: The content item used to populate the cell
/// - delegate: The delegate used to make the calls resulted from the cell actions
func updateUI(_ item: MyProfileContentItem, delegate: MyProfileCellsDelegate?) {
setUpImage(item.firstInputItem.value)
}
}
|
[
-1
] |
ce165eb83c0b2fdd194c0e06e5d54fedd04cfab7
|
e98e9272d5581b9a8e0a1fdd11dd837db17363f1
|
/Swiflix/V2/Movie/Model/UpcomingDate.swift
|
cd96f0fb13dc249433152a71dc9981317c3b6502
|
[] |
no_license
|
matheusgrigoletto/codinghouse-swiflix
|
60975605f8dd819104bfd2b49a769fa2e96a673d
|
29f77e5d32f43b5b81bc451bf657459dd566cc99
|
refs/heads/develop
| 2023-03-03T04:00:01.675937 | 2021-02-10T02:17:21 | 2021-02-10T02:17:21 | 304,172,183 | 2 | 0 | null | 2021-02-06T00:45:57 | 2020-10-15T00:57:00 |
Swift
|
UTF-8
|
Swift
| false | false | 209 |
swift
|
//
// UpcomingDate.swift
// Swiflix
//
// Created by Erik Radicheski da Silva on 11/12/20.
//
import Foundation
struct UpcomingDate: Response {
let maximum: String
let minimum: String
}
|
[
-1
] |
19daaa87c100dfb3a889a6126c326342ece75bea
|
d51de8c59a440a83d1c469b5f543a823d076ee56
|
/Zenith/Zenith/UtilityClasses/UIWindowExtension.swift
|
193d098604d791f2a5bf0e178e1f049a33b827a1
|
[] |
no_license
|
SriAgrawal/ZenithNEw
|
87578be92c7d2e0cef0ea9f2403b5feb6dfb290d
|
de8803fe854529d1cf7bc4f7f5bb973baaa764e1
|
refs/heads/master
| 2021-07-10T16:06:47.264848 | 2017-10-14T06:36:12 | 2017-10-14T06:36:12 | 106,904,596 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,057 |
swift
|
//
// UIWindowExtensions.swift
// Template
//
// Created by Johan Wiig on 24/11/15.
// Copyright © 2015 Innology. All rights reserved.
//
import UIKit
extension UIWindow {
static var currentController: UIViewController? {
let appDelegate = UIApplication.shared.delegate as? AppDelegate
return appDelegate?.window?.currentController
}
var currentController: UIViewController? {
if let vc = self.rootViewController {
return getCurrentController(vc)
}
return nil
}
func getCurrentController(_ vc: UIViewController) -> UIViewController {
if let pc = vc.presentedViewController {
return getCurrentController(pc)
}
else if let nc = vc as? UINavigationController {
if nc.viewControllers.count > 0 {
return getCurrentController(nc.viewControllers.last!)
} else {
return nc
}
}
else {
return vc
}
}
}
|
[
-1
] |
3639e89477fdfbffce128c9f156b55523dfbf6d5
|
695a4bcb2cf3edc7fe55985540afd13752a25cea
|
/Pokedex/Pokemon.swift
|
f0510b8e9f3598308e55eb285eb888e2cb92173a
|
[] |
no_license
|
luketas/pokedex-app
|
37af726819dd1542fa793ee4c0aa6da929602d4a
|
22f637d888647625e5ed4cc89a2c795467d97388
|
refs/heads/master
| 2021-01-10T07:38:20.967456 | 2016-03-29T21:30:15 | 2016-03-29T21:30:15 | 54,864,676 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,491 |
swift
|
//
// Pokemon.swift
// Pokedex
//
// Created by Lucas Franco on 3/28/16.
// Copyright © 2016 Lucas Franco. All rights reserved.
//
import Foundation
import Alamofire
class Pokemon {
private var _name: String!
private var _pokedexid: Int!
private var _description: String!
private var _type: String!
private var _height: String!
private var _weight: String!
private var _defense: String!
private var _attack: String!
private var _nextEvotxt: String!
private var _nextEvoID: String!
private var _nextEvoLvl: String!
private var _pokemonURL: String!
var nextEvotxt: String{
if _nextEvotxt == nil{
_nextEvotxt = ""
}
return _nextEvotxt
}
var nextEvoId: String{
if _nextEvoID == nil {
_nextEvoID = ""
}
return _nextEvoID
}
var nextEvoLvl: String{
if _nextEvoLvl == nil {
_nextEvoLvl = ""
}
return _nextEvoLvl
}
var description: String{
if _description == nil{
_description = ""
}
return _description
}
var type: String{
if _type == nil{
_type = ""
}
return _type
}
var defense: String{
if _defense == nil{
_defense = ""
}
return _defense
}
var height: String{
if _height == nil {
_height = ""
}
return _height
}
var weight: String{
if _weight == nil{
_weight = ""
}
return _weight
}
var attack: String{
if _attack == nil{
_attack = ""
}
return _attack
}
var name:String{
return _name
}
var pokedexid: Int{
return _pokedexid
}
init(name: String, pokedexid: Int){
self._name = name
self._pokedexid = pokedexid
_pokemonURL = "\(URL_BASE)\(URL_POKEMON)\(self._pokedexid)/"
}
func downloadPokemonDetails(completed: DownloadComplete) {
let url = NSURL(string: _pokemonURL)!
Alamofire.request(.GET , url).responseJSON { response in
let result = response.result
if let dict = result.value as? Dictionary<String, AnyObject> {
if let weight = dict["weight"] as? String {
self._weight = weight
}
if let height = dict["height"] as? String {
self._height = height
}
if let attack = dict["attack"] as? Int {
self._attack = "\(attack)"
}
if let defense = dict["defense"] as? Int {
self._defense = "\(defense)"
}
if let types = dict["types"] as? [Dictionary<String, String>] where types.count > 0 {
if let name = types[0]["name"] {
self._type = name.capitalizedString
}
if types.count > 1 {
for var x = 1 ; x < types.count ; x++ {
if let name = types[x]["name"] {
self._type! += "/\(name.capitalizedString)"
}
}
}
} else {
self._type = ""
}
print(self._type)
if let descArr = dict["descriptions"] as? [Dictionary<String, String>] where descArr.count > 0 {
if let url = descArr[0]["resource_uri"] {
let NSurl = NSURL(string: "\(URL_BASE)\(url)")!
Alamofire.request(.GET, NSurl).responseJSON { response in
let descResult = response.result
if let descDict = descResult.value as? Dictionary<String, AnyObject> {
if let description = descDict["description"] as? String {
self._description = description
print(self._description)
}
}
completed()
}
}
} else {
self._description = ""
}
if let evolutions = dict["evolutions"] as? [Dictionary<String, AnyObject>] where evolutions.count > 0 {
if let to = evolutions[0]["to"] as? String {
if to.rangeOfString("mega") == nil {
if let uri = evolutions[0]["resource_uri"] as? String {
let str = uri.stringByReplacingOccurrencesOfString("/api/v1/pokemon/", withString: "")
let num = str.stringByReplacingOccurrencesOfString("/", withString: "")
self._nextEvoID = num
self._nextEvotxt = to
if let lvl = evolutions[0]["level"] as? Int {
self._nextEvoLvl = "\(lvl)"
}
print(self._nextEvoID)
print(self.nextEvotxt)
print(self.nextEvoLvl)
}
}
}
}
}
}
}
}
|
[
-1
] |
154526815725cfbf5ee2bfeac3f96c98fa7c1ce3
|
03809f649a0aa0347f0328c1c6ab422ec79f355e
|
/Watch-iOS Communication/Watch-iOS Communication/ViewController.swift
|
9c81702e7953f8e926a2495476ac8e288d30bfd4
|
[] |
no_license
|
ivensdenner/watch-ios-communication
|
11ddc675f45fe924e54890cc4ebe7b955fbbe2ac
|
b2af77268fd144ea08c043a2a9a6cfe7121e1c98
|
refs/heads/master
| 2021-01-01T06:33:37.160444 | 2015-07-06T20:54:37 | 2015-07-06T20:54:37 | 38,645,316 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 617 |
swift
|
//
// ViewController.swift
// Watch-iOS Communication
//
// Created by Ivens Denner on 06/07/15.
// Copyright (c) 2015 Ivens Denner. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
// MARK: - IBOutlets
@IBOutlet weak var nameLabel: UILabel!
// MARK: -
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
|
[
291105,
234596,
303977
] |
b9380df26113a93a4c0532dece8eb8362ca977b5
|
98316b26dbf6da04cd67e41eeece985657bd7805
|
/AddaMig_ChatApp/requests/RequestTableViewCell.swift
|
983aeb4060cab52ed195f774423b7b17f8bfdfd4
|
[] |
no_license
|
etygard/AddaMig_ChatApp
|
276a03a64031489d59a3a2f1e7428ee797f2e87a
|
91be7f9f2358037c46af0e66bb75f646a9c8e1d4
|
refs/heads/master
| 2023-07-09T15:32:03.734112 | 2021-08-10T19:49:35 | 2021-08-10T19:49:35 | 394,755,711 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 571 |
swift
|
//
// RequestTableViewCell.swift
// AddaMig_ChatApp
//
// Created by Emma tygard on 2021-08-05.
//
import UIKit
class RequestTableViewCell: UITableViewCell {
//properties:
//outlets:
@IBOutlet weak var contactName: UILabel!
@IBOutlet weak var contactStatus: UILabel!
@IBOutlet weak var contactProfileImg: UIImageView!
@IBOutlet weak var acceptBtn: UIButton!
@IBOutlet weak var rejectBtn: UIButton!
override func awakeFromNib() {
contactProfileImg.layer.cornerRadius = contactProfileImg.frame.height / 2
}
}
|
[
-1
] |
45bb3330e1790be5f742ff940ecd8e3d7a1c8dc6
|
7847ed6cbd3c33723d0e74a6b6cee6d8708c1396
|
/pokedex3/Pokemon.swift
|
ec9aa2e2ca09f3d831ed06d36ec2248c3af5fbd7
|
[] |
no_license
|
rpsr15/pokedex3
|
2a3e46b4e1e3cafc370a09b3c629897e62b2b0e1
|
288c339c6b39da4c14bc6648c1670adea913794c
|
refs/heads/master
| 2021-01-11T14:17:23.072290 | 2017-02-10T21:53:07 | 2017-02-10T21:53:07 | 81,306,236 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 5,759 |
swift
|
//
// Pokemon.swift
// pokedex3
//
// Created by Ravi Rathore on 2/10/17.
// Copyright © 2017 com.banago. All rights reserved.
//
import Foundation
import Alamofire
class Pokemon : NSObject{
private var _name : String!
private var _id : Int!
private var _pokemonURL :String!
private var _description: String!
private var _type : String!
private var _defense : String!
private var _height: String!
private var _weight: String!
private var _attack : String!
private var _nextEvolutionTxt : String!
private var _nextEvolutionId : String!
var nextEvolutionId : String{
if _nextEvolutionId == nil{
_nextEvolutionId = ""
}
return _nextEvolutionId
}
var details : String{
if _description == nil {
_description = ""
}
return _description
}
var weight : String{
if _weight == nil {
_weight = ""
}
return _weight
}
var height : String{
if _height == nil {
_height = ""
}
return _height
}
var defense : String{
if _defense == nil {
_defense = ""
}
return _defense
}
var type : String{
if _type == nil {
_type = ""
}
return _type
}
var attack : String{
if _attack == nil {
_attack = ""
}
return _attack
}
var nextEvolutoinText : String{
if _nextEvolutionTxt == nil {
_nextEvolutionTxt = ""
}
return _nextEvolutionTxt
}
var name : String{
return _name
}
var id : Int{
return _id
}
init(name: String , pokeid : Int) {
self._id = pokeid
self._name = name
self._pokemonURL = URL_BASE + URL_POKEMON + "\(pokeid)"
}
override var description: String{
return "\(_name) and \(_id) "
}
func downloadPokemonDetails(completed : @escaping DownloadComplete){
print(#function)
print(self._pokemonURL)
Alamofire.request(
URL(string: self._pokemonURL)!,
method: .get,
parameters: ["include_docs": "true"])
.validate()
.responseJSON { (response) -> Void in
if let dict = response.result.value as? [String : Any]{
if let descArr = dict["descriptions"] as? [[String : Any]]{
if let desc = descArr.first{
if let path = desc["resource_uri"] as? String
{
let url = URL_BASE + path
print(url)
Alamofire.request(URL(string: url)!, method: .get, parameters: ["include_docs" : "true"]).validate().responseJSON(completionHandler: { (response) in
if let jsonData = response.result.value as? [String:Any]{
if let dString = jsonData["description"] as? String{
self._description = dString
}
}
completed()
})
}
}
}
if let evolutions = dict["evolutions"] as? [[String : Any]]{
if let evolution = evolutions.first{
if let name = evolution["to"] as? String {
self._nextEvolutionTxt = "Next Evolutioin is \(name)"
}
if let path = evolution["resource_uri"] as? String{
if let id = getId(path: path){
self._nextEvolutionId = id
}
}
}
}
if let weight = dict["weight"] as? String{
self._weight = weight
}
if let height = dict["height"] as? String{
self._height = height
}
if let attack = dict["attack"] as? Int{
self._attack = "\(attack)"
}
if let defense = dict["defense"] as? Int{
self._defense = "\(defense)"
}
var typeString = ""
if let types = dict["types"] as? [[String : Any]]{
for type in types{
if let typeName = type["name"] as? String{
if typeString == ""{
typeString.append(typeName)
}
else{
typeString.append("/\(typeName)")
}
}
}
self._type = typeString.capitalized
print(typeString)
}
completed()
return
}
}
}
}
|
[
-1
] |
e4c40aaa37ecb33cf94f88017c05050664a9afb7
|
434252df489ec1ae23608b2a8d810f29a965b95d
|
/KurtEllul_SimpleCalculator/KurtEllul_SimpleCalculatorTests/KurtEllul_SimpleCalculatorTests.swift
|
bdefaf137ed50d9a8381ed3cbab7c39745457c06
|
[] |
no_license
|
kurtellul/KurtEllul_Swift_SimpleApplications
|
d352cbe327157e4f526b9e9329efffefb08b9738
|
74dfefd270c7a5b7a57a1b8cb82e89cc27720f44
|
refs/heads/master
| 2021-05-04T09:14:37.617094 | 2016-10-10T04:20:04 | 2016-10-10T04:20:04 | 70,451,503 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,046 |
swift
|
//
// KurtEllul_SimpleCalculatorTests.swift
// KurtEllul_SimpleCalculatorTests
//
// Created by Kurt Ellul on 09/10/2016.
// Copyright © 2016 Kurt Ellul. All rights reserved.
//
import XCTest
@testable import KurtEllul_SimpleCalculator
class KurtEllul_SimpleCalculatorTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
|
[
305179,
229413,
354343,
354345,
278570,
233517,
309295,
229424,
282672,
237620,
129076,
229430,
288833,
288834,
311372,
315476,
280661,
354393,
315487,
237663,
45153,
309345,
280675,
307301,
280677,
313447,
131178,
280694,
131191,
237689,
131198,
280712,
311438,
284825,
284826,
311458,
284842,
239793,
299187,
280762,
223419,
280768,
227524,
309444,
280778,
280795,
227548,
311519,
280802,
176362,
286958,
227585,
227592,
278797,
282909,
278816,
237857,
233762,
211235,
217380,
211238,
280887,
282939,
260418,
311621,
6481,
305495,
379225,
323935,
416104,
280939,
285040,
242033,
291192,
311681,
227725,
285084,
293303,
61880,
278978,
291267,
283075,
127427,
278989,
281040,
328152,
188894,
287198,
279008,
160225,
358882,
279013,
291311,
281072,
309744,
279029,
279032,
279039,
279050,
303631,
279057,
283153,
279062,
279065,
283182,
283184,
23092,
279094,
70209,
309830,
55881,
281166,
281171,
287318,
309846,
295519,
279146,
313966,
287346,
287352,
301689,
279164,
287374,
314009,
303771,
221852,
164512,
279210,
287404,
285361,
279217,
299699,
314040,
287417,
303803,
285373,
287422,
287433,
225995,
279252,
287452,
289502,
285415,
293612,
312047,
279280,
230134,
154359,
234234,
299770,
221948,
279294,
299776,
285444,
322313,
283419,
293664,
234277,
283430,
312108,
285487,
164656,
285497,
289598,
160575,
281408,
318278,
201551,
281427,
281433,
301918,
295776,
293730,
303972,
174963,
207732,
310131,
228215,
209785,
279417,
308092,
158593,
113542,
228234,
308107,
56208,
293781,
324506,
324507,
279464,
213960,
316364,
183248,
50143,
314342,
234472,
234473,
287731,
234500,
234514,
308243,
175132,
238623,
238651,
308287,
238664,
234587,
277597,
304222,
281697,
302177,
277603,
281700,
285798,
207979,
279660,
15471,
144496,
234609,
312434,
285814,
300151,
279672,
160891,
300158,
150657,
187521,
234625,
285828,
302213,
285830,
222343,
302216,
228491,
234638,
308372,
185493,
238743,
119962,
283802,
285851,
300187,
302240,
234663,
249002,
238765,
238769,
208058,
64700,
228540,
228542,
283840,
302274,
283847,
283852,
279765,
279774,
304351,
304356,
298228,
302325,
216315,
208124,
228609,
292107,
312587,
339234,
286013,
286018,
279875,
216386,
224586,
222541,
238927,
283991,
357719,
230756,
281957,
163175,
284014,
279920,
111993,
181625,
224640,
142729,
368011,
112017,
282007,
318875,
279974,
282022,
173491,
304564,
228795,
292283,
296392,
302540,
280013,
312782,
306639,
310736,
228827,
239068,
316902,
280041,
308723,
306677,
286202,
286205,
302590,
306692,
306693,
282129,
308756,
282136,
302623,
288309,
288318,
280130,
288327,
282183,
218696,
292425,
286288,
300630,
306776,
286306,
288378,
282245,
282246,
288392,
229001,
290443,
323217,
282259,
229020,
282273,
302754,
282276,
40613,
40614,
40615,
229029,
300714,
298667,
286391,
300728,
282303,
218819,
306890,
280267,
302797,
9936,
9937,
302802,
280278,
282327,
298712,
278233,
18138,
278234,
282339,
282348,
282355,
229113,
300794,
286459,
278272,
288512,
311042,
288516,
216839,
300811,
321295,
284431,
278291,
278293,
282400,
313120,
315171,
284459,
280366,
282417,
200498,
280372,
282427,
282434,
280390,
282438,
18262,
188251,
284507,
284512,
284514,
276327,
292712,
288619,
280430,
282480,
305026,
67463,
282504,
243597,
184208,
282518,
282519,
214937,
239514,
294823,
276394,
284587,
288697,
237504,
294850,
280519,
24532,
298980,
294886
] |
e5754ef147dd133c0a3e07353f496e8f323325a6
|
44358d35552839ec0f1545dbc5fb277d6eaeffd7
|
/PennyTests/PennyTests.swift
|
13ed24fe62ce617cfdf96bec1411cfaa39d04c87
|
[] |
no_license
|
hpp/Penny
|
7a16a7b2dfedf0cd36f89513e7655d229b0f28d8
|
d7a51cdf7291ed6938962c66fcb79c3b7d04cc9b
|
refs/heads/master
| 2021-01-20T12:03:49.710282 | 2015-01-21T06:05:43 | 2015-01-21T06:05:43 | 28,156,913 | 3 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 901 |
swift
|
//
// PennyTests.swift
// PennyTests
//
// Created by Izzy Water on 11/30/14.
// Copyright (c) 2014 Harmonic Processes. All rights reserved.
//
import UIKit
import XCTest
class PennyTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
|
[
276481,
276484,
276489,
276492,
276509,
159807,
276543,
280649,
276555,
223318,
288857,
227417,
194652,
194653,
276577,
43109,
276582,
276581,
276585,
223340,
276589,
227439,
276592,
227446,
276603,
276606,
276613,
141450,
311435,
276627,
276631,
184475,
227492,
196773,
227495,
129203,
176314,
227528,
276684,
278742,
278746,
278753,
196834,
276709,
276710,
276715,
157944,
211193,
227576,
276744,
276748,
276753,
157970,
129301,
276760,
278810,
276764,
276774,
262450,
276787,
278846,
164162,
278856,
276813,
278862,
278863,
276821,
276822,
276831,
276835,
276847,
278898,
278908,
178571,
278951,
278954,
278965,
276919,
276920,
278969,
278985,
279002,
276958,
227813,
279019,
279022,
276998,
186893,
279054,
223767,
223769,
277017,
277029,
277048,
301634,
369220,
277066,
166507,
189036,
189037,
277101,
189042,
189043,
277118,
184962,
277133,
133774,
225933,
225936,
277138,
277141,
277142,
225943,
225944,
164512,
225956,
285353,
225962,
209581,
154291,
154294,
199366,
225997,
226001,
164563,
277204,
277203,
226004,
119513,
201442,
226033,
226035,
226043,
209660,
234238,
234241,
226051,
234245,
277254,
209670,
203529,
234250,
234253,
234256,
234263,
369432,
234268,
105246,
228129,
234280,
277289,
234283,
277294,
234286,
226097,
234289,
234301,
234304,
234305,
162626,
277316,
234311,
234312,
234317,
277327,
234323,
234326,
277339,
297822,
234335,
297826,
234340,
174949,
234343,
234346,
277354,
234349,
277360,
213876,
277366,
234361,
277370,
234366,
234367,
234372,
226181,
213894,
277381,
234377,
226189,
234381,
226194,
234387,
234392,
234395,
279456,
277410,
234404,
226214,
256937,
234409,
275371,
234412,
226222,
226223,
234419,
226227,
234425,
277435,
287677,
234430,
275397,
234438,
226249,
234445,
234450,
234451,
234454,
234457,
275418,
234463,
234466,
277480,
179176,
234477,
234482,
234492,
234495,
277505,
234498,
277510,
234503,
234506,
234509,
277517,
197647,
277518,
295953,
275469,
234517,
281625,
234530,
234531,
234534,
275495,
234539,
275500,
310317,
277550,
275505,
234548,
277563,
234555,
7229,
277566,
230463,
7230,
7231,
207938,
156733,
234560,
234565,
277574,
281666,
234569,
207953,
277585,
296018,
234583,
234584,
275547,
277596,
234594,
277603,
234603,
281707,
156785,
275571,
234612,
398457,
234622,
275590,
275591,
234631,
253063,
277640,
302217,
234632,
234642,
226451,
226452,
275607,
119963,
234652,
277665,
275625,
208043,
275628,
226476,
226479,
226481,
277686,
277690,
277694,
203989,
275671,
195811,
285929,
204022,
120055,
120056,
204041,
277792,
199971,
259363,
277800,
113962,
277803,
277806,
113966,
226608,
277809,
226609,
277814,
277815,
277821,
277824,
277825,
15686,
277831,
226632,
142669,
277838,
277841,
222548,
277845,
277844,
277852,
224605,
218462,
224606,
277856,
142689,
302438,
277862,
281962,
173420,
277868,
277871,
279919,
277878,
275831,
275832,
277882,
277883,
142716,
275838,
275839,
277890,
277891,
226694,
275847,
277896,
277897,
281992,
277900,
230799,
296338,
277907,
206228,
277911,
226711,
226712,
277919,
277920,
277925,
277927,
370091,
277936,
277939,
277940,
296375,
277943,
277946,
277949,
277952,
296387,
163269,
277957,
296391,
277962,
282060,
277965,
277969,
277974,
228823,
228824,
277977,
277980,
226781,
277983,
277988,
277993,
296425,
277994,
277997,
278002,
278005,
278008,
153095,
175625,
192010,
280077,
65041,
204313,
278060,
226875,
128583,
226888,
276046,
226897,
276050,
226906,
243292,
226910,
370271,
276085,
276088,
278140,
276097,
276100,
276101,
312972,
278160,
276116,
276117,
276120,
278170,
280220,
276126,
278191,
276146,
278195,
296628,
276148,
278201,
276156,
276165,
278214,
323276,
276179,
276180,
216795,
216796,
276195,
313065,
276210,
276219,
278285,
227091,
184086,
278299,
276253,
276257,
278307,
288547,
278316,
159533,
276279,
276282,
276283,
288574,
276287,
276298,
188246,
276311,
276325,
276332,
173936,
110452,
276344,
276350,
227199,
1923,
40850,
40853,
44952,
247712,
276385,
276394,
276400,
276401,
276408,
161722,
276413,
276421,
276422,
276430,
153552,
276444,
153566,
276450,
276451,
276454,
276459,
276462,
276463,
276468,
276469,
278518,
276475,
276478
] |
943a284a1c2af1b5718e654c5f997a1a08494f4b
|
1cd40d789b9ad7b06144e011232fcf2713f87b54
|
/YLAnimationTest/Pods/YLSwiftScan/YLSwiftScan/Classes/YLScanViewSetting.swift
|
1d9b5e401b661b38781aad98f03b25ec7aa4b91e
|
[
"MIT"
] |
permissive
|
hoggenw/YLTestCode
|
8622abc17faba162d6bb6543c9d6b2626ae9416f
|
ede621708cc82b85a49308a5e9ed6ddcf82a0924
|
refs/heads/master
| 2021-01-20T13:13:40.959955 | 2019-10-09T06:02:11 | 2019-10-09T06:02:11 | 82,680,526 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 23,515 |
swift
|
//
// YLScanViewSetting.swift
// YLScan
//
// Created by 王留根 on 17/1/16.
// Copyright © 2017年 ios-mac. All rights reserved.
//
import UIKit
import AVFoundation
public struct YLScanResult {
//码内容
public var strScanned:String? = ""
//扫描图像
public var imgScanned:UIImage?
//码的类型
public var strBarCodeType:String? = ""
//码在图像中的位置
public var arrayCorner:[AnyObject]?
public init(str:String?,img:UIImage?,barCodeType:String?,corner:[AnyObject]?)
{
self.strScanned = str
self.imgScanned = img
self.strBarCodeType = barCodeType
self.arrayCorner = corner
}
}
open class YLScanViewSetting: NSObject ,AVCaptureMetadataOutputObjectsDelegate {
let device: AVCaptureDevice? = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
var input: AVCaptureDeviceInput?
var output: AVCaptureMetadataOutput
let session = AVCaptureSession()
var previewLayer: AVCaptureVideoPreviewLayer?
var stillImageOutput: AVCaptureStillImageOutput?
//存储返回结果
var arrayResult: [YLScanResult] = [YLScanResult]()
//扫码返回block
var succesBlock:([YLScanResult]) -> Void
//是否需要拍照
var isNeedCaptureImage:Bool
//当前扫码结果是否处理
var isNeedScanResult:Bool = true
//二维码视图
static var QRcodeView: UIView {
get {
let QRView = UIView()
QRView.backgroundColor = UIColor.white
QRView.layer.shadowOffset = CGSize(width: 0, height: 2);
QRView.layer.shadowRadius = 2;
QRView.layer.shadowColor = UIColor.black.cgColor
QRView.layer.shadowOpacity = 0.5;
return QRView
}
}
/**
初始化设备
- parameter videoPreView: 视频显示UIView
- parameter objType: 识别码的类型,缺省值 QR二维码
- parameter isCaptureImg: 识别后是否采集当前照片
- parameter cropRect: 识别区域
- parameter success: 返回识别信息
- returns:
*/
deinit {
print("YLScanSetting deinit")
}
init(videoPreView:UIView,objType:[String] = [AVMetadataObjectTypeQRCode],isCaptureImg:Bool,cropRect:CGRect=CGRect.zero,success:@escaping ( ([YLScanResult]) -> Void)) {
do{
input = try AVCaptureDeviceInput(device: device)
}
catch let error as NSError {
print("AVCaptureDeviceInput(): \(error)")
}
succesBlock = success
isNeedCaptureImage = isCaptureImg
stillImageOutput = AVCaptureStillImageOutput()
// Output
output = AVCaptureMetadataOutput()
super.init()
guard device != nil else {
return
}
if session.canAddInput(input)
{
session.addInput(input)
}
if session.canAddOutput(output)
{
session.addOutput(output)
}
if session.canAddOutput(stillImageOutput)
{
session.addOutput(stillImageOutput)
}
let outputSettings:Dictionary = [AVVideoCodecJPEG:AVVideoCodecKey]
stillImageOutput?.outputSettings = outputSettings
session.sessionPreset = AVCaptureSessionPresetHigh
//参数设置
output.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
output.metadataObjectTypes = objType
// output.metadataObjectTypes = [AVMetadataObjectTypeQRCode,AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode128Code]
if !cropRect.equalTo(CGRect.zero)
{
//启动相机后,直接修改该参数无效
output.rectOfInterest = cropRect
}
previewLayer = AVCaptureVideoPreviewLayer(session: session)
previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
var frame:CGRect = videoPreView.frame
frame.origin = CGPoint.zero
previewLayer?.frame = frame
videoPreView.layer .insertSublayer(previewLayer!, at: 0)
if ( device!.isFocusPointOfInterestSupported && device!.isFocusModeSupported(AVCaptureFocusMode.continuousAutoFocus) )
{
do {
try input?.device.lockForConfiguration()
input?.device.focusMode = AVCaptureFocusMode.continuousAutoFocus
input?.device.unlockForConfiguration()
}
catch let error as NSError {
print("device.lockForConfiguration(): \(error)")
}
}
}
func start() {
if !session.isRunning {
isNeedScanResult = true
session.startRunning()
}
}
func stop() {
if session.isRunning {
isNeedScanResult = false
session.stopRunning()
}
}
class open func imageFromBundleWithName(name: String) -> UIImage{
let filePathBundle: Bundle = YLScanViewSetting.resourceWithName()
let imageFilePath: String = filePathBundle.path(forResource: name, ofType: "png")!
let image = UIImage(contentsOfFile: imageFilePath)
return image!
}
class open func resourceWithName() -> Bundle {
let scanViewBunlde: Bundle = Bundle.init(for: YLScanViewController.self)
let returnBundel: Bundle = Bundle(path: scanViewBunlde.bundlePath.appending("/YLSwiftScan.bundle"))!
return returnBundel
}
open func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
guard isNeedScanResult else {
//上一帧处理中
return
}
isNeedScanResult = false
arrayResult.removeAll()
for current:Any in metadataObjects {
if (current as AnyObject).isKind(of: AVMetadataMachineReadableCodeObject.self) {
let code = current as! AVMetadataMachineReadableCodeObject
//码类型
let codeType = code.type
print("code type:%@",codeType!)
//码内容
let codeContent = code.stringValue
print("code string:%@",codeContent!)
//4个字典,分别 左上角-右上角-右下角-左下角的 坐标百分百,可以使用这个比例抠出码的图像
// let arrayRatio = code.corners
arrayResult.append(YLScanResult(str: codeContent, img: UIImage(), barCodeType: codeType,corner: code.corners as [AnyObject]?))
}
}
if arrayResult.count > 0 {
if isNeedCaptureImage{
captureImage()
}else {
stop()
succesBlock(arrayResult)
}
}
}
//MARK: ----拍照
open func captureImage() {
let stillImageConnection:AVCaptureConnection? = connectionWithMediaType(mediaType: AVMediaTypeVideo, connections: (stillImageOutput?.connections)! as [AnyObject])
stillImageOutput?.captureStillImageAsynchronously(from: stillImageConnection, completionHandler: { (imageDataSampleBuffer, error) -> Void in
self.stop()
if imageDataSampleBuffer != nil {
let imageData: Data = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageDataSampleBuffer) as Data
let scanImg:UIImage? = UIImage(data: imageData)
for idx in 0...self.arrayResult.count-1
{
self.arrayResult[idx].imgScanned = scanImg
}
}
self.succesBlock(self.arrayResult)
})
}
open func connectionWithMediaType(mediaType:String,connections:[AnyObject]) -> AVCaptureConnection? {
for connection:AnyObject in connections {
let connectionTmp:AVCaptureConnection = connection as! AVCaptureConnection
for port:Any in connectionTmp.inputPorts {
if (port as AnyObject).isKind(of: AVCaptureInputPort.self) {
let portTmp:AVCaptureInputPort = port as! AVCaptureInputPort
if portTmp.mediaType == mediaType {
return connectionTmp
}
}
}
}
return nil
}
//MARK:切换识别区域
open func changeScanRect(cropRect:CGRect) {
//待测试,不知道是否有效
stop()
output.rectOfInterest = cropRect
start()
}
//MARK: 切换识别码的类型
open func changeScanType(objType:[String]) {
//待测试中途修改是否有效
output.metadataObjectTypes = objType
}
open func isGetFlash()->Bool {
if (device != nil && device!.hasFlash && device!.hasTorch) {
return true
}
return false
}
/**
打开或关闭闪关灯
- parameter torch: true:打开闪关灯 false:关闭闪光灯
*/
open func setTorch(torch:Bool) {
if isGetFlash() {
do {
try input?.device.lockForConfiguration()
input?.device.torchMode = torch ? AVCaptureTorchMode.on : AVCaptureTorchMode.off
input?.device.unlockForConfiguration()
}
catch let error as NSError {
print("device.lockForConfiguration(): \(error)")
}
}
}
/**
------闪光灯打开或关闭
*/
open func changeTorch() {
if isGetFlash() {
do
{
try input?.device.lockForConfiguration()
var torch = false
if input?.device.torchMode == AVCaptureTorchMode.on {
torch = false
}
else if input?.device.torchMode == AVCaptureTorchMode.off {
torch = true
}
input?.device.torchMode = torch ? AVCaptureTorchMode.on : AVCaptureTorchMode.off
input?.device.unlockForConfiguration()
}
catch let error as NSError {
print("device.lockForConfiguration(): \(error)")
}
}
}
//MARK: ------获取系统默认支持的码的类型
static func defaultMetaDataObjectTypes() ->[String] {
var types =
[AVMetadataObjectTypeQRCode,
AVMetadataObjectTypeUPCECode,
AVMetadataObjectTypeCode39Code,
AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeEAN13Code,
AVMetadataObjectTypeEAN8Code,
AVMetadataObjectTypeCode93Code,
AVMetadataObjectTypeCode128Code,
AVMetadataObjectTypePDF417Code,
AVMetadataObjectTypeAztecCode,
];
//if #available(iOS 8.0, *)
types.append(AVMetadataObjectTypeInterleaved2of5Code)
types.append(AVMetadataObjectTypeITF14Code)
types.append(AVMetadataObjectTypeDataMatrixCode)
types.append(AVMetadataObjectTypeInterleaved2of5Code)
types.append(AVMetadataObjectTypeITF14Code)
types.append(AVMetadataObjectTypeDataMatrixCode)
return types;
}
static func isSysIos8Later()->Bool {
// return Float(UIDevice.currentDevice().systemVersion) >= 8.0 ? true:false
return floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_8_0
}
/**
识别二维码码图像
- parameter image: 二维码图像
- returns: 返回识别结果
*/
static open func recognizeQRImage(image:UIImage) ->[YLScanResult] {
var returnResult:[YLScanResult]=[]
if YLScanViewSetting.isSysIos8Later() {
//if #available(iOS 8.0, *)
let detector:CIDetector = CIDetector(ofType: CIDetectorTypeQRCode, context: nil, options: [CIDetectorAccuracy:CIDetectorAccuracyHigh])!
let img = CIImage(cgImage: (image.cgImage)!)
let features:[CIFeature]? = detector.features(in: img, options: [CIDetectorAccuracy:CIDetectorAccuracyHigh])
if( features != nil && (features?.count)! > 0) {
let feature = features![0]
if feature.isKind(of: CIQRCodeFeature.self) {
let featureTmp:CIQRCodeFeature = feature as! CIQRCodeFeature
let scanResult = featureTmp.messageString
let result = YLScanResult(str: scanResult, img: image, barCodeType: AVMetadataObjectTypeQRCode,corner: nil)
returnResult.append(result)
}
}
}
return returnResult
}
// static open func createCode128( codeString:String, size:CGSize,qrColor:UIColor,bkColor:UIColor )->UIImage?{
// let stringData = codeString.data(using: String.Encoding.utf8)
// //系统自带能生成的码
// // CIAztecCodeGenerator 二维码
// // CICode128BarcodeGenerator 条形码
// // CIPDF417BarcodeGenerator
// // CIQRCodeGenerator 二维码
// let qrFilter = CIFilter(name: "CICode128BarcodeGenerator")
// qrFilter?.setDefaults()
// qrFilter?.setValue(stringData, forKey: "inputMessage")
//
//
//
// let outputImage:CIImage? = qrFilter?.outputImage
// let context = CIContext()
// let cgImage = context.createCGImage(outputImage!, from: outputImage!.extent)
//
// let image = UIImage(cgImage: cgImage!, scale: 1.0, orientation: UIImageOrientation.up)
//
//
// // Resize without interpolating
// let scaleRate:CGFloat = 20.0
// let resized = resizeImage(image: image, quality: CGInterpolationQuality.none, rate: scaleRate)
//
// return resized;
// }
//MARK: ----图像处理
/**
@brief 图像中间加logo图片
@param srcImg 原图像
@param LogoImage logo图像
@param logoSize logo图像尺寸
@return 加Logo的图像
*/
static func creatQRCodeView(bound:CGRect, codeMessage: String,logoName: String?) -> UIImageView {
let qrImg = YLScanViewSetting.createCode(codeType: "CIQRCodeGenerator",codeString:codeMessage, size: bound.size, qrColor: UIColor.black, bkColor: UIColor.white)
let qrImgView = UIImageView()
qrImgView.frame = bound
if let logoIcon = logoName {
let logoImg = UIImage(named:logoIcon)
qrImgView.image = YLScanViewSetting.addImageLogo(srcImg: qrImg!, logoImg: logoImg, logoSize: CGSize(width: 30, height: 30))
}else {
qrImgView.image = YLScanViewSetting.addImageLogo(srcImg: qrImg!, logoImg: nil, logoSize: CGSize(width: 30, height: 30))
}
return qrImgView
}
//MARK: -- - 生成二维码,背景色及二维码颜色设置
static open func createCode( codeType:String, codeString:String, size:CGSize,qrColor:UIColor,bkColor:UIColor )->UIImage?
{
//if #available(iOS 8.0, *)
let stringData = codeString.data(using: String.Encoding.utf8)
//系统自带能生成的码
// CIAztecCodeGenerator
// CICode128BarcodeGenerator
// CIPDF417BarcodeGenerator
// CIQRCodeGenerator
let qrFilter = CIFilter(name: codeType)
qrFilter?.setValue(stringData, forKey: "inputMessage")
qrFilter?.setValue("H", forKey: "inputCorrectionLevel")
//上色
let colorFilter = CIFilter(name: "CIFalseColor", withInputParameters: ["inputImage":qrFilter!.outputImage!,"inputColor0":CIColor(cgColor: qrColor.cgColor),"inputColor1":CIColor(cgColor: bkColor.cgColor)])
let qrImage = colorFilter!.outputImage!;
//绘制
let cgImage = CIContext().createCGImage(qrImage, from: qrImage.extent)!
UIGraphicsBeginImageContext(size);
let context = UIGraphicsGetCurrentContext()!;
context.interpolationQuality = CGInterpolationQuality.none;
context.scaleBy(x: 1.0, y: -1.0);
context.draw(cgImage, in: context.boundingBoxOfClipPath)
let codeImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return codeImage
}
static open func addImageLogo(srcImg:UIImage,logoImg:UIImage?,logoSize:CGSize )->UIImage {
UIGraphicsBeginImageContext(srcImg.size);
srcImg.draw(in: CGRect(x: 0, y: 0, width: srcImg.size.width, height: srcImg.size.height))
let rect = CGRect(x: srcImg.size.width/2 - logoSize.width/2, y: srcImg.size.height/2-logoSize.height/2, width:logoSize.width, height: logoSize.height);
if let _ = logoImg {
logoImg!.draw(in: rect)
}
let resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage!;
}
//MARK:根据扫描结果,获取图像中得二维码区域图像(如果相机拍摄角度故意很倾斜,获取的图像效果很差)
static func getConcreteCodeImage(srcCodeImage:UIImage,codeResult:YLScanResult)->UIImage? {
let rect:CGRect = getConcreteCodeRectFromImage(srcCodeImage: srcCodeImage, codeResult: codeResult)
if rect.isEmpty
{
return nil
}
let img = imageByCroppingWithStyle(srcImg: srcCodeImage, rect: rect)
if img != nil
{
let imgRotation = imageRotation(image: img!, orientation: UIImageOrientation.right)
return imgRotation
}
return nil
}
//图像缩放
static func resizeImage(image:UIImage,quality:CGInterpolationQuality,rate:CGFloat)->UIImage? {
var resized:UIImage?;
let width = image.size.width * rate;
let height = image.size.height * rate;
UIGraphicsBeginImageContext(CGSize(width: width, height: height));
let context = UIGraphicsGetCurrentContext();
context!.interpolationQuality = quality;
image.draw(in: CGRect(x: 0, y: 0, width: width, height: height))
resized = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resized;
}
//图像裁剪
static func imageByCroppingWithStyle(srcImg:UIImage,rect:CGRect)->UIImage?
{
let imageRef = srcImg.cgImage
let imagePartRef = imageRef!.cropping(to: rect)
let cropImage = UIImage(cgImage: imagePartRef!)
return cropImage
}
//获取二维码的图像区域
static open func getConcreteCodeRectFromImage(srcCodeImage:UIImage,codeResult:YLScanResult)->CGRect{
if (codeResult.arrayCorner == nil || (codeResult.arrayCorner?.count)! < 4 )
{
return CGRect.zero
}
let corner:[[String:Float]] = codeResult.arrayCorner as! [[String:Float]]
let dicTopLeft = corner[0]
let dicTopRight = corner[1]
let dicBottomRight = corner[2]
let dicBottomLeft = corner[3]
let xLeftTopRatio:Float = dicTopLeft["X"]!
let yLeftTopRatio:Float = dicTopLeft["Y"]!
let xRightTopRatio:Float = dicTopRight["X"]!
let yRightTopRatio:Float = dicTopRight["Y"]!
let xBottomRightRatio:Float = dicBottomRight["X"]!
let yBottomRightRatio:Float = dicBottomRight["Y"]!
let xLeftBottomRatio:Float = dicBottomLeft["X"]!
let yLeftBottomRatio:Float = dicBottomLeft["Y"]!
//由于截图只能矩形,所以截图不规则四边形的最大外围
let xMinLeft = CGFloat( min(xLeftTopRatio, xLeftBottomRatio) )
let xMaxRight = CGFloat( max(xRightTopRatio, xBottomRightRatio) )
let yMinTop = CGFloat( min(yLeftTopRatio, yRightTopRatio) )
let yMaxBottom = CGFloat ( max(yLeftBottomRatio, yBottomRightRatio) )
let imgW = srcCodeImage.size.width
let imgH = srcCodeImage.size.height
//宽高反过来计算
let rect = CGRect(x: xMinLeft * imgH, y: yMinTop*imgW, width: (xMaxRight-xMinLeft)*imgH, height: (yMaxBottom-yMinTop)*imgW)
return rect
}
//图像旋转
static func imageRotation(image:UIImage,orientation:UIImageOrientation)->UIImage
{
var rotate:Double = 0.0;
var rect:CGRect;
var translateX:CGFloat = 0.0;
var translateY:CGFloat = 0.0;
var scaleX:CGFloat = 1.0;
var scaleY:CGFloat = 1.0;
switch (orientation) {
case UIImageOrientation.left:
rotate = M_PI_2;
rect = CGRect(x: 0, y: 0, width: image.size.height, height: image.size.width);
translateX = 0;
translateY = -rect.size.width;
scaleY = rect.size.width/rect.size.height;
scaleX = rect.size.height/rect.size.width;
break;
case UIImageOrientation.right:
rotate = 3 * M_PI_2;
rect = CGRect(x: 0, y: 0, width: image.size.height, height: image.size.width);
translateX = -rect.size.height;
translateY = 0;
scaleY = rect.size.width/rect.size.height;
scaleX = rect.size.height/rect.size.width;
break;
case UIImageOrientation.down:
rotate = M_PI;
rect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height);
translateX = -rect.size.width;
translateY = -rect.size.height;
break;
default:
rotate = 0.0;
rect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height);
translateX = 0;
translateY = 0;
break;
}
UIGraphicsBeginImageContext(rect.size);
let context = UIGraphicsGetCurrentContext()!;
//做CTM变换
context.translateBy(x: 0.0, y: rect.size.height);
context.scaleBy(x: 1.0, y: -1.0);
context.rotate(by: CGFloat(rotate));
context.translateBy(x: translateX, y: translateY);
context.scaleBy(x: scaleX, y: scaleY);
//绘制图片
context.draw(image.cgImage!, in: CGRect(x: 0, y: 0, width: rect.size.width, height: rect.size.height))
let newPic = UIGraphicsGetImageFromCurrentImageContext();
return newPic!;
}
}
|
[
123235
] |
784f360bf16f49015f619512f64a435be4b233a6
|
4e8ddac7967d381911c87738b70ecffdd2e81082
|
/Comb Sort/Comb Sort.playground/Sources/Comb Sort.swift
|
f7c4eec615a157e7c2284c9fad8f759f86d344ab
|
[
"MIT"
] |
permissive
|
daisysomus/swift-algorithm-club
|
c2a3f1ea3139907f2c3cf7a0a08a6d5d955f632a
|
da030ebe4c3b0d6ebf3b9e6960b6a19dc434efdf
|
refs/heads/master
| 2021-01-17T04:53:09.065940 | 2017-06-12T06:01:48 | 2017-06-12T06:01:48 | 83,023,874 | 2 | 0 | null | 2017-02-24T09:18:16 | 2017-02-24T09:18:16 | null |
UTF-8
|
Swift
| false | false | 759 |
swift
|
// Comb Sort.swift
// Comb Sort
//
// Created by Stephen.Rutstein on 7/16/16.
// Copyright © 2016 Stephen.Rutstein. All rights reserved.
//
import Foundation
public func combSort<T: Comparable>(_ input: [T]) -> [T] {
var copy: [T] = input
var gap = copy.count
let shrink = 1.3
while gap > 1 {
gap = (Int)(Double(gap) / shrink)
if gap < 1 {
gap = 1
}
var index = 0
while !(index + gap >= copy.count) {
if copy[index] > copy[index + gap] {
swap(©[index], ©[index + gap])
}
index += 1
}
}
return copy
}
fileprivate func swap<T: Comparable>(a: inout T, b: inout T) {
let temp = a
a = b
b = temp
}
|
[
-1
] |
2a073a8e747cc3ac8dd6cfcec501bc8d7e4ad2cd
|
3e1ed8959e4a2bda6fbc59289a0515a1c5e90f99
|
/Base/Extensions/Results.swift
|
b7b7863f7ab7010bc160e8c56d031a5c60b492e9
|
[] |
no_license
|
Tinhvv-Ominext/Clean-Architecture-iOS
|
809af0103e54da95f16f915de68573a712da7658
|
5086d4beacb31dd1e6f3156f2a12640e020db83e
|
refs/heads/master
| 2022-12-07T01:47:12.125586 | 2020-08-27T06:07:14 | 2020-08-27T06:07:14 | 290,431,468 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 485 |
swift
|
//
// Results.swift
// Knafeh
//
// Created by Tinh Vu on 4/11/20.
// Copyright © 2020 Ominext JSC. All rights reserved.
//
import Foundation
import RealmSwift
extension Results {
func toArray<R: StandaloneCopy>(ofType: R.Type) -> [R.T] {
typealias RM = R.T
var array = [RM]()
for i in 0 ..< count {
if let result = self[i] as? R {
array.append(result.toStandalone())
}
}
return array
}
}
|
[
-1
] |
00df43ed964e73a9a622c2506e4ed1057754eaab
|
09dba985fa29e0cb6b2cf650b0fd168ea7eca07c
|
/Playground/Examples Functional Style.playground/Pages/ErrorHandling.xcplaygroundpage/Contents.swift
|
7aadeb911eeba8fcad7610be6ccf349ea43c4683
|
[
"MIT"
] |
permissive
|
konrad1977/FunNetworking
|
10e03f8d292b6ecfb7c81c2dc4f64c442258bf79
|
86cf58fe16d6268aaab238a18439214d40b09144
|
refs/heads/main
| 2023-05-06T06:57:40.984972 | 2021-05-27T17:27:30 | 2021-05-27T17:27:30 | 361,135,686 | 7 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 659 |
swift
|
//: [Previous](@previous)
import Foundation
import FunNetworking
import Funswift
struct Host: Decodable { let ip: String }
func handleError(error: Error) {
switch error {
case let NetworkRequestError.failed(err):
print(err)
case NetworkRequestError.invalidRequest:
print("Invalid request")
case let NetworkRequestError.invalidResponse(code):
print("Invalid response code: \(code)")
default:
print("An error occured \(error)")
}
}
let fetchIpNumber: IO<Either<Error, Host>> = {
Optional<URLRequest>.none
|> requestSyncE
<&> decodeJsonData
}()
fetchIpNumber
.unsafeRun()
.onLeft(handleError)
.onRight({ dump($0) })
//: [Next](@next)
|
[
-1
] |
b58df91e25481f211856bc1a806bcf560cab4f52
|
4efa63e5a8ad330578bae2be1de0ae69ed64c002
|
/ZuYu2/ZuYu2/controller/login/PlatformStepThreeController.swift
|
44f38bea079a5b0502825c5df77a2bbe5c236e07
|
[
"MIT"
] |
permissive
|
MoMoLiangyu/qianxingzuyu
|
43436260f4ec333388848c70f87eda283704e540
|
4b252b8c5135b34d1412857be039e04a2326b79e
|
refs/heads/master
| 2023-06-04T03:16:09.595319 | 2021-06-26T13:37:37 | 2021-06-26T13:37:37 | 380,501,827 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 876 |
swift
|
//
// PlatformStepThreeController.swift
// ZuYu2
//
// Created by million on 2020/8/2.
// Copyright © 2020 million. All rights reserved.
//
import UIKit
class PlatformStepThreeController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .done, target: self, action: #selector(done))
}
@objc func done() {
navigationController?.popToRootViewController(animated: true)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
02be80ed5a455f28ed0478515c5d7ede9036d023
|
855a08ee0f3670b1e131755d6a77880e8bc756d1
|
/Vision/Services/ContactsService.swift
|
2b6555c4accfca3980c03c4fda1b94898d209a1d
|
[] |
no_license
|
idanmos/Bmore
|
46445c3e45ece156b162a6d1dcf7573d6a1258dd
|
ec68713ce4f3b629cc8d3bd939c3dfec403710f8
|
refs/heads/main
| 2023-03-18T05:55:23.117277 | 2021-03-08T08:01:15 | 2021-03-08T08:01:15 | 331,641,644 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,740 |
swift
|
//
// ContactsService.swift
// ContactsPicker
//
// Created by Idan Moshe on 07/11/2020.
//
import UIKit
import Contacts
import ContactsUI
protocol ContactsServiceDelegate: class {
func contactsPicker(_ contactsPicker: ContactsService, accessGranted: Bool, error: Error?)
func contactsPicker(_ contactsPicker: ContactsService, fetchContactsSuccess contacts: [CNContact])
func contactsPicker(_ contactsPicker: ContactsService, fetchContactsFail error: Error)
}
class ContactsService: NSObject {
static let shared = ContactsService()
weak var delegate: ContactsServiceDelegate?
let contactStore = CNContactStore()
var authorizationStatus: CNAuthorizationStatus {
return CNContactStore.authorizationStatus(for: .contacts)
}
lazy var keysToFetch: [CNKeyDescriptor] = {
return [CNContactNamePrefixKey as CNKeyDescriptor,
CNContactGivenNameKey as CNKeyDescriptor,
CNContactMiddleNameKey as CNKeyDescriptor,
CNContactFamilyNameKey as CNKeyDescriptor,
CNContactPreviousFamilyNameKey as CNKeyDescriptor,
CNContactNameSuffixKey as CNKeyDescriptor,
CNContactNicknameKey as CNKeyDescriptor,
CNContactOrganizationNameKey as CNKeyDescriptor,
CNContactDepartmentNameKey as CNKeyDescriptor,
CNContactJobTitleKey as CNKeyDescriptor,
CNContactPhoneticGivenNameKey as CNKeyDescriptor,
CNContactPhoneticMiddleNameKey as CNKeyDescriptor,
CNContactPhoneticFamilyNameKey as CNKeyDescriptor,
CNContactPhoneticOrganizationNameKey as CNKeyDescriptor,
CNContactBirthdayKey as CNKeyDescriptor,
CNContactNonGregorianBirthdayKey as CNKeyDescriptor,
/* CNContactNoteKey as CNKeyDescriptor, */ // Add entitlement - com.apple.developer.contacts.notes
CNContactImageDataKey as CNKeyDescriptor,
CNContactThumbnailImageDataKey as CNKeyDescriptor,
CNContactImageDataAvailableKey as CNKeyDescriptor,
CNContactTypeKey as CNKeyDescriptor,
CNContactPhoneNumbersKey as CNKeyDescriptor,
CNContactEmailAddressesKey as CNKeyDescriptor,
CNContactPostalAddressesKey as CNKeyDescriptor,
CNContactDatesKey as CNKeyDescriptor,
CNContactUrlAddressesKey as CNKeyDescriptor,
CNContactRelationsKey as CNKeyDescriptor,
CNContactSocialProfilesKey as CNKeyDescriptor,
CNContactInstantMessageAddressesKey as CNKeyDescriptor,
CNContactViewController.descriptorForRequiredKeys()]
}()
func requestAccess() {
switch self.authorizationStatus {
case .notDetermined:
self.contactStore.requestAccess(for: .contacts) { (accessGranted: Bool, error: Error?) in
self.delegate?.contactsPicker(self, accessGranted: accessGranted, error: error)
}
case .restricted:
self.delegate?.contactsPicker(self, accessGranted: false, error: nil)
case .denied:
self.delegate?.contactsPicker(self, accessGranted: false, error: nil)
case .authorized:
self.delegate?.contactsPicker(self, accessGranted: true, error: nil)
@unknown default: break
}
}
func findContacts(onQueue queue: DispatchQueue = .global(qos: .background), sortOrder: CNContactSortOrder = .givenName) {
queue.async {
var contacts: [CNContact] = []
let fetchRequest = CNContactFetchRequest(keysToFetch: self.keysToFetch)
fetchRequest.sortOrder = sortOrder
do {
try self.contactStore.enumerateContacts(with: fetchRequest) { (contact: CNContact, stop: UnsafeMutablePointer<ObjCBool>) in
contacts.append(contact)
}
DispatchQueue.main.async {
self.delegate?.contactsPicker(self, fetchContactsSuccess: contacts)
}
} catch let error {
DispatchQueue.main.async {
self.delegate?.contactsPicker(self, fetchContactsFail: error)
}
}
}
}
func sortContacts(contacts: [CNContact]) -> [String: [CNContact]] {
var dataSource: [String: [CNContact]] = [:]
for contact: CNContact in contacts {
if let key: Character = contact.givenName.first {
let firstLetter = String(key)
if dataSource[firstLetter] == nil {
dataSource[firstLetter] = []
}
dataSource[firstLetter]!.append(contact)
}
}
/* let sortedDataSource = dataSource.sorted { (lhs, rhs) -> Bool in
return lhs.key < rhs.key
} */
return dataSource
}
func findContacts(_ identifiers: [String]) -> [CNContact] {
let store = CNContactStore()
do {
let predicate: NSPredicate = CNContact.predicateForContacts(withIdentifiers: identifiers)
let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: self.keysToFetch)
return contacts
} catch let error {
debugPrint("Failed to fetch contact, error: \(error)")
}
return []
}
func showContact(_ contact: CNContact, navigationController: UINavigationController? = nil) {
let contactViewController = CNContactViewController(for: contact)
contactViewController.allowsEditing = false
contactViewController.allowsActions = true
contactViewController.shouldShowLinkedContacts = true
navigationController?.pushViewController(contactViewController, animated: true)
}
func showContact(_ contact: CNContact, presenter: UIViewController) {
let contactViewController = CNContactViewController(for: contact)
contactViewController.allowsEditing = false
contactViewController.allowsActions = true
contactViewController.shouldShowLinkedContacts = true
presenter.present(contactViewController, animated: true, completion: nil)
}
func showContactsPicker(delegate: CNContactPickerDelegate, presenter: UIViewController) {
let pickerViewController = CNContactPickerViewController()
pickerViewController.delegate = delegate
presenter.present(pickerViewController, animated: true, completion: nil)
}
}
|
[
-1
] |
a82d7e8732275f9208fef5d62ea0d9e8339cc278
|
d8f5b40985b61e233cadd5f15d883cf0270d1c5d
|
/MapBox-sample/DataManager/Service/AddressServiceProtocol.swift
|
0e87ac03012ed4be7e9a844afc3e89c5bec86922
|
[] |
no_license
|
benjdum59/MapBox-sample
|
a71feee90b7098db9951411109f44a2cbd7d1182
|
caa2cb24d577db82b8c94c7067f7de83df13e857
|
refs/heads/develop
| 2021-04-27T04:09:27.747874 | 2018-02-27T13:38:14 | 2018-02-27T13:38:14 | 122,726,002 | 1 | 1 | null | 2018-02-26T19:57:15 | 2018-02-24T09:37:55 |
Swift
|
UTF-8
|
Swift
| false | false | 421 |
swift
|
//
// AddressServiceProtocol.swift
// MapBox-sample
//
// Created by Benjamin DUMONT on 25/02/2018.
// Copyright © 2018 Benjamin DUMONT. All rights reserved.
//
import Foundation
import CoreLocation
protocol AddressServiceProtocol {
func searchAddresses(string: String, completion:@escaping ([Address]) -> Void)
func getAddress(coordinate:CLLocationCoordinate2D, completion:@escaping (Address?) -> Void)
}
|
[
-1
] |
93122739915460e5abe845767b039647f5674eb0
|
076e4f2e89b512a492f9851a717097106c26e3f0
|
/AmplifyPlugins/API/AWSAPICategoryPlugin/Interceptor/SubscriptionInterceptor/IAMAuthInterceptor.swift
|
8c1ecd69c8a02d169135ad7890c2991a6fed0630
|
[
"Apache-2.0"
] |
permissive
|
hakanyildizay/amplify-ios
|
23df5dac531c65289f5227eef5c3b770c1a3c3bf
|
65757ce1d169120f64de54fb8855f1d1209e7af5
|
refs/heads/main
| 2023-01-30T18:32:06.479893 | 2020-07-20T21:08:38 | 2020-07-20T21:08:38 | 281,486,823 | 1 | 1 |
Apache-2.0
| 2020-12-14T13:08:39 | 2020-07-21T19:32:32 | null |
UTF-8
|
Swift
| false | false | 6,643 |
swift
|
//
// Copyright 2018-2020 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
import Foundation
import AWSCore
import AWSPluginsCore
import Amplify
import AppSyncRealTimeClient
class IAMAuthInterceptor: AuthInterceptor {
let authProvider: AWSCredentialsProvider
let region: AWSRegionType
init(_ authProvider: AWSCredentialsProvider, region: AWSRegionType) {
self.authProvider = authProvider
self.region = region
}
func interceptMessage(_ message: AppSyncMessage, for endpoint: URL) -> AppSyncMessage {
switch message.messageType {
case .subscribe:
let authHeader = getAuthHeader(endpoint, with: message.payload?.data ?? "")
var payload = message.payload ?? AppSyncMessage.Payload()
payload.authHeader = authHeader
let signedMessage = AppSyncMessage(id: message.id,
payload: payload,
type: message.messageType)
return signedMessage
default:
Amplify.API.log.verbose("Message type does not need signing - \(message.messageType)")
}
return message
}
func interceptConnection(_ request: AppSyncConnectionRequest,
for endpoint: URL) -> AppSyncConnectionRequest {
let url = endpoint.appendingPathComponent(RealtimeProviderConstants.iamConnectPath)
let payloadString = SubscriptionConstants.emptyPayload
guard let authHeader = getAuthHeader(url, with: payloadString) else {
return request
}
let base64Auth = AppSyncJSONHelper.base64AuthenticationBlob(authHeader)
let payloadData = payloadString.data(using: .utf8)
let payloadBase64 = payloadData?.base64EncodedString()
guard var urlComponents = URLComponents(url: request.url, resolvingAgainstBaseURL: false) else {
return request
}
let headerQuery = URLQueryItem(name: RealtimeProviderConstants.header, value: base64Auth)
let payloadQuery = URLQueryItem(name: RealtimeProviderConstants.payload, value: payloadBase64)
urlComponents.queryItems = [headerQuery, payloadQuery]
guard let signedUrl = urlComponents.url else {
return request
}
let signedRequest = AppSyncConnectionRequest(url: signedUrl)
return signedRequest
}
final private func getAuthHeader(_ endpoint: URL, with payload: String) -> IAMAuthenticationHeader? {
guard let host = endpoint.host else {
return nil
}
let amzDate = NSDate.aws_clockSkewFixed() as NSDate
guard let date = amzDate.aws_stringValue(AWSDateISO8601DateFormat2) else {
return nil
}
guard let awsEndpoint = AWSEndpoint(region: region,
serviceName: SubscriptionConstants.appsyncServiceName,
url: endpoint) else {
return nil
}
let signer: AWSSignatureV4Signer = AWSSignatureV4Signer(credentialsProvider: authProvider,
endpoint: awsEndpoint)
let semaphore = DispatchSemaphore(value: 0)
let mutableRequest = NSMutableURLRequest(url: endpoint)
mutableRequest.httpMethod = "POST"
mutableRequest.addValue(RealtimeProviderConstants.iamAccept,
forHTTPHeaderField: RealtimeProviderConstants.acceptKey)
mutableRequest.addValue(date, forHTTPHeaderField: RealtimeProviderConstants.amzDate)
mutableRequest.addValue(RealtimeProviderConstants.iamEncoding,
forHTTPHeaderField: RealtimeProviderConstants.contentEncodingKey)
mutableRequest.addValue(RealtimeProviderConstants.iamConentType,
forHTTPHeaderField: RealtimeProviderConstants.contentTypeKey)
mutableRequest.httpBody = payload.data(using: .utf8)
signer.interceptRequest(mutableRequest).continueWith { _ in
semaphore.signal()
return nil
}
semaphore.wait()
let authorization = mutableRequest.allHTTPHeaderFields?[SubscriptionConstants.authorizationkey] ?? ""
let securityToken = mutableRequest.allHTTPHeaderFields?[RealtimeProviderConstants.iamSecurityTokenKey] ?? ""
let authHeader = IAMAuthenticationHeader(authorization: authorization,
host: host,
token: securityToken,
date: date,
accept: RealtimeProviderConstants.iamAccept,
contentEncoding: RealtimeProviderConstants.iamEncoding,
contentType: RealtimeProviderConstants.iamConentType)
return authHeader
}
}
/// Authentication header for IAM based auth
private class IAMAuthenticationHeader: AuthenticationHeader {
let authorization: String
let securityToken: String
let date: String
let accept: String
let contentEncoding: String
let contentType: String
init(authorization: String,
host: String,
token: String,
date: String,
accept: String,
contentEncoding: String,
contentType: String) {
self.date = date
self.authorization = authorization
self.securityToken = token
self.accept = accept
self.contentEncoding = contentEncoding
self.contentType = contentType
super.init(host: host)
}
private enum CodingKeys: String, CodingKey {
case authorization = "Authorization"
case accept
case contentEncoding = "content-encoding"
case contentType = "content-type"
case date = "x-amz-date"
case securityToken = "x-amz-security-token"
}
override func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(authorization, forKey: .authorization)
try container.encode(accept, forKey: .accept)
try container.encode(contentEncoding, forKey: .contentEncoding)
try container.encode(contentType, forKey: .contentType)
try container.encode(date, forKey: .date)
try container.encode(securityToken, forKey: .securityToken)
try super.encode(to: encoder)
}
}
|
[
-1
] |
359b5f5afc63c5f7e70a0c21167bfd84ee1ae347
|
0486c2bf775fad4aa1fc25aafe6a219b7a99d4ce
|
/Snappy/AppDelegate.swift
|
c116775ce1106fbcf8542640ef14168a44850070
|
[
"MIT"
] |
permissive
|
DroidsOnRoids/temomuko-1-ios107-tests
|
c9fa5f27865b514931b9a3c52312223731078253
|
e412f108cef026c531b7dbd733d2e3dd4b654ca3
|
refs/heads/master
| 2020-12-13T04:32:21.066064 | 2017-06-26T07:07:06 | 2017-06-26T07:07:06 | 95,414,741 | 0 | 1 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,408 |
swift
|
//
// AppDelegate.swift
// Snappy
//
// Created by Marcel Starczyk on 10/11/16.
// Copyright © 2016 Droids on Roids. 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.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let cameraViewController = storyboard.instantiateViewController(withIdentifier: "middle")
let storyViewController = storyboard.instantiateViewController(withIdentifier: "right")
let contactsViewController = storyboard.instantiateViewController(withIdentifier: "left")
let settingsViewController = storyboard.instantiateViewController(withIdentifier: "top")
let snapContainerViewController = SnapContainerViewController.containerViewWith(contactsViewController, middleViewController: cameraViewController, rightViewController: storyViewController, topViewController: settingsViewController)
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = snapContainerViewController
window?.makeKeyAndVisible()
return true
}
}
|
[
-1
] |
005ebb0389803a45d8cf975125c249c6d94f5fea
|
2c913fd6ad085b2bd6f909d5c50b7dcd5fb01895
|
/Sources/SpringItems.swift
|
5df106eb59a8117aa37a35f4adb2050ff4d02945
|
[
"Apache-2.0"
] |
permissive
|
ShabanKamell/SpringMenu
|
e2b3ccd8c11e6ae2a06a61d4d55b6355cc614148
|
26dbc4ea0da8c15e1ffe6c44398e5d66c7cca73a
|
refs/heads/master
| 2023-06-03T10:38:16.092795 | 2021-06-23T00:26:21 | 2021-06-23T00:26:21 | 373,620,829 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 10,554 |
swift
|
//
// Created by Shaban on 05/06/2021.
// Copyright (c) 2021 sha. All rights reserved.
//
import SwiftUI
struct SpringItems {
let items: [SpringItem]
}
extension SpringItems {
static func from(_ input: TwoSpringItems, position: TwoSpringItems.Position) -> SpringItems {
var items = input
let array: [SpringItem]
switch position {
case .top:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .topRight),
SpringItem.placeholder(direction: .bottomLeft),
SpringItem.placeholder(direction: .bottomRight)]
case .bottom:
array = [items.item1.with(direction: .bottomLeft),
items.item2.with(direction: .bottomRight),
SpringItem.placeholder(direction: .topLeft),
SpringItem.placeholder(direction: .topRight)]
case .horizontal:
array = [items.item1.with(direction: .leading),
items.item2.with(direction: .trailing),
SpringItem.placeholder(direction: .top),
SpringItem.placeholder(direction: .bottom)]
case .vertical:
array = [items.item1.with(direction: .top),
items.item2.with(direction: .bottom),
SpringItem.placeholder(direction: .leading),
SpringItem.placeholder(direction: .trailing)]
}
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: ThreeSpringItems, position: ThreeSpringItems.Position) -> SpringItems {
var items = input
let array: [SpringItem]
switch position {
case .top:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .top),
items.item3.with(direction: .topRight),
SpringItem.placeholder(direction: .bottom),
SpringItem.placeholder(direction: .bottomLeft),
SpringItem.placeholder(direction: .bottomRight),
]
case .bottom:
array = [items.item1.with(direction: .bottomLeft),
items.item2.with(direction: .bottom),
items.item3.with(direction: .bottomRight),
SpringItem.placeholder(direction: .top),
SpringItem.placeholder(direction: .topLeft),
SpringItem.placeholder(direction: .topRight)
]
case .leading:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .leading),
items.item3.with(direction: .bottomLeft),
SpringItem.placeholder(direction: .trailing),
SpringItem.placeholder(direction: .topRight),
SpringItem.placeholder(direction: .bottomRight)]
case .trailing:
array = [items.item1.with(direction: .topRight),
items.item2.with(direction: .trailing),
items.item3.with(direction: .bottomRight),
SpringItem.placeholder(direction: .leading),
SpringItem.placeholder(direction: .bottomLeft),
SpringItem.placeholder(direction: .topLeft)]
}
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: FourSpringItems) -> SpringItems {
var items = input
let array: [SpringItem]
array = [items.item1.with(direction: .leading),
items.item2.with(direction: .top),
items.item3.with(direction: .trailing),
items.item4.with(direction: .bottom)]
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: FiveSpringItems, gravity: FiveSpringItems.Gravity) -> SpringItems {
var items = input
let array: [SpringItem]
switch gravity {
case .top:
array = [items.item1.with(direction: .leading),
items.item2.with(direction: .topLeft),
items.item3.with(direction: .top),
items.item4.with(direction: .topRight),
items.item5.with(direction: .trailing),
SpringItem.placeholder(direction: .bottom),
SpringItem.placeholder(direction: .bottomLeft),
SpringItem.placeholder(direction: .bottomRight)
]
case .bottom:
array = [items.item1.with(direction: .leading),
items.item2.with(direction: .bottomLeft),
items.item3.with(direction: .bottom),
items.item4.with(direction: .bottomRight),
items.item5.with(direction: .trailing),
SpringItem.placeholder(direction: .top),
SpringItem.placeholder(direction: .topLeft),
SpringItem.placeholder(direction: .topRight)
]
case .leading:
array = [items.item1.with(direction: .top),
items.item2.with(direction: .topLeft),
items.item3.with(direction: .leading),
items.item4.with(direction: .bottomLeft),
items.item5.with(direction: .bottom),
SpringItem.placeholder(direction: .trailing),
SpringItem.placeholder(direction: .topRight),
SpringItem.placeholder(direction: .bottomRight)
]
case .trailing:
array = [items.item1.with(direction: .bottom),
items.item2.with(direction: .bottomRight),
items.item3.with(direction: .trailing),
items.item4.with(direction: .topRight),
items.item5.with(direction: .top),
SpringItem.placeholder(direction: .leading),
SpringItem.placeholder(direction: .topLeft),
SpringItem.placeholder(direction: .bottomLeft)
]
}
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: SixSpringItems, position: SixSpringItems.Position) -> SpringItems {
var items = input
let array: [SpringItem]
switch position {
case .vertical:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .leading),
items.item3.with(direction: .bottomLeft),
items.item4.with(direction: .topRight),
items.item5.with(direction: .trailing),
items.item6.with(direction: .bottomRight),
SpringItem.placeholder(direction: .top),
SpringItem.placeholder(direction: .bottom)]
case .horizontal:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .top),
items.item3.with(direction: .topRight),
items.item4.with(direction: .bottomLeft),
items.item5.with(direction: .bottom),
items.item6.with(direction: .bottomRight),
SpringItem.placeholder(direction: .leading),
SpringItem.placeholder(direction: .trailing)]
}
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: SevenSpringItems, gravity: SevenSpringItems.Gravity) -> SpringItems {
var items = input
let array: [SpringItem]
switch gravity {
case .top:
array = [items.item1.with(direction: .bottomLeft),
items.item2.with(direction: .leading),
items.item3.with(direction: .topLeft),
items.item4.with(direction: .top),
items.item5.with(direction: .topRight),
items.item6.with(direction: .trailing),
items.item7.with(direction: .bottomRight),
SpringItem.placeholder(direction: .bottom)]
case .bottom:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .leading),
items.item3.with(direction: .bottomLeft),
items.item4.with(direction: .bottom),
items.item5.with(direction: .bottomRight),
items.item6.with(direction: .trailing),
items.item7.with(direction: .topRight),
SpringItem.placeholder(direction: .top)]
case .leading:
array = [items.item1.with(direction: .topRight),
items.item2.with(direction: .top),
items.item3.with(direction: .topLeft),
items.item4.with(direction: .leading),
items.item5.with(direction: .bottomLeft),
items.item6.with(direction: .bottom),
items.item7.with(direction: .bottomRight),
SpringItem.placeholder(direction: .trailing)]
case .trailing:
array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .top),
items.item3.with(direction: .topRight),
items.item4.with(direction: .trailing),
items.item5.with(direction: .bottomRight),
items.item6.with(direction: .bottom),
items.item7.with(direction: .bottomLeft),
SpringItem.placeholder(direction: .leading)]
}
return SpringItems(items: array)
}
}
extension SpringItems {
static func from(_ input: EightSpringItems) -> SpringItems {
var items = input
let array = [items.item1.with(direction: .topLeft),
items.item2.with(direction: .top),
items.item3.with(direction: .topRight),
items.item4.with(direction: .trailing),
items.item5.with(direction: .bottomRight),
items.item6.with(direction: .bottom),
items.item7.with(direction: .bottomLeft),
items.item8.with(direction: .leading)]
return SpringItems(items: array)
}
}
|
[
-1
] |
41f8bf074b52b95665af217c373ee11b1774b453
|
e3899125df32d6a1036f6e01389ee5857253041f
|
/searchbar4/ViewController.swift
|
945d7c2cc036fd3fbdf961dd56178f66b93d9eb3
|
[] |
no_license
|
hayounlim/AvocaDonate
|
0db93493a29547c953f06b6f3d7e9fa032a8ea67
|
eb9e5f9a5bc69e40535446573e9c6d7d0755b05e
|
refs/heads/master
| 2021-04-24T15:29:44.753653 | 2016-08-12T16:08:49 | 2016-08-12T16:08:49 | 65,566,110 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 7,859 |
swift
|
//
// ViewController.swift
// searchbar4
//
// Created by GEGWC8 on 8/3/16.
// Copyright © 2016 GEGWC8. All rights reserved.
//
import UIKit
protocol CandySelectionDelegate: class {
func candySelected(newCandy: Candy)
}
class ViewController: UITableViewController, UISearchResultsUpdating {
var candies = [Candy]()
var searchController: UISearchController!
var resultsController = UITableViewController()
var filteredCandies = [Candy]()
weak var delegate: CandySelectionDelegate?
func resizeImage(image:UIImage, toTheSize size:CGSize)->UIImage{
let scale = CGFloat(max(size.width/image.size.width,
size.height/image.size.height))
let width:CGFloat = image.size.width * scale
let height:CGFloat = image.size.height * scale;
let rr:CGRect = CGRectMake( 0, 0, width, height);
UIGraphicsBeginImageContextWithOptions(size, false, 0);
image.drawInRect(rr)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
return newImage
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.candies.append(Candy(address:"225 Potrero Avenue, San Francisco, CA 94103", name:"Martin de Porres", food:["","carrots","noodles", "rice"], picture: "orgmartindeporres.jpg", email:"info@martindeporres.org", phonenum:"(415) 552-0240",website:"http://martindeporres.org"))
self.candies.append(Candy(address:"7900 Edgewater Drive, Oakland, CA 94621", name:"Alameda County Food Bank", food:["","bananas","apples"], picture: "orgalamedacountyfoodbank.jpg", email:"info@accfb.org", phonenum:"(510) 635-3663",website:"http://www.accfb.org/"))
self.candies.append(Candy(address:"4010 Nelson Ave, Concord, CA 94520", name:"Contra Costa Food Bank", food:["","water","coke"], picture: "orgcontracostafoodbank.jpg", email:"info@foodbankccs.org", phonenum:"(925) 676-7543",website:"https://www.foodbankccs.org/"))
self.candies.append(Candy(address:"835 Ferry Street, Martinez, CA 94553", name:"Loaves and Fishes", food:["","sprite","sandwiches"], picture: "orgloavesandfishes.jpg", email:"info@loavesfishescc.org", phonenum:"(925) 293 - 4792",website:"http://www.loavesfishescc.org/"))
self.candies.append(Candy(address:"123 Macdonald Avenue, Richmond, CA 94801", name:"Bay Area Rescue Mission", food:["","milk","bread"], picture: "orgbayarearescuemission.jpg", email:"info@bayarearescue.org", phonenum:"(510) 215-4887",website:"http://www.bayarearescue.org/"))
// self.candies.append(Candy(category:"Hard", name:"Organization", food:["","rice","brown rice"], picture: "org"))
// self.candies.append(Candy(category:"Hard", name:"Organization", food:["","salads","pies"]))
// self.candies.append(Candy(category:"Other", name:"Organization", food:["","apple juice","coffee"]))
// self.candies.append(Candy(category:"Other", name:"Organization", food:["","chips","watermelon"]))
// self.candies.append(Candy(category:"Other", name:"Organization", food:["","cakes","pineapples"]))
}
override func viewDidLoad() {
super.viewDidLoad()
self.resultsController.tableView.dataSource = self
self.resultsController.tableView.delegate = self
// self.searchController = UISearchController(searchResultsController: self.resultsController)
// self.tableView.tableHeaderView = self.searchController.searchBar
// self.searchController.searchResultsUpdater = self
// self.searchController.dimsBackgroundDuringPresentation = true
// definesPresentationContext = true
//back button
let button = UIButton(type: .System) // let preferred over var here
button.frame = CGRectMake(2, 20, 70, 30)
button.backgroundColor = UIColor.clearColor()
button.setTitle("< Back", forState: UIControlState.Normal)
button.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
button.addTarget(self, action: "pressed:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(button)
}
//button action
func pressed(sender: UIButton!) {
self.performSegueWithIdentifier("toHome", sender: self)
//self.dismissViewControllerAnimated(true, completion:nil);
}
func updateSearchResultsForSearchController(searchController: UISearchController) {
self.filteredCandies = self.candies.filter {(candies:Candy) -> Bool in
if candies.name.lowercaseString.containsString(self.searchController.searchBar.text!.lowercaseString) {
return true
}
else if candies.address.lowercaseString.containsString(self.searchController.searchBar.text!.lowercaseString){
return true
}
else {
return false
}
}
self.resultsController.tableView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == self.tableView {
return self.candies.count
} else {
return self.filteredCandies.count
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomTableViewCell
var candy:Candy
if tableView == self.tableView {
candy = candies[indexPath.row]
cell.labUerName.text = candy.name
let imageName = candy.picture
let image = UIImage(named: imageName)
let newImage = resizeImage(image!, toTheSize: CGSizeMake(80, 80))
let cellImageLayer: CALayer? = cell.imgUser.layer
cellImageLayer!.cornerRadius = cellImageLayer!.frame.size.width / 2
cellImageLayer!.masksToBounds = true
cell.imgUser.image = newImage
}
else {
candy = filteredCandies[indexPath.row]
cell.labUerName.text = candy.name
let imageName = candy.name
let image = UIImage(named: imageName)
let newImage = resizeImage(image!, toTheSize: CGSizeMake(80, 80))
let cellImageLayer: CALayer? = cell.imgUser.layer
cellImageLayer!.cornerRadius = cellImageLayer!.frame.size.width / 2
cellImageLayer!.masksToBounds = true
cell.imgUser.image = newImage
}
return cell
}
override func tableView(tableView: UITableView,
heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 100
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let selectedCandy = self.candies[indexPath.row]
self.delegate?.candySelected(selectedCandy)
if let detailViewController = self.delegate as? DetailViewController {
splitViewController?.showDetailViewController(detailViewController.navigationController!, sender: nil)
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "toDetailPage",
let destination = segue.destinationViewController as? DetailViewController,
index = tableView.indexPathForSelectedRow?.row
{
destination.candy = candies[index]
}
}
}
|
[
-1
] |
a357fca17a9db20145e2846d026c7f09237e9e85
|
8ae2963869955e3189207cb98fd264d8ecabf30a
|
/LibraryOfAlexandria/SearchTableViewCell.swift
|
0c89803e8206a99a27a7832a63e1e5cf1ab4f455
|
[] |
no_license
|
jinxinrui/LibraryOfAlexandriaMain
|
0318b0254bbbd2f100097f2bdac26e28d89dde16
|
9b49e0c0e5f03ba39f34cef5a8b219038f2d6c44
|
refs/heads/master
| 2020-03-10T17:49:16.630799 | 2018-04-17T10:16:47 | 2018-04-17T10:16:47 | 129,509,345 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 592 |
swift
|
//
// BookTableViewCell.swift
// LibraryOfAlexandria
//
// Created by Jxr on 13/4/18.
// Copyright © 2018 xjin0001. All rights reserved.
//
import UIKit
class SearchTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var authorLabel: 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
}
}
|
[
320001,
337412,
227845,
333831,
227849,
227852,
333837,
372750,
372753,
196114,
372754,
327190,
328214,
287258,
370207,
243746,
287266,
281636,
327224,
327225,
307277,
327248,
235604,
235611,
213095,
213097,
310894,
213109,
148600,
403068,
410751,
300672,
373913,
148637,
148638,
276639,
148648,
300206,
361651,
327360,
223437,
291544,
306907,
337627,
176358,
271087,
325874,
338682,
276746,
276756,
203542,
261406,
349470,
396065,
111912,
369458,
369461,
282934,
342850,
342851,
151881,
430412,
283471,
283472,
270679,
287067,
350050,
270691,
257898,
330602,
179568,
317296,
317302,
244600,
179578,
179580,
211843,
213891,
36743,
209803,
211370,
288690,
281014,
430546,
430547,
180695,
180696,
284131,
344039,
196076,
310778,
305661
] |
56f75c31035733291bd7878af7dd417a888ab5b1
|
426cc7b1b2f218f2f4b8a4108130d49c938f1423
|
/Checklist/Scenes/AddItem/ItemDetailViewController.swift
|
180dbc7aa6eeba03292f06b227502f388d784f16
|
[] |
no_license
|
laza992/Checklist
|
bad48345d653089adaff937c7bd7c38a99ad5871
|
24fafe6c63df70955fdfb6090ab1eb7a09a1dec0
|
refs/heads/master
| 2022-11-05T03:26:56.721163 | 2020-06-08T08:53:03 | 2020-06-08T08:53:03 | 270,594,398 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 6,964 |
swift
|
//
// ItemDetailViewController.swift
// Checklist
//
// Created by Lazar Stojkovic on 5/29/20.
// Copyright © 2020 lazar. All rights reserved.
//
import UIKit
import UserNotifications
protocol ItemDetailViewControllerDelegate: class {
func ItemDetailViewControllerDidCancel(_ controller: ItemDetailViewController)
func ItemDetailViewController(_ controller: ItemDetailViewController, didFinishAdding item: ChecklistItem)
func ItemDetailViewController(_ controller: ItemDetailViewController, didFinishEditing item: ChecklistItem)
}
class ItemDetailViewController: UITableViewController {
// MARK: - Outltes
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var doneBarButton: UIBarButtonItem!
@IBOutlet weak var shouldRemindSwitch: UISwitch!
@IBOutlet weak var dueDateLabel: UILabel!
@IBOutlet var datePickerCell: UITableViewCell!
@IBOutlet weak var datePicker: UIDatePicker!
// MARK: - Properties
weak var delegate: ItemDetailViewControllerDelegate?
var itemToEdit: ChecklistItem?
var dueDate = Date()
var datePickerVisible = false
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
if let item = itemToEdit {
title = "Edit Item"
textField.text = item.text
doneBarButton.isEnabled = true
shouldRemindSwitch.isOn = item.shouldRemind
dueDate = item.dueDate
}
updateDueDateLabel()
navigationItem.largeTitleDisplayMode = .never
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
textField.becomeFirstResponder()
}
// MARK: - Private methods
private func updateDueDateLabel() {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
dueDateLabel.text = formatter.string(from: dueDate)
}
private func showDatePicker() {
datePickerVisible = true
let indexPathDateRow = IndexPath(row: 1, section: 1)
let indexPathDatePicker = IndexPath(row: 2, section: 1)
tableView.beginUpdates()
tableView.insertRows(at: [indexPathDatePicker], with: .fade)
tableView.reloadRows(at: [indexPathDateRow], with: .none)
tableView.endUpdates()
datePicker.setDate(dueDate, animated: false)
}
func hideDatePicker() {
if datePickerVisible {
datePickerVisible = false
let indexPathDateRow = IndexPath(row: 1, section: 1)
let indexPathDatePicker = IndexPath(row: 2, section: 1)
tableView.beginUpdates()
tableView.reloadRows(at: [indexPathDateRow], with: .none)
tableView.deleteRows(at: [indexPathDatePicker], with: .fade)
tableView.endUpdates()
}
}
// MARK: - Actions
@IBAction func cancelAction(_ sender: Any) {
delegate?.ItemDetailViewControllerDidCancel(self)
}
@IBAction func dateChanged(_ sender: Any) {
dueDate = datePicker.date
updateDueDateLabel()
}
@IBAction func shouldRemindToggled(_ switchControl: UISwitch) {
textField.resignFirstResponder()
if switchControl.isOn {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound]) {
granted, error in
// do nothing
}
}
}
@IBAction func doneAction(_ sender: Any) {
if let item = itemToEdit {
item.text = textField.text!
item.shouldRemind = shouldRemindSwitch.isOn
item.dueDate = dueDate
delegate?.ItemDetailViewController(self, didFinishEditing: item)
} else {
let item = ChecklistItem()
item.text = textField.text!
item.checked = false
item.shouldRemind = shouldRemindSwitch.isOn
item.dueDate = dueDate
item.scheduleNotification()
delegate?.ItemDetailViewController(self, didFinishAdding: item)
}
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 1 && datePickerVisible {
return 3
} else {
return super.tableView(tableView, numberOfRowsInSection: section)
}
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 1 && indexPath.row == 2 {
return 217
} else {
return super.tableView(tableView, heightForRowAt: indexPath)
}
}
override func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int {
var newIndexPath = indexPath
if indexPath.section == 1 && indexPath.row == 2 {
newIndexPath = IndexPath(row: 0, section: indexPath.section)
}
return super.tableView(tableView, indentationLevelForRowAt: newIndexPath)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 1 && indexPath.row == 2 {
return datePickerCell
} else {
return super.tableView(tableView, cellForRowAt: indexPath)
}
}
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if indexPath.section == 1 && indexPath.row == 1 {
return indexPath
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
textField.resignFirstResponder()
if indexPath.section == 1 && indexPath.row == 1 {
if !datePickerVisible {
showDatePicker()
} else {
hideDatePicker()
}
}
}
}
// MARK: - UITextFieldDelegate
extension ItemDetailViewController: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let oldText = textField.text!
let stringRange = Range(range, in:oldText)!
let newText = oldText.replacingCharacters(in: stringRange, with: string)
if newText.isEmpty {
doneBarButton.isEnabled = false
} else {
doneBarButton.isEnabled = true
}
return true
}
func textFieldDidBeginEditing(_ textField: UITextField) {
hideDatePicker()
}
}
|
[
296928,
297380,
296934,
293895
] |
82a9de0676e26363225066d96b35c5e6f86ed37c
|
138cc9893120f0ad8210624eb9762b4d467a0a21
|
/FreshFruit/AppDelegate.swift
|
9a1f7823f105837eeb38ad949dcfb4d332b4fcd6
|
[] |
no_license
|
jliussuweno/FreshFruit
|
f92f133e2d00a2fd2ac486ba38678bff82d7bdc8
|
8f352e81f1110704f574dda9021555f450cc9b7f
|
refs/heads/main
| 2022-12-19T21:38:38.340278 | 2020-10-12T15:02:55 | 2020-10-12T15:02:55 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,350 |
swift
|
//
// AppDelegate.swift
// FreshFruit
//
// Created by Jlius Suweno on 06/10/20.
//
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
|
[
393222,
393224,
393230,
393250,
344102,
393261,
393266,
213048,
385081,
376889,
393275,
376905,
254030,
286800,
368727,
180313,
368735,
180320,
376931,
286831,
368752,
286844,
417924,
262283,
286879,
286888,
377012,
164028,
327871,
377036,
180431,
377046,
418010,
377060,
205036,
393456,
393460,
418043,
336123,
385280,
336128,
262404,
180490,
164106,
368911,
262416,
262422,
377117,
262436,
336180,
262454,
393538,
262472,
344403,
213332,
65880,
262496,
418144,
262499,
213352,
246123,
262507,
262510,
213372,
385419,
393612,
262550,
262552,
385440,
385443,
385451,
262573,
393647,
385458,
262586,
344511,
262592,
360916,
369118,
328177,
328179,
328182,
328189,
328192,
164361,
410128,
393747,
254490,
188958,
385570,
33316,
377383,
197159,
352821,
197177,
418363,
188987,
369223,
385609,
385616,
352864,
369253,
262760,
352874,
352887,
254587,
377472,
148105,
377484,
352918,
98968,
344744,
361129,
336555,
385713,
434867,
164534,
336567,
164538,
352968,
344776,
352971,
418507,
352973,
385742,
385748,
361179,
189153,
369381,
361195,
418553,
344831,
336643,
344835,
344841,
361230,
336659,
418580,
418585,
434970,
369435,
418589,
262942,
418593,
336675,
328484,
418598,
418605,
336696,
361273,
328515,
328519,
361288,
336711,
328522,
426841,
254812,
361309,
197468,
361315,
361322,
328573,
377729,
369542,
361360,
222128,
345035,
386003,
345043,
386011,
386018,
386022,
435187,
328702,
328714,
361489,
386069,
386073,
336921,
336925,
345118,
377887,
345133,
345138,
386101,
361536,
189520,
345169,
156761,
361567,
148578,
345199,
386167,
361593,
410745,
361598,
214149,
345222,
386186,
337047,
345246,
214175,
337075,
386258,
328924,
66782,
222437,
386285,
328941,
386291,
345376,
353570,
345379,
410917,
345382,
345399,
378169,
369978,
337222,
337229,
337234,
263508,
402791,
345448,
271730,
378227,
271745,
181638,
353673,
181643,
181649,
181654,
230809,
181670,
181673,
181678,
181681,
337329,
181684,
181690,
361917,
181696,
337349,
181703,
337365,
271839,
329191,
361960,
329194,
116210,
337415,
329226,
419339,
419343,
419349,
345625,
419355,
370205,
419359,
394786,
419362,
370213,
419368,
419376,
206395,
214593,
419400,
419402,
353867,
419406,
419410,
394853,
345701,
222830,
370297,
403075,
345736,
198280,
403091,
345749,
419483,
345757,
345762,
419491,
345765,
419497,
419501,
370350,
419506,
419509,
419512,
337592,
419517,
337599,
419527,
419530,
419535,
272081,
419542,
394966,
419544,
181977,
345818,
419547,
419550,
419559,
337642,
419563,
337645,
370415,
337659,
362247,
395021,
362255,
116509,
345887,
378663,
345905,
354106,
354111,
247617,
354117,
370503,
329544,
370509,
354130,
247637,
337750,
370519,
313180,
354142,
354150,
354156,
345964,
345967,
345970,
345974,
403320,
354172,
247691,
337808,
247700,
329623,
436126,
436132,
337833,
362413,
337844,
346057,
247759,
346063,
329697,
354277,
190439,
247789,
354313,
346139,
436289,
378954,
395339,
338004,
100453,
329832,
329855,
329867,
329885,
346272,
362660,
100524,
387249,
379066,
387260,
256191,
395466,
346316,
411861,
411864,
411868,
411873,
379107,
411876,
387301,
338152,
387306,
387312,
346355,
436473,
321786,
379134,
411903,
411916,
379152,
395538,
387349,
338199,
387352,
182558,
338211,
248111,
362822,
436555,
190796,
379233,
354673,
321910,
248186,
420236,
379278,
272786,
354727,
338352,
330189,
338381,
338386,
338403,
338409,
248308,
199164,
330252,
199186,
330267,
354855,
10828,
199249,
346721,
174695,
248425,
191084,
338543,
191092,
346742,
330383,
354974,
150183,
248504,
223934,
355024,
273108,
355028,
264918,
183005,
256734,
436962,
338660,
338664,
264941,
363251,
207619,
264964,
338700,
256786,
199452,
363293,
396066,
346916,
396069,
215853,
355122,
355131,
355140,
355143,
338763,
355150,
330580,
355166,
265055,
265058,
355175,
387944,
355179,
330610,
330642,
355218,
412599,
207808,
379848,
396245,
330710,
248792,
248798,
257008,
183282,
265207,
330748,
265214,
330760,
330768,
248862,
396328,
347176,
158761,
199728,
396336,
330800,
396339,
339001,
388154,
388161,
347205,
330826,
412764,
339036,
257120,
265320,
248951,
420984,
330889,
347287,
339097,
248985,
44197,
380070,
339112,
249014,
126144,
330958,
330965,
265432,
265436,
388319,
388347,
175375,
175396,
208166,
273708,
347437,
372015,
347441,
372018,
199988,
44342,
175415,
396600,
437566,
175423,
437570,
437575,
437583,
331088,
437587,
331093,
396633,
175450,
437595,
175457,
208227,
175460,
175463,
265580,
437620,
175477,
249208,
175483,
175486,
249214,
175489,
249218,
249224,
249227,
249234,
175513,
175516,
396705,
175522,
355748,
380332,
396722,
208311,
372163,
216517,
380360,
216522,
339404,
372176,
208337,
339412,
413141,
339417,
339420,
249308,
339424,
249312,
339428,
339434,
249328,
69113,
372228,
208398,
380432,
175635,
265778,
265795,
396872,
265805,
224853,
224857,
257633,
224870,
372327,
257646,
372337,
224884,
224887,
224890,
224894,
224897,
372353,
216707,
126596,
421508,
224904,
11918,
224913,
126610,
339601,
224916,
224919,
126616,
224922,
208538,
224926,
224929,
224932,
224936,
257704,
224942,
257712,
224947,
257716,
257720,
257724,
224959,
257732,
224965,
224969,
339662,
224975,
257747,
224981,
224986,
257761,
224993,
257764,
224999,
339695,
225012,
257787,
225020,
339710,
257790,
225025,
257794,
257801,
339721,
257804,
225038,
257807,
225043,
372499,
167700,
225048,
257819,
225053,
184094,
225058,
257833,
225066,
257836,
413484,
225070,
225073,
372532,
257845,
225079,
397112,
225082,
397115,
225087,
225092,
225096,
323402,
257868,
225103,
257871,
397139,
225108,
225112,
257883,
257886,
225119,
257890,
225127,
274280,
257896,
257901,
225137,
257908,
225141,
257912,
225148,
257916,
257920,
225155,
339844,
225165,
397200,
225170,
380822,
225175,
225180,
184244,
372664,
372702,
372706,
356335,
380918,
372738,
405533,
430129,
266294,
421960,
356439,
430180,
421990,
266350,
356466,
266362,
381068,
225423,
250002,
250004,
225429,
356506,
225437,
135327,
225441,
438433,
225444,
438436,
225447,
438440,
225450,
258222,
225455,
430256,
225458,
225461,
225466,
389307,
225470,
381120,
372929,
430274,
225475,
389320,
225484,
225487,
225490,
266453,
225493,
225496,
225499,
225502,
225505,
356578,
225510,
225514,
225518,
372976,
381176,
397571,
389380,
356637,
356640,
356643,
356646,
266536,
356649,
356655,
332080,
340275,
356660,
397622,
332090,
225597,
332097,
201028,
348488,
332106,
348502,
250199,
250202,
332125,
250210,
348522,
348525,
348527,
332152,
389502,
250238,
356740,
373145,
340379,
389550,
266687,
160234,
127471,
340472,
324094,
266754,
324111,
340500,
381481,
356907,
324142,
356916,
324149,
324155,
348733,
324164,
356934,
348743,
381512,
324173,
324176,
389723,
332380,
373343,
381545,
340627,
184982,
373398,
258721,
332453,
332459,
389805,
332463,
381617,
332471,
332483,
332486,
373449,
332493,
357069,
357073,
332511,
332520,
340718,
332533,
348924,
389892,
373510,
389926,
348978,
152370,
340789,
348982,
398139,
127814,
357201,
357206,
389978,
430939,
357211,
357214,
201579,
201582,
349040,
340849,
201588,
430965,
381813,
324472,
398201,
340858,
324475,
430972,
340861,
324478,
119674,
324481,
373634,
398211,
324484,
324487,
381833,
324492,
324495,
324498,
430995,
324501,
324510,
422816,
324513,
398245,
201637,
324524,
340909,
324533,
324538,
324541,
398279,
340939,
340941,
209873,
340957,
431072,
398306,
340963,
209895,
201711,
349172,
349180,
439294,
431106,
209943,
357410,
250914,
185380,
357418,
209965,
209968,
209971,
209975,
209979,
209987,
209990,
209995,
341071,
349267,
250967,
210010,
341091,
210025,
210027,
210030,
210036,
210039,
349308,
210044,
349311,
160895,
152703,
210052,
349319,
210055,
218247,
210067,
210071,
210077,
210080,
251044,
210084,
185511,
210088,
210095,
210098,
210107,
210115,
332997,
210127,
333009,
210131,
333014,
210138,
210143,
218354,
218360,
251128,
275706,
275712,
275715,
275721,
349459,
333078,
251160,
349484,
349491,
251189,
415033,
251210,
357708,
210260,
365911,
259421,
365921,
333154,
251235,
374117,
333162,
234866,
390516,
333175,
357755,
136590,
374160,
112020,
349590,
357792,
259515,
415166,
415185,
366034,
366038,
415191,
415193,
415196,
415199,
423392,
333284,
415207,
366056,
366061,
415216,
210420,
415224,
423423,
415257,
415263,
366117,
415270,
144939,
415278,
415281,
415285,
210487,
415290,
415293,
349761,
415300,
333386,
366172,
333413,
423528,
423532,
210544,
415353,
415361,
267909,
210631,
333511,
358099,
333534,
366307,
366311,
431851,
366318,
210672,
366321,
366325,
210695,
268041,
210698,
366348,
210706,
399128,
210719,
358191,
366387,
210739,
399159,
358200,
325440,
366401,
341829,
325446,
46920,
341834,
341838,
341843,
415573,
358234,
341851,
350045,
399199,
259938,
399206,
268143,
358255,
399215,
358259,
341876,
243579,
325504,
333698,
333708,
333724,
382890,
350146,
333774,
358371,
350189,
350193,
350202,
350206,
350213,
268298,
350224,
350231,
333850,
350237,
350240,
350244,
350248,
178218,
350251,
350256,
350259,
350271,
243781,
350285,
374864,
342111,
374902,
432271,
260289,
260298,
350410,
350416,
350422,
211160,
350425,
334045,
350445,
375026,
358644,
350461,
350464,
325891,
350467,
350475,
375053,
268559,
350480,
432405,
350486,
325914,
350490,
325917,
350493,
350498,
194852,
350504,
358700,
391468,
350509,
358704,
358713,
358716,
383306,
334161,
383321,
383330,
383333,
391530,
383341,
334203,
268668,
194941,
391563,
366990,
416157,
342430,
268701,
375208,
375216,
334262,
334275,
326084,
358856,
195039,
334304,
334311,
375277,
334321,
350723,
391690,
186897,
334358,
342550,
342554,
334363,
350761,
252461,
334384,
383536,
358961,
334394,
252482,
219718,
334407,
334420,
350822,
375400,
334465,
334468,
162445,
326290,
342679,
342683,
260766,
342710,
244409,
260797,
260801,
350917,
391894,
154328,
416473,
64230,
342766,
375535,
203506,
342776,
391937,
391948,
375568,
375571,
375574,
162591,
326441,
383793,
326451,
326454,
326460,
260924,
375612,
244540,
326467,
244551,
326473,
326477,
326485,
416597,
326490,
342874,
326502,
375656,
433000,
326507,
326510,
211825,
211831,
351097,
392060,
359295,
351104,
342915,
400259,
236430,
342930,
252822,
392091,
400285,
252836,
359334,
400306,
351168,
359361,
326598,
359366,
359382,
359388,
383967,
343015,
359407,
261108,
244726,
261111,
383997,
261129,
359451,
261147,
211998,
261153,
261159,
359470,
359476,
343131,
384098,
384101,
384107,
367723,
187502,
343154,
384114,
212094,
351364,
384135,
384139,
384143,
351381,
384160,
384168,
367794,
384181,
367800,
384191,
351423,
326855,
253130,
343244,
146642,
359649,
351466,
351479,
343306,
261389,
359694,
253200,
261393,
384275,
245020,
245029,
171302,
351534,
376110,
245040,
425276,
384323,
212291,
343365,
212303,
367965,
343393,
343398,
367980,
425328,
343409,
253303,
154999,
343417,
327034,
245127,
384397,
245136,
245142,
245145,
343450,
245148,
245151,
245154,
245157,
245162,
327084,
359865,
384443,
146876,
327107,
384453,
327115,
327117,
359886,
359890,
343507,
368092,
343534,
343539,
368119,
343544,
368122,
409091,
359947,
359955,
359983,
343630,
179802,
155239,
327275,
245357,
138864,
155254,
155273,
368288,
245409,
425638,
425649,
155322,
425662,
155327,
155351,
155354,
212699,
155363,
155371,
245483,
409335,
155393,
155403,
155422,
360223,
155438,
155442,
155447,
417595,
155461,
360261,
376663,
155482,
261981,
425822,
155487,
376671,
155490,
155491,
327531,
261996,
376685,
261999,
262002,
327539,
262005,
147317,
425845,
262008,
262011,
155516,
155521,
155525,
360326,
155531,
262027,
262030,
262033,
262036,
262039,
262042,
155549,
262045,
262048,
262051,
327589,
155559,
155562,
155565,
393150,
393169,
155611,
155619,
253923,
155621,
253926,
204784,
393203,
360438,
253943,
393206,
393212,
155646
] |
2cdd4f18e4bfca24be33c51e7522f846ce4c39c0
|
8e426e542334eabc857e0f25cc7f085cdbe6e8d2
|
/ReduxModule/Redux/ReduceStore/StoreProvider/ReduceStoreProvider.swift
|
d1def56f573df496f7ed990c92580b2d49eece3f
|
[] |
no_license
|
mariusjcb/CrossReduxSOA
|
232a4a249d4023e85c654ca944a74548ba680552
|
629602418f50d21f4fefdb5643a9554e741aa551
|
refs/heads/master
| 2021-07-02T20:18:19.876975 | 2021-01-17T14:29:30 | 2021-01-17T14:29:30 | 216,480,178 | 2 | 0 | null | 2019-10-25T10:32:14 | 2019-10-21T04:52:16 |
Swift
|
UTF-8
|
Swift
| false | false | 4,568 |
swift
|
//
// StoreProvider.swift
// CrossReduxSOA
//
// Created by Marius Ilie on 21/10/2019.
// Copyright © 2019 Marius Ilie. All rights reserved.
//
import Foundation
public protocol ReduceStoreProvider: ReduceStoreInitializable, RxReduceStoreProvider, CombineReduceStoreProvider, ReduceStoreOutputDelegate {
func dispatch(action: ReducerType.ActionType, await: Bool)
func syncStore<T: ReduceStore>(_ store: T?,
with currentState: T.ReducerType.StateType?,
error: T.ReducerType.ErrorType?)
func syncStore<T>(_ store: T?,
onDispatch action: T.ReducerType.ActionType?) where T : ReduceStore
init()
/** Plase do not dispatch actions on Initializers or Setup methods it will desync Combine and Rx stores. */
init(_ initialState: ReducerType.StateType, reducer: ReducerType, outputDelegates: [ReduceStoreOutputDelegate])
}
public extension ReduceStoreProvider {
func syncStore<T>(_ store: T?,
with currentState: T.ReducerType.StateType?,
error: T.ReducerType.ErrorType?) where T : ReduceStore {
guard let store = store else { return }
guard store.isWaitingForReducer else { return }
store.isWaitingForReducer = false
if let state = currentState {
store.currentState = state
store.outputDelegates.invoke { a in
a.reduceStore(store, didChange: state)
}
} else {
store.error = error
store.outputDelegates.invoke { a in
a.reduceStore(store, didFailedWith: error)
}
}
}
func syncStore<T>(_ store: T?,
onDispatch action: T.ReducerType.ActionType?) where T : ReduceStore {
guard let store = store else { return }
store.isWaitingForReducer = true
store.error = nil
}
func dispatch(action: ReducerType.ActionType, await: Bool = false) {
if let action = action as? RxStore.ReducerType.ActionType {
rx?.dispatch(action: action, await: await)
}
if #available(iOS 13.0, *),
let action = action as? CombineStore.ReducerType.ActionType {
combine?.dispatch(action: action, await: await)
}
}
init(_ initialState: ReducerType.StateType, reducer: ReducerType, outputDelegates: [ReduceStoreOutputDelegate]) {
self.init()
var outputDelegates = outputDelegates
outputDelegates.append(self)
if let initialState = initialState as? RxStore.ReducerType.StateType,
let reducer = reducer as? RxStore.ReducerType {
rx = RxStore(initialState, reducer: reducer, outputDelegates: outputDelegates)
}
if #available(iOS 13.0, *) {
if let initialState = initialState as? CombineStore.ReducerType.StateType,
let reducer = reducer as? CombineStore.ReducerType {
combine = CombineStore(initialState, reducer: reducer, outputDelegates: outputDelegates)
}
}
}
}
public extension ReduceStoreProvider {
func reduceStore<T: ReduceStore>(_ reduceStore: T, didChange currentState: T.ReducerType.StateType) {
switch currentState {
case let state as RxStore.ReducerType.StateType:
syncStore(rx, with: state, error: nil)
case let state as CombineStore.ReducerType.StateType:
guard #available(iOS 13.0, *) else { return }
syncStore(combine, with: state, error: nil)
default: break
}
}
func reduceStore<T: ReduceStore>(_ reduceStore: T, willDispatch action: T.ReducerType.ActionType) {
switch action {
case let action as RxStore.ReducerType.ActionType:
syncStore(rx, onDispatch: action)
case let action as CombineStore.ReducerType.ActionType:
guard #available(iOS 13.0, *) else { return }
syncStore(combine, onDispatch: action)
default: break
}
}
func reduceStore<T: ReduceStore>(_ reduceStore: T, didFailedWith error: T.ReducerType.ErrorType?) {
switch error {
case let error as RxStore.ReducerType.ErrorType:
syncStore(rx, with: nil, error: error)
case let error as CombineStore.ReducerType.ErrorType:
guard #available(iOS 13.0, *) else { return }
syncStore(combine, with: nil, error: error)
default: break
}
}
}
|
[
-1
] |
e86d53cb6da389e1b4207070dd08bed21ab24685
|
f27cb5503a0f0d6d6db6896ef60cadfd25fc612a
|
/ShoppingList/extention-tableView.swift
|
d8144a36b04d5b2b967720ee630dff4eafbbed74
|
[] |
no_license
|
docmisterio/shoppingList
|
211cc64b51ecc17a9d9755214b540fa9c5748ccb
|
baa5bc7dac68ab0b20b6c9d947f7d3f8773f6b2e
|
refs/heads/master
| 2023-01-19T16:25:58.317165 | 2020-11-16T05:08:52 | 2020-11-16T05:08:52 | 312,379,671 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,778 |
swift
|
import UIKit
extension UITableView {
func setEmptyView(title: String, message: String) {
let emptyView = UIView(frame: CGRect(x: self.center.x, y: self.center.y, width: self.bounds.size.width, height: self.bounds.size.height))
let titleLabel = UILabel()
let messageLabel = UILabel()
titleLabel.translatesAutoresizingMaskIntoConstraints = false
messageLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.textColor = .black
titleLabel.font = UIFont(name: "SFUIText-Bold", size: 20)
titleLabel.text = title
messageLabel.textColor = .lightGray
messageLabel.font = UIFont(name: "SFUIText-Medium", size: 17)
messageLabel.text = message
messageLabel.numberOfLines = 0
messageLabel.textAlignment = .center
emptyView.addSubview(titleLabel)
emptyView.addSubview(messageLabel)
let titleLabelConstraints = [titleLabel.centerXAnchor.constraint(equalTo: emptyView.centerXAnchor),
titleLabel.centerYAnchor.constraint(equalTo: emptyView.centerYAnchor)]
let messageLabelConstraints = [messageLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10), messageLabel.leftAnchor.constraint(equalTo: emptyView.leftAnchor, constant: 20), messageLabel.rightAnchor.constraint(equalTo: emptyView.rightAnchor, constant: -20)]
NSLayoutConstraint.activate(titleLabelConstraints)
NSLayoutConstraint.activate(messageLabelConstraints)
self.backgroundView = emptyView
self.separatorStyle = .none
}
func restore() {
self.backgroundView = nil
self.separatorStyle = .singleLine
}
}
|
[
321315
] |
4209da64dfec0655f704e9121bc882ebaf918583
|
6e327dcb7081778ad5df4bf30b260ea685c1de29
|
/moreconnectedthanyouthinkApp.swift
|
bb5a8983267a06ac82944d6bba10cf40212d4b7c
|
[] |
no_license
|
BrycenBissell/Icebreaker
|
d61bdecd56f9fd75841102fdffd50e74ffba23d2
|
124d9db3c35093cb023e77a8abcc305c6d7342af
|
refs/heads/main
| 2023-07-13T03:06:59.368528 | 2021-08-17T22:53:33 | 2021-08-17T22:53:33 | 397,407,898 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 280 |
swift
|
//
// moreconnectedthanyouthinkApp.swift
// moreconnectedthanyouthink
//
// Created by Brycen Bissell on 5/27/21.
//
import SwiftUI
@main
struct moreconnectedthanyouthinkApp: App {
var body: some Scene {
WindowGroup {
Start_screen()
}
}
}
|
[
-1
] |
149b33bbe1bb2630ac7b30c4385316bb071133f9
|
dfada47adeb57ca5d42c05886fd8d978892eef09
|
/Messenger/Messenger/MessageViewController.swift
|
a3f0078a26d588e6e29d7971c436c3cd307dadb7
|
[] |
no_license
|
ayethuthuzaw/ios_study
|
b30db0bccc8ec66290acf00e7dfbf34f071233f4
|
8db7d0f556bc5093d888ae8e1aca3da3cf730c89
|
refs/heads/master
| 2022-11-06T00:53:51.274392 | 2020-06-24T00:07:16 | 2020-06-24T00:07:16 | 269,286,905 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,561 |
swift
|
//
// MessageViewController.swift
// Messenger
//
// Created by Aye Thu Thu Zaw on 2020/06/18.
// Copyright © 2020 ALJ. All rights reserved.
//
import UIKit
import NCMB
class MessageViewController: UIViewController,UITableViewDataSource,UITextFieldDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath)
let msg = messages.object(at: indexPath.row) as! NCMBObject
cell.textLabel!.text = msg.object(forKey: "text") as? String
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return messages.count
}
var room = NCMBObject()
var messages = NSArray()
@IBOutlet weak var bottomMargin: NSLayoutConstraint!
@IBOutlet weak var messageTextField: UITextField!
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
messageTextField.delegate = self
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// メッセージ取得
fetchMessages()
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func fetchMessages(){
let query = NCMBQuery(className: "Message")
query?.whereKey("room", equalTo: room)
query?.order(byAscending: "createDate")
query?.findObjectsInBackground({(objects, error) in
if (error == nil) {
if(objects!.count > 0) {
self.messages = objects! as NSArray;
self.tableView.reloadData()
} else {
print("エラー")
}
} else {
print(error?.localizedDescription as Any)
}
})
}
@IBAction func sendMessageButtonTapped(_ sender: Any) {
let msgStr = messageTextField.text
// 文字を何かしら入力していたら送信
if msgStr!.count > 0 {
// メッセージ送信
let msg = NCMBObject(className: "Mesage")
msg?.setObject(msgStr, forKey: "text")
msg?.setObject(room, forKey: "room")
// データストアに保存
msg?.saveInBackground({(error) in
if (error != nil) {
print("Message:保存失敗:\(String(describing: error))")
}else{
print("Message:保存成功:\(String(describing: msg))")
// TableView更新
self.fetchMessages()
// テキストフィールドの入力内容をリセット
self.messageTextField.text = ""
}
})
}
messageTextField.resignFirstResponder()
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
5529be3750b8106a0cd34bd6053baa76e1a3592b
|
2eb91f9879a1b56b35257831100312a9949a17bf
|
/WeatherApp/APIListCall.swift
|
b3d4350da168d72b6b4d9714fcd38e33ffddff6c
|
[] |
no_license
|
anwarcarage/code_examples
|
93c09abe4d6c90299eb25fb3a4fdb3618de3ff7d
|
aaa6b24273032f0df8c897c690858dd91c229238
|
refs/heads/main
| 2022-12-30T20:19:40.098544 | 2020-10-22T03:33:42 | 2020-10-22T03:42:47 | 306,212,068 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,134 |
swift
|
//
// APIListCall.swift
// WeatherApp
//
// Created by user162990 on 2/7/20.
// Copyright © 2020 Array North. All rights reserved.
//
import UIKit
class APIListCall: UIViewController {
let button = UIButton()
var menuItems = [DailyWeatherData]()
@objc func callAPI() {
let weatherController = WeatherController()
weatherController.loadForecast(city: "New York", completion: { (result: ResultType<ForecastData>) in
switch result {
case .success(let response):
self.handleDataFromAPI(response: response)
case .failure(let error):
print(error)
}
})
}
func handleDataFromAPI(response: ForecastData?) {
guard let response = response else {
return
}
menuItems.append(response.list[0])
tableView.reloadData()
}
let tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
button.backgroundColor = .green
button.setTitleColor(.white, for: .normal)
button.setTitle("Call API", for: .normal)
button.addTarget(self, action: #selector(callAPI), for: .touchUpInside)
button.translatesAutoresizingMaskIntoConstraints = false
button.widthAnchor.constraint(equalToConstant: 200).isActive = true
button.heightAnchor.constraint(equalToConstant: 100).isActive = true
tableView.dataSource = self
tableView.delegate = self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "menuCell")
//label.textColor = .blue
let stack = UIStackView(arrangedSubviews: [button, tableView])
stack.axis = .vertical
stack.spacing = 20
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
stack.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
}
}
extension APIListCall: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "menuCell", for: indexPath)
cell.textLabel?.text = String(menuItems[indexPath.row].main.temp_max) + " " +
String(menuItems[indexPath.row].main.temp_min)
return cell
}
/// This is used whenever you want to take an action on a user selecting a specific cell
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let menuItem = menuItems[indexPath.row] // Detail Screen
}
}
|
[
-1
] |
f7727e58455cd6b56c490934ed3c738ca8ffb461
|
4be774356fd8e830e9a264bbb2164b284508a417
|
/PokemonCollection/Pokemon.swift
|
ecdb7535ac37cf1263a6355a266451f639aa83ab
|
[] |
no_license
|
phonglnh/PokemonCollection
|
0b5b77a38de868b396ad9f93e2622c74537ac9e7
|
26cdb9ce951ed46a3bf99343acd4ec40ee6eb88e
|
refs/heads/master
| 2021-01-18T15:10:22.628322 | 2017-08-15T13:06:47 | 2017-08-15T13:06:47 | 93,014,419 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 4,112 |
swift
|
//
// Pokemon.swift
// PokemonCollection
//
// Created by PhongLe on 5/30/17.
// Copyright © 2017 PhongLe. All rights reserved.
//
import Foundation
import UIKit
struct Pokemon {
var name: String!
var image: UIImage!
var type: String!
init(name: String, image: UIImage, type: String) {
self.name = name
self.image = image
self.type = type
}
static func getPokemons() -> [Pokemon]{
return [
Pokemon(name: "001", image: UIImage(named: "001")!, type: "T"),
Pokemon(name: "002", image: UIImage(named: "002")!, type: "T"),
Pokemon(name: "003", image: UIImage(named: "003")!, type: "T"),
Pokemon(name: "004", image: UIImage(named: "004")!, type: "F"),
Pokemon(name: "005", image: UIImage(named: "005")!, type: "F"),
Pokemon(name: "006", image: UIImage(named: "006")!, type: "F"),
Pokemon(name: "007", image: UIImage(named: "007")!, type: "W"),
Pokemon(name: "008", image: UIImage(named: "008")!, type: "W"),
Pokemon(name: "009", image: UIImage(named: "009")!, type: "W"),
Pokemon(name: "010", image: UIImage(named: "010")!, type: "T"),
Pokemon(name: "011", image: UIImage(named: "011")!, type: "T"),
Pokemon(name: "012", image: UIImage(named: "012")!, type: "T"),
Pokemon(name: "013", image: UIImage(named: "013")!, type: "S"),
Pokemon(name: "014", image: UIImage(named: "014")!, type: "S"),
Pokemon(name: "015", image: UIImage(named: "015")!, type: "S"),
Pokemon(name: "016", image: UIImage(named: "016")!, type: "S"),
Pokemon(name: "017", image: UIImage(named: "017")!, type: "S"),
Pokemon(name: "018", image: UIImage(named: "018")!, type: "S"),
Pokemon(name: "019", image: UIImage(named: "019")!, type: "G"),
Pokemon(name: "020", image: UIImage(named: "020")!, type: "G"),
Pokemon(name: "021", image: UIImage(named: "021")!, type: "S"),
Pokemon(name: "022", image: UIImage(named: "022")!, type: "S"),
Pokemon(name: "023", image: UIImage(named: "023")!, type: "F"),
Pokemon(name: "024", image: UIImage(named: "024")!, type: "F"),
Pokemon(name: "025", image: UIImage(named: "025")!, type: "T"),
Pokemon(name: "026", image: UIImage(named: "026")!, type: "T"),
Pokemon(name: "027", image: UIImage(named: "027")!, type: "G"),
Pokemon(name: "028", image: UIImage(named: "028")!, type: "G"),
Pokemon(name: "029", image: UIImage(named: "029")!, type: "G"),
Pokemon(name: "030", image: UIImage(named: "030")!, type: "G"),
Pokemon(name: "031", image: UIImage(named: "031")!, type: "G"),
Pokemon(name: "032", image: UIImage(named: "032")!, type: "G"),
Pokemon(name: "033", image: UIImage(named: "033")!, type: "G"),
Pokemon(name: "034", image: UIImage(named: "034")!, type: "G"),
Pokemon(name: "035", image: UIImage(named: "035")!, type: "F"),
Pokemon(name: "036", image: UIImage(named: "036")!, type: "F"),
Pokemon(name: "037", image: UIImage(named: "037")!, type: "S"),
Pokemon(name: "038", image: UIImage(named: "038")!, type: "W"),
Pokemon(name: "039", image: UIImage(named: "039")!, type: "W"),
Pokemon(name: "040", image: UIImage(named: "040")!, type: "W"),
Pokemon(name: "041", image: UIImage(named: "041")!, type: "F")
]
}
static func getPokePerType() -> [Int: [Pokemon]] {
let dataPoke = self.getPokemons()
var dictPoke: [Int: [Pokemon]] = [Int: [Pokemon]]()
dictPoke[0] = dataPoke.filter({$0.type == "F"})
dictPoke[1] = dataPoke.filter({$0.type == "W"})
dictPoke[2] = dataPoke.filter({$0.type == "G"})
dictPoke[3] = dataPoke.filter({$0.type == "T"})
dictPoke[4] = dataPoke.filter({$0.type == "S"})
return dictPoke
}
}
|
[
-1
] |
24e8a878571c3a7c0fa4e0f5c7eba895b586561c
|
38ad705d4095e1fa2eb2b8af0a8f41aa9736446c
|
/Swift_iOS/SwiftProjects/GCDSample/GCDSample/DataManager.swift
|
40dc0bab7d2ae4a525847deac7834c2ec35101f2
|
[] |
no_license
|
JuneBuug/TIL
|
31240f6e5ec50a813a217191264d4237829b985a
|
622885492e13d70816198c14926c970bf8f6d8c2
|
refs/heads/master
| 2021-01-20T17:27:34.555973 | 2019-11-26T04:16:36 | 2019-11-26T04:16:36 | 90,876,819 | 4 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,853 |
swift
|
//
// DataManager.swift
// GCDSample
//
// Created by woowabrothers on 2017. 7. 24..
// Copyright © 2017년 woowabrothers. All rights reserved.
//
import Foundation
class DataManager {
var parsedJson : Array<Dictionary<String,Any>> = []
let notiKey = NSNotification.Name(rawValue: "dataGetComplete")
let imgDownloadKey = NSNotification.Name(rawValue: "imgDownloadComplete")
func getJSONfromURL(){
URLSession(configuration: URLSessionConfiguration.default).dataTask(with:
URL(string: "http://125.209.194.123/doodle.php")!) {
(data, response, error) in
if error != nil {
print("에러가 발생했습니다.")
}else{
self.parseJson(data: data!)
}
}.resume()
}
func parseJson(data: Data) {
do {
let json = try JSONSerialization.jsonObject(with: data, options: [])
if let array = json as? [Any] {
// json is an array
for object in array {
parsedJson.append(object as! [String : Any])
}
NotificationCenter.default.post(name: self.notiKey, object: nil, userInfo : ["json": parsedJson])
} else {
print("JSON is invalid")
}
} catch {
print(error.localizedDescription)
}
}
func downloadImagefromURL(urlstr : String, title: String) {
let url = URL(string: urlstr)!
let manager = FileManager()
URLSession(configuration: URLSessionConfiguration.default).downloadTask(with: url){
url, response,error in
if error != nil {
print(error!)
}else{
let cacheDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
print("현재경로 \(url!.path)")
print("cache경로 \(cacheDirectory.path)")
let destURL = cacheDirectory.appendingPathComponent(title+".png")
// response 의 파일 이름을 붙여서 최종 복사할 파일명까지 나오게한다
if manager.fileExists(atPath: destURL.path) == false {
do {
try manager.moveItem(atPath: url!.path, toPath: destURL.path)
NotificationCenter.default.post(name: self.imgDownloadKey, object: nil, userInfo : ["index": title])
} catch let error {
print("Failed moving directory, \(error)")
}
}
}
}.resume()
}
}
|
[
-1
] |
15f99ec9ee0b771c425500602bc40d92c31c8758
|
aaab596b0a05ea304b1c51dbf1c19dd976765024
|
/TestKitchen/TestKitchen/classes/Community/main/controller/CommunityViewController.swift
|
e8d954051ae8a4d22cb71d5c68896644d08699a2
|
[
"MIT"
] |
permissive
|
StephenMIMI/TestKitchen
|
cc1a7df963f65fe914df1c577f210857a4971e13
|
bee7ee4766f056c4f1224689d5a71517276412e2
|
refs/heads/master
| 2021-01-17T16:14:23.583836 | 2016-10-25T04:08:00 | 2016-10-25T04:08:00 | 71,517,759 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 875 |
swift
|
//
// CommunityViewController.swift
// TestKitchen
//
// Created by qianfeng on 16/10/21.
// Copyright © 2016年 zhb. All rights reserved.
//
import UIKit
class CommunityViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.greenColor()
}
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.
}
*/
}
|
[
286163,
98399
] |
c9866d8fab74fd14e0109b3d70a5f5403aa2b012
|
9f04f82e544db86459ef596e7adf1e5a67044c88
|
/SwiftYampTests/Models/UserMessageBodyFrameTest.swift
|
fae4a451147de539f97bbbf172a029cc2978a71e
|
[
"MIT"
] |
permissive
|
andrewBatutin/SwiftYamp
|
7b77f23daf0ab6e2465a64a8bb0672c3385f68bd
|
d6d915b54e47ff2fea709b59540cdbccfdd66a1f
|
refs/heads/master
| 2020-06-02T17:00:09.267023 | 2017-06-27T11:05:03 | 2017-06-27T11:05:03 | 94,099,601 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,378 |
swift
|
//
// UserMessageBodyFrameTest.swift
// SwiftYamp
//
// Created by Andrey Batutin on 6/13/17.
// Copyright © 2017 Andrey Batutin. All rights reserved.
//
import XCTest
@testable import SwiftYamp
class UserMessageBodyFrameTest: XCTestCase {
func testUserMessageBodySerializationSuccsefull(){
let expectedData = Data(bytes: [0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04])
let subject = UserMessageBodyFrame(size: 4, body: [0x01, 0x02, 0x03, 0x04])
let realData = try! subject.toData()
XCTAssertEqual(realData, expectedData)
}
func testUserMessageBodyDeSerializationThrowsWithShortData(){
let inputData = Data(bytes: [0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03])
XCTAssertThrowsError(try UserMessageBodyFrame(data: inputData))
}
func testUserMessageBodyDeSerializationThrowsWithSizeOverflow(){
let inputData = Data(bytes: [0x04, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03])
XCTAssertThrowsError(try UserMessageBodyFrame(data: inputData))
}
func testUserMessageBodyDeSerializationSuccsefull(){
let inputData = Data(bytes: [0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04])
let subject = try! UserMessageBodyFrame(data: inputData)
XCTAssertEqual(subject.size, 0x04)
XCTAssertEqual(subject.body!, [0x01, 0x02, 0x03, 0x04])
}
}
|
[
-1
] |
7ad8aa3cb646ef8385ef30c17f7ecfa9d7a947f6
|
f7cee9ecdd8a9613b4b47743eb3d65fe9abf38be
|
/Tinkoff/View/DetailsView.swift
|
e52595b63754ef715e8a03c11dbe7bede0fa542e
|
[] |
no_license
|
belotserkovtsev/tinkoff-stocks
|
1e8686822e13826ae75c26f0fe856c752fe1b2dc
|
036ec055ad9136b9c0427845dde246069615b978
|
refs/heads/main
| 2023-05-20T01:14:25.900353 | 2021-06-14T16:15:06 | 2021-06-14T16:15:06 | 334,501,234 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,018 |
swift
|
//
// DetailsView.swift
// Tinkoff
//
// Created by belotserkovtsev on 30.01.2021.
//
import SwiftUI
struct DetailsView: View {
@ObservedObject var stocks: StocksWorker
var body: some View {
if let data = stocks.stockToDisplay {
VStack(spacing: .zero) {
companyDescriptionView(for: data)
.padding(.bottom)
stockPriceView(for: data)
.padding(.bottom, 44)
Button(action: {
stocks.addCurrentStockToFavourite()
}, label: { Text("Add to favorite") })
Spacer()
}
.padding(.top, 36)
} else {
EmptyView()
}
}
//MARK: DetailsView UI Elements
private func companyDescriptionView(for data: StockData) -> some View {
ZStack {
RoundedRectangle(cornerRadius: 10)
.foregroundColor(Color("card"))
VStack(alignment: .leading, spacing: .zero) {
Text("Company")
.font(.system(size: 14, weight: .regular))
.padding(.bottom, 6)
Text(data.companyName)
.font(.system(size: 16, weight: .regular))
.foregroundColor(Color("darkGray2"))
.padding(.bottom, 14)
Divider()
.font(.system(size: 14, weight: .regular))
.padding(.bottom, 14)
Text("Ticker/Symbol")
.font(.system(size: 14, weight: .regular))
.padding(.bottom, 6)
Text(data.symbol)
.font(.system(size: 16, weight: .regular))
.foregroundColor(Color("darkGray2"))
}.padding(.leading, 16)
}
.frame(width: companyDescriptionWidth, height: commpanyDescriptionHeight)
.shadow(color: Color("shadow"), radius: 8, x: 2, y: 2)
}
private func stockPriceView(for data: StockData) -> some View {
ZStack {
RoundedRectangle(cornerRadius: 10)
.foregroundColor(Color("card"))
VStack(alignment: .leading, spacing: .zero) {
Text("$ \(String(format: "%.2f", data.latestPrice))")
.font(.system(size: 44, weight: .regular))
.padding(.bottom, 16)
HStack {
Image(systemName: data.change >= 0 ? "arrow.up" : "arrow.down")
.resizable()
.foregroundColor(Color("darkGray2"))
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
Text("\(String(format: "%.2f", data.change / data.latestPrice * 100)) %")
.foregroundColor(Color("darkGray2"))
.font(.system(size: 16, weight: .medium))
Text(sinceWhen)
.font(.system(size: 16, weight: .light))
.opacity(0.6)
Spacer()
}
}.padding(.leading, 17)
}
.frame(width: stockPriceWidth, height: stockPriceHeight)
.shadow(color: Color("shadow"), radius: 8, x: 2, y: 2)
}
//MARK: DetailsView UI Constants
private let sinceWhen = "since last month"
private let companyDescriptionWidth: CGFloat = 359
private let commpanyDescriptionHeight: CGFloat = 138
private let stockPriceWidth: CGFloat = 359
private let stockPriceHeight: CGFloat = 208
}
//struct DetailsView_Previews: PreviewProvider {
//// @State static var symbol = "TSL"
// static var previews: some View {
// DetailsView(stocks: StocksWorker())
// .preferredColorScheme(.light)
// }
//}
|
[
-1
] |
67e44a94e025725447131cdc0e7d4c875500d854
|
0e3eac1edd22bd2c4294a4cb7cd678676e4451fa
|
/WYP/WYP/WYPFramework/WYPThirdParty/ZJPickerMenu/ZJPickerMenu.swift
|
b53149530df093c2418c2cdfbce193ccc5d2bc51
|
[] |
no_license
|
Jhinnn/swiftProject
|
a8debca575e11b5f8f06fb990e4a152235400b8d
|
fa9959d136a10290696348b50fcf0fdcdf460e2d
|
refs/heads/master
| 2020-04-05T10:44:43.784819 | 2018-11-09T04:12:42 | 2018-11-09T04:12:42 | 156,809,130 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 9,659 |
swift
|
//
// ZJPickerMenu.swift
// 商城属性
//
// Created by zj on 2017/12/7.
// Copyright © 2017年 zj. All rights reserved.
//
import UIKit
protocol ZJPickerMenuDelegate:NSObjectProtocol
{
func getMsg(pro:[String:String])
}
class ZJPickerMenu: UIView,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {
var numLabel:UILabel?
var pro = [String:String]()
var delegate : ZJPickerMenuDelegate?
private var padding_top:CGFloat = 100
var arr : [String:[ExhibitionModel]]?
var arrTitle : [String]?
lazy var backView: UIView = {
var back = UIView.init(frame: UIScreen.main.bounds)
// let tap = UITapGestureRecognizer(target: self, action: #selector(miss(_ :)))
// back.addGestureRecognizer(tap)
back.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.3)
return back
}()
lazy var hiddenView: UIView = {
var back = UIView.init(frame: CGRect(x: 0, y: 0, width: 100, height: UIScreen.main.bounds.height))
let tap = UITapGestureRecognizer(target: self, action: #selector(miss(_ :)))
back.addGestureRecognizer(tap)
back.backgroundColor = UIColor.clear
return back
}()
lazy var headerView: UIView = {
var header = UIView.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 80))
header.backgroundColor = UIColor.menuColor
header.addSubview(self.titleLabel)
return header
}()
lazy var titleLabel: UILabel = {
var titleLabel = UILabel.init(frame: CGRect(x: 14, y: 40, width: kScreen_width - 100, height: 30))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.text = "筛选"
titleLabel.font = UIFont.systemFont(ofSize: 15)
return titleLabel
}()
lazy var commitButton: UIButton = {
var button = UIButton()
if deviceTypeIPhoneX() {
button.frame = CGRect(x: 0, y: UIScreen.main.bounds.height - 50 - 34, width: UIScreen.main.bounds.width - 100, height: 50)
}else {
button.frame = CGRect(x: 0, y: UIScreen.main.bounds.height - 50, width: UIScreen.main.bounds.width - 100, height: 50)
}
button.setTitle("确定", for: UIControlState.normal)
button.setTitleColor(UIColor.white, for: .normal)
button.backgroundColor = UIColor.themeColor
button.addTarget(self, action: #selector(sureCommit), for: UIControlEvents.touchUpInside)
return button
}()
lazy var pickerView: UIView = {
var picker = UIView.init(frame: CGRect(x: 100, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
picker.backgroundColor = UIColor.white
// let tap = UITapGestureRecognizer(target: self, action: #selector(misss(_ :)))
// picker.addGestureRecognizer(tap)
picker.addSubview(self.headerView)
picker.addSubview(self.cv)
picker.addSubview(self.commitButton)
return picker
}()
lazy var cv: UICollectionView =
{
let layout = UICollectionViewFlowLayout()
var cv = UICollectionView.init(frame: CGRect(x: 0, y:90, width: UIScreen.main.bounds.width - 100, height: UIScreen.main.bounds.height - 90 - 50 - 34), collectionViewLayout: layout)
cv.register(ProCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
cv.register(ProHeaderCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "sectionHeader")
cv.delegate = self
cv.dataSource = self
cv.backgroundColor = UIColor.white
return cv
}()
func numberOfSections(in collectionView: UICollectionView) -> Int
{
return arr?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
// let result = Array((arr?.values)!)
return (arr![self.arrTitle![section]]?.count)!
// return result[section].count
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
{
// let result = Array((arr?.values)!)
// let str = result[indexPath.section][indexPath.row]
// let rect = (str as NSString).boundingRect(with: CGSize(width: CGFloat(MAXFLOAT), height: 38), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes:nil, context: nil)
// return CGSize(width: rect.width + 58, height: 38)
return CGSize(width: 80, height: 38)
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let v = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "sectionHeader", for: indexPath) as! ProHeaderCollectionReusableView
// let res = Array((arr?.keys)!)
v.label.text = self.arrTitle?[indexPath.section]
return v
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: 40)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { //行间距
return 6
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { //列间距
return 4
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsetsMake(8, 15, 8, 8)
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
if arr?.count != 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ProCollectionViewCell
// let exhibitionModelArray = Array((arr?.values)!)
let exhibitionModelArray = arr![self.arrTitle![indexPath.section]]
let model = exhibitionModelArray![indexPath.row]
cell.button.isSelected = false
cell.button.setTitle(model.title, for: UIControlState.normal)
cell.button.backgroundColor = UIColor.menuColor
cell.button.setTitleColor(UIColor.black, for: .normal)
return cell
}
return UICollectionViewCell()
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
let num = collectionView.numberOfItems(inSection: indexPath.section)
for i in 0..<num
{
let index = NSIndexPath.init(row: i, section: indexPath.section)
if i != indexPath.row
{
let cell1 = collectionView.cellForItem(at: index as IndexPath) as? ProCollectionViewCell
cell1?.button.isSelected = false
}
else
{
// let exhibitionModelArray = Array((arr?.values)!)
let exhibitionModelArray = arr![self.arrTitle![indexPath.section]]
let model = exhibitionModelArray![indexPath.row]
// let model = exhibitionModelArray[indexPath.section][indexPath.row]
let res = Array((arr?.keys)!)
let cell1 = collectionView.cellForItem(at: index as IndexPath) as? ProCollectionViewCell
cell1?.button.isSelected = true
pro[res[indexPath.section]] = model.id
}
}
}
override init(frame: CGRect)
{
super.init(frame: frame)
self.backView.addSubview(self.pickerView)
self.pickerView.addSubview(self.cv)
self.backView.addSubview(self.hiddenView)
}
func show() {
self.frame = CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
self.backView.frame = CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
let guidePageWindow = UIApplication.shared.keyWindow
guidePageWindow?.addSubview(self.backView)
UIView.animate(withDuration: 0.1)
{
self.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
}
cv.reloadData()
}
@objc func miss(_ tap: UITapGestureRecognizer)
{
UIView.animate(withDuration: 0.1) {
self.backView.transform = (self.backView.transform.translatedBy(x: kScreen_width, y: 0))
}
}
// @objc func misss(_ tap: UITapGestureRecognizer)
// {
//
// }
required init?(coder aDecoder: NSCoder)
{
fatalError("init(coder:) has not been implemented")
}
//提交
@objc func sureCommit()
{
UIView.animate(withDuration: 0.1) {
self.backView.transform = (self.backView.transform.translatedBy(x: kScreen_width, y: 0))
}
self.delegate?.getMsg(pro: pro)
pro.removeAll()
}
}
|
[
-1
] |
b8629159d6855708756a8acd3f41b2c3d1115bbb
|
a8bc6447555b36b2a2df1a60a7b7739dc120606b
|
/PhotoFeedDemo/UseCases/Feed/UI/UIKit/Feed/FeedViewComposer.swift
|
0a54eec41e583f0012336274ca59e5a5eb4ceb16
|
[
"MIT"
] |
permissive
|
surakamy/PhotoFeedDemo
|
d92d76a670315f3110ffecfe4a85f9936b0006cf
|
1f9a1cf52d78872f543a75be924430f361802416
|
refs/heads/main
| 2023-02-08T23:51:42.095708 | 2020-12-29T14:46:12 | 2020-12-29T14:46:12 | 325,283,359 | 5 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,094 |
swift
|
//
// FeedViewComposer.swift
// PhotoFeedDemo
//
// Created by Dmytro Kholodov on 18.12.2020.
//
import UIKit
enum FeedViewComposer {
static func compose(feedLoader: RemoteFeedLoader, imageLoader: HTTPClient, onSelect: @escaping (Int) -> Void) -> FeedViewController {
let interactor = FeedInteractor(source: feedLoader)
let presenter = FeedPresenter()
let controller = FeedViewController(collectionViewLayout: makeGalleryCollectionLayout())
controller.onSelectFeedCard = onSelect
controller.interactor = interactor
controller.imageLoader = imageLoader
presenter.viewFeed = WeakRef(controller)
presenter.viewRefresh = WeakRef(controller.refreshController)
interactor.presenter = presenter
return controller
}
}
// MARK: - WeakRef Proxies
extension WeakRef: FeedView where T == FeedViewController {
func displayReload(_ viewModel: FeedViewModel) {
object?.displayReload(viewModel)
}
func displayAppend(_ viewModel: FeedViewModel) {
object?.displayAppend(viewModel)
}
func displayError() {
object?.displayError()
}
}
extension WeakRef: FeedRefreshView where T == FeedRefreshController {
func displayLoading(_ active: Bool) {
object?.displayLoading(active)
}
}
// MARK: - MainQueueDispatchDecorator
extension MainQueueDispatchDecorator: RemoteFeedLoader where T == PicsumFeedLoader {
public typealias Result = RemoteFeedLoader.Result
public func load(page: Int, completion: @escaping (Result) -> Void) -> HTTPClientTask {
decoratee.load(page: page) {
[weak self] (result) in
self?.dispatchOnMain { completion(result) }
}
}
}
extension MainQueueDispatchDecorator: HTTPClient where T == URLSessionClient {
public func dispatch(_ request: URLRequest, then handler: @escaping (Response) -> Void) -> HTTPClientTask {
decoratee.dispatch(request) {
[weak self] (response) in
self?.dispatchOnMain { handler(response) }
}
}
}
|
[
-1
] |
68f895f43168407a2341f544a12611dc07111de7
|
1c9924b4aa218167597afe53b46109a0b4f3969b
|
/Sources/VoiceMemoView/VolumeControl.swift
|
da955262ce75fb7a0d4fed6399f1f58c3bda4aa7
|
[
"MIT"
] |
permissive
|
paulnelsontx/VoiceMemoView
|
b14b7c677fe31955c5b3d429f63aaccaf84c483e
|
d32f9b078d5dee9e571d9d18861f0091da96825c
|
refs/heads/main
| 2023-08-06T03:20:30.214509 | 2021-10-08T23:41:05 | 2021-10-08T23:41:05 | 397,733,316 | 0 | 0 |
MIT
| 2021-10-08T23:41:06 | 2021-08-18T20:58:51 |
Swift
|
UTF-8
|
Swift
| false | false | 1,530 |
swift
|
//
// File.swift
//
//
// Created by Paul Nelson on 8/18/21.
//
import SwiftUI
import MediaPlayer
import os
public struct VolumeSlider : UIViewRepresentable {
public typealias UIViewType = MPVolumeView
public func makeUIView(context: Context) -> MPVolumeView {
let result = MPVolumeView(frame: CGRect.zero)
return result
}
public func updateUIView(_ uiView: MPVolumeView, context: Context) {
// eliminate deprecated routing button from the layout because it makes the slider
// appear off center
for subview in uiView.subviews {
if let routeButton = subview as? UIButton {
var frame = routeButton.frame
frame.size.width = 0
routeButton.frame = frame
}
}
uiView.setNeedsLayout()
}
public static func dismantleUIView(_ uiView: MPVolumeView, coordinator: ()) {
os_log("%@", log: .default, type: .error,
"VolumeControl dismantleUIView" )
}
public init() {
}
}
public struct VolumeControl : View {
public var body: some View {
HStack(alignment: .center, spacing: 10.0) {
Label("", systemImage:"speaker.wave.1")
VolumeSlider().frame(maxHeight:20.0)
Label("", systemImage:"speaker.wave.3")
}.padding(20)
}
public init() {
}
}
struct VolumeControl_Previews: PreviewProvider {
static var previews: some View {
VolumeControl()
}
}
|
[
-1
] |
d7e3243d76256902ade84b504d99887301c7a64b
|
f134d8b1c62240c7580ab29b2a9cbf45516c6a1b
|
/Sources/LaunchBehavior.swift
|
cc17d3cdeff86227be5de58cca9eea9528538bb8
|
[] |
no_license
|
yutmr/LaunchBehavior
|
a1f4a8cec5f28b81d40dc9bd14663986ab29ceb6
|
f266b40c8f3d95f6d05e305130e40d020830b610
|
refs/heads/master
| 2020-03-17T02:42:36.165356 | 2018-05-13T06:31:22 | 2018-05-13T06:31:22 | 133,201,820 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,834 |
swift
|
//
// LaunchBehavior.swift
// LaunchBehavior
//
// Created by Yu Tamura on 2018/05/13.
// Copyright © 2018年 Yu Tamura. All rights reserved.
//
import Foundation
import UserNotifications
public enum LaunchSource {
case direct
case notification([AnyHashable: Any])
case urlScheme(URL)
case universalLinks(URL)
}
public protocol LaunchBehaviorDelegate: class {
func launchBehavior(_ launchBehavior: LaunchBehavior, didLaunchApplication from: LaunchSource)
}
public final class LaunchBehavior {
public static let shared = LaunchBehavior()
public private(set) var currentLaunch: LaunchSource?
public weak var delegate: LaunchBehaviorDelegate?
private func setCurrentLaunch(_ launchSource: LaunchSource) {
guard currentLaunch == nil else {
return
}
currentLaunch = launchSource
delegate?.launchBehavior(self, didLaunchApplication: launchSource)
}
private func clear() {
currentLaunch = nil
}
public func applicationDidBecomeActive(_ application: UIApplication) {
setCurrentLaunch(.direct)
}
public func applicationDidEnterBackground(_ application: UIApplication) {
clear()
}
public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) {
setCurrentLaunch(.urlScheme(url))
}
public func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void
) {
guard let url = userActivity.webpageURL else {
return
}
switch userActivity.activityType {
case NSUserActivityTypeBrowsingWeb:
setCurrentLaunch(.universalLinks(url))
default:
break
}
}
public func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
switch application.applicationState {
case .inactive:
if #available(iOS 10.0, *) {
} else {
setCurrentLaunch(.notification(userInfo))
}
default:
break
}
}
@available(iOS 10.0, *)
public func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
let userInfo = response.notification.request.content.userInfo
switch UIApplication.shared.applicationState {
case .inactive:
setCurrentLaunch(.notification(userInfo))
default:
break
}
}
}
|
[
-1
] |
fc25cf8947ec93e8bd1cb6ebf3f94d5666372fe7
|
76d13dbc2a27474a06a6ad6c0f5e5fbdfcddea52
|
/elenaWeather/Manager/APIManager.swift
|
da89dec1b42a17b5b80ad0de169ec2a0b4410c73
|
[] |
no_license
|
ElenaLiu/Elena-weather
|
eaded18dbc2f41c0921b5025e1f3a0369e2fc777
|
ddefea92c18458ee75e90680961482e378194f14
|
refs/heads/master
| 2021-05-02T15:45:27.032739 | 2018-02-13T14:33:36 | 2018-02-13T14:33:36 | 120,702,866 | 0 | 0 | null | 2018-02-13T14:13:11 | 2018-02-08T03:00:47 |
Swift
|
UTF-8
|
Swift
| false | false | 1,851 |
swift
|
//
// APIManager.swift
// elenaWeather
//
// Created by 劉芳瑜 on 2018/2/10.
// Copyright © 2018年 Fang-Yu. Liu. All rights reserved.
//
import Foundation
import UIKit
protocol ApiManagerDelegate: class {
func manager(_ manager: ApiManager, didGet data: Item)
func manager(_ manager: ApiManager, didFailWith error: ApiManagerError)
}
enum ApiManagerError: Error {
case convertError
case dataTaskError
}
class ApiManager {
static let share = ApiManager()
weak var delegate: ApiManagerDelegate?
func getWeatherInfo(city: String) {
let cityUrlEncodeString = city.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
let urlString = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22\(cityUrlEncodeString)%22)&format=json"
guard let url = URL(string: urlString) else {
print("所在地點無法顯示 city name: \(city)")
print("URL stirng: \(urlString)")
return
}
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
let decoder = JSONDecoder()
if error != nil {
self.delegate?.manager(self, didFailWith: ApiManagerError.dataTaskError)
return
}
if let data = data,
let weatherResult = try? decoder.decode(WeatherResult.self, from: data)
{
self.delegate?.manager(self, didGet: weatherResult.query.results.channel.item)
} else {
self.delegate?.manager(self, didFailWith: ApiManagerError.convertError)
}
}
task.resume()
}
}
|
[
-1
] |
e896e66c71304a3c9e5afcf2d06ff8f30742e24a
|
815f436e292a09ba66e1a916dc6c5386592c12aa
|
/TextViewMaximumTest/SteramReader.swift
|
93353a36e45b8330d983731cf4bac7b7aada2805
|
[] |
no_license
|
wiwi-git/TextReader-Test
|
45fd9edd1e986171f76b11061be0ba9d5af54e43
|
b0f10a9d7d26546e2636dcec8acaab520fc0daf6
|
refs/heads/main
| 2023-04-16T23:50:30.985663 | 2021-04-18T10:57:41 | 2021-04-18T10:57:41 | 357,868,223 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 2,033 |
swift
|
//
//
//sooop/StreamReader.swift
//https://gist.github.com/sooop/a2b110f8eebdf904d0664ed171bcd7a2
//
//
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
init?(url: URL, delimeter: String = "\n", encoding: String.Encoding = .utf8, chunkSize: Int = 4096)
{
guard let fileHandle = try? FileHandle(forReadingFrom: url) else { return nil }
self.fileHandle = fileHandle
self.chunkSize = chunkSize
self.encoding = encoding
buffer = Data(capacity: chunkSize)
delimPattern = delimeter.data(using: .utf8)!
}
deinit {
fileHandle.closeFile()
}
func rewind() {
fileHandle.seek(toFileOffset: 0)
buffer.removeAll(keepingCapacity: true)
isAtEOF = false
}
func nextLine() -> String? {
if isAtEOF { return nil }
repeat {
do {
if let range = buffer.range(of: delimPattern, options: [], in: buffer.startIndex..<buffer.endIndex) {
let subData = buffer.subdata(in: buffer.startIndex..<range.lowerBound)
let line = String(data: subData, encoding: encoding)
buffer.replaceSubrange(buffer.startIndex..<range.upperBound, with: [])
return line
} else {
// let tempData = fileHandle.readData(ofLength: chunkSize)
let tempData = try fileHandle.read(upToCount: chunkSize)
if tempData == nil || tempData!.count == 0 {
isAtEOF = true
return (buffer.count > 0) ? String(data: buffer, encoding: encoding) : nil
} else {
buffer.append(tempData!)
}
}
} catch let err {
print(err)
}
} while true
}
}
|
[
67222
] |
b0ada669f19a89d52a2a0b81f6e889ca257c4890
|
413f743b5dfae58aa135f93bda7ec5ef268692f4
|
/Combinestagram_04/Combinestagram_04Tests/Combinestagram_04Tests.swift
|
14419069463d46865272d247937076f7c6f0f5ee
|
[] |
no_license
|
cxm1234/rxs-practice
|
8a2926487b2458e522ace243b12ce13aade03e6d
|
285dd56f48528651cb23a8b4ee1008c40adc406d
|
refs/heads/master
| 2023-08-26T08:28:10.878176 | 2021-10-26T12:24:23 | 2021-10-26T12:24:23 | 341,577,248 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 931 |
swift
|
//
// Combinestagram_04Tests.swift
// Combinestagram_04Tests
//
// Created by xiaoming on 2021/5/21.
//
import XCTest
@testable import Combinestagram_04
class Combinestagram_04Tests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
|
[
333828,
346118,
43014,
358410,
354316,
313357,
360462,
399373,
317467,
145435,
16419,
223268,
229413,
204840,
315432,
325674,
344107,
102445,
155694,
176175,
253999,
233517,
346162,
129076,
241716,
229430,
243767,
163896,
180280,
358456,
352315,
288828,
436285,
376894,
288833,
288834,
436292,
403525,
352326,
225351,
315465,
436301,
338001,
196691,
338003,
280661,
329814,
338007,
307289,
385116,
356447,
254048,
237663,
315487,
280675,
280677,
43110,
319591,
321637,
436329,
194666,
221290,
438377,
260207,
432240,
352368,
204916,
233589,
266357,
131191,
215164,
215166,
422019,
280712,
415881,
104587,
235662,
241808,
381073,
196760,
284826,
426138,
346271,
436383,
362659,
258214,
299174,
333991,
239793,
377009,
405687,
182456,
295098,
379071,
258239,
389313,
299203,
149703,
299209,
346314,
372941,
266449,
321745,
139479,
254170,
229597,
194782,
301279,
311519,
317664,
280802,
379106,
387296,
346346,
205035,
307435,
321772,
438511,
381172,
338164,
436470,
336120,
327929,
243962,
344313,
356602,
184575,
149760,
375039,
411906,
147717,
368905,
375051,
325905,
254226,
272658,
368916,
262421,
272660,
325912,
381208,
377114,
151839,
237856,
237857,
233762,
211235,
217380,
432421,
211238,
338218,
254251,
311597,
358703,
321840,
98610,
332083,
379186,
332085,
358709,
180535,
336183,
332089,
321860,
332101,
438596,
323913,
348492,
254286,
383311,
323920,
344401,
366930,
377169,
348500,
368981,
155990,
289110,
368984,
168281,
215385,
332123,
272729,
332127,
98657,
383332,
242023,
383336,
270701,
160110,
242033,
270706,
354676,
354677,
139640,
291192,
106874,
211326,
436608,
362881,
240002,
436611,
340357,
225670,
311685,
317831,
106888,
242058,
385417,
373134,
385422,
108944,
252308,
190871,
213403,
39324,
149916,
121245,
242078,
420253,
141728,
315810,
315811,
381347,
289189,
108972,
272813,
340398,
385454,
377264,
342450,
338356,
436661,
293303,
311738,
33211,
293306,
293310,
336320,
311745,
342466,
127427,
416197,
254406,
188871,
324039,
129483,
342476,
373197,
289232,
328152,
256477,
287198,
160225,
342498,
358882,
334309,
391655,
432618,
375276,
319981,
291311,
254456,
377338,
377343,
174593,
254465,
291333,
348682,
340490,
139792,
420369,
303636,
258581,
393751,
254488,
416286,
377376,
207393,
375333,
377386,
358954,
244269,
197167,
375343,
385588,
289332,
234036,
375351,
174648,
338489,
338490,
244281,
315960,
242237,
348732,
70209,
115270,
70215,
293448,
55881,
301638,
309830,
348742,
348749,
381517,
385615,
426576,
369235,
416341,
297560,
332378,
201308,
354911,
416351,
139872,
436832,
436834,
268899,
111208,
39530,
184940,
373358,
420463,
346737,
389745,
313971,
346740,
139892,
420471,
287352,
344696,
209530,
244347,
356989,
373375,
152195,
311941,
348806,
336518,
369289,
311945,
330379,
344715,
311949,
287374,
326287,
375440,
316049,
311954,
334481,
117396,
352917,
111253,
316053,
346772,
230040,
342682,
264856,
111258,
111259,
271000,
289434,
303771,
205471,
318106,
318107,
139939,
344738,
176808,
336558,
205487,
303793,
318130,
299699,
293556,
336564,
383667,
314040,
287417,
39614,
287422,
377539,
422596,
422599,
291530,
225995,
363211,
164560,
242386,
385747,
361176,
418520,
422617,
287452,
363230,
264928,
422626,
375526,
422631,
234217,
346858,
330474,
342762,
293612,
342763,
289518,
299759,
369385,
377489,
312052,
154359,
172792,
348920,
344827,
344828,
221948,
432893,
35583,
363263,
205568,
162561,
291585,
295682,
430849,
291592,
197386,
383754,
62220,
117517,
434957,
322319,
422673,
377497,
430865,
166676,
291604,
310036,
197399,
207640,
422680,
426774,
426775,
326429,
293664,
344865,
377500,
326433,
197411,
400166,
289576,
293672,
189228,
295724,
152365,
197422,
353070,
164656,
295729,
422703,
191283,
422709,
353078,
152374,
197431,
273207,
355130,
375609,
160571,
289598,
160575,
336702,
355137,
430910,
355139,
160580,
252741,
355146,
381773,
201551,
293711,
355121,
355152,
353109,
377686,
244568,
230234,
189275,
244570,
355165,
435039,
295776,
127841,
242529,
349026,
357218,
303972,
385893,
342887,
355178,
308076,
242541,
207729,
330609,
246643,
207732,
295798,
361337,
177019,
185211,
308092,
398206,
400252,
291712,
158593,
254850,
359298,
260996,
359299,
113542,
369538,
381829,
316298,
392074,
349067,
295824,
224145,
349072,
355217,
256922,
289690,
318364,
390045,
310176,
185250,
310178,
337227,
420773,
185254,
289703,
293800,
140204,
236461,
363438,
347055,
377772,
304051,
326581,
373687,
326587,
230332,
377790,
289727,
273344,
349121,
363458,
330689,
359364,
353215,
379844,
213957,
19399,
326601,
345033,
373706,
316364,
211914,
359381,
386006,
418776,
359387,
433115,
248796,
343005,
347103,
50143,
248797,
64485,
123881,
326635,
359406,
187374,
383983,
347123,
240630,
349175,
201720,
271350,
127992,
295927,
328700,
318461,
293886,
257024,
328706,
330754,
320516,
293893,
295942,
357379,
386056,
410627,
353290,
330763,
377869,
433165,
146448,
384016,
238610,
308243,
418837,
140310,
433174,
201755,
252958,
369701,
357414,
248872,
238639,
300084,
312373,
359478,
203830,
252980,
238651,
132158,
308287,
336960,
361535,
257094,
359495,
377926,
361543,
218186,
250954,
250956,
314448,
341073,
339030,
439384,
361566,
304222,
392290,
250981,
253029,
257125,
300135,
316520,
273515,
357486,
173166,
351344,
144496,
404593,
377972,
285814,
291959,
300150,
300151,
363641,
160891,
363644,
341115,
300158,
377983,
392318,
248961,
150657,
384131,
349316,
402565,
349318,
302216,
330888,
386189,
337039,
169104,
373903,
177296,
347283,
326804,
363669,
238743,
119962,
300187,
300188,
339100,
351390,
199839,
380061,
429214,
343203,
265379,
300201,
249002,
253099,
253100,
238765,
3246,
300202,
306346,
238769,
318639,
402613,
367799,
421048,
373945,
113850,
294074,
367810,
302274,
259268,
265412,
353479,
62665,
402634,
283852,
259280,
290000,
316627,
333011,
189653,
351446,
419029,
148696,
296153,
359647,
304351,
195808,
298208,
310497,
298212,
298213,
222440,
330984,
328940,
298221,
298228,
302325,
234742,
386294,
351478,
128251,
363771,
386301,
261377,
351490,
320770,
386306,
437505,
322824,
369930,
439562,
292107,
328971,
414990,
353551,
251153,
177428,
349462,
257305,
320796,
222494,
253216,
339234,
372009,
412971,
130348,
66862,
353584,
351537,
261425,
382258,
345396,
300343,
386359,
378172,
286013,
306494,
382269,
216386,
312648,
337225,
304456,
230729,
146762,
224586,
177484,
294218,
353616,
259406,
234831,
238927,
294219,
331090,
406861,
318805,
314710,
372054,
159066,
425304,
374109,
314720,
378209,
163175,
333160,
386412,
380271,
327024,
296307,
116084,
208244,
249204,
316787,
382330,
290173,
357759,
306559,
337281,
314751,
318848,
378244,
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,
208293,
374191,
286129,
380337,
173491,
286132,
150965,
304564,
353719,
380338,
228795,
425405,
302531,
163268,
380357,
339398,
361927,
300489,
425418,
306639,
413137,
366037,
23092,
210390,
210391,
210393,
286172,
144867,
271843,
429542,
361963,
296433,
251378,
308723,
300536,
286202,
359930,
302590,
366083,
372227,
323080,
329225,
253451,
296461,
359950,
259599,
304656,
329232,
146964,
398869,
308756,
370197,
175639,
253463,
374296,
388632,
374299,
423453,
308764,
396827,
134686,
431649,
349726,
355876,
286244,
245287,
402985,
394794,
245292,
349741,
169518,
347694,
431663,
288309,
312889,
194110,
425535,
349763,
196164,
265798,
288327,
218696,
292425,
128587,
265804,
333388,
396882,
349781,
128599,
179801,
44635,
239198,
343647,
333408,
396895,
99938,
374372,
300644,
323172,
310889,
415338,
243307,
312940,
54893,
204397,
138863,
188016,
222832,
325231,
224883,
314998,
370296,
366203,
323196,
325245,
337534,
337535,
339584,
339585,
263809,
294529,
194180,
224901,
288392,
229001,
415375,
188048,
239250,
419478,
345752,
425626,
255649,
302754,
153251,
298661,
40614,
300714,
210603,
224946,
337591,
384695,
370363,
110268,
415420,
224958,
327358,
333503,
274115,
259781,
306890,
403148,
212685,
333517,
9936,
9937,
241361,
302802,
333520,
272085,
345814,
370388,
384720,
345821,
321247,
298720,
321249,
325346,
153319,
325352,
345833,
345834,
212716,
212717,
360177,
67315,
173814,
325371,
288512,
319233,
339715,
288516,
360195,
339720,
243472,
372496,
323346,
321302,
345879,
366360,
169754,
325404,
286494,
321310,
255776,
339745,
257830,
421672,
362283,
378668,
399147,
431916,
300848,
339762,
409394,
296755,
259899,
319292,
360252,
325439,
345919,
436031,
403267,
339783,
153415,
345929,
360264,
341836,
415567,
337745,
325457,
317269,
18262,
216918,
241495,
341847,
362327,
350044,
346779,
128862,
345951,
245599,
362337,
376669,
345955,
425825,
296806,
292712,
425833,
423789,
214895,
362352,
313199,
325492,
276341,
417654,
341879,
241528,
317304,
333688,
112509,
55167,
182144,
325503,
305026,
339841,
188292,
253829,
333701,
243591,
315273,
315274,
350093,
325518,
372626,
380821,
329622,
294807,
337815,
333722,
376732,
118685,
298909,
311199,
319392,
350109,
292771,
436131,
294823,
415655,
436137,
327596,
362417,
323507,
243637,
290745,
294843,
188348,
362431,
237504,
294850,
274371,
384964,
214984,
151497,
362443,
344013,
212942,
301008,
212946,
153554,
24532,
212951,
372701,
219101,
329695,
354272,
436191,
354274,
354269,
292836,
292837,
298980,
313319,
354280,
253929,
317415,
337895,
380908,
436205,
174057,
311281,
311282,
325619,
432116,
292858,
415741
] |
1f00ee4d08014a8d8ea68430d5ec658b74cbc28a
|
fc8c1a316657211f76668dfeb1ef12b906698fb3
|
/JPSFSActionRequest/JPSFSActionRequestTip/JPSFSActionRequestTip.swift
|
77d148e6f2edf7ad7a012ec55d53d52db39a584d
|
[] |
no_license
|
MotivatedCreation/JPSFoursquare
|
2f9461ea814710625c1fdee612202567a0ea5f59
|
0b096bf049832b4bfb3975ba07c39de37452c6a9
|
refs/heads/master
| 2021-01-22T19:04:30.858987 | 2017-03-21T02:06:17 | 2017-03-21T02:06:17 | 85,155,500 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 242 |
swift
|
//
// JPSFSActionRequestTip.swift
// Just Bucket
//
// Created by Jonathan Sullivan on 3/18/17.
// Copyright © 2017 Jonathan Sullivan. All rights reserved.
//
import Foundation
class JPSFSActionRequestTip: JPSFSActionRequest
{
}
|
[
-1
] |
0f84346405bc0703150941c411cf5d9d80e06069
|
6ab7ba8633fb267787332a5197535205476d35aa
|
/Arkonia/Seasons.swift
|
538efffc314f55e342858c35e36aa3ae0a91a4d6
|
[
"MIT"
] |
permissive
|
SaganRitual/Arkonia
|
5965f742c7df62754b0786d9a05c4d45e25d9c1a
|
33ff844b05723232bcef9ccba177e00aca758377
|
refs/heads/master
| 2021-07-05T00:56:05.453696 | 2020-07-24T06:29:56 | 2020-07-24T06:29:56 | 157,790,019 | 3 | 2 |
MIT
| 2019-02-28T08:05:41 | 2018-11-16T00:28:39 |
Swift
|
UTF-8
|
Swift
| false | false | 3,560 |
swift
|
import SpriteKit
extension Double {
static let tau = 2 * Double.pi
}
class Seasons {
static var shared: Seasons!
var dayCounter: TimeInterval = 0
let sun: SKSpriteNode
init() {
let atlas = SKTextureAtlas(named: "Backgrounds")
let texture = atlas.textureNamed("sun")
self.sun = SKSpriteNode(texture: texture)
sun.alpha = 0 // Start the world at midnight
sun.color = .blue
sun.colorBlendFactor = 1
sun.size = ArkoniaScene.arkonsPortal!.size
ArkoniaScene.arkonsPortal!.addChild(sun)
start()
}
func getSeasonalFactors(_ onComplete: @escaping (CGFloat, CGFloat) -> Void) {
SceneDispatch.shared.schedule {
let ageOfYearInDays = self.dayCounter.truncatingRemainder(dividingBy: Arkonia.arkoniaDaysPerYear)
let yearCompletion: TimeInterval = ageOfYearInDays / Arkonia.arkoniaDaysPerYear
let scaledToSin = yearCompletion * TimeInterval.tau
// Shift -1...1 sine domain to 0...1
let weatherIntensityIndex = CGFloat(sin(scaledToSin) + 1) / 2
// Arkonia uses the proper (celsius) scale, but the temperature
// always stays in the range of 0.25...1˚C
let itReallyAmountsToTemperature = max(weatherIntensityIndex, 0.25)
// dayNightFactor == 1 means midday, 0 is midnight
let dayNightFactor = self.sun.alpha / Arkonia.maximumBrightnessAlpha
Debug.log(level: 182) {
"seasonalFactors:"
+ " julian date \(ageOfYearInDays)"
+ " 0..<1 \(yearCompletion)"
+ " for sin \(scaledToSin)"
+ " temp \(itReallyAmountsToTemperature)"
}
onComplete(dayNightFactor, itReallyAmountsToTemperature)
}
}
// Remember: as with pollenators, our update happens during the spritekit scene
// update, so it's ok for us to hit, for example, ArkoniaScene.currentSceneTime,
// unprotected, because it's never changed outside the scene update
func start() {
let durationToFullLight = Arkonia.realSecondsPerArkoniaDay * Arkonia.darknessAsPercentageOfDay
let durationToFullDarkness = Arkonia.realSecondsPerArkoniaDay * (1 - Arkonia.darknessAsPercentageOfDay)
let darken = SKAction.fadeAlpha(
to: 0,
duration: durationToFullLight
)
let lighten = SKAction.fadeAlpha(
to: Arkonia.maximumBrightnessAlpha,
duration: durationToFullDarkness
)
let countHalfDay = SKAction.run { self.dayCounter += 0.5 }
let oneDayOneNight = SKAction.sequence([lighten, countHalfDay, darken, countHalfDay])
let dayNightCycle = SKAction.repeatForever(oneDayOneNight)
let realSecondsPerYear = Arkonia.arkoniaDaysPerYear * Arkonia.realSecondsPerArkoniaDay
let winterDuration = realSecondsPerYear * Arkonia.winterAsPercentageOfYear
let summerDuration = realSecondsPerYear - winterDuration
let warm = SKAction.colorize(
with: .orange, colorBlendFactor: 1,
duration: winterDuration
)
let cool = SKAction.colorize(
with: .blue, colorBlendFactor: 1,
duration: summerDuration
)
let oneSummerOneWinter = SKAction.sequence([warm, cool])
let seasonCycle = SKAction.repeatForever(oneSummerOneWinter)
let bothCycles = SKAction.group([dayNightCycle, seasonCycle])
sun.run(bothCycles)
}
}
|
[
-1
] |
f991511108736014758ffcc6e3b872bc22f563f8
|
10d497d0f265c6c8402cd51385de1ae5d4f47361
|
/SugoiToolKitTests/SugoiToolKitTests.swift
|
a59407ddf8cfe0b5e941dd1e3c521f02d893c550
|
[
"MIT"
] |
permissive
|
gin0606/SugoiTool
|
c2f43bd96f4071b28bcf6392c7b084d8ae18e294
|
7f9f52ad559ba26f7936098bb618615852cd5178
|
refs/heads/master
| 2021-01-10T11:22:51.549812 | 2016-02-15T12:38:11 | 2016-02-15T12:38:11 | 51,576,132 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 300 |
swift
|
import XCTest
@testable import SugoiToolKit
class SugoiTests: XCTestCase {
func testSugoi() {
let sugoi = Sugoi(isSugoi: true)
XCTAssertEqual(sugoi.command(), "凄い")
}
func testSugokunai() {
let sugoi = Sugoi(isSugoi: false)
XCTAssertEqual(sugoi.command(), "普通")
}
}
|
[
-1
] |
71ef55d9bdc194169e2e674c632884e7f437d58c
|
e99f8764b47ff16f3a9408ffc45fb72e0b24b04d
|
/instagram_firebase/User.swift
|
12aef091fe0b8d47319de5c68d15c78eb774d2ac
|
[] |
no_license
|
qhuang20/instagram_firebase
|
a44dabfb6cf7f3e079508e66d63a3b791cbfce41
|
70e131efc55a04ea21b2f3c544ab4944e668067b
|
refs/heads/master
| 2021-04-29T21:20:53.328935 | 2018-03-13T20:54:46 | 2018-03-13T20:54:46 | 121,612,486 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 488 |
swift
|
//
// User.swift
// instagram_firebase
//
// Created by Qichen Huang on 2018-02-20.
// Copyright © 2018 Qichen Huang. All rights reserved.
//
import Foundation
struct User {
let uid: String
let username: String
let profileImageUrl: String
init(uid: String, dictionary: [String: Any]) {
self.uid = uid
self.username = dictionary["username"] as? String ?? ""
self.profileImageUrl = dictionary["profileImageUrl"] as? String ?? ""
}
}
|
[
-1
] |
4adb0e717659c8511c5c32e054873245941304cf
|
b8723ffea97efe3176623668bdf9cd4fd10d2266
|
/Sample-RealmApp-Swift/TableViewController.swift
|
ab83bef00eb5189afffde9974aea2bf7bce8880f
|
[] |
no_license
|
YunnieYunick/Sample-RealmApp-Swift
|
5e752988d21edfcbf618546f8131236a5937bb87
|
f677fb325e351e7b047ddc5c9cea317ece5ef47d
|
refs/heads/master
| 2021-01-11T16:54:46.268815 | 2017-01-23T15:24:58 | 2017-01-23T15:24:58 | 79,695,678 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 4,358 |
swift
|
//
// TableViewController.swift
// Sample-RealmApp-Swift
//
// Created by Yunnie Yunick on 2017/01/22.
// Copyright © 2017年 yunnieyunick. All rights reserved.
//
import UIKit
import RealmSwift
class TableViewController: UITableViewController {
var selectedNum = 0
var SampleItems:Results<Sample>?{
do{
let realm = try! Realm()
return realm.objects(Sample.self)
}catch{
print("エラー")
}
return nil
}
override func viewDidLoad() {
super.viewDidLoad()
//fing default.realm
//print(Realm.Configuration.defaultConfiguration.fileURL!)
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func viewDidAppear(_ animated: Bool) {
self.tableView .reloadData()
super.viewDidAppear(true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return (SampleItems?.count)!
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let item = SampleItems?[indexPath.row]
// Configure the cell...
cell.textLabel?.text = item?.name
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedNum = Int(indexPath.row)
performSegue(withIdentifier: "next", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if(segue.identifier == "next"){
var viewCon: ViewController = segue.destination as! ViewController
viewCon.count = selectedNum
}
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
|
[
-1
] |
a2aa5c4dffcccece9e168a5825c9a3b527e4c088
|
90d5682a1b8b98b32dfebecbb4708b86677a8f56
|
/PortfolioCell.swift
|
6433aedec96e7b27748d1733850cd1faa5b148c2
|
[] |
no_license
|
Replica-/ios-swift-torosolutions
|
b3544fb4164ba3edd9810f551ee6f7635fa1f6b8
|
b77940ee49108571dc027e42a76a365292422541
|
refs/heads/master
| 2021-05-12T17:46:19.926008 | 2018-01-11T05:36:17 | 2018-01-11T05:36:17 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 412 |
swift
|
//
// PortfolioCell.swift
// Toro Solutions
//
// Created by Replica on 2/07/2015.
// Copyright (c) 2015 Toro Solutions. All rights reserved.
//
import UIKit
class PortfolioCell: UITableViewCell {
@IBOutlet weak var viewImage: UIImageView!
@IBOutlet weak var viewLabel: UILabel!
@IBOutlet weak var view: UIView!
@IBOutlet weak var viewText: UITextView!
var data:PortfolioItem?
}
|
[
-1
] |
a25818a096e48b4c475573b7d6df8e26bac5bb5e
|
806fa72fd1f601c283f028fad100881ab053ad59
|
/Sources/Graphaello/Processing/Code Generstion/CodeTransformable/Array+CodeTransformable.swift
|
eb43a7df8db872ec7aefbb3566ebf8de4769b154
|
[
"MIT"
] |
permissive
|
nerdsupremacist/Graphaello
|
291485d85edfd40871c8f5a171608b4f131d89bb
|
83fb6106f222603c5ec3c539fdd859b6539ca89e
|
refs/heads/develop
| 2023-06-01T01:44:01.586570 | 2022-06-27T16:18:40 | 2022-06-27T16:18:40 | 242,351,920 | 505 | 22 |
MIT
| 2022-06-27T16:18:42 | 2020-02-22T14:06:25 |
Swift
|
UTF-8
|
Swift
| false | false | 791 |
swift
|
import Foundation
import Stencil
extension Array: CodeTransformable where Element: CodeTransformable {
func code(using context: Stencil.Context, arguments: [Any?]) throws -> String {
return try context.render(template: "Array.stencil", context: ["values" : self])
}
}
extension Array {
func code(using context: Stencil.Context, arguments: [Any?]) throws -> [String] {
return try compactMap { element in
switch element {
case let element as CodeTransformable:
return try element.code(using: context, arguments: arguments)
case let element as CustomStringConvertible:
return element.description
default:
return nil
}
}
}
}
|
[
-1
] |
7bec60eb45bf6366a7a39bfc32979969978cffab
|
c976cb46bac49658efd2bfdc569c4fbcfc0cc696
|
/Healthood/PostImageHelper.swift
|
6bded701559dd2793e3a87232b93ba505742665c
|
[] |
no_license
|
kbujak/Healthood
|
432556f578795768dbde4358c02bd64948a17b66
|
bfeeb3298f938195bb10af72dc3ca0d9ade0560e
|
refs/heads/master
| 2021-08-27T21:15:20.126857 | 2017-12-10T10:35:32 | 2017-12-10T10:35:32 | 104,774,587 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 3,829 |
swift
|
//
// PostImageHelper.swift
// Healthood
//
// Created by Krystian Bujak on 11/11/2017.
// Copyright © 2017 Krystian Bujak. All rights reserved.
//
import Foundation
import UIKit
class PostImageHelper{
let serverPath: String!
init(){
self.serverPath = "(UIApplication.shared.delegate as! AppDelegate).dataBaseDelegate.serverPath"
}
func myImageUploadRequest(with image: UIImage, for name: String, using db: DataBaseProtocol, imgType: ImageType){
let serverURL = URL(string: "http://" + self.serverPath + "/healt/postImage.php")
var request = URLRequest(url: serverURL!)
request.httpMethod = "POST"
let param = [
"name" : String.SHA256(name + String.randomString(length: 15))! + ".jpg",
"dbType" : db.dataBaseType.rawValue,
"imgType" : imgType.rawValue
]
let boundary = generateBoundaryString()
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
let imageData = UIImageJPEGRepresentation(image, 0.8)
if(imageData==nil) { return }
request.httpBody = createBodyWithParameters(parameters: param, filePathKey: "file", imageDataKey: imageData! as NSData, boundary: boundary) as Data
let task = URLSession.shared.dataTask(with: request){
data, response, error in
if error != nil{
print("error = \(error!)")
}
if imgType == .food{
DispatchQueue.main.async {
try? db.addFoodImagePath(for: name, with: "/\(db.dataBaseType.rawValue)/\(ImageType.food.rawValue)/\(String(describing: param["name"]!))")
}
}else{
DispatchQueue.main.async {
try? db.changeUserProfileImage(with: param["name"]!, for: UserDefaults.standard.object(forKey: "logInUserId") as! String)
}
}
print("*****response = \(response!)")
let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
print("****** response data = \(responseString!)")
do {
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary
print(json)
}catch
{
print(error)
}
}
task.resume()
}
func createBodyWithParameters(parameters: [String: String]?, filePathKey: String?, imageDataKey: NSData, boundary: String) -> NSData {
let body = NSMutableData();
if parameters != nil {
for (key, value) in parameters! {
body.appendString(string: "--\(boundary)\r\n")
body.appendString(string: "Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n")
body.appendString(string: "\(value)\r\n")
}
}
let filename = "user-profile.jpg"
let mimetype = "image/jpg"
body.appendString(string: "--\(boundary)\r\n")
body.appendString(string: "Content-Disposition: form-data; name=\"\(filePathKey!)\"; filename=\"\(filename)\"\r\n")
body.appendString(string: "Content-Type: \(mimetype)\r\n\r\n")
body.append(imageDataKey as Data)
body.appendString(string: "\r\n")
body.appendString(string: "--\(boundary)--\r\n")
return body
}
func generateBoundaryString() -> String {
return "Boundary-\(NSUUID().uuidString)"
}
}
extension NSMutableData {
func appendString(string: String) {
let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
append(data!)
}
}
|
[
-1
] |
4205db80365f1c1bb48d55ac1e004aa06f7ca320
|
92bc46cf7a7aae785ee20e8fa5f698314e93f64c
|
/baforada/ShowResultView.swift
|
2a94be1a4fad8e80ccac85a5868d0400e30d0381
|
[] |
no_license
|
Henrique1701/BaforADA
|
c5e481e15af3924c050cd51887c64c5c9cfc8a34
|
a7ce9a56bf85dd1682ba3031f87709e8828de894
|
refs/heads/master
| 2023-03-02T09:15:22.962469 | 2021-02-11T23:00:32 | 2021-02-11T23:00:32 | 335,717,501 | 1 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,535 |
swift
|
//
// ShowResultView.swift
// baforada
//
// Created by Samuel Brasileiro on 10/02/21.
//
import SwiftUI
struct ShowResultView: View {
var drunkness: Drunkness
@Binding var isActive: Bool
var body: some View {
VStack{
HStack{
Text("Baforada")
.foregroundColor(.beerYellow)
.font(.system(size: 50, weight: .bold, design: .default))
Spacer()
}
.padding(20)
Spacer()
HStack{
VStack(alignment: .leading){
Text("Faça o nosso teste")
.foregroundColor(.white)
.font(.system(size: 30, weight: .bold, design: .default))
Text("E descubra o seu grau de embriaguez")
.foregroundColor(.gray)
.font(.system(size: 16, weight: .regular, design: .default))
.frame(maxWidth: 200)
}
Spacer()
}
.padding(20)
.padding(.bottom, 40)
Text(String(drunkness.rawValue))
Image("drunkperson")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(100)
Spacer()
}
.background(Color.darkGray)
.navigationBarHidden(true)
}
}
|
[
-1
] |
28a00c623b6e7fd7988c97b40f393b18be8a5717
|
df4b9f297c2b08acdfc5a8e982e366302261ed34
|
/mfc/Tabs/Profile Views/Profile.swift
|
acf6999f3b820de109fec0ca217eec5aa4fc4ce7
|
[] |
no_license
|
shamil-chomaev/mfc
|
34f596a49ef5ecf40331adb962948f33b3c5f133
|
58fa4543c36f133f1f6d5fca0aade4b4c379ac6c
|
refs/heads/main
| 2023-02-08T00:08:04.053322 | 2020-12-25T09:08:15 | 2020-12-25T09:08:15 | 306,860,801 | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 11,392 |
swift
|
//
// Profile.swift
// mfc
//
// Created by Shamil Chomaev on 24.10.2020.
//
import SwiftUI
import FirebaseAuth
import FirebaseFirestore
struct Profile: View {
@State var showAuthView: Bool = false
@State var authState: AuthViewState = .authorization
@State var isAuth: Bool = false
@State var uemail: String = ""
var body: some View {
NavigationView{
ScrollView(.vertical, showsIndicators: true){
VStack(alignment: .center, spacing: 20) {
if isAuth {
ProfileView(uemail: uemail)
} else {
ZStack(alignment: .center) {
Color("BackgroundColorRow")
Button(action: {
self.authState = .authorization
self.showAuthView = true
print("authorization")
}){
HStack(alignment: .center, spacing: 10.0){
Image(systemName: "arkit")
.font(.body)
.frame(width: 20)
// Divider()
Text("Вход")
.font(.body)
.fontWeight(.regular)
Spacer()
Image(systemName: "chevron.right")
.font(.body)
.foregroundColor(Color("Primary"))
}
}
.buttonStyle(PlainButtonStyle())
.padding(15)
}
.clipShape(RoundedRectangle(cornerRadius: 15))
.padding(.horizontal ,15)
}
Divider()
VStack(alignment: .leading, spacing: 10) {
SectionTitle(title: "Сервис")
URLButtonView(image: "arkit", title: "Участвовать в разработке", url: "https://t.me/joinchat/AAAAAFWCjDfLSi-i_g_6fQ")
URLButtonView(image: "text.bubble", title: "Написать разработчику", url: "https://instagram.com/dv.shama")
URLButtonView(image: "circle.grid.hex", title: "Открытый бэклог", url: "https://instagram.com/dv.shama")
}
.padding(.horizontal ,15)
if isAuth {
Divider()
ProfileServiceView(isAuth: $isAuth)
}
Divider()
AppInfoView()
}
.padding(.horizontal)
.frame(width: UIScreen.main.bounds.width)
// .padding(.horizontal)
}
.sheet(isPresented: $showAuthView) {
AuthView(showAuthView: $showAuthView, isAuth: $isAuth, stateAuth: authState)
}
.onAppear(){
if Auth.auth().currentUser != nil {
self.uemail = (Auth.auth().currentUser?.email)!
self.isAuth = true
} else {
self.isAuth = false
// No user is signed in.
// ...
}
}
.navigationTitle("Профиль")
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
struct ProfileView: View {
@State var fullName: String = ""
@State var email: String = ""
var uemail: String
var body: some View {
ZStack(alignment: .center) {
VStack(alignment: .center, spacing: 15){
// Image("shamiltestphoto")//"unfoundpic")
Image("unfoundpic")//"unfoundpic")
.resizable()
.frame(width: 125, height: 125)
.aspectRatio(1, contentMode: .fit)
// .mask(Circle())
.clipShape(Circle())
// .shadow(radius: 10)
.overlay(Circle().stroke(Color("Primary"), lineWidth: 3))
Text(fullName)
.font(.title)
.fontWeight(.bold)
ZStack(alignment: .leading) {
Color("BackgroundColorRow")
VStack(alignment: .leading, spacing: 0){
Text("Электронная почта")
.font(.caption)
.fontWeight(.light)
Text(email)
.font(.body)
.fontWeight(.bold)
}
.padding(15)
}
.clipShape(RoundedRectangle(cornerRadius: 15))
// ZStack(alignment: .leading) {
// Color("BackgroundColorRow")
// VStack(alignment: .leading, spacing: 0){
// Text("Телефон")
// .font(.caption)
// .fontWeight(.light)
// Text("+7-999-999-99-99")
// .font(.body)
// .fontWeight(.bold)
// }
// .padding(15)
// }
// .clipShape(RoundedRectangle(cornerRadius: 15))
}
.padding(15)
}
.clipShape(RoundedRectangle(cornerRadius: 15))
.onAppear(){
Firestore.firestore().collection("users").document(uemail).getDocument { (document, error) in
if let document = document, document.exists {
let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
self.fullName = "\(document.get("lastName") as! String) \(document.get("firstName") as! String)"
self.email = document.get("email") as! String
UserProfileControl.SetUserStatus(tp: "\(document.get("type") as! String)")
print("Document data: \(dataDescription)")
} else {
print("Document does not exist")
}
}
}
}
}
struct ProfileServiceView: View {
@Binding var isAuth: Bool
var body: some View {
ZStack(alignment: .center) {
// Color.gray.opacity(0.1)//(."BackgroundColorRow")
VStack(alignment: .center, spacing: 10.0){
Button(action: {
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
UserProfileControl.DeleteUserStatus()
self.isAuth = false
} catch let signOutError as NSError {
print ("Error signing out: %@", signOutError)
}
// let url = URL (string: "https://instagram.com/dv.shama")!
// UIApplication.shared.open (url)
}){
Text("Выйти")
.font(.body)
.fontWeight(.regular)
.foregroundColor(Color.red)
}
.buttonStyle(PlainButtonStyle())
}
.padding(15)
}
.clipShape(RoundedRectangle(cornerRadius: 15))
}
}
struct SectionTitle: View {
var title: String
var body: some View {
HStack(alignment: .center){
Text(title)
.font(.caption)
Spacer()
}
}
}
struct URLButtonView: View {
var image: String
var title: String
var url: String
var body: some View {
ZStack(alignment: .center) {
Color("BackgroundColorRow")
Button(action: {
let openUrl = URL (string: "\(url)")!
UIApplication.shared.open (openUrl)
}){
HStack(alignment: .center, spacing: 10.0){
Image(systemName: image)
.font(.body)
.frame(width: 20)
// Divider()
Text(title)
.font(.body)
.fontWeight(.regular)
Spacer()
Image(systemName: "chevron.right")
.font(.body)
.foregroundColor(Color("Primary"))
}
}
.buttonStyle(PlainButtonStyle())
.padding(15)
}
.clipShape(RoundedRectangle(cornerRadius: 15))
}
}
struct AppInfoView: View {
@State var version: String = "0.0.0"
@State var build: String = "0"
var body: some View {
VStack(alignment: .center, spacing: 10){
Button(action: {
let url = URL (string: "https://instagram.com/dv.shama")!
UIApplication.shared.open (url)
}){
Text("Политика конфиденциальности")
.font(.caption)
.fontWeight(.light)
.underline()
}
.buttonStyle(PlainButtonStyle())
Button(action: {
let url = URL (string: "https://instagram.com/dv.shama")!
UIApplication.shared.open (url)
}){
Text("О приложении")
.font(.caption)
.fontWeight(.light)
.underline()
}
.buttonStyle(PlainButtonStyle())
Text("Версия \(version) (\(build))")
.font(.caption)
.fontWeight(.light)
}
.onAppear(){
if let versionBundle = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
let buildBundle = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
self.build = buildBundle
self.version = versionBundle
}
}
}
}
struct Profile_Previews: PreviewProvider {
static var previews: some View {
Profile()
}
}
|
[
-1
] |
902e7b8d8e5e4dac19d8bb28386548ef468914a5
|
b92308aacc122264fc7db9a0c53cbf766301a2b7
|
/MyFitMembers/Cell/TableViewCell/FoodPicsTableViewCell.swift
|
969571cd3e3c3e0beaf3358d82e3aaf5ef7066a8
|
[] |
no_license
|
torst/SocialNetworking
|
95d1e7827282ef4b550e9a0fe257dfa4bbab3c4d
|
2d3e49972a5a43e1beb350cc1b1576748e77b623
|
refs/heads/master
| 2021-07-23T00:15:20.480471 | 2017-11-03T02:51:41 | 2017-11-03T02:51:41 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,537 |
swift
|
//
// FoodPicsTableViewCell.swift
// MyFitMembers
//
// Created by Boris Esanu on 10/10/16.
// Copyright © 2016 Codebrew. All rights reserved.
//
import UIKit
class FoodPicsTableViewCell: UITableViewCell {
//MARK::- OUTLETS
@IBOutlet weak var imageFood: UIImageView!
@IBOutlet weak var labelTyme: UILabel!
@IBOutlet weak var labelFoodType: UILabel!
//MARK::- OVERRIDE FUNCTIONS
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
}
//MARK::- FUNCTIONS
func setData(_ foodData:FoodPics){
guard let image = foodData.userImage?.userOriginalImage else {return}
let imgUrl = ApiCollection.apiImageBaseUrl + image
guard let imageUrlX = URL(string: imgUrl) else {return}
imageFood.yy_setImage(with: imageUrlX, options: .progressiveBlur)
let foodTime = changeStringDateFormat1(foodData.foodPicDate ?? "",fromFormat:"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",toFormat:"hh:mm a")
let foddDateFormatted = foodTime.toLocalTime()
let foodFormattedTime = foddDateFormatted.changeFormatOnly("hh:mm a", date: foddDateFormatted)
labelTyme.text = foodFormattedTime
labelFoodType.text = foodData.foodType
}
//MARK::- ACTIONS
}
|
[
-1
] |
f7357caa972e251710e87f25aac14d10a8be93d9
|
4f5b37146490b70e6c85844d2c372649df19b03c
|
/Shared/Model/AppFoundation/Statistics/ModelRandomizer.swift
|
af8e7a3aa29fe98ff99e43b7bd4dcdac6004cfec
|
[] |
no_license
|
lionelmichaud/Patrimoine
|
644565fb9a34f7daa800ab38f6e6806946493421
|
87558052eab5cff0e97adabbea6908a49c7609ab
|
refs/heads/master
| 2023-04-30T07:10:20.299022 | 2021-03-29T13:44:29 | 2021-03-29T13:44:29 | 273,727,573 | 2 | 0 | null | null | null | null |
UTF-8
|
Swift
| false | false | 1,714 |
swift
|
//
// ModelRandomizer.swift
// Patrimoine
//
// Created by Lionel MICHAUD on 26/09/2020.
// Copyright © 2020 Lionel MICHAUD. All rights reserved.
//
import Foundation
// MARK: - Model aléatoire
struct ModelRandomizer<R: RandomGenerator>: Codable, Versionable
where R: Codable,
R.Number == Double {
// MARK: - Properties
var version : Version
var name : String
var rndGenerator : R
private var defaultValue : Double = 0 // valeur par defaut déterministe
private var randomValue : Double = 0 // dernière valeur randomisée
var randomHistory : [Double]? // historique des tirages aléatoires
// MARK: - Methods
/// Remettre à zéro les historiques des tirages aléatoires
mutating func resetRandomHistory() {
randomHistory = []
}
/// Générer le nombre aléatoire suivant
mutating func next() -> Double {
randomValue = Double(rndGenerator.next())
if randomHistory == nil {
randomHistory = []
}
randomHistory!.append(randomValue)
return randomValue
}
/// Définir une valeur pour la variable aléaoitre avant un rejeu
/// - Parameter value: nouvelle valeure à rejouer
mutating func setRandomValue(to value: Double) {
randomValue = value
}
/// Returns a default value or a random value depending on the value of simulationMode.mode
func value(withMode mode : SimulationModeEnum) -> Double {
switch mode {
case .deterministic:
return defaultValue
case .random:
return randomValue
}
}
}
|
[
-1
] |
d45ab62fee6959e56b2461564c980f3d3b478d08
|
d467657a2ce223a79c56cb3da23957bac06c608a
|
/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/PetAPITests.swift
|
63b3954b246cf18c582fb3ff0bc92c826acea8ad
|
[
"Apache-2.0"
] |
permissive
|
zenreach/swagger-codegen
|
2620f2b04ac9873320aa1c9cf95cfa0be562e505
|
809d6471035bdab59597dc14e12af77fc3ae4085
|
refs/heads/master
| 2020-12-24T10:12:57.496323 | 2020-05-01T18:58:42 | 2020-05-01T18:58:42 | 52,184,381 | 0 | 0 |
NOASSERTION
| 2020-05-01T18:58:43 | 2016-02-21T01:02:51 |
HTML
|
UTF-8
|
Swift
| false | false | 3,067 |
swift
|
//
// PetAPITests.swift
// SwaggerClient
//
// Created by Joseph Zuromski on 2/8/16.
// Copyright © 2016 Swagger. All rights reserved.
//
import PetstoreClient
import PromiseKit
import XCTest
@testable import SwaggerClient
class PetAPITests: XCTestCase {
let testTimeout = 10.0
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 test1CreatePet() {
let expectation = self.expectationWithDescription("testCreatePet")
let newPet = Pet()
let category = PetstoreClient.Category()
category.id = 1234
category.name = "eyeColor"
newPet.category = category
newPet.id = 1000
newPet.name = "Fluffy"
newPet.status = .Available
PetstoreClientAPI.PetAPI.addPet(body: newPet).execute().then { response -> Void in
expectation.fulfill()
}.always {
// Noop for now
}.error { errorType -> Void in
XCTFail("error creating pet")
}
self.waitForExpectationsWithTimeout(testTimeout, handler: nil)
}
func test2GetPet() {
let expectation = self.expectationWithDescription("testGetPet")
PetstoreClientAPI.PetAPI.getPetById(petId: 1000).execute().then { response -> Void in
let pet = response.body
XCTAssert(pet.id == 1000, "invalid id")
XCTAssert(pet.name == "Fluffy", "invalid name")
expectation.fulfill()
}.always {
// Noop for now
}.error { errorType -> Void in
XCTFail("error creating pet")
}
self.waitForExpectationsWithTimeout(testTimeout, handler: nil)
}
func test3DeletePet() {
let expectation = self.expectationWithDescription("testDeletePet")
PetstoreClientAPI.PetAPI.deletePet(petId: 1000).execute().always { response -> Void in
// expectation.fulfill()
}.always {
// Noop for now
}.error { errorType -> Void in
// The server gives us no data back so alamofire parsing fails - at least
// verify that is the error we get here
// Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero
// length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero
// length.}
let error = errorType as NSError
if error.code == -6006 {
expectation.fulfill()
} else {
XCTFail("error logging out")
}
}
self.waitForExpectationsWithTimeout(testTimeout, handler: nil)
}
}
|
[
-1
] |
71c6c875adde74921458b5583e334a8f4cdac02f
|
60ea416df522fad8c01bd0215686b6d0013a39dd
|
/ZhangChu/Views/Community/PictureCell.swift
|
0a3f06bdcfb2259ca5ad36e5cf140dbbe7341515
|
[] |
no_license
|
swordChow/Zhangchu
|
586074978823f5fe5a46b897bc6dee6a6295e343
|
f8e8515fa90e4b556294849b446b40e31d060909
|
refs/heads/master
| 2020-06-28T11:27:04.513080 | 2016-09-22T09:32:10 | 2016-09-22T09:32:10 | 67,608,077 | 2 | 2 | null | null | null | null |
UTF-8
|
Swift
| false | false | 960 |
swift
|
//
// PictureCell.swift
// ZhangChu
//
// Created by sword on 16/8/17.
// Copyright © 2016年 Chow-Chow. All rights reserved.
//
import UIKit
class PictureCell: UITableViewCell {
var mainImageView = UIImageView()
override func awakeFromNib() {
super.awakeFromNib()
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.mainImageView = UIImageView(frame: CGRectMake(0, 0, screenWidth / 4, screenWidth / 4))
self.contentView.addSubview(self.mainImageView)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
|
[
-1
] |