Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Nov 28, 2024
1 parent 081ff8b commit 9889a79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/AIChat/AIChatModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ final class AIChatModel {
self?.cleanupPublisher.send()
}
}

}
13 changes: 5 additions & 8 deletions DuckDuckGo/AIChat/AIChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit
import Combine

Expand All @@ -36,7 +35,6 @@ final class AIChatViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

setupNavigationBar()
subscribeToCleanupPublisher()
}
Expand Down Expand Up @@ -64,26 +62,26 @@ final class AIChatViewController: UIViewController {

let titleLabel = UILabel()
titleLabel.text = UserText.aiChatTitle
titleLabel.font = UIFont.semiBoldAppFont(ofSize: 17)
titleLabel.font = .semiBoldAppFont(ofSize: 17)

let stackView = UIStackView(arrangedSubviews: [imageView, titleLabel])
stackView.axis = .horizontal
stackView.spacing = 8
stackView.alignment = .center
stackView.distribution = .fill

let leftBarButtonItem = UIBarButtonItem(customView: stackView)
navigationItem.leftBarButtonItem = leftBarButtonItem
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: stackView)

let closeButton = UIBarButtonItem(
image: UIImage(named: "Close-24")!,
image: UIImage(named: "Close-24"),
style: .plain,
target: self,
action: #selector(closeButtonTapped)
)
closeButton.tintColor = .label
navigationItem.rightBarButtonItem = closeButton
}

private func addWebViewController() {
guard webViewController == nil else {
print("WebViewController already exists, returning")
Expand All @@ -107,7 +105,6 @@ final class AIChatViewController: UIViewController {
newWebViewController.didMove(toParent: self)
}


private func removeWebViewController() {
webViewController?.removeFromParent()
webViewController?.view.removeFromSuperview()
Expand All @@ -124,7 +121,7 @@ final class AIChatViewController: UIViewController {

@objc private func closeButtonTapped() {
chatModel.startCleanupTimer()
dismiss(animated: true, completion: nil)
dismiss(animated: true)
}

override func didReceiveMemoryWarning() {
Expand Down

0 comments on commit 9889a79

Please sign in to comment.