From 5040e6dae9b76a1e41fc6998ce4e08202198a3c1 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Sun, 3 Jul 2022 18:53:14 +0200 Subject: [PATCH] Dropdown picker more user-friendly --- .gitlab-ci.yml | 1 + Classes/Swift/Voip/Widgets/StyledValuePicker.swift | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3fbfa5902..2d857c68b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ job-ios: script: - pod install --repo-update - pwd + - sed 's/fileprivate let tableView =/public let tableView =/g' ./Pods/DropDown/DropDown/src/DropDown.swift > tmp.swift && mv -f tmp.swift ./Pods/DropDown/DropDown/src/DropDown.swift - xcodebuild archive -scheme $archive_scheme -archivePath ./$archive_path -configuration Release -workspace ./linphone.xcworkspace -UseModernBuildSystem=YES -destination 'generic/platform=iOS' - xcodebuild -exportArchive -archivePath ./$archive_path -exportPath ./$export_path -exportOptionsPlist ./$export_options_plist -allowProvisioningUpdates -UseModernBuildSystem=YES -destination 'generic/platform=iOS' diff --git a/Classes/Swift/Voip/Widgets/StyledValuePicker.swift b/Classes/Swift/Voip/Widgets/StyledValuePicker.swift index e13a9117e..979e61c30 100644 --- a/Classes/Swift/Voip/Widgets/StyledValuePicker.swift +++ b/Classes/Swift/Voip/Widgets/StyledValuePicker.swift @@ -27,6 +27,7 @@ class StyledValuePicker: UIView { // layout constants let chevron_margin = 10.0 let form_input_height = 38.0 + let dropdown_width = 250.0 let dropDown = DropDown() @@ -73,16 +74,18 @@ class StyledValuePicker: UIView { dropDown.bottomOffset = CGPoint(x: 0, y:(dropDown.anchorView?.plainView.bounds.height)!) dropDown.dataSource = options dropDown.backgroundColor = .white + dropDown.width = dropdown_width dropDown.selectionAction = { [unowned self] (index: Int, item: String) in liveIndex.value = index dropDown.selectRow(at: index) - //dropDown.tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true) formattedLabel.text = " "+options[liveIndex.value!] dropDown.hide() } - + onClick { + self.dropDown.anchorView = self.superview + self.dropDown.tableView.scrollToRow(at: IndexPath(row: liveIndex.value!, section: 0), at: .top, animated: true) // Change visibility to public instead of fileprivate in DropDown.swift self.dropDown.show() }