Swiftpack.co - AndreaMiotto/ActionOver as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AndreaMiotto.
AndreaMiotto/ActionOver 1.0.3
A custom SwiftUI modifier to present an ActionSheet or a Popover menu
⭐️ 137
🕓 3 years ago
iOS
.package(url: "https://github.com/AndreaMiotto/ActionOver.git", from: "1.0.3")

ActionOver

A custom SwiftUI modifier to present an Action Sheet on iPhone and a Popover on iPad and Mac.

iPhone Preview

iPad Preview

Mac Preview

Features

Availables

  • [x] Slidable and dismissable with drag gesture.
  • [x] Light/Dark mode.
  • [x] Customizable button color.
  • [x] Custon popup position on ipad and mac.
  • [x] Custom popup arrow edge position on ipad and mac.
  • [x] iOS compatibility
  • [x] iPad compatibility
  • [x] Mac compatibility

Installation

Requirements

  • iOS 13.0+ / macOS 10.15.4+
  • Xcode 11.2+
  • Swift 5+

Via Swift Package Manager

In Xcode 11 or grater, in you project, select: File > Swift Packages > Add Pacakage Dependency.

In the search bar type ActionOver and when you find the package, with the next button you can proceed with the installation.

If you can't find anything in the panel of the Swift Packages you probably haven't added yet your github account. You can do that under the Preferences panel of your Xcode, in the Accounts section.

How to Use

To use the Action Over just attach the new modifier:

YourView
.actionOver(
    presented: Binding<Bool>,
    title: String,
    message: String?,
    buttons: [ActionOverButton],
    ipadAndMacConfiguration: IpadAndMacConfiguration,
    normalButtonColor: UIColor = UIColor.label
)

If you want a starting point copy in your ContentView file the following code:

import SwiftUI
import ActionOver

struct ContentView: View {

    @State var presented = false

    var body: some View {
        NavigationView {
            VStack(alignment: .leading, spacing: 40) {
                Text("""
                Hi, this is the Action Over modifier.

                With this modifier you will preset an Action Sheet on iPhone
                and a Popover on iPad and Mac.

                You will write just once your actions, and with a single modifier
                you will dislay the proper menu according the user's device.
                """)
                Button(action: {
                    self.presented = true
                }, label: {
                    Text("Show Action Over")
                })
                    .actionOver(
                        presented: $presented,
                        title: "Settings",
                        message: "Wich setting will you enamble?",
                        buttons: buttons,
                        ipadAndMacConfiguration: ipadMacConfig
                )
                HStack {
                    Spacer()
                }
                Spacer()
            }
            .padding()
                .navigationBarTitle("Action Over", displayMode: .large)
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }

    private var buttons: [ActionOverButton] = {
        return [
            ActionOverButton(
                title: "Option one",
                type: .normal,
                action: {}
            ),
            ActionOverButton(
                title: "Option two",
                type: .normal,
                action: {}
            ),
            ActionOverButton(
                title: "Delete",
                type: .destructive,
                action: {}
            ),
            ActionOverButton(
                title: nil,
                type: .cancel,
                action: nil
            ),
        ]
    }()

    private var ipadMacConfig = {
        IpadAndMacConfiguration(anchor: nil, arrowEdge: nil)
    }()
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

GitHub

link
Stars: 137
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics