Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ @interface FLEXSystemLogViewController ()

@property (nonatomic, readonly) FLEXMutableListSection<FLEXSystemLogMessage *> *logMessages;
@property (nonatomic, readonly) id<FLEXLogController> logController;
@property (nonatomic) BOOL isPaused;
@property (nonatomic, strong) UIBarButtonItem *pauseButton;

@end

Expand Down Expand Up @@ -121,13 +123,19 @@ - (void)viewDidLoad {
target:self
action:@selector(scrollToLastRow)
];
self.pauseButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage systemImageNamed:@"pause.fill"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(togglePause)
];
UIBarButtonItem *settings = [UIBarButtonItem
flex_itemWithImage:FLEXResources.gearIcon
target:self
action:@selector(showLogSettings)
];

[self addToolbarItems:@[scrollDown, settings]];
[self addToolbarItems:@[scrollDown, self.pauseButton, settings]];
}

- (void)viewWillAppear:(BOOL)animated {
Expand Down Expand Up @@ -170,6 +178,10 @@ - (void)viewWillAppear:(BOOL)animated {
#pragma mark - Private

- (void)handleUpdateWithNewMessages:(NSArray<FLEXSystemLogMessage *> *)newMessages {
if (self.isPaused) {
return;
}

self.title = [self.class globalsEntryTitle:FLEXGlobalsRowSystemLog];

[self.logMessages mutate:^(NSMutableArray *list) {
Expand Down Expand Up @@ -198,6 +210,12 @@ - (void)scrollToLastRow {
}
}

- (void)togglePause {
self.isPaused = !self.isPaused;
UIImage *newIcon = self.isPaused ? [UIImage systemImageNamed:@"play.fill"] : [UIImage systemImageNamed:@"pause.fill"];
self.pauseButton.image = newIcon;
}

- (void)showLogSettings {
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
BOOL disableOSLog = defaults.flex_disableOSLog;
Expand Down