|  |  | @ -27,8 +27,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     private lazy var spinner: NVActivityIndicatorView = { |  |  |  |     private lazy var spinner: NVActivityIndicatorView = { | 
			
		
	
		
		
			
				
					
					|  |  |  |         let result = NVActivityIndicatorView(frame: CGRect.zero, type: .circleStrokeSpin, color: Colors.text, padding: nil) |  |  |  |         let result = NVActivityIndicatorView(frame: CGRect.zero, type: .circleStrokeSpin, color: Colors.text, padding: nil) | 
			
		
	
		
		
			
				
					
					|  |  |  |         result.set(.width, to: 40) |  |  |  |         result.set(.width, to: OpenGroupSuggestionGrid.cellHeight) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         result.set(.height, to: 40) |  |  |  |         result.set(.height, to: OpenGroupSuggestionGrid.cellHeight) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         return result |  |  |  |         return result | 
			
		
	
		
		
			
				
					
					|  |  |  |     }() |  |  |  |     }() | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
	
		
		
			
				
					|  |  | @ -57,8 +57,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl | 
			
		
	
		
		
			
				
					
					|  |  |  |         addSubview(spinner) |  |  |  |         addSubview(spinner) | 
			
		
	
		
		
			
				
					
					|  |  |  |         spinner.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top ], to: self) |  |  |  |         spinner.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top ], to: self) | 
			
		
	
		
		
			
				
					
					|  |  |  |         spinner.startAnimating() |  |  |  |         spinner.startAnimating() | 
			
		
	
		
		
			
				
					
					|  |  |  |         heightConstraint = set(.height, to: 40) |  |  |  |         heightConstraint = set(.height, to: OpenGroupSuggestionGrid.cellHeight) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         widthAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true |  |  |  |         widthAnchor.constraint(greaterThanOrEqualToConstant: OpenGroupSuggestionGrid.cellHeight).isActive = true | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         let _ = OpenGroupAPIV2.defaultRoomsPromise?.done { [weak self] rooms in |  |  |  |         let _ = OpenGroupAPIV2.defaultRoomsPromise?.done { [weak self] rooms in | 
			
		
	
		
		
			
				
					
					|  |  |  |             self?.rooms = rooms |  |  |  |             self?.rooms = rooms | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
	
		
		
			
				
					|  |  | @ -68,7 +68,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl | 
			
		
	
		
		
			
				
					
					|  |  |  |     private func update() { |  |  |  |     private func update() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         spinner.stopAnimating() |  |  |  |         spinner.stopAnimating() | 
			
		
	
		
		
			
				
					
					|  |  |  |         spinner.isHidden = true |  |  |  |         spinner.isHidden = true | 
			
		
	
		
		
			
				
					
					|  |  |  |         let height = OpenGroupSuggestionGrid.cellHeight * ceil(CGFloat(rooms.count) / 2) |  |  |  |         let roomCount = min(rooms.count, 8) // Cap to a maximum of 8 (4 rows of 2) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         let height = OpenGroupSuggestionGrid.cellHeight * ceil(CGFloat(roomCount) / 2) | 
			
		
	
		
		
			
				
					
					|  |  |  |         heightConstraint.constant = height |  |  |  |         heightConstraint.constant = height | 
			
		
	
		
		
			
				
					
					|  |  |  |         collectionView.reloadData() |  |  |  |         collectionView.reloadData() | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -85,9 +86,6 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |  |  |  |     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | 
			
		
	
		
		
			
				
					
					|  |  |  |         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Cell.identifier, for: indexPath) as! Cell |  |  |  |         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Cell.identifier, for: indexPath) as! Cell | 
			
		
	
		
		
			
				
					
					|  |  |  |         let roomCount = min(rooms.count, 8) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cell.showRightSeparator = (indexPath.row % 2 != 0) || (indexPath.row % 2 == 0 && indexPath.row == roomCount - 1) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cell.showBottomSeparator = (indexPath.row >= roomCount - 2) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cell.room = rooms[indexPath.item] |  |  |  |         cell.room = rooms[indexPath.item] | 
			
		
	
		
		
			
				
					
					|  |  |  |         return cell |  |  |  |         return cell | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -103,14 +101,18 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl | 
			
		
	
		
		
			
				
					
					|  |  |  | extension OpenGroupSuggestionGrid { |  |  |  | extension OpenGroupSuggestionGrid { | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     fileprivate final class Cell : UICollectionViewCell { |  |  |  |     fileprivate final class Cell : UICollectionViewCell { | 
			
		
	
		
		
			
				
					
					|  |  |  |         var showRightSeparator = false |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         var showBottomSeparator = false |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         var room: OpenGroupAPIV2.Info? { didSet { update() } } |  |  |  |         var room: OpenGroupAPIV2.Info? { didSet { update() } } | 
			
		
	
		
		
			
				
					
					|  |  |  |         private var rightSeparator: UIView! |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         private var bottomSeparator: UIView! |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         static let identifier = "OpenGroupSuggestionGridCell" |  |  |  |         static let identifier = "OpenGroupSuggestionGridCell" | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private lazy var snContentView: UIView = { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             let result = UIView() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             result.backgroundColor = Colors.navigationBarBackground | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             result.set(.height, to: Cell.contentViewHeight) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             result.layer.cornerRadius = Cell.contentViewCornerRadius | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return result | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         private lazy var imageView: UIImageView = { |  |  |  |         private lazy var imageView: UIImageView = { | 
			
		
	
		
		
			
				
					
					|  |  |  |             let result = UIImageView() |  |  |  |             let result = UIImageView() | 
			
		
	
		
		
			
				
					
					|  |  |  |             let size: CGFloat = 24 |  |  |  |             let size: CGFloat = 24 | 
			
		
	
	
		
		
			
				
					|  |  | @ -129,6 +131,10 @@ extension OpenGroupSuggestionGrid { | 
			
		
	
		
		
			
				
					
					|  |  |  |             return result |  |  |  |             return result | 
			
		
	
		
		
			
				
					
					|  |  |  |         }() |  |  |  |         }() | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private static let contentViewInset: CGFloat = 4 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private static var contentViewHeight: CGFloat { OpenGroupSuggestionGrid.cellHeight - 2 * contentViewInset } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private static var contentViewCornerRadius: CGFloat { contentViewHeight / 2 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         override init(frame: CGRect) { |  |  |  |         override init(frame: CGRect) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             super.init(frame: frame) |  |  |  |             super.init(frame: frame) | 
			
		
	
		
		
			
				
					
					|  |  |  |             setUpViewHierarchy() |  |  |  |             setUpViewHierarchy() | 
			
		
	
	
		
		
			
				
					|  |  | @ -140,41 +146,25 @@ extension OpenGroupSuggestionGrid { | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         private func setUpViewHierarchy() { |  |  |  |         private func setUpViewHierarchy() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             addSubview(snContentView) | 
			
		
	
		
		
			
				
					
					|  |  |  |             let stackView = UIStackView(arrangedSubviews: [ imageView, label ]) |  |  |  |             let stackView = UIStackView(arrangedSubviews: [ imageView, label ]) | 
			
		
	
		
		
			
				
					
					|  |  |  |             stackView.axis = .horizontal |  |  |  |             stackView.axis = .horizontal | 
			
		
	
		
		
			
				
					
					|  |  |  |             stackView.spacing = Values.smallSpacing |  |  |  |             stackView.spacing = Values.smallSpacing | 
			
		
	
		
		
			
				
					
					|  |  |  |             addSubview(stackView) |  |  |  |             snContentView.addSubview(stackView) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             stackView.center(.vertical, in: self) |  |  |  |             stackView.center(.vertical, in: snContentView) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             stackView.pin(.leading, to: .leading, of: self, withInset: Values.smallSpacing) |  |  |  |             stackView.pin(.leading, to: .leading, of: snContentView, withInset: Values.smallSpacing) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             trailingAnchor.constraint(greaterThanOrEqualTo: stackView.trailingAnchor, constant: Values.smallSpacing).isActive = true |  |  |  |             snContentView.trailingAnchor.constraint(greaterThanOrEqualTo: stackView.trailingAnchor, constant: Values.smallSpacing).isActive = true | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             setUpSeparators() |  |  |  |             snContentView.pin(to: self, withInset: Cell.contentViewInset) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         private func setUpSeparators() { |  |  |  |         override func layoutSubviews() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             func getVSeparator() -> UIView { |  |  |  |             super.layoutSubviews() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 let separator = UIView() |  |  |  |             let newPath = UIBezierPath(roundedRect: snContentView.bounds, cornerRadius: Cell.contentViewCornerRadius).cgPath | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 separator.backgroundColor = Colors.separator |  |  |  |             snContentView.layer.shadowPath = newPath | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 separator.set(.height, to: 1 / UIScreen.main.scale) |  |  |  |             snContentView.layer.shadowColor = UIColor.black.cgColor | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 return separator |  |  |  |             snContentView.layer.shadowOffset = CGSize.zero | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             snContentView.layer.shadowOpacity = 0.2 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             func getHSeparator() -> UIView { |  |  |  |             snContentView.layer.shadowRadius = 2 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 let separator = UIView() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 separator.backgroundColor = Colors.separator |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 separator.set(.width, to: 1 / UIScreen.main.scale) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 return separator |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             let leftSeparator = getHSeparator() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             addSubview(leftSeparator) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             leftSeparator.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top, UIView.VerticalEdge.bottom ], to: self) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             let topSeparator = getVSeparator() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             addSubview(topSeparator) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             topSeparator.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top, UIView.HorizontalEdge.right ], to: self) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             rightSeparator = getHSeparator() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             addSubview(rightSeparator) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             rightSeparator.pin([ UIView.VerticalEdge.top, UIView.HorizontalEdge.right, UIView.VerticalEdge.bottom ], to: self) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             bottomSeparator = getVSeparator() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             addSubview(bottomSeparator) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             bottomSeparator.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.bottom, UIView.HorizontalEdge.right ], to: self) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         private func update() { |  |  |  |         private func update() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -183,8 +173,6 @@ extension OpenGroupSuggestionGrid { | 
			
		
	
		
		
			
				
					
					|  |  |  |             imageView.image = given(promise.value) { UIImage(data: $0)! } |  |  |  |             imageView.image = given(promise.value) { UIImage(data: $0)! } | 
			
		
	
		
		
			
				
					
					|  |  |  |             imageView.isHidden = (imageView.image == nil) |  |  |  |             imageView.isHidden = (imageView.image == nil) | 
			
		
	
		
		
			
				
					
					|  |  |  |             label.text = room.name |  |  |  |             label.text = room.name | 
			
		
	
		
		
			
				
					
					|  |  |  |             rightSeparator.alpha = showRightSeparator ? 1 :0 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             bottomSeparator.alpha = showBottomSeparator ? 1 :0 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |