Skip to content

Commit 227df86

Browse files
committed
Updated
1 parent 6492e71 commit 227df86

File tree

5 files changed

+52
-61
lines changed

5 files changed

+52
-61
lines changed

Sources/UIFloatMenu.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class UIFloatMenu {
1515
return vc
1616
}
1717

18-
static private var containerView = ContainerView()
19-
2018
static private var container_VC = UIViewController()
2119
static private var source_VC = UIViewController()
2220

@@ -335,7 +333,6 @@ class UIFloatMenu {
335333

336334
var newView: UIView {
337335
if let new = container_VC.view.viewWithTag(id) {
338-
//new.isHidden = true
339336
return new
340337
}
341338
return UIView()
@@ -386,7 +383,6 @@ class UIFloatMenu {
386383

387384
animator.addMovingAnimation(from: lastView, to: previousView, sourceView: previousView, in: previousView)
388385
animator.addCompletion({ _ in
389-
showTo(containerView, positions: correct, animation: .fade)
390386
lastView.removeFromSuperview()
391387
queue.removeLast()
392388
})

Sources/UIFloatMenuController.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
194194
// MARK: - detect device rotations
195195
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
196196
super.viewWillTransition(to: size, with: coordinator)
197-
198197
UIView.animate(withDuration: 0.01) {
199198
self.backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
200199
}
@@ -205,7 +204,7 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
205204
for index in 0..<UIFloatMenu.queue.count {
206205
if let menuView = self.view.viewWithTag(UIFloatMenu.queue[index].uuid) {
207206
if device == .pad {
208-
let layout = Layout.determineLayout()
207+
let layout = UIFloatMenuHelper.Layout.determineLayout()
209208

210209
let current_presentation = (UIFloatMenu.queue[index].config.presentation)!
211210
let position: UIFloatMenuPresentStyle!
@@ -240,7 +239,7 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
240239
}
241240
menu.showTo(menuView, positions: position, iPad_window_width: 0, animation: .default(animated: false))
242241
} else if device == .phone {
243-
if Orientation.isLandscape {
242+
if UIFloatMenuHelper.Orientation.isLandscape {
244243
menuView.center = self.view.center
245244
} else {
246245
menu.showTo(menuView, positions: UIFloatMenuHelper.correctPosition((self.queue.last?.config.presentation)!), animation: .default(animated: false))

Sources/UIFloatMenuHelper.swift

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -124,62 +124,58 @@ class UIFloatMenuHelper {
124124
return ""
125125
}
126126

127-
}
128-
129-
// MARK: - Layout
130-
struct Layout {
131-
132-
enum LayoutStyle: String {
133-
case iPadFullScreen = "iPad Full Screen"
134-
case iPadHalfScreen = "iPad 1/2 Screen"
135-
case iPadTwoThirdScreen = "iPad 2/3 Screen"
136-
case iPadOneThirdScreen = "iPad 1/3 Screen"
137-
case iPhoneFullScreen = "iPhone"
138-
}
139-
140-
static func determineLayout() -> LayoutStyle {
141-
if UIDevice.current.userInterfaceIdiom == .phone {
142-
return .iPhoneFullScreen
143-
}
144-
145-
let screenSize = UIScreen.main.bounds.size
146-
let appSize = UIApplication.shared.windows[0].bounds.size
147-
let screenWidth = screenSize.width
148-
let appWidth = appSize.width
149-
150-
if screenSize == appSize {
151-
return .iPadFullScreen
127+
// MARK: - Layout
128+
struct Layout {
129+
enum LayoutStyle: String {
130+
case iPadFullScreen = "iPad Full Screen"
131+
case iPadHalfScreen = "iPad 1/2 Screen"
132+
case iPadTwoThirdScreen = "iPad 2/3 Screen"
133+
case iPadOneThirdScreen = "iPad 1/3 Screen"
134+
case iPhoneFullScreen = "iPhone"
152135
}
153136

154-
let persent = CGFloat(appWidth / screenWidth) * 100.0
155-
156-
if persent <= 55.0 && persent >= 45.0 {
157-
return .iPadHalfScreen
158-
} else if persent > 55.0 {
159-
return .iPadTwoThirdScreen
160-
} else {
161-
return .iPadOneThirdScreen
137+
static func determineLayout() -> LayoutStyle {
138+
if UIDevice.current.userInterfaceIdiom == .phone {
139+
return .iPhoneFullScreen
140+
}
141+
142+
let screenSize = UIScreen.main.bounds.size
143+
let appSize = UIApplication.shared.windows[0].bounds.size
144+
let screenWidth = screenSize.width
145+
let appWidth = appSize.width
146+
147+
if screenSize == appSize {
148+
return .iPadFullScreen
149+
}
150+
151+
let persent = CGFloat(appWidth / screenWidth) * 100.0
152+
153+
if persent <= 55.0 && persent >= 45.0 {
154+
return .iPadHalfScreen
155+
} else if persent > 55.0 {
156+
return .iPadTwoThirdScreen
157+
} else {
158+
return .iPadOneThirdScreen
159+
}
162160
}
163161
}
164-
165-
}
166162

167-
// MARK: - Orientation
168-
struct Orientation {
169-
170-
static var isLandscape: Bool {
171-
get {
172-
return UIDevice.current.orientation.isValidInterfaceOrientation
173-
? UIDevice.current.orientation.isLandscape
174-
: (UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape)!
163+
// MARK: - Orientation
164+
struct Orientation {
165+
static var isLandscape: Bool {
166+
get {
167+
return UIDevice.current.orientation.isValidInterfaceOrientation
168+
? UIDevice.current.orientation.isLandscape
169+
: (UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape)!
170+
}
175171
}
176-
}
177-
178-
static var isPortrait: Bool {
179-
get {
180-
return UIDevice.current.orientation.isValidInterfaceOrientation
181-
? UIDevice.current.orientation.isPortrait
182-
: (UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait)!
172+
173+
static var isPortrait: Bool {
174+
get {
175+
return UIDevice.current.orientation.isValidInterfaceOrientation
176+
? UIDevice.current.orientation.isPortrait
177+
: (UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait)!
178+
}
183179
}
184180
}
185181

Sources/UIFloatMenuView/UIFloatMenuHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class UIFloatMenuHeaderView: UIView {
5050
super.init(frame: CGRect.zero)
5151
let appRect = UIApplication.shared.windows[0].bounds
5252
let device = UIDevice.current.userInterfaceIdiom
53-
let width = (device == .pad ? menuConfig.viewWidth_iPad : (Orientation.isPortrait ? appRect.width-30 : appRect.width/2.5))!
53+
let width = (device == .pad ? menuConfig.viewWidth_iPad : (UIFloatMenuHelper.Orientation.isPortrait ? appRect.width-30 : appRect.width/2.5))!
5454

5555
self.headerConfig = headerConfig
5656

Sources/UIFloatMenuView/UIFloatMenuView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class UIFloatMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGes
381381
let appRect = UIApplication.shared.windows[0].bounds
382382
var topSpace: CGFloat {
383383
let device = UIDevice.current.userInterfaceIdiom
384-
return device == .pad ? 250 : (Orientation.isLandscape ? 30 : 120)
384+
return device == .pad ? 250 : (UIFloatMenuHelper.Orientation.isLandscape ? 30 : 120)
385385
}
386386

387387
let maxH = appRect.height-topPadding-bottomPadding-topSpace
@@ -402,9 +402,9 @@ class UIFloatMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGes
402402
if device == .pad {
403403
return currentWidth
404404
} else if device == .phone {
405-
if Orientation.isLandscape {
405+
if UIFloatMenuHelper.Orientation.isLandscape {
406406
return appRect.height-30
407-
} else if Orientation.isPortrait {
407+
} else if UIFloatMenuHelper.Orientation.isPortrait {
408408
return appRect.width-30
409409
}
410410
}

0 commit comments

Comments
 (0)