git.iko.soy/dashared/GDproject
on master help sign in
Working authentication
commit5334c41bb98f048822f9aebca94466b413d902b4 authorDarya Rednikina <rednikina.com@yandex.ru> dateSat 11 May 2019, 13:01 (7 years ago) parentc621bf1
8 files changed+33−26
GDproject/Base.lproj/Main.storyboard+1 GDproject/Controller/ News and channels/FullPostController.swift+1−1 GDproject/Controller/Coordinators/MessagesCoordinator.swift+7−4 GDproject/Controller/Log In/CodeViewController.swift+6−6 GDproject/Controller/Log In/LogInViewController.swift+1−1 GDproject/Controller/Messages/Dialog/DialogViewController.swift+1−1 GDproject/Controller/Profile/ProfileViewController.swift+12−6 GDproject/Simple model/Model.swift+4−7
GDproject/Base.lproj/Main.storyboard+1
@@ -286,6 +286,7 @@
286286 </textField>
287287 </subviews>
288288 <constraints>
289+ <constraint firstAttribute="height" constant="58" id="5tl-bI-7tm"/>
289290 <constraint firstItem="YKO-0M-KD8" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="E7r-rk-4Mb"/>
290291 <constraint firstItem="SmG-Ae-oOs" firstAttribute="width" secondItem="744-t1-YNn" secondAttribute="width" id="Hkd-L6-qkf"/>
291292 <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 {
2525
2626 func setUpNavigationBar(){
2727 navigationItem.largeTitleDisplayMode = .never
28− navigationItem.title = "\(post?.authorId ?? 0)"
28+ navigationItem.title = "Post"
2929 navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(self.options))]
3030 }
3131
GDproject/Controller/Coordinators/MessagesCoordinator.swift+7−4
@@ -33,14 +33,14 @@ class MessagesCoordinator: BaseCoordinator {
3333
3434 let newVC = self.storyboard.instantiateViewController(withIdentifier: peopleToWriteVC) as! PeopleToWriteViewController
3535
36− newVC.whatToDoWithSelection = { [weak newVC, weak self] in
36+ newVC.whatToDoWithSelection = { [weak newVC, weak self] people in
3737 newVC?.navigationController?.popViewController(animated: true)
3838
3939 // detect is it a user or group dialog
40− let count = $0.count
40+ let count = people.count
4141 if count == 1 {
4242
43− let user = $0.first!.key
43+ let user = people.first!.key
4444 let createdDialog = Model.Dialog.userChat(Model.UserChat(user: user))
4545
4646 let vc = DialogViewController()
@@ -49,11 +49,14 @@ class MessagesCoordinator: BaseCoordinator {
4949 self?.navigationController?.pushViewController(vc, animated: true)
5050
5151 } 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+
5355 Model.createGroupChat(from: group, completion: { [weak self] id in
5456
5557 let newVC1 = DialogViewController()
5658 group.id = id
59+ newVC1.users = Model.Channels.fullPeopleDict
5760 newVC1.dialog = Model.Dialog.groupChat(Model.GroupChat(group: group))
5861 self?.navigationController?.pushViewController(newVC1, animated: true)
5962 })
GDproject/Controller/Log In/CodeViewController.swift+6−6
@@ -23,12 +23,12 @@ class CodeViewController: UIViewController {
2323 super.viewDidLoad()
2424 setUpConstraint()
2525
26− f1.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
27− f2.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
28− f3.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
29− f4.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
30− f5.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .touchUpInside)
31− f6.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: .editingChanged)
28+ f3.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
29+ f4.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
30+ f5.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
31+ f6.addTarget(self, action: #selector(textFiledDidChange(textField:)), for: .editingChanged)
3232 }
3333
3434 override func viewWillAppear(_ animated: Bool) {
GDproject/Controller/Log In/LogInViewController.swift+1−1
@@ -72,7 +72,7 @@ class LogInViewController: UIViewController {
7272 // configure keyboardBar components
7373 keyboardBar.addSubview(logInButton)
7474 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)
7676
7777 }
7878
GDproject/Controller/Messages/Dialog/DialogViewController.swift+1−1
@@ -253,7 +253,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
253253 tabBarController?.tabBar.isHidden = true
254254
255255 if let dialog = dialog {
256− getMessages(for: dialog)
256+ getMessagesNew(for: dialog)
257257 }
258258 }
259259
GDproject/Controller/Profile/ProfileViewController.swift+12−6
@@ -48,15 +48,15 @@ class ProfileViewController: UIViewController
4848
4949 var onChannelsListToAddAPerson: ((Model.Users)->())?
5050
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")]
5252
5353 func fill(with user: Model.Users)
5454 {
55− self.facultyLabel.text = "Студент: Факультет Компьютерных Наук"
55+ self.facultyLabel.text = user.faculty.name
5656 self.nameLabel.text = "\(user.firstName) \(user.middleName)"
5757 self.surnameLabel.text = "\(user.lastName)"
58− self.profileImageView.image = protoDictionary[user.id]?.roundedImage
59− self.placeLabel.text = "📍Москва, Кочновский пр.3"
58+ self.profileImageView.image = protoDictionary[user.faculty.campusCode]?.roundedImage
59+ self.placeLabel.text = "📍\(user.faculty.campusName)"
6060 if user.id == DataStorage.standard.getUserId() {
6161 newMessageButton.isHidden = true
6262 } else {
@@ -66,8 +66,14 @@ class ProfileViewController: UIViewController
6666
6767 var user: Model.Users? {
6868 didSet {
69− self.fill(with: user!)
70− navigationItem.title = "\(user!.firstName) \(user!.lastName)"
69+ if let user = user {
70+ self.fill(with: user)
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+ }
7177 }
7278 }
7379
GDproject/Simple model/Model.swift+4−7
@@ -128,6 +128,8 @@ class Model{
128128 var lastName: String
129129 var firstName: String
130130 var id: Int
131+ var faculty: Faculty
132+ var email: String
131133
132134 func fullName() -> String {
133135 return "\(firstName) \(lastName)"
@@ -264,12 +266,6 @@ class Model{
264266
265267 if statusCode == 204 {
266268 // 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−
273269 completion(true)
274270 }
275271
@@ -462,6 +458,7 @@ class Model{
462458 guard let users = try? decoder.decode([Users].self, from: json) else { return }
463459
464460 var dict: [Int:Users] = [:]
461+
465462 users.forEach({ (user) in
466463 dict[user.id] = user
467464 })
@@ -657,7 +654,7 @@ class Model{
657654
658655 guard let newQueery = try? decoder.decode(QueryPosts<Posts>.self, from: json) else { return }
659656
660− // idUser = newQueery.users
657+ print("\(anonymousChannel) \(newQueery)")
661658 completion((newQueery.users, newQueery.response))
662659 }
663660 }