Skip to content

Commit

Permalink
alerts in settings added
Browse files Browse the repository at this point in the history
  • Loading branch information
m1rosh committed May 21, 2024
1 parent c4061bf commit 9e7921d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
12 changes: 12 additions & 0 deletions LiveRecipes/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,9 @@
},
"Готово!" : {

},
"Да" : {

},
"Дессерт" : {
"extractionState" : "manual",
Expand Down Expand Up @@ -2955,6 +2958,15 @@
}
}
}
},
"Отмена" : {

},
"Очистить избранное?" : {

},
"Очистить мои рецепты?" : {

},
"Первое блюдо" : {
"extractionState" : "manual",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct StartCookingButton: View {
Spacer()

Button(action: {
//self.presentationMode.wrappedValue.dismiss()

}) {
NavigationLink(destination:{
if openedFromFavorites {
Expand Down
2 changes: 1 addition & 1 deletion LiveRecipes/Modules/Creation/Dish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Dish: Identifiable, Hashable {
var arraySteps: [[String]] = []
for dishStep in dishSteps {
let photoDataStep = dishStep.photo?.jpegData(compressionQuality: 0.4)
let photoDataBase64Step = photoData?.base64EncodedString() ?? ""
let photoDataBase64Step = photoDataStep?.base64EncodedString() ?? ""
arraySteps.append([dishStep.description, photoDataBase64Step, String(dishStep.stepTime)])
}

Expand Down
30 changes: 28 additions & 2 deletions LiveRecipes/Modules/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ struct SettingsView: View {
@StateObject var viewState: SettingsViewModel
@State private var isShowingCreationView = false
@StateObject var creationViewModel = CreationViewModel(creationModel: CreationModel())
@State var isClearMyRecipes = false
@State var isClearFavorites = false

var body: some View {
List {
Expand All @@ -32,20 +34,44 @@ struct SettingsView: View {
}
Section(header: Text("settings.userSettings".localized)) {
Button(action: {
viewState.clearMyRecipes()
isClearMyRecipes = true
})
{
Text("settings.clearMyRecipes".localized)
.tint(Color(uiColor: .label))
}.alert(isPresented: $isClearMyRecipes) {
Alert(title: Text("Очистить мои рецепты?"), primaryButton: .default(Text("Да")){
viewState.clearMyRecipes()
isClearMyRecipes = false
}, secondaryButton: .default(Text("Отмена")) {
isClearMyRecipes = false
})
}

Button(action: {
viewState.clearFavorites()
isClearFavorites = true
//viewState.clearMyRecipes()
})
{
Text("settings.clearFavourites".localized)
.tint(Color(uiColor: .label))
}.alert(isPresented: $isClearFavorites) {
Alert(title: Text("Очистить избранное?"), primaryButton: .default(Text("Да")){
viewState.clearFavorites()
isClearFavorites = false
}, secondaryButton: .default(Text("Отмена")) {
isClearFavorites = false
})
}


// Button(action: {
// viewState.clearFavorites()
// })
// {
// Text("settings.clearFavourites".localized)
// .tint(Color(uiColor: .label))
// }
Button(action: {
viewState.clearRecents()
})
Expand Down

0 comments on commit 9e7921d

Please sign in to comment.