-
Notifications
You must be signed in to change notification settings - Fork 1
/
LogViewController.m
67 lines (57 loc) · 2.66 KB
/
LogViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// LogViewController.m
// xchighlight
//
// Created by EthanRDoesMC on 3/18/21.
//
#import "LogViewController.h"
#import <Foundation/Foundation.h>
#import "NSTask.h"
#import "BLMautrixTask.h"
@interface LogViewController ()
@property (strong, nonatomic) IBOutlet UITextView *logField;
@property (nonatomic, strong) NSTask* task;
@end
@implementation LogViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(presentOptions)];
[BLMautrixTask sharedTask];
[self updateLog];
// Do any additional setup after loading the view from its nib.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateLog) name:@"BLMautrixLogUpdated" object:nil];
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
}
-(void)updateLog {
[self.logField setText:[[BLMautrixTask sharedTask] outputString]];
[self.logField scrollRangeToVisible: NSMakeRange(_logField.text.length, 0)];
}
-(void)presentOptions {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Requests"
message:@"Send a request to the bridge."
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* ping = [UIAlertAction actionWithTitle:@"Ping" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[BLMautrixTask sharedTask] sendPing];
}];
// UIAlertAction* testMsg = [UIAlertAction actionWithTitle:@"Test Message" style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
// [[BLMautrixTask sharedTask] sendTest];
// }];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
[alert addAction:ping];
// [alert addAction:testMsg];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end