feat: property-editor#533
Conversation
835a24e to
03afbc6
Compare
| #import "../Chips/SeafCollaboratorChipView.h" | ||
| #import "../Chips/SeafTagChipView.h" | ||
| #import "../Selectors/SeafTagSelectorViewController.h" | ||
| #import "../Services/SeafSdocService.h" |
There was a problem hiding this comment.
直接文件名导入就行,不需要用相对路径,工程配置文件里面有文件搜索路径的配置
| }]; | ||
| } | ||
| return [UIColor colorWithRed:0x66/255.0 green:0x66/255.0 blue:0x66/255.0 alpha:1.0]; | ||
| } |
There was a problem hiding this comment.
这些uikit相关的能力,不推荐用C 静态函数,可以直接写个专门的子类或者UIView的分类。
There was a problem hiding this comment.
这几个样式函数仅在本文件内使用,scope 有限,暂保持现状,后续迭代再考虑抽分类。
| [self.scrollView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], | ||
| [self.scrollView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor], | ||
| [self.scrollView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor], | ||
| [self.scrollView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], |
There was a problem hiding this comment.
这里底部对其safeArea bottom是不是更合理
There was a problem hiding this comment.
这里不用修改,scrollView bottom 用物理边是为了底部的safeArea的穿透显示效果,避免内容过长时,底部安全区域显示纯色遮挡
There was a problem hiding this comment.
后面keyboardWillChangeFrame里面中用 CGRectGetMaxY(self.view.bounds) 把bottomSafeArea的高度算计去了,这里可以确认下距离键盘的高度是不是偏高了。
There was a problem hiding this comment.
已确认,这里的计算是正确的,真机测试了一下看起来也没有问题。
scrollView 是延伸到屏幕最底部的,与 CGRectGetMaxY(self.view.bounds) 的基准一致
| [self.stackView.leadingAnchor constraintGreaterThanOrEqualToAnchor:self.scrollView.contentLayoutGuide.leadingAnchor], | ||
| [self.scrollView.contentLayoutGuide.widthAnchor constraintEqualToAnchor:self.scrollView.frameLayoutGuide.widthAnchor], | ||
| [self.stackView.widthAnchor constraintLessThanOrEqualToConstant:700], | ||
| fullWidth, |
There was a problem hiding this comment.
这里我在iPad 上实测了一下没有约束冲突。fullWidth 用了 priority 750,会被 maxWidth ≤ 700自动打破,表单居中显示,左右两侧有留白。
| // Dismiss the profile sheet first, then present editor | ||
| __weak typeof(self) weakSelf = self; | ||
| [self dismissViewControllerAnimated:YES completion:^{ | ||
| if (!weakSelf.connection || !weakSelf.aggregate || !weakSelf.repoId) return; |
There was a problem hiding this comment.
这种dismiss回调可能存在销毁的情况,最好是加上strongself
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf.connection || !strongSelf.aggregate || !strongSelf.repoId) return;
|
|
||
| if (editable) { | ||
| [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; | ||
| objc_setAssociatedObject(textField, "metadataKey", key, OBJC_ASSOCIATION_COPY_NONATOMIC); |
There was a problem hiding this comment.
objc_setAssociatedObject的key判断的是指针不是字符串,应该是用static const void *kMetadataKey = &kMetadataKey。这个vc里面掺杂了对UIView、UITextField、UILabel等的关联属性动态绑定的方法,代码结构上不太优雅,建议封装一个UIView的分类,把这些属性添加到分类中。另外也可把buildTextFieldForKey和buildNumberFieldForKey修改成UITextField的子类SeafProfileTextField和SeafNumberTextField。
There was a problem hiding this comment.
好的,key 会改成 static const void * 的标准写法。子类抽取改动较大,可以先等版本和功能页面稳定后,后续迭代再优化。
There was a problem hiding this comment.
这个vc的代码过于庞大了,可以考虑把数据解析与转换和UI 构建的逻辑单独抽离出来。
There was a problem hiding this comment.
这个VC支持的字段较多,做大范围改动需要再完整的检查和测试。当前版本先保持,待功能稳定后,后续迭代中可以考虑用 Category 或完整的重构做进一步的文件级拆分
| // Uses UITableView with chip-style tag cells and selection checkmarks. | ||
|
|
||
| #import "SeafTagSelectorViewController.h" | ||
| #import "../Chips/SeafTagChipView.h" |
| #import "SeafSdocProfileSheetViewController.h" | ||
| #import "Editor/SeafSdocProfileEditorViewController.h" | ||
| #import "Chips/SeafTagChipView.h" | ||
| #import "Services/SeafSdocService.h" |
There was a problem hiding this comment.
import "SeafSdocProfileEditorViewController.h"、import "SeafTagChipView.h"、import "SeafSdocService.h"
| @@ -1,5 +1,6 @@ | |||
| #import "SeafPhotoInfoView.h" | |||
| #import "Debug.h" | |||
| #import "SDoc/Chips/SeafCollaboratorChipView.h" | |||
There was a problem hiding this comment.
#import "SeafCollaboratorChipView.h"
Add file property editor