Skip to content

Commit f1f30b1

Browse files
committed
Make use of tint color configurable
IASKColorSchemeSystem: color scheme replicating the system settings IASKColorSchemeTinted: color scheme where user-editable options are displayed in tintColor fixes #513
1 parent 8520b49 commit f1f30b1

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

InAppSettingsKit.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'InAppSettingsKit'
3-
s.version = '3.8.3'
3+
s.version = '3.8.4'
44
s.summary = 'This iPhone framework allows settings to be in-app in addition to being in the Settings app.'
55

66
s.description = <<-DESC

InAppSettingsKitSampleApp/Classes/MainViewController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class MainViewController: UIViewController {
3838
{
3939
settingsVC.delegate = self
4040
settingsVC.showDoneButton = segue.identifier == "modal"
41+
settingsVC.colorScheme = .tinted
4142
settingsViewController = settingsVC
4243
} else if let settingsVC = segue.destination as? IASKAppSettingsViewController{
4344
settingsVC.delegate = self

Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m

+21-4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ @implementation IASKAppSettingsViewController
6666
@synthesize childPaneHandler = _childPaneHandler;
6767
@synthesize currentFirstResponder = _currentFirstResponder;
6868
@synthesize listParentViewController;
69+
@synthesize colorScheme = _colorScheme;
6970

7071
#pragma mark accessors
7172
- (IASKSettingsReader*)settingsReader {
@@ -116,6 +117,18 @@ - (void)setFile:(NSString *)file {
116117
}
117118
}
118119

120+
- (UIColor*)detailTextColor {
121+
if (self.colorScheme == IASKColorSchemeSystem) {
122+
if (@available(iOS 13.0, *)) {
123+
return UIColor.secondaryLabelColor;
124+
} else {
125+
return [UIColor colorWithRed:0.235294 green:0.235294 blue:0.262745 alpha:0.6];
126+
}
127+
} else {
128+
return self.tintColor;
129+
}
130+
}
131+
119132
- (void)createSelections {
120133
NSMutableArray *sectionSelection = [NSMutableArray new];
121134
for (int section = 0; section < self.settingsReader.numberOfSections; section++) {
@@ -649,14 +662,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
649662

650663
BOOL hasTitle = title.length > 0 && !specifier.isItemSpecifier;
651664
cell.detailTextLabel.text = [[specifier titleForCurrentValue:currentValue ?: specifier.defaultValue] description];
652-
cell.detailTextLabel.textColor = self.tintColor;
665+
cell.detailTextLabel.textColor = self.detailTextColor;
653666
if (hasTitle) {
654667
cell.textLabel.text = title;
655668
} else {
656669
cell.textLabel.text = cell.detailTextLabel.text;
657670
cell.detailTextLabel.text = nil;
658671

659-
if (!specifier.parentSpecifier) {
672+
if (!specifier.parentSpecifier && self.colorScheme == IASKColorSchemeTinted) {
660673
cell.textLabel.textColor = self.tintColor;
661674
}
662675
}
@@ -698,7 +711,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
698711
}
699712
cell.userInteractionEnabled = [specifier.type isEqualToString:kIASKDatePickerSpecifier];
700713
if ([specifier.type isEqualToString:kIASKDatePickerSpecifier]) {
701-
cell.detailTextLabel.textColor = [specifier isEqual:self.settingsReader.selectedSpecifier] ? [UILabel appearanceWhenContainedInInstancesOfClasses:@[UITableViewCell.class]].textColor : self.tintColor;
714+
cell.detailTextLabel.textColor = self.detailTextColor;
715+
if ([specifier isEqual:self.settingsReader.selectedSpecifier]) {
716+
cell.detailTextLabel.textColor = [UILabel appearanceWhenContainedInInstancesOfClasses:@[UITableViewCell.class]].textColor;
717+
}
702718
}
703719
}
704720
else if ([specifier.type isEqualToString:kIASKPSTextFieldSpecifier]) {
@@ -766,7 +782,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
766782
cell.textLabel.text = [self.settingsReader titleForId:valueString];
767783
} else {
768784
cell.detailTextLabel.text = [self.settingsReader titleForId:valueString];
769-
cell.detailTextLabel.textColor = self.tintColor;
785+
cell.detailTextLabel.textColor = self.detailTextColor;
770786
}
771787
}
772788
}
@@ -1061,6 +1077,7 @@ - (void)presentChildViewController:(UITableViewController<IASKViewController> *)
10611077
targetViewController.tableView.cellLayoutMarginsFollowReadableWidth = self.cellLayoutMarginsFollowReadableWidth;
10621078
_currentChildViewController = targetViewController;
10631079
targetViewController.settingsStore = self.settingsStore;
1080+
targetViewController.colorScheme = self.colorScheme;
10641081
targetViewController.view.tintColor = self.tintColor;
10651082
if ([specifier.parentSpecifier.type isEqualToString:kIASKListGroupSpecifier]) {
10661083
NSDictionary *itemDict = @{};

Sources/InAppSettingsKit/include/IASKViewController.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,25 @@
1616
@class IASKSettingsReader;
1717
@protocol IASKSettingsStore;
1818

19-
// protocol all IASK view controllers implement
19+
typedef NS_ENUM(NSUInteger, IASKColorScheme) {
20+
/// color scheme replicating the system settings
21+
IASKColorSchemeSystem = 0,
22+
23+
/// color scheme where user-editable options are displayed in tintColor
24+
IASKColorSchemeTinted,
25+
};
26+
27+
/// protocol all IASK view controllers implement
2028
@protocol IASKViewController <NSObject>
2129

2230
@property (nonatomic, strong, nullable) IASKSettingsReader* settingsReader;
2331
@property (nonatomic, strong, nonnull) id<IASKSettingsStore> settingsStore;
2432
@property (nonatomic, copy, nullable) void (^childPaneHandler)(BOOL doneEditing);
2533
@property (nonatomic, weak, nullable) UIViewController<IASKViewController> *listParentViewController;
2634

35+
/// defines the use of tintColor, default is `IASKColorSchemeSystem`.
36+
@property (nonatomic) IASKColorScheme colorScheme;
37+
2738
@optional
2839
@property (nonatomic, weak, nullable) id currentFirstResponder;
2940

0 commit comments

Comments
 (0)