From 4a80b62cc56f6cb88577101b4e3c156af072823d Mon Sep 17 00:00:00 2001 From: LawrenceGlow Date: Thu, 28 Mar 2019 19:01:55 +0800 Subject: [PATCH 1/4] added popover animation --- Demo/Demo.xcodeproj/project.pbxproj | 119 ++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Demo/Demo/AView.swift | 20 + Demo/Demo/AView.xib | 42 ++ Demo/Demo/Base.lproj/Main.storyboard | 49 +- Demo/Demo/CustomAnimation.swift | 433 ++++++++++++++++++ Demo/Demo/CustomPanHandler.swift | 177 +++++++ Demo/Demo/TacoDialogView.xib | 37 +- Demo/Demo/TestView.swift | 14 + Demo/Demo/TestViewController.swift | 31 ++ Demo/Demo/ViewController.swift | 36 +- Demo/Source/Stevia+Alignment.swift | 366 +++++++++++++++ Demo/Source/Stevia+Baselines.swift | 77 ++++ Demo/Source/Stevia+Center.swift | 102 +++++ Demo/Source/Stevia+Constraints.swift | 150 ++++++ Demo/Source/Stevia+Content.swift | 102 +++++ Demo/Source/Stevia+DoubleDash.swift | 98 ++++ Demo/Source/Stevia+Equation.swift | 252 ++++++++++ Demo/Source/Stevia+Fill.swift | 70 +++ Demo/Source/Stevia+FlexibleMargin.swift | 126 +++++ Demo/Source/Stevia+GetConstraint.swift | 197 ++++++++ Demo/Source/Stevia+Hierarchy.swift | 165 +++++++ Demo/Source/Stevia+LayoutAnchors.swift | 151 ++++++ Demo/Source/Stevia+Notifications.swift | 20 + Demo/Source/Stevia+Operators.swift | 208 +++++++++ Demo/Source/Stevia+Percentage.swift | 175 +++++++ Demo/Source/Stevia+Position.swift | 171 +++++++ Demo/Source/Stevia+Size.swift | 279 +++++++++++ Demo/Source/Stevia+Stacks.swift | 162 +++++++ Demo/Source/Stevia+Style.swift | 43 ++ SwiftMessages/Resources/TestView.xib | 124 +++++ 31 files changed, 3965 insertions(+), 39 deletions(-) create mode 100644 Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Demo/Demo/AView.swift create mode 100644 Demo/Demo/AView.xib create mode 100644 Demo/Demo/CustomAnimation.swift create mode 100644 Demo/Demo/CustomPanHandler.swift create mode 100644 Demo/Demo/TestView.swift create mode 100644 Demo/Demo/TestViewController.swift create mode 100644 Demo/Source/Stevia+Alignment.swift create mode 100644 Demo/Source/Stevia+Baselines.swift create mode 100644 Demo/Source/Stevia+Center.swift create mode 100644 Demo/Source/Stevia+Constraints.swift create mode 100644 Demo/Source/Stevia+Content.swift create mode 100644 Demo/Source/Stevia+DoubleDash.swift create mode 100644 Demo/Source/Stevia+Equation.swift create mode 100644 Demo/Source/Stevia+Fill.swift create mode 100644 Demo/Source/Stevia+FlexibleMargin.swift create mode 100644 Demo/Source/Stevia+GetConstraint.swift create mode 100644 Demo/Source/Stevia+Hierarchy.swift create mode 100644 Demo/Source/Stevia+LayoutAnchors.swift create mode 100644 Demo/Source/Stevia+Notifications.swift create mode 100644 Demo/Source/Stevia+Operators.swift create mode 100644 Demo/Source/Stevia+Percentage.swift create mode 100644 Demo/Source/Stevia+Position.swift create mode 100644 Demo/Source/Stevia+Size.swift create mode 100644 Demo/Source/Stevia+Stacks.swift create mode 100644 Demo/Source/Stevia+Style.swift create mode 100644 SwiftMessages/Resources/TestView.xib diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj index 780b3fd6..e68ec64e 100644 --- a/Demo/Demo.xcodeproj/project.pbxproj +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -7,6 +7,32 @@ objects = { /* Begin PBXBuildFile section */ + 022658412238FCD600991DA2 /* TestView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 022658402238FCD600991DA2 /* TestView.xib */; }; + 022658432238FD4500991DA2 /* TestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022658422238FD4500991DA2 /* TestView.swift */; }; + 022658452238FE0C00991DA2 /* AView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 022658442238FE0C00991DA2 /* AView.xib */; }; + 022658472238FEC000991DA2 /* AView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022658462238FEC000991DA2 /* AView.swift */; }; + 029050DF2191737E00B9681F /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029050DE2191737E00B9681F /* TestViewController.swift */; }; + 02F4F97C224C6766009CC649 /* CustomAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F97B224C6766009CC649 /* CustomAnimation.swift */; }; + 02F4F97F224C6890009CC649 /* CustomPanHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F97E224C6890009CC649 /* CustomPanHandler.swift */; }; + 02F4F996224C727A009CC649 /* Stevia+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F981224C7279009CC649 /* Stevia+Style.swift */; }; + 02F4F997224C727A009CC649 /* Stevia+DoubleDash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F982224C7279009CC649 /* Stevia+DoubleDash.swift */; }; + 02F4F998224C727A009CC649 /* Stevia+GetConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F983224C7279009CC649 /* Stevia+GetConstraint.swift */; }; + 02F4F999224C727A009CC649 /* Stevia+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F984224C7279009CC649 /* Stevia+Operators.swift */; }; + 02F4F99A224C727A009CC649 /* Stevia+Center.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F985224C7279009CC649 /* Stevia+Center.swift */; }; + 02F4F99B224C727A009CC649 /* Stevia+Fill.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F986224C7279009CC649 /* Stevia+Fill.swift */; }; + 02F4F99C224C727A009CC649 /* Stevia+Position.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F987224C7279009CC649 /* Stevia+Position.swift */; }; + 02F4F99D224C727A009CC649 /* Stevia+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F988224C7279009CC649 /* Stevia+Notifications.swift */; }; + 02F4F99E224C727A009CC649 /* Stevia+FlexibleMargin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F989224C7279009CC649 /* Stevia+FlexibleMargin.swift */; }; + 02F4F99F224C727A009CC649 /* Stevia+Baselines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F98A224C7279009CC649 /* Stevia+Baselines.swift */; }; + 02F4F9A0224C727A009CC649 /* Stevia+Hierarchy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F98B224C7279009CC649 /* Stevia+Hierarchy.swift */; }; + 02F4F9A1224C727A009CC649 /* Stevia+Constraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F98C224C7279009CC649 /* Stevia+Constraints.swift */; }; + 02F4F9A2224C727A009CC649 /* Stevia+Size.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F98E224C7279009CC649 /* Stevia+Size.swift */; }; + 02F4F9A3224C727A009CC649 /* Stevia+Stacks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F98F224C7279009CC649 /* Stevia+Stacks.swift */; }; + 02F4F9A4224C727A009CC649 /* Stevia+Percentage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F990224C7279009CC649 /* Stevia+Percentage.swift */; }; + 02F4F9A5224C727A009CC649 /* Stevia+Equation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F991224C7279009CC649 /* Stevia+Equation.swift */; }; + 02F4F9A6224C727A009CC649 /* Stevia+Alignment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F992224C7279009CC649 /* Stevia+Alignment.swift */; }; + 02F4F9A7224C727A009CC649 /* Stevia+LayoutAnchors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F993224C7279009CC649 /* Stevia+LayoutAnchors.swift */; }; + 02F4F9A9224C727A009CC649 /* Stevia+Content.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F4F995224C7279009CC649 /* Stevia+Content.swift */; }; 22652712210F698600310344 /* TacoDialogView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 86C0AB9F1D5E814600F76BD6 /* TacoDialogView.xib */; }; 226FA5E61F506993004CB2BC /* CountedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226FA5E51F506993004CB2BC /* CountedViewController.swift */; }; 226FA5E81F5071D0004CB2BC /* CountedMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226FA5E71F5071D0004CB2BC /* CountedMessageView.swift */; }; @@ -79,6 +105,32 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 022658402238FCD600991DA2 /* TestView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = TestView.xib; path = ../../SwiftMessages/Resources/TestView.xib; sourceTree = ""; }; + 022658422238FD4500991DA2 /* TestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestView.swift; sourceTree = ""; }; + 022658442238FE0C00991DA2 /* AView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AView.xib; sourceTree = ""; }; + 022658462238FEC000991DA2 /* AView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AView.swift; sourceTree = ""; }; + 029050DE2191737E00B9681F /* TestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewController.swift; sourceTree = ""; }; + 02F4F97B224C6766009CC649 /* CustomAnimation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAnimation.swift; sourceTree = ""; }; + 02F4F97E224C6890009CC649 /* CustomPanHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPanHandler.swift; sourceTree = ""; }; + 02F4F981224C7279009CC649 /* Stevia+Style.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Style.swift"; sourceTree = ""; }; + 02F4F982224C7279009CC649 /* Stevia+DoubleDash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+DoubleDash.swift"; sourceTree = ""; }; + 02F4F983224C7279009CC649 /* Stevia+GetConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+GetConstraint.swift"; sourceTree = ""; }; + 02F4F984224C7279009CC649 /* Stevia+Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Operators.swift"; sourceTree = ""; }; + 02F4F985224C7279009CC649 /* Stevia+Center.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Center.swift"; sourceTree = ""; }; + 02F4F986224C7279009CC649 /* Stevia+Fill.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Fill.swift"; sourceTree = ""; }; + 02F4F987224C7279009CC649 /* Stevia+Position.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Position.swift"; sourceTree = ""; }; + 02F4F988224C7279009CC649 /* Stevia+Notifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Notifications.swift"; sourceTree = ""; }; + 02F4F989224C7279009CC649 /* Stevia+FlexibleMargin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+FlexibleMargin.swift"; sourceTree = ""; }; + 02F4F98A224C7279009CC649 /* Stevia+Baselines.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Baselines.swift"; sourceTree = ""; }; + 02F4F98B224C7279009CC649 /* Stevia+Hierarchy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Hierarchy.swift"; sourceTree = ""; }; + 02F4F98C224C7279009CC649 /* Stevia+Constraints.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Constraints.swift"; sourceTree = ""; }; + 02F4F98E224C7279009CC649 /* Stevia+Size.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Size.swift"; sourceTree = ""; }; + 02F4F98F224C7279009CC649 /* Stevia+Stacks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Stacks.swift"; sourceTree = ""; }; + 02F4F990224C7279009CC649 /* Stevia+Percentage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Percentage.swift"; sourceTree = ""; }; + 02F4F991224C7279009CC649 /* Stevia+Equation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Equation.swift"; sourceTree = ""; }; + 02F4F992224C7279009CC649 /* Stevia+Alignment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Alignment.swift"; sourceTree = ""; }; + 02F4F993224C7279009CC649 /* Stevia+LayoutAnchors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+LayoutAnchors.swift"; sourceTree = ""; }; + 02F4F995224C7279009CC649 /* Stevia+Content.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Stevia+Content.swift"; sourceTree = ""; }; 226FA5E51F506993004CB2BC /* CountedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CountedViewController.swift; sourceTree = ""; }; 226FA5E71F5071D0004CB2BC /* CountedMessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CountedMessageView.swift; sourceTree = ""; }; 226FA5E91F507586004CB2BC /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; @@ -109,6 +161,32 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 02F4F980224C7279009CC649 /* Source */ = { + isa = PBXGroup; + children = ( + 02F4F981224C7279009CC649 /* Stevia+Style.swift */, + 02F4F982224C7279009CC649 /* Stevia+DoubleDash.swift */, + 02F4F983224C7279009CC649 /* Stevia+GetConstraint.swift */, + 02F4F984224C7279009CC649 /* Stevia+Operators.swift */, + 02F4F985224C7279009CC649 /* Stevia+Center.swift */, + 02F4F986224C7279009CC649 /* Stevia+Fill.swift */, + 02F4F987224C7279009CC649 /* Stevia+Position.swift */, + 02F4F988224C7279009CC649 /* Stevia+Notifications.swift */, + 02F4F989224C7279009CC649 /* Stevia+FlexibleMargin.swift */, + 02F4F98A224C7279009CC649 /* Stevia+Baselines.swift */, + 02F4F98B224C7279009CC649 /* Stevia+Hierarchy.swift */, + 02F4F98C224C7279009CC649 /* Stevia+Constraints.swift */, + 02F4F98E224C7279009CC649 /* Stevia+Size.swift */, + 02F4F98F224C7279009CC649 /* Stevia+Stacks.swift */, + 02F4F990224C7279009CC649 /* Stevia+Percentage.swift */, + 02F4F991224C7279009CC649 /* Stevia+Equation.swift */, + 02F4F992224C7279009CC649 /* Stevia+Alignment.swift */, + 02F4F993224C7279009CC649 /* Stevia+LayoutAnchors.swift */, + 02F4F995224C7279009CC649 /* Stevia+Content.swift */, + ); + path = Source; + sourceTree = ""; + }; 22FB323B21193A3B005C13D9 /* Products */ = { isa = PBXGroup; children = ( @@ -129,6 +207,7 @@ 86AEDCD91D5D1DB70030232E = { isa = PBXGroup; children = ( + 02F4F980224C7279009CC649 /* Source */, 86AEDCE41D5D1DB70030232E /* Demo */, 86AEDCE31D5D1DB70030232E /* Products */, 6AB98897E817EE976DD72852 /* Frameworks */, @@ -150,6 +229,8 @@ 86AEDCE51D5D1DB70030232E /* AppDelegate.swift */, 86AEDCE91D5D1DB70030232E /* Main.storyboard */, 86AEDCE71D5D1DB70030232E /* ViewController.swift */, + 02F4F97B224C6766009CC649 /* CustomAnimation.swift */, + 02F4F97E224C6890009CC649 /* CustomPanHandler.swift */, 8642F4351D5F7F540061BDCD /* ExploreViewController.swift */, 226FA5E51F506993004CB2BC /* CountedViewController.swift */, 22F27952210D0FDE00273E7F /* ViewControllersViewController.swift */, @@ -158,8 +239,13 @@ 86AEDCF11D5D1DB70030232E /* Info.plist */, 86C0ABA11D5E816600F76BD6 /* TacoDialogView.swift */, 86C0AB9F1D5E814600F76BD6 /* TacoDialogView.xib */, + 022658402238FCD600991DA2 /* TestView.xib */, + 022658422238FD4500991DA2 /* TestView.swift */, + 022658442238FE0C00991DA2 /* AView.xib */, + 022658462238FEC000991DA2 /* AView.swift */, 226FA5E71F5071D0004CB2BC /* CountedMessageView.swift */, 226FA5E91F507586004CB2BC /* Utils.swift */, + 029050DE2191737E00B9681F /* TestViewController.swift */, ); path = Demo; sourceTree = ""; @@ -200,7 +286,7 @@ TargetAttributes = { 86AEDCE11D5D1DB70030232E = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 38R82CD868; + DevelopmentTeam = 89YHB42JY7; LastSwiftMigration = 1000; }; }; @@ -210,6 +296,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -251,8 +338,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 022658452238FE0C00991DA2 /* AView.xib in Resources */, 86AEDCF01D5D1DB70030232E /* LaunchScreen.storyboard in Resources */, 22652712210F698600310344 /* TacoDialogView.xib in Resources */, + 022658412238FCD600991DA2 /* TestView.xib in Resources */, 86AEDCED1D5D1DB70030232E /* Assets.xcassets in Resources */, 86AEDCEB1D5D1DB70030232E /* Main.storyboard in Resources */, ); @@ -265,14 +354,38 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 02F4F9A7224C727A009CC649 /* Stevia+LayoutAnchors.swift in Sources */, + 02F4F9A9224C727A009CC649 /* Stevia+Content.swift in Sources */, + 02F4F99A224C727A009CC649 /* Stevia+Center.swift in Sources */, + 02F4F99D224C727A009CC649 /* Stevia+Notifications.swift in Sources */, 8642F4361D5F7F540061BDCD /* ExploreViewController.swift in Sources */, + 02F4F9A6224C727A009CC649 /* Stevia+Alignment.swift in Sources */, + 02F4F998224C727A009CC649 /* Stevia+GetConstraint.swift in Sources */, + 02F4F997224C727A009CC649 /* Stevia+DoubleDash.swift in Sources */, + 022658472238FEC000991DA2 /* AView.swift in Sources */, + 02F4F99B224C727A009CC649 /* Stevia+Fill.swift in Sources */, 226FA5E81F5071D0004CB2BC /* CountedMessageView.swift in Sources */, + 02F4F996224C727A009CC649 /* Stevia+Style.swift in Sources */, 86AEDCE81D5D1DB70030232E /* ViewController.swift in Sources */, + 02F4F9A2224C727A009CC649 /* Stevia+Size.swift in Sources */, + 02F4F9A4224C727A009CC649 /* Stevia+Percentage.swift in Sources */, + 02F4F999224C727A009CC649 /* Stevia+Operators.swift in Sources */, + 02F4F9A5224C727A009CC649 /* Stevia+Equation.swift in Sources */, 226FA5EA1F507586004CB2BC /* Utils.swift in Sources */, + 02F4F99E224C727A009CC649 /* Stevia+FlexibleMargin.swift in Sources */, + 02F4F99F224C727A009CC649 /* Stevia+Baselines.swift in Sources */, + 02F4F97F224C6890009CC649 /* CustomPanHandler.swift in Sources */, + 02F4F9A0224C727A009CC649 /* Stevia+Hierarchy.swift in Sources */, + 02F4F99C224C727A009CC649 /* Stevia+Position.swift in Sources */, 86AEDCE61D5D1DB70030232E /* AppDelegate.swift in Sources */, + 02F4F9A3224C727A009CC649 /* Stevia+Stacks.swift in Sources */, 226FA5E61F506993004CB2BC /* CountedViewController.swift in Sources */, + 022658432238FD4500991DA2 /* TestView.swift in Sources */, + 02F4F9A1224C727A009CC649 /* Stevia+Constraints.swift in Sources */, 86C0ABA21D5E816600F76BD6 /* TacoDialogView.swift in Sources */, + 029050DF2191737E00B9681F /* TestViewController.swift in Sources */, 22F27953210D0FDE00273E7F /* ViewControllersViewController.swift in Sources */, + 02F4F97C224C6766009CC649 /* CustomAnimation.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -423,7 +536,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = 38R82CD868; + DEVELOPMENT_TEAM = 89YHB42JY7; INFOPLIST_FILE = Demo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo; @@ -438,7 +551,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = 38R82CD868; + DEVELOPMENT_TEAM = 89YHB42JY7; INFOPLIST_FILE = Demo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo; diff --git a/Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Demo/Demo/AView.swift b/Demo/Demo/AView.swift new file mode 100644 index 00000000..14a9994e --- /dev/null +++ b/Demo/Demo/AView.swift @@ -0,0 +1,20 @@ +// +// AView.swift +// Demo +// +// Created by Hanguang on 2019/3/13. +// Copyright © 2019 SwiftKick Mobile. All rights reserved. +// + +import UIKit +import SwiftMessages + +class AView: MessageView { + var position: CGPoint = .zero { + didSet { + var frame = backgroundView.frame + frame.origin = position + backgroundView.frame = frame + } + } +} diff --git a/Demo/Demo/AView.xib b/Demo/Demo/AView.xib new file mode 100644 index 00000000..c05025da --- /dev/null +++ b/Demo/Demo/AView.xib @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Base.lproj/Main.storyboard b/Demo/Demo/Base.lproj/Main.storyboard index 12449d96..93e7be66 100644 --- a/Demo/Demo/Base.lproj/Main.storyboard +++ b/Demo/Demo/Base.lproj/Main.storyboard @@ -1,13 +1,11 @@ - + - - - + @@ -220,7 +218,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -833,10 +856,10 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 66d5717f9d06abb2efe2453ded5aace395666cbb Mon Sep 17 00:00:00 2001 From: LawrenceGlow Date: Thu, 28 Mar 2019 19:03:32 +0800 Subject: [PATCH 2/4] deleted unused code --- Demo/Demo/CustomAnimation.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Demo/Demo/CustomAnimation.swift b/Demo/Demo/CustomAnimation.swift index cd6f491c..c464be39 100644 --- a/Demo/Demo/CustomAnimation.swift +++ b/Demo/Demo/CustomAnimation.swift @@ -15,8 +15,6 @@ public class CustomAnimation: NSObject, Animator { case down } - private var arrowDirection: ArrowDirection = .up - weak public var delegate: AnimationDelegate? weak var messageView: UIView? weak var containerView: UIView? @@ -29,12 +27,11 @@ public class CustomAnimation: NSObject, Animator { let layer = CAShapeLayer() return layer }() - + private var arrowDirection: ArrowDirection = .up var containerSize: CGSize { return containerView?.frame.size ?? .zero } var cornerRadius: CGFloat = 15.0 - var popoverFrame: CGRect? var popoverView: UIView? var fillColor: CGColor? = UIColor.white.cgColor From eedcd21d72de7c2df6910830d200c5027ba51c78 Mon Sep 17 00:00:00 2001 From: LawrenceHan Date: Fri, 29 Mar 2019 10:32:37 +0800 Subject: [PATCH 3/4] deleted unused code 2 --- Demo/Demo/AView.xib | 2 +- Demo/Demo/CustomAnimation.swift | 92 ++++++++++++++------------------- 2 files changed, 41 insertions(+), 53 deletions(-) diff --git a/Demo/Demo/AView.xib b/Demo/Demo/AView.xib index c05025da..08d1536b 100644 --- a/Demo/Demo/AView.xib +++ b/Demo/Demo/AView.xib @@ -17,7 +17,7 @@ - + diff --git a/Demo/Demo/CustomAnimation.swift b/Demo/Demo/CustomAnimation.swift index c464be39..358933f0 100644 --- a/Demo/Demo/CustomAnimation.swift +++ b/Demo/Demo/CustomAnimation.swift @@ -15,6 +15,10 @@ public class CustomAnimation: NSObject, Animator { case down } + public var margin: CGFloat = 4 + public var arrowWidth: CGFloat = 8 + public var arrowHeight: CGFloat = 10 + weak public var delegate: AnimationDelegate? weak var messageView: UIView? weak var containerView: UIView? @@ -112,10 +116,10 @@ public class CustomAnimation: NSObject, Animator { menuView.height(values.menuFrame.height) view.fillHorizontally() if arrowDirection == .up { - view.top(FT.DefaultMenuArrowHeight) + view.top(arrowHeight) view.bottom(0) } else { - view.bottom(FT.DefaultMenuArrowHeight) + view.bottom(arrowHeight) view.top(0) } @@ -181,21 +185,21 @@ extension CustomAnimation { // arrow point arrowPoint = CGPoint(x: senderRect.midX, y: 0) let menuSize = menuView.frame.size - let menuCenterX = menuSize.width/2 + FT.DefaultMargin + let menuCenterX = menuSize.width/2 + margin if senderRect.midY < containerSize.height/2 { arrowPoint.y = 0 } else { - arrowPoint.y = menuSize.height+FT.DefaultMenuArrowHeight + arrowPoint.y = menuSize.height+arrowHeight } if arrowPoint.x+menuCenterX > containerSize.width { arrowPoint.x = min( - arrowPoint.x-(containerSize.width-menuSize.width-FT.DefaultMargin), - menuSize.width-FT.DefaultMenuArrowWidth-FT.DefaultMargin + arrowPoint.x-(containerSize.width-menuSize.width-margin), + menuSize.width-arrowWidth-margin ) } else if arrowPoint.x-menuCenterX < 0 { arrowPoint.x = max( - cornerRadius+FT.DefaultMenuArrowWidth, - arrowPoint.x-FT.DefaultMargin + cornerRadius+arrowWidth, + arrowPoint.x-margin ) } else { arrowPoint.x = menuSize.width/2 @@ -205,16 +209,16 @@ extension CustomAnimation { var senderCenterX = senderRect.midX if senderRect.midX+menuCenterX > containerSize.width { senderCenterX = min( - senderCenterX-(containerSize.width-menuSize.width-FT.DefaultMargin), - menuSize.width-FT.DefaultMenuArrowWidth-FT.DefaultMargin + senderCenterX-(containerSize.width-menuSize.width-margin), + menuSize.width-arrowWidth-margin ) - menuOffsetX = containerSize.width-menuSize.width-FT.DefaultMargin + menuOffsetX = containerSize.width-menuSize.width-margin } else if senderCenterX-menuCenterX < 0 { senderCenterX = max( - cornerRadius+FT.DefaultMenuArrowWidth, - senderCenterX-FT.DefaultMargin + cornerRadius+arrowWidth, + senderCenterX-margin ) - menuOffsetX = FT.DefaultMargin + menuOffsetX = margin } else { senderCenterX = menuSize.width/2 menuOffsetX = senderRect.midX - menuSize.width/2 @@ -226,29 +230,29 @@ extension CustomAnimation { x: menuOffsetX, y: senderRect.maxY, width: menuSize.width, - height: menuSize.height+FT.DefaultMenuArrowHeight + height: menuSize.height+arrowHeight ) if (menuFrame.maxY > containerSize.height) { menuFrame = CGRect( x: menuOffsetX, y: senderRect.maxY, width: menuSize.width, - height: containerSize.height-menuFrame.origin.y-FT.DefaultMargin + height: containerSize.height-menuFrame.origin.y-margin ) } } else { menuFrame = CGRect( x: menuOffsetX, - y: senderRect.origin.y-menuSize.height-FT.DefaultMenuArrowHeight, + y: senderRect.origin.y-menuSize.height-arrowHeight, width: menuSize.width, - height: menuSize.height+FT.DefaultMenuArrowHeight + height: menuSize.height+arrowHeight ) if menuFrame.origin.y < 0 { menuFrame = CGRect( x: menuOffsetX, - y: FT.DefaultMargin, + y: margin, width: menuSize.width, - height: senderRect.origin.y-FT.DefaultMargin + height: senderRect.origin.y-margin ) } } @@ -276,22 +280,22 @@ extension CustomAnimation { if arrowDirection == .up { path.move(to: CGPoint( - x: arrowPoint.x-FT.DefaultMenuArrowWidth, - y: FT.DefaultMenuArrowHeight) + x: arrowPoint.x-arrowWidth, + y: arrowHeight) ) path.addLine(to: CGPoint(x: arrowPoint.x, y: 0)) path.addLine(to: CGPoint( - x: arrowPoint.x+FT.DefaultMenuArrowWidth, - y: FT.DefaultMenuArrowHeight) + x: arrowPoint.x+arrowWidth, + y: arrowHeight) ) path.addLine(to: CGPoint( x: viewWidth-radius, - y: FT.DefaultMenuArrowHeight) + y: arrowHeight) ) path.addArc( withCenter: CGPoint( x: viewWidth-radius, - y: FT.DefaultMenuArrowHeight+radius + y: arrowHeight+radius ), radius: radius, startAngle: .pi/2*3, @@ -318,9 +322,9 @@ extension CustomAnimation { endAngle: .pi, clockwise: true ) - path.addLine(to: CGPoint(x: 0, y: FT.DefaultMenuArrowHeight+radius)) + path.addLine(to: CGPoint(x: 0, y: arrowHeight+radius)) path.addArc( - withCenter: CGPoint(x: radius, y: FT.DefaultMenuArrowHeight+radius), + withCenter: CGPoint(x: radius, y: arrowHeight+radius), radius: radius, startAngle: .pi, endAngle: .pi/2*3, @@ -329,22 +333,22 @@ extension CustomAnimation { path.close() } else { path.move(to: CGPoint( - x: arrowPoint.x-FT.DefaultMenuArrowWidth, - y: viewHeight-FT.DefaultMenuArrowHeight) + x: arrowPoint.x-arrowWidth, + y: viewHeight-arrowHeight) ) path.addLine(to: CGPoint(x: arrowPoint.x, y: viewHeight)) path.addLine(to: CGPoint( - x: arrowPoint.x+FT.DefaultMenuArrowWidth, - y: viewHeight-FT.DefaultMenuArrowHeight) + x: arrowPoint.x+arrowWidth, + y: viewHeight-arrowHeight) ) path.addLine(to: CGPoint( x: viewWidth-radius, - y: viewHeight-FT.DefaultMenuArrowHeight) + y: viewHeight-arrowHeight) ) path.addArc( withCenter: CGPoint( x: viewWidth-radius, - y: viewHeight-FT.DefaultMenuArrowHeight-radius), + y: viewHeight-arrowHeight-radius), radius: radius, startAngle: .pi/2, endAngle: 0, @@ -368,12 +372,12 @@ extension CustomAnimation { ) path.addLine(to: CGPoint( x: 0, - y: viewHeight-FT.DefaultMenuArrowHeight-radius) + y: viewHeight-arrowHeight-radius) ) path.addArc( withCenter: CGPoint( x: radius, - y: viewHeight-FT.DefaultMenuArrowHeight-radius), + y: viewHeight-arrowHeight-radius), radius: radius, startAngle: .pi, endAngle: .pi/2, @@ -412,19 +416,3 @@ extension CustomAnimation { return CGPoint(x: newOffsetX, y: newOffsetY) } } - -struct FT { - internal static let DefaultMargin = CGFloat(4) - internal static let DefaultCellMargin = CGFloat(6) - internal static let DefaultMenuIconSize = CGFloat(24) - internal static let DefaultMenuCornerRadius = CGFloat(4) - internal static let DefaultMenuArrowWidth = CGFloat(8) - internal static let DefaultMenuArrowHeight = CGFloat(10) - internal static let DefaultAnimationDuration = TimeInterval(0.2) - internal static let DefaultBorderWidth = CGFloat(0.5) - internal static let DefaultCornerRadius = CGFloat(6) - internal static let DefaultMenuRowHeight = CGFloat(40) - internal static let DefaultMenuWidth = CGFloat(120) - internal static let DefaultTintColor = UIColor(red: 80/255, green: 80/255, blue: 80/255, alpha: 1) - internal static let PopOverMenuTableViewCellIndentifier = "FTPopOverMenuTableViewCellIndentifier" -} From 4f7067c4cfd995df7a7bcaddb562b47438094673 Mon Sep 17 00:00:00 2001 From: LawrenceHan Date: Fri, 29 Mar 2019 11:07:43 +0800 Subject: [PATCH 4/4] added shadow path --- Demo/Demo/CustomAnimation.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Demo/Demo/CustomAnimation.swift b/Demo/Demo/CustomAnimation.swift index 358933f0..5e814f18 100644 --- a/Demo/Demo/CustomAnimation.swift +++ b/Demo/Demo/CustomAnimation.swift @@ -86,7 +86,7 @@ public class CustomAnimation: NSObject, Animator { } menuView.bounds = view.bounds - messageView = menuView + messageView = context.messageView containerView = container self.context = context @@ -129,7 +129,7 @@ public class CustomAnimation: NSObject, Animator { } @objc public func adjustMargins() { - guard let adjustable = messageView as? MarginAdjustable & UIView, + guard let adjustable = menuView as? MarginAdjustable & UIView, let context = context else { return } adjustable.preservesSuperviewLayoutMargins = false if #available(iOS 11, *) { @@ -266,6 +266,18 @@ extension CustomAnimation { backgroundLayer.fillColor = fillColor backgroundLayer.strokeColor = strokeColor backgroundLayer.lineWidth = lineWidth + + // read shadow from message view + if let messageView = messageView as? MessageView { + backgroundLayer.shadowColor = messageView.layer.shadowColor + backgroundLayer.shadowOffset = messageView.layer.shadowOffset + backgroundLayer.shadowOpacity = messageView.layer.shadowOpacity + backgroundLayer.masksToBounds = messageView.layer.masksToBounds + backgroundLayer.shouldRasterize = true + backgroundLayer.rasterizationScale = UIScreen.main.scale + messageView.layer.shadowOpacity = 0.0 + } + view.layer.insertSublayer(backgroundLayer, at: 0) }