#1540 (comfortable/compact feeds)

This commit is contained in:
David Sinclair 2021-12-20 20:40:43 -07:00
parent 95efd21426
commit a44e307c69
3 changed files with 22 additions and 2 deletions

View file

@ -1046,6 +1046,14 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
[self.appDelegate resizeFontSize];
}];
preferenceKey = @"feed_list_spacing";
titles = @[@"Compact", @"Comfortable"];
values = @[@"compact", @"comfortable"];
[viewController addSegmentedControlWithTitles:titles values:values defaultValue:@"comfortable" preferenceKey:preferenceKey selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
[self reloadFeedTitlesTable];
}];
[viewController addThemeSegmentedControl];
UINavigationController *navController = self.navigationController;
@ -1587,7 +1595,10 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
UIFontDescriptor *fontDescriptor = [self fontDescriptorUsingPreferredSize:UIFontTextStyleCaption1];
UIFont *font = [UIFont fontWithName:@"WhitneySSm-Medium" size:fontDescriptor.pointSize];
return height + font.pointSize*2;
NSString *spacing = [[NSUserDefaults standardUserDefaults] objectForKey:@"feed_list_spacing"];
NSInteger offset = [spacing isEqualToString:@"compact"] ? 6 : 0;
return height + (font.pointSize * 2) - offset;
}
- (void)resetRowHeights {

View file

@ -22,6 +22,7 @@ typedef void (^MenuItemSegmentedHandler)(NSUInteger selectedIndex);
- (void)addTitle:(NSString *)title iconTemplateName:(NSString *)iconTemplateName selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemHandler)handler;
- (void)addSegmentedControlWithTitles:(NSArray *)titles selectIndex:(NSUInteger)selectIndex selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemSegmentedHandler)handler;
- (void)addSegmentedControlWithTitles:(NSArray *)titles values:(NSArray *)values preferenceKey:(NSString *)preferenceKey selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemSegmentedHandler)handler;
- (void)addSegmentedControlWithTitles:(NSArray *)titles values:(NSArray *)values defaultValue:(NSString *)defaultValue preferenceKey:(NSString *)preferenceKey selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemSegmentedHandler)handler;
- (void)addThemeSegmentedControl;
- (void)showFromNavigationController:(UINavigationController *)navigationController barButtonItem:(UIBarButtonItem *)barButtonItem;

View file

@ -106,11 +106,19 @@ NSString * const MenuHandler = @"handler";
}
- (void)addSegmentedControlWithTitles:(NSArray *)titles values:(NSArray *)values preferenceKey:(NSString *)preferenceKey selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemSegmentedHandler)handler {
[self addSegmentedControlWithTitles:titles values:values defaultValue:nil preferenceKey:preferenceKey selectionShouldDismiss:selectionShouldDismiss handler:handler];
}
- (void)addSegmentedControlWithTitles:(NSArray *)titles values:(NSArray *)values defaultValue:(NSString *)defaultValue preferenceKey:(NSString *)preferenceKey selectionShouldDismiss:(BOOL)selectionShouldDismiss handler:(MenuItemSegmentedHandler)handler {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
id value = [userPreferences objectForKey:preferenceKey];
NSUInteger valueIndex = [values indexOfObject:value];
if (valueIndex < 0) {
if (valueIndex == NSNotFound && defaultValue != nil) {
valueIndex = [values indexOfObject:defaultValue];
}
if (valueIndex == NSNotFound) {
valueIndex = 0;
}