-
Notifications
You must be signed in to change notification settings - Fork 2
/
ClientIDTableViewController.m
73 lines (61 loc) · 2.64 KB
/
ClientIDTableViewController.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
68
69
70
71
72
73
//
// ClientIDTableViewController.m
// Soundrocket
//
// Created by Sebastian Boldt on 20.06.15.
// Copyright © 2015 sebastianboldt. All rights reserved.
//
#import "ClientIDTableViewController.h"
#import "SRPlayer.h"
#import <SVProgressHUD.h>
#import "SRStylesheet.h"
#import <SupportKit/SupportKit.h>
@interface ClientIDTableViewController ()
@end
@implementation ClientIDTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.clientTextField setText:[[SRPlayer sharedPlayer]loadStreamingID]];
[self setupTweetLabel];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"help",nil) style:UIBarButtonItemStylePlain target:self action:@selector(showSupport:)];
[self.descriptionTextView setText:NSLocalizedString(@"CLIENT_ID_DESCRIPTION", nil)];
[self.pasteLabel setText:NSLocalizedString(@"register your app", nil)];
[self.yourAppsLabel setText:NSLocalizedString(@"click your apps", nil)];
[self.saveClientIDButton setTitle:NSLocalizedString(@"Save client ID", nil) forState:UIControlStateNormal];
}
-(void)showSupport:(id)sender {
[SupportKit show];
}
-(IBAction)saveClientIDPressed:(id)sender {
[[SRPlayer sharedPlayer]saveStreamingID:self.clientTextField.text];
[SVProgressHUD showSuccessWithStatus:@"Success"];
}
-(void)setupTweetLabel {
STTweetLabel* label = (STTweetLabel*)self.linkLabel;
label.userInteractionEnabled = YES;
NSDictionary* textAttributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:13.0],
NSForegroundColorAttributeName:[UIColor grayColor]
};
[self.linkLabel setAttributes:textAttributes];
NSDictionary* linkAttributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:13.0],
NSForegroundColorAttributeName:[SRStylesheet mainColor]
};
[label setAttributes:linkAttributes hotWord:STTweetLink];
[label setAttributes:linkAttributes hotWord:STTweetHashtag];
[label setAttributes:linkAttributes hotWord:STTweetHandle];
[label setDetectionBlock:^(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range) {
switch (hotWord){
case STTweetLink:
[self handleURL:string];
break;
default: break;
}
}];
[self.linkLabel setText:@"1. https://developers.soundcloud.com"];
}
-(void)handleURL:(NSString*)string {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:string]];
}
@end