From 534f1e209439b5b236a4dbcb0d34fb45edae7a27 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 1 Dec 2018 09:02:33 +0100 Subject: [PATCH] Show activity indicator while loading license --- Passepartout-iOS/Global/Theme.swift | 6 ++++++ .../Scenes/Organizer/LabelViewController.swift | 8 ++++++++ Passepartout-iOS/en.lproj/Organizer.storyboard | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index fc046b0f..25d4113a 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -136,6 +136,12 @@ extension UITextField { } } +extension UIActivityIndicatorView { + func applyAccent(_ theme: Theme) { + color = theme.palette.colorAccent1 + } +} + // XXX: status bar is broken extension MFMailComposeViewController { func apply(_ theme: Theme) { diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index 078bb475..8894f6db 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -28,6 +28,8 @@ import UIKit class LabelViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView? + @IBOutlet private weak var activity: UIActivityIndicatorView? + @IBOutlet private weak var label: UILabel? var text: String? @@ -43,12 +45,18 @@ class LabelViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + activity?.hidesWhenStopped = true + activity?.applyAccent(Theme.current) + if let url = url { label?.text = nil + activity?.startAnimating() + DispatchQueue(label: LabelViewController.description(), qos: .background).async { [weak self] in let urlText = try? String(contentsOf: url) DispatchQueue.main.async { self?.label?.text = urlText + self?.activity?.stopAnimating() } } } else { diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard index 2818c92a..94f21074 100644 --- a/Passepartout-iOS/en.lproj/Organizer.storyboard +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -599,10 +599,15 @@ + + + + + @@ -610,6 +615,7 @@ +