diff --git a/xdrip.xcodeproj/project.pbxproj b/xdrip.xcodeproj/project.pbxproj index c12dfbd3..02280590 100644 --- a/xdrip.xcodeproj/project.pbxproj +++ b/xdrip.xcodeproj/project.pbxproj @@ -252,6 +252,7 @@ F870D3EE2513B786008967B0 /* Trace.swift in Sources */ = {isa = PBXBuildFile; fileRef = F870D3ED2513B786008967B0 /* Trace.swift */; }; F8797CEA255B43960033956B /* GlucoseData+Smoothable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8797CE9255B43960033956B /* GlucoseData+Smoothable.swift */; }; F889CB6F236D84AC00A81068 /* M5StackView.strings in Resources */ = {isa = PBXBuildFile; fileRef = F889CB71236D84AC00A81068 /* M5StackView.strings */; }; + F88EC27025FEB8B900DF0EAF /* DTCustomColoredAccessory.m in Sources */ = {isa = PBXBuildFile; fileRef = F88EC26E25FEB8B800DF0EAF /* DTCustomColoredAccessory.m */; }; F890E07A247687AE008FB2EC /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = F890E079247687AE008FB2EC /* URL.swift */; }; F897AAF92200F2D200CDDD10 /* CBPeripheralState.swift in Sources */ = {isa = PBXBuildFile; fileRef = F897AAF82200F2D200CDDD10 /* CBPeripheralState.swift */; }; F897AAFB2201018800CDDD10 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F897AAFA2201018800CDDD10 /* String.swift */; }; @@ -989,6 +990,8 @@ F88EC12325F6CFB200DF0EAF /* sl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/SettingsViews.strings; sourceTree = ""; }; F88EC12425F6CFC200DF0EAF /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/WatlaaView.strings; sourceTree = ""; }; F88EC12525F6CFC500DF0EAF /* sl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/WatlaaView.strings; sourceTree = ""; }; + F88EC26E25FEB8B800DF0EAF /* DTCustomColoredAccessory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DTCustomColoredAccessory.m; sourceTree = ""; }; + F88EC26F25FEB8B800DF0EAF /* DTCustomColoredAccessory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DTCustomColoredAccessory.h; sourceTree = ""; }; F890E079247687AE008FB2EC /* URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = ""; }; F897AAF82200F2D200CDDD10 /* CBPeripheralState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CBPeripheralState.swift; sourceTree = ""; }; F897AAFA2201018800CDDD10 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; @@ -1823,6 +1826,15 @@ path = Texts; sourceTree = ""; }; + F88EC26D25FEB7F900DF0EAF /* CustomColoredDisclosureIndicator */ = { + isa = PBXGroup; + children = ( + F88EC26F25FEB8B800DF0EAF /* DTCustomColoredAccessory.h */, + F88EC26E25FEB8B800DF0EAF /* DTCustomColoredAccessory.m */, + ); + path = CustomColoredDisclosureIndicator; + sourceTree = ""; + }; F8A2BBFB25D9D36C001D1E78 /* Atom */ = { isa = PBXGroup; children = ( @@ -2364,6 +2376,7 @@ F8EA6C8021B723A80082976B /* Utilities */ = { isa = PBXGroup; children = ( + F88EC26D25FEB7F900DF0EAF /* CustomColoredDisclosureIndicator */, F8AF11F624B1E6D700AE5BA2 /* Errors */, F85FF38F25288860004E6FF1 /* HouseKeeping */, F8F7B8EE259A84A300C47B04 /* KalmanFilter */, @@ -3366,6 +3379,7 @@ F8A389E7232ECE7E0010F405 /* SettingsViewUtilities.swift in Sources */, F8A2BC3125DB0D6D001D1E78 /* BluetoothPeripheralManager+M5StackBluetoothTransmitterDelegate.swift in Sources */, F8A2BC2D25DB0D6D001D1E78 /* BluetoothPeripheralManager+CGMG5TransmitterDelegate.swift in Sources */, + F88EC27025FEB8B900DF0EAF /* DTCustomColoredAccessory.m in Sources */, F8B3A7DF226E48C1004BA588 /* SoundPlayer.swift in Sources */, F816E12C2439DFBA009EE65B /* DexcomG4+CoreDataProperties.swift in Sources */, F8A2BC3425DB0D6D001D1E78 /* BluetoothPeripheralManager+WatlaaBluetoothTransmitterDelegate.swift in Sources */, diff --git a/xdrip/Constants/ConstantsUI.swift b/xdrip/Constants/ConstantsUI.swift index 6dfceefc..b9250f16 100644 --- a/xdrip/Constants/ConstantsUI.swift +++ b/xdrip/Constants/ConstantsUI.swift @@ -9,4 +9,7 @@ enum ConstantsUI { /// color to use as background when a row is selected static let tableRowSelectedBackGroundColor = UIColor.systemBlue + /// color to use for disclosure indicator in settings views + static let disclosureIndicatorColor = UIColor.systemBlue + } diff --git a/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.h b/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.h new file mode 100644 index 00000000..74dfb297 --- /dev/null +++ b/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.h @@ -0,0 +1,110 @@ +// +// DTCustomColoredAccessory.h +// DTFoundation +// +// Created by Oliver Drobnik on 2/10/12. +// Copyright (c) 2012 Cocoanetics. All rights reserved. +// +//https://github.com/Cocoanetics/DTFoundation + +#import +#import + +#if TARGET_OS_IPHONE && !TARGET_OS_WATCH + +#import + +/** + Constant used by DTCustomColoredAccessory to specify the type of accessory. + */ +typedef NS_ENUM(NSUInteger, DTCustomColoredAccessoryType) +{ + /** + An accessoring pointing to the right side + */ + DTCustomColoredAccessoryTypeRight = 0, + + /** + An accessoring pointing to the left side + */ + DTCustomColoredAccessoryTypeLeft, + + /** + An accessoring pointing upwards + */ + DTCustomColoredAccessoryTypeUp, + + /** + An accessoring pointing downwards + */ + DTCustomColoredAccessoryTypeDown, + + /** + A front square drawn on top of a back square with the back square offset up and to the right + */ + DTCustomColoredAccessoryTypeSquare + +}; + +/** + An accessory control that can be used instead of the standard disclosure indicator in a `UITableView`. See the DTCustomColoredAccessoryType for supported styles. + */ + +@interface DTCustomColoredAccessory : UIControl + +/**------------------------------------------------------------------------------------- + @name Creating A Custom-Colored Accessory + --------------------------------------------------------------------------------------- + */ + +/** + Creates a custom-colored right disclosure indicator accessory with a given color + @param color The color to use + */ ++ (DTCustomColoredAccessory *)accessoryWithColor:(UIColor *)color; + +/** + Creates a custom-colored accessory with a given color and type + @param color The color to use + @param type The DTCustomColoredAccessoryType to use + */ ++ (DTCustomColoredAccessory *)accessoryWithColor:(UIColor *)color type:(DTCustomColoredAccessoryType)type; + +/** + Creates a custom-colored square on top of a square with offset + @param color The color to use + @param backgroundColor The backgroundColor to use + */ ++ (DTCustomColoredAccessory *)squareAccessoryWithColor:(UIColor *)color backgroundColor:(UIColor *)backgroundColor; + +/**------------------------------------------------------------------------------------- + @name Properties + --------------------------------------------------------------------------------------- + */ + +/** + The color to draw the accessory in + */ +@property (nonatomic, retain) UIColor *accessoryColor; + +/** + The color to draw the accessory in while highlighted + */ +@property (nonatomic, retain) UIColor *highlightedColor; +/** + The color to draw the front square of the square accessory in while not highlighted + */ +@property (nonatomic, retain) UIColor *frontSquareAccessoryColor; +/** + The color to draw the back square of the square accessory in while not highlighted + */ +@property (nonatomic, retain) UIColor *backSquareAccessoryColor; + +/** + The DTCustomColoredAccessoryType of the accessory. + */ +@property (nonatomic, assign) DTCustomColoredAccessoryType type; + +@end + +#endif diff --git a/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.m b/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.m new file mode 100644 index 00000000..05456e2a --- /dev/null +++ b/xdrip/Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.m @@ -0,0 +1,243 @@ +// +// DTCustomColoredAccessory.m +// DTFoundation +// +// Created by Oliver Drobnik on 2/10/12. +// Copyright (c) 2012 Cocoanetics. All rights reserved. +// +//https://github.com/Cocoanetics/DTFoundation + +#import "DTCustomColoredAccessory.h" + +#if TARGET_OS_IPHONE && !TARGET_OS_WATCH + +#import + +@implementation DTCustomColoredAccessory +{ + UIColor *_accessoryColor; + UIColor *_highlightedColor; + + DTCustomColoredAccessoryType _type; +} + +#pragma mark - Creating A Custom-Colored Accessory + ++ (DTCustomColoredAccessory *)accessoryWithColor:(UIColor *)color +{ + return [self accessoryWithColor:color type:DTCustomColoredAccessoryTypeRight]; +} + ++ (DTCustomColoredAccessory *)accessoryWithColor:(UIColor *)color type:(DTCustomColoredAccessoryType)type +{ + DTCustomColoredAccessory *ret = [[DTCustomColoredAccessory alloc] initWithFrame:CGRectMake(0, 0, 15.0, 15.0)]; + ret.accessoryColor = color; + ret.frontSquareAccessoryColor = color; + ret.type = type; + ret.backSquareAccessoryColor = color == [UIColor blackColor] ? [UIColor whiteColor] : [UIColor blackColor]; + + return ret; +} + ++ (DTCustomColoredAccessory *)squareAccessoryWithColor:(UIColor *)color backgroundColor:(UIColor *)backgroundColor +{ + DTCustomColoredAccessory *ret = [[DTCustomColoredAccessory alloc] initWithFrame:CGRectMake(0, 0, 15.0, 15.0)]; + ret.accessoryColor = color; + ret.frontSquareAccessoryColor = color; + ret.type = DTCustomColoredAccessoryTypeSquare; + ret.backSquareAccessoryColor = backgroundColor; + + return ret; +} + +#pragma mark - Internal Methods + +- (id)initWithFrame:(CGRect)frame +{ + if ((self = [super initWithFrame:frame])) + { + self.backgroundColor = [UIColor clearColor]; + } + return self; +} + +- (void)drawRect:(CGRect)rect +{ + CGContextRef ctxt = UIGraphicsGetCurrentContext(); + + const CGFloat R = 4.5; + + BOOL doFinal = true; + + switch (_type) + { + case DTCustomColoredAccessoryTypeRight: + { + // (x,y) is the tip of the arrow + CGFloat x = CGRectGetMaxX(self.bounds)-3.0;; + CGFloat y = CGRectGetMidY(self.bounds); + + CGContextMoveToPoint(ctxt, x-R, y-R); + CGContextAddLineToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x-R, y+R); + + break; + } + + case DTCustomColoredAccessoryTypeLeft: + { + // (x,y) is the tip of the arrow + CGFloat x = CGRectGetMaxX(self.bounds)-10.0;; + CGFloat y = CGRectGetMidY(self.bounds); + + CGContextMoveToPoint(ctxt, x+R, y+R); + CGContextAddLineToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x+R, y-R); + break; + } + + case DTCustomColoredAccessoryTypeUp: + { + // (x,y) is the tip of the arrow + CGFloat x = CGRectGetMaxX(self.bounds)-7.0;; + CGFloat y = CGRectGetMinY(self.bounds)+5.0; + + CGContextMoveToPoint(ctxt, x-R, y+R); + CGContextAddLineToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x+R, y+R); + + break; + } + + case DTCustomColoredAccessoryTypeDown: + { + // (x,y) is the tip of the arrow + CGFloat x = CGRectGetMaxX(self.bounds)-7.0;; + CGFloat y = CGRectGetMaxY(self.bounds)-5.0; + + CGContextMoveToPoint(ctxt, x-R, y-R); + CGContextAddLineToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x+R, y-R); + + break; + } + + case DTCustomColoredAccessoryTypeSquare: + { + doFinal = false; + + // (x,y) is the tip of the arrow + CGFloat x = CGRectGetMinX(self.bounds)+5.0; + CGFloat y = CGRectGetMinY(self.bounds)+1.0; + + CGFloat s = 9.0; + + CGContextMoveToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x+s, y); + CGContextAddLineToPoint(ctxt, x+s, y+s); + CGContextAddLineToPoint(ctxt, x, y+s); + CGContextClosePath(ctxt); + + CGContextSetLineCap(ctxt, kCGLineCapSquare); + CGContextSetLineJoin(ctxt, kCGLineJoinMiter); + CGContextSetLineWidth(ctxt, 3); + + if (self.highlighted) + { + [self.highlightedColor setStroke]; + } + else + { + _accessoryColor = self.backSquareAccessoryColor; + [self.accessoryColor setStroke]; + } + + CGContextStrokePath(ctxt); + + x = CGRectGetMinX(self.bounds)+3.0; + y = CGRectGetMinY(self.bounds)+3.0; + + CGContextMoveToPoint(ctxt, x, y); + CGContextAddLineToPoint(ctxt, x+s, y); + CGContextAddLineToPoint(ctxt, x+s, y+s); + CGContextAddLineToPoint(ctxt, x, y+s); + CGContextClosePath(ctxt); + + CGContextSetLineCap(ctxt, kCGLineCapSquare); + CGContextSetLineJoin(ctxt, kCGLineJoinMiter); + CGContextSetLineWidth(ctxt, 3); + + if (self.highlighted) + { + [self.highlightedColor setStroke]; + } + else + { + _accessoryColor = self.frontSquareAccessoryColor; + [self.accessoryColor setStroke]; + } + + CGContextStrokePath(ctxt); + + break; + } + + default: + break; + } + + if (doFinal) + { + CGContextSetLineCap(ctxt, kCGLineCapSquare); + CGContextSetLineJoin(ctxt, kCGLineJoinMiter); + CGContextSetLineWidth(ctxt, 3); + + if (self.highlighted) + { + [self.highlightedColor setStroke]; + } + else + { + [self.accessoryColor setStroke]; + } + + CGContextStrokePath(ctxt); + } +} + +#pragma mark - Properties + +- (void)setHighlighted:(BOOL)highlighted +{ + [super setHighlighted:highlighted]; + + [self setNeedsDisplay]; +} + +- (UIColor *)accessoryColor +{ + if (!_accessoryColor) + { + return [UIColor blackColor]; + } + + return _accessoryColor; +} + +- (UIColor *)highlightedColor +{ + if (!_highlightedColor) + { + return [UIColor whiteColor]; + } + + return _highlightedColor; +} + +@synthesize accessoryColor = _accessoryColor; +@synthesize highlightedColor = _highlightedColor; +@synthesize type = _type; + +@end + +#endif diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/BluetoothPeripheralViewController.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/BluetoothPeripheralViewController.swift index a62a2c49..5f7746b3 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/BluetoothPeripheralViewController.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/BluetoothPeripheralViewController.swift @@ -831,7 +831,11 @@ extension BluetoothPeripheralViewController: UITableViewDataSource, UITableViewD // default value for accessoryView is nil cell.accessoryView = nil - + + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + //it's a Setting defined here in BluetoothPeripheralViewController // is it a bluetooth setting or web oop setting ? @@ -858,6 +862,7 @@ extension BluetoothPeripheralViewController: UITableViewDataSource, UITableViewD cell.accessoryType = .none } else { cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } case .connectionStatus: @@ -874,6 +879,7 @@ extension BluetoothPeripheralViewController: UITableViewDataSource, UITableViewD cell.accessoryType = .none } else { cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } case .transmitterId: @@ -883,6 +889,9 @@ extension BluetoothPeripheralViewController: UITableViewDataSource, UITableViewD // if transmitterId already has a value, then it can't be changed anymore. To change it, user must delete the transmitter and recreate one. cell.accessoryType = transmitterIdTempValue == nil ? .disclosureIndicator : .none + if (transmitterIdTempValue == nil) { + cell.accessoryView = disclosureAaccessoryView + } case .connectOrDisconnectTimeStamp: diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Atom/AtomBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Atom/AtomBluetoothPeripheralViewModel.swift index 02c5e661..6016bb70 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Atom/AtomBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Atom/AtomBluetoothPeripheralViewModel.swift @@ -119,6 +119,10 @@ extension AtomBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("AtomBluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -161,18 +165,21 @@ extension AtomBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_Common.firmware cell.detailTextLabel?.text = atom.firmware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .hardWare: cell.textLabel?.text = Texts_Common.hardware cell.detailTextLabel?.text = atom.hardware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .sensorSerialNumber: cell.textLabel?.text = Texts_BluetoothPeripheralView.sensorSerialNumber cell.detailTextLabel?.text = atom.blePeripheral.sensorSerialNumber cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Blucon/BluconBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Blucon/BluconBluetoothPeripheralViewModel.swift index 75d113ef..3a3f87d6 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Blucon/BluconBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Blucon/BluconBluetoothPeripheralViewModel.swift @@ -107,6 +107,10 @@ extension BluconBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("BluconBluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -126,6 +130,7 @@ extension BluconBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_BluetoothPeripheralView.sensorSerialNumber cell.detailTextLabel?.text = blucon.blePeripheral.sensorSerialNumber cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Bubble/BubbleBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Bubble/BubbleBluetoothPeripheralViewModel.swift index 5794fa18..8a5842bb 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Bubble/BubbleBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Bubble/BubbleBluetoothPeripheralViewModel.swift @@ -118,7 +118,11 @@ extension BubbleBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil - + + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("BubbleBluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -138,12 +142,14 @@ extension BubbleBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_Common.firmware cell.detailTextLabel?.text = bubble.firmware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .hardWare: cell.textLabel?.text = Texts_Common.hardware cell.detailTextLabel?.text = bubble.hardware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .sensorSerialNumber: @@ -152,7 +158,8 @@ extension BubbleBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.detailTextLabel?.text = sensorSerialNumber cell.accessoryType = .disclosureIndicator - + cell.accessoryView = disclosureAaccessoryView + } else { cell.detailTextLabel?.text = Texts_Common.unknown diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/GNSENtry/GNSEntryBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/GNSENtry/GNSEntryBluetoothPeripheralViewModel.swift index 9a21bad5..c91e3535 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/GNSENtry/GNSEntryBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/GNSENtry/GNSEntryBluetoothPeripheralViewModel.swift @@ -110,6 +110,10 @@ extension GNSEntryBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("GNSEntryBluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -124,13 +128,15 @@ extension GNSEntryBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_Common.firmware cell.detailTextLabel?.text = gNSEntry.firmwareVersion cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .serialNumber: cell.textLabel?.text = Texts_BluetoothPeripheralView.serialNumber cell.detailTextLabel?.text = gNSEntry.serialNumber cell.accessoryType = .disclosureIndicator - + cell.accessoryView = disclosureAaccessoryView + } } diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Libre2/Libre2BluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Libre2/Libre2BluetoothPeripheralViewModel.swift index 4ad51b06..87ef4c52 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Libre2/Libre2BluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/Libre2/Libre2BluetoothPeripheralViewModel.swift @@ -111,6 +111,10 @@ extension Libre2BluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("Libre2BluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -120,6 +124,7 @@ extension Libre2BluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_BluetoothPeripheralView.sensorSerialNumber cell.detailTextLabel?.text = libre2.blePeripheral.sensorSerialNumber cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .sensorStartTime: diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/MiaoMiao/MiaoMiaoBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/MiaoMiao/MiaoMiaoBluetoothPeripheralViewModel.swift index 7ea6cecf..8edb29da 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/MiaoMiao/MiaoMiaoBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/CGM/Libre/MiaoMiao/MiaoMiaoBluetoothPeripheralViewModel.swift @@ -119,6 +119,10 @@ extension MiaoMiaoBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + guard let setting = Settings(rawValue: rawValue) else { fatalError("MiaoMiaoBluetoothPeripheralViewModel update, unexpected setting") } switch setting { @@ -161,18 +165,21 @@ extension MiaoMiaoBluetoothPeripheralViewModel: BluetoothPeripheralViewModel { cell.textLabel?.text = Texts_Common.firmware cell.detailTextLabel?.text = miaoMiao.firmware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .hardWare: cell.textLabel?.text = Texts_Common.hardware cell.detailTextLabel?.text = miaoMiao.hardware cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .sensorSerialNumber: cell.textLabel?.text = Texts_BluetoothPeripheralView.sensorSerialNumber cell.detailTextLabel?.text = miaoMiao.blePeripheral.sensorSerialNumber cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/M5Stack/M5StackBluetoothPeripheralViewModel.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/M5Stack/M5StackBluetoothPeripheralViewModel.swift index e1388ae7..de5c938e 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/M5Stack/M5StackBluetoothPeripheralViewModel.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralViewController/Models/M5Stack/M5StackBluetoothPeripheralViewModel.swift @@ -312,7 +312,11 @@ class M5StackBluetoothPeripheralViewModel { // default value for accessoryView is nil cell.accessoryView = nil - + + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + switch section { case 1: // this is the section with settings common to M5Stack and M5StickC @@ -349,6 +353,7 @@ class M5StackBluetoothPeripheralViewModel { cell.textLabel?.text = Texts_M5StackView.m5StackSoftWhereHelpCellText cell.detailTextLabel?.text = nil cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .blePassword: cell.textLabel?.text = Texts_Common.password @@ -369,6 +374,7 @@ class M5StackBluetoothPeripheralViewModel { } cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .backGroundColor: cell.textLabel?.text = Texts_SettingsView.m5StackbackGroundColor @@ -380,11 +386,13 @@ class M5StackBluetoothPeripheralViewModel { } cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .rotation: cell.textLabel?.text = Texts_SettingsView.m5StackRotation cell.detailTextLabel?.text = rotationStrings[Int(m5Stack.rotation)] cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView } @@ -402,6 +410,7 @@ class M5StackBluetoothPeripheralViewModel { cell.textLabel?.text = Texts_SettingsView.m5StackBrightness cell.detailTextLabel?.text = brightnessStrings[Int(m5Stack.brightness/10)] cell.accessoryType = .disclosureIndicator + cell.accessoryView = disclosureAaccessoryView case .batteryLevel: cell.textLabel?.text = Texts_BluetoothPeripheralsView.batteryLevel @@ -416,7 +425,8 @@ class M5StackBluetoothPeripheralViewModel { cell.textLabel?.text = Texts_M5StackView.powerOff cell.accessoryType = .disclosureIndicator cell.detailTextLabel?.text = nil - + cell.accessoryView = disclosureAaccessoryView + } default: diff --git a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralsViewController.swift b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralsViewController.swift index 2385b9dc..ef1505ec 100644 --- a/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralsViewController.swift +++ b/xdrip/View Controllers/BluetoothPeripheralsNavigationController/BluetoothPeripheralsViewController/BluetoothPeripheralsViewController.swift @@ -327,9 +327,10 @@ extension BluetoothPeripheralsViewController: UITableViewDataSource, UITableView // detail is the connection status cell.detailTextLabel?.text = BluetoothPeripheralViewController.setConnectButtonLabelTextAndGetStatusDetailedText(bluetoothPeripheral: bluetoothPeripheral, isScanning: false, connectButtonOutlet: nil, expectedBluetoothPeripheralType: bluetoothPeripheral.bluetoothPeripheralType(), transmitterId: nil, bluetoothPeripheralManager: bluetoothPeripheralManager as! BluetoothPeripheralManager) - // clicking the cell will always open a new screen which allows the user to edit the alert type - cell.accessoryType = .disclosureIndicator - + // clicking the cell will always open a new screen which allows the user to edit the alert type - add disclosureIndicator + // set color of disclosureIndicator to ConstantsUI.disclosureIndicatorColor + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + return cell } diff --git a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertTypesSettingsViewController/AlertTypeSettingsViewController/AlertTypeSettingsViewController.swift b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertTypesSettingsViewController/AlertTypeSettingsViewController/AlertTypeSettingsViewController.swift index c1b99e78..da9063d2 100644 --- a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertTypesSettingsViewController/AlertTypeSettingsViewController/AlertTypeSettingsViewController.swift +++ b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertTypesSettingsViewController/AlertTypeSettingsViewController/AlertTypeSettingsViewController.swift @@ -222,6 +222,10 @@ extension AlertTypeSettingsViewController: UITableViewDataSource, UITableViewDel // default value for accessoryView is nil cell.accessoryView = nil + // create disclosureIndicator in color ConstantsUI.disclosureIndicatorColor + // will be used whenever accessoryType is to be set to disclosureIndicator + let disclosureAaccessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + // configure the cell depending on setting switch setting { @@ -229,6 +233,8 @@ extension AlertTypeSettingsViewController: UITableViewDataSource, UITableViewDel cell.textLabel?.text = Texts_AlertTypeSettingsView.alertTypeName cell.detailTextLabel?.text = name cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + cell.accessoryView = disclosureAaccessoryView + case .enabled: cell.textLabel?.text = Texts_AlertTypeSettingsView.alertTypeEnabled cell.detailTextLabel?.text = nil @@ -260,10 +266,14 @@ extension AlertTypeSettingsViewController: UITableViewDataSource, UITableViewDel cell.textLabel?.text = Texts_AlertTypeSettingsView.alertTypeDefaultSnoozePeriod cell.detailTextLabel?.text = snoozePeriod.description cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + cell.accessoryView = disclosureAaccessoryView + case .soundName: cell.textLabel?.text = Texts_AlertTypeSettingsView.alertTypeSound cell.detailTextLabel?.text = soundName != nil ? soundName! == "" ? Texts_AlertTypeSettingsView.alertTypeNoSound : soundName! : Texts_AlertTypeSettingsView.alertTypeDefaultIOSSound cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + cell.accessoryView = disclosureAaccessoryView + case .overridemute: cell.textLabel?.text = Texts_AlertTypeSettingsView.alertTypeOverrideMute cell.detailTextLabel?.text = nil diff --git a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertSettingsViewController/AlertSettingsViewControllerData.swift b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertSettingsViewController/AlertSettingsViewControllerData.swift index 2c7bbc55..2162ed91 100644 --- a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertSettingsViewController/AlertSettingsViewControllerData.swift +++ b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertSettingsViewController/AlertSettingsViewControllerData.swift @@ -152,6 +152,8 @@ extension AlertSettingsViewControllerData { cell.accessoryType = UITableViewCell.AccessoryType.none } else { cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + // set color of disclosureIndicator to ConstantsUI.disclosureIndicatorColor + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) } case .value: // note that value will not be shown if alerttype not enabled or alertkind doesn't need a value, means if that's the case, setting will never be .value @@ -162,10 +164,15 @@ extension AlertSettingsViewControllerData { cell.detailTextLabel?.text = value.description } cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + // set color of disclosureIndicator to ConstantsUI.disclosureIndicatorColor + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + case .alertType: cell.textLabel?.text = Texts_Alerts.alerttype cell.detailTextLabel?.text = AlertSettingsViewControllerData.getAlertType(alertType: alertType).name cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator + // set color of disclosureIndicator to ConstantsUI.disclosureIndicatorColor + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) } return cell diff --git a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertsSettingsViewController.swift b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertsSettingsViewController.swift index a3a3f224..1a97de6d 100644 --- a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertsSettingsViewController.swift +++ b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/AlertsSettingsViewController/AlertsSettingsViewController.swift @@ -192,6 +192,9 @@ extension AlertsSettingsViewController:UITableViewDataSource, UITableViewDelegat // clicking the cell will always open a new screen which allows the user to edit the alert type cell.accessoryType = .disclosureIndicator + // set color of disclosureIndicator to ConstantsUI.disclosureIndicatorColor + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) + return cell } diff --git a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/SettingsViewUtilities.swift b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/SettingsViewUtilities.swift index 7bfa6181..d47afbef 100644 --- a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/SettingsViewUtilities.swift +++ b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/SettingsViewUtilities.swift @@ -14,24 +14,21 @@ class SettingsViewUtilities { // first the two textfields cell.textLabel?.text = viewModel.settingsRowText(index: rowIndex) cell.detailTextLabel?.text = viewModel.detailedText(index: rowIndex) - + // if not enabled, then no need to adding anything else if viewModel.isEnabled(index: rowIndex) { - + + // get accessoryView + cell.accessoryView = viewModel.uiView(index: rowIndex) + // setting enabled, get accessory type and accessory view cell.accessoryType = viewModel.accessoryType(index: rowIndex) - switch cell.accessoryType { - case .checkmark, .detailButton, .detailDisclosureButton, .disclosureIndicator: - cell.selectionStyle = .gray - case .none: - cell.selectionStyle = .none - @unknown default: - cell.selectionStyle = .none + //if accessoryType = disclosure indicator then use custom disclosureIndicator in ConstantsUI.disclosureIndicatorColor + if cell.accessoryType == .disclosureIndicator { + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) } - cell.accessoryView = viewModel.uiView(index: rowIndex) - // if uiview is an uiswitch then a reload must be initiated whenever the switch changes, either complete view or just the section if let view = cell.accessoryView as? UISwitch { view.addTarget(self, action: { diff --git a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/TimeScheduleViewController.swift b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/TimeScheduleViewController.swift index 67da035c..08ea7cbc 100644 --- a/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/TimeScheduleViewController.swift +++ b/xdrip/View Controllers/SettingsNavigationController/SettingsViewController/TimeScheduleViewController.swift @@ -186,6 +186,7 @@ extension TimeScheduleViewController: UITableViewDataSource { cell.accessoryType = .none } else { cell.accessoryType = .disclosureIndicator + cell.accessoryView = DTCustomColoredAccessory(color: ConstantsUI.disclosureIndicatorColor) } return cell diff --git a/xdrip/xdrip-Bridging-Header.h b/xdrip/xdrip-Bridging-Header.h index da6fa16d..a6491dac 100644 --- a/xdrip/xdrip-Bridging-Header.h +++ b/xdrip/xdrip-Bridging-Header.h @@ -1,3 +1,3 @@ #import "BluetoothTransmitter/CGM/Dexcom/G5/G5Messages/AESCrypt.h" - +#import "Utilities/CustomColoredDisclosureIndicator/DTCustomColoredAccessory.h"