Skip to content

Commit

Permalink
Add ActivityIndicator and update project to accept pods
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeAGomes committed Jan 7, 2022
1 parent 66d9cd7 commit f7b38fe
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Credentials
run: |
git config --global credential.helper store
echo "https://AnTonhoLAB:${{ secrets.ACCESS_TOKEN }}@github.com" > ~/.git-credentials
- name: Pod Install
run: pod install
- name: Run tests
run: xcodebuild clean test -project GGDevelopmentKit.xcodeproj -scheme GGDevelopmentKit -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest"
run: xcodebuild clean test -workspace GGDevelopmentKit.xcworkspace -scheme GGDevelopmentKit -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.2.1
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

---

## [0.2.0](https://github.com/AnTonhoLAB/GGDevelopmentKit/releases/tag/0.2.0) - 2022-01-07
### Added
- ActivityIndicator - Add ActivityIndicator for request controll

## [0.1.1](https://github.com/AnTonhoLAB/GGDevelopmentKit/releases/tag/0.1.1) - 2022-01-06
### Fix
- GGCoordinator - fix GGCoordiator reference to navigation coordinator.
Expand Down
6 changes: 5 additions & 1 deletion GGDevelopmentKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |spec|
spec.platform = :ios
spec.ios.deployment_target = '10.0'
spec.name = "GGDevelopmentKit"
spec.version = "0.1.1"
spec.version = "0.2.0"
spec.module_name = 'GGDevelopmentKit'
spec.summary = "All essential code for my applications"

Expand All @@ -15,6 +15,10 @@ Pod::Spec.new do |spec|
spec.source = { :git => "https://github.com/AnTonhoLAB/GGDevelopmentKit.git", :tag => "#{spec.version}" }

spec.framework = "UIKit"

spec.dependency 'RxSwift'
spec.dependency 'RxCocoa'

spec.source_files = ["#{spec.module_name}/Coordinator/**/*.{swift}"]
# spec.source_files = 'Classes/*.{h,m}'
end
160 changes: 159 additions & 1 deletion GGDevelopmentKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions GGDevelopmentKit.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
58 changes: 58 additions & 0 deletions GGDevelopmentKit/Rx/ActivityIndicator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// ActivityIndicator.swift
// GGDevelopmentKit
//
// Created by George Vilnei Arboite Gomes on 07/01/22.
// Copyright © 2022 George Gomes. All rights reserved.
//

import Foundation
import RxSwift
import RxCocoa

public class ActivityIndicator: SharedSequenceConvertibleType {
public typealias Element = Bool
public typealias SharingStrategy = DriverSharingStrategy

private let _lock = NSRecursiveLock()
private let _behavior = BehaviorRelay<Bool>(value: false)
private let _loading: SharedSequence<SharingStrategy, Bool>

public init() {
_loading = _behavior.asDriver()
.distinctUntilChanged()
}

fileprivate func trackActivityOfObservable<O: ObservableConvertibleType>(_ source: O) -> Observable<O.Element> {
return source.asObservable()
.do(onNext: { _ in
self.sendStopLoading()
}, onError: { _ in
self.sendStopLoading()
}, onCompleted: {
self.sendStopLoading()
}, onSubscribe: subscribed)
}

private func subscribed() {
_lock.lock()
_behavior.accept(true)
_lock.unlock()
}

private func sendStopLoading() {
_lock.lock()
_behavior.accept(false)
_lock.unlock()
}

public func asSharedSequence() -> SharedSequence<SharingStrategy, Element> {
return _loading
}
}

extension ObservableConvertibleType {
public func trackActivity(_ activityIndicator: ActivityIndicator) -> Observable<Element> {
return activityIndicator.trackActivityOfObservable(self)
}
}
29 changes: 29 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
platform :ios, '10.0'

# source to download other pods
source 'https://github.com/CocoaPods/Specs.git'


target 'GGDevelopmentKit' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for GGDevelopmentKit
pod 'RxSwift', '>= 5.0.0'
pod 'RxCocoa', '>= 5.0.0'

target 'GGDevelopmentKitTests' do
# Pods for testing
pod 'RxBlocking'
pod 'RxTest'
end

end

target 'Run' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for Run

end

0 comments on commit f7b38fe

Please sign in to comment.