Skip to content

Commit

Permalink
delete change theme in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DenAlNik committed May 21, 2024
1 parent 9e7921d commit eef2add
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 173 deletions.
2 changes: 1 addition & 1 deletion LiveRecipes/Modules/Recipes/FiltersView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct FiltersView: View {
Image(systemName: "xmark")
.imageScale(.small)
.fontWeight(.semibold)
.foregroundStyle(Color(red: 0.2353, green: 0.2353, blue: 0.2627, opacity: 0.6))
.foregroundStyle(Color(red: 0.2353, green: 0.2353, blue: 0.2627, opacity: 1))
}
.frame(width: 30, height: 30)
.background(Color(UIColor.secondarySystemBackground))
Expand Down
143 changes: 1 addition & 142 deletions LiveRecipes/Modules/Recipes/KeyWordsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,6 @@

import SwiftUI

//struct KeyWordsView: View {
// @Environment(\.presentationMode) var presentationMode
// @StateObject var viewModel: RecipesViewModel
// @State private var searchText = ""
//
// var body: some View {
// NavigationView {
// keyWordsViewContent()
// .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))
// .navigationTitle("keywords.title".localized)
// .navigationBarTitleDisplayMode(.inline)
// .toolbar {
// ToolbarItem(placement: .topBarTrailing) {
// Button {
// self.presentationMode.wrappedValue.dismiss()
// viewModel.sortKeyWordsByChoose()
// } label: {
// VStack {
// Image(systemName: "xmark")
// .imageScale(.small)
// .fontWeight(.semibold)
// .foregroundStyle(Color(red: 0.2353, green: 0.2353, blue: 0.2627, opacity: 0.6))
// }
// .frame(width: 30, height: 30)
// .background(Color(UIColor.secondarySystemBackground))
// .clipShape(.circle)
// }
// }
// }
// }
// }
//
// @ViewBuilder
// func keyWordsViewContent() -> some View {
// if (viewModel.keyWords.isEmpty) {
// Text("keywords.error.message".localized)
// } else {
// ScrollView {
// LazyVGrid(columns: [GridItem(), GridItem(), GridItem()],
// content: {
// ForEach (viewModel.keyWords.indices, id: \.self) { index in
// VStack {
// Button(action: {
// viewModel.keyWords[index].choose()
// }, label: {
// Text(viewModel.keyWords[index].keyWord)
// .tint(viewModel.keyWords[index].isChoosed ? .white : .black)
// .font(.caption)
// .padding(8)
// .background(Color(viewModel.keyWords[index].isChoosed ? UIColor.orange : UIColor.secondarySystemBackground))
// .clipShape(.capsule)
// })
// }
// }
// })
// }
// .overlay(
// Button {
// self.presentationMode.wrappedValue.dismiss()
// viewModel.sortKeyWordsByChoose()
// } label: {
// HStack {
// Image(systemName: "magnifyingglass")
// .imageScale(.medium)
// Text("keywords.search.button".localized)
// }
// .tint(.white)
// .fontWeight(.semibold)
// }
// .frame(width: 200, height: 50)
// .background(.orange, in: .rect(cornerRadius: 14)),
// alignment: .bottom
// )
// }
// }
//}



struct KeyWordsView: View {
@Environment(\.presentationMode) var presentationMode
Expand All @@ -107,7 +29,7 @@ struct KeyWordsView: View {
Image(systemName: "xmark")
.imageScale(.small)
.fontWeight(.semibold)
.foregroundStyle(Color(red: 0.2353, green: 0.2353, blue: 0.2627, opacity: 0.6))
.foregroundStyle(Color(red: 0.2353, green: 0.2353, blue: 0.2627, opacity: 1))
}
.frame(width: 30, height: 30)
.background(Color(UIColor.secondarySystemBackground))
Expand Down Expand Up @@ -165,66 +87,3 @@ struct KeyWordsView: View {
}
}
}


//пытался сделать нормально, не через LazyVGrid

// LazyVStack {
// GeometryReader { proxy in
// var width = UIScreen.main.bounds.size.width
// var height = UIScreen.main.bounds.size.height
// ZStack(alignment: .topLeading) {
// ForEach (viewModel.keyWords.indices, id: \.self) { index in
// VStack {
// Button(action: {
// viewModel.keyWords[index].choose()
// }, label: {
// Text(viewModel.keyWords[index].keyWord)
// .tint(viewModel.keyWords[index].isChoosed ? .white : .black)
// .font(.caption)
// .padding(8)
// .background(Color(viewModel.keyWords[index].isChoosed ? UIColor.orange : UIColor.secondarySystemBackground))
// .clipShape(.capsule)
// })
// .padding(4)
// }
// .alignmentGuide(.top, computeValue: {d in
// let result = height
// if index == viewModel.keyWords.endIndex {
// height = 0
// }
// return result
// })
// .alignmentGuide(.leading, computeValue: { d in
// if (abs(width - d.width) > proxy.size.width - 24)
// {
// width = 0
// height -= d.height
// }
// let result = width
// if index == viewModel.keyWords.endIndex {
// width = 0
// } else {
// width -= d.width
// }
// return result
// })
//
// .padding(.horizontal, 8)
// }
// }
// }
// }
// }
// .scrollIndicators(.hidden)
// }
// }
//
// private func viewHeightReader(_ binding: Binding<CGFloat>) -> some View {
// return GeometryReader { geometry -> Color in
// let rect = geometry.frame(in: .local)
// DispatchQueue.main.async {
// binding.wrappedValue = rect.size.height
// }
// return .clear
// }
16 changes: 0 additions & 16 deletions LiveRecipes/Modules/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ struct SettingsView: View {

var body: some View {
List {
Section {
Picker(selection: $viewState.selectedSegment, label: Text("Select a segment")) {
ForEach(0..<viewState.segments.count) { index in
Text(viewState.segments[index]).tag(index)
}
}
.pickerStyle(.segmented)
.frame(width: 350)
.listRowBackground(Color.clear)
.onChange(of: viewState.selectedSegment) { _, _ in
viewState.changeTheme()
}
.preferredColorScheme(viewState.colorScheme)
} header: {
Text("theme.settings".localized)
}
Section(header: Text("settings.userSettings".localized)) {
Button(action: {
isClearMyRecipes = true
Expand Down
15 changes: 1 addition & 14 deletions LiveRecipes/Modules/Settings/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SettingsViewModel: ObservableObject, SettingsViewModelProtocol {

let segments = ["light.theme".localized, "system.theme".localized, "dark.theme".localized]
@Published var selectedSegment = 1
@Published var colorScheme: ColorScheme?
// @Published var colorScheme: ColorScheme?

init(settingsModel: SettingsModelProtocol) {
self.model = settingsModel
Expand Down Expand Up @@ -45,17 +45,4 @@ final class SettingsViewModel: ObservableObject, SettingsViewModelProtocol {
}
}
}
func changeTheme() {
switch selectedSegment {
case 0:
colorScheme = .light
case 1:
colorScheme = nil
case 2:
colorScheme = .dark
default:
break
}
print(segments[selectedSegment])
}
}

0 comments on commit eef2add

Please sign in to comment.