// // AccountControllerTutorial.swift // Wallet // // Created by Saveliy Stavitsky on 9/29/20. // Copyright © 2020 List. All rights reserved. // import UIKit class AccountControllerTutorial: UIViewController { @IBOutlet var pageStackView: UIStackView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // if Accounts().current != nil { // dismiss(animated: true) // } } @IBAction func addAccountPressed(_ sender: Any) { UserDefaults.standard.setValue(true, forKey: "onboardingOverviewPassed") AccountController.showPopup(in: self) } @IBAction func skipPressed(_ sender: Any) { UserDefaults.standard.setValue(true, forKey: "onboardingOverviewPassed") self.dismiss(animated: true) } var current = -1 } extension AccountControllerTutorial: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { let width = scrollView.frame.width let page = Int(round(scrollView.contentOffset.x/width)) guard current != page else { return } current = page print("CurrentPage:\(page)") UIView.animate(withDuration: 0.3, animations: { self.pageStackView.arrangedSubviews .forEach({ ($0 as? UIButton)?.setImage(Asset.accountOnboardingStep.image, for: .normal) }) (self.pageStackView.arrangedSubviews[page] as? UIButton)? .setImage(Asset.accountOnboardingCurrentStep.image, for: .normal) }) } }