Skip to content

Commit

Permalink
bump SwiftUI minimum target to iOS 14
Browse files Browse the repository at this point in the history
  • Loading branch information
efremidze committed Jul 25, 2023
1 parent bc6cb1a commit 122fc2f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 62 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ pod try VisualEffectView
## Requirements

- iOS 9.0+
- iOS 13.0 + (For SwiftUI Support)
- iOS 14.0 + (SwiftUI support)
- Xcode 9.0+
- Swift 5 (VisualEffectView 4.x), Swift 4 (VisualEffectView 3.x), Swift 3 (VisualEffectView 2.x), Swift 2 (VisualEffectView 1.x)

Expand Down Expand Up @@ -64,7 +64,7 @@ Works great with storyboards and xibs.

### SwiftUI Support

VisualEffectView works well with the SwiftUI.
VisualEffectView supports SwiftUI.

```swift
import VisualEffectView
Expand All @@ -76,8 +76,7 @@ struct ContentView: View {
}
```

You have to make sure you don't set `colorTintAlpha` if `colorTint` is `nil`.

Make sure that `colorTintAlpha` is not set when `colorTint` is `nil`.

## Installation

Expand Down
1 change: 0 additions & 1 deletion Sources/UIViewEffectViewiOS14.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import UIKit

@available(iOS 14, *)
@available(xrOS 1.0, *)
extension UIVisualEffectView {
var ios14_blurRadius: CGFloat {
get {
Expand Down
49 changes: 10 additions & 39 deletions Sources/VisualEffectView_SwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,34 @@

import SwiftUI

@available(iOS 13, *)
@available(xrOS 1.0, *)
@available(iOS 14, *)
public struct VisualEffect: UIViewRepresentable {
let colorTint: Color?
let colorTintAlpha: CGFloat
let blurRadius: CGFloat
let scale: CGFloat

public init(colorTint: Color? = nil, colorTintAlpha: CGFloat = 0, blurRadius: CGFloat = 0, scale: CGFloat = 1) {
self.colorTint = colorTint
self.colorTintAlpha = colorTintAlpha
self.blurRadius = blurRadius
self.scale = scale
}

public typealias UIViewType = VisualEffectView


public func makeUIView(context: Context) -> VisualEffectView {
let view = VisualEffectView()
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

if let colorTint {
view.colorTint = colorTint.uiColor()
}
view.colorTintAlpha = colorTintAlpha
view.blurRadius = blurRadius
view.scale = scale

return view
}

public func updateUIView(_ uiView: VisualEffectView, context: Context) {
if let colorTint {
uiView.colorTint = colorTint.uiColor()
Expand All @@ -49,8 +46,7 @@ public struct VisualEffect: UIViewRepresentable {
}
}

@available(iOS 13, *)
@available(xrOS 1.0, *)
@available(iOS 14, *)
struct VisualEffect_Previews: PreviewProvider {
static var previews: some View {
ZStack {
Expand All @@ -64,34 +60,9 @@ struct VisualEffect_Previews: PreviewProvider {
}
}


@available(iOS 13, *)
@available(xrOS 1.0, *)
extension Color {

@available(iOS 14, *)
private extension Color {
func uiColor() -> UIColor {

if #available(iOS 14.0, *) {
return UIColor(self)
}

let components = self.components()
return UIColor(red: components.r, green: components.g, blue: components.b, alpha: components.a)
}

private func components() -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) {

let scanner = Scanner(string: self.description.trimmingCharacters(in: CharacterSet.alphanumerics.inverted))
var hexNumber: UInt64 = 0
var r: CGFloat = 0.0, g: CGFloat = 0.0, b: CGFloat = 0.0, a: CGFloat = 0.0

let result = scanner.scanHexInt64(&hexNumber)
if result {
r = CGFloat((hexNumber & 0xff000000) >> 24) / 255
g = CGFloat((hexNumber & 0x00ff0000) >> 16) / 255
b = CGFloat((hexNumber & 0x0000ff00) >> 8) / 255
a = CGFloat(hexNumber & 0x000000ff) / 255
}
return (r, g, b, a)
return UIColor(self)
}
}
25 changes: 9 additions & 16 deletions VisualEffectView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -16,7 +16,7 @@
8B3DFCE01E07D8F5009EAFA2 /* VisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B3DFCDF1E07D8F5009EAFA2 /* VisualEffectView.swift */; };
8BD4B7E61E8A563A00BD74C6 /* VisualEffectView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B3243FE1E07D7CB00712FEA /* VisualEffectView.framework */; };
8BD4B7E71E8A563A00BD74C6 /* VisualEffectView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8B3243FE1E07D7CB00712FEA /* VisualEffectView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
90B970382A0B38D600BE7DAF /* VisualEffectView_SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B970372A0B38D600BE7DAF /* VisualEffectView_SwiftUI.swift */; };
C0864C842A6FB2D2006B0F49 /* VisualEffectView_SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0864C832A6FB2D2006B0F49 /* VisualEffectView_SwiftUI.swift */; };
F449249E206F2D5100117F6B /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = F449249B206F2D5100117F6B /* README.md */; };
F449249F206F2D5100117F6B /* VisualEffectView.podspec in Resources */ = {isa = PBXBuildFile; fileRef = F449249C206F2D5100117F6B /* VisualEffectView.podspec */; };
F44924A0206F2D5100117F6B /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = F449249D206F2D5100117F6B /* CHANGELOG.md */; };
Expand Down Expand Up @@ -60,7 +60,7 @@
8B3244191E07D7D900712FEA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
8B32441B1E07D7D900712FEA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8B3DFCDF1E07D8F5009EAFA2 /* VisualEffectView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisualEffectView.swift; sourceTree = "<group>"; };
90B970372A0B38D600BE7DAF /* VisualEffectView_SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisualEffectView_SwiftUI.swift; sourceTree = "<group>"; };
C0864C832A6FB2D2006B0F49 /* VisualEffectView_SwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisualEffectView_SwiftUI.swift; sourceTree = "<group>"; };
F449249B206F2D5100117F6B /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
F449249C206F2D5100117F6B /* VisualEffectView.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VisualEffectView.podspec; sourceTree = "<group>"; };
F449249D206F2D5100117F6B /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -113,9 +113,9 @@
children = (
8B3DFCDF1E07D8F5009EAFA2 /* VisualEffectView.swift */,
F4BE05CA25108C0000500B57 /* UIViewEffectViewiOS14.swift */,
C0864C832A6FB2D2006B0F49 /* VisualEffectView_SwiftUI.swift */,
8B3244011E07D7CB00712FEA /* VisualEffectView.h */,
8B3244021E07D7CB00712FEA /* Info.plist */,
90B970372A0B38D600BE7DAF /* VisualEffectView_SwiftUI.swift */,
);
name = VisualEffectView;
path = Sources;
Expand Down Expand Up @@ -192,9 +192,8 @@
8B3243F51E07D7CB00712FEA /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = "Lasha Efremidze";
TargetAttributes = {
8B3243FD1E07D7CB00712FEA = {
Expand All @@ -210,7 +209,7 @@
};
};
buildConfigurationList = 8B3243F81E07D7CB00712FEA /* Build configuration list for PBXProject "VisualEffectView" */;
compatibilityVersion = "Xcode 3.2";
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -258,7 +257,7 @@
files = (
8B3DFCE01E07D8F5009EAFA2 /* VisualEffectView.swift in Sources */,
F4BE05CB25108C0000500B57 /* UIViewEffectViewiOS14.swift in Sources */,
90B970382A0B38D600BE7DAF /* VisualEffectView_SwiftUI.swift in Sources */,
C0864C842A6FB2D2006B0F49 /* VisualEffectView_SwiftUI.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -353,7 +352,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -411,7 +410,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand All @@ -434,7 +433,6 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -443,8 +441,6 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.1.4;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = com.efremidze.VisualEffectView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -462,7 +458,6 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -471,8 +466,6 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.1.4;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = com.efremidze.VisualEffectView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 122fc2f

Please sign in to comment.