PickerGroupCell.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2015-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "PickerGroupCell.h"
  21. #import "AvatarMaker.h"
  22. #import "PermissionChecker.h"
  23. #import "BundleUtil.h"
  24. @implementation PickerGroupCell
  25. - (void)awakeFromNib {
  26. [super awakeFromNib];
  27. _nameLabel.font = [UIFont boldSystemFontOfSize: _nameLabel.font.pointSize];
  28. }
  29. - (void)setGroup:(GroupProxy *)group {
  30. _group = group;
  31. NSString *groupName = group.conversation.displayName;
  32. [_nameLabel setText: groupName];
  33. NSString *creator = [_group creatorString];
  34. NSString *memberCount = [_group membersSummaryString];
  35. [_creatorNameLabel setText:creator];
  36. [_countMembersLabel setText:memberCount];
  37. _avatarImage.image = [BundleUtil imageNamed:@"Unknown"];
  38. [[AvatarMaker sharedAvatarMaker] avatarForConversation:group.conversation size:_avatarImage.image.size.width masked:YES onCompletion:^(UIImage *avatarImage) {
  39. dispatch_async(dispatch_get_main_queue(), ^{
  40. self.avatarImage.image = avatarImage;
  41. });
  42. }];
  43. _nameLabel.highlightedTextColor = _nameLabel.textColor;
  44. [self updateState];
  45. }
  46. - (void)updateState {
  47. if ([[PermissionChecker permissionChecker] canSendIn:_group.conversation entityManager:nil]) {
  48. _avatarImage.alpha = 1.0;
  49. _nameLabel.alpha = 1.0;
  50. self.userInteractionEnabled = YES;
  51. } else {
  52. _avatarImage.alpha = 0.5;
  53. _nameLabel.alpha = 0.5;
  54. self.userInteractionEnabled = NO;
  55. }
  56. }
  57. @end