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

fix: service toggle selection issue #390

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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