Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions ios/Classes/AliAuthPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,18 @@ - (void)checkCellularDataEnable:(FlutterMethodCall*)call result:(FlutterResult)r
- (void)btnClick: (UIGestureRecognizer *) sender {
UIButton *view = (UIButton *)sender;
NSInteger index = view.tag;
NSDictionary *dict = @{
@"code": @"700005",
@"msg" : @"点击第三方登录按钮",
@"data" : [NSNumber numberWithInteger: index]
};
/// 700000 为 自定义返回按钮的 tag
NSDictionary * dict = index == 700000 ? @{
@"code": @"700000",
@"msg" : @"用户取消登录",
@"data" : @"cancel login by tapping customized back button"
} : @{
@"code": @"700005",
@"msg" : @"点击第三方登录按钮",
@"data" : [NSNumber numberWithInteger: index]
};
[self resultData: dict];
if (!self->_isChecked && !self->_isHideToast) {
if (index != 700000 && !self->_isChecked && !self->_isHideToast) {
NSDictionary *dic = self -> _callData.arguments;
[self showToast: [dic stringValueForKey: @"toastText" defaultValue: @"请先阅读用户协议"]];
} else {
Expand Down
118 changes: 74 additions & 44 deletions ios/Classes/Utils/PNSBuildModelUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ + (TXCustomModel *)buildFullScreenPortraitModel:(NSDictionary *)viewConfig
};
}
/// 返回按钮 END

/// 右侧按钮布局设置
// UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeSystem];
// [rightBtn setTitle:@"更多" forState:UIControlStateNormal];
Expand Down Expand Up @@ -1570,7 +1570,7 @@ + (TXCustomModel *)buildModelOption:(NSDictionary *)dict
target:(id)target
style:(PNSBuildModelStyle)style
selector:(SEL)selector {
NSLog(@"%@", dict);
NSLog(@"buildModelOption %@", dict);
TXCustomModel *model = [TXCustomModel mj_objectWithKeyValues: dict];
for (NSString *key in dict) {
if (key && key.length > 0 && dict[key] != nil) {
Expand Down Expand Up @@ -1830,18 +1830,15 @@ + (TXCustomModel *)buildModelOption:(NSDictionary *)dict
}
};
}
#pragma mark 8、自定义控件区(如其他方式登录)
#pragma mark 8、自定义控件区(如其他方式登录、自定义返回按钮)
NSMutableArray * customArrayView = [NSMutableArray array]; /// 空数组,有意义
NSDictionary *customThirdView = [dict dictValueForKey: @"customThirdView" defaultValue: nil];
if (customThirdView != nil) {
NSMutableArray * customArrayView = [NSMutableArray array]; /// 空数组,有意义
NSArray * customArray = [customThirdView arrayValueForKey: @"viewItemPath" defaultValue: nil]; //空数组,有意义
NSArray * customNameArray = [customThirdView arrayValueForKey: @"viewItemName" defaultValue: nil]; //空数组,有意义
if(customArray != nil && customArray.count > 0){
/// 第三方图标按钮的相关参数
int width = [customThirdView intValueForKey: @"itemWidth" defaultValue: 70];
int height = [customThirdView intValueForKey: @"itemHeight" defaultValue: 70];
int offsetY = [customThirdView intValueForKey: @"top" defaultValue: 20];
int space = [customThirdView intValueForKey: @"space" defaultValue: 30];
int textSize = [customThirdView intValueForKey: @"size" defaultValue: 17];
NSString *color = [customThirdView stringValueForKey: @"color" defaultValue: @"#3C4E5F"];

Expand All @@ -1856,45 +1853,78 @@ + (TXCustomModel *)buildModelOption:(NSDictionary *)dict
[button addTarget:target action: selector forControlEvents:UIControlEventTouchUpInside];
[customArrayView addObject: button];
}
/// 添加第三方图标
model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
if (backgroundView != nil) {
[superCustomView addSubview: backgroundView];
}
for (int i = 0 ; i < customArrayView.count; i++) {
[superCustomView addSubview: customArrayView[i]];
}
};

model.customViewLayoutBlock = ^(
CGSize screenSize, /// 全屏参数
CGRect contentViewFrame, /// contentView参数
CGRect navFrame, /// 导航参数
CGRect titleBarFrame, /// title参数
CGRect logoFrame, /// logo区域参数
CGRect sloganFrame, /// slogan参数
CGRect numberFrame, /// 号码处参数
CGRect loginFrame, /// 登录按钮处的参数
CGRect changeBtnFrame, /// 切换到其他的参数
CGRect privacyFrame /// 协议区域的参数
) {
if (backgroundView != nil) {
backgroundView.frame = CGRectMake(0, -CGRectGetMaxY(navFrame), contentViewFrame.size.width, contentViewFrame.size.height);
}
NSUInteger count = customArrayView.count;
NSInteger contentWidth = screenSize.width;
/// 弹窗模式需要重新获取他的宽度
if (PNSBuildModelStyleAlertPortrait == style || PNSBuildModelStyleAlertLandscape == style){
contentWidth = [dict intValueForKey: @"dialogWidth" defaultValue: 0];
}
for (int i = 0 ; i < count; i++) {
UIButton *itemView = (UIButton *)customArrayView[i];
NSInteger X = (contentWidth - (width * count + space * (count - 1))) / 2 + (space + width) * i; /// 两端评分
itemView.frame = CGRectMake( X, offsetY, itemView.frame.size.width, itemView.frame.size.height );
}
};
}
}
/// 自定义返回按钮
NSDictionary *customReturnBtnCnf = [dict dictValueForKey: @"customReturnBtn" defaultValue: nil];
UIButton *customReturnBtn = nil;
NSLog(@"customReturnBtnCnf: %@", customReturnBtnCnf);
if (customReturnBtnCnf != nil && [customReturnBtnCnf count] != 0) {
NSString * imgPath = [customReturnBtnCnf stringValueForKey: @"imgPath" defaultValue: nil];

customReturnBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[customReturnBtn setTag: 700000];
[customReturnBtn setBackgroundImage:[self changeUriPathToImage: imgPath] forState:UIControlStateNormal];
[customReturnBtn addTarget:target action: selector forControlEvents:UIControlEventTouchUpInside];
}

model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
if (backgroundView != nil) {
[superCustomView addSubview: backgroundView];
}
/// 添加第三方图标
for (int i = 0 ; i < customArrayView.count; i++) {
[superCustomView addSubview: customArrayView[i]];
}
/// 添加自定义返回按钮
if (customReturnBtn != nil) {
[superCustomView addSubview: customReturnBtn];
}
};

model.customViewLayoutBlock = ^(
CGSize screenSize, /// 全屏参数
CGRect contentViewFrame, /// contentView参数
CGRect navFrame, /// 导航参数
CGRect titleBarFrame, /// title参数
CGRect logoFrame, /// logo区域参数
CGRect sloganFrame, /// slogan参数
CGRect numberFrame, /// 号码处参数
CGRect loginFrame, /// 登录按钮处的参数
CGRect changeBtnFrame, /// 切换到其他的参数
CGRect privacyFrame /// 协议区域的参数
) {
if (backgroundView != nil) {
backgroundView.frame = CGRectMake(0, -CGRectGetMaxY(navFrame), contentViewFrame.size.width, contentViewFrame.size.height);
}
NSUInteger count = customArrayView.count;
NSInteger contentWidth = screenSize.width;
/// 弹窗模式需要重新获取他的宽度
if (PNSBuildModelStyleAlertPortrait == style || PNSBuildModelStyleAlertLandscape == style){
contentWidth = [dict intValueForKey: @"dialogWidth" defaultValue: 0];
}
if ([customArrayView count] > 0) {
/// 第三方图标按钮的相关参数
int width = [customThirdView intValueForKey: @"itemWidth" defaultValue: 70];
int offsetY = [customThirdView intValueForKey: @"top" defaultValue: 20];
int spacing = [customThirdView intValueForKey: @"space" defaultValue: 30];
for (int i = 0 ; i < count; i++) {
UIButton *itemView = (UIButton *)customArrayView[i];
NSInteger X = (contentWidth - (width * count + spacing * (count - 1))) / 2 + (spacing + width) * i; /// 两端评分
itemView.frame = CGRectMake( X, offsetY, itemView.frame.size.width, itemView.frame.size.height );
}
}

/// 自定义返回按钮的位置
if (customReturnBtn != nil) {
int top = [customReturnBtnCnf intValueForKey: @"top" defaultValue: 0];
int left = [customReturnBtnCnf intValueForKey: @"left" defaultValue: 0];
int width = [customReturnBtnCnf intValueForKey: @"width" defaultValue: 40];
int height = [customReturnBtnCnf intValueForKey: @"height" defaultValue: 40];
customReturnBtn.frame = CGRectMake(left, top, width, height);
}
};

#pragma mark 9、协议栏
if (!model.checkBoxIsHidden) {
UIImage* unchecked = [self changeUriPathToImage: [dict stringValueForKey: @"uncheckedImgPath" defaultValue: nil]];
Expand Down