Skip to content
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
8 changes: 6 additions & 2 deletions WaiterRobot/Features/Order/OrderScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import WRCore
struct OrderScreen: View {
@EnvironmentObject var navigator: UIPilot<Screen>

@State private var showProductSearch: Bool
@State private var showProductSearch: Bool = false
@State private var showAbortOrderConfirmationDialog = false

@StateObject private var viewModel: ObservableOrderViewModel
private let table: shared.Table
private let initialItemId: KotlinLong?

init(table: shared.Table, initialItemId: KotlinLong?) {
self.table = table
_viewModel = StateObject(wrappedValue: ObservableOrderViewModel(table: table, initialItemId: initialItemId))
showProductSearch = initialItemId == nil ? true : false
self.initialItemId = initialItemId

UIToolbar.appearance().barTintColor = UIColor.systemBackground // Background color
UIToolbar.appearance().tintColor = UIColor.blue // Tint color of buttons
Expand Down Expand Up @@ -46,6 +47,9 @@ struct OrderScreen: View {
}
.animation(.default, value: viewModel.state.currentOrder)
.withViewModel(viewModel, navigator)
.onAppear {
showProductSearch = initialItemId == nil ? true : false
}
}

@ViewBuilder
Expand Down
2 changes: 1 addition & 1 deletion WaiterRobot/Features/Order/Search/ProductSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ProductSearch: View {
}
)
.searchable(text: $search, placement: .navigationBarDrawer(displayMode: .always))
.onChange(of: search, perform: { viewModel.actual.filterProducts(filter: $0) })
.onChange(of: search) { viewModel.actual.filterProducts(filter: search) }
}
}
}
Expand Down