git.iko.soy/dashared/GDproject
on master help sign in
Working authentication
5334c41Darya Rednikina
GDproject/Base.lproj/Main.storyboard+1
@@ -286,6 +286,7 @@
286 </textField>
286 </textField>
287 </subviews>
287 </subviews>
288 <constraints>
288 <constraints>
289+ <constraint firstAttribute="height" constant="58" id="5tl-bI-7tm"/>
289 <constraint firstItem="YKO-0M-KD8" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="E7r-rk-4Mb"/>
290 <constraint firstItem="YKO-0M-KD8" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="E7r-rk-4Mb"/>
290 <constraint firstItem="SmG-Ae-oOs" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="Hkd-L6-qkf"/>
291 <constraint firstItem="SmG-Ae-oOs" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="Hkd-L6-qkf"/>
291 <constraint firstItem="qDh-32-HSn" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="Koj-e5-Dof"/>
292 <constraint firstItem="qDh-32-HSn" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="Koj-e5-Dof"/>
GDproject/Controller/ News and channels/FullPostController.swift+1−1
@@ -25,7 +25,7 @@ class FullPostController: UITableViewController {
25
25
26 func setUpNavigationBar(){
26 func setUpNavigationBar(){
27 navigationItem.largeTitleDisplayMode = .never
27 navigationItem.largeTitleDisplayMode = .never
28− navigationItem.title = "\(post?.authorId ?? 0)"
28+ navigationItem.title = "Post"
29 navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(self.options))]
29 navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(self.options))]
30 }
30 }
31
31
GDproject/Controller/Coordinators/MessagesCoordinator.swift+7−4
@@ -33,14 +33,14 @@ class MessagesCoordinator: BaseCoordinator {
33
33
34 let newVC = self.storyboard.instantiateViewController(withIdentifier: peopleToWriteVC) as! PeopleToWriteViewController
34 let newVC = self.storyboard.instantiateViewController(withIdentifier: peopleToWriteVC) as! PeopleToWriteViewController
35
35
36− newVC.whatToDoWithSelection = { [weak newVC, weak self] in
36+ newVC.whatToDoWithSelection = { [weak newVC, weak self] people in
37 newVC?.navigationController?.popViewController(animated: true)
37 newVC?.navigationController?.popViewController(animated: true)
38
38
39 // detect is it a user or group dialog
39 // detect is it a user or group dialog
40− let count = $0.count
40+ let count = people.count
41 if count == 1 {
41 if count == 1 {
42
42
43− let user = $0.first!.key
43+ let user = people.first!.key
44 let createdDialog = Model.Dialog.userChat(Model.UserChat(user: user))
44 let createdDialog = Model.Dialog.userChat(Model.UserChat(user: user))
45
45
46 let vc = DialogViewController()
46 let vc = DialogViewController()
@@ -49,11 +49,14 @@ class MessagesCoordinator: BaseCoordinator {
49 self?.navigationController?.pushViewController(vc, animated: true)
49 self?.navigationController?.pushViewController(vc, animated: true)
50
50
51 } else {
51 } else {
52− var group = Model.Group(users: $0, name: "Untitled", id: 0)
52+ var group = Model.Group(users: people, name: "Untitled", id: 0)
53+ group.users[DataStorage.standard.getUserId()] = Model.UserPermission(isAdmin: true)
54+
53 Model.createGroupChat(from: group, completion: { [weak self] id in
55 Model.createGroupChat(from: group, completion: { [weak self] id in
54
56
55 let newVC1 = DialogViewController()
57 let newVC1 = DialogViewController()
56 group.id = id
58 group.id = id
59+ newVC1.users = Model.Channels.fullPeopleDict
57 newVC1.dialog = Model.Dialog.groupChat(Model.GroupChat(group: group))
60 newVC1.dialog = Model.Dialog.groupChat(Model.GroupChat(group: group))
58 self?.navigationController?.pushViewController(newVC1, animated: true)
61 self?.navigationController?.pushViewController(newVC1, animated: true)
59 })
62 })
GDproject/Controller/Log In/CodeViewController.swift+6−6
@@ -23,12 +23,12 @@ class CodeViewController: UIViewController {
23 super.viewDidLoad()
23 super.viewDidLoad()
24 setUpConstraint()
24 setUpConstraint()
25
25
26− f1.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
26+ f1.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
27− f2.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
27+ f2.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
28− f3.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
28+ f3.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
29− f4.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
29+ f4.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
30− f5.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
30+ f5.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
31− f6.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
31+ f6.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
32 }
32 }
33
33
34 override func viewWillAppear(_ animated: Bool) {
34 override func viewWillAppear(_ animated: Bool) {
GDproject/Controller/Log In/LogInViewController.swift+1−1
@@ -72,7 +72,7 @@ class LogInViewController: UIViewController {
72 // configure keyboardBar components
72 // configure keyboardBar components
73 keyboardBar.addSubview(logInButton)
73 keyboardBar.addSubview(logInButton)
74 logInButton.height(50)
74 logInButton.height(50)
75− logInButton.rightToSuperview(view.rightAnchor, offset: 16, relation: .equal, isActive: true)
75+ logInButton.rightToSuperview(view.rightAnchor, offset: -16, relation: .equal, isActive: true)
76
76
77 }
77 }
78
78
GDproject/Controller/Messages/Dialog/DialogViewController.swift+1−1
@@ -253,7 +253,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
253 tabBarController?.tabBar.isHidden = true
253 tabBarController?.tabBar.isHidden = true
254
254
255 if let dialog = dialog {
255 if let dialog = dialog {
256− getMessages(for: dialog)
256+ getMessagesNew(for: dialog)
257 }
257 }
258 }
258 }
259
259
GDproject/Controller/Profile/ProfileViewController.swift+12−6
@@ -48,15 +48,15 @@ class ProfileViewController: UIViewController
48
48
49 var onChannelsListToAddAPerson: ((Model.Users)->())?
49 var onChannelsListToAddAPerson: ((Model.Users)->())?
50
50
51− var protoDictionary: [Int: UIImage] = [9: #imageLiteral(resourceName: "9"), 5051: #imageLiteral(resourceName: "5051"), 69: #imageLiteral(resourceName: "69"), 42: #imageLiteral(resourceName: "42")]
51+ var protoDictionary: [String: UIImage] = ["135213": #imageLiteral(resourceName: "9"), "135288": #imageLiteral(resourceName: "5051"), "22723" : #imageLiteral(resourceName: "69"), "135083": #imageLiteral(resourceName: "42")]
52
52
53 func fill(with user: Model.Users)
53 func fill(with user: Model.Users)
54 {
54 {
55− self.facultyLabel.text = "Студент: Факультет Компьютерных Наук"
55+ self.facultyLabel.text = user.faculty.name
56 self.nameLabel.text = "\(user.firstName) \(user.middleName)"
56 self.nameLabel.text = "\(user.firstName) \(user.middleName)"
57 self.surnameLabel.text = "\(user.lastName)"
57 self.surnameLabel.text = "\(user.lastName)"
58− self.profileImageView.image = protoDictionary[user.id]?.roundedImage
58+ self.profileImageView.image = protoDictionary[user.faculty.campusCode]?.roundedImage
59− self.placeLabel.text = "📍Москва, Кочновский пр.3"
59+ self.placeLabel.text = "📍\(user.faculty.campusName)"
60 if user.id == DataStorage.standard.getUserId() {
60 if user.id == DataStorage.standard.getUserId() {
61 newMessageButton.isHidden = true
61 newMessageButton.isHidden = true
62 } else {
62 } else {
@@ -66,8 +66,14 @@ class ProfileViewController: UIViewController
66
66
67 var user: Model.Users? {
67 var user: Model.Users? {
68 didSet {
68 didSet {
69+ if let user = user {
69− self.fill(with: user!)
70+ self.fill(with: user)
70− navigationItem.title = "\(user!.firstName) \(user!.lastName)"
71+ navigationItem.title = "\(user.firstName) \(user.lastName)"
72+ } else if let id = idProfile {
73+ Model.getUsers(for: [id]) { [unowned self ] in
74+ self.user = $0[id]
75+ }
76+ }
71 }
77 }
72 }
78 }
73
79
GDproject/Simple model/Model.swift+4−7
@@ -128,6 +128,8 @@ class Model{
128 var lastName: String
128 var lastName: String
129 var firstName: String
129 var firstName: String
130 var id: Int
130 var id: Int
131+ var faculty: Faculty
132+ var email: String
131
133
132 func fullName() -> String {
134 func fullName() -> String {
133 return "\(firstName) \(lastName)"
135 return "\(firstName) \(lastName)"
@@ -264,12 +266,6 @@ class Model{
264
266
265 if statusCode == 204 {
267 if statusCode == 204 {
266 // at this point cookies are set
268 // at this point cookies are set
267− let fields = responce.response?.allHeaderFields as? [String :String]
268−
269− let cookies = HTTPCookie.cookies(withResponseHeaderFields: fields!, for: responce.response!.url!)
270−
271− HTTPCookieStorage.shared.setCookie(cookies[0])
272−
273 completion(true)
269 completion(true)
274 }
270 }
275
271
@@ -462,6 +458,7 @@ class Model{
462 guard let users = try? decoder.decode([Users].self, from: json) else { return }
458 guard let users = try? decoder.decode([Users].self, from: json) else { return }
463
459
464 var dict: [Int:Users] = [:]
460 var dict: [Int:Users] = [:]
461+
465 users.forEach({ (user) in
462 users.forEach({ (user) in
466 dict[user.id] = user
463 dict[user.id] = user
467 })
464 })
@@ -657,7 +654,7 @@ class Model{
657
654
658 guard let newQueery = try? decoder.decode(QueryPosts<Posts>.self, from: json) else { return }
655 guard let newQueery = try? decoder.decode(QueryPosts<Posts>.self, from: json) else { return }
659
656
660− // idUser = newQueery.users
657+ print("\(anonymousChannel) \(newQueery)")
661 completion((newQueery.users, newQueery.response))
658 completion((newQueery.users, newQueery.response))
662 }
659 }
663 }
660 }