iOS/Sources/App/Utilities/Extensions/Array+SafeSubscripting.swift
Fábio Oliveira c49a5b072a
Migrate LocationHistoryList to SwiftUI (#3468)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
In this PR I set to migrate the LocationHistoryList to SwiftUI, to
reduce the dependency in Eureka. This screen was picked at random.

As this screen is presented from two different places, SettingsDetail
and Debug screens, also updated the code in the corresponding classes.

The LocationHistory list reacts to changes.

### LocationHistoryDetail
LocationHistoryDetailViewController also gained a SwiftUI wrapper in
order for it to be presented from the new LocationHistoryListView.
This wrapper syncs the navigation items between the wrapped View
Controller and the parent.
Move functionality also got migrated.

### Misc changes

- Support for M4 added to the Gemfile.lock (added automatically)
- New extension for safe subscripting in arrays added.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
`LocationHistoryList item`
<img width="967" alt="Screenshot 2025-02-27 at 23 39 32"
src="https://github.com/user-attachments/assets/01576ced-ef97-4340-8353-e52a6fd14fac"
/>

`Empty LocationHistoryList`
<img width="955" alt="Screenshot 2025-02-27 at 23 40 56"
src="https://github.com/user-attachments/assets/303ae7c8-5fd6-40c1-87b4-e38098a175ea"
/>
2025-03-17 10:02:08 +01:00

9 lines
177 B
Swift

import Foundation
extension Array {
subscript(safe index: Int) -> Element? {
guard index >= 0, index < count else { return nil }
return self[index]
}
}