Skip to content

Commit

Permalink
[PBIOS-591] Fix popover closing on scroll (#469)
Browse files Browse the repository at this point in the history
**What does this PR do?** A clear and concise description with your
runway ticket url.
I want the typeahead popover to remain open when scrolling to dismiss
the keyboard,
So that I can continue interacting with the typeahead options without
losing the popover.

https://runway.powerhrg.com/backlog_items/PBIOS-591

**Screenshots:** Screenshots to visualize your addition/change


**How to test?** Steps to confirm the desired behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See addition/change

### Checklist
- [ ] **LABELS** - Add a label: `breaking`, `bug`, `improvement`,
`documentation`, or `enhancement`. See
[Labels](https://github.com/powerhome/playbook-apple/labels) for
descriptions.
- [ ] **RELEASES** - Add the appropriate label: `Ready for Testing` /
`Ready for Release`
- [ ] **TESTING** - Have you tested your story?

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
isismsilva and renovate[bot] authored Nov 22, 2024
1 parent d472031 commit ee531a2
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 127 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/nicklockwood/SwiftFormat
rev: 0.53.5
rev: 0.54.6
hooks:
- id: swiftformat
- repo: https://github.com/realm/SwiftLint
rev: 0.54.0
rev: 0.57.0
hooks:
- id: swiftlint
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.3.0
ruby 3.3.6
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "fastlane", "~> 2.219.0"
gem "json", "~> 2.7.0"
gem "fastlane", "~> 2.225.0"
gem "json", "~> 2.8.0"
gem 'httparty'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
Expand Down
119 changes: 65 additions & 54 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
artifactory (3.0.15)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.876.0)
aws-sdk-core (3.190.1)
aws-partitions (1.1006.0)
aws-sdk-core (3.212.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.75.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.142.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-kms (1.95.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.170.1)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
bigdecimal (3.1.8)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
csv (0.1.0)
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.108.0)
faraday (1.10.3)
excon (0.112.0)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -57,22 +62,22 @@ GEM
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.0)
fastlane (2.219.0)
fastimage (2.3.1)
fastlane (2.225.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored
colored (~> 1.2)
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
Expand All @@ -81,6 +86,7 @@ GEM
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
Expand All @@ -93,10 +99,10 @@ GEM
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (>= 0.1.1)
optparse (>= 0.1.1, < 1.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
Expand All @@ -105,37 +111,38 @@ GEM
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-appcenter (2.1.2)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.45.0)
google-cloud-errors (1.4.0)
google-cloud-storage (1.47.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.29.0)
google-apis-storage_v1 (~> 0.31.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
Expand All @@ -146,45 +153,50 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.5)
http-cookie (1.0.7)
domain_name (~> 0.5)
httparty (0.21.0)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
jwt (2.7.1)
mini_magick (4.12.0)
json (2.8.2)
jwt (2.9.3)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.3.0)
nanaimo (0.3.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
nanaimo (0.4.0)
naturally (2.2.1)
optparse (0.1.1)
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
plist (3.7.1)
public_suffix (5.0.4)
rake (13.1.0)
public_suffix (5.1.1)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
rexml (3.3.9)
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.18.0)
security (0.1.5)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.10)
CFPropertyList
naturally
sysrandom (1.0.5)
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand All @@ -194,16 +206,15 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand All @@ -214,10 +225,10 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
fastlane (~> 2.219.0)
fastlane (~> 2.225.0)
fastlane-plugin-appcenter
httparty
json (~> 2.7.0)
json (~> 2.8.0)

BUNDLED WITH
2.4.20
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/marmelroy/PhoneNumberKit.git", from: "3.7.9"),
.package(url: "https://github.com/marmelroy/PhoneNumberKit.git", from: "3.8.0"),
.package(url: "[email protected]:powerhome/power-fonts.git", from: "0.0.1"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.15.4")
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.6")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
11 changes: 11 additions & 0 deletions Sources/Playbook/Components/Popover/PopoverHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftUI
struct PopoverView: View {
let id: Int
let blockBackgroundInteractions: Bool
@State private var opacity: CGFloat = 0.01
@EnvironmentObject var popoverManager: PopoverManager

init(
Expand All @@ -35,6 +36,16 @@ struct PopoverView: View {
.onTapGesture {
popoverManager.closeInside(id)
}
.onAppear {
if popover?.position != nil {
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { _ in
opacity = 1
}
} else {
opacity = 0.01
}
}
.opacity(opacity)
}
}
}
Expand Down
30 changes: 26 additions & 4 deletions Sources/Playbook/Components/Popover/PopoverManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,35 @@ import SwiftUI
public class PopoverManager: ObservableObject {
@Published var isPresented: [Int : Bool] = [:]
@Published var popovers: [Int : Popover] = [:]

@Published var activePopoverID: Int?

public static let shared = PopoverManager()

struct Popover {
var view: AnyView
var position: CGPoint?
var close: (Close, action: (() -> Void)?) = (.anywhere, nil)
}


func showPopover(for id: Int) {
activePopoverID = id
}

func hidePopover(for id: Int) {
if activePopoverID == id {
activePopoverID = nil
}
}

func isPopoverActive(for id: Int) -> Bool {
return activePopoverID == id
}

func createPopover(with id: Int, view: AnyView, position: CGPoint?, close: (Close, action: (() -> Void)?)) {
popovers[id] = Popover(view: view, position: position, close: close)
isPresented[id] = false
}

func removeValues() {
popovers.removeAll()
isPresented.removeAll()
Expand All @@ -45,7 +60,14 @@ public class PopoverManager: ObservableObject {
popovers.updateValue(newPopover, forKey: id)
}
}


func update(with id: Int) {
if let popover = popovers.first(where: { $0.key == id })?.value {
let newPopover = Popover(view: popover.view, position: popover.position, close: popover.close)
popovers.updateValue(newPopover, forKey: id)
}
}

func closeInside(_ key: Int) -> Void {
switch popovers[key]?.close.0 {
case .inside, .anywhere:
Expand Down
1 change: 1 addition & 0 deletions Sources/Playbook/Components/Typeahead/GridInputField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private extension GridInputField {
}
.textFieldStyle(.plain)
.pbFont(.body, color: textColor)
.frame(height: 24)
}
.fixedSize()
.frame(minWidth: 60, alignment: .leading)
Expand Down
Loading

0 comments on commit ee531a2

Please sign in to comment.