UserRegisterAccountViewController.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // UserRegisterAccountViewController.m
  3. // XenonSDK
  4. //
  5. // Created by SAGESSE on 2019/5/29.
  6. // Copyright © 2019 SAGESSE. All rights reserved.
  7. //
  8. #import "XenonSDK.h"
  9. #import "UserRegisterAccountViewController.h"
  10. #import "NSBundle+KODLocalizable.h"
  11. #import "KODCommonConst.h"
  12. @interface UserRegisterAccountViewController ()
  13. @end
  14. @implementation UserRegisterAccountViewController
  15. -(void)viewDidLoad {
  16. self.view.backgroundColor = [UIColor whiteColor];
  17. self.accountTextField.textColor = [UIColor blackColor];
  18. self.passwordTextField.textColor = [UIColor blackColor];
  19. }
  20. - (void)registerForPassword:(id)sender {
  21. // Resign editing.
  22. [self.view endEditing:YES];
  23. // Must enter account.
  24. NSString* account = self.accountTextField.text;
  25. if (account.length == 0) {
  26. //请输入帐号
  27. NSString *str = [NSBundle KOD_localizedStringForKey:PleaseEnterAccount];
  28. [XSNetwork showHudFailure:str];
  29. return;
  30. }
  31. // Must enter password.
  32. NSString* password = self.passwordTextField.text;
  33. if (password.length == 0) {
  34. //请输入密码
  35. NSString *str = [NSBundle KOD_localizedStringForKey:PleaseEnterPwd];
  36. [XSNetwork showHudFailure:str];
  37. return;
  38. }
  39. [XSNetwork showHudLoading];
  40. [XSNetwork registerWithAccount:account password:password complete:^(id object, NSError *error) {
  41. if (error != nil) {
  42. [XSNetwork showHudFailure:error];
  43. return;
  44. }
  45. if (XenonSDK.sharedSDK.sdk_loginCallback) {
  46. XenonSDK.sharedSDK.sdk_loginCallback(object);
  47. }
  48. }];
  49. }
  50. - (void)displayModeForPassword:(UIButton*)sender {
  51. // Toggle password display mode.
  52. sender.selected = !sender.selected;
  53. self.passwordTextField.secureTextEntry = sender.selected;
  54. }
  55. // MARK: -
  56. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  57. if (textField.returnKeyType == UIReturnKeyDone) {
  58. [self registerForPassword:textField];
  59. return NO;
  60. }
  61. if (textField == self.accountTextField) {
  62. [self.passwordTextField becomeFirstResponder];
  63. }
  64. return YES;
  65. }
  66. @end