Skip to content

Commit

Permalink
[Feat] #279 - GBStackView 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jul 14, 2024
1 parent 835bd0b commit ef53ffa
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
12 changes: 12 additions & 0 deletions GEON-PPANG-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
0915C1722A5C3D3700ACB8D4 /* PaddingLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0915C1712A5C3D3700ACB8D4 /* PaddingLabel.swift */; };
0915C1752A5C533900ACB8D4 /* HomeReviewCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0915C1742A5C533900ACB8D4 /* HomeReviewCollectionViewCell.swift */; };
0924632F2A5BA0F200B6F65D /* HomeBakeryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0924632E2A5BA0F200B6F65D /* HomeBakeryCollectionViewCell.swift */; };
0926989E2C3EB19600A9349D /* GBStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0926989D2C3EB19600A9349D /* GBStackView.swift */; };
092EFCA42A6195D900E7C262 /* CommonTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092EFCA32A6195D900E7C262 /* CommonTextView.swift */; };
0930D25B2A928B8000A75C7E /* CertificationMarkResponseType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0930D25A2A928B8000A75C7E /* CertificationMarkResponseType.swift */; };
0930D25D2A928BF200A75C7E /* NearStationResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0930D25C2A928BF200A75C7E /* NearStationResponseDTO.swift */; };
Expand Down Expand Up @@ -283,6 +284,7 @@
0915C1742A5C533900ACB8D4 /* HomeReviewCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeReviewCollectionViewCell.swift; sourceTree = "<group>"; };
091AFD412ABD79380001DD02 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
0924632E2A5BA0F200B6F65D /* HomeBakeryCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeBakeryCollectionViewCell.swift; sourceTree = "<group>"; };
0926989D2C3EB19600A9349D /* GBStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GBStackView.swift; sourceTree = "<group>"; };
092EFCA32A6195D900E7C262 /* CommonTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonTextView.swift; sourceTree = "<group>"; };
0930D25A2A928B8000A75C7E /* CertificationMarkResponseType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CertificationMarkResponseType.swift; sourceTree = "<group>"; };
0930D25C2A928BF200A75C7E /* NearStationResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearStationResponseDTO.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -584,6 +586,14 @@
path = Label;
sourceTree = "<group>";
};
0926989C2C3EB18600A9349D /* StackView */ = {
isa = PBXGroup;
children = (
0926989D2C3EB19600A9349D /* GBStackView.swift */,
);
path = StackView;
sourceTree = "<group>";
};
092F11B12A69A6CC00852CA5 /* Cell */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1158,6 +1168,7 @@
3E2A0B822BE72373004F8D6B /* View */ = {
isa = PBXGroup;
children = (
0926989C2C3EB18600A9349D /* StackView */,
0989547B2C1C07B30000D650 /* TextField */,
3E2A0B832BE74E49004F8D6B /* Chip */,
);
Expand Down Expand Up @@ -2228,6 +2239,7 @@
3EAC950D2A9FAF4500D2AADC /* WebViewController.swift in Sources */,
3ED40E002A608B4700C7D5DA /* MyPageBasicCell.swift in Sources */,
09E445392AA3BA07008E3D33 /* SortBakeryFilterView.swift in Sources */,
0926989E2C3EB19600A9349D /* GBStackView.swift in Sources */,
3E06F8D92A9E1588001302F4 /* AlertViewController.swift in Sources */,
3EF9F8A82BBD116F00F3E366 /* DummyResDTO.swift in Sources */,
097682E52A5C99340008F4FB /* BakeryFilterItems.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// GBStackView.swift
// GEON-PPANG-iOS
//
// Created by JEONGEUN KIM on 7/10/24.
//

import UIKit

enum GBStackType {
case big
case small

var images: [UIImage] {
switch self {
case .big: return [.haccpMark28px, .veganMark28px, .gmoMark28px]
case .small: return [.haccpMark22px, .veganMark22px, .gmoMark22px]
}
}

var size: Int {
switch self {
case .big: return 28
case .small: return 24
}
}
}

final class GBStackView: UIStackView {

init(type: GBStackType, data: [Bool]) {
super.init(frame: .zero)
setUI()
addCertifiedImageViews(type: type, data: data)
}

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

private func setUI() {
axis = .horizontal
spacing = -8
}

private func addCertifiedImageViews(type: GBStackType, data: [Bool]) {
data.enumerated()
.filter { $0.element }
.map { $0.offset }
.forEach { index in
let imageView = UIImageView(image: type.images[index])
imageView.contentMode = .topLeft
addArrangedSubview(imageView)
imageView.snp.makeConstraints {
$0.size.equalTo(type.size)
}
}
}
}

0 comments on commit ef53ffa

Please sign in to comment.