Skip to content

Commit

Permalink
profileVC before nested collection view
Browse files Browse the repository at this point in the history
  • Loading branch information
ducanh2211 committed May 6, 2023
1 parent 1ba3ad1 commit 3bdcf1c
Show file tree
Hide file tree
Showing 40 changed files with 2,780 additions and 1,850 deletions.
Binary file modified .DS_Store
Binary file not shown.
126 changes: 121 additions & 5 deletions InstagramClone.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,6 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D994C853-AFFB-4CF7-8134-5C0EE0A97A52"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InstagramClone/Source/Login/Controller/LogInViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "124"
endingLineNumber = "124"
landmarkName = "bindViewModel()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "88FDE869-4550-45C7-8AAB-A8E574DE00FF"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InstagramClone/Source/Login/Controller/LogInViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "125"
endingLineNumber = "125"
landmarkName = "bindViewModel()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
Expand All @@ -78,8 +46,8 @@
filePath = "InstagramClone/Source/MainTabBar/TabBarViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "27"
endingLineNumber = "27"
startingLineNumber = "28"
endingLineNumber = "28"
landmarkName = "viewDidLoad()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -94,8 +62,8 @@
filePath = "InstagramClone/Source/MainTabBar/TabBarViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "33"
endingLineNumber = "33"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "init(viewModel:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -110,27 +78,43 @@
filePath = "InstagramClone/Source/MainTabBar/TabBarViewModel.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
startingLineNumber = "43"
endingLineNumber = "43"
landmarkName = "fetchUser()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "0DFF9D68-C793-422E-AAA9-FCE53DFF1E92"
uuid = "C60B7B89-AB7F-425E-A238-DB10A8157F69"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InstagramClone/Source/MainTabBar/TabBarViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "46"
endingLineNumber = "46"
startingLineNumber = "48"
endingLineNumber = "48"
landmarkName = "bindViewModel()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "113E8BCF-0CE8-4573-92BF-BDBEBCBDB805"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InstagramClone/Source/Profile/View/UserProfileButton.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "41"
endingLineNumber = "41"
landmarkName = "initialSetup()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file added InstagramClone/.DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions InstagramClone/Assets.xcassets/Shape.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Shape.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions InstagramClone/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -11,15 +14,20 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
15 changes: 1 addition & 14 deletions InstagramClone/Helper/CommonView/StatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ class StatusView: UIView {
return button
}()

private let seperatorView: UIView = {
let view = UIView()
view.backgroundColor = .systemGray5
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

override init(frame: CGRect) {
super.init(frame: frame)
setupConstraints()
Expand All @@ -60,7 +53,6 @@ class StatusView: UIView {
private func setupConstraints() {
addSubview(backButton)
addSubview(titleLabel)
addSubview(seperatorView)

NSLayoutConstraint.activate([
backButton.leftAnchor.constraint(equalTo: leftAnchor, constant: 12),
Expand All @@ -69,12 +61,7 @@ class StatusView: UIView {
backButton.heightAnchor.constraint(equalTo: backButton.widthAnchor),

titleLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
titleLabel.centerYAnchor.constraint(equalTo: centerYAnchor),

seperatorView.leftAnchor.constraint(equalTo: leftAnchor),
seperatorView.rightAnchor.constraint(equalTo: rightAnchor),
seperatorView.bottomAnchor.constraint(equalTo: bottomAnchor),
seperatorView.heightAnchor.constraint(equalToConstant: 1)
titleLabel.centerYAnchor.constraint(equalTo: centerYAnchor)
])
}
}
10 changes: 10 additions & 0 deletions InstagramClone/Helper/Constant/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ enum Constants {
}
}

enum PhotoConstants {
enum Post {
static let portraitAspectRatio: CGFloat = 2/3
static let landscapeAspectRatio: CGFloat = 16/9
}

enum Profile {
static let aspectRatio: CGFloat = 1/1
}
}
16 changes: 16 additions & 0 deletions InstagramClone/Helper/Extension/Extentsion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ extension PHAsset {
return photo
}

func getImageAsync(targetSize: CGSize,
contentMode: PHImageContentMode = .aspectFit,
completion: @escaping (UIImage?) -> Void) -> PHImageRequestID {

let manager = PHImageManager.default()

let id = manager.requestImage(for: self,
targetSize: targetSize,
contentMode: contentMode,
options: nil) { image, _ in
completion(image)
}

return id
}

func getImageFromAsset(targetSize: CGSize,
contentMode: PHImageContentMode = .aspectFit,
options: PHImageRequestOptions,
Expand Down
12 changes: 7 additions & 5 deletions InstagramClone/Manager/AuthManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AuthManager {
private let storageManager: StorageManager

deinit {
print("Auth Manager deinit")
print("AuthManager deinit")
}

init(auth: Auth = .auth(),
Expand All @@ -59,6 +59,7 @@ class AuthManager {
return
}

// completion call on main thread
auth.createUser(withEmail: email, password: password) { [weak self] auth, error in
guard let self = self else { return }

Expand All @@ -70,18 +71,18 @@ class AuthManager {
guard let avatarImageData = self.defaultAvatar().jpegData(compressionQuality: 0.3) else { return }
let uid = auth!.user.uid

// completion call on main thread
self.storageManager.uploadUserAvatar(avatarImageData, folderName: uid) { imageUrl, error in
if let error = error {
completion(nil, .otherError(error))
return
}

let userData = User(uid: uid, email: email, fullName: fullName,
let user = User(uid: uid, email: email, fullName: fullName,
userName: userName, avatarUrl: imageUrl!)

self.userManager.uploadUser(userData, email: email,
fullName: fullName, userName: userName,
avatarUrl: imageUrl!) { user, error in
// completion call on background thread
self.userManager.uploadUser(user) { user, error in
if let error = error {
completion(nil, .otherError(error))
return
Expand All @@ -106,6 +107,7 @@ class AuthManager {

let uid = auth!.user.uid

// completion call on background thread
self.userManager.fetchUser(withUid: uid) { user, error in
if let error = error {
completion(nil, .otherError(error))
Expand Down
2 changes: 1 addition & 1 deletion InstagramClone/Manager/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class StorageManager {
}

deinit {
print("Storage Manager deinit")
print("StorageManager deinit")
}

func uploadUserAvatar(_ imageData: Data, folderName: String,
Expand Down
17 changes: 9 additions & 8 deletions InstagramClone/Manager/UserManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@ class UserManager {
}

deinit {
print("User Manager deinit")
print("UserManager deinit")
}

func uploadUser(_ user: User, email: String,
fullName: String, userName: String,
avatarUrl: String, completion: @escaping (User?, Error?) -> Void) {
/// - Note: Completion being invoked from background thread.
func uploadUser(_ user: User,
completion: @escaping (User?, Error?) -> Void) {

collectionUsersRef.document(user.uid).setData(user.description) { error in
guard error == nil else {
completion(nil, error)
return
}

DispatchQueue.main.async {

completion(user, nil)
}

}
}

/// - Note: Completion being invoked from background thread.
func fetchUser(withUid uid: String,
completion: @escaping (User?, Error?) -> Void) {

Expand All @@ -63,10 +64,10 @@ class UserManager {
}

let user = User(dictionary: dictionary)
DispatchQueue.main.async {

print("DEBUG: completion with USER")
completion(user, nil)
}

}
}
}
Loading

0 comments on commit 3bdcf1c

Please sign in to comment.