Skip to content

Commit

Permalink
fix: use default List selection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Feb 6, 2024
1 parent ff9268d commit e024d4a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.

This file was deleted.

27 changes: 1 addition & 26 deletions Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,20 @@ import SwiftUI
struct ServiceTab: View {
@StateObject private var viewModel: ServiceTabViewModel = .init()

@Environment(\.colorScheme) private var colorScheme

var bgColor: Color {
Color(nsColor: colorScheme == .light ? .windowBackgroundColor : .controlBackgroundColor)
}

var tableColor: Color {
Color(nsColor: colorScheme == .light ? .ez_tableRowViewBgLight() : .ez_tableRowViewBgDark())
}

var body: some View {
HStack {
VStack {
WindowTypePicker(windowType: $viewModel.windowType)
.padding()
List {
List(selection: $viewModel.selectedService) {
ServiceItems()
}
.scrollContentBackground(.hidden)
.listStyle(.plain)
.scrollIndicators(.never)
.clipShape(RoundedRectangle(cornerRadius: 10))
.background(bgColor, in: RoundedRectangle(cornerRadius: 10))
.padding(.bottom)
.padding(.horizontal)
}
.background(bgColor)
Group {
if let service = viewModel.selectedService {
// To provide configuration options for a service, follow these steps
Expand Down Expand Up @@ -172,18 +159,6 @@ private struct ServiceItemView: View {
.listRowSeparator(.hidden)
.listRowInsets(.init())
.padding(10)
.listRowBackground(viewModel.selectedService == service ? Color("service_cell_highlight_color") : tableColor)
.overlay {
TapHandler {
viewModel.selectedService = service
}
}
}

@Environment(\.colorScheme) private var colorScheme

private var tableColor: Color {
Color(nsColor: colorScheme == .light ? .ez_tableRowViewBgLight() : .ez_tableRowViewBgDark())
}
}

Expand Down

0 comments on commit e024d4a

Please sign in to comment.