Skip to content

Commit

Permalink
reorginzation of directories etc. finishing up profile view/settings …
Browse files Browse the repository at this point in the history
…tonight
  • Loading branch information
skucheria committed May 30, 2019
1 parent ac7205e commit 4d28564
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 19 deletions.
84 changes: 84 additions & 0 deletions Helpers/LoadingIndicator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// File.swift
// LearnLab
//
// Created by Siddharth Kucheria on 5/27/19.
// Copyright © 2019 Siddharth Kucheria. All rights reserved.
//

import UIKit

class ProgressHUD: UIVisualEffectView {

var text: String? {
didSet {
label.text = text
}
}

let activityIndictor: UIActivityIndicatorView = UIActivityIndicatorView(style: .gray)
let label: UILabel = UILabel()
let blurEffect = UIBlurEffect(style: .light)
let vibrancyView: UIVisualEffectView

init(text: String) {
self.text = text
self.vibrancyView = UIVisualEffectView(effect: UIVibrancyEffect(blurEffect: blurEffect))
super.init(effect: blurEffect)
self.setup()
}

required init?(coder aDecoder: NSCoder) {
self.text = ""
self.vibrancyView = UIVisualEffectView(effect: UIVibrancyEffect(blurEffect: blurEffect))
super.init(coder: aDecoder)
self.setup()
}

func setup() {
contentView.addSubview(vibrancyView)
contentView.addSubview(activityIndictor)
contentView.addSubview(label)
activityIndictor.startAnimating()
}

override func didMoveToSuperview() {
super.didMoveToSuperview()

if let superview = self.superview {

let width = superview.frame.size.width / 2.3
let height: CGFloat = 50.0
self.frame = CGRect(x: superview.frame.size.width / 2 - width / 2,
y: superview.frame.height / 2 - height / 2,
width: width,
height: height)
vibrancyView.frame = self.bounds

let activityIndicatorSize: CGFloat = 40
activityIndictor.frame = CGRect(x: 5,
y: height / 2 - activityIndicatorSize / 2,
width: activityIndicatorSize,
height: activityIndicatorSize)

layer.cornerRadius = 8.0
layer.masksToBounds = true
label.text = text
label.textAlignment = NSTextAlignment.center
label.frame = CGRect(x: activityIndicatorSize + 5,
y: 0,
width: width - activityIndicatorSize - 15,
height: height)
label.textColor = UIColor.gray
label.font = UIFont.boldSystemFont(ofSize: 16)
}
}

func show() {
self.isHidden = false
}

func hide() {
self.isHidden = true
}
}
4 changes: 2 additions & 2 deletions LearnLab/LoginHandlers.swift → Helpers/LoginHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension LoginVC : UIImagePickerControllerDelegate, UINavigationControllerDeleg
print("successfully created user")
}
else{
print(error)
print(error!)
}
//save user here
let values = ["name": name, "email": email ]
Expand All @@ -66,7 +66,7 @@ extension LoginVC : UIImagePickerControllerDelegate, UINavigationControllerDeleg
if let uploadData = self.profileImageView.image?.jpegData(compressionQuality: 0.1){
imageRef.putData(uploadData, metadata: nil) { (metadata, error) in
if error != nil{
print(error)
print(error!)
return
}
imageRef.downloadURL(completion: { (url, error) in
Expand Down
46 changes: 33 additions & 13 deletions LearnLab.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
35900FB02289405500D796D3 /* Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35900FAF2289405500D796D3 /* Profile.swift */; };
35900FB22289409000D796D3 /* MessagesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35900FB12289409000D796D3 /* MessagesVC.swift */; };
35900FB4228940AC00D796D3 /* SearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35900FB3228940AC00D796D3 /* SearchVC.swift */; };
35B33D20229CA5AC00B207F4 /* LoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35B33D1F229CA5AC00B207F4 /* LoadingIndicator.swift */; };
35BA1DC82299B79C00F0ADE3 /* ProfileVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35BA1DC72299B79C00F0ADE3 /* ProfileVC.swift */; };
35C1C79F228BB7EE0060AAA3 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C1C79E228BB7EE0060AAA3 /* Message.swift */; };
35C1C7A1228E24390060AAA3 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C1C7A0228E24390060AAA3 /* User.swift */; };
Expand Down Expand Up @@ -79,6 +80,7 @@
35900FAF2289405500D796D3 /* Profile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Profile.swift; sourceTree = "<group>"; };
35900FB12289409000D796D3 /* MessagesVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesVC.swift; sourceTree = "<group>"; };
35900FB3228940AC00D796D3 /* SearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchVC.swift; sourceTree = "<group>"; };
35B33D1F229CA5AC00B207F4 /* LoadingIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingIndicator.swift; sourceTree = "<group>"; };
35BA1DC72299B79C00F0ADE3 /* ProfileVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileVC.swift; sourceTree = "<group>"; };
35C1C79E228BB7EE0060AAA3 /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
35C1C7A0228E24390060AAA3 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -160,6 +162,8 @@
isa = PBXGroup;
children = (
353AD7F5229515B70063596E /* Extensions.swift */,
357D4137228E6CB700EEEFE6 /* LoginHandlers.swift */,
35B33D1F229CA5AC00B207F4 /* LoadingIndicator.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand All @@ -173,6 +177,32 @@
path = Images;
sourceTree = "<group>";
};
35B33D21229CA97E00B207F4 /* Tabs */ = {
isa = PBXGroup;
children = (
3560D85022888AF1003C12E0 /* MainTabController.swift */,
3560D8522288907F003C12E0 /* tab1.swift */,
3560D85422889089003C12E0 /* tab2.swift */,
35900FAB2289401B00D796D3 /* tab3.swift */,
35900FAD2289402200D796D3 /* tab4.swift */,
);
path = Tabs;
sourceTree = "<group>";
};
35B33D22229CA9B300B207F4 /* ViewControllers */ = {
isa = PBXGroup;
children = (
35900FA922893FF500D796D3 /* Tutors.swift */,
3560D8562288943D003C12E0 /* LoginVC.swift */,
3560D85A22890C24003C12E0 /* InfoVC.swift */,
35900FB12289409000D796D3 /* MessagesVC.swift */,
353AD7F722952D420063596E /* ChatLogVC.swift */,
35900FB3228940AC00D796D3 /* SearchVC.swift */,
35BA1DC72299B79C00F0ADE3 /* ProfileVC.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
35C1C799228B7B2F0060AAA3 /* Models - Chat */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -213,22 +243,11 @@
35D2998A228553AD005DF851 /* GoogleService-Info.plist */,
35D2995922855346005DF851 /* AppDelegate.swift */,
3560D84922868EC3003C12E0 /* ViewController.swift */,
3560D8562288943D003C12E0 /* LoginVC.swift */,
357D4137228E6CB700EEEFE6 /* LoginHandlers.swift */,
3560D85A22890C24003C12E0 /* InfoVC.swift */,
3560D85022888AF1003C12E0 /* MainTabController.swift */,
3560D8522288907F003C12E0 /* tab1.swift */,
35900FA922893FF500D796D3 /* Tutors.swift */,
3560D85422889089003C12E0 /* tab2.swift */,
35900FB12289409000D796D3 /* MessagesVC.swift */,
353AD7F722952D420063596E /* ChatLogVC.swift */,
35B33D22229CA9B300B207F4 /* ViewControllers */,
35B33D21229CA97E00B207F4 /* Tabs */,
35C1C799228B7B2F0060AAA3 /* Models - Chat */,
35900FAB2289401B00D796D3 /* tab3.swift */,
35900FB3228940AC00D796D3 /* SearchVC.swift */,
35900FAD2289402200D796D3 /* tab4.swift */,
35900FAF2289405500D796D3 /* Profile.swift */,
3560D8582289030C003C12E0 /* SettingsVC.swift */,
35BA1DC72299B79C00F0ADE3 /* ProfileVC.swift */,
35D2996322855348005DF851 /* Assets.xcassets */,
35D2996522855348005DF851 /* LaunchScreen.storyboard */,
35D2996822855348005DF851 /* Info.plist */,
Expand Down Expand Up @@ -544,6 +563,7 @@
3560D84A22868EC3003C12E0 /* ViewController.swift in Sources */,
35900FB02289405500D796D3 /* Profile.swift in Sources */,
3560D8572288943D003C12E0 /* LoginVC.swift in Sources */,
35B33D20229CA5AC00B207F4 /* LoadingIndicator.swift in Sources */,
3560D85522889089003C12E0 /* tab2.swift in Sources */,
35900FB4228940AC00D796D3 /* SearchVC.swift in Sources */,
35900FB22289409000D796D3 /* MessagesVC.swift in Sources */,
Expand Down
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ class ProfileVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
imageView.layer.cornerRadius = 75/2

imageView.layer.borderColor = UIColor.black.cgColor

let gest = UITapGestureRecognizer(target: self, action: #selector(uploadPic))
gest.numberOfTapsRequired = 1
imageView.addGestureRecognizer(gest)
return imageView
}()

let name : UILabel = {
let name = UILabel()
name.text = "FirstName LastName"
name.translatesAutoresizingMaskIntoConstraints = false
return name
}()
Expand All @@ -47,6 +50,15 @@ class ProfileVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
options.translatesAutoresizingMaskIntoConstraints = false
return options
}()

// let alert : UIAlertController = {
// let alert = UIAlertController(title: "Logout", message: "Are you sure you want to logout?", preferredStyle: .alert)
// alert.addAction(UIAlertAction(title: "Yes", style: .destructive, handler: nil))
// alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil))
// return alert
// }()

let progressHUD = ProgressHUD(text: "Logging Out...")

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -62,6 +74,9 @@ class ProfileVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
options.delegate = self
options.dataSource = self
options.register(UITableViewCell.self, forCellReuseIdentifier: "cellId")

self.view.addSubview(progressHUD)
progressHUD.hide()

}

Expand Down Expand Up @@ -107,7 +122,6 @@ class ProfileVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
curr.name = item.value["name"]
curr.profLinik = item.value["profilePic"]
curr.id = item.key

self.name.text = curr.name
let profileImageUrl = curr.profLinik
self.profileImageView.loadImageUsingCacheWithUrlString(urlString: profileImageUrl!)
Expand All @@ -130,19 +144,45 @@ class ProfileVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
return 2
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath)

if(indexPath.row == 0){
cell.textLabel?.text = "Logout"
return cell
}

cell.textLabel?.text = "Cell"


return cell
}


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath as IndexPath, animated: true)
if indexPath.row == 0{
progressHUD.show()
DispatchQueue.main.asyncAfter(deadline: .now() + 3.5) {
self.progressHUD.hide()
self.logout()
}
}
}

func logout(){
do{
try Auth.auth().signOut()
let newVC = LoginVC()
self.present(newVC, animated: true)
}
catch{}
}

@objc func uploadPic(){
print("Upload pic")
}

}
File renamed without changes.
File renamed without changes.

0 comments on commit 4d28564

Please sign in to comment.