FloatingPanel icon indicating copy to clipboard operation
FloatingPanel copied to clipboard

Setting inset according to different screen devices ?

Open DiwakarThapa opened this issue 6 years ago • 7 comments

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
    }
  }

DiwakarThapa avatar Feb 20 '20 15:02 DiwakarThapa

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.

scenee avatar Feb 28 '20 12:02 scenee

Hi, any updates on v2?

md-griddy avatar Apr 22 '20 05:04 md-griddy

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.

scenee avatar Apr 22 '20 13:04 scenee

Any updates on this fix?

simonsmiley64 avatar May 21 '20 23:05 simonsmiley64

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
}

FlashTang avatar May 28 '20 09:05 FlashTang

@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.

scenee avatar May 28 '20 23:05 scenee

I've already released v2 so I closed this issue. Thank you for all.

scenee avatar Dec 05 '20 02:12 scenee