diff --git a/VGApp/Tabs/ItemsList/ItemView.swift b/VGApp/Tabs/ItemsList/ItemView.swift index ab7a56a..0a14b07 100644 --- a/VGApp/Tabs/ItemsList/ItemView.swift +++ b/VGApp/Tabs/ItemsList/ItemView.swift @@ -156,35 +156,56 @@ struct Itemview: View { } func newRecycleView() -> some View { - VStack { - Text("newRecycle_title").font(.title) - .padding(.bottom, 20) - .padding(.top, 20) - - HStack { - Button("-") { - if vm.recycleCount > 1 { - vm.recycleCount -= 1 - } - }.buttonStyle(RecycleButtonStyle()).disabled(vm.recycleCount <= 1) - Text(String(vm.recycleCount)).frame(minWidth: 60) - Button("+") { - vm.recycleCount += 1 - }.buttonStyle(RecycleButtonStyle()) + NavigationView(content: { + VStack { + HStack { + Button("-") { + if vm.recycleCount > 1 { + vm.recycleCount -= 1 + } + }.buttonStyle(RecycleButtonStyle()).disabled(vm.recycleCount <= 1) + Text(String(vm.recycleCount)).frame(minWidth: 60) + Button("+") { + vm.recycleCount += 1 + }.buttonStyle(RecycleButtonStyle()) + }.padding(.top, 20) + + Spacer() + + ForEach(Array(vm.typeArr.enumerated()), id: \.offset) { _, type in + Button { + vm.addRecyle(type) + } label: { + HStack { + IconManager.get_recycle_image(type) + .resizable() + .frame(width: 15, height: 15) + .colorMultiply(.gray) + + Text(Util.recTypeName(type)) + .frame(height: 15) + .frame(maxWidth: .infinity) + } + }.buttonStyle(RecycleOptionButtonStyle()) + } + .frame(maxWidth: .infinity) + navigationStyling("newRecycle_title".localized) } - + .padding() + }) + } + + @ViewBuilder + func navigationStyling(_ title: String) -> some View { + if #available(iOS 16.0, *) { Spacer() - - ForEach(Array(vm.typeArr.enumerated()), id: \.offset) { _, type in - Button { - vm.addRecyle(type) - } label: { - Text(Util.recTypeName(type)).frame(maxWidth: .infinity) - }.buttonStyle(RecycleOptionButtonStyle()) - } - .padding(.bottom, 30).frame(maxWidth: .infinity) + .navigationTitle(title) + .toolbarBackground( + Color.accentColor, for: .navigationBar) + .toolbarBackground(.visible, for: .navigationBar) + } else { Spacer() + .navigationTitle(title) } - .padding() } } diff --git a/VGApp/Tabs/ItemsList/ItemViewmodel.swift b/VGApp/Tabs/ItemsList/ItemViewmodel.swift index 30e32e1..31d9914 100644 --- a/VGApp/Tabs/ItemsList/ItemViewmodel.swift +++ b/VGApp/Tabs/ItemsList/ItemViewmodel.swift @@ -102,7 +102,6 @@ class ItemViewmodel: ObservableObject { recycleCount = 1 Util.save() withAnimation { showsSheet = false } - // updateViews() setUsedRecyleTypesArr() } diff --git a/VGApp/Util/IconManager.swift b/VGApp/Util/IconManager.swift index 96ffd88..8c1bd42 100644 --- a/VGApp/Util/IconManager.swift +++ b/VGApp/Util/IconManager.swift @@ -89,4 +89,22 @@ struct IconManager { return getIcon("crate") } } + + static func get_recycle_image(_ type: RecycleTypes) -> Image { + var img: Image? + + switch type { + case .yoghurtglass: + img = icons["yogurt"] + case .bottle: + img = icons["glass"] + case .crate: + img = icons["crate"] + } + + guard let img = img else { + return Image(systemName: "questionmark.diamond") + } + return img + } }