This file contains hidden or 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
    
  
  
    
  | import SwiftUI | |
| public struct SpinnerView: UIViewRepresentable { | |
| public typealias UIViewType = UIActivityIndicatorView | |
| public init(isAnimating: Binding<Bool>, style: UIActivityIndicatorView.Style) { | |
| self._isAnimating = isAnimating | |
| self.style = style | |
| } | |
  
    
      This file contains hidden or 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
    
  
  
    
  | private func isLastItem(index: Int) -> Bool { | |
| index == (items.count - 1) | |
| } | |
| private func isOffsetReached(at index: Int) -> Bool { | |
| index == (items.count - offset) | |
| } | |
| private func itemAppears(at index: Int) { | |
| if isOffsetReached(at: index) { | 
  
    
      This file contains hidden or 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
    
  
  
    
  | var pagination: ((() -> Void)?) -> Void | |
| @State var isLoading = false | |
| private var offset: Int | 
  
    
      This file contains hidden or 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
    
  
  
    
  | public struct ListPagination<Item: Identifiable, Content: View>: View { | |
| private var items: [Item] | |
| var content: (_ item: Item) -> Content | 
  
    
      This file contains hidden or 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
    
  
  
    
  | public init (items: [Item], offset: Int = 5, | |
| pagination: @escaping (_ completion: (() -> Void)?) -> Void, | |
| @ViewBuilder content: @escaping (_ item: Item) -> Content) { | |
| self.items = items | |
| self.content = content | |
| self.pagination = pagination | |
| self.offset = offset | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | public var body: some View { | |
| List { | |
| //1. | |
| ForEach(items.indices, id: \.self) { index in | |
| VStack { | |
| //2. | |
| self.content(self.items[index]) | |
| //3. | |
| if self.isLoading && self.isLastItem(index: index) { | 
  
    
      This file contains hidden or 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
    
  
  
    
  | func getNearestDegree(time: String) -> Int { | |
| let array = time.split(separator: ":") | |
| let hours = Int(array[0])! | |
| let minutes = Int(array[1])! | |
| let hourPosition = hours*60 + minutes | |
| let minutesPosition = 12*minutes | |
| let actualPosition = hourPosition - minutesPosition | |
| let degrees = actualPosition/2 | |
NewerOlder