Skip to content

Commit

Permalink
Merge pull request #69 from NatLibFi/ekirjasto-104-add-accessibility-…
Browse files Browse the repository at this point in the history
…headings

Ekirjasto 104 add accessibility headings
  • Loading branch information
natlibfi-kaisa authored Nov 12, 2024
2 parents 5b94ac2 + 2f36b75 commit be8a698
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Palace/Catalog/TPPCatalogGroupedFeedViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,26 +274,32 @@ - (NSInteger)numberOfSectionsInTableView:(__attribute__((unused)) UITableView *)

#pragma mark UITableViewDelegate

// Sets the row height in the table view
- (CGFloat)tableView:(__attribute__((unused)) UITableView *)tableView
heightForRowAtIndexPath:(__attribute__((unused)) NSIndexPath *)indexPath
{
return kRowHeight;
}

// Sets the section header height in the table view
- (CGFloat)tableView:(__attribute__((unused)) UITableView *)tableView
heightForHeaderInSection:(__attribute__((unused)) NSInteger)section
{
return kSectionHeaderHeight;
}

// Sets sections header properties.
- (UIView *)tableView:(__attribute__((unused)) UITableView *)tableView
viewForHeaderInSection:(NSInteger const)section

// Creates a section header view in a table view, with a fixed height and a width that spans the entire width of the table view.
{
CGRect const frame = CGRectMake(0, 0, CGRectGetWidth(self.tableView.frame), kSectionHeaderHeight);
UIView *const view = [[UIView alloc] initWithFrame:frame];
view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
view.backgroundColor = [[TPPConfiguration backgroundColor] colorWithAlphaComponent:0.9];

// Creates a header button that displays the title of a category and allows the user to tap on it to view more books in that category.
{
UIButton *const button = [UIButton buttonWithType:UIButtonTypeSystem];
button.titleLabel.font = [UIFont palaceFontOfSize:21];
Expand All @@ -307,13 +313,18 @@ - (UIView *)tableView:(__attribute__((unused)) UITableView *)tableView
}
button.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
button.tag = section;
TPPCatalogLane *const lane = self.feed.lanes[button.tag];
button.accessibilityLabel = [[NSString alloc] initWithFormat:NSLocalizedString(@"More %@ books", nil), lane.title];
button.accessibilityTraits = UIAccessibilityTraitHeader;
button.accessibilityHint = NSLocalizedString(@"Tap to view more books in this category", "Descriptive label for screen readers");
[button addTarget:self
action:@selector(didSelectCategory:)
forControlEvents:UIControlEventTouchUpInside];
button.exclusiveTouch = YES;
[view addSubview:button];
}

// Creates a button with text and arrrow and allows the user to tap on it to view more books in the category.
{
UIButton *const button = [UIButton buttonWithType:UIButtonTypeSystem];
button.titleLabel.font = [UIFont palaceFontOfSize:14]; //Edited by Ellibs
Expand All @@ -334,6 +345,7 @@ - (UIView *)tableView:(__attribute__((unused)) UITableView *)tableView
button.tag = section;
TPPCatalogLane *const lane = self.feed.lanes[button.tag];
button.accessibilityLabel = [[NSString alloc] initWithFormat:NSLocalizedString(@"More %@ books", nil), lane.title];
button.accessibilityHint = NSLocalizedString(@"Tap to view more books in this category", "Descriptive label for screen readers");
button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[button addTarget:self
action:@selector(didSelectCategory:)
Expand Down Expand Up @@ -486,6 +498,7 @@ - (void)didSelectCategory:(UIButton *const)button
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont semiBoldPalaceFontOfSize: 16];
label.text = lane.title;
label.accessibilityTraits = UIAccessibilityTraitHeader;
viewController.navigationItem.titleView = label;

[self.navigationController pushViewController:viewController animated:YES];
Expand Down

0 comments on commit be8a698

Please sign in to comment.