Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 진동 추가 #168

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: 즐겨찾기, 공유, 삭제 부드러운 진동 추가
noeyiz committed Apr 9, 2024
commit 63477c9d513b6303c2e37d9e36ac0fd234afe13c
21 changes: 21 additions & 0 deletions iBox/Sources/BoxList/BoxListView.swift
Original file line number Diff line number Diff line change
@@ -229,6 +229,11 @@ extension BoxListView: UITableViewDelegate {
let shareAction = UIContextualAction(style: .normal, title: "share", handler: {(action, view, completionHandler) in
let cellViewModel = self.viewModel?.viewModel(at: indexPath)
self.delegate?.pushViewController(url: cellViewModel?.url)
if UserDefaultsManager.isHaptics {
let generator = UIImpactFeedbackGenerator(style: .soft)
generator.prepare()
generator.impactOccurred()
}
completionHandler(true)
})
shareAction.backgroundColor = .box3
@@ -291,6 +296,11 @@ extension BoxListView: UITableViewDelegate {
private func makeContextMenu(for indexPath: IndexPath) -> UIMenu {
let deleteAction = UIAction(title: "삭제", image: UIImage(systemName: "trash"), attributes: .destructive) { [weak self] action in
self?.viewModel?.input.send(.deleteBookmark(indexPath: indexPath))
if UserDefaultsManager.isHaptics {
let generator = UIImpactFeedbackGenerator(style: .soft)
generator.prepare()
generator.impactOccurred()
}
}

let isFavorite = self.viewModel?.isFavoriteBookmark(at: indexPath) ?? false
@@ -299,11 +309,22 @@ extension BoxListView: UITableViewDelegate {

let favoriteAction = UIAction(title: favoriteActionTitle, image: favoriteActionImage) { [weak self] action in
self?.viewModel?.input.send(.toggleFavorite(indexPath: indexPath))
if UserDefaultsManager.isHaptics {
let generator = UIImpactFeedbackGenerator(style: .soft)
generator.prepare()
generator.impactOccurred()
}
}

let shareAction = UIAction(title: "공유하기", image: UIImage(systemName: "square.and.arrow.up")) { [weak self] action in
guard let self = self, let url = self.viewModel?.boxList[indexPath.section].boxListCellViewModelsWithStatus[indexPath.row].url else { return }

if UserDefaultsManager.isHaptics {
let generator = UIImpactFeedbackGenerator(style: .soft)
generator.prepare()
generator.impactOccurred()
}

let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
if let viewController = self.delegate as? UIViewController {
viewController.present(activityViewController, animated: true, completion: nil)