Skip to content

Commit ca73c0f

Browse files
committed
mod: update demo
1 parent cc85b63 commit ca73c0f

File tree

2 files changed

+185
-6
lines changed

2 files changed

+185
-6
lines changed

TdsDemo/TapDBViewController.m

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,194 @@
66
//
77

88
#import "TapDBViewController.h"
9+
#import <TapSDK/TapDB.h>
910

1011
@interface TapDBViewController ()
12+
@property (nonatomic, strong) UILabel *nameLabel;
13+
@property (nonatomic, strong) UILabel *levelLabel;
14+
@property (nonatomic, strong) UILabel *serverLabel;
15+
@property (nonatomic, strong) UILabel *chargeLabel;
16+
@property (nonatomic, strong) UILabel *eventLabel;
1117

18+
@property (nonatomic, strong) UITextField *nameText;
19+
@property (nonatomic, strong) UITextField *levelText;
20+
@property (nonatomic, strong) UITextField *serverText;
21+
22+
@property (nonatomic, strong) UIButton *nameButton;
23+
@property (nonatomic, strong) UIButton *levelButton;
24+
@property (nonatomic, strong) UIButton *serverButton;
25+
@property (nonatomic, strong) UIButton *chargeButton;
26+
@property (nonatomic, strong) UIButton *eventButton;
1227
@end
1328

1429
@implementation TapDBViewController
1530

1631
- (void)viewDidLoad {
1732
[super viewDidLoad];
33+
self.view.backgroundColor = [UIColor whiteColor];
34+
[self.view addSubview:self.nameLabel];
35+
[self.view addSubview:self.levelLabel];
36+
[self.view addSubview:self.serverLabel];
37+
[self.view addSubview:self.chargeLabel];
38+
[self.view addSubview:self.eventLabel];
39+
40+
[self.view addSubview:self.nameText];
41+
[self.view addSubview:self.levelText];
42+
[self.view addSubview:self.serverText];
43+
44+
[self.view addSubview:self.nameButton];
45+
[self.view addSubview:self.levelButton];
46+
[self.view addSubview:self.serverButton];
47+
[self.view addSubview:self.chargeButton];
48+
[self.view addSubview:self.eventButton];
49+
}
50+
51+
- (UILabel *)nameLabel {
52+
if (!_nameLabel) {
53+
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)];
54+
_nameLabel.text = @"name";
55+
}
56+
return _nameLabel;
57+
}
58+
59+
- (UILabel *)levelLabel {
60+
if (!_levelLabel) {
61+
_levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 50, 20)];
62+
_levelLabel.text = @"level";
63+
}
64+
return _levelLabel;
65+
}
66+
67+
- (UILabel *)serverLabel {
68+
if (!_serverLabel) {
69+
_serverLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 50, 20)];
70+
_serverLabel.text = @"server";
71+
}
72+
return _serverLabel;
73+
}
74+
75+
- (UILabel *)chargeLabel {
76+
if (!_chargeLabel) {
77+
_chargeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 160, 50, 20)];
78+
_chargeLabel.text = @"chargr";
79+
}
80+
return _chargeLabel;
81+
}
82+
83+
- (UILabel *)eventLabel {
84+
if (!_eventLabel) {
85+
_eventLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 210, 50, 20)];
86+
_eventLabel.text = @"event";
87+
}
88+
return _eventLabel;
89+
}
90+
91+
- (UITextField *)nameText {
92+
if (!_nameText) {
93+
_nameText = [[UITextField alloc] initWithFrame:CGRectMake(80, 10, 100, 20)];
94+
_nameText.text = @"nameTest";
95+
_nameText.backgroundColor = [UIColor lightGrayColor];
96+
}
97+
return _nameText;
98+
}
99+
100+
- (UITextField *)levelText {
101+
if (!_levelText) {
102+
_levelText = [[UITextField alloc] initWithFrame:CGRectMake(80, 60, 100, 20)];
103+
_levelText.text = @"1";
104+
_levelText.backgroundColor = [UIColor lightGrayColor];
105+
}
106+
return _levelText;
107+
}
108+
109+
- (UITextField *)serverText {
110+
if (!_serverText) {
111+
_serverText = [[UITextField alloc] initWithFrame:CGRectMake(80, 110, 100, 20)];
112+
_serverText.text = @"serverTest";
113+
_serverText.backgroundColor = [UIColor lightGrayColor];
114+
}
115+
return _serverText;
116+
}
117+
118+
- (UIButton *)nameButton {
119+
if (!_nameButton) {
120+
_nameButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 10, 100, 20)];
121+
[_nameButton setTitle:@"set Name" forState:UIControlStateNormal];
122+
_nameButton.layer.cornerRadius = 5;
123+
_nameButton.layer.masksToBounds = YES;
124+
_nameButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00];
125+
[_nameButton addTarget:self action:@selector(nameButtonAction) forControlEvents:UIControlEventTouchUpInside];
126+
}
127+
return _nameButton;
128+
}
129+
130+
- (UIButton *)levelButton {
131+
if (!_levelButton) {
132+
_levelButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 60, 100, 20)];
133+
[_levelButton setTitle:@"set Level" forState:UIControlStateNormal];
134+
_levelButton.layer.cornerRadius = 5;
135+
_levelButton.layer.masksToBounds = YES;
136+
_levelButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00];
137+
[_levelButton addTarget:self action:@selector(levelButtonAction) forControlEvents:UIControlEventTouchUpInside];
138+
}
139+
return _levelButton;
140+
}
141+
142+
- (UIButton *)serverButton {
143+
if (!_serverButton) {
144+
_serverButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 110, 100, 20)];
145+
[_serverButton setTitle:@"set Server" forState:UIControlStateNormal];
146+
_serverButton.layer.cornerRadius = 5;
147+
_serverButton.layer.masksToBounds = YES;
148+
_serverButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00];
149+
[_serverButton addTarget:self action:@selector(serverButtonAction) forControlEvents:UIControlEventTouchUpInside];
150+
}
151+
return _serverButton;
152+
}
153+
154+
- (UIButton *)chargeButton {
155+
if (!_chargeButton) {
156+
_chargeButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 160, 100, 20)];
157+
[_chargeButton setTitle:@"on Charge" forState:UIControlStateNormal];
158+
_chargeButton.layer.cornerRadius = 5;
159+
_chargeButton.layer.masksToBounds = YES;
160+
_chargeButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00];
161+
[_chargeButton addTarget:self action:@selector(chargeButtonAction) forControlEvents:UIControlEventTouchUpInside];
162+
}
163+
return _chargeButton;
164+
}
165+
166+
- (UIButton *)eventButton {
167+
if (!_eventButton) {
168+
_eventButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 210, 100, 20)];
169+
[_eventButton setTitle:@"on Event" forState:UIControlStateNormal];
170+
_eventButton.layer.cornerRadius = 5;
171+
_eventButton.layer.masksToBounds = YES;
172+
_eventButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00];
173+
[_eventButton addTarget:self action:@selector(eventButtonAction) forControlEvents:UIControlEventTouchUpInside];
174+
}
175+
return _eventButton;
176+
}
177+
178+
- (void)nameButtonAction{
179+
[TapDB setName:self.nameText.text];
180+
}
181+
182+
- (void)levelButtonAction{
183+
[TapDB setLevel:[self.levelText.text intValue]];
184+
}
185+
186+
- (void)serverButtonAction{
187+
[TapDB setServer:self.serverText.text];
188+
}
189+
190+
- (void)chargeButtonAction{
191+
[TapDB onChargeSuccess:@"22222" product:@"product2" amount:3 currencyType:@"rmb" payment:@"10"];
192+
}
18193

