Commit 0b3227fb authored by Daniil Manin's avatar Daniil Manin

Add code and examples

parent 3cbef5f9
# Created by https://www.gitignore.io/api/swift,macos,carthage,cocoapods
# Edit at https://www.gitignore.io/?templates=swift,macos,carthage,cocoapods
### Carthage ###
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
### CocoaPods ###
## CocoaPods GitIgnore Template
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
# - Also handy if you have a large number of dependant pods
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
Pods/
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Swift ###
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/
# Add this line if you want to avoid checking in Xcode SPM integration.
# .swiftpm/xcode
# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
# Accio dependency management
Dependencies/
.accio/
# fastlane
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
# End of https://www.gitignore.io/api/swift,macos,carthage,cocoapods
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
A76D5A51270EE72300A26544 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A50270EE72300A26544 /* ExampleApp.swift */; };
A76D5A53270EE72300A26544 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A52270EE72300A26544 /* ContentView.swift */; };
A76D5A55270EE72500A26544 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A76D5A54270EE72500A26544 /* Assets.xcassets */; };
A76D5A58270EE72500A26544 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A76D5A57270EE72500A26544 /* Preview Assets.xcassets */; };
D06F86197595E6C2064D1150 /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F33B8892B52568A954E16A71 /* Pods_Example.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3C9FB3B62D9479C4686E5125 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
A76D5A4D270EE72300A26544 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
A76D5A50270EE72300A26544 /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = "<group>"; };
A76D5A52270EE72300A26544 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
A76D5A54270EE72500A26544 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A76D5A57270EE72500A26544 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
CC7D7D8AF7F192B8A86F3B3B /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
F33B8892B52568A954E16A71 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
A76D5A4A270EE72300A26544 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D06F86197595E6C2064D1150 /* Pods_Example.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
02306536A13834F6C5972A5E /* Pods */ = {
isa = PBXGroup;
children = (
3C9FB3B62D9479C4686E5125 /* Pods-Example.debug.xcconfig */,
CC7D7D8AF7F192B8A86F3B3B /* Pods-Example.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
16E51A056747E677DCA266E5 /* Frameworks */ = {
isa = PBXGroup;
children = (
F33B8892B52568A954E16A71 /* Pods_Example.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
A76D5A44270EE72300A26544 = {
isa = PBXGroup;
children = (
A76D5A4F270EE72300A26544 /* Example */,
A76D5A4E270EE72300A26544 /* Products */,
02306536A13834F6C5972A5E /* Pods */,
16E51A056747E677DCA266E5 /* Frameworks */,
);
sourceTree = "<group>";
};
A76D5A4E270EE72300A26544 /* Products */ = {
isa = PBXGroup;
children = (
A76D5A4D270EE72300A26544 /* Example.app */,
);
name = Products;
sourceTree = "<group>";
};
A76D5A4F270EE72300A26544 /* Example */ = {
isa = PBXGroup;
children = (
A76D5A50270EE72300A26544 /* ExampleApp.swift */,
A76D5A52270EE72300A26544 /* ContentView.swift */,
A76D5A54270EE72500A26544 /* Assets.xcassets */,
A76D5A56270EE72500A26544 /* Preview Content */,
);
path = Example;
sourceTree = "<group>";
};
A76D5A56270EE72500A26544 /* Preview Content */ = {
isa = PBXGroup;
children = (
A76D5A57270EE72500A26544 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
A76D5A4C270EE72300A26544 /* Example */ = {
isa = PBXNativeTarget;
buildConfigurationList = A76D5A5B270EE72500A26544 /* Build configuration list for PBXNativeTarget "Example" */;
buildPhases = (
4AC6DDFBBF698B2B192B0950 /* [CP] Check Pods Manifest.lock */,
A76D5A49270EE72300A26544 /* Sources */,
A76D5A4A270EE72300A26544 /* Frameworks */,
A76D5A4B270EE72300A26544 /* Resources */,
279AEC5FA27B2194E24469C5 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Example;
productName = Example;
productReference = A76D5A4D270EE72300A26544 /* Example.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
A76D5A45270EE72300A26544 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1300;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = Exyte;
TargetAttributes = {
A76D5A4C270EE72300A26544 = {
CreatedOnToolsVersion = 13.0;
};
};
};
buildConfigurationList = A76D5A48270EE72300A26544 /* Build configuration list for PBXProject "Example" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = A76D5A44270EE72300A26544;
productRefGroup = A76D5A4E270EE72300A26544 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
A76D5A4C270EE72300A26544 /* Example */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
A76D5A4B270EE72300A26544 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A76D5A58270EE72500A26544 /* Preview Assets.xcassets in Resources */,
A76D5A55270EE72500A26544 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
279AEC5FA27B2194E24469C5 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
4AC6DDFBBF698B2B192B0950 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
A76D5A49270EE72300A26544 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A76D5A53270EE72300A26544 /* ContentView.swift in Sources */,
A76D5A51270EE72300A26544 /* ExampleApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
A76D5A59270EE72500A26544 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
A76D5A5A270EE72500A26544 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
A76D5A5C270EE72500A26544 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3C9FB3B62D9479C4686E5125 /* Pods-Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = FZXCM5CJ7P;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A76D5A5D270EE72500A26544 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = CC7D7D8AF7F192B8A86F3B3B /* Pods-Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = FZXCM5CJ7P;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
A76D5A48270EE72300A26544 /* Build configuration list for PBXProject "Example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A76D5A59270EE72500A26544 /* Debug */,
A76D5A5A270EE72500A26544 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A76D5A5B270EE72500A26544 /* Build configuration list for PBXNativeTarget "Example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A76D5A5C270EE72500A26544 /* Debug */,
A76D5A5D270EE72500A26544 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = A76D5A45270EE72300A26544 /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Example.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Example.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// ContentView.swift
// Example
//
// Created by Daniil Manin on 07.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
import ProgressIndicatorView
struct ContentView: View {
@State private var showProgressIndicator: Bool = true
@State private var progress: CGFloat = 0.0
@State private var progressForDefaultSector: CGFloat = 0.0
private let timer = Timer.publish(every: 1 / 5, on: .main, in: .common).autoconnect()
var body: some View {
GeometryReader { geometry in
let size = geometry.size.width / 5
VStack {
Spacer()
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .bar(progress: $progress, backgroundColor: .gray.opacity(0.25)))
.frame(height: 8.0)
.foregroundColor(.red)
.padding([.bottom, .horizontal], size)
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .impulseBar(progress: $progress, backgroundColor: .gray.opacity(0.25)))
.frame(height: 8.0)
.foregroundColor(.red)
.padding([.bottom, .horizontal], size)
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .dashBar(progress: $progress, numberOfItems: 8, backgroundColor: .gray.opacity(0.25)))
.frame(height: 12.0)
.foregroundColor(.red)
.padding([.bottom, .horizontal], size)
HStack {
Spacer()
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .default(progress: $progressForDefaultSector))
.foregroundColor(.red)
.frame(width: size, height: size)
Spacer()
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .circle(progress: $progress, lineWidth: 8.0, strokeColor: .red, backgroundColor: .gray.opacity(0.25)))
.frame(width: size, height: size)
Spacer()
}
Spacer()
}
}
.onReceive(timer) { _ in
switch progress {
case ...0.3, 0.4...0.6:
progress += 1 / 30
case 0.3...0.4, 0.6...0.9:
progress += 1 / 120
case 0.9...0.99:
progress = 1
case 1.0...:
progress = 0
default:
break
}
if progressForDefaultSector >= 1.5 {
progressForDefaultSector = 0
} else {
progressForDefaultSector += 1 / 10
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
//
// ExampleApp.swift
// Example
//
// Created by Daniil Manin on 07.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
@main
struct ExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
def pods
pod 'ProgressIndicatorView', :path => '../'
end
target 'Example' do
platform :ios, '14.0'
pods
end
PODS:
- ProgressIndicatorView (0.0.1)
DEPENDENCIES:
- ProgressIndicatorView (from `../`)
EXTERNAL SOURCES:
ProgressIndicatorView:
:path: "../"
SPEC CHECKSUMS:
ProgressIndicatorView: 8032bc4a860c056a178899ee7fc50fdde1010c88
PODFILE CHECKSUM: 975d16e862abaa9d708f17641a7379ef951d0ca3
COCOAPODS: 1.11.2
Copyright (c) 2019 exyte <info@exyte.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "ProgressIndicatorView",
platforms: [
.macOS(.v11),
.iOS(.v15),
.watchOS(.v7),
.tvOS(.v14)
],
products: [
.library(
name: "ProgressIndicatorView",
targets: ["ProgressIndicatorView"]
)
],
targets: [
.target(
name: "ProgressIndicatorView",
path: "Source"
)
],
swiftLanguageVersions: [.v5]
)
\ No newline at end of file
Pod::Spec.new do |s|
s.name = "ProgressIndicatorView"
s.version = "0.0.1"
s.summary = "A number of preset loading indicators created with SwiftUI."
s.homepage = 'https://github.com/exyte/ProgressIndicatorView.git'
s.license = 'MIT'
s.author = { 'Exyte' => 'info@exyte.com' }
s.source = { :git => 'https://github.com/exyte/ProgressIndicatorView.git', :tag => s.version.to_s }
s.social_media_url = 'http://exyte.com'
s.ios.deployment_target = '15.0'
s.osx.deployment_target = '11.0'
s.tvos.deployment_target = '14.0'
s.watchos.deployment_target = '7.0'
s.requires_arc = true
s.swift_version = "5.2"
s.source_files = [
'Source/*.h',
'Source/*.swift',
'Source/**/*.swift'
]
end
......@@ -7,14 +7,24 @@
objects = {
/* Begin PBXBuildFile section */
A76D5A2E270EE55D00A26544 /* ProgressIndicatorView.docc in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A2D270EE55D00A26544 /* ProgressIndicatorView.docc */; };
A76D5A2F270EE55D00A26544 /* ProgressIndicatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = A76D5A2C270EE55D00A26544 /* ProgressIndicatorView.h */; settings = {ATTRIBUTES = (Public, ); }; };
A7179C6327101DED00AAFB3A /* DashBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7179C6227101DED00AAFB3A /* DashBarView.swift */; };
A76D5A38270EE61B00A26544 /* ProgressIndicatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = A76D5A37270EE61B00A26544 /* ProgressIndicatorView.h */; };
A76D5A3A270EE6AE00A26544 /* ProgressIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A39270EE6AE00A26544 /* ProgressIndicatorView.swift */; };
A76D5A40270EE6D200A26544 /* ImpulseBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A3C270EE6D200A26544 /* ImpulseBarView.swift */; };
A76D5A41270EE6D200A26544 /* CircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A3D270EE6D200A26544 /* CircleView.swift */; };
A76D5A42270EE6D200A26544 /* DefaultSectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A3E270EE6D200A26544 /* DefaultSectorView.swift */; };
A76D5A43270EE6D200A26544 /* BarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76D5A3F270EE6D200A26544 /* BarView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
A7179C6227101DED00AAFB3A /* DashBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashBarView.swift; sourceTree = "<group>"; };
A76D5A29270EE55D00A26544 /* ProgressIndicatorView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ProgressIndicatorView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A76D5A2C270EE55D00A26544 /* ProgressIndicatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProgressIndicatorView.h; sourceTree = "<group>"; };
A76D5A2D270EE55D00A26544 /* ProgressIndicatorView.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = ProgressIndicatorView.docc; sourceTree = "<group>"; };
A76D5A37270EE61B00A26544 /* ProgressIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressIndicatorView.h; sourceTree = "<group>"; };
A76D5A39270EE6AE00A26544 /* ProgressIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressIndicatorView.swift; sourceTree = "<group>"; };
A76D5A3C270EE6D200A26544 /* ImpulseBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImpulseBarView.swift; sourceTree = "<group>"; };
A76D5A3D270EE6D200A26544 /* CircleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleView.swift; sourceTree = "<group>"; };
A76D5A3E270EE6D200A26544 /* DefaultSectorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultSectorView.swift; sourceTree = "<group>"; };
A76D5A3F270EE6D200A26544 /* BarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -31,7 +41,7 @@
A76D5A1F270EE55D00A26544 = {
isa = PBXGroup;
children = (
A76D5A2B270EE55D00A26544 /* ProgressIndicatorView */,
A76D5A36270EE61B00A26544 /* Source */,
A76D5A2A270EE55D00A26544 /* Products */,
);
sourceTree = "<group>";
......@@ -44,13 +54,26 @@
name = Products;
sourceTree = "<group>";
};
A76D5A2B270EE55D00A26544 /* ProgressIndicatorView */ = {
A76D5A36270EE61B00A26544 /* Source */ = {
isa = PBXGroup;
children = (
A76D5A2C270EE55D00A26544 /* ProgressIndicatorView.h */,
A76D5A2D270EE55D00A26544 /* ProgressIndicatorView.docc */,
A76D5A3B270EE6C000A26544 /* Indicators */,
A76D5A39270EE6AE00A26544 /* ProgressIndicatorView.swift */,
A76D5A37270EE61B00A26544 /* ProgressIndicatorView.h */,
);
path = ProgressIndicatorView;
path = Source;
sourceTree = "<group>";
};
A76D5A3B270EE6C000A26544 /* Indicators */ = {
isa = PBXGroup;
children = (
A76D5A3F270EE6D200A26544 /* BarView.swift */,
A76D5A3D270EE6D200A26544 /* CircleView.swift */,
A76D5A3E270EE6D200A26544 /* DefaultSectorView.swift */,
A76D5A3C270EE6D200A26544 /* ImpulseBarView.swift */,
A7179C6227101DED00AAFB3A /* DashBarView.swift */,
);
path = Indicators;
sourceTree = "<group>";
};
/* End PBXGroup section */
......@@ -60,7 +83,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
A76D5A2F270EE55D00A26544 /* ProgressIndicatorView.h in Headers */,
A76D5A38270EE61B00A26544 /* ProgressIndicatorView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -93,9 +116,11 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = Exyte;
TargetAttributes = {
A76D5A28270EE55D00A26544 = {
CreatedOnToolsVersion = 13.0;
LastSwiftMigration = 1300;
};
};
};
......@@ -132,7 +157,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A76D5A2E270EE55D00A26544 /* ProgressIndicatorView.docc in Sources */,
A7179C6327101DED00AAFB3A /* DashBarView.swift in Sources */,
A76D5A41270EE6D200A26544 /* CircleView.swift in Sources */,
A76D5A40270EE6D200A26544 /* ImpulseBarView.swift in Sources */,
A76D5A42270EE6D200A26544 /* DefaultSectorView.swift in Sources */,
A76D5A3A270EE6AE00A26544 /* ProgressIndicatorView.swift in Sources */,
A76D5A43270EE6D200A26544 /* BarView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -264,6 +294,7 @@
A76D5A33270EE55D00A26544 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
......@@ -284,6 +315,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
......@@ -292,6 +324,7 @@
A76D5A34270EE55D00A26544 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
......
# ``ProgressIndicatorView``
<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@-->
## Overview
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@-->
## Topics
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->
\ No newline at end of file
<img src="https://github.com/exyte/ProgressIndicatorView/blob/master/Assets/header.png">
<img align="right" src="https://raw.githubusercontent.com/exyte/ProgressIndicatorView/master/Assets/demo.gif" width="480" />
<p><h1 align="left">ProgressIndicatorView</h1></p>
<p><h4>A number of preset loading indicators created with SwiftUI</h4></p>
___
<p> We are a development agency building
<a href="https://clutch.co/profile/exyte#review-731233">phenomenal</a> apps.</p>
</br>
<a href="https://exyte.com/contacts"><img src="https://i.imgur.com/vGjsQPt.png" width="134" height="34"></a> <a href="https://twitter.com/exyteHQ"><img src="https://i.imgur.com/DngwSn1.png" width="165" height="34"></a>
</br></br>
[![Travis CI](https://travis-ci.org/exyte/ActivityIndicatorView.svg?branch=master)](https://travis-ci.org/exyte/ProgressIndicatorView)
[![Version](https://img.shields.io/cocoapods/v/ActivityIndicatorView.svg?style=flat)](http://cocoapods.org/pods/ProgressIndicatorView)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-0473B3.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/ActivityIndicatorView.svg?style=flat)](http://cocoapods.org/pods/ProgressIndicatorView)
[![Platform](https://img.shields.io/cocoapods/p/ActivityIndicatorView.svg?style=flat)](http://cocoapods.org/pods/ProgressIndicatorView)
[![Twitter](https://img.shields.io/badge/Twitter-@exyteHQ-blue.svg?style=flat)](http://twitter.com/exyteHQ)
# Usage
Create a progress indicator like this:
```swift
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .bar(progress: $progress))
```
where
`showProgressIndicator` - bool value you may change to display or hide the indicator
`type` - value from `ProgressIndicatorView.IndicatorType` enum
You may alter it with standard SwiftUI means like this:
```swift
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .bar(progress: $progress))
.frame(width: 50.0, height: 50.0)
.foregroundColor(.red)
```
### Indicator types
`default` - progress indicator looks like default iOS UIActivityIndicator.
`bar` - line progress bar with a Binding<CGFloat> progress value and background color, default is `Color.clear`:
```swift
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .bar(progress: $progress, backgroundColor: .gray)
.frame(height: 8.0)
.foregroundColor(.red)
```
`impulseBar` - impulse line bar, works as `bar` indicator with an impulse effect.
`dashBar` - discrete line bar, with number of pieces, default is 8:
```swift
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .dashBar(progress: $progress, numberOfItems: 8))
.frame(height: 8.0)
.foregroundColor(.red)
```
`circle` - cirle progress indicator, with `lineWidth` and `strokeColor`:
```swift
ProgressIndicatorView(isVisible: $showProgressIndicator, type: .circle(progress: $progress, lineWidth: 8.0, strokeColor: .red))
.frame(height: 8.0)
.foregroundColor(.red)
```
## Examples
To try out the ActivityIndicatorView examples:
- Clone the repo `git clone git@github.com:exyte/ProgressIndicatorView.git`
- Open terminal and run `cd <ProgressIndicatorViewRepo>/Example`
- Run `pod install` to install all dependencies
- Run `xed .` to open project in the Xcode
- Try it!
## Installation
### CocoaPods
```ruby
pod 'ProgressIndicatorView'
```
### Carthage
```ogdl
github "Exyte/ProgressIndicatorView"
```
### Swift Package Manager
```swift
dependencies: [
.package(url: "https://github.com/exyte/ProgressIndicatorView.git", from: "0.0.1")
]
```
## Requirements
* iOS 15+ / watchOS 7+ / tvOS 14+ / macOS 11+
* Xcode 13+
//
// BarView.swift
// ActivityIndicatorView
//
// Created by Daniil Manin on 16.09.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
struct BarView: View {
@Binding var progress: CGFloat
let backgroundColor: Color
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
Capsule()
.foregroundColor(backgroundColor)
Capsule()
.frame(width: min(max(geometry.size.width * progress, 0), geometry.size.width))
.animation(.easeIn, value: progress)
}
}
}
}
//
// CircleView.swift
// ActivityIndicatorView
//
// Created by Daniil Manin on 07.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
struct CircleView: View {
@Binding var progress: CGFloat
let lineWidth: CGFloat
let strokeColor: Color
let backgroundColor: Color
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
Arc(startAngle: .radians(-.pi / 2), endAngle: .radians(.pi * 3 / 2))
.stroke(backgroundColor, style: .init(lineWidth: lineWidth, lineCap: .butt, lineJoin: .miter))
Arc(startAngle: .radians(-.pi / 2), endAngle: .radians(.pi * 3 / 2 * progress))
.stroke(strokeColor, style: .init(lineWidth: lineWidth, lineCap: .butt, lineJoin: .miter))
.animation(.easeIn, value: progress)
}
}
}
}
struct Arc: Shape {
var startAngle: Angle
var endAngle: Angle
var clockwise: Bool = false
var animatableData: CGFloat {
get { CGFloat(endAngle.radians) }
set { endAngle = Angle(radians: newValue) }
}
func path(in rect: CGRect) -> Path {
Path { path in
path.addArc(
center: .init(x: rect.midX, y: rect.midY),
radius: rect.width / 2.0,
startAngle: startAngle,
endAngle: endAngle,
clockwise: clockwise)
}
}
}
//
// DashBarView.swift
// ProgressIndicatorView
//
// Created by Daniil Manin on 08.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
struct DashBarView: View {
@Binding var progress: CGFloat
let numberOfItems: Int
let backgroundColor: Color
private let spacing: CGFloat = 4.0
var body: some View {
GeometryReader { geometry in
let itemWidth = widthForItem(fullWidth: geometry.size.width)
HStack(spacing: spacing) {
ForEach(0..<numberOfItems) { index in
DashBarItemView(
backgroundColor: backgroundColor,
needToFill: progress > (1 / CGFloat(numberOfItems) * CGFloat(index)),
width: itemWidth)
}
}
}
}
// MARK: - Private
private func widthForItem(fullWidth: CGFloat) -> CGFloat {
(fullWidth - CGFloat(numberOfItems - 1) * spacing) / CGFloat(numberOfItems)
}
}
struct DashBarItemView: View {
let backgroundColor: Color
let needToFill: Bool
let width: CGFloat
var body: some View {
ZStack(alignment: .leading) {
Capsule()
.foregroundColor(backgroundColor)
Capsule()
.frame(width: needToFill ? width : 0.0)
.animation(.easeIn, value: needToFill)
}
}
}
//
// DefaultSectorView.swift
// ActivityIndicatorView
//
// Created by Daniil Manin on 06.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
struct DefaultSectorView: View {
@Binding var progress: CGFloat
private let count: Int = 8
@State private var rotationAngle: Angle = .radians(0)
public var body: some View {
GeometryReader { geometry in
Group {
ForEach(0..<count) { index in
DefaultSectorItemView(index: index, count: count, size: geometry.size)
.opacity(progress * 2.0 - CGFloat(index) * 1 / CGFloat(count) - 0.1)
.animation(.linear, value: progress)
}
}
.rotationEffect(rotationAngle)
.frame(width: geometry.size.width, height: geometry.size.height)
.onChange(of: progress) { _ in
if progress > 1.0 {
withAnimation(.linear(duration: 1)) {
rotationAngle = .radians(.pi * 2.0)
}
} else {
rotationAngle = .zero
}
}
}
}
}
struct DefaultSectorItemView: View {
let index: Int
let count: Int
let size: CGSize
var body: some View {
let height = size.height / 3.2
let width = height / 2
let angle = 2 * .pi / CGFloat(count) * CGFloat(index) - .pi / 2
let x = (size.width / 2 - height / 2) * cos(angle)
let y = (size.height / 2 - height / 2) * sin(angle)
return RoundedRectangle(cornerRadius: width / 2 + 1)
.frame(width: width, height: height)
.rotationEffect(.radians(angle + .pi / 2))
.offset(x: x, y: y)
}
}
//
// ImpulseBarView.swift
// ActivityIndicatorView
//
// Created by Daniil Manin on 05.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
struct ImpulseBarView: View {
@Binding var progress: CGFloat
let backgroundColor: Color
@State private var offset: CGFloat = -200.0 // x2 gradientWidth
private let animation: Animation = .linear(duration: 1.5).repeatForever(autoreverses: false)
private let gradientWidth: CGFloat = 100.0
private let gradient = Gradient(
colors: [
.white.opacity(0.0),
.white.opacity(0.25),
.white.opacity(0.5),
.white.opacity(0.75),
.white.opacity(0.85),
.white.opacity(0.75),
.white.opacity(0.5),
.white.opacity(0.25),
.white.opacity(0.0)
]
)
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
Capsule()
.foregroundColor(backgroundColor)
Capsule()
.animation(.easeIn, value: progress)
.frame(width: min(max(geometry.size.width * progress, 0), geometry.size.width))
.overlay(
LinearGradient(gradient: gradient, startPoint: .leading, endPoint: .trailing)
.frame(width: gradientWidth)
.offset(x: offset)
)
.clipped()
}
.onAppear {
withAnimation(animation) {
offset = geometry.size.width
}
}
}
}
}
//
// ProgressIndicatorView.swift
// ActivityIndicatorView
//
// Created by Daniil Manin on 05.10.2021.
// Copyright © 2021 Exyte. All rights reserved.
//
import SwiftUI
public struct ProgressIndicatorView: View {
public enum IndicatorType {
case `default`(progress: Binding<CGFloat>)
case bar(progress: Binding<CGFloat>, backgroundColor: Color = .clear)
case impulseBar(progress: Binding<CGFloat>, backgroundColor: Color = .clear)
case dashBar(progress: Binding<CGFloat>, numberOfItems: Int = 8, backgroundColor: Color = .clear)
case circle(progress: Binding<CGFloat>, lineWidth: CGFloat, strokeColor: Color, backgroundColor: Color = .clear)
}
@Binding var isVisible: Bool
var type: IndicatorType
public init(isVisible: Binding<Bool>, type: IndicatorType) {
self._isVisible = isVisible
self.type = type
}
public var body: some View {
if isVisible {
indicator
} else {
EmptyView()
}
}
// MARK: - Private
private var indicator: some View {
ZStack {
switch type {
case .bar(let progress, let backgroundColor):
BarView(progress: progress, backgroundColor: backgroundColor)
case .impulseBar(let progress, let backgroundColor):
ImpulseBarView(progress: progress, backgroundColor: backgroundColor)
case .`default`(let progress):
DefaultSectorView(progress: progress)
case .circle(let progress, let lineWidth, let strokeColor, let backgroundColor):
CircleView(progress: progress, lineWidth: lineWidth, strokeColor: strokeColor, backgroundColor: backgroundColor)
case .dashBar(let progress, let numberOfItems, let backgroundColor):
DashBarView(progress: progress, numberOfItems: numberOfItems, backgroundColor: backgroundColor)
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment