Skip to content

Instantly share code, notes, and snippets.

View michal-majchrzycki's full-sized avatar

Michal Majchrzycki michal-majchrzycki

  • Poland, Poznan
View GitHub Profile
on run {input, parameters}
set foldersList to {"DerivedData", "Archives", "iOS DeviceSupport", "CoreSimulator", "com.apple.dt.Xcode", "Backup"}
set choseFoldersToDelete to (choose from list foldersList with title "Pick Xcode folders to delete" with prompt "Automator will remove files from selected folders to Trash" default items "None" OK button name "Next" cancel button name "Cancel" with multiple selections allowed)
if choseFoldersToDelete is false then error number -128
set theAlertText to "You've picked files from folders:"
set saveTID to text item delimiters
set text item delimiters to ", "
set theAlertMessage to choseFoldersToDelete as text
set text item delimiters to saveTID
final class Spinner {
fileprivate static var activityIndicator: UIActivityIndicatorView?
fileprivate static var style: UIActivityIndicatorViewStyle = .whiteLarge
fileprivate static var baseBackColor = UIColor(white: 0, alpha: 0.6)
fileprivate static var baseColor = UIColor.white
/**
Add spinner to `UIView`
//
// Spinner.swift
//
// Created by Michał Majchrzycki on 28.03.2018.
// Copyright © 2018 Prograils.com. All rights reserved.
// Check whole tutorial at: https://prograils.com/posts/reusable-activity-indicator-with-swift
import UIKit
open class Spinner {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
self.calendarArray = getCalendar().arrayOfDates()
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if calendarCollectionView == scrollView && !decelerate {
setSelectedItemFromScrollView(scrollView)
}
}
func setSelectedItemFromScrollView(_ scrollView: UIScrollView) {
if calendarCollectionView == scrollView {
let center = CGPoint(x: scrollView.center.x + scrollView.contentOffset.x, y: scrollView.center.y + scrollView.contentOffset.y)
let index = calendarCollectionView.indexPathForItem(at: center)
if index != nil {
calendarCollectionView.scrollToItem(at: index!, at: .centeredHorizontally, animated: true)
self.calendarCollectionView.selectItem(at: index, animated: false, scrollPosition: [])
self.collectionView(self.calendarCollectionView, didSelectItemAt: index!)
self.selectedDate = (index?.row)!
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
if calendarCollectionView == scrollView {
setSelectedItemFromScrollView(scrollView)
}
}
let centeredIndexPath = IndexPath.init(item: selectedDate, section: 0)
collectionView.scrollToItem(at: centeredIndexPath, at: .centeredHorizontally, animated: true)
if indexPath == centeredIndexPath {
collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
}
self.selectedDateLabel.text = self.calendarArray?[indexPath.row] as? String
override var isSelected: Bool {
didSet {
if isSelected {
dateLabel!.textColor = UIColor.green
dateLabel.font = UIFont.boldSystemFont(ofSize: 14)
} else {
dateLabel!.textColor = UIColor.darkText
dateLabel.font = UIFont.systemFont(ofSize: 14)
}
}