Skip to content

Commit c0bbe36

Browse files
Resolve dark mode issue when creating groups
1 parent 3beb5a8 commit c0bbe36

File tree

5 files changed

+28
-33
lines changed

5 files changed

+28
-33
lines changed

ChatSecureCore/Classes/View Controllers/OTRComposeGroupViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ open class OTRComposeGroupViewController: UIViewController, UICollectionViewDele
164164
if existingItems.contains(threadOwner.uniqueId) {
165165
isExistingOccupant = true
166166
}
167-
cell.nameLabel.textColor = isExistingOccupant ? UIColor.gray : UIColor.black
168-
cell.accountLabel.textColor = isExistingOccupant ? UIColor.gray : UIColor.black
169-
cell.identifierLabel.textColor = isExistingOccupant ? UIColor.gray : UIColor.black
167+
cell.nameLabel.textColor = isExistingOccupant ? OTRBuddyInfoCell.subtitleTextColor : OTRBuddyInfoCell.primaryTextColor
168+
cell.accountLabel.textColor = isExistingOccupant ? OTRBuddyInfoCell.subtitleTextColor : OTRBuddyInfoCell.primaryTextColor
169+
cell.identifierLabel.textColor = isExistingOccupant ? OTRBuddyInfoCell.subtitleTextColor : OTRBuddyInfoCell.primaryTextColor
170170
return cell
171171
}
172172
return UITableViewCell()

ChatSecureCore/Classes/Views/Cells/OTRBuddyInfoCell.m

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,19 @@ @interface OTRBuddyInfoCell ()
2323
@property (nonatomic, strong) UILabel *identifierLabel;
2424
@property (nonatomic, strong) UILabel *accountLabel;
2525

26-
@property (nonatomic, strong, readonly) UIColor *primaryTextColor;
27-
@property (nonatomic, strong, readonly) UIColor *subtitleTextColor;
28-
2926
@end
3027

3128
@implementation OTRBuddyInfoCell
3229

33-
- (UIColor *) primaryTextColor {
30+
+ (UIColor *) primaryTextColor {
3431
if (@available(iOS 13.0, *)) {
3532
return [UIColor labelColor];
3633
} else {
3734
return [UIColor darkTextColor];
3835
}
3936
}
4037

41-
- (UIColor *) subtitleTextColor {
38+
+ (UIColor *) subtitleTextColor {
4239
if (@available(iOS 13.0, *)) {
4340
return [UIColor systemGray3Color];
4441
} else {
@@ -53,11 +50,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
5350
self.nameLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
5451

5552
self.identifierLabel = [[UILabel alloc] initForAutoLayout];
56-
self.identifierLabel.textColor = self.primaryTextColor;
53+
self.identifierLabel.textColor = self.class.primaryTextColor;
5754
self.identifierLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
5855

5956
self.accountLabel = [[UILabel alloc] initForAutoLayout];
60-
self.accountLabel.textColor = self.subtitleTextColor;
57+
self.accountLabel.textColor = self.class.subtitleTextColor;
6158
self.accountLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
6259

6360
NSArray<UILabel*> *labels = @[self.nameLabel, self.identifierLabel, self.accountLabel];
@@ -93,9 +90,9 @@ - (void)setThread:(id<OTRThreadOwner>)thread account:(nullable OTRAccount*)accou
9390
}
9491
self.identifierLabel.text = identifier;
9592

96-
UIColor *textColor = self.primaryTextColor;
93+
UIColor *textColor = self.class.primaryTextColor;
9794
if ([thread isArchived]) {
98-
textColor = self.subtitleTextColor;
95+
textColor = self.class.subtitleTextColor;
9996
}
10097
[@[self.nameLabel, self.identifierLabel] enumerateObjectsUsingBlock:^(UILabel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
10198
obj.textColor = textColor;
@@ -126,9 +123,9 @@ - (void)updateConstraints
126123

127124
- (void)prepareForReuse {
128125
[super prepareForReuse];
129-
self.nameLabel.textColor = self.primaryTextColor;
130-
self.identifierLabel.textColor = self.primaryTextColor;
131-
self.accountLabel.textColor = self.subtitleTextColor;
126+
self.nameLabel.textColor = self.class.primaryTextColor;
127+
self.identifierLabel.textColor = self.class.primaryTextColor;
128+
self.accountLabel.textColor = self.class.subtitleTextColor;
132129
}
133130

134131
- (void) infoButtonPressed:(UIButton*)sender {

ChatSecureCore/Public/OTRBuddyInfoCell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extern const CGFloat OTRBuddyInfoCellHeight;
2727
/** Action callback for infoButton */
2828
@property (nonatomic, copy, nullable) void (^infoAction)(OTRBuddyInfoCell *cell, UIButton *sender);
2929

30+
@property (class, nonatomic, strong, readonly) UIColor *primaryTextColor;
31+
@property (class, nonatomic, strong, readonly) UIColor *subtitleTextColor;
3032

3133
@end
3234
NS_ASSUME_NONNULL_END

OTRResources/Interface/OTRComposeGroup.storyboard

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="o67-Zh-raq">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="o67-Zh-raq">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<scenes>
@@ -22,15 +20,15 @@
2220
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2321
<subviews>
2422
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="cr5-7D-PoW">
25-
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
23+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2624
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
2725
<view key="tableHeaderView" contentMode="scaleToFill" id="czz-0S-JIP">
2826
<rect key="frame" x="0.0" y="0.0" width="375" height="20"/>
2927
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
3028
<subviews>
3129
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="IqC-6K-6tj">
3230
<rect key="frame" x="0.0" y="0.0" width="375" height="10"/>
33-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
31+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
3432
<constraints>
3533
<constraint firstAttribute="height" constant="10" id="Rw6-Dg-zTk"/>
3634
</constraints>
@@ -54,7 +52,7 @@
5452
</constraints>
5553
</view>
5654
</subviews>
57-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
55+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
5856
<constraints>
5957
<constraint firstItem="zka-zO-LBL" firstAttribute="leading" secondItem="czz-0S-JIP" secondAttribute="leading" constant="4" id="29d-IK-QMi"/>
6058
<constraint firstAttribute="trailing" secondItem="IqC-6K-6tj" secondAttribute="trailing" id="5WY-wZ-gCN"/>
@@ -71,7 +69,7 @@
7169
</connections>
7270
</tableView>
7371
</subviews>
74-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
72+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
7573
<constraints>
7674
<constraint firstItem="c8h-vc-VRi" firstAttribute="top" secondItem="cr5-7D-PoW" secondAttribute="bottom" id="00e-w3-kfN"/>
7775
<constraint firstAttribute="trailing" secondItem="cr5-7D-PoW" secondAttribute="trailing" id="2x0-An-DMB"/>

OTRResources/Interface/OTRComposeGroupBuddyCell.xib

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<objects>
@@ -26,13 +24,12 @@
2624
</constraints>
2725
</imageView>
2826
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tU6-2C-mKC">
29-
<rect key="frame" x="29" y="5" width="90" height="16"/>
27+
<rect key="frame" x="29" y="4.5" width="90" height="16"/>
3028
<fontDescription key="fontDescription" type="system" pointSize="13"/>
31-
<nil key="textColor"/>
3229
<nil key="highlightedColor"/>
3330
</label>
3431
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2IT-n8-QOZ">
35-
<rect key="frame" x="129" y="7" width="12" height="12"/>
32+
<rect key="frame" x="129" y="6.5" width="12" height="12"/>
3633
<constraints>
3734
<constraint firstAttribute="height" constant="12" id="VwD-Aa-TVr"/>
3835
<constraint firstAttribute="width" constant="12" id="cXM-0J-zRi"/>
@@ -45,7 +42,7 @@
4542
</button>
4643
</subviews>
4744
</view>
48-
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
45+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
4946
<constraints>
5047
<constraint firstItem="tU6-2C-mKC" firstAttribute="leading" secondItem="yH9-g6-OKm" secondAttribute="trailing" constant="4" id="4sN-ML-XrD"/>
5148
<constraint firstAttribute="bottom" secondItem="yH9-g6-OKm" secondAttribute="bottom" id="5kf-pz-AHe"/>
@@ -61,6 +58,7 @@
6158
<outlet property="image" destination="yH9-g6-OKm" id="3fC-TB-ph5"/>
6259
<outlet property="label" destination="tU6-2C-mKC" id="eyi-Ac-MsG"/>
6360
</connections>
61+
<point key="canvasLocation" x="138" y="153"/>
6462
</collectionViewCell>
6563
</objects>
6664
<resources>

0 commit comments

Comments
 (0)