Skip to content

Commit

Permalink
Revert "Merge pull request #238 from Narsail/master"
Browse files Browse the repository at this point in the history
  • Loading branch information
pcantrell committed Mar 9, 2018
1 parent 9261272 commit fb27aa9
Showing 1 changed file with 46 additions and 50 deletions.
96 changes: 46 additions & 50 deletions Source/SiestaUI/NetworkActivityIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,58 @@
// Copyright © 2016 Bust Out Solutions. All rights reserved.
//

#if UIApplication
#if !COCOAPODS
import Siesta
#endif
import UIKit
#if !COCOAPODS
import Siesta
#endif
import UIKit

// Tracks the number of requests in progress across all Siesta services
private var requestsInProgress = 0
// Tracks the number of requests in progress across all Siesta services
private var requestsInProgress = 0
{
didSet
{
didSet
{

UIApplication.shared.isNetworkActivityIndicatorVisible =
requestsInProgress > 0

}
UIApplication.shared.isNetworkActivityIndicatorVisible =
requestsInProgress > 0
}

private func requestStarted()
{ requestsInProgress += 1 }

private func requestCompleted()
{ requestsInProgress -= 1 }

extension Configuration
}

private func requestStarted()
{ requestsInProgress += 1 }

private func requestCompleted()
{ requestsInProgress -= 1 }

extension Configuration
{
/**
Causes requests to automatically show and hide the iOS network activity indicator. You can attach this to an
entire service:
service.configure {
$0.useNetworkActivityIndicator()
}
…or only to carefully selected large resources, if you are looking to follow [Apple’s Human Interface guidelines
for the indicator](https://developer.apple.com/ios/human-interface-guidelines/ui-controls/progress-indicators/#network-activity-indicators):
service.configure("/downloads/​**") {
$0.useNetworkActivityIndicator()
}
service.configure("/profile/avatar", requestMethods: [.post, .put]) {
$0.useNetworkActivityIndicator()
}
*/
public mutating func useNetworkActivityIndicator()
{
/**
Causes requests to automatically show and hide the iOS network activity indicator. You can attach this to an
entire service:
service.configure {
$0.useNetworkActivityIndicator()
}
…or only to carefully selected large resources, if you are looking to follow [Apple’s Human Interface guidelines
for the indicator](https://developer.apple.com/ios/human-interface-guidelines/ui-controls/progress-indicators/#network-activity-indicators):
service.configure("/downloads/​**") {
$0.useNetworkActivityIndicator()
}
service.configure("/profile/avatar", requestMethods: [.post, .put]) {
$0.useNetworkActivityIndicator()
}
*/
public mutating func useNetworkActivityIndicator()
decorateRequests
{
decorateRequests
{
resource, request in
resource, request in

requestStarted()
request.onCompletion
{ _ in requestCompleted() }
requestStarted()
request.onCompletion
{ _ in requestCompleted() }

return request
}
return request
}
}
#endif
}

0 comments on commit fb27aa9

Please sign in to comment.