Skip to content

Commit 07f7cb3

Browse files
committed
Add z index inversion parameter
1 parent 6e6a757 commit 07f7cb3

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "FloatingButton"
18+
BuildableName = "FloatingButton"
19+
BlueprintName = "FloatingButton"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
shouldAutocreateTestPlan = "YES">
31+
</TestAction>
32+
<LaunchAction
33+
buildConfiguration = "Debug"
34+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
35+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36+
launchStyle = "0"
37+
useCustomWorkingDirectory = "NO"
38+
ignoresPersistentStateOnLaunch = "NO"
39+
debugDocumentVersioning = "YES"
40+
debugServiceExtension = "internal"
41+
allowLocationSimulation = "YES">
42+
</LaunchAction>
43+
<ProfileAction
44+
buildConfiguration = "Release"
45+
shouldUseLaunchSchemeArgsEnv = "YES"
46+
savedToolIdentifier = ""
47+
useCustomWorkingDirectory = "NO"
48+
debugDocumentVersioning = "YES">
49+
<MacroExpansion>
50+
<BuildableReference
51+
BuildableIdentifier = "primary"
52+
BlueprintIdentifier = "FloatingButton"
53+
BuildableName = "FloatingButton"
54+
BlueprintName = "FloatingButton"
55+
ReferencedContainer = "container:">
56+
</BuildableReference>
57+
</MacroExpansion>
58+
</ProfileAction>
59+
<AnalyzeAction
60+
buildConfiguration = "Debug">
61+
</AnalyzeAction>
62+
<ArchiveAction
63+
buildConfiguration = "Release"
64+
revealArchiveInOrganizer = "YES">
65+
</ArchiveAction>
66+
</Scheme>

FloatingButton.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "FloatingButton"
3-
s.version = "1.2.0"
3+
s.version = "1.2.1"
44
s.summary = "Easily customizable floating button menu created with SwiftUI."
55

66
s.homepage = 'https://github.com/exyte/FloatingButton.git'

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ FloatingButton(mainButtonView: mainButton, buttons: buttons, isOpen: $isOpen)
5656
- you can pass array of delays - one for each element
5757
- or you can pass `delayDelta` - then this same delay will be used for each element
5858
`mainZStackAlignment` - main button and submenu buttons are contained in one ZStack (not an overlay so the menu has a correct size), you can change this ZStack's alignment with this parameter
59+
`inverseZIndex` - inverse zIndex of mainButton and the children. Use, for example, if you have a negative spacing and want to change the order
5960
`wholeMenuSize` - pass CGSize binding to get updates of menu's size. Menu's size includes main button frame and all of elements' frames
6061
`menuButtonsSize` - pass CGSize binding to get updates of combined menu elements' size
6162

@@ -102,7 +103,7 @@ github "Exyte/FloatingButton"
102103

103104
## Requirements
104105

105-
* iOS 14.0+ / macOS 11.0+ / tvOS 14.0+ / watchOS 7.0+
106+
* iOS 14.0+ / macOS 11.0+ / watchOS 7.0+
106107
* Xcode 12+
107108

108109
## Our other open source SwiftUI libraries

Sources/FloatingButton/FloatingButton.swift

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public struct FloatingButton<MainView, ButtonView>: View where MainView: View, B
3434
fileprivate var animation: Animation = .easeInOut(duration: 0.4)
3535
fileprivate var delays: [Double] = []
3636
fileprivate var mainZStackAlignment: SwiftUI.Alignment = .center
37+
fileprivate var inverseZIndex: Bool = false
3738

3839
fileprivate var wholeMenuSize: Binding<CGSize> = .constant(.zero)
3940
fileprivate var menuButtonsSize: Binding<CGSize> = .constant(.zero)
@@ -86,11 +87,13 @@ public struct FloatingButton<MainView, ButtonView>: View where MainView: View, B
8687
.scaleEffect(isOpen ? 1 : initialScaling)
8788
.opacity(mainButtonSize == .zero ? 0 : isOpen ? 1 : initialOpacity)
8889
.animation(buttonAnimation(at: i), value: isOpen)
90+
.zIndex(Double(inverseZIndex ? (buttons.count - i - 1) : 1))
8991
}
9092

9193
MainButtonViewInternal(isOpen: isOpenBinding ?? $privateIsOpen, mainButtonView: mainButtonView)
9294
.buttonStyle(PlainButtonStyle())
9395
.sizeGetter($mainButtonSize)
96+
.zIndex(Double(inverseZIndex ? buttons.count : 0))
9497
}
9598
.onPreferenceChange(SubmenuButtonPreferenceKey.self) { (sizes) in
9699
let sizes = sizes.map { CGSize(width: CGFloat(Int($0.width + 0.5)), height: CGFloat(Int($0.height + 0.5))) }
@@ -335,6 +338,12 @@ public extension FloatingButtonGeneric where T : DefaultFloatingButton {
335338
return copy
336339
}
337340

341+
func inverseZIndex(_ inverse: Bool) -> FloatingButtonGeneric {
342+
var copy = self
343+
copy.floatingButton.inverseZIndex = inverse
344+
return copy
345+
}
346+
338347
func wholeMenuSize(_ wholeMenuSize: Binding<CGSize>) -> FloatingButtonGeneric {
339348
var copy = self
340349
copy.floatingButton.wholeMenuSize = wholeMenuSize

0 commit comments

Comments
 (0)