Skip to content

Commit

Permalink
[Merge] Feat/v1.1.0 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
heerucan authored Feb 13, 2023
2 parents 31eaa86 + dd1fa48 commit 06d6fd7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"object": {
"pins": [
{
"package": "Lottie",
"repositoryURL": "https://github.com/airbnb/lottie-ios.git",
"state": {
"branch": null,
"revision": "440a6eebb8a8ae9c773e9a3e21021b72a74ffbb7",
"version": "4.1.2"
}
},
{
"package": "SnapKit",
"repositoryURL": "https://github.com/SnapKit/SnapKit",
Expand Down
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ let package = Package(
targets: ["WALKit"]),
],
dependencies: [
.package(name: "SnapKit", url: "https://github.com/SnapKit/SnapKit", from: "5.6.0")
.package(name: "SnapKit", url: "https://github.com/SnapKit/SnapKit", from: "5.6.0"),
.package(name: "Lottie", url: "https://github.com/airbnb/lottie-ios.git", from: "4.0.0")
],
targets: [
.target(
name: "WALKit",
dependencies: [
.product(name: "SnapKit", package: "SnapKit", condition: .when(platforms: [.iOS]))
.product(name: "SnapKit", package: "SnapKit", condition: .when(platforms: [.iOS])),
.product(name: "Lottie", package: "Lottie", condition: .when(platforms: [.iOS]))
],
path: "Sources/WALKit",
resources: [
.process("loading.json"),
.process("Font/Fonts"),
.process("Icon/Icon.xcassets"),
]
),
.testTarget(
Expand Down
24 changes: 24 additions & 0 deletions Sources/WALKit/Component/Loading/JSONFile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// JSONFile.swift
//
//
// Created by heerucan on 2023/02/14.
//

import Foundation

public class JSONFile {
static public func read(resource: String) -> Any? {
if let path = Bundle.module.path(forResource: resource, ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: [])
let jsonResult = try JSONSerialization.jsonObject(with: data, options: [])
return jsonResult
} catch {
return nil
}
} else {
return nil
}
}
}
63 changes: 63 additions & 0 deletions Sources/WALKit/Component/Loading/WALLoadingView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// WALLoadingView.swift
//
//
// Created by heerucan on 2023/02/13.
//

import UIKit

import Lottie
import SnapKit

final public class WALLoadingView: UIView {

// MARK: - Property

public var loadingAnimationView = LottieAnimationView(name: "loading")

// MARK: - Initializer

override init(frame: CGRect) {
super.init(frame: .zero)
configureUI()
setupLayout()
play()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Configure UI & Layout

private func configureUI() {
self.backgroundColor = .black100.withAlphaComponent(0)
}

private func setupLayout() {
self.addSubview(loadingAnimationView)

loadingAnimationView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(100)
}
}

// MARK: - Custom Method

public func play() {
UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseIn, animations: {
self.backgroundColor = .black100.withAlphaComponent(0.5)
self.loadingAnimationView.play()
self.loadingAnimationView.loopMode = .loop
})
}

public func hide() {
UIView.animate(withDuration: 0.3, delay: 0, options: .transitionCrossDissolve, animations: {
self.loadingAnimationView.stop()
self.loadingAnimationView.removeFromSuperview()
})
}
}
2 changes: 1 addition & 1 deletion Sources/WALKit/Component/Matrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

public struct Matrix {
public enum Matrix {
// NavigationBar
static let navigationHeight: CGFloat = 44
static let barButtonSize: CGFloat = 44
Expand Down
1 change: 1 addition & 0 deletions Sources/WALKit/loading.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Tests/WALKitTests/WALKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ final class WALKitTests: XCTestCase {
XCTAssertNotNil(image)
}
}

func testLoadJSONFileFromBundle() {
let jsonFile = JSONFile.read(resource: "loading")
XCTAssertNotNil(jsonFile)
}
}

fileprivate extension UIColor {
Expand Down

0 comments on commit 06d6fd7

Please sign in to comment.