-
-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]> Finish Signed-off-by: Milen Pivchev <[email protected]> WIP Signed-off-by: Milen Pivchev <[email protected]>
- Loading branch information
Showing
7 changed files
with
244 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// UIButton+Extension.swift | ||
// Nextcloud | ||
// | ||
// Created by Milen Pivchev on 17.12.24. | ||
// Copyright © 2024 Marino Faggiana. All rights reserved. | ||
// | ||
|
||
extension UIButton { | ||
func hideButtonAndShowSpinner(tint: UIColor = .white) { | ||
self.isHidden = true | ||
|
||
let spinnerTag = Int(bitPattern: Unmanaged.passUnretained(self).toOpaque()) | ||
if self.superview?.subviews.first(where: { view -> Bool in | ||
return view.isKind(of: UIActivityIndicatorView.self) && view.tag == spinnerTag | ||
}) != nil { | ||
return | ||
} | ||
|
||
let spinner = UIActivityIndicatorView(style: .medium) | ||
spinner.tag = spinnerTag | ||
spinner.color = tint | ||
spinner.startAnimating() | ||
spinner.center = self.center | ||
self.superview?.addSubview(spinner) | ||
spinner.translatesAutoresizingMaskIntoConstraints = false | ||
spinner.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true | ||
spinner.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true | ||
} | ||
|
||
func hideSpinnerAndShowButton() { | ||
let spinnerTag = Int(bitPattern: Unmanaged.passUnretained(self).toOpaque()) | ||
let spinner = self.superview?.subviews.first(where: { view -> Bool in | ||
return view.isKind(of: UIActivityIndicatorView.self) && view.tag == spinnerTag | ||
}) | ||
|
||
spinner?.removeFromSuperview() | ||
self.isHidden = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.