194+
- (void)eventButtonAction{
195+
NSDictionary* dic = @{@"aaa":@"xxx",@"bbb":@"yyy"};
196+
[TapDB onEvent:@"testEvent2" properties:dic];
19197
}
20198

21199
/*

TdsDemo/ViewController.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,42 @@ @implementation ViewController
2323
- (void)viewDidLoad {
2424
[super viewDidLoad];
2525

26-
UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 50)];
26+
UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 50, 100, 50)];
2727
loginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
2828
[loginButton setTitle:@"登录" forState:UIControlStateNormal];
2929
[loginButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
3030
[loginButton addTarget:self action:@selector(taptapLogin:) forControlEvents:UIControlEventTouchUpInside];
3131
[self.view addSubview:loginButton];
3232

33-
UIButton *logoutButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 100, 50)];
33+
UIButton *logoutButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 150, 100, 50)];
3434
logoutButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
3535
[logoutButton setTitle:@"登出" forState:UIControlStateNormal];
3636
[logoutButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
3737
[logoutButton addTarget:self action:@selector(taptapLogout:) forControlEvents:UIControlEventTouchUpInside];
3838
[self.view addSubview:logoutButton];
3939

40-
UIButton *profileButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 300, 50)];
40+
UIButton *profileButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 300, 50)];
4141
profileButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
4242
[profileButton setTitle:@"获取用户最新信息" forState:UIControlStateNormal];
4343
[profileButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
4444
[profileButton addTarget:self action:@selector(fetchProfile:) forControlEvents:UIControlEventTouchUpInside];
4545
[self.view addSubview:profileButton];
4646

47-
UIButton *momentButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 100, 50)];
47+
UIButton *momentButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 350, 100, 50)];
4848
momentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
4949
[momentButton setTitle:@"打开动态" forState:UIControlStateNormal];
5050
[momentButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
5151
[momentButton addTarget:self action:@selector(taptapMoment:) forControlEvents:UIControlEventTouchUpInside];
5252
[self.view addSubview:momentButton];
5353

54-
UIButton *momentRedPoint = [[UIButton alloc] initWithFrame:CGRectMake(100, 500, 300, 50)];
54+
UIButton *momentRedPoint = [[UIButton alloc] initWithFrame:CGRectMake(100, 450, 300, 50)];
5555
momentRedPoint.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
5656
[momentRedPoint setTitle:@"获取动态未读数" forState:UIControlStateNormal];
5757
[momentRedPoint setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
5858
[momentRedPoint addTarget:self action:@selector(taptapMomentRedPoint:) forControlEvents:UIControlEventTouchUpInside];
5959
[self.view addSubview:momentRedPoint];
6060

61-
UIButton *dbButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 600, 300, 50)];
61+
UIButton *dbButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 550, 300, 50)];
6262
dbButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
6363
[dbButton setTitle:@"进入TapDB测试" forState:UIControlStateNormal];
6464
[dbButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
@@ -161,6 +161,7 @@ - (void)didChangeResultCode:(NSInteger)code msg:(NSString *)msg {
161161

162162
- (void)toTapDB:(UIButton *)button {
163163
TapDBViewController *dbController = [TapDBViewController new];
164+
// [self showViewController:dbController sender:nil];
164165
[self presentViewController:dbController animated:YES completion:nil];
165166
}
166167

0 commit comments

Comments
 (0)