tweak: redo home vc plus button

pull/689/head
Ryan Zhao 3 years ago
parent fc949a9882
commit 5dd5168b92

@ -7,8 +7,9 @@ import SessionMessagingKit
import SessionUtilitiesKit import SessionUtilitiesKit
import SignalUtilitiesKit import SignalUtilitiesKit
final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConversationButtonSetDelegate, SeedReminderViewDelegate { final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedReminderViewDelegate {
private static let loadingHeaderHeight: CGFloat = 20 private static let loadingHeaderHeight: CGFloat = 20
private static let newConversationButtonSize: CGFloat = 60
private let viewModel: HomeViewModel = HomeViewModel() private let viewModel: HomeViewModel = HomeViewModel()
private var dataChangeObservable: DatabaseCancellable? private var dataChangeObservable: DatabaseCancellable?
@ -90,10 +91,27 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
return result return result
}() }()
private lazy var newConversationButtonSet: NewConversationButtonSet = { private lazy var newConversationButton: UIButton = {
let result = NewConversationButtonSet() let result = UIButton(type: .system)
result.delegate = self let iconSize = CGFloat(24)
let icon = #imageLiteral(resourceName: "Plus").scaled(to: CGSize(width: iconSize, height: iconSize))
let glowConfiguration = UIView.CircularGlowConfiguration(
size: Self.newConversationButtonSize,
color: Colors.expandedButtonGlowColor,
isAnimated: false,
radius: isLightMode ? 4 : 6
)
result.setImage(icon, for: .normal)
result.set(.width, to: Self.newConversationButtonSize)
result.set(.height, to: Self.newConversationButtonSize)
result.contentMode = .center
result.backgroundColor = Colors.accent
result.layer.cornerRadius = Self.newConversationButtonSize / 2
result.setCircularGlow(with: glowConfiguration)
result.layer.masksToBounds = false
result.tintColor = .white
return result return result
}() }()
@ -185,10 +203,10 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
let verticalCenteringConstraint = emptyStateView.center(.vertical, in: view) let verticalCenteringConstraint = emptyStateView.center(.vertical, in: view)
verticalCenteringConstraint.constant = -16 // Makes things appear centered visually verticalCenteringConstraint.constant = -16 // Makes things appear centered visually
// New conversation button set // New conversation button
view.addSubview(newConversationButtonSet) view.addSubview(newConversationButton)
newConversationButtonSet.center(.horizontal, in: view) newConversationButton.center(.horizontal, in: view)
newConversationButtonSet.pin(.bottom, to: .bottom, of: view, withInset: -Values.newConversationButtonBottomOffset) // Negative due to how the constraint is set up newConversationButton.pin(.bottom, to: .bottom, of: view, withInset: -Values.newConversationButtonBottomOffset) // Negative due to how the constraint is set up
// Notifications // Notifications
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
@ -385,6 +403,16 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
} }
} }
private func updateNewConversationButton() {
let glowConfiguration = UIView.CircularGlowConfiguration(
size: Self.newConversationButtonSize,
color: Colors.expandedButtonGlowColor,
isAnimated: false,
radius: isLightMode ? 4 : 6
)
newConversationButton.setCircularGlow(with: glowConfiguration)
}
private func updateNavBarButtons() { private func updateNavBarButtons() {
// Profile picture view // Profile picture view
let profilePictureSize = Values.verySmallProfilePictureSize let profilePictureSize = Values.verySmallProfilePictureSize
@ -435,6 +463,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
let gradient = Gradients.homeVCFade let gradient = Gradients.homeVCFade
fadeView.setGradient(gradient) // Re-do the gradient fadeView.setGradient(gradient) // Re-do the gradient
updateNewConversationButton()
tableView.reloadData() tableView.reloadData()
} }
@ -704,17 +733,17 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
self.navigationController?.setViewControllers([ self, searchController ], animated: true) self.navigationController?.setViewControllers([ self, searchController ], animated: true)
} }
@objc func joinOpenGroup() { // @objc func joinOpenGroup() {
let joinOpenGroupVC: JoinOpenGroupVC = JoinOpenGroupVC() // let joinOpenGroupVC: JoinOpenGroupVC = JoinOpenGroupVC()
let navigationController: OWSNavigationController = OWSNavigationController(rootViewController: joinOpenGroupVC) // let navigationController: OWSNavigationController = OWSNavigationController(rootViewController: joinOpenGroupVC)
//
if UIDevice.current.isIPad { // if UIDevice.current.isIPad {
navigationController.modalPresentationStyle = .fullScreen // navigationController.modalPresentationStyle = .fullScreen
} // }
//
present(navigationController, animated: true, completion: nil) // present(navigationController, animated: true, completion: nil)
} // }
//
@objc func createNewDM() { @objc func createNewDM() {
let newDMVC = NewDMVC() let newDMVC = NewDMVC()
let navigationController = OWSNavigationController(rootViewController: newDMVC) let navigationController = OWSNavigationController(rootViewController: newDMVC)
@ -734,12 +763,12 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, NewConve
present(navigationController, animated: true, completion: nil) present(navigationController, animated: true, completion: nil)
} }
@objc func createClosedGroup() { // @objc func createClosedGroup() {
let newClosedGroupVC = NewClosedGroupVC() // let newClosedGroupVC = NewClosedGroupVC()
let navigationController = OWSNavigationController(rootViewController: newClosedGroupVC) // let navigationController = OWSNavigationController(rootViewController: newClosedGroupVC)
if UIDevice.current.isIPad { // if UIDevice.current.isIPad {
navigationController.modalPresentationStyle = .fullScreen // navigationController.modalPresentationStyle = .fullScreen
} // }
present(navigationController, animated: true, completion: nil) // present(navigationController, animated: true, completion: nil)
} // }
} }

Loading…
Cancel
Save