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

[MP-5326] Notice Compontent 생성 #83

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
4D1FA9292AFC778E00AA510F /* SwitchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FA9282AFC778E00AA510F /* SwitchViewController.swift */; };
4D5326D52AB15FFF00A9509A /* ButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5326D42AB15FFF00A9509A /* ButtonViewController.swift */; };
4D58315E2B033EC4009F7B48 /* SliderBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D58315D2B033EC4009F7B48 /* SliderBarViewController.swift */; };
4D584A1E2D1A82BF007BB775 /* NoticeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D584A1D2D1A82BF007BB775 /* NoticeViewController.swift */; };
4D96495B2BDA227D00AC1BDE /* RxKeyboard in Frameworks */ = {isa = PBXBuildFile; productRef = 4D96495A2BDA227D00AC1BDE /* RxKeyboard */; };
4DB2D6F42AFB281100DFF053 /* BottomSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB2D6F32AFB281100DFF053 /* BottomSheetViewController.swift */; };
4DE326202CDB61CF00E67FEC /* ImageChipViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DE3261F2CDB61CF00E67FEC /* ImageChipViewController.swift */; };
Expand Down Expand Up @@ -84,6 +85,7 @@
4D1FA9282AFC778E00AA510F /* SwitchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchViewController.swift; sourceTree = "<group>"; };
4D5326D42AB15FFF00A9509A /* ButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonViewController.swift; sourceTree = "<group>"; };
4D58315D2B033EC4009F7B48 /* SliderBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderBarViewController.swift; sourceTree = "<group>"; };
4D584A1D2D1A82BF007BB775 /* NoticeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeViewController.swift; sourceTree = "<group>"; };
4DB2D6F32AFB281100DFF053 /* BottomSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomSheetViewController.swift; sourceTree = "<group>"; };
4DE3261F2CDB61CF00E67FEC /* ImageChipViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageChipViewController.swift; sourceTree = "<group>"; };
4DF5ABEA2CC25E1300BFB7D6 /* ColorItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorItemView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -204,6 +206,7 @@
4D1FA9272AFC740000AA510F /* Sub */ = {
isa = PBXGroup;
children = (
4D584A1C2D1A82A1007BB775 /* Notice */,
FC0838852D06C0B70028AE27 /* TextLink */,
4DF5ABE82CC25C2300BFB7D6 /* Color */,
4DE3261E2CDB611400E67FEC /* ImageChip */,
Expand Down Expand Up @@ -235,6 +238,14 @@
path = Sub;
sourceTree = "<group>";
};
4D584A1C2D1A82A1007BB775 /* Notice */ = {
isa = PBXGroup;
children = (
4D584A1D2D1A82BF007BB775 /* NoticeViewController.swift */,
);
path = Notice;
sourceTree = "<group>";
};
4DE3261E2CDB611400E67FEC /* ImageChip */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -375,6 +386,7 @@
3990E48D2CC61E90007C2D9E /* LabeledTextComponentViewController.swift in Sources */,
FC0838872D06C0DB0028AE27 /* TextLinkViewController.swift in Sources */,
392C38A22C467A540088D176 /* DropdownViewController.swift in Sources */,
4D584A1E2D1A82BF007BB775 /* NoticeViewController.swift in Sources */,
FC52E5FF2AA0315B00CADB39 /* RadioButtonViewController.swift in Sources */,
39F6D2442D197568008B35A9 /* PlaceholderImageViewController.swift in Sources */,
396EF4C22BDA04EE006CEF43 /* SearchInputViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ final class MainViewController: UIViewController {
$0.addTarget(self, action: #selector(accordionComponentsPressed), for: .touchUpInside)
}

let noticeComponents = DealiControl.btnOutlineLarge03()
contentStackView.addArrangedSubview(noticeComponents)
noticeComponents.do {
$0.title = "Notice Components"
$0.addTarget(self, action: #selector(noticeComponentsPressed), for: .touchUpInside)
}

let placeholderImageViewComponents = DealiControl.btnOutlineLarge03()
contentStackView.addArrangedSubview(placeholderImageViewComponents)
placeholderImageViewComponents.do {
Expand Down Expand Up @@ -316,6 +323,10 @@ extension MainViewController {
self.navigationController?.pushViewController(AccordionComponentViewController(), animated: true)
}

@objc func noticeComponentsPressed() {
self.navigationController?.pushViewController(NoticeViewController(), animated: true)
}

@objc func placeholderImageViewComponentsPressed() {
self.navigationController?.pushViewController(PlaceholderImageViewController(), animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//
// NoticeViewController.swift
// DealiDesignSystemSampleApp
//
// Created by 윤조현 on 12/24/24.
// Copyright © 2024 Dealicious Inc. All rights reserved.
//

import UIKit
import DealiDesignKit

final class NoticeViewController: UIViewController {

private let noticeView = DealiNotice()

private let noticeViewWithTitle = DealiNotice()
private let noticeViewWithLabeledTexts = DealiNotice()
private let noticeViewWithLabeledTextGroup = DealiNotice()

override func loadView() {
self.view = .init()

self.setUI()
}

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
}

}

private extension NoticeViewController {
func setUI() {
self.view.backgroundColor = .primary04

let contentScrollView = UIScrollView()
self.view.addSubview(contentScrollView)
contentScrollView.then {
$0.bounces = false
}.snp.makeConstraints {
$0.edges.equalToSuperview()
}

let contentView = UIView()
contentScrollView.addSubview(contentView)
contentView.then {
$0.backgroundColor = .clear
}.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.width.equalToSuperview()
}

let customBodyView = UIView().then {
$0.backgroundColor = .success
}

contentView.addSubview(noticeView)
noticeView.then {
$0.setTextLinkButton(DealiControl.textLinkSmall01().then {
$0.title = ("TextLink")
})

$0.addContents(customBodyView) {
$0.edges.equalToSuperview().inset(16.0)
$0.height.equalTo(200.0)
}
}.snp.makeConstraints {
$0.top.left.right.equalToSuperview().inset(16.0)
}

contentView.addSubview(noticeViewWithTitle)
noticeViewWithTitle.then {
$0.title = "Notice with Custom Body"
$0.setTextLinkButton(DealiControl.textLinkSmall01().then {
$0.title = ("TextLink")
})

$0.addContents(customBodyView) {
$0.edges.equalToSuperview().inset(16.0)
$0.height.equalTo(200.0)
}
}.snp.makeConstraints {
$0.top.equalTo(noticeView.snp.bottom).offset(16.0)
$0.left.right.equalToSuperview().inset(16.0)
}


let labeledTextViewModel: [DealiLabeledTextModel] = [
DealiLabeledTextModel(message: "내용 가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하"),
DealiLabeledTextModel(message: "내용 가나다라마바사아자차카타파하가나다라마바사아자차카타파하가나다라마바사아자차카타파하 하하하"),
]

let labeledTextViews = labeledTextViewModel.enumerated().map { (index, model) in
if index == 0 {
return DealiLabeledTextView(preset: .labeledTextBullet01, model: model)

}
return DealiLabeledTextView(preset: .labeledTextBullet02, model: model)
}

contentView.addSubview(noticeViewWithLabeledTexts)
noticeViewWithLabeledTexts.then {
$0.title = "Notice with LabeledText Array"
$0.addLabeledTexts(labeledTextViews)
}.snp.makeConstraints {
$0.left.right.equalToSuperview().inset(16.0)
$0.top.equalTo(noticeViewWithTitle.snp.bottom).offset(16.0)
}

let labeledTextGroupView = DealiLabeledText.labeledTextNumber01().then {
$0.configure(modelArray: labeledTextViewModel)
}

contentView.addSubview(noticeViewWithLabeledTextGroup)
noticeViewWithLabeledTextGroup.then {
$0.title = "Notice with LabeledText Group"
$0.addLabeledTextGroups(labeledTextGroupView)
}.snp.makeConstraints {
$0.left.right.equalToSuperview().inset(16.0)
$0.top.equalTo(noticeViewWithLabeledTexts.snp.bottom).offset(16.0)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,8 @@ final public class DealiLabeledTextView: UIView {
self.labeledCustomView = model.labeledCustomView
}

public convenience init(preset: DealiLabeledTextPreset, model: DealiLabeledTextModel) {
self.init(preset: preset)
self.configure(model: model)
}
}
153 changes: 153 additions & 0 deletions Sources/DealiDesignKit/Components/Notice/DealiNotice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
//
// DealiNotice.swift
// DealiDesignKit
//
// Created by JohyeonYoon on 12/23/24.
//

import UIKit
import SnapKit

public final class DealiNotice: UIView {

public func setTextLinkButton(_ textLink: TextLink) {
self.textLinkButton = textLink

self.addSubview(textLink)
textLink.snp.makeConstraints {
$0.left.greaterThanOrEqualTo(self.titleLabel.snp.right).offset(16.0)
$0.centerY.equalTo(self.titleLabel)
$0.right.equalToSuperview().inset(16.0)
}
}

public var title: String? {
didSet {
self.titleContentView.isHidden = title == nil

guard let title else { return }
let attributedTitle = NSMutableAttributedString(string: title)
.font(.b2sb14)
.color(.g100)
.setLineHeight()

self.titleLabel.attributedText = attributedTitle
}
}

private let titleLabel = UILabel()
private var textLinkButton: TextLink?
private let contentView = UIView()

private var titleContentView = UIView()
override internal init(frame: CGRect) {
super.init(frame: frame)

self.setUI()
}

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

public func addContents(_ view: UIView, layout: ((_ make: ConstraintMaker) -> Void)? = nil) {
self.contentView.addSubview(view)

if let layout {
view.snp.makeConstraints(layout)
} else {
view.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}
}

public func addLabeledTextGroups(_ groups: DealiLabeledTextGroupView..., spacing: CGFloat = 8.0) {
let stackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = spacing
$0.isLayoutMarginsRelativeArrangement = true
$0.layoutMargins = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
}

for group in groups {
stackView.addArrangedSubview(group)
}

self.addContents(stackView)
}

public func addLabeledTexts(_ labeledTextArray: [DealiLabeledTextView]) {
let stackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 8.0
$0.isLayoutMarginsRelativeArrangement = true
$0.layoutMargins = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
}

for labeledText in labeledTextArray {
stackView.addArrangedSubview(labeledText)
}

self.addContents(stackView)
}
}

private extension DealiNotice {
func setUI() {

self.backgroundColor = .g10
self.layer.cornerRadius = 10.0
self.layer.masksToBounds = true

let stackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 0.0
}

self.addSubview(stackView)
stackView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

self.titleContentView = self.titleView().then {
$0.isHidden = true
}

stackView.addArrangedSubview(self.titleContentView)
stackView.addArrangedSubview(self.contentView)
}

func titleView() -> UIView {
let titleContentView = UIView()

let iconImageView = UIImageView()
titleContentView.addSubview(iconImageView)
iconImageView.then {
$0.image = UIImage.dealiIcon(named: "ic_notice")
}.snp.makeConstraints {
$0.left.equalToSuperview().inset(16.0)
$0.centerY.equalToSuperview()
$0.size.equalTo(16.0)
}

titleContentView.addSubview(self.titleLabel)
self.titleLabel.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(16.0)
$0.left.equalTo(iconImageView.snp.right).offset(8.0)
$0.centerY.equalToSuperview()
}

let dividerView = UIView()
titleContentView.addSubview(dividerView)
dividerView.then {
$0.backgroundColor = .g30
}.snp.makeConstraints {
$0.height.equalTo(1.0)
$0.left.right.equalToSuperview().inset(16.0)
$0.bottom.equalToSuperview()
}

return titleContentView
}
}