Code Monkey home page Code Monkey logo

megax's Introduction

MegaX

MegaX, representing Modifiers, Elements, Graphical and Abstractions, is a powerful SwiftUI framework which offers a set of modifiers and components for SwiftUI.

MegaX comes with a set of Views and Modifiers I often use in my project. The goal of the package is to accelerate developement process.

MegaX is currently compatible with iOS 17 or later.

AsyncButton

AsyncButton is a simple Button but with progress indicator and async action environment.

Usage

AsyncButton("Download", systemName: "arrow.down.circle") {
    await download()
}

CameraView

When you need capture photos, CameraView comes in.

CameraView is a system-like camera view with support for manual focus and exposure, zooming with gesture or with lens switcher.

It automatically handles element orientation, but need developers to add AppOrientationDelegate to the App declaration.

import SwiftUI
import MegaX

@main
struct MyCameraApp: App {
    // This is needed, or the orientation behavior may be wired.
    @UIApplicationDelegateAdaptor(AppOrientationDelegate.self) private var delegate

    var body: some Scene {
        WindowGroup {
            CameraView { photoCaptured in
                print("photoData: \(photoCaptured)")}
    }
}

You can also add a custom status bar and a photo album button.

CameraView { photoData in
    print("Photo Captured")
} photoAlbum: {
    // A custom album button to display the lastest captured photo
    RoundedRectangle(cornerRadius: 8)
        .foregroundStyle(.fill.secondary)
        .aspectRatio(contentMode: .fit)
        .frame(height: 56)
}

If you want to customize the Camera, the available modifiers are

  • autoDeferredPhotoDeliveryEnabled
  • zeroShutterLagEnabled
  • responsiveCaptureEnabled
  • fastCapturePrioritizationEnabled
  • captureWhenMultiTaskingEnabled
  • cameraStabilizationMode

Backdrop Blur

High performance backdrop blur layer with just one line of code.

YourView()
    .backdropBlur(smoothEdges: .bottom)

Extensions for SwiftUI

if-else modifier

Creating conditional modifier just like writing normal code.

But be careful when using this extension modifier because it might lead to poor performance and unexpected behavior.

Use this modifier only when the condition value will not change through the view's lifecycle, like using DeviceType to add platform specific adjustments.

megax's People

Contributors

liyanan2004 avatar

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.