This commit is contained in:
Alexey Gerasimov 2017-04-27 15:58:44 +03:00
parent deb9b3b9e1
commit 39ca3d7fbd
2 changed files with 21 additions and 8 deletions

View File

@ -32,7 +32,7 @@ public enum LoadingBarButtonSide {
public class LoadingBarButton {
fileprivate weak var navigationItem: UINavigationItem?
fileprivate var savedBarButton: UIBarButtonItem?
fileprivate var initialBarButton: UIBarButtonItem?
private let side: LoadingBarButtonSide
private var barButtonItem: UIBarButtonItem? {
@ -57,17 +57,16 @@ public class LoadingBarButton {
public init(navigationItem: UINavigationItem, side: LoadingBarButtonSide) {
self.navigationItem = navigationItem
self.side = side
initialBarButton = barButtonItem
}
fileprivate func setState(waiting: Bool = false) {
if waiting {
savedBarButton = barButtonItem
let activityIndicatorItem = UIBarButtonItem.activityIndicator
barButtonItem = activityIndicatorItem.barButton
activityIndicatorItem.activityIndicator.startAnimating()
} else {
barButtonItem = savedBarButton
barButtonItem = initialBarButton
}
}

View File

@ -1,9 +1,23 @@
//
// ApiErrorProtocol.swift
// LeadKitAdditions
// Copyright (c) 2017 Touch Instinct
//
// Created by Alexey Gerasimov on 27/04/2017.
// Copyright © 2017 TouchInstinct. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
public protocol ApiErrorProtocol: RawRepresentable {}