@@ -31,9 +31,9 @@ - (void)viewDidLoad {
3131 }
3232
3333 if (@available (iOS 13.0 , *)) {
34- self.view .backgroundColor = UIColor.systemBackgroundColor ;
34+ self.view .backgroundColor = UIColor.systemGroupedBackgroundColor ;
3535 } else {
36- self.view .backgroundColor = UIColor. whiteColor ;
36+ self.view .backgroundColor = [ UIColor colorWithRed: 242 / 255.0 green: 242 / 255.0 blue: 247 / 255.0 alpha: 1.0 ] ;
3737 }
3838
3939 self.colorsArr = @[
@@ -59,11 +59,17 @@ - (void)setUpMainTableView {
5959 tableView.delegate = self;
6060 tableView.dataSource = self;
6161 if (@available (iOS 13.0 , *)) {
62- tableView.backgroundColor = UIColor.systemBackgroundColor ;
62+ tableView.backgroundColor = UIColor.systemGroupedBackgroundColor ;
6363 } else {
64- tableView.backgroundColor = UIColor.whiteColor ;
64+ tableView.backgroundColor = [UIColor colorWithRed: 242 /255.0 green: 242 /255.0 blue: 247 /255.0 alpha: 1.0 ];
65+ }
66+ tableView.sectionHeaderHeight = 56 ;
67+ tableView.estimatedRowHeight = 92 ;
68+ tableView.rowHeight = UITableViewAutomaticDimension;
69+ tableView.separatorInset = UIEdgeInsetsMake (0 , 48 , 0 , 0 );
70+ if (@available (iOS 13.0 , *)) {
71+ tableView.separatorColor = UIColor.separatorColor ;
6572 }
66- tableView.sectionHeaderHeight = 45 ;
6773 tableView.sectionIndexColor = UIColor.redColor ;
6874 [tableView registerNib: [UINib nibWithNibName: kCustomTableViewCell bundle: NSBundle .mainBundle] forCellReuseIdentifier: kCustomTableViewCell ];
6975 [self .view addSubview: tableView];
@@ -125,58 +131,96 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
125131#pragma mark - UITableViewDelegate
126132
127133- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
128- UIView *sectionHeaderView = [[UIView alloc ] init ];
129- UIColor *bgColor = [self kColorWithHexString: self .colorsArr[section % 18 ]];
130- sectionHeaderView.backgroundColor = bgColor;
131-
132- UILabel *sectionTitleLabel = [[UILabel alloc ] initWithFrame: sectionHeaderView.bounds];
133- sectionTitleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
134- sectionTitleLabel.text = self.sectionTitleArr [section];
135- sectionTitleLabel.textColor = UIColor.whiteColor ;
136- sectionTitleLabel.font = [UIFont boldSystemFontOfSize: 17 ];
137- sectionTitleLabel.textAlignment = NSTextAlignmentCenter;
138- [sectionHeaderView addSubview: sectionTitleLabel];
139-
140- return sectionHeaderView;
134+ UIColor *baseColor = [self kColorWithHexString: self .colorsArr[section % 18 ]];
135+ CGFloat tableW = tableView.bounds .size .width ;
136+
137+ // Transparent container
138+ UIView *container = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , tableW, 56 )];
139+ container.backgroundColor = UIColor.clearColor ;
140+
141+ // Floating card
142+ CGFloat margin = 12 ;
143+ UIView *card = [[UIView alloc ] initWithFrame: CGRectMake (margin, 4 , tableW - margin * 2 , 48 )];
144+ card.layer .cornerRadius = 12 ;
145+ card.clipsToBounds = NO ;
146+
147+ // Diagonal gradient
148+ CAGradientLayer *gradient = [CAGradientLayer layer ];
149+ gradient.frame = card.bounds ;
150+ gradient.cornerRadius = 12 ;
151+ gradient.startPoint = CGPointMake (0 , 0 );
152+ gradient.endPoint = CGPointMake (1 , 1 );
153+ UIColor *lighterColor = [self aa_lightenColor: baseColor byAmount: 0.12 ];
154+ gradient.colors = @[(id )baseColor.CGColor, (id )lighterColor.CGColor];
155+ [card.layer insertSublayer: gradient atIndex: 0 ];
156+
157+ // Colored shadow
158+ card.layer .shadowColor = baseColor.CGColor ;
159+ card.layer .shadowOffset = CGSizeMake (0 , 3 );
160+ card.layer .shadowRadius = 6 ;
161+ card.layer .shadowOpacity = 0.35 ;
162+
163+ // Decorative translucent circles
164+ CGFloat cardW = card.bounds .size .width ;
165+ CGFloat cardH = card.bounds .size .height ;
166+
167+ CAShapeLayer *circle1 = [CAShapeLayer layer ];
168+ circle1.path = [UIBezierPath bezierPathWithOvalInRect: CGRectMake (cardW - 60 , -10 , 50 , 50 )].CGPath ;
169+ circle1.fillColor = [UIColor colorWithWhite: 1.0 alpha: 0.08 ].CGColor ;
170+ [card.layer addSublayer: circle1];
171+
172+ CAShapeLayer *circle2 = [CAShapeLayer layer ];
173+ circle2.path = [UIBezierPath bezierPathWithOvalInRect: CGRectMake (cardW - 35 , cardH - 30 , 40 , 40 )].CGPath ;
174+ circle2.fillColor = [UIColor colorWithWhite: 1.0 alpha: 0.06 ].CGColor ;
175+ [card.layer addSublayer: circle2];
176+
177+ // Section number badge
178+ UILabel *badge = [[UILabel alloc ] initWithFrame: CGRectMake (14 , (cardH - 24 ) / 2 , 24 , 24 )];
179+ badge.backgroundColor = [UIColor colorWithWhite: 1.0 alpha: 0.25 ];
180+ badge.layer .cornerRadius = 12 ;
181+ badge.layer .masksToBounds = YES ;
182+ badge.text = [NSString stringWithFormat: @" %ld " , (long )(section + 1 )];
183+ badge.textColor = UIColor.whiteColor ;
184+ badge.font = [UIFont monospacedDigitSystemFontOfSize: 11 weight: UIFontWeightBold];
185+ badge.textAlignment = NSTextAlignmentCenter;
186+ [card addSubview: badge];
187+
188+ // Title label
189+ UILabel *titleLabel = [[UILabel alloc ] initWithFrame: CGRectMake (46 , 0 , cardW - 70 , cardH)];
190+ titleLabel.text = self.sectionTitleArr [section];
191+ titleLabel.textColor = UIColor.whiteColor ;
192+ titleLabel.font = [UIFont systemFontOfSize: 15 weight: UIFontWeightBold];
193+ titleLabel.numberOfLines = 1 ;
194+ [card addSubview: titleLabel];
195+
196+ [container addSubview: card];
197+ return container;
141198}
142199
143200- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
144201 CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: kCustomTableViewCell ];
145202 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
146203
147- if (@available (iOS 13.0 , *)) {
148- if (indexPath.row % 2 == 0 ) {
149- cell.backgroundColor = UIColor.systemBackgroundColor ;
150- } else {
151- cell.backgroundColor = UIColor.secondarySystemBackgroundColor ;
152- }
153- } else {
154- if (indexPath.row % 2 == 0 ) {
155- cell.backgroundColor = UIColor.whiteColor ;
156- } else {
157- cell.backgroundColor = [self kRGBColorFromHex: 0xE6E6FA ];
158- }
159- }
204+ UIColor *themeColor = [self kColorWithHexString: self .colorsArr[indexPath.section % 18 ]];
205+ cell.sectionColor = themeColor;
206+ cell.numberLabel .text = [NSString stringWithFormat: @" %ld " , (long )(indexPath.row + 1 )];
160207
161208 NSString *cellTitle = self.chartTypeTitleArr [indexPath.section][indexPath.row];
162209 NSArray <NSString *> *titleParts = [cellTitle componentsSeparatedByString: @" ---" ];
163210 cell.titleLabel .text = titleParts.firstObject ;
164211 cell.subtitleLabel .text = titleParts.count > 1 ? titleParts[1 ] : @" " ;
212+
165213 if (@available (iOS 13.0 , *)) {
166- cell.titleLabel . textColor = UIColor.labelColor ;
214+ cell.backgroundColor = UIColor.secondarySystemGroupedBackgroundColor ;
167215 } else {
168- cell.titleLabel . textColor = UIColor.blackColor ;
216+ cell.backgroundColor = UIColor.whiteColor ;
169217 }
170- cell.numberLabel .text = [NSString stringWithFormat: @" %ld " , (long )(indexPath.row + 1 )];
171-
172- UIColor *bgColor = [self kColorWithHexString: self .colorsArr[indexPath.section % 18 ]];
173- cell.numberLabel .backgroundColor = bgColor;
174218
175219 return cell;
176220}
177221
178222- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
179- // Implement selection logic here
223+ [tableView deselectRowAtIndexPath: indexPath animated: YES ];
180224}
181225
182226#pragma mark - Dark Mode Support
@@ -192,11 +236,22 @@ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
192236
193237- (void )aa_updateDynamicColors {
194238 if (@available (iOS 13.0 , *)) {
195- self.view .backgroundColor = UIColor.systemBackgroundColor ;
196- self.mainTableView .backgroundColor = UIColor.systemBackgroundColor ;
239+ self.view .backgroundColor = UIColor.systemGroupedBackgroundColor ;
240+ self.mainTableView .backgroundColor = UIColor.systemGroupedBackgroundColor ;
197241 [self .mainTableView reloadData ];
198242 }
199243}
200244
245+ #pragma mark - Color Helpers
246+
247+ - (UIColor *)aa_lightenColor : (UIColor *)color byAmount : (CGFloat)amount {
248+ CGFloat r, g, b, a;
249+ [color getRed: &r green: &g blue: &b alpha: &a];
250+ return [UIColor colorWithRed: MIN (r + amount, 1.0 )
251+ green: MIN (g + amount, 1.0 )
252+ blue: MIN (b + amount, 1.0 )
253+ alpha: a];
254+ }
255+
201256@end
202257
0 commit comments