소스 검색

right align location streaming indicator in chat view

cyberta 5 년 전
부모
커밋
e831e1b10a
2개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 0
      deltachat-ios/Controller/ChatViewController.swift
  2. 9 1
      deltachat-ios/View/ChatTitleView.swift

+ 9 - 0
deltachat-ios/Controller/ChatViewController.swift

@@ -233,6 +233,15 @@ class ChatViewController: MessagesViewController {
         stopTimer()
     }
 
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        coordinator.animate(alongsideTransition: { (_) -> Void in
+            if self.showCustomNavBar, let titleView = self.navigationItem.titleView as? ChatTitleView {
+                titleView.hideLocationStreamingIndicator() }},
+                            completion: { (_) -> Void in
+                                self.updateTitle(chat: DcChat(id: self.chatId)) })
+        super.viewWillTransition(to: size, with: coordinator)
+    }
+
     private func updateTitle(chat: DcChat) {
         let titleView =  ChatTitleView()
 

+ 9 - 1
deltachat-ios/View/ChatTitleView.swift

@@ -31,6 +31,9 @@ class ChatTitleView: UIView {
         return view
     }()
 
+    private let paddingNaviationButtons = 120
+    private let sizeStreamingIndicator = 28
+
     init() {
         super.init(frame: .zero)
         setupSubviews()
@@ -47,7 +50,8 @@ class ChatTitleView: UIView {
         addSubview(containerView)
         addConstraints([ containerView.constraintAlignTopTo(self),
                          containerView.constraintAlignBottomTo(self),
-                         containerView.constraintCenterXTo(self)])
+                         containerView.constraintCenterXTo(self),
+                         containerView.constraintWidthTo(UIScreen.main.bounds.width - CGFloat(paddingNaviationButtons + sizeStreamingIndicator)) ])
 
         containerView.addSubview(titleLabel)
         containerView.addConstraints([ titleLabel.constraintAlignLeadingTo(containerView),
@@ -73,4 +77,8 @@ class ChatTitleView: UIView {
         subtitleLabel.text = subtitle
         locationStreamingIndicator.isHidden = !isLocationStreaming
     }
+
+    func hideLocationStreamingIndicator() {
+        locationStreamingIndicator.isHidden = true
+    }
 }