diff --git a/TdsDemo/TapDBViewController.m b/TdsDemo/TapDBViewController.m index 92b6a84..f55d698 100644 --- a/TdsDemo/TapDBViewController.m +++ b/TdsDemo/TapDBViewController.m @@ -6,16 +6,194 @@ // #import "TapDBViewController.h" +#import @interface TapDBViewController () +@property (nonatomic, strong) UILabel *nameLabel; +@property (nonatomic, strong) UILabel *levelLabel; +@property (nonatomic, strong) UILabel *serverLabel; +@property (nonatomic, strong) UILabel *chargeLabel; +@property (nonatomic, strong) UILabel *eventLabel; +@property (nonatomic, strong) UITextField *nameText; +@property (nonatomic, strong) UITextField *levelText; +@property (nonatomic, strong) UITextField *serverText; + +@property (nonatomic, strong) UIButton *nameButton; +@property (nonatomic, strong) UIButton *levelButton; +@property (nonatomic, strong) UIButton *serverButton; +@property (nonatomic, strong) UIButton *chargeButton; +@property (nonatomic, strong) UIButton *eventButton; @end @implementation TapDBViewController - (void)viewDidLoad { [super viewDidLoad]; + self.view.backgroundColor = [UIColor whiteColor]; + [self.view addSubview:self.nameLabel]; + [self.view addSubview:self.levelLabel]; + [self.view addSubview:self.serverLabel]; + [self.view addSubview:self.chargeLabel]; + [self.view addSubview:self.eventLabel]; + + [self.view addSubview:self.nameText]; + [self.view addSubview:self.levelText]; + [self.view addSubview:self.serverText]; + + [self.view addSubview:self.nameButton]; + [self.view addSubview:self.levelButton]; + [self.view addSubview:self.serverButton]; + [self.view addSubview:self.chargeButton]; + [self.view addSubview:self.eventButton]; +} + +- (UILabel *)nameLabel { + if (!_nameLabel) { + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)]; + _nameLabel.text = @"name"; + } + return _nameLabel; +} + +- (UILabel *)levelLabel { + if (!_levelLabel) { + _levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 50, 20)]; + _levelLabel.text = @"level"; + } + return _levelLabel; +} + +- (UILabel *)serverLabel { + if (!_serverLabel) { + _serverLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 50, 20)]; + _serverLabel.text = @"server"; + } + return _serverLabel; +} + +- (UILabel *)chargeLabel { + if (!_chargeLabel) { + _chargeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 160, 50, 20)]; + _chargeLabel.text = @"chargr"; + } + return _chargeLabel; +} + +- (UILabel *)eventLabel { + if (!_eventLabel) { + _eventLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 210, 50, 20)]; + _eventLabel.text = @"event"; + } + return _eventLabel; +} + +- (UITextField *)nameText { + if (!_nameText) { + _nameText = [[UITextField alloc] initWithFrame:CGRectMake(80, 10, 100, 20)]; + _nameText.text = @"nameTest"; + _nameText.backgroundColor = [UIColor lightGrayColor]; + } + return _nameText; +} + +- (UITextField *)levelText { + if (!_levelText) { + _levelText = [[UITextField alloc] initWithFrame:CGRectMake(80, 60, 100, 20)]; + _levelText.text = @"1"; + _levelText.backgroundColor = [UIColor lightGrayColor]; + } + return _levelText; +} + +- (UITextField *)serverText { + if (!_serverText) { + _serverText = [[UITextField alloc] initWithFrame:CGRectMake(80, 110, 100, 20)]; + _serverText.text = @"serverTest"; + _serverText.backgroundColor = [UIColor lightGrayColor]; + } + return _serverText; +} + +- (UIButton *)nameButton { + if (!_nameButton) { + _nameButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 10, 100, 20)]; + [_nameButton setTitle:@"set Name" forState:UIControlStateNormal]; + _nameButton.layer.cornerRadius = 5; + _nameButton.layer.masksToBounds = YES; + _nameButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; + [_nameButton addTarget:self action:@selector(nameButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _nameButton; +} + +- (UIButton *)levelButton { + if (!_levelButton) { + _levelButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 60, 100, 20)]; + [_levelButton setTitle:@"set Level" forState:UIControlStateNormal]; + _levelButton.layer.cornerRadius = 5; + _levelButton.layer.masksToBounds = YES; + _levelButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; + [_levelButton addTarget:self action:@selector(levelButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _levelButton; +} + +- (UIButton *)serverButton { + if (!_serverButton) { + _serverButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 110, 100, 20)]; + [_serverButton setTitle:@"set Server" forState:UIControlStateNormal]; + _serverButton.layer.cornerRadius = 5; + _serverButton.layer.masksToBounds = YES; + _serverButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; + [_serverButton addTarget:self action:@selector(serverButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _serverButton; +} + +- (UIButton *)chargeButton { + if (!_chargeButton) { + _chargeButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 160, 100, 20)]; + [_chargeButton setTitle:@"on Charge" forState:UIControlStateNormal]; + _chargeButton.layer.cornerRadius = 5; + _chargeButton.layer.masksToBounds = YES; + _chargeButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; + [_chargeButton addTarget:self action:@selector(chargeButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _chargeButton; +} + +- (UIButton *)eventButton { + if (!_eventButton) { + _eventButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 210, 100, 20)]; + [_eventButton setTitle:@"on Event" forState:UIControlStateNormal]; + _eventButton.layer.cornerRadius = 5; + _eventButton.layer.masksToBounds = YES; + _eventButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; + [_eventButton addTarget:self action:@selector(eventButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _eventButton; +} + +- (void)nameButtonAction{ + [TapDB setName:self.nameText.text]; +} + +- (void)levelButtonAction{ + [TapDB setLevel:[self.levelText.text intValue]]; +} + +- (void)serverButtonAction{ + [TapDB setServer:self.serverText.text]; +} + +- (void)chargeButtonAction{ + [TapDB onChargeSuccess:@"22222" product:@"product2" amount:3 currencyType:@"rmb" payment:@"10"]; +} +- (void)eventButtonAction{ + NSDictionary* dic = @{@"aaa":@"xxx",@"bbb":@"yyy"}; + [TapDB onEvent:@"testEvent2" properties:dic]; } /* diff --git a/TdsDemo/ViewController.m b/TdsDemo/ViewController.m index 26de5e8..76d2fd9 100644 --- a/TdsDemo/ViewController.m +++ b/TdsDemo/ViewController.m @@ -23,42 +23,42 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 50)]; + UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 50, 100, 50)]; loginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [loginButton setTitle:@"登录" forState:UIControlStateNormal]; [loginButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [loginButton addTarget:self action:@selector(taptapLogin:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:loginButton]; - UIButton *logoutButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 100, 50)]; + UIButton *logoutButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 150, 100, 50)]; logoutButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [logoutButton setTitle:@"登出" forState:UIControlStateNormal]; [logoutButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [logoutButton addTarget:self action:@selector(taptapLogout:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:logoutButton]; - UIButton *profileButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 300, 50)]; + UIButton *profileButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 300, 50)]; profileButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [profileButton setTitle:@"获取用户最新信息" forState:UIControlStateNormal]; [profileButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [profileButton addTarget:self action:@selector(fetchProfile:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:profileButton]; - UIButton *momentButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 100, 50)]; + UIButton *momentButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 350, 100, 50)]; momentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [momentButton setTitle:@"打开动态" forState:UIControlStateNormal]; [momentButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [momentButton addTarget:self action:@selector(taptapMoment:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:momentButton]; - UIButton *momentRedPoint = [[UIButton alloc] initWithFrame:CGRectMake(100, 500, 300, 50)]; + UIButton *momentRedPoint = [[UIButton alloc] initWithFrame:CGRectMake(100, 450, 300, 50)]; momentRedPoint.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [momentRedPoint setTitle:@"获取动态未读数" forState:UIControlStateNormal]; [momentRedPoint setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [momentRedPoint addTarget:self action:@selector(taptapMomentRedPoint:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:momentRedPoint]; - UIButton *dbButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 600, 300, 50)]; + UIButton *dbButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 550, 300, 50)]; dbButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [dbButton setTitle:@"进入TapDB测试" forState:UIControlStateNormal]; [dbButton setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; @@ -161,6 +161,7 @@ - (void)didChangeResultCode:(NSInteger)code msg:(NSString *)msg { - (void)toTapDB:(UIButton *)button { TapDBViewController *dbController = [TapDBViewController new]; +// [self showViewController:dbController sender:nil]; [self presentViewController:dbController animated:YES completion:nil]; }