swiftUI-slide-over-card icon indicating copy to clipboard operation
swiftUI-slide-over-card copied to clipboard

Bottom Positioning

Open khashabri opened this issue 4 years ago • 2 comments

Not sure why we use the number of 80 here, but does anyone know how to position the card exactly above the tabBar when it is at the bottom position? (of course screen size independent) https://github.com/moifort/swiftUI-slide-over-card/blob/9fdc77c16d639d80a789daad0e036a24faf00825/Sources/SlideOverCard/SlideOverCard.swift#L32

Like this Bildschirmfoto 2020-09-27 um 15 27 44

khashabri avatar Sep 27 '20 22:09 khashabri

Sorry for the late answer I wasn't notified , I will take a look!

moifort avatar Sep 28 '20 07:09 moifort

Alright. I couldn't find a programmatically solution to stop the card right above the tabBar (here also my forum post). So, I ended up writing the following function:

func aboveTabBarPosition(screenSize: CGRect) -> CGFloat{
    switch screenSize {
    case CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0): // iPhone 8 & iPhone SE
        return 485
    case CGRect(x: 0.0, y: 0.0, width: 414.0, height: 736.0): // iPhone 8 Plus
        return 551
    case CGRect(x: 0.0, y: 0.0, width: 414.0, height: 896.0): // iPhone 11
        return 650
    case CGRect(x: 0.0, y: 0.0, width: 375.0, height: 812.0): // iPhone 11 Pro
        return 569
    case CGRect(x: 0.0, y: 0.0, width: 414.0, height: 896.0): // iPhone 11 Pro Max
        return 654
    case CGRect(x: 0.0, y: 0.0, width: 320.0, height: 568.0): // iPod touch
        return 390
    default:
        return screenSize.height/1.425
    }
}

and changing the line https://github.com/moifort/swiftUI-slide-over-card/blob/9fdc77c16d639d80a789daad0e036a24faf00825/Sources/SlideOverCard/SlideOverCard.swift#L32 to return aboveTabBarPosition(screenSize: UIScreen.main.bounds)

khashabri avatar Sep 28 '20 10:09 khashabri