forked from Health-Food-Me/Health-Food-Me-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chore] Health-Food-Me#150 - 로딩뷰 구현에 필요한 뷰 파일 생성 및 json 파일명 변경 적용
- Loading branch information
Showing
5 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions
20
HealthFoodMe/HealthFoodMe/Presentation/Common/HelfmeLoading/VC/HelfmeLoadingVC.swift
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
HealthFoodMe/HealthFoodMe/Presentation/Common/HelfmeLoading/View/HelfmeLoadingView.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// HelfmeLoadingVC.swift | ||
// HealthFoodMe | ||
// | ||
// Created by 강윤서 on 2022/07/20. | ||
// | ||
|
||
import UIKit | ||
|
||
import Lottie | ||
import SnapKit | ||
|
||
class HelfmeLoadingVC: UIView { | ||
private var contentView: UIView = { | ||
let view = UIView() | ||
view.backgroundColor = .black.withAlphaComponent(0.4) | ||
view.alpha = 0 | ||
return view | ||
}() | ||
|
||
private var loadingView: AnimationView = { | ||
let animationView = AnimationView(name: "loading_iOS") | ||
animationView.loopMode = .loop | ||
|
||
return animationView | ||
}() | ||
} | ||
|
||
extension HelfmeLoadingVC { | ||
private func setLayout() { | ||
self.addSubview(contentView) | ||
contentView.addSubview(loadingView) | ||
|
||
contentView.snp.makeConstraints { make in | ||
make.edges.equalToSuperview() | ||
} | ||
|
||
loadingView.snp.makeConstraints { make in | ||
make.center.equalTo(safeAreaLayoutGuide) | ||
make.size.equalTo(300) | ||
} | ||
} | ||
|
||
func show() { | ||
guard !AppDelegate.window.subviews.contains(where: {$0 is HelfmeLoadingVC}) | ||
self.layoutIfNeeded() | ||
self.loadingView.play() | ||
} | ||
|
||
func hide(completion: @escaping () -> ()) { | ||
self.loadingView.stop() | ||
self.removeFromSuperview() | ||
completion() | ||
} | ||
} |
This file contains 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