GithubHelp home page GithubHelp logo

mijick / popupview Goto Github PK

View Code? Open in Web Editor NEW
873.0 10.0 36.0 94 KB

Popups presentation made simple (SwiftUI)

License: MIT License

Swift 98.63% Ruby 1.37%
popup swift swift-package-manager swift5 swiftui swiftui-components swiftui-framework alert popups toast

popupview's People

Contributors

fulcrumone avatar jay-jay-lama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

popupview's Issues

Dismiss on touching outside?

Congratulations on this awesome library! The only thing missing is to dismiss the popup when touching outside. Would be great if this feature can be added.

Pod not update the latest code

pod 'Mijick_PopupView'

After pod install
I have to change
import PopView to Mijick_PopupView

but I got this error. please look that issue

Screenshot 2023-08-29 at 14 10 59

Why is viewModel not deiniting with a PopupView?

I use popupView for a popup that confirms the user is leaving that screen. But the ViewModel cannot be denied when combined
with the popupView, so in the long run it will lead to memory leaks.
Screenshot 2024-03-01 at 01 09 18

PopupView seems to follow the component with the biggest width in the view?

Popup seems to follow the component with the biggest width in the view?

Screenshot 2024-01-23 at 23 25 59

it works as expected when content overflows to the next line

Screenshot 2024-01-23 at 23 27 16

Code:

`
import MijickPopupView
import SwiftUI

  struct BottomCustomPopup: BottomPopup {
      func createContent() -> some View {
          HStack(spacing: 0) {
              Text("Witaj okrutny świecie")
              Spacer()
              Button(action: dismiss) { Text("Dismiss") }
          }
          .padding(.vertical, 20)
          .padding(.leading, 24)
          .padding(.trailing, 16)
      }
      func configurePopup(popup: BottomPopupConfig) -> BottomPopupConfig {
          popup
              .horizontalPadding(20)
              .bottomPadding(42)
              .cornerRadius(16)
              .tapOutsideToDismiss(true)
              .dragGestureEnabled(true)
              .contentIgnoresSafeArea(true)
      }
  }

`

UIScreen.main.bounds doesn't work for iPad and Mac

Manually computing the screen width limits the usage of the library only for the iPhone and it's not the ideal way for SwiftUI. On iPad, in split screen or with stage manager, UIScreen.main.bounds gives the width of the entire screen, not the width of the app's window.

Simulator Screenshot - iPad Pro (12 9-inch) (6th generation) - 2023-05-22 at 12 59 38

The fix is actually quite simple, mostly removing some .frame modifiers, like in this example

Screenshot 2023-05-22 at 13 00 24

And now it looks good everywhere.

Simulator Screenshot - iPad Pro (12 9-inch) (6th generation) - 2023-05-22 at 13 00 18

The background view has the same problem, more apparent on the Mac.

Screenshot 2023-05-22 at 13 27 51

But this too can be fixed quite easily

Screenshot 2023-05-22 at 13 28 10
Screenshot 2023-05-22 at 13 28 16

I can open a pull request with these changes if that's ok for you

PopupView size not updated after screen rotation.

Steps to reproduce:
1, Start the app when the phone is in portrait mode.
2, Rotate the phone to landscape mode.
3, Open the bottom PopupView.

The bottom PopupView doesn't span the full screen width. Instead, it displays a shadow strip in the center of the screen with full height.

Bug with custom center two popups

Issue Description

When attempting to .showAndStack() two separate center popups with custom views at the same time, the background view always adopts a gray color. This behavior occurs despite different configurations intended for the popups. Additionally, an issue with tap gestures is present when a bottom sheet with a TabView is used; the button tap does not work upon the first appearance.

Steps to Reproduce

  1. Implement .showAndStack() with two separate center popups with custom views.
  2. Observe that the background view is gray for both popups.
  3. Implement a bottom sheet with a TabView.
  4. Notice that the button within the TabView does not work on the first appearance.

Expected Behavior

The background view should not default to gray when stacking popups, and all user interactions, such as tap gestures on buttons within a TabView, should be responsive upon the first appearance.

Screenshots

  • iPhone 15 Example:
    iPhone 15 Example

  • iPhone 15 Pro Example:
    iPhone 15 Pro Example

  • Screenshot of Issue:
    Issue Screenshot

Code Snippet

struct BreakDownBottomSheetView: BottomPopup {

    func configurePopup(popup: BottomPopupConfig) -> BottomPopupConfig {
        popup
            .tapOutsideToDismiss(true)
            .dragGestureEnabled(true)
            .contentIgnoresSafeArea(true)
    }

    func createContent() -> some View {
        VStack(spacing: 15){
            TabView(selection: $index) {
                ForEach(yourDataArray, id: \.self) { item in
                    Button(action: {
                        // Button action here
                        // Doesn't work on first appearance
                    }) {
                        Text("Button for \(item)")
                    }
                    .tabItem {
                        Image(systemName: "some-system-image")
                        Text("Tab \(item)")
                    }
                    .tag(item)
                }
            }
            .tabViewStyle(.page(indexDisplayMode: .never))
            .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
        }
    }
}

BreakDownBottomSheetView()
    .showAndStack()

Shift up the screen when the keyboard is opened.

If I have a TextEditor on the bottom popup, and the TextEditor is focused, the keyboard doesn't open. I think this is because the bottom PopupView doesn't shift up. Can we make the screen shift up when the keyboard is opened? Thanks.

Cant used GeometryReader

When I wrap using GeometryReader ,I got results like below image

Code Snippet

'struct BottomPopup_NoCornerRadius: BottomPopup {
    func configurePopup(popup: BottomPopupConfig) -> BottomPopupConfig { popup.cornerRadius(0) }
    func createContent() -> some View {
        GeometryReader{ geo in
            VStack(alignment: .leading, spacing: 0) {
                Text("Test")
                createTitle()
                Spacer.height(16)
                createDescription()
                Spacer.height(36)
                createButtons()
            }
            .padding(.top, 32)
            .padding(.bottom, 12)
            .padding(.horizontal, 28)
        }
        }
      
}
@FulcrumOne 

Demo:
Simulator Screenshot - iPhone 15 - 2023-12-29 at 01 55 09

TopPopup White Safe Area (See Screenshot)

I created the following "alert" popup, and when it displays, the safe area at the top is white, despite my background being dark. I would expect any background to be using .clear by default. As a work around, I have implemented my own PopupConfig.

Screenshot 2023-06-01 at 8 08 44 AM

Problem with scrollable content

If in popup view there is scrollable content and it's value bigger than screen's height - we can't scroll it to the bottom
Problem cam be solved with setting view's configuration to
contentFillsWholeHeigh(true) or contentFillsEntireScreen(true)

Automatically falling back to Main Thread rendering engine...

Hi, thanks for this amazing library. When I present popup view, I get below log in Xcode.
Automatically falling back to Main Thread rendering engine. This fallback comes with some additional performance
overhead, which can be reduced by manually specifying that this animation should always use the Main Thread engine.

BottomPopup placed under sheet

Hi, very nice work!

I only have one issue, the BottomPopup is placed under other sheets.

So if I show a sheet, then present a BottomPopup, I have to dismiss the sheet for the BottomPopup to be visible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.