-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Description Fixes GitHub issue #184 - CategoriesFavoritesSegmentControl was missing Right-to-Left language support - Tested with Right-to-left pseudo language - Add PreviewCategoriesFavoritesSegmentControl.swift to fix previews in Xcode 14 - Fix xib errors for CategoriesFavoritesSegmentControl ### Checklist - [x] Update `CHANGELOG` ### Screenshots ##### Xcode Right-to-left pseudo language Edit Scheme > App language > change to Right-to-left pseudolanguage <img width="942" alt="Screenshot 2024-03-19 at 17 42 58" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/10ecfadf-e26b-48b1-9275-3f399d67c304"> ##### Updated behavior | Left-to-right | Right-to-left | | -- | -- | | ![Simulator Screen Recording - iPhone 15 Pro - 2024-03-19 at 17 44 13](https://github.com/mapbox/mapbox-search-ios/assets/384288/b3254b52-8127-4e2e-92a5-a3b207d1f3f0) | ![Simulator Screen Recording - iPhone 15 Pro - 2024-03-19 at 17 44 50](https://github.com/mapbox/mapbox-search-ios/assets/384288/d0225339-5888-467a-9dcf-5401445ff240) | ###### SwiftUI Previews <img width="1677" alt="Screenshot 2024-03-20 at 13 18 34" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/d8e4ddfa-c4bc-45b5-9d30-7002bd180c27"> <img width="1677" alt="Screenshot 2024-03-20 at 13 18 31" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/35d4cecb-4329-47f7-bf28-41384d8c723c"> <img width="1677" alt="Screenshot 2024-03-20 at 13 18 29" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/21b6db61-335d-417d-8930-ba595d90683f"> ###### Right to Left behavior | With Results | Dark mode categories | Dark mode favorites | | -- | -- | -- | | ![Simulator Screenshot - iPhone 15 Pro - 2024-03-20 at 13 20 33](https://github.com/mapbox/mapbox-search-ios/assets/384288/9ecf021c-cab3-4847-93b9-b61adb7a9d8a) | ![Simulator Screenshot - iPhone 15 Pro - 2024-03-20 at 13 22 37](https://github.com/mapbox/mapbox-search-ios/assets/384288/0f976a7e-a9d3-46e5-b00d-95f8fac06aaa) | ![Simulator Screenshot - iPhone 15 Pro - 2024-03-20 at 13 22 39](https://github.com/mapbox/mapbox-search-ios/assets/384288/736355eb-2892-42a8-b3bc-1eaecf4f5ae4) |
- Loading branch information
Showing
6 changed files
with
129 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
45 changes: 45 additions & 0 deletions
45
Sources/MapboxSearchUI/PreviewCategoriesFavoritesSegmentControl.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright © 2024 Mapbox. All rights reserved. | ||
|
||
import Foundation | ||
|
||
#if canImport(SwiftUI) && DEBUG | ||
import SwiftUI | ||
|
||
@available(iOS 13.0, *) | ||
struct TabsSegmentControlRepresentable: UIViewRepresentable { | ||
func makeUIView(context: Context) -> UIView { | ||
let segmentControl: CategoriesFavoritesSegmentControl = UINib( | ||
nibName: "CategoriesFavoritesSegmentControl", | ||
bundle: .mapboxSearchUI | ||
) | ||
.instantiate(withOwner: nil, options: nil)[0] as! CategoriesFavoritesSegmentControl | ||
// swiftlint:disable:previous force_cast | ||
|
||
segmentControl.configuration = Configuration() | ||
|
||
return segmentControl | ||
} | ||
|
||
func updateUIView(_ view: UIView, context: Context) {} | ||
} | ||
|
||
@available(iOS 13.0, *) | ||
struct CategoriesFavoritesSegmentControlPreview: PreviewProvider { | ||
static var previews: some View { | ||
Group { | ||
TabsSegmentControlRepresentable() | ||
.previewDisplayName("Light Mode") | ||
.previewLayout(PreviewLayout.fixed(width: 202, height: 28)) | ||
TabsSegmentControlRepresentable() | ||
.previewDisplayName("Dark Mode") | ||
.preferredColorScheme(.dark) | ||
.previewLayout(PreviewLayout.fixed(width: 202, height: 28)) | ||
.previewLayout(.sizeThatFits) | ||
TabsSegmentControlRepresentable() | ||
.previewDisplayName("Right to Left") | ||
.previewLayout(PreviewLayout.fixed(width: 202, height: 28)) | ||
.environment(\.layoutDirection, .rightToLeft) | ||
} | ||
} | ||
} | ||
#endif |
This file contains 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
This file contains 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