Skip to content

Commit

Permalink
Since the activity VC takes a while to present, let's make sure to in…
Browse files Browse the repository at this point in the history
…dicate loading
  • Loading branch information
Geoffrey Liu committed Jan 23, 2022
1 parent 4fe1896 commit 8897b0a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion WordleWithFriends/WordGuessViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ final class WordGuessViewController: UIViewController {
return textField
}()

private lazy var loadingView: UIActivityIndicatorView = {
let view = UIActivityIndicatorView(style: .large)
view.translatesAutoresizingMaskIntoConstraints = false

view.startAnimating()
view.isHidden = true

return view
}()

private var gameMessagingVC: GameMessagingViewController

private var isBeingScrolled = false
Expand Down Expand Up @@ -75,7 +85,9 @@ final class WordGuessViewController: UIViewController {

view.addSubview(guessTable)
view.addSubview(guessInputTextField)
view.addSubview(loadingView)
guessTable.pin(to: view.safeAreaLayoutGuide, margins: .init(top: 12, left: 0, bottom: 0, right: 0))
loadingView.pin(to: view.safeAreaLayoutGuide)

guessInputTextField.becomeFirstResponder()
title = "Guess the word"
Expand Down Expand Up @@ -169,8 +181,11 @@ final class WordGuessViewController: UIViewController {
guard let gameResult = UIPasteboard.general.string else {
return
}
loadingView.isHidden = false
let ac = UIActivityViewController(activityItems: [gameResult], applicationActivities: nil)
navigationController?.present(ac, animated: true)
navigationController?.present(ac, animated: true) { [weak self] in
self?.loadingView.isHidden = true
}
}
}

Expand Down

0 comments on commit 8897b0a

Please sign in to comment.