All Projects → Jake-Short → swiftui-image-viewer

Jake-Short / swiftui-image-viewer

Licence: MIT License
Image viewer built in SwiftUI for both local and remote images.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to swiftui-image-viewer

AdvancedList-SwiftUI
MOVED to https://github.com/crelies/AdvancedList | Advanced list with empty, error and loading state implemented with SwiftUI
Stars: ✭ 41 (-77.22%)
Mutual labels:  swiftui, swiftui-components
AStack
The Missing SwiftUI Adaptive and Accessible Stacks Library.
Stars: ✭ 110 (-38.89%)
Mutual labels:  swiftui, swiftui-components
SSSwiftUIGIFView
SSSwiftUIGIFView is a custom controller which helps to load GIF in SwiftUI.
Stars: ✭ 48 (-73.33%)
Mutual labels:  swiftui, swiftui-components
SwiftUI-App
This swiftUI Demo is very simple & easy to understand. This swiftUI demo includes On-boarding screens, login screen, forgot password screen, sign up screen, home & logout.
Stars: ✭ 175 (-2.78%)
Mutual labels:  swiftui, swiftui-components
SwiftUI.TextEdit
SwiftUI proof-of-concept text edit component
Stars: ✭ 71 (-60.56%)
Mutual labels:  swiftui, swiftui-components
RRSettingsKit
A beautiful customizable settings screen created in SwiftUI
Stars: ✭ 118 (-34.44%)
Mutual labels:  swiftui, swiftui-components
Swipeable-View
Simple editActionsForRowAt functionality, written on SWIFTUI
Stars: ✭ 37 (-79.44%)
Mutual labels:  swiftui, swiftui-components
RichText
Easily show RichText(html) in SwiftUI
Stars: ✭ 25 (-86.11%)
Mutual labels:  swiftui, swiftui-components
ImagePickerView
🌇 PHPickerViewController / UIImagePickerController for SwiftUI
Stars: ✭ 18 (-90%)
Mutual labels:  swiftui
GitBlamePR
Mac app that shows pull request last modified each line of a file, Written in SwiftUI
Stars: ✭ 24 (-86.67%)
Mutual labels:  swiftui
view
Image Viewer for BART
Stars: ✭ 13 (-92.78%)
Mutual labels:  image-viewer
mpv-image-viewer
Configuration, scripts and tips for using mpv as an image viewer
Stars: ✭ 157 (-12.78%)
Mutual labels:  image-viewer
SwiftUICoreData
SwiftUI Integration With CoreData FetchedRequest property wrapper
Stars: ✭ 16 (-91.11%)
Mutual labels:  swiftui
myyearwithgit
代码仓库年终总结报告。
Stars: ✭ 176 (-2.22%)
Mutual labels:  swiftui
NetworkAgent
This package is meant to make http request of an easy way inspiren in the architecture of Moya package. This package is 100% free of dependencies and works with Combine api + Codable
Stars: ✭ 16 (-91.11%)
Mutual labels:  swiftui
Flashcards
Application to memorise information in a game form (SwiftUI)
Stars: ✭ 14 (-92.22%)
Mutual labels:  swiftui
BottomSheet
BottomSheet lets you add custom bottom sheets to your SwiftUI apps.
Stars: ✭ 111 (-38.33%)
Mutual labels:  swiftui
E-Rezept-App-iOS
https://gematik.github.io/E-Rezept-App-iOS/
Stars: ✭ 76 (-57.78%)
Mutual labels:  swiftui
Notflix
📱Netflix like application using SwiftUI and Combine
Stars: ✭ 76 (-57.78%)
Mutual labels:  swiftui
puffery
A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.
Stars: ✭ 17 (-90.56%)
Mutual labels:  swiftui

SwiftUI Image Viewer

License: MIT Maintenance PRs Welcome

Summary

An image viewer built using SwiftUI. Featuring drag to dismiss, pinch to zoom, remote and local images, and more.

image

Installation via Swift Package Manager

File > Swift Packages > Add Package Dependancy

https://github.com/Jake-Short/swiftui-image-viewer.git

Usage

Notes on NavigationView: The .overlay modifier only applies to the view it is applied to. Therefore, the .overlay modifier must be applied to the NavigationView to appear above all elements! If it is applied to a child view, it will appear beneath the title/navigation buttons.

Local Image:

The image parameter accepts Binding<Image> in all versions. As of 1.0.20, it also accepts Binding<Image?>

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer))
    }
}

Remote Image:

The imageURL parameter accepts Binding<String>

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var imgURL: String = "https://..."
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: self.$imgURL, viewerShown: self.$showImageViewer))
    }
}

Customization

Close Button Position

Availability: 2.2.0 or higher

The close button can be moved to the top right if desired. The closeButtonTopRight parameter accepts bool.

Example:

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")
    
    var body: some View {
        VStack {
            Text("Example!")
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, closeButtonTopRight: true))
    }
}

Caption

Availability: 2.1.0 or higher

A caption can be added to the image viewer. The caption will appear near the bottom of the image viewer (if the image fills the whole screen the text will appear on top of the image). The caption parameter accepts Text.

Example:

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, caption: Text("This is a caption!")))
    }
}

Explicit Aspect Ratio

Availability: 1.0.21 or higher

An explcit image aspect ratio can be specified, which fixes an issue of incorrect stretching that occurs in certain situations. The aspectRatio parameter accepts Binding<CGFloat>

Example:

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, aspectRatio: .constant(2)))
    }
}

Disable Cache

Availability: 1.0.25 or higher

To disable cache on the remote image viewer, simply pass a Bool value to the disableCache parameter

Example:

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: URL(string: "https://..."), viewerShown: self.$showImageViewer, disableCache: true))
    }
}
Deprecated

HTTP Headers

Availability: 1.0.15 to 1.0.25

DEPRECATED: No longer available as of 2.0.0

The remote image viewer allows HTTP headers to be included in the URL request. To use them, pass a dictonary to the httpHeaders field. The format should be [Header: Value], both strings.

Example:

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true
	
    var body: some View {
        VStack {
            Text("Example!")
        }
	.frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: URL(string: "https://..."), viewerShown: self.$showImageViewer, httpHeaders: ["X-Powered-By": "Swift!"]))
    }
}

Compatibility

This package is compatible on iOS 13 and later.

Previous to 1.0.18, this package used Swift tools version 5.2. If you receive an error while trying to use the package, you may be on an older version of Xcode, and should use version 1.0.18 of this package or later.

As of 1.0.18 and later, this package uses Swift tools version 5.1, allowing for compatibility with more Xcode versions.

License

This project is licensed under the MIT license.

Enjoying this project?

Please consider giving it a star!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].