diff --git a/Instagram/Instagram.xcodeproj/project.pbxproj b/Instagram/Instagram.xcodeproj/project.pbxproj index 78718d0..a70b404 100644 --- a/Instagram/Instagram.xcodeproj/project.pbxproj +++ b/Instagram/Instagram.xcodeproj/project.pbxproj @@ -47,6 +47,12 @@ 921E579E27FAE81E00CDC913 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 921E579D27FAE81E00CDC913 /* Colors.xcassets */; }; 922DD0E8281290B9008F29DF /* UIWindow+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 922DD0E7281290B9008F29DF /* UIWindow+.swift */; }; 9244A9DF27FEDD0400D7C2EC /* SignInViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9244A9DE27FEDD0400D7C2EC /* SignInViewModel.swift */; }; + 924AC4CD2816A7DB0056F0A5 /* HomeMainStoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4CC2816A7DB0056F0A5 /* HomeMainStoryTableViewCell.swift */; }; + 924AC4CF2816A8ED0056F0A5 /* HomeMainStoryDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4CE2816A8ED0056F0A5 /* HomeMainStoryDataModel.swift */; }; + 924AC4D12816AC0F0056F0A5 /* HomeMainStoryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4D02816AC0F0056F0A5 /* HomeMainStoryCollectionViewCell.swift */; }; + 924AC4D32816B01A0056F0A5 /* HomeMainContentDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4D22816B01A0056F0A5 /* HomeMainContentDataModel.swift */; }; + 924AC4D52816B1F60056F0A5 /* HomeMainContentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4D42816B1F60056F0A5 /* HomeMainContentTableViewCell.swift */; }; + 924AC4D72816C18D0056F0A5 /* UILabel+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924AC4D62816C18D0056F0A5 /* UILabel+.swift */; }; 92920C7527FAE95F00DCABC7 /* Assets+Generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92920C7427FAE95F00DCABC7 /* Assets+Generated.swift */; }; 92920C7727FAF71C00DCABC7 /* Reactive+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92920C7627FAF71C00DCABC7 /* Reactive+.swift */; }; 92920C7927FAFE6800DCABC7 /* UserPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92920C7827FAFE6800DCABC7 /* UserPasswordViewController.swift */; }; @@ -102,6 +108,12 @@ 921E579D27FAE81E00CDC913 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; 922DD0E7281290B9008F29DF /* UIWindow+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIWindow+.swift"; sourceTree = ""; }; 9244A9DE27FEDD0400D7C2EC /* SignInViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInViewModel.swift; sourceTree = ""; }; + 924AC4CC2816A7DB0056F0A5 /* HomeMainStoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMainStoryTableViewCell.swift; sourceTree = ""; }; + 924AC4CE2816A8ED0056F0A5 /* HomeMainStoryDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMainStoryDataModel.swift; sourceTree = ""; }; + 924AC4D02816AC0F0056F0A5 /* HomeMainStoryCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMainStoryCollectionViewCell.swift; sourceTree = ""; }; + 924AC4D22816B01A0056F0A5 /* HomeMainContentDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMainContentDataModel.swift; sourceTree = ""; }; + 924AC4D42816B1F60056F0A5 /* HomeMainContentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMainContentTableViewCell.swift; sourceTree = ""; }; + 924AC4D62816C18D0056F0A5 /* UILabel+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+.swift"; sourceTree = ""; }; 92920C7427FAE95F00DCABC7 /* Assets+Generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Assets+Generated.swift"; sourceTree = ""; }; 92920C7627FAF71C00DCABC7 /* Reactive+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Reactive+.swift"; sourceTree = ""; }; 92920C7827FAFE6800DCABC7 /* UserPasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPasswordViewController.swift; sourceTree = ""; }; @@ -253,6 +265,7 @@ 921E575627FAD11800CDC913 /* UITextField+.swift */, 92920C7627FAF71C00DCABC7 /* Reactive+.swift */, 922DD0E7281290B9008F29DF /* UIWindow+.swift */, + 924AC4D62816C18D0056F0A5 /* UILabel+.swift */, ); path = Extension; sourceTree = ""; @@ -415,6 +428,9 @@ isa = PBXGroup; children = ( 921E578927FADD0300CDC913 /* HomeMainView.swift */, + 924AC4CC2816A7DB0056F0A5 /* HomeMainStoryTableViewCell.swift */, + 924AC4D02816AC0F0056F0A5 /* HomeMainStoryCollectionViewCell.swift */, + 924AC4D42816B1F60056F0A5 /* HomeMainContentTableViewCell.swift */, ); path = View; sourceTree = ""; @@ -423,6 +439,8 @@ isa = PBXGroup; children = ( 921E578727FADCFA00CDC913 /* HomeMainModel.swift */, + 924AC4CE2816A8ED0056F0A5 /* HomeMainStoryDataModel.swift */, + 924AC4D22816B01A0056F0A5 /* HomeMainContentDataModel.swift */, ); path = Model; sourceTree = ""; @@ -617,7 +635,9 @@ buildActionMask = 2147483647; files = ( 921E578C27FADD6A00CDC913 /* UserNameViewController.swift in Sources */, + 924AC4D12816AC0F0056F0A5 /* HomeMainStoryCollectionViewCell.swift in Sources */, 921E578A27FADD0300CDC913 /* HomeMainView.swift in Sources */, + 924AC4D52816B1F60056F0A5 /* HomeMainContentTableViewCell.swift in Sources */, 921E577427FADADC00CDC913 /* MoyaLoggingPlugin.swift in Sources */, 921E579627FAE33C00CDC913 /* CloseButton.swift in Sources */, 9244A9DF27FEDD0400D7C2EC /* SignInViewModel.swift in Sources */, @@ -628,6 +648,7 @@ 9201FE56282E33E800443946 /* SignInAPI.swift in Sources */, 921E576E27FADA7800CDC913 /* BaseResponse.swift in Sources */, 92920C7527FAE95F00DCABC7 /* Assets+Generated.swift in Sources */, + 924AC4CF2816A8ED0056F0A5 /* HomeMainStoryDataModel.swift in Sources */, 921E579227FAE23B00CDC913 /* IDSNavigationBar.swift in Sources */, 92BF25332829689700DE0205 /* SignInRequest.swift in Sources */, 920995AF280DD9AD008C3491 /* ShopMainViewController.swift in Sources */, @@ -642,8 +663,10 @@ 920995AB280DD965008C3491 /* SearchMainViewController.swift in Sources */, 921E578E27FADD8E00CDC913 /* AuthCompleteViewController.swift in Sources */, 92BF253528296A8800DE0205 /* SignUpRequest.swift in Sources */, + 924AC4CD2816A7DB0056F0A5 /* HomeMainStoryTableViewCell.swift in Sources */, 92920C7727FAF71C00DCABC7 /* Reactive+.swift in Sources */, 921E578827FADCFA00CDC913 /* HomeMainModel.swift in Sources */, + 924AC4D72816C18D0056F0A5 /* UILabel+.swift in Sources */, 920995A8280DD79F008C3491 /* TabBarController.swift in Sources */, 921E573D27FACB1A00CDC913 /* SceneDelegate.swift in Sources */, 921E575C27FAD1DF00CDC913 /* IDSFont.swift in Sources */, @@ -654,6 +677,7 @@ 92BF253728296A9300DE0205 /* SignUpResponse.swift in Sources */, 921E577027FADA8900CDC913 /* GeneralAPI.swift in Sources */, 921E579427FAE2BA00CDC913 /* BackButton.swift in Sources */, + 924AC4D32816B01A0056F0A5 /* HomeMainContentDataModel.swift in Sources */, 920995B4280DD9D9008C3491 /* ProfileMainViewController.swift in Sources */, 920995B1280DD9B5008C3491 /* ReelsMainViewController.swift in Sources */, 922DD0E8281290B9008F29DF /* UIWindow+.swift in Sources */, diff --git a/Instagram/Instagram/Global/Constant/Assets+Generated.swift b/Instagram/Instagram/Global/Constant/Assets+Generated.swift index 56ee9e3..8f0ae1c 100644 --- a/Instagram/Instagram/Global/Constant/Assets+Generated.swift +++ b/Instagram/Instagram/Global/Constant/Assets+Generated.swift @@ -50,6 +50,10 @@ internal enum Asset { internal static let icnUnlike = ImageAsset(name: "icn_unlike") internal static let passwordHiddenEyeIcon = ImageAsset(name: "password_hidden_eyeIcon") internal static let passwordShownEyeIcon = ImageAsset(name: "password_shown_eyeIcon") + internal static let postImage1 = ImageAsset(name: "postImage1") + internal static let postImage2 = ImageAsset(name: "postImage2") + internal static let postImage3 = ImageAsset(name: "postImage3") + internal static let postImage4 = ImageAsset(name: "postImage4") } internal enum Colors { } diff --git a/Instagram/Instagram/Global/DesignSystem/Font/IDSFont.swift b/Instagram/Instagram/Global/DesignSystem/Font/IDSFont.swift index 6cbf665..1ac88cd 100644 --- a/Instagram/Instagram/Global/DesignSystem/Font/IDSFont.swift +++ b/Instagram/Instagram/Global/DesignSystem/Font/IDSFont.swift @@ -8,10 +8,13 @@ import UIKit public enum IDSFont { + static let head1 = UIFont.systemFont(ofSize: 14, weight: .semibold) + static let head2 = UIFont.systemFont(ofSize: 12, weight: .semibold) + static let body1 = UIFont.systemFont(ofSize: 24, weight: .regular) static let body2 = UIFont.systemFont(ofSize: 14, weight: .regular) static let body3 = UIFont.systemFont(ofSize: 12, weight: .regular) - static let head1 = UIFont.systemFont(ofSize: 14, weight: .semibold) - static let head2 = UIFont.systemFont(ofSize: 12, weight: .semibold) + static let body4 = UIFont.systemFont(ofSize: 10, weight: .medium) + static let body5 = UIFont.systemFont(ofSize: 10, weight: .semibold) } diff --git a/Instagram/Instagram/Global/Extension/UILabel+.swift b/Instagram/Instagram/Global/Extension/UILabel+.swift new file mode 100644 index 0000000..219549f --- /dev/null +++ b/Instagram/Instagram/Global/Extension/UILabel+.swift @@ -0,0 +1,18 @@ +// +// UILabel+.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +extension UILabel { + func setTextSpacingBy(value: Double) { + if let textString = self.text { + let attributedString = NSMutableAttributedString(string: textString) + attributedString.addAttribute(NSAttributedString.Key.kern, value: value, range: NSRange(location: 0, length: attributedString.length - 1)) + attributedText = attributedString + } + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/avatar3.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/avatar3.imageset/Contents 2.json new file mode 100644 index 0000000..0783325 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/avatar3.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "avatar3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "avatar3@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "avatar3@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_add.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_add.imageset/Contents 2.json new file mode 100644 index 0000000..4204893 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_add.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_add.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_add@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_add@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_bookmark.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_bookmark.imageset/Contents 2.json new file mode 100644 index 0000000..4aaa057 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_bookmark.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_bookmark.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_bookmark@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_bookmark@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home.imageset/Contents 2.json new file mode 100644 index 0000000..deeccae --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_home.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_home@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_home@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home_selected.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home_selected.imageset/Contents 2.json new file mode 100644 index 0000000..a4db00a --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_home_selected.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_home_selected.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_home_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_home_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_like.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_like.imageset/Contents 2.json new file mode 100644 index 0000000..1e49081 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_like.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_like.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_like@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_like@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile.imageset/Contents 2.json new file mode 100644 index 0000000..c68bd1e --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile.imageset/Contents 2.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "icn_profile.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_profile@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_profile@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "original" + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile_selected.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile_selected.imageset/Contents 2.json new file mode 100644 index 0000000..c998565 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_profile_selected.imageset/Contents 2.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "icn_profile_selected.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_profile_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_profile_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "original" + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_reels_selected.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_reels_selected.imageset/Contents 2.json new file mode 100644 index 0000000..9ca9f2b --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_reels_selected.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_reels_selected.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_reels_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_reels_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search.imageset/Contents 2.json new file mode 100644 index 0000000..0025652 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_search.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_search@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_search@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search_selected.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search_selected.imageset/Contents 2.json new file mode 100644 index 0000000..dc7c627 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_search_selected.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_search_selected.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_search_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_search_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_share.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_share.imageset/Contents 2.json new file mode 100644 index 0000000..771b583 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_share.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_share.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_share@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_share@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop.imageset/Contents 2.json new file mode 100644 index 0000000..1e111eb --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_shop.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_shop@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_shop@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop_selected.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop_selected.imageset/Contents 2.json new file mode 100644 index 0000000..e5a9f1c --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_shop_selected.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_shop_selected.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_shop_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_shop_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_unlike.imageset/Contents 2.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_unlike.imageset/Contents 2.json new file mode 100644 index 0000000..2597838 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/icn_unlike.imageset/Contents 2.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icn_unlike.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icn_unlike@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icn_unlike@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/Contents.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/Contents.json new file mode 100644 index 0000000..5f49c65 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "postImage1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "postImage1@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "postImage1@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1.png new file mode 100644 index 0000000..b2e829f Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@2x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@2x.png new file mode 100644 index 0000000..08526b3 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@2x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@3x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@3x.png new file mode 100644 index 0000000..f38c1f5 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage1.imageset/postImage1@3x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/Contents.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/Contents.json new file mode 100644 index 0000000..ea88f2d --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "postImage2.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "postImage2@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "postImage2@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2.png new file mode 100644 index 0000000..13d4668 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@2x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@2x.png new file mode 100644 index 0000000..d5a84e3 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@2x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@3x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@3x.png new file mode 100644 index 0000000..c7d50c4 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage2.imageset/postImage2@3x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/Contents.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/Contents.json new file mode 100644 index 0000000..1c2104e --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "postImage3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "postImage3@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "postImage3@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3.png new file mode 100644 index 0000000..efdb09e Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@2x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@2x.png new file mode 100644 index 0000000..c675e44 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@2x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@3x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@3x.png new file mode 100644 index 0000000..8de2287 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage3.imageset/postImage3@3x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/Contents.json b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/Contents.json new file mode 100644 index 0000000..6aaa793 --- /dev/null +++ b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "postImage4.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "postImage4@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "postImage4@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4.png new file mode 100644 index 0000000..cf391c3 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@2x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@2x.png new file mode 100644 index 0000000..13763b0 Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@2x.png differ diff --git a/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@3x.png b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@3x.png new file mode 100644 index 0000000..31c5ced Binary files /dev/null and b/Instagram/Instagram/Resource/Asset/Assets.xcassets/postImage4.imageset/postImage4@3x.png differ diff --git a/Instagram/Instagram/Resource/Support/SceneDelegate.swift b/Instagram/Instagram/Resource/Support/SceneDelegate.swift index e6717c3..ced7212 100644 --- a/Instagram/Instagram/Resource/Support/SceneDelegate.swift +++ b/Instagram/Instagram/Resource/Support/SceneDelegate.swift @@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). guard let scene = (scene as? UIWindowScene) else { return } self.window = UIWindow(windowScene: scene) - self.window?.rootViewController = UINavigationController(rootViewController: SignInViewController()) + self.window?.rootViewController = TabBarController() self.window?.makeKeyAndVisible() } diff --git a/Instagram/Instagram/Source/Screen/Home/Controller/HomeMainViewController.swift b/Instagram/Instagram/Source/Screen/Home/Controller/HomeMainViewController.swift index dfd88d0..b189ed9 100644 --- a/Instagram/Instagram/Source/Screen/Home/Controller/HomeMainViewController.swift +++ b/Instagram/Instagram/Source/Screen/Home/Controller/HomeMainViewController.swift @@ -29,6 +29,7 @@ final class HomeMainViewController: UIViewController { super.viewDidLoad() configUI() setLayout() + bind() } // MARK: - InitUI @@ -38,11 +39,27 @@ final class HomeMainViewController: UIViewController { } private func configUI() { - view.backgroundColor = .systemGray2 + view.backgroundColor = .white } private func setLayout() { + view.addSubview(rootView) + rootView.snp.makeConstraints { + $0.top.bottom.leading.trailing.equalTo(view.safeAreaLayoutGuide) + } + } + + private func bind() { + rootView.delegate = self + } +} + +// MARK: - Custom Delegate + +extension HomeMainViewController: HomeMainViewDelegate { + func touchUpLikeButton(index: Int) { + print(index, "is Tapped") } } diff --git a/Instagram/Instagram/Source/Screen/Home/Model/HomeMainContentDataModel.swift b/Instagram/Instagram/Source/Screen/Home/Model/HomeMainContentDataModel.swift new file mode 100644 index 0000000..ec11cf7 --- /dev/null +++ b/Instagram/Instagram/Source/Screen/Home/Model/HomeMainContentDataModel.swift @@ -0,0 +1,32 @@ +// +// HomeMainContentDataModel.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +struct HomeMainContentDataModel { + let userImage: UIImage + let userName: String + + let contentImage: UIImage + + let likeCount: Int + let content: String + let commentCount: Int +} + +extension HomeMainContentDataModel { + static let sampleData: [HomeMainContentDataModel] = [ + HomeMainContentDataModel(userImage: Asset.Assets.avatar1.image, userName: "김루희", contentImage: Asset.Assets.postImage1.image, likeCount: 300, content: "소깡이💟", commentCount: 300), + HomeMainContentDataModel(userImage: Asset.Assets.avatar2.image, userName: "박인우", contentImage: Asset.Assets.postImage2.image, likeCount: 20, content: "박인우 바보 메롱메롱", commentCount: 10), + HomeMainContentDataModel(userImage: Asset.Assets.avatar3.image, userName: "한유진", contentImage: Asset.Assets.postImage3.image, likeCount: 20, content: "유진아 우리 온제 놀지?", commentCount: 10), + HomeMainContentDataModel(userImage: Asset.Assets.avatar3.image, userName: "이경민", contentImage: Asset.Assets.postImage4.image, likeCount: 110, content: "경민티비 하위", commentCount: 19), + HomeMainContentDataModel(userImage: Asset.Assets.avatar4.image, userName: "임윤휘", contentImage: Asset.Assets.postImage1.image, likeCount: 20, content: "윤휘는 벨리곰을 좋아하나봐", commentCount: 92), + HomeMainContentDataModel(userImage: Asset.Assets.avatar5.image, userName: "최영린", contentImage: Asset.Assets.postImage1.image, likeCount: 20, content: "영린이랑 언제 또 만나지?", commentCount: 8), + HomeMainContentDataModel(userImage: Asset.Assets.avatar6.image, userName: "김태현", contentImage: Asset.Assets.postImage1.image, likeCount: 18, content: "태끼 태끼 산태끼", commentCount: 18), + ] +} + diff --git a/Instagram/Instagram/Source/Screen/Home/Model/HomeMainStoryDataModel.swift b/Instagram/Instagram/Source/Screen/Home/Model/HomeMainStoryDataModel.swift new file mode 100644 index 0000000..20962b3 --- /dev/null +++ b/Instagram/Instagram/Source/Screen/Home/Model/HomeMainStoryDataModel.swift @@ -0,0 +1,25 @@ +// +// HomeMainStoryDataModel.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +struct HomeMainStoryDataModel { + let userImage: UIImage + let userName: String +} + +extension HomeMainStoryDataModel { + static let sampleData: [HomeMainStoryDataModel] = [ + HomeMainStoryDataModel(userImage: Asset.Assets.avatar1.image, userName: "김루희"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar2.image, userName: "박인우"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar3.image, userName: "한유진"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar4.image, userName: "이경민"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar5.image, userName: "임윤휘"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar6.image, userName: "최영린"), + HomeMainStoryDataModel(userImage: Asset.Assets.avatar1.image, userName: "김태현"), + ] +} diff --git a/Instagram/Instagram/Source/Screen/Home/View/HomeMainContentTableViewCell.swift b/Instagram/Instagram/Source/Screen/Home/View/HomeMainContentTableViewCell.swift new file mode 100644 index 0000000..941b598 --- /dev/null +++ b/Instagram/Instagram/Source/Screen/Home/View/HomeMainContentTableViewCell.swift @@ -0,0 +1,200 @@ +// +// HomeMainContentTableViewCell.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +import SnapKit +import Then + +protocol HomeMainContentTableViewCellDelegate: AnyObject { + func touchUpLikeButton(index: Int) +} + +final class HomeMainContentTableViewCell: UITableViewCell { + static var cellIdentifier: String { return String(describing: self) } + + // MARK: - Properties + + private var userImageView = UIImageView() + + private var userNameLabel = UILabel().then { + $0.textColor = .black + $0.font = IDSFont.body4 + } + + private var moreButton = UIButton().then { + $0.setTitle("", for: .normal) + $0.setImage(Asset.Assets.icnMore.image, for: .normal) + } + + private var contentImageView = UIImageView() + + private var buttonStackView = UIStackView().then { + $0.axis = .horizontal + $0.distribution = .fillEqually + } + + private lazy var likeButton = UIButton().then { + $0.setTitle("", for: .normal) + $0.setImage(Asset.Assets.icnUnlike.image, for: .normal) + $0.setImage(Asset.Assets.icnLike.image, for: .selected) + $0.addTarget(self, action: #selector(touchUpLikeButton), for: .touchUpInside) + } + + private var commentButton = UIButton().then { + $0.setTitle("", for: .normal) + $0.setImage(Asset.Assets.icnComment.image, for: .normal) + } + + private var shareButtn = UIButton().then { + $0.setTitle("", for: .normal) + $0.setImage(Asset.Assets.icnShare.image, for: .normal) + } + + private var bookMarkButton = UIButton().then { + $0.setTitle("", for: .normal) + $0.setImage(Asset.Assets.icnBookmark.image, for: .normal) + } + + private var likeLabel = UILabel().then { + $0.textColor = .black + $0.font = IDSFont.body5 + $0.text = "좋아요" + $0.setTextSpacingBy(value: -0.3) + } + + private var contentUserNameLabel = UILabel().then { + $0.textColor = .black + $0.font = IDSFont.body4 + } + + private var contentLabel = UILabel().then { + $0.textColor = .black + $0.font = IDSFont.body4 + $0.setTextSpacingBy(value: -0.3) + $0.numberOfLines = 1 + } + + private var commentLabel = UILabel().then { + $0.font = IDSFont.body4 + $0.textColor = .darkGray + $0.setTextSpacingBy(value: -0.3) + } + + weak var delegate: HomeMainContentTableViewCellDelegate? + var index: Int = 0 + + // MARK: - Initializer + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + configUI() + setLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Init UI + + private func configUI() { + contentView.backgroundColor = .white + } + + private func setLayout() { + contentView.addSubviews([userImageView, + userNameLabel, + moreButton, + contentImageView, + buttonStackView, + bookMarkButton, + likeLabel, + contentUserNameLabel, + contentLabel, + commentLabel]) + + buttonStackView.addArrangedSubview(likeButton) + buttonStackView.addArrangedSubview(commentButton) + buttonStackView.addArrangedSubview(shareButtn) + + userImageView.snp.makeConstraints { + $0.top.equalToSuperview().inset(10) + $0.leading.equalToSuperview().inset(6) + $0.width.height.equalTo(24) + } + + userNameLabel.snp.makeConstraints { + $0.centerY.equalTo(userImageView.snp.centerY) + $0.leading.equalTo(userImageView.snp.trailing).offset(6) + } + + moreButton.snp.makeConstraints { + $0.top.equalToSuperview().inset(10) + $0.trailing.equalToSuperview().inset(10) + $0.width.height.equalTo(24) + } + + contentImageView.snp.makeConstraints { + $0.top.equalTo(userImageView.snp.bottom).offset(12) + $0.leading.trailing.equalToSuperview() +// $0.height.equalTo(340) + } + + buttonStackView.snp.makeConstraints { + $0.top.equalTo(contentImageView.snp.bottom).offset(8) + $0.leading.equalToSuperview().inset(10) + $0.width.equalTo(92) + $0.height.equalTo(24) + } + + bookMarkButton.snp.makeConstraints { + $0.top.equalTo(contentImageView.snp.bottom).offset(8) + $0.trailing.equalToSuperview().inset(10) + $0.width.height.equalTo(24) + } + + likeLabel.snp.makeConstraints { + $0.top.equalTo(buttonStackView.snp.bottom).offset(11) + $0.leading.equalToSuperview().inset(12) + } + + contentUserNameLabel.snp.makeConstraints { + $0.top.equalTo(likeLabel.snp.bottom).offset(5) + $0.leading.equalToSuperview().inset(12) + } + + contentLabel.snp.makeConstraints { + $0.centerY.equalTo(contentUserNameLabel.snp.centerY) + $0.leading.equalTo(contentUserNameLabel.snp.trailing).offset(4) + } + + commentLabel.snp.makeConstraints { + $0.top.equalTo(contentUserNameLabel.snp.bottom).offset(4) + $0.leading.bottom.equalToSuperview().inset(12) + } + } + + // MARK: - Custom Method + + internal func setData(_ data: HomeMainContentDataModel) { + userImageView.image = data.userImage + userNameLabel.text = data.userName + contentUserNameLabel.text = data.userName + contentImageView.image = data.contentImage + contentLabel.text = data.content + likeLabel.text = "좋아요 \(data.likeCount)" + commentLabel.text = "댓글 \(data.commentCount) 모두 보기" + } + + // MARK: - @objc + + @objc func touchUpLikeButton() { + delegate?.touchUpLikeButton(index: index) + likeButton.isSelected.toggle() + } +} diff --git a/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryCollectionViewCell.swift b/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryCollectionViewCell.swift new file mode 100644 index 0000000..271a0eb --- /dev/null +++ b/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryCollectionViewCell.swift @@ -0,0 +1,63 @@ +// +// HomeMainStoryCollectionViewCell.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +import SnapKit +import Then + +final class HomeMainStoryCollectionViewCell: UICollectionViewCell { + static var CellIdentifier: String { return String(describing: self) } + + // MARK: - Properties + + private var userImageView = UIImageView() + + private var userNameLabel = UILabel().then { + $0.textColor = .black + $0.font = IDSFont.body4 + } + + // MARK: - Initializer + + override init(frame: CGRect) { + super.init(frame: frame) + setLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Init UI + + private func configUI() { + contentView.backgroundColor = .white + } + + private func setLayout() { + contentView.addSubviews([userImageView, userNameLabel]) + + userImageView.snp.makeConstraints { + $0.top.equalToSuperview().inset(6) + $0.width.height.equalTo(48) + $0.centerX.equalToSuperview() + } + + userNameLabel.snp.makeConstraints { + $0.top.equalTo(userImageView.snp.bottom).offset(3) + $0.centerX.equalToSuperview() + } + } + + // MARK: - Custom Method + + internal func setData(_ data: HomeMainStoryDataModel) { + userImageView.image = data.userImage + userNameLabel.text = data.userName + } +} diff --git a/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryTableViewCell.swift b/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryTableViewCell.swift new file mode 100644 index 0000000..5336d2b --- /dev/null +++ b/Instagram/Instagram/Source/Screen/Home/View/HomeMainStoryTableViewCell.swift @@ -0,0 +1,115 @@ +// +// HomeMainStoryTableViewCell.swift +// Instagram +// +// Created by 소연 on 2022/04/25. +// + +import UIKit + +import SnapKit +import Then + +final class HomeMainStoryTableViewCell: UITableViewCell { + static var cellIdentifier: String { return String(describing: self) } + + private var storyList = [HomeMainStoryDataModel]() + + // MARK: - Properties + + private(set) lazy var storyCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + layout.itemSize = UICollectionViewFlowLayout.automaticSize + layout.estimatedItemSize = .zero + return UICollectionView(frame: .zero, collectionViewLayout: layout).then { + $0.backgroundColor = .clear + $0.isScrollEnabled = true + $0.showsHorizontalScrollIndicator = false + } + }() + + private var lineView = UIView().then { + $0.backgroundColor = .systemGray6 + } + + // MARK: - Initializer + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + configUI() + setLayout() + setCollectionvView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Init UI + + private func configUI() { + contentView.backgroundColor = .white + } + + private func setLayout() { + contentView.addSubviews([storyCollectionView, lineView]) + + storyCollectionView.snp.makeConstraints { + $0.top.equalToSuperview().inset(12) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(72) + } + + lineView.snp.makeConstraints { + $0.top.equalTo(storyCollectionView.snp.bottom).offset(8) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(1) + } + } + + // MARK: - Custom Method + + private func setCollectionvView() { + storyCollectionView.delegate = self + storyCollectionView.dataSource = self + + storyCollectionView.register(HomeMainStoryCollectionViewCell.self, + forCellWithReuseIdentifier: HomeMainStoryCollectionViewCell.CellIdentifier) + } +} + +// MARK: - UICollectionView Protocols + +extension HomeMainStoryTableViewCell: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let width = UIScreen.main.bounds.width + let cellWidth = width * (58/375) + let cellHeight = cellWidth * (72/58) + return CGSize(width: cellWidth, height: cellHeight) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 4 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 0 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 11) + } +} + +extension HomeMainStoryTableViewCell: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return HomeMainStoryDataModel.sampleData.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeMainStoryCollectionViewCell.CellIdentifier, for: indexPath) as? HomeMainStoryCollectionViewCell else { return UICollectionViewCell() } + cell.setData(HomeMainStoryDataModel.sampleData[indexPath.item]) + return cell + } +} diff --git a/Instagram/Instagram/Source/Screen/Home/View/HomeMainView.swift b/Instagram/Instagram/Source/Screen/Home/View/HomeMainView.swift index e1d5ac6..7f56574 100644 --- a/Instagram/Instagram/Source/Screen/Home/View/HomeMainView.swift +++ b/Instagram/Instagram/Source/Screen/Home/View/HomeMainView.swift @@ -7,6 +7,13 @@ import UIKit +import SnapKit +import Then + +protocol HomeMainViewDelegate: AnyObject { + func touchUpLikeButton(index: Int) +} + final class HomeMainView: UIView { private var navigationBar = UIView().then { @@ -19,6 +26,7 @@ final class HomeMainView: UIView { private var buttonStackView = UIStackView().then { $0.axis = .horizontal + $0.distribution = .fillEqually } private var addButton = UIButton().then { @@ -28,33 +36,151 @@ final class HomeMainView: UIView { private var likeButton = UIButton().then { $0.setTitle("", for: .normal) - $0.setImage(Asset.Assets.icnLike.image, for: .normal) + $0.setImage(Asset.Assets.icnUnlike.image, for: .normal) } - private var messageButton = UIButton().then { + private var shareButton = UIButton().then { $0.setTitle("", for: .normal) $0.setImage(Asset.Assets.icnShare.image, for: .normal) } + private var contentTableView = UITableView().then { + $0.backgroundColor = .clear + $0.separatorStyle = .none + + $0.register(HomeMainContentTableViewCell.self, + forCellReuseIdentifier: HomeMainContentTableViewCell.cellIdentifier) + $0.register(HomeMainStoryTableViewCell.self, + forCellReuseIdentifier: HomeMainStoryTableViewCell.cellIdentifier) + } + + weak var delegate: HomeMainViewDelegate? + // MARK: - Initializer init() { super.init(frame: .zero) configUI() setLayout() + setTableView() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - // MARK: - Custom Method + // MARK: - Init UI private func configUI() { - + backgroundColor = .white } private func setLayout() { + addSubviews([navigationBar, contentTableView]) + navigationBar.addSubviews([logoImageView, buttonStackView]) + + buttonStackView.addArrangedSubview(addButton) + buttonStackView.addArrangedSubview(likeButton) + buttonStackView.addArrangedSubview(shareButton) + + navigationBar.snp.makeConstraints { + $0.top.equalTo(self.safeAreaLayoutGuide) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(36) + } + + logoImageView.snp.makeConstraints { + $0.top.equalToSuperview().inset(9) + $0.leading.equalToSuperview().inset(14) + $0.width.equalTo(96) + $0.height.equalTo(27) + } + + buttonStackView.snp.makeConstraints { + $0.top.equalToSuperview().inset(11) + $0.trailing.equalToSuperview().inset(14) + $0.width.equalTo(104) + $0.height.equalTo(24) + } + + contentTableView.snp.makeConstraints { + $0.leading.trailing.bottom.equalTo(self.safeAreaLayoutGuide) + $0.top.equalTo(navigationBar.snp.bottom) + } + } + + // MARK: - Custom Method + + private func setTableView() { + contentTableView.delegate = self + contentTableView.dataSource = self + } +} + +// MARK: - UITableView Protocols + +extension HomeMainView: UITableViewDelegate { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + switch indexPath.section { + case 0: + return 93 + case 1: + return UITableView.automaticDimension + default: + return 0 + } + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch indexPath.section { + case 0: + print("Story View") + case 1: + print("Content View") + default: + print("Default") + } + } +} + +extension HomeMainView: UITableViewDataSource { + func numberOfSections(in tableView: UITableView) -> Int { + return 2 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case 0: + return 1 + case 1: + return HomeMainContentDataModel.sampleData.count + default: + return 0 + } + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch indexPath.section { + case 0: + guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeMainStoryTableViewCell.cellIdentifier, for: indexPath) as? HomeMainStoryTableViewCell else { return UITableViewCell() } + return cell + case 1: + guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeMainContentTableViewCell.cellIdentifier, for: indexPath) as? HomeMainContentTableViewCell else { return UITableViewCell() } + cell.index = indexPath.row + cell.setData(HomeMainContentDataModel.sampleData[indexPath.row]) + cell.delegate = self + return cell + default: + return UITableViewCell() + } + } +} + +// MARK: - Cusom Delegate + +extension HomeMainView: HomeMainContentTableViewCellDelegate { + func touchUpLikeButton(index: Int) { + delegate?.touchUpLikeButton(index: index) } } diff --git a/README.md b/README.md index 142a6b6..4bd7bce 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ | :------: | :-------------- | :---: |:-:| | 1주차 | iOS 개발 입문 : Xcode 기본 사용법, Layout 기초, View 화면 전환 | 💟 | 💟 | | 2주차 | UI 설계 기초(1) : AutoLayout, StackView, TabBarController | 💟 | 💟 | -| 3주차 | UI 설계 기초(2) : ScrollView, TableView, CollectionView | 💟 | | +| 3주차 | UI 설계 기초(2) : ScrollView, TableView, CollectionView | 💟 | 💟 | | 4주차 | 서버 통신 기초: 서버와 클라이언트 이해, RESTful API, Alamofire를 활용한 실습 | | | | 5주차 | 클라이언트 · 디자인 합동 세미나 | | | | 6주차 | 클라이언트 · 서버 합동 세미나 / 솝커톤 | | |