From a873b7f8b3d7c3d32c5a5d5d4ddcf53f68c189a2 Mon Sep 17 00:00:00 2001 From: Faizan Durrani Date: Sun, 11 Dec 2022 23:15:17 +0500 Subject: [PATCH 1/2] added support for specifying max width --- .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++++++++ PopMenu/Classes/PopMenuAppearance.swift | 2 ++ .../View Controller & Views/PopMenuViewController.swift | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/PopMenu/Classes/PopMenuAppearance.swift b/PopMenu/Classes/PopMenuAppearance.swift index 9a4085d..dd2fff8 100644 --- a/PopMenu/Classes/PopMenuAppearance.swift +++ b/PopMenu/Classes/PopMenuAppearance.swift @@ -17,6 +17,8 @@ public typealias Color = UIColor /// Appearance for PopMenu. /// Use for configuring custom styles and looks. final public class PopMenuAppearance: NSObject { + /// The minimum width for the menu; Default: auto-sizing + public var popMenuMinimumWidth: CGFloat? = .none /// Background and tint colors. public var popMenuColor: PopMenuColor = .default() diff --git a/PopMenu/View Controller & Views/PopMenuViewController.swift b/PopMenu/View Controller & Views/PopMenuViewController.swift index f2507f9..0941390 100644 --- a/PopMenu/View Controller & Views/PopMenuViewController.swift +++ b/PopMenu/View Controller & Views/PopMenuViewController.swift @@ -434,7 +434,12 @@ extension PopMenuViewController { contentFitWidth += action.iconWidthHeight } - return min(contentFitWidth,maxContentWidth) + + if let minimumWidth = self.appearance.popMenuMinimumWidth { + return max(minimumWidth, min(contentFitWidth,maxContentWidth)) + } else { + return min(contentFitWidth,maxContentWidth) + } } /// Setup actions view. From 6170362c2ae0d303fd2398a6a8233936d26d5d2e Mon Sep 17 00:00:00 2001 From: Faizan Durrani Date: Sun, 11 Dec 2022 23:24:42 +0500 Subject: [PATCH 2/2] Delete WorkspaceSettings.xcsettings --- .../xcshareddata/WorkspaceSettings.xcsettings | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index f9b0d7c..0000000 --- a/PopMenu.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - PreviewsEnabled - - -