This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Privacy Policy for QueryPeeler | |
QueryPeeler does not collect, store, or transmit any personal data. | |
The app runs entirely on your device and does not send any information to external servers. It does not collect analytics, track user behaviour, or access sensitive information. | |
If you have any concerns, please contact [email protected]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func monitorChanges() async throws { | |
let stream = makeStream() | |
for try await status in stream { | |
self.status = status | |
} | |
} | |
private func makeStream() -> AsyncThrowingStream<Status, Error> { | |
AsyncThrowingStream { continuation in | |
let monitor = NWPathMonitor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ReportStore where Report: Identifiable { | |
func binding(for report: Report) -> Binding<Report> { | |
let index = fetchedItems.firstIndex(where: { $0.id == report.id } )! | |
return Binding( | |
get: { self.fetchedItems[index] }, | |
set: { self.fetchedItems[index] = $0 } | |
) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MenuViewController: UIViewController { | |
let table = MenuTableHandler() | |
var categories: [MenuCategory] = [] | |
var selections = Set<MenuItem>() | |
fileprivate var searchText: String? { | |
didSet { | |
if oldValue == searchText { return } | |
categories = MenuOption.allCases.map { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MenuViewController: UITableViewDelegate { | |
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
table.reloadItem(at: indexPath, save: { (item) in | |
switch selections.contains(item) { | |
case true: selections.remove(item) | |
case false: selections.insert(item) | |
} | |
}, animate: false) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toggleSelectedStateOfItem(at indexPath: IndexPath) { | |
let item = dataSource.itemIdentifier(for: indexPath)! | |
var snapshot = dataSource.snapshot() | |
item.isSelected = !item.isSelected | |
snapshot.reloadItems([item]) | |
dataSource.apply(snapshot) | |
} | |
let cellProvider: CellProvider = { (tableView, indexPath, item) -> UITableViewCell? in | |
let cell = tableView.dequeueReusableCell( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MenuItem: Hashable, Comparable { | |
func hash(into hasher: inout Hasher) { | |
hasher.combine(name) | |
} | |
} | |
extension MenuItem: Comparable { | |
static func <(lhs: MenuItem, rhs: MenuItem) -> Bool { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private typealias CellProvider = (UITableView, IndexPath, MenuItem) -> UITableViewCell? | |
private let cellProvider: CellProvider = { (tableView, indexPath, item) -> UITableViewCell? in | |
let cell = tableView.dequeueReusableCell( | |
withIdentifier: MenuItemTableViewCell.identifier, | |
for: indexPath) as! MenuItemTableViewCell | |
cell.accessoryType = item.isSelected ? .checkmark : .none | |
cell.textLabel?.text = item.name | |
return cell | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MenuCategory { | |
let name: String | |
let description: String? | |
let items: Set<MenuItem> | |
} | |
struct MenuItem { | |
let name: String | |
let description: String | |
let category: MenuCategory |