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

fix: 명함 공유 뷰 수정 (#349) #350

Merged
merged 27 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2885740
Merge branch 'feature/#347' of https://github.com/TeamNADA/NADA-iOS-F…
hyun99999 Jan 18, 2023
3ba5ff1
add: 명함 공유 바텀시트를 위한 이미지 에셋 추가 (#349)
hyun99999 Jan 18, 2023
ad541d8
chore: pod update (#349)
hyun99999 Jan 18, 2023
6e103d4
fix: 바텀시트 높이 변경 (#349)
hyun99999 Jan 18, 2023
a5beac6
feat: UIView Extension 추가 (#349)
hyun99999 Jan 18, 2023
33a315e
feat: addSubviews(_:) 함수 적용 (#349)
hyun99999 Jan 18, 2023
cc27170
refactor: 접근 제어자 수정 (#349)
hyun99999 Jan 18, 2023
d3cfebe
add: UI Components 추가 (#349)
hyun99999 Jan 18, 2023
7280ee9
feat: 명함 활성화 유무에 따른 UI 구현 (#349)
hyun99999 Jan 18, 2023
6ea26dc
delete: FIXME 주석 삭제 (#349)
hyun99999 Jan 18, 2023
c2c79a8
fix: 명함 공유 바텀시트의 수정으로 QR Code 의 배경 변경 (#349)
hyun99999 Jan 18, 2023
d841a23
fix: QR Code 크기 변경 (#349)
hyun99999 Jan 18, 2023
861ec6d
design: UI layout 수정 (#349)
hyun99999 Jan 18, 2023
e5785b6
feat: nearBySwitch 의 액션 메서드 구현 (#349)
hyun99999 Jan 18, 2023
64c48a4
refactor: 삼항연산자 사용한 nearBySwitch 액션메서드 리펙토링 (#349)
hyun99999 Jan 18, 2023
0ae2411
chore: import Lottie (#349)
hyun99999 Jan 18, 2023
14e5657
feat: 명함 공유 바텀시트가 가지는 변수 설정 (#349)
hyun99999 Jan 18, 2023
74073da
add: lottieImage 추가 (#349)
hyun99999 Jan 19, 2023
8c0040c
design: lottieImage 레이아웃 설정 (#349)
hyun99999 Jan 19, 2023
32632a8
feat: isActivate 변수에 따른 UI 설정 (#349)
hyun99999 Jan 19, 2023
857bb48
feat: nearBySwitch 액션 메서드에 lottieImage 설정 추가 (#349)
hyun99999 Jan 19, 2023
e67e4c7
refactor: SwiftLint (self_in_property_initialization) 워닝 제거 (#349)
hyun99999 Jan 19, 2023
4127d92
refactor: 명함의 활성화 유무를 가지고 UI 를 설정해주는 함수로 리펙토링 (#349)
hyun99999 Jan 19, 2023
99c3f33
Merge branch 'develop' of https://github.com/TeamNADA/NADA-iOS-ForRel…
hyun99999 Jan 25, 2023
6dafb5f
chore: Podfile 특정 버전 다운로드하는 옵션 삭제 (#349)
hyun99999 Jan 27, 2023
fa04290
chore: GoogleService-info.plist 파일이 빠져있어 다시 추가 (#349)
hyun99999 Jan 30, 2023
82d5ef4
Merge branch 'develop' of https://github.com/TeamNADA/NADA-iOS-ForRel…
hyun99999 Jan 31, 2023
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
8 changes: 4 additions & 4 deletions NADA-iOS-forRelease.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
F87122762733046300A24E74 /* Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87122752733046300A24E74 /* Card.swift */; };
F871227827330A3800A24E74 /* CardCreationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F871227727330A3800A24E74 /* CardCreationRequest.swift */; };
F8719DDB274F92E90081AD51 /* UITextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8719DDA274F92E90081AD51 /* UITextField+Extension.swift */; };
F8810203298826FC007266B5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F8810202298826FC007266B5 /* GoogleService-Info.plist */; };
F88101F92987CBAF007266B5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F88101F82987CBAF007266B5 /* GoogleService-Info.plist */; };
F8915A22275728F20013D609 /* SelectBirthBottomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */; };
F8915A23275728F20013D609 /* SelectMBTIBottomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8915A21275728F20013D609 /* SelectMBTIBottomViewController.swift */; };
F8A9FE1A2743DC6B00BC60CE /* CardListInGroupRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A9FE192743DC6B00BC60CE /* CardListInGroupRequest.swift */; };
Expand Down Expand Up @@ -273,7 +273,7 @@
F87122752733046300A24E74 /* Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = "<group>"; };
F871227727330A3800A24E74 /* CardCreationRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardCreationRequest.swift; sourceTree = "<group>"; };
F8719DDA274F92E90081AD51 /* UITextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extension.swift"; sourceTree = "<group>"; };
F8810202298826FC007266B5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
F88101F82987CBAF007266B5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectBirthBottomViewController.swift; sourceTree = "<group>"; };
F8915A21275728F20013D609 /* SelectMBTIBottomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectMBTIBottomViewController.swift; sourceTree = "<group>"; };
F8A9FE192743DC6B00BC60CE /* CardListInGroupRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardListInGroupRequest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -816,7 +816,7 @@
F8FC439926C01E2B0033E151 /* Resouces */ = {
isa = PBXGroup;
children = (
F8810202298826FC007266B5 /* GoogleService-Info.plist */,
F88101F82987CBAF007266B5 /* GoogleService-Info.plist */,
F857FC8A26C03A5C00A48D01 /* Assets */,
39DA4D7B2747D7060082D572 /* Font */,
F8562C94296ADC0A00DA1109 /* Lottie */,
Expand Down Expand Up @@ -1030,7 +1030,7 @@
files = (
F8518058275D042B006BD5ED /* Onboarding.storyboard in Resources */,
F8FC43BF26C025180033E151 /* .swiftlint.yml in Resources */,
F8810203298826FC007266B5 /* GoogleService-Info.plist in Resources */,
F88101F92987CBAF007266B5 /* GoogleService-Info.plist in Resources */,
397B75142763A916004AEB03 /* OpenSourceTableViewCell.xib in Resources */,
F85711A7274A6B3400F59F0B /* CardCreationPreview.storyboard in Resources */,
77607EDB274A68BE00204CD2 /* GroupCollectionViewCell.xib in Resources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "icnNearbyOff.png"
},
{
"idiom" : "universal",
"filename" : "icnNearbyOff@2x.png",
"scale" : "2x"
},
{
"filename" : "icnNearbyOff@3x.png",
"scale" : "3x",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icnNearbyOn.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icnNearbyOn@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icnNearbyOn@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "nadaLogoTxt.png",
"scale" : "1x"
},
{
"filename" : "nadaLogoTxt@2x.png",
"scale" : "2x",
"idiom" : "universal"
},
{
"filename" : "nadaLogoTxt@3x.png",
"scale" : "3x",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ extension UIView {
}

extension UIView {
func addSubviews(_ views: [UIView]) {
views.forEach { view in
self.addSubview(view)
}
}

func pinToSafeArea(top: CGFloat? = 0, left: CGFloat? = 0, bottom: CGFloat? = 0, right: CGFloat? = 0) {
guard let superview = self.superview else { return }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,64 @@ import UIKit
import Photos

import FirebaseDynamicLinks
import Lottie

class CardShareBottomSheetViewController: CommonBottomSheetViewController {

// MARK: - Properties

var isShareable = false
var cardDataModel: Card?
public var isShareable = false
public var cardDataModel: Card?
public var isActivate: Bool?

private let cardBackgroundView: UIView = {
let view = UIView()
view.backgroundColor = .card
view.layer.cornerRadius = 10.0

return view
}()

private let nearByBackgroundView: UIView = {
let view = UIView()
view.backgroundColor = .card
view.layer.cornerRadius = 10.0

return view
}()

private let nadaLogoImage: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "nadaLogoTxt")

return imageView
}()

private let nearByImage: UIImageView = {
let imageView = UIImageView()

return imageView
}()

private let nearByLabel: UILabel = {
let label = UILabel()
label.font = .button02

return label
}()

lazy
private var nearBySwitch: UISwitch = {
let nearBySwitch = UISwitch()
nearBySwitch.onTintColor = .mainColorNadaMain
nearBySwitch.addTarget(self, action: #selector(touchSwitch), for: .valueChanged)

return nearBySwitch
}()

private let qrImage: UIImageView = {
let imageView = UIImageView()
imageView.frame = CGRect(x: 0, y: 0, width: 160, height: 160)
imageView.frame = CGRect(x: 0, y: 0, width: 189, height: 189)
return imageView
}()

Expand All @@ -40,7 +87,8 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {
return label
}()

private let copyButton: UIButton = {
lazy
private var copyButton: UIButton = {
let button = UIButton()
button.setImage(UIImage(named: "iconCopy"), for: .normal)
button.addTarget(self, action: #selector(copyId), for: .touchUpInside)
Expand All @@ -56,14 +104,23 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {
return stackView
}()

private let saveAsImageButton: UIButton = {
lazy
private var saveAsImageButton: UIButton = {
let button = UIButton()
button.setImage(UIImage(named: "buttonShareImg"), for: .normal)
button.addTarget(self, action: #selector(saveAsImage), for: .touchUpInside)

return button
}()

lazy
private var lottieImage: LottieAnimationView = {
let view = LottieAnimationView(name: Const.Lottie.nearby)
view.loopMode = .loop

return view
}()

// MARK: - View Life Cycle

override func viewDidLoad() {
Expand All @@ -74,53 +131,118 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {
// MARK: - @Functions

private func setupUI() {
view.addSubviews([cardBackgroundView, nearByBackgroundView])

idStackView.addArrangedSubview(idTitleLabel)
idStackView.addArrangedSubview(idLabel)
idStackView.addArrangedSubview(copyButton)

view.addSubview(qrImage)
view.addSubview(idStackView)
view.addSubview(saveAsImageButton)
cardBackgroundView.addSubviews([nadaLogoImage, qrImage, idStackView, saveAsImageButton])

nearByBackgroundView.addSubviews([nearByImage, nearByLabel, nearBySwitch, lottieImage])

idLabel.text = cardDataModel?.cardID ?? ""

setCardActivationUI(with: isActivate ?? false)

setupLayout()
setQRImage()
}

private func setCardActivationUI(with isActivate: Bool) {
nearByBackgroundView.backgroundColor = isActivate ? .mainColorNadaMain.withAlphaComponent(0.15) : .card

nearByImage.image = isActivate ? UIImage(named: "icnNearbyOn") : UIImage(named: "icnNearbyOff")

nearByLabel.text = isActivate ? "내 근처의 명함 ON" : "내 근처의 명함 OFF"
nearByLabel.textColor = isActivate ? .mainColorNadaMain : .tertiary

nearBySwitch.setOn(isActivate, animated: false)

lottieImage.isHidden = isActivate ? false : true
_ = isActivate ? lottieImage.play() : lottieImage.stop()
}

private func setupLayout() {
cardBackgroundView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
cardBackgroundView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 20.0),
cardBackgroundView.leadingAnchor.constraint(equalTo: bottomSheetView.leadingAnchor, constant: 24.0),
cardBackgroundView.trailingAnchor.constraint(equalTo: bottomSheetView.trailingAnchor, constant: -24.0),
cardBackgroundView.heightAnchor.constraint(equalToConstant: 384.0)
])

nadaLogoImage.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nadaLogoImage.topAnchor.constraint(equalTo: cardBackgroundView.topAnchor, constant: 18.0),
nadaLogoImage.leadingAnchor.constraint(equalTo: cardBackgroundView.leadingAnchor, constant: 18.0),
nadaLogoImage.widthAnchor.constraint(equalToConstant: 84.0),
nadaLogoImage.heightAnchor.constraint(equalToConstant: 30.0)
])

Comment on lines +167 to +182
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와우 이거 스냅킷 안쓰시고 하셨군요...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

놀랍게도 이 프로젝트는 스냅킷이 인스톨되어있지 않아요 ㅋㅋㅋㅋㅋ 우리가 그때 없이 해보자고 한거 같아여
불편하면 추가해도 좋아요!

qrImage.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
qrImage.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 8),
qrImage.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor),
qrImage.widthAnchor.constraint(equalToConstant: 160),
qrImage.heightAnchor.constraint(equalToConstant: 160)
qrImage.topAnchor.constraint(equalTo: cardBackgroundView.topAnchor, constant: 64.0),
qrImage.centerXAnchor.constraint(equalTo: cardBackgroundView.centerXAnchor),
qrImage.widthAnchor.constraint(equalToConstant: 189.0),
qrImage.heightAnchor.constraint(equalToConstant: 189.0)
])

idStackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
idStackView.topAnchor.constraint(equalTo: qrImage.bottomAnchor, constant: 9),
idStackView.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor)
idStackView.topAnchor.constraint(equalTo: qrImage.bottomAnchor, constant: 15.0),
idStackView.centerXAnchor.constraint(equalTo: cardBackgroundView.centerXAnchor)
])

saveAsImageButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
saveAsImageButton.topAnchor.constraint(equalTo: idStackView.bottomAnchor, constant: 32),
saveAsImageButton.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor),
saveAsImageButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 107)
saveAsImageButton.topAnchor.constraint(equalTo: idStackView.bottomAnchor, constant: 20.0),
saveAsImageButton.centerXAnchor.constraint(equalTo: cardBackgroundView.centerXAnchor)
])

nearByBackgroundView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nearByBackgroundView.topAnchor.constraint(equalTo: cardBackgroundView.bottomAnchor, constant: 12.0),
nearByBackgroundView.leadingAnchor.constraint(equalTo: bottomSheetView.leadingAnchor, constant: 24.0),
nearByBackgroundView.trailingAnchor.constraint(equalTo: bottomSheetView.trailingAnchor, constant: -24.0),
nearByBackgroundView.heightAnchor.constraint(equalToConstant: 60.0)
])

nearByImage.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nearByImage.centerYAnchor.constraint(equalTo: nearByBackgroundView.centerYAnchor),
nearByImage.heightAnchor.constraint(equalToConstant: 54.0),
nearByImage.widthAnchor.constraint(equalToConstant: 54.0)
])

nearByLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nearByLabel.centerYAnchor.constraint(equalTo: nearByBackgroundView.centerYAnchor),
nearByLabel.leadingAnchor.constraint(equalTo: nearByImage.trailingAnchor)
])

nearBySwitch.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nearBySwitch.centerYAnchor.constraint(equalTo: nearByBackgroundView.centerYAnchor),
nearBySwitch.trailingAnchor.constraint(equalTo: nearByBackgroundView.trailingAnchor, constant: -20.0),
nearBySwitch.heightAnchor.constraint(equalToConstant: 31.0),
nearBySwitch.widthAnchor.constraint(equalToConstant: 51.0)
])

lottieImage.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
lottieImage.centerXAnchor.constraint(equalTo: nearByImage.centerXAnchor),
lottieImage.centerYAnchor.constraint(equalTo: nearByImage.centerYAnchor)
])
}

private func setQRImage() {
let frame = CGRect(origin: .zero, size: qrImage.frame.size)
let qrcode = QRCodeView(frame: frame)
generateDynamicLink(with: cardDataModel?.cardID ?? "") { dynamicLink in

// FIXME: - ThisIsTeamNADAQrCode 로 나다에서 prefix 파악하는데 수정하기

qrcode.generateCode(dynamicLink,
foregroundColor: .primary,
backgroundColor: .background)
backgroundColor: .card)
self.qrImage.addSubview(qrcode)
}
}
Expand Down Expand Up @@ -180,7 +302,6 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {
default:
break
}

}

// FIXME: - 명함 저장시에도 테두리 둥글게 가능한가 찾기
Expand Down Expand Up @@ -221,12 +342,14 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {

// MARK: - @objc Methods

@objc func copyId() {
@objc
private func copyId() {
UIPasteboard.general.string = cardDataModel?.cardID ?? ""
showToast(message: "명함 아이디가 복사되었습니다.", font: UIFont.button02, view: "copyID")
}

@objc func saveAsImage() {
@objc
private func saveAsImage() {
setImageWriteToSavedPhotosAlbum()
}

Expand All @@ -238,4 +361,8 @@ class CardShareBottomSheetViewController: CommonBottomSheetViewController {
showToast(message: "갤러리에 저장되었습니다.", font: UIFont.button02, view: "saveImage")
}
}

@objc func touchSwitch(_ sender: UISwitch) {
setCardActivationUI(with: sender.isOn)
}
}
Loading