From 5b31ce41b73882e33bc43252846c7ebb3fd3d0de Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Sun, 14 Jan 2024 21:56:30 -0800 Subject: [PATCH] fix: cannot move and scroll position error --- .../View/SettingView/Tabs/ServiceTab.swift | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift b/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift index 296d6147e..80e2a6e3f 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift @@ -61,9 +61,6 @@ struct ServiceTab: View { } .frame(minWidth: 500) } - .onChange(of: windowType) { _ in - selectedService = nil - } } } @@ -78,7 +75,7 @@ private struct ServiceItems: View { private var servicesWithID: [(QueryService, String)] { services.map { service in - (service, "\(service.name())\(windowType)") + (service, service.name()) } } @@ -137,22 +134,17 @@ private struct ServiceItemView: View { .frame(width: 20.0, height: 20.0) Text(service.inner.name()) } - .onTapGesture { - selectedService = service.inner - } } .padding(4.0) .toggleStyle(.switch) .controlSize(.small) .listRowSeparator(.hidden) - .listRowBackground(selectedService == service.inner ? Color("service_cell_highlight") : tableColor) .listRowInsets(.init()) .padding(10) - .background { - if selectedService != service.inner { - tableColor.onTapGesture { - selectedService = service.inner - } + .listRowBackground(selectedService == service.inner ? Color("service_cell_highlight") : tableColor) + .overlay { + TapHandler { + selectedService = service.inner } } }