Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…yover into iOS/feat#209
  • Loading branch information
loinsir committed Dec 6, 2023
2 parents cb093ca + db941ea commit 0074515
Show file tree
Hide file tree
Showing 54 changed files with 1,594 additions and 83 deletions.
81 changes: 81 additions & 0 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions iOS/Layover/Layover/DesignSystem/LOPopUpView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// LOPopUpView.swift
// Layover
//
// Created by 황지웅 on 12/4/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import UIKit

final class LOPopUpView: UIView {
private let titleLabel: UILabel = {
let label: UILabel = UILabel()
label.text = "콘텐츠 신고"
label.font = .loFont(type: .subtitle)
return label
}()

private let reportStackView: LOReportStackView = LOReportStackView()

private let cancelButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle("취소", for: .normal)
button.setTitleColor(.grey200, for: .normal)
return button
}()

private let reportButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle("신고", for: .normal)
button.setTitleColor(.error, for: .normal)
return button
}()

weak var delegate: ReportViewControllerDelegate?

override init(frame: CGRect) {
super.init(frame: frame)
setConstraints()
cancelButton.addTarget(self, action: #selector(cancelButtonDidTap), for: .touchUpInside)
reportButton.addTarget(self, action: #selector(reportButtonDidTap), for: .touchUpInside)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setConstraints()
cancelButton.addTarget(self, action: #selector(cancelButtonDidTap), for: .touchUpInside)
reportButton.addTarget(self, action: #selector(reportButtonDidTap), for: .touchUpInside)
}

func getReportContent() -> String {
reportStackView.reportContent
}

private func setConstraints() {
addSubviews(titleLabel, reportStackView, cancelButton, reportButton)
subviews.forEach { subView in
subView.translatesAutoresizingMaskIntoConstraints = false
}

NSLayoutConstraint.activate([
titleLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: 28),
titleLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 28),
titleLabel.bottomAnchor.constraint(equalTo: reportStackView.topAnchor, constant: -5),
reportStackView.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.8),
reportStackView.heightAnchor.constraint(equalToConstant: 336),
reportStackView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 5),
reportStackView.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 13.5),
cancelButton.leadingAnchor.constraint(equalTo: self.leadingAnchor),
cancelButton.trailingAnchor.constraint(equalTo: reportButton.leadingAnchor),
cancelButton.widthAnchor.constraint(equalToConstant: 175),
cancelButton.heightAnchor.constraint(equalToConstant: 56),
cancelButton.topAnchor.constraint(equalTo: reportStackView.bottomAnchor),
reportButton.leadingAnchor.constraint(equalTo: cancelButton.trailingAnchor),
reportButton.trailingAnchor.constraint(equalTo: self.trailingAnchor),
reportButton.widthAnchor.constraint(equalToConstant: 175),
reportButton.heightAnchor.constraint(equalToConstant: 56),
reportButton.topAnchor.constraint(equalTo: reportStackView.bottomAnchor)
])

}

@objc private func cancelButtonDidTap() {
delegate?.dismissReportView()
}

@objc private func reportButtonDidTap() {
delegate?.reportPlaybackVideo(reportContent: getReportContent())
}
}
93 changes: 93 additions & 0 deletions iOS/Layover/Layover/DesignSystem/LOReportContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// LOReportContentView.swift
// Layover
//
// Created by 황지웅 on 12/4/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import UIKit

final class LOReportContentView: UIView {

// MARK: - UI Components

var index: Int = 0

private let whiteCircle: UIView = {
let view: UIView = UIView()
view.backgroundColor = .layoverWhite
view.clipsToBounds = true
view.layer.cornerRadius = 4
view.isHidden = true
view.isUserInteractionEnabled = false
return view
}()

private let radioView: UIView = {
let view: UIView = UIView()
view.layer.borderColor = UIColor.grey100.cgColor
view.layer.borderWidth = 0.1
view.backgroundColor = .clear
view.layer.cornerRadius = 10
view.clipsToBounds = true
view.isUserInteractionEnabled = false
return view
}()

let contentLabel: UILabel = {
let label: UILabel = UILabel()
label.text = "스팸 / 홍보 도배글이에요"
label.font = .loFont(type: .body2)
label.textAlignment = .left
label.textColor = .layoverWhite
return label
}()

override init(frame: CGRect) {
super.init(frame: frame)
setConstraints()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setConstraints()
}

func onRadio() {
whiteCircle.isHidden = false
radioView.backgroundColor = .primaryPurple
}

func offRadio() {
whiteCircle.isHidden = true
radioView.backgroundColor = .clear
}

func setText(_ content: String) {
contentLabel.text = content
}

// MARK: - UI Methods

private func setConstraints() {
radioView.addSubview(whiteCircle)
whiteCircle.translatesAutoresizingMaskIntoConstraints = false
addSubviews(radioView, contentLabel)
subviews.forEach { subView in
subView.translatesAutoresizingMaskIntoConstraints = false
}
NSLayoutConstraint.activate([
whiteCircle.centerXAnchor.constraint(equalTo: radioView.centerXAnchor),
whiteCircle.centerYAnchor.constraint(equalTo: radioView.centerYAnchor),
whiteCircle.widthAnchor.constraint(equalToConstant: 8),
whiteCircle.heightAnchor.constraint(equalToConstant: 8),
radioView.widthAnchor.constraint(equalToConstant: 20),
radioView.heightAnchor.constraint(equalToConstant: 20),
radioView.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10),
radioView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
radioView.trailingAnchor.constraint(equalTo: contentLabel.leadingAnchor, constant: -12),
contentLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor)
])
}
}
66 changes: 66 additions & 0 deletions iOS/Layover/Layover/DesignSystem/LOReportStackView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// LOReportStackView.swift
// Layover
//
// Created by 황지웅 on 12/4/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import UIKit

final class LOReportStackView: UIStackView {

var reportViews: [LOReportContentView] = {
let contentArray: [String] = ["스팸 홍보 / 도배글이에요", "부적절한 사진이에요", "청소년에게 유해한 내용이에요", "욕설 / 혐오 / 차별적 표현을 담고있어요", "거짓 정보를 담고있어요", "기타"]
return contentArray.enumerated().map { index, content in
let loReportContentView: LOReportContentView = LOReportContentView()
loReportContentView.setText(content)
loReportContentView.index = index
return loReportContentView
}
}()

var reportContent: String = "스팸 홍보 / 도배글이에요"

override init(frame: CGRect) {
super.init(frame: frame)
setUI()
addContent()
}

required init(coder: NSCoder) {
super.init(coder: coder)
setUI()
addContent()
}

private func setUI() {
self.alignment = .fill
self.distribution = .fillProportionally
self.axis = .vertical
self.spacing = 8
guard let firstReportView: LOReportContentView = reportViews.first else { return }
firstReportView.onRadio()
}

private func addContent() {
reportViews.forEach { reportView in
let addGesutre: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(reportViewDidTap(_:)))
reportView.addGestureRecognizer(addGesutre)
addArrangedSubview(reportView)
}
}

@objc private func reportViewDidTap(_ sender: UITapGestureRecognizer) {
guard let tempView: LOReportContentView = sender.view as? LOReportContentView else { return }
self.reportViews.forEach { reportView in
if reportView.index == tempView.index {
reportView.onRadio()
guard let reportContentText: String = reportView.contentLabel.text else { return }
reportContent = reportContentText
} else {
reportView.offRadio()
}
}
}
}
6 changes: 6 additions & 0 deletions iOS/Layover/Layover/DesignSystem/LOTagStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ final class LOTagStackView: UIStackView {

// MARK: - Properties

var tags: [String] {
arrangedSubviews
.map { $0 as? UIButton }
.compactMap(\.?.titleLabel?.text)
}

private let style: Style

// MARK: - Initializer
Expand Down
3 changes: 3 additions & 0 deletions iOS/Layover/Layover/Extensions/Notification.Name+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ import Foundation

extension Notification.Name {
static let refreshTokenDidExpired = Notification.Name("refreshTokenDidExpired")
static let uploadTaskStart = Notification.Name("uploadTaskStart")
static let progressChanged = Notification.Name("progressChanged")
static let uploadTaskDidComplete = Notification.Name("uploadTaskDidComplete")
}
17 changes: 17 additions & 0 deletions iOS/Layover/Layover/Models/UploadPost.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// UploadPost.swift
// Layover
//
// Created by kong on 2023/12/05.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct UploadPost {
let title: String
let content: String?
let latitude, longitude: Double
let tag: [String]
let videoURL: URL
}
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Network/DTOs/CheckSignUpDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
import Foundation

struct CheckSignUpDTO: Decodable {
let isValid: Bool
let isAlreadyExist: Bool
}
15 changes: 15 additions & 0 deletions iOS/Layover/Layover/Network/DTOs/ReportDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ReportDTO.swift
// Layover
//
// Created by 황지웅 on 12/5/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct ReportDTO: Codable {
let memberId: Int?
let boardID: Int
let reportType: String
}
24 changes: 24 additions & 0 deletions iOS/Layover/Layover/Network/DTOs/UploadPostDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UploadPostDTO.swift
// Layover
//
// Created by kong on 2023/12/05.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct UploadPostDTO: Decodable {
let id: Int
let title: String
let content: String?
let latitude, longitude: Double
let tag: [String]
}

struct UploadPostRequestDTO: Encodable {
let title: String
let content: String?
let latitude, longitude: Double
let tag: [String]
}
27 changes: 27 additions & 0 deletions iOS/Layover/Layover/Network/DTOs/UploadVideoDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// UploadVideoDTO.swift
// Layover
//
// Created by kong on 2023/12/05.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct UploadVideoDTO: Decodable {
let preSignedURL: String

enum CodingKeys: String, CodingKey {
case preSignedURL = "preSignedUrl"
}
}

struct UploadVideoRequestDTO: Encodable {
let boardID: Int
let filetype: String

enum CodingKeys: String, CodingKey {
case boardID = "boardId"
case filetype
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// ReportEndPointFactory.swift
// Layover
//
// Created by 황지웅 on 12/5/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

protocol ReportEndPointFactory {
func reportPlaybackVideoEndpoint(boardID: Int, reportType: String) -> EndPoint<Response<ReportDTO>>
}

struct DefaultReportEndPointFactory: ReportEndPointFactory {
func reportPlaybackVideoEndpoint(boardID: Int, reportType: String) -> EndPoint<Response<ReportDTO>> {
var bodyParmeters: ReportDTO = ReportDTO(
memberId: nil,
boardID: boardID,
reportType: reportType)

return EndPoint(
path: "/report",
method: .POST,
bodyParameters: bodyParmeters)
}
}
Loading

0 comments on commit 0074515

Please sign in to comment.