Skip to content

Commit

Permalink
Disable unregistration on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
liang2kl committed May 4, 2021
1 parent 8e1576b commit ce3dfc4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Source/Hollow/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
}

#if targetEnvironment(macCatalyst)
override func buildMenu(with builder: UIMenuBuilder) {
builder.remove(menu: .file)
builder.remove(menu: .edit)
builder.remove(menu: .format)
builder.remove(menu: .help)
builder.remove(menu: .services)
builder.remove(menu: .toolbar)
}
#endif
}
2 changes: 2 additions & 0 deletions Source/Hollow/View/Hierarchy/Account/AccountInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ struct AccountInfoView: View {
destination: ChangePasswordView().environmentObject(viewModel)
)

#if !targetEnvironment(macCatalyst)
NavigationLink(NSLocalizedString("LOGINVIEW_RESTORE_PASSWORD_ALERT_UNREGISTER_BUTTON", comment: ""), destination: UnregisterView())
#endif
}

Section {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct HollowCommentContentView: View {
static let avatarWidth: CGFloat = 45
static let avatarProportion: CGFloat = 0.7

@ScaledMetric(wrappedValue: 50, relativeTo: .body) var labelWidth: CGFloat
@ScaledMetric(wrappedValue: UIDevice.isPad ? 60 : 50, relativeTo: .body) var labelWidth: CGFloat
@ScaledMetric(wrappedValue: avatarWidth, relativeTo: .body) var body45: CGFloat
@ScaledMetric(wrappedValue: 5, relativeTo: .body) var body5: CGFloat
@ScaledMetric(wrappedValue: 4, relativeTo: .body) var body4: CGFloat
Expand All @@ -34,6 +34,17 @@ struct HollowCommentContentView: View {
@Environment(\.colorScheme) var colorScheme

var body: some View {
// View created by view builder in macOS is HStack by default, so
// we can only explictly wrap them inside a VStack. The scrolling
// issue does not appear on macOS so this trick is OK.
#if targetEnvironment(macCatalyst)
VStack(spacing: 0) { content }
#else
content
#endif
}

@ViewBuilder var content: some View {
if let padding = contentVerticalPadding {
Spacer(minLength: padding)
.fixedSize()
Expand Down
6 changes: 6 additions & 0 deletions Source/Hollow/View/Hierarchy/Login/UnregisterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ struct UnregisterView: View {

var body: some View {
VStack(spacing: 0) {
#if targetEnvironment(macCatalyst)
Text("UNREGISTERVIEW_NOT_SUPPORT_MAC_NOTICE")
.horizontalCenter()
.verticalCenter()
#else
ScrollView(showsIndicators: false) {
VStack(spacing: ViewConstants.listVStackSpacing) {
MyTextField<EmptyView>(
Expand Down Expand Up @@ -80,6 +85,7 @@ struct UnregisterView: View {
text: buttonText
)
.disabled(disableButton)
#endif
}
.padding(.horizontal)
.padding(.horizontal)
Expand Down
2 changes: 2 additions & 0 deletions Source/Hollow/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@

"UNREGISTERVIEW_BUTTON_UNREGISTER" = "Unregister";

"UNREGISTERVIEW_NOT_SUPPORT_MAC_NOTICE" = "Unregistering is not support on macOS.";

/* No comment provided by engineer. */
"LOGINVIEW_RESTORE_PASSWORD_ALERT_TITLE" = "Restore Password";

Expand Down
2 changes: 2 additions & 0 deletions Source/Hollow/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@

"UNREGISTERVIEW_BUTTON_UNREGISTER" = "注销";

"UNREGISTERVIEW_NOT_SUPPORT_MAC_NOTICE" = "注销账户在macOS上暂时不支持。";

/* No comment provided by engineer. */
"LOGINVIEW_RESTORE_PASSWORD_ALERT_TITLE" = "重置密码";

Expand Down

0 comments on commit ce3dfc4

Please sign in to comment.