Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor settings menu in swiftui only UI #316

Merged
merged 10 commits into from
Jan 14, 2024

Conversation

liyafly
Copy link
Contributor

@liyafly liyafly commented Jan 7, 2024

#286 初步完成UI,功能是否需要等使用swift重构后添加还是使用桥接Objc完成呢?

@liyafly liyafly force-pushed the refactor_settings_menu_swiftui branch from c330118 to 7b30e19 Compare January 7, 2024 08:44
@tisfeng
Copy link
Owner

tisfeng commented Jan 7, 2024

一些简单的功能,可以在重构 UI 时顺便也重写了。一些比较复杂的,像输入翻译这几个,可以先桥接使用 objc,后面专门弄个 PR 来重写。

@tisfeng
Copy link
Owner

tisfeng commented Jan 7, 2024

目前这个【检查更新】功能好像不对,麻烦你也看一下。

@liyafly
Copy link
Contributor Author

liyafly commented Jan 7, 2024

我已经添加objc桥接,但debug下部分功能系统权限授权有问题,无法做到全面测试。请review

@tisfeng
Copy link
Owner

tisfeng commented Jan 7, 2024

有两个小问题:

  • @Property window 出现警告,可能是桥接文件添加 #import "EZWindowManager.h" 导致。
  • Sparkle 有 gentle reminders 警告,我之前是通过实现 supportsGentleScheduledUpdateReminders 消除了这个警告。
image

@tisfeng
Copy link
Owner

tisfeng commented Jan 7, 2024

我已经添加objc桥接,但debug下部分功能系统权限授权有问题,无法做到全面测试。请review

参考下面,你可以在 Easydict-debug.xcconfig 配置文件添加你自己的开发者账号,方便后续调试。

DEVELOPMENT_TEAM = 79NQA2XYHM
CODE_SIGN_IDENTITY = Apple Development
CODE_SIGN_STYLE = Manual

由于这个文件不应该提交,可以使用 git 忽略这个文件变动。(后面假如切换分支遇到问题,可以再改回来)

git update-index --skip-worktree Easydict-debug.xcconfig

@liyafly
Copy link
Contributor Author

liyafly commented Jan 7, 2024

有两个小问题:

  • @Property window 出现警告,可能是桥接文件添加 #import "EZWindowManager.h" 导致。
  • Sparkle 有 gentle reminders 警告,我之前是通过实现 supportsGentleScheduledUpdateReminders 消除了这个警告。
image

好的,我下周进行修改。thanks

@liyafly
Copy link
Contributor Author

liyafly commented Jan 8, 2024

有两个小问题:

  • @Property window 出现警告,可能是桥接文件添加 #import "EZWindowManager.h" 导致。

  • Sparkle 有 gentle reminders 警告,我之前是通过实现 supportsGentleScheduledUpdateReminders 消除了这个警告。

image

I added the nullable modifier to @property (nullable, nonatomic, weak) EZBaseQueryWindow *window;, but Xcode is still throwing a warning. I’m not quite sure why this is happening. Do you have any insights on this issue?

@tisfeng
Copy link
Owner

tisfeng commented Jan 8, 2024

Wait for me to take a look.

@tisfeng
Copy link
Owner

tisfeng commented Jan 8, 2024

It's strange, I've tried a number of ways and none of them work. This is caused by being referenced by a Swift bridge file, and I'm not familiar with Swift.

If there's really no way to fix it, we can just ignore the warning:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability"
@property (nonatomic, weak) EZBaseQueryWindow *window;
#pragma clang diagnostic pop

Ref: https://stackoverflow.com/a/39918786/8378840

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 8, 2024

It's strange, I've tried a number of ways and none of them work. This is caused by being referenced by a Swift bridge file, and I'm not familiar with Swift.

If there's really no way to fix it, we can just ignore the warning:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability"
@property (nonatomic, weak) EZBaseQueryWindow *window;
#pragma clang diagnostic pop

Ref: stackoverflow.com/a/39918786/8378840

Nope. This is just a small issue and we should fix it easily.

The log message already tells us how to fix it.

/Users/kyle/Github/Easydict/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h:21:48: warning: conflicting nullability specifier on return types, '_Nullable' conflicts with existing specifier 'nonnull' [-Wnullability]
@property (nonatomic, weak) EZBaseQueryWindow *window;
                                               ^
In file included from /Users/kyle/Github/Easydict/Easydict/Feature/PerferenceWindow/EZSettingViewController.m:12:
/Users/kyle/Github/Easydict/Easydict/Feature/Utility/EZCategory/NSViewController+EZWindow.h:15:1: note: previous declaration is here
- (NSWindow *)window;
^
1 warning generated.

weak just infer nullable implicitly. I believe the right fix is to remove NS_ASSUME_NONNULL_BEGIN and NS_ASSUME_NONNULL_END in NSViewController+EZWindow.h or add a nullable mark here(Suggested).

NS_ASSUME_NONNULL_BEGIN

@interface NSViewController (EZWindow)

- (NSWindow *)window;

@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_BEGIN

@interface NSViewController (EZWindow)

-- (NSWindow *)window;
+- (nullable NSWindow *)window;
@end

NS_ASSUME_NONNULL_END

You can just merge the patch here liyafly#1.

@tisfeng
Copy link
Owner

tisfeng commented Jan 9, 2024

Awesome, I thought it was warning me about @property (nonatomic, weak) EZBaseQueryWindow *window;, didn't look at the log details carefully 😥

image image

@liyafly
Copy link
Contributor Author

liyafly commented Jan 9, 2024

It's strange, I've tried a number of ways and none of them work. This is caused by being referenced by a Swift bridge file, and I'm not familiar with Swift.
If there's really no way to fix it, we can just ignore the warning:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability"
@property (nonatomic, weak) EZBaseQueryWindow *window;
#pragma clang diagnostic pop

Ref: stackoverflow.com/a/39918786/8378840

Nope. This is just a small issue and we should fix it easily.

The log message already tells us how to fix it.

/Users/kyle/Github/Easydict/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h:21:48: warning: conflicting nullability specifier on return types, '_Nullable' conflicts with existing specifier 'nonnull' [-Wnullability]
@property (nonatomic, weak) EZBaseQueryWindow *window;
                                               ^
In file included from /Users/kyle/Github/Easydict/Easydict/Feature/PerferenceWindow/EZSettingViewController.m:12:
/Users/kyle/Github/Easydict/Easydict/Feature/Utility/EZCategory/NSViewController+EZWindow.h:15:1: note: previous declaration is here
- (NSWindow *)window;
^
1 warning generated.

weak just infer nullable implicitly. I believe the right fix is to remove NS_ASSUME_NONNULL_BEGIN and NS_ASSUME_NONNULL_END in NSViewController+EZWindow.h or add a nullable mark here(Suggested).

NS_ASSUME_NONNULL_BEGIN

@interface NSViewController (EZWindow)

- (NSWindow *)window;

@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_BEGIN

@interface NSViewController (EZWindow)

-- (NSWindow *)window;
+- (nullable NSWindow *)window;
@end

NS_ASSUME_NONNULL_END

You can just merge the patch here liyafly#1.

Okay, I didn't see the whole log either, but according to you, does this duplicate the attribute definition in the category @tisfeng

@tisfeng
Copy link
Owner

tisfeng commented Jan 9, 2024

No, they are not the same. I didn't notice that they had the same name before. Maybe we can rename the name of window to baseQueryWindow, like this

@property (nonatomic, weak) EZBaseQueryWindow *baseQueryWindow;

@liyafly
Copy link
Contributor Author

liyafly commented Jan 9, 2024

No, they are not the same. I didn't notice that they had the same name before. Maybe we can rename the name of window to baseQueryWindow, like this

@property (nonatomic, weak) EZBaseQueryWindow *baseQueryWindow;

Certainly, I’ll go through everything to ensure that all the renaming is correct

@tisfeng
Copy link
Owner

tisfeng commented Jan 9, 2024

I tried renaming the window to baseQueryWindow and it looks like the warning is resolved?

@liyafly
Copy link
Contributor Author

liyafly commented Jan 9, 2024

Yes, It would be nice to rename it, because weak just infer nullable, and it would be clearer to add nullable, don't you think? @tisfeng

@tisfeng
Copy link
Owner

tisfeng commented Jan 9, 2024

Yes, It would be nice to rename it, because weak just infer nullable, and it would be clearer to add nullable, don't you think? @tisfeng

Yes, I just want to confirm that renaming the property can fix this warning, and also explicitly adding nullable is ok.

@tisfeng
Copy link
Owner

tisfeng commented Jan 13, 2024

I ran the code, and there was no problem.

If there are no other questions, we can continue to review.

@liyafly
Copy link
Contributor Author

liyafly commented Jan 13, 2024

I ran the code, and there was no problem.

If there are no other questions, we can continue to review.

I'm not too familiar with SwiftUI, so feel free to point out any code issues — I'm here to learn. I've tested the features extensively and they seem fine for now. Welcome to review and give feedback!

My English isn't very good, please bear with me.

@tisfeng tisfeng requested review from Kyle-Ye, phlpsong, choykarl and CanglongCl and removed request for phlpsong January 13, 2024 15:17
@tisfeng tisfeng merged commit 39b7730 into tisfeng:dev Jan 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants