Skip to content

Commit f19fbda

Browse files
committed
feat: enhance MainVC layout handling and improve footer management; update localization handling in CrowdinSDK
1 parent 09078de commit f19fbda

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

Example/AppleReminders/Controllers/MainVC.swift

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import UIKit
1212

1313
final class MainVC: UIViewController {
1414
private let footerHeight: CGFloat = 75
15+
private let footerInsetPadding: CGFloat = 12
1516

1617
let realm = MyRealm.getConfig()
1718

@@ -81,9 +82,23 @@ final class MainVC: UIViewController {
8182
}
8283
}
8384

85+
deinit {
86+
realmListToken?.invalidate()
87+
print("MainVC deinit")
88+
}
89+
90+
override func viewDidLayoutSubviews() {
91+
super.viewDidLayoutSubviews()
92+
layoutTableHeaderIfNeeded()
93+
updateTableInsetsForFooter()
94+
}
95+
8496
override func viewWillAppear(_ animated: Bool) {
8597
super.viewWillAppear(animated)
8698

99+
// Keep the footer controls above any table/search content.
100+
view.bringSubviewToFront(footerView)
101+
87102
realmListToken = realm?.objects(ReminderList.self).observe { [weak self] changes in
88103
guard let self = self else { return }
89104
switch changes {
@@ -102,19 +117,6 @@ final class MainVC: UIViewController {
102117
setupNavBar()
103118
setupSearch()
104119
}
105-
106-
override func viewDidLayoutSubviews() {
107-
super.viewDidLayoutSubviews()
108-
layoutTableHeaderIfNeeded()
109-
// Keep the footer controls above any table/search content after layout updates.
110-
view.bringSubviewToFront(footerView)
111-
updateTableInsetsForFooter()
112-
}
113-
114-
deinit {
115-
realmListToken?.invalidate()
116-
print("MainVC deinit")
117-
}
118120

119121
private func setupTableView() {
120122
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "BlankTVCell")
@@ -171,7 +173,7 @@ final class MainVC: UIViewController {
171173
private func updateTableInsetsForFooter() {
172174
// Compute real overlap between the table and footer to avoid rows appearing under controls.
173175
let overlap = max(0, tableView.frame.maxY - footerView.frame.minY)
174-
let bottomInset = overlap + 12
176+
let bottomInset = overlap + footerInsetPadding
175177
if tableView.contentInset.bottom != bottomInset {
176178
tableView.contentInset.bottom = bottomInset
177179
tableView.scrollIndicatorInsets.bottom = bottomInset
@@ -207,6 +209,9 @@ final class MainVC: UIViewController {
207209
searchController?.hidesNavigationBarDuringPresentation = false
208210
searchController?.searchBar.placeholder = "Search".localized
209211
searchController?.searchBar.sizeToFit()
212+
// Intentionally attach the search bar to the table view header instead of navigationItem.searchController.
213+
// This keeps the search UI visually tied to this table view and working even when this VC is not embedded
214+
// in a navigation controller using large titles.
210215
tableView.tableHeaderView = searchController?.searchBar
211216
definesPresentationContext = true
212217
}

Example/AppleReminders/Controllers/SettingsVC.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class SettingsVC: UITableViewController {
104104
private func setLocalizationLoading(_ loading: Bool) {
105105
isLocalizationLoading = loading
106106
tableView.allowsSelection = !loading
107-
tableView.isUserInteractionEnabled = !loading
108107
navigationItem.rightBarButtonItem?.isEnabled = !loading
109108

110109
if loading {

Sources/CrowdinSDK/CrowdinSDK/CrowdinSDK.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public typealias CrowdinSDKLogMessage = (String) -> Void
2929
public var onLogCallback: ((String) -> Void)?
3030

3131
/// Current localization language code. If SDK is started than after setting new localization it triggers localization download.
32+
///
33+
/// - Note: Deprecated. Use ``setCurrentLocalization(_:completion:)`` instead for async operation with completion handler.
3234
@available(*, deprecated, message: "Please use setCurrentLocalization(_:completion:) to update localization.")
3335
public class var currentLocalization: String? {
3436
get {

Sources/CrowdinSDK/Features/RealtimeUpdateFeature/RealtimeUpdateFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RealtimeUpdateFeature: RealtimeUpdateFeatureProtocol {
3434
var disconnect: (() -> Void)?
3535
var localization: String {
3636
let localizations = Localization.current.provider.remoteStorage.localizations
37-
return Localization.currentLocalization ?? Localization.current?.provider.localization ?? Bundle.main.preferredLanguage(with: localizations)
37+
return Localization.currentLocalization ?? Bundle.main.preferredLanguage(with: localizations)
3838
}
3939
let hashString: String
4040
let sourceLanguage: String

Sources/CrowdinSDK/Providers/Crowdin/Extensions/CrowdinSDK+CrowdinProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension CrowdinSDK {
2727
public class func startWithConfig(_ config: CrowdinSDKConfig, completion: @escaping () -> Void) {
2828
self.config = config
2929
let crowdinProviderConfig = config.crowdinProviderConfig ?? CrowdinProviderConfig()
30-
let localization = Localization.currentLocalization ?? Bundle.main.preferredLanguage
30+
let localization = Localization.currentLocalization ?? Localization.current?.provider.localization ?? Bundle.main.preferredLanguage
3131
let remoteStorage = CrowdinRemoteLocalizationStorage(localization: localization, config: crowdinProviderConfig)
3232
self.startWithRemoteStorage(remoteStorage, completion: completion)
3333
}

0 commit comments

Comments
 (0)