Skip to content

Commit

Permalink
#1 feat::hamster: Setup/Configure FoodInfoStackView
Browse files Browse the repository at this point in the history
  • Loading branch information
torch-ray committed Apr 20, 2021
1 parent 22fa9b3 commit c1e4b5d
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 4 deletions.
36 changes: 32 additions & 4 deletions iOS/sideDish/sideDish.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
719B37BF262E781D00107FE6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 719B37BD262E781D00107FE6 /* LaunchScreen.storyboard */; };
719B37CA262E781D00107FE6 /* sideDishTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 719B37C9262E781D00107FE6 /* sideDishTests.swift */; };
719B37D5262E781D00107FE6 /* sideDishUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 719B37D4262E781D00107FE6 /* sideDishUITests.swift */; };
719B37EF262E7A9F00107FE6 /* FoodInfoStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 719B37EE262E7A9F00107FE6 /* FoodInfoStackView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -49,6 +50,7 @@
719B37D0262E781D00107FE6 /* sideDishUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = sideDishUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
719B37D4262E781D00107FE6 /* sideDishUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sideDishUITests.swift; sourceTree = "<group>"; };
719B37D6262E781D00107FE6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
719B37EE262E7A9F00107FE6 /* FoodInfoStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodInfoStackView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -99,10 +101,9 @@
719B37B1262E781C00107FE6 /* sideDish */ = {
isa = PBXGroup;
children = (
719B37B2262E781C00107FE6 /* AppDelegate.swift */,
719B37B4262E781C00107FE6 /* SceneDelegate.swift */,
719B37B6262E781C00107FE6 /* MainViewController.swift */,
719B37B8262E781C00107FE6 /* Main.storyboard */,
719B37ED262E7A8A00107FE6 /* View */,
719B37EC262E7A7700107FE6 /* Supports */,
719B37EB262E7A6500107FE6 /* Controller */,
719B37BB262E781D00107FE6 /* Assets.xcassets */,
719B37BD262E781D00107FE6 /* LaunchScreen.storyboard */,
719B37C0262E781D00107FE6 /* Info.plist */,
Expand All @@ -128,6 +129,32 @@
path = sideDishUITests;
sourceTree = "<group>";
};
719B37EB262E7A6500107FE6 /* Controller */ = {
isa = PBXGroup;
children = (
719B37B6262E781C00107FE6 /* MainViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
};
719B37EC262E7A7700107FE6 /* Supports */ = {
isa = PBXGroup;
children = (
719B37B2262E781C00107FE6 /* AppDelegate.swift */,
719B37B4262E781C00107FE6 /* SceneDelegate.swift */,
719B37B8262E781C00107FE6 /* Main.storyboard */,
);
path = Supports;
sourceTree = "<group>";
};
719B37ED262E7A8A00107FE6 /* View */ = {
isa = PBXGroup;
children = (
719B37EE262E7A9F00107FE6 /* FoodInfoStackView.swift */,
);
path = View;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -261,6 +288,7 @@
719B37B7262E781C00107FE6 /* MainViewController.swift in Sources */,
719B37B3262E781C00107FE6 /* AppDelegate.swift in Sources */,
719B37B5262E781C00107FE6 /* SceneDelegate.swift in Sources */,
719B37EF262E7A9F00107FE6 /* FoodInfoStackView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
File renamed without changes.
File renamed without changes.
72 changes: 72 additions & 0 deletions iOS/sideDish/sideDish/View/FoodInfoStackView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import UIKit

class FoodInfoStackView: UIStackView {

var foodNameLabel: UILabel!
var foodDescriptionLabel: UILabel!
var sellPriceLabel: UILabel!
var originalPriceLabel: UILabel?
var eventInfoLabel: UILabel?

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

required init(coder: NSCoder) {
super.init(coder: coder)
setupMainView()
}


}

//MARK: -Setup && Cofiguration
extension FoodInfoStackView {

private func setupMainView() {
configureMainView()
configureFoodNameLabel()
configureFoodDescriptionLabel()
configureSellPriceLabel()
}

private func configureMainView() {
axis = .vertical
translatesAutoresizingMaskIntoConstraints = false
heightAnchor.constraint(equalToConstant: 130).isActive = true
widthAnchor.constraint(equalToConstant: 213).isActive = true
}

private func configureFoodNameLabel() {
foodNameLabel = UILabel(frame: .zero)
foodNameLabel.font = UIFont.boldSystemFont(ofSize: 16)
foodNameLabel.numberOfLines = 0
addArrangedSubview(foodNameLabel)
foodNameLabel.translatesAutoresizingMaskIntoConstraints = false
foodNameLabel.widthAnchor.constraint(equalToConstant: 205).isActive = true
foodNameLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15).isActive = true
foodNameLabel.topAnchor.constraint(equalTo: topAnchor, constant: 10).isActive = true
}

private func configureFoodDescriptionLabel() {
foodDescriptionLabel = UILabel(frame: .zero)
foodDescriptionLabel.textColor = UIColor.systemGray3
foodDescriptionLabel.font = foodDescriptionLabel.font.withSize(14)
addArrangedSubview(foodDescriptionLabel)
foodDescriptionLabel.translatesAutoresizingMaskIntoConstraints = false
foodDescriptionLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
foodDescriptionLabel.widthAnchor.constraint(equalToConstant: 205).isActive = true
foodDescriptionLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15).isActive = true
}

private func configureSellPriceLabel() {
sellPriceLabel = UILabel(frame: .zero)
sellPriceLabel.font = UIFont.boldSystemFont(ofSize: 14)
addArrangedSubview(sellPriceLabel)
sellPriceLabel.translatesAutoresizingMaskIntoConstraints = false
sellPriceLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
sellPriceLabel.widthAnchor.constraint(equalToConstant: 51).isActive = true
sellPriceLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15).isActive = true
}
}

0 comments on commit c1e4b5d

Please sign in to comment.