Setting inset according to different screen devices ?
Do I need to give inset for the position according to different screen devices ? or library automatically does that for us?
class IntrinsicLayout: FloatingPanelIntrinsicLayout {
func backdropAlphaFor(position: FloatingPanelPosition) -> CGFloat {
return 0
}
var positionReference: FloatingPanelLayoutReference {
return .fromSafeArea
}
public var initialPosition: FloatingPanelPosition {
return .tip
}
public var supportedPositions: Set<FloatingPanelPosition> {
return [.tip, .half]
}
public func insetFor(position: FloatingPanelPosition) -> CGFloat? {
switch position {
case .half: return (UIScreen.main.bounds.height) - (299 + 44)
// 276
case .tip: return (UIScreen.main.bounds.height) - 424 - (299 + 44)
//293
default: return nil
}
}
Yes you need because on FloatingPanel v1 you need to define the insets for tip and half from bottom of the reference guide(i.e. SafeArea).
However I have a good news for you, FloatingPanel v2 will be able to select the inset's reference guide and edge(top or bottom) for each position. Additionally you will be also able to define a relative inset, for example, a half(0.5) of screen.
Hi, any updates on v2?
I'm sorry I'm late to release v2. Now I'm working to improve the APIs and release v2 beta in a couple of weeks.
Any updates on this fix?
Any news on v2 ? I want to set more positions , and move to any Y with giving CGFloat, like so :
func move(_ to distanceFromBottom: CGFloat, animated:Bool ,completion: (() -> Void)? = nil)
fpc.move(distanceFromBottom:350.0,animated:true){
print(self.fpc.position == .anyPositionDefined) // false , so now the position is not any position pre-defined
}
func onKeyboardUpdate(positionY:CGFloat){
fpc.move(distanceFromBottom:positionY + 50.0 ,animated:false) // so I can let fpc follow keyboard as a tip bar
}
@simonsmiley64 @FlashTang
Thanks for your interesting on v2. I'm working the development on v2-dev branch.
v2 will introduce FloatingPanelLayoutAnchor for the more flexible layout. Since v2, you can define a position(which is renamed as state on v2) with a fractional inset from top/bottom edge.
var stateAnchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelLayoutAnchor(absoluteInset: 18.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea),
.tip: FloatingPanelLayoutAnchor(absoluteInset: 69.0, edge: .bottom, referenceGuide: .safeArea),
]
}
FloatingPanelLayoutAnchor will replaces FloatingPanelFullScreenLayout and FloatingPanelIntrinsicLayout is also replaced by FloatingPanelIntrinsicLayoutAnchorwhich is a subclass of it.
At last, if you like, I'm glad for you to try Maps.app on v2-dev which fully supports iPad.
I've already released v2 so I closed this issue. Thank you for all.