Skip to content

Commit

Permalink
Merge pull request #11 from yoomoney-tech/feature/task/b2b/MOC-1901
Browse files Browse the repository at this point in the history
[MOC-1901] Add support swift package. Update Readme. Add AnalyticsChartSpriteKitModuleOutput.
  • Loading branch information
Oscarworld authored Apr 30, 2021
2 parents 155d316 + bf56832 commit e9abefc
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 18 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
### NEXT_VERSION_DESCRIPTION_BEGIN
### NEXT_VERSION_DESCRIPTION_END

## [1.2.0] (26-04-2021)
## [1.3.0](30-04-2021)

Add support swift package manager. Update Readme. Add AnalyticsChartSpriteKitModuleOutput.

## [1.2.0](26-04-2021)

Change blend mode of chart line to alpha. Change dash pattern for zero line.

## [1.1.0] (11-12-2020)
## [1.1.0](11-12-2020)

Added draw zero line.

## [1.0.0] (25-11-2020)
## [1.0.0](25-11-2020)

Move mobile analytics chart library to open-source
2 changes: 1 addition & 1 deletion MobileAnalyticsChartSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MobileAnalyticsChartSwift'
s.version = '1.2.0'
s.version = '1.3.0'
s.homepage = 'https://github.com/yoomoney-tech/mobile-analytics-chart-swift/browse'
s.license = {
:type => "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@ public protocol AnalyticsChartSpriteKitModuleInput: class {

func setChartIdleState()
}

/// AnalyticsChartSpriteKit module output
public protocol AnalyticsChartSpriteKitModuleOutput: class {
func didChangeRangeValue(
rangeValue: RangeValue<CGFloat>
)

func didHandleLongPress()

func didHandlePan(
deltaLocation: CGFloat
)

func didHandlePinch(
scale: CGFloat
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public enum AnalyticsChartSpriteKitAssembly {

/// Make AnalyticsChartSpriteKit module.
public static func makeModule(
inputData: AnalyticsChartSpriteKitModuleInputData
inputData: AnalyticsChartSpriteKitModuleInputData,
moduleOutput: AnalyticsChartSpriteKitModuleOutput? = nil
) -> (UIView, AnalyticsChartSpriteKitModuleInput) {
let view = AnalyticsChartSpriteKitView()

Expand All @@ -22,6 +23,7 @@ public enum AnalyticsChartSpriteKitAssembly {
view.output = presenter

presenter.view = view
presenter.moduleOutput = moduleOutput

return (view, presenter)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final public class AnalyticsChartSpriteKitPresenter {
// MARK: - VIPER

weak var view: AnalyticsChartSpriteKitViewInput?
weak var renderDrawerModuleInput: RenderDrawerModuleInput?
weak var moduleOutput: AnalyticsChartSpriteKitModuleOutput?

// MARK: - Init data

Expand Down Expand Up @@ -40,6 +40,10 @@ final public class AnalyticsChartSpriteKitPresenter {
self.analyticsDefinitionFactory = analyticsDefinitionFactory
}

// MARK: - Module input

private weak var renderDrawerModuleInput: RenderDrawerModuleInput?

// MARK: - Stored data

private var scene: RenderSpriteKitImpl?
Expand Down Expand Up @@ -98,17 +102,24 @@ extension AnalyticsChartSpriteKitPresenter: RenderDrawerModuleOutput {
rangeValue: RangeValue<CGFloat>
) {
self.rangeValue = rangeValue
moduleOutput?.didChangeRangeValue(rangeValue: rangeValue)
}

public func didHandleLongPress() {}
public func didHandleLongPress() {
moduleOutput?.didHandleLongPress()
}

public func didHandlePan(
deltaLocation: CGFloat
) {}
) {
moduleOutput?.didHandlePan(deltaLocation: deltaLocation)
}

public func didHandlePinch(
scale: CGFloat
) {}
) {
moduleOutput?.didHandlePinch(scale: scale)
}
}

// MARK: - AnalyticsChartSpriteKitModuleInput
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CoreGraphics
import MobileAnalyticsChartSwift

final class ChartPresenter {
Expand All @@ -18,7 +19,8 @@ final class ChartPresenter {
extension ChartPresenter: ChartViewOutput {
func setupView() {
let (chartView, moduleInput) = AnalyticsChartSpriteKitAssembly.makeModule(
inputData: analyticsChartViewModel.data
inputData: analyticsChartViewModel.data,
moduleOutput: self
)

analyticsChartSpriteKitModuleInput = moduleInput
Expand All @@ -27,3 +29,27 @@ extension ChartPresenter: ChartViewOutput {
view?.setChartView(chartView)
}
}

extension ChartPresenter: AnalyticsChartSpriteKitModuleOutput {
func didChangeRangeValue(
rangeValue: RangeValue<CGFloat>
) {
print(#function, rangeValue)
}

func didHandleLongPress() {
print(#function)
}

func didHandlePan(
deltaLocation: CGFloat
) {
print(#function, deltaLocation)
}

func didHandlePinch(
scale: CGFloat
) {
print(#function, scale)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CoreGraphics
import MobileAnalyticsChartSwift

final class CustomChartPresenter {
Expand All @@ -22,7 +23,8 @@ final class CustomChartPresenter {
extension CustomChartPresenter: CustomChartViewOutput {
func setupView() {
let (chartView, moduleInput) = AnalyticsChartSpriteKitAssembly.makeModule(
inputData: analyticsChartViewModel.data
inputData: analyticsChartViewModel.data,
moduleOutput: self
)

analyticsChartSpriteKitModuleInput = moduleInput
Expand Down Expand Up @@ -59,3 +61,27 @@ extension CustomChartPresenter: CustomChartViewOutput {
analyticsChartSpriteKitModuleInput?.setChartIdleState()
}
}

extension CustomChartPresenter: AnalyticsChartSpriteKitModuleOutput {
func didChangeRangeValue(
rangeValue: RangeValue<CGFloat>
) {
print(#function, rangeValue)
}

func didHandleLongPress() {
print(#function)
}

func didHandlePan(
deltaLocation: CGFloat
) {
print(#function, deltaLocation)
}

func didHandlePinch(
scale: CGFloat
) {
print(#function, scale)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,27 @@ extension MultiselectChartsPresenter: MultiselectChartsViewOutput {
)
}
}

extension MultiselectChartsPresenter: AnalyticsChartSpriteKitModuleOutput {
func didChangeRangeValue(
rangeValue: RangeValue<CGFloat>
) {
print(#function, rangeValue)
}

func didHandleLongPress() {
print(#function)
}

func didHandlePan(
deltaLocation: CGFloat
) {
print(#function, deltaLocation)
}

func didHandlePinch(
scale: CGFloat
) {
print(#function, scale)
}
}
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// swift-tools-version:5.3
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MobileAnalyticsChartSwift",
platforms: [.iOS(.v11)],
platforms: [
.iOS(.v11),
],
products: [
.library(
name: "MobileAnalyticsChartSwift",
Expand All @@ -18,6 +20,6 @@ let package = Package(
name: "MobileAnalyticsChartSwift",
dependencies: [],
path: "MobileAnalyticsChartSwift"
)
),
]
)
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- MobileAnalyticsChartSwift (1.2.0)
- MobileAnalyticsChartSwift (1.3.0)
- SwiftLint (0.27.0)

DEPENDENCIES:
Expand All @@ -15,7 +15,7 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
MobileAnalyticsChartSwift: cea298673bef519adc54031144e322cef8392ebc
MobileAnalyticsChartSwift: 2ca24f4abaf166427025adbf6bc75e15969677c5
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073

PODFILE CHECKSUM: 31d319b88d1ce01558e41645a4f93f2a9519396b
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mobile Analytics Chart

[![Platform](https://img.shields.io/badge/Support-iOS%2011.0+-brightgreen.svg)](https://img.shields.io/badge/Support-iOS%2011.0+-brightgreen.svg)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Platform](https://img.shields.io/badge/Support-iOS%2011.0+-brightgreen.svg)](https://img.shields.io/badge/Support-iOS%2011.0+-brightgreen.svg)[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/)[![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

------

Expand All @@ -11,6 +11,7 @@
* [Calculator configuration](#calculator-configuration)
- [Changelog](#changelog)
- [Connecting dependencies](#connecting-dependencies)
* [Swift Package Manager](#swift-package-manager)
* [CocoaPods](#cocoapods)
* [Carthage](#carthage)
- [Fast integration](#fast-integration)
Expand Down Expand Up @@ -38,7 +39,7 @@

#### Render configuration

- Customize range label, XAxis, YAxis, definition view
- Customize range label, XAxis, YAxis, zero line, definition view
- Toggle gesture (Swipe, pinch and handle)
- Setup redraw animation duration
- Configure insets and margins
Expand Down Expand Up @@ -188,6 +189,12 @@ let yAxis = ChartYAxis(
lineWidth: 1
)

// Creating a zero line
let zeroLine = ChartZeroLine(
color: UIColor(white: 236 / 255, alpha: 1),
width: 1
)

// Creating a gesture state configuration
let gestureState = ChartGestureState(
swipeIsActive: true,
Expand Down Expand Up @@ -223,6 +230,7 @@ let chartViewModel = AnalyticsChartSpriteKitModuleInputData(
rangeLabel: rangeLabel,
xAxis: xAxis,
yAxis: yAxis,
zeroLine: zeroLine,
gestureState: gestureState,
animation: animation,
definition: definition,
Expand Down

0 comments on commit e9abefc

Please sign in to comment.