3
Podfile
|
|
@ -1,7 +1,7 @@
|
|||
# Uncomment the next line to define a global platform for your project
|
||||
source 'https://gitee.com/mirrors/CocoaPods-Specs.git'
|
||||
platform :ios, '15.0'
|
||||
|
||||
use_frameworks!
|
||||
target 'QuickLocation' do
|
||||
# Comment the next line if you don't want to use dynamic frameworks
|
||||
use_frameworks!
|
||||
|
|
@ -39,6 +39,7 @@ target 'QuickLocation' do
|
|||
pod 'Popover'
|
||||
pod 'SDCycleScrollView'
|
||||
pod 'lottie-ios'
|
||||
pod 'TagListView', '~> 1.0'
|
||||
|
||||
#第三方SDk
|
||||
pod 'GYSDK' #个推一键登录
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ PODS:
|
|||
- SwiftKeychainWrapper (4.0.1)
|
||||
- SwiftyJSON (5.0.2)
|
||||
- SwiftyUserDefaults (5.3.0)
|
||||
- TagListView (1.4.1)
|
||||
- URLNavigator (2.5.1)
|
||||
- ZXSDK (3.3.2)
|
||||
|
||||
|
|
@ -149,6 +150,7 @@ DEPENDENCIES:
|
|||
- SwiftKeychainWrapper
|
||||
- SwiftyJSON
|
||||
- SwiftyUserDefaults
|
||||
- TagListView (~> 1.0)
|
||||
- URLNavigator
|
||||
|
||||
SPEC REPOS:
|
||||
|
|
@ -194,6 +196,7 @@ SPEC REPOS:
|
|||
- SwiftKeychainWrapper
|
||||
- SwiftyJSON
|
||||
- SwiftyUserDefaults
|
||||
- TagListView
|
||||
- URLNavigator
|
||||
- ZXSDK
|
||||
|
||||
|
|
@ -249,9 +252,10 @@ SPEC CHECKSUMS:
|
|||
SwiftKeychainWrapper: 807ba1d63c33a7d0613288512399cd1eda1e470c
|
||||
SwiftyJSON: f5b1bf1cd8dd53cd25887ac0eabcfd92301c6a5a
|
||||
SwiftyUserDefaults: 63f80248cf5bfb3458825d9a78f2eb7e1293a040
|
||||
TagListView: a1c236d17960a0cf64156725a76ce6d73ebce2be
|
||||
URLNavigator: e9c0426ba6e6ac57f34d018bbf3df840797f984d
|
||||
ZXSDK: 786338c0a18e98e03eda00699c3bfd2700b97117
|
||||
|
||||
PODFILE CHECKSUM: 3f46a4156fa0c5d43a1b12c2295ee879276d4f69
|
||||
PODFILE CHECKSUM: 7d3667576e8d6c3f1a98be0e406f215041cf2eb7
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
|
|
|||
|
|
@ -145,13 +145,6 @@
|
|||
305A770F2FCA8C7000227D26 /* DLCustomPopVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A76652FCA8C7000227D26 /* DLCustomPopVC.swift */; };
|
||||
305A77102FCA8C7000227D26 /* DLSheetPopVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A76662FCA8C7000227D26 /* DLSheetPopVC.swift */; };
|
||||
305A77112FCA8C7000227D26 /* DLViewTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76682FCA8C7000227D26 /* DLViewTransition.m */; };
|
||||
305A77122FCA8C7000227D26 /* TTGTagCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A766B2FCA8C7000227D26 /* TTGTagCollectionView.m */; };
|
||||
305A77132FCA8C7000227D26 /* TTGTextTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A766E2FCA8C7000227D26 /* TTGTextTag.m */; };
|
||||
305A77142FCA8C7000227D26 /* TTGTextTagAttributedStringContent.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76702FCA8C7000227D26 /* TTGTextTagAttributedStringContent.m */; };
|
||||
305A77152FCA8C7000227D26 /* TTGTextTagCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76722FCA8C7000227D26 /* TTGTextTagCollectionView.m */; };
|
||||
305A77162FCA8C7000227D26 /* TTGTextTagContent.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76742FCA8C7000227D26 /* TTGTextTagContent.m */; };
|
||||
305A77172FCA8C7000227D26 /* TTGTextTagStringContent.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76762FCA8C7000227D26 /* TTGTextTagStringContent.m */; };
|
||||
305A77182FCA8C7000227D26 /* TTGTextTagStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 305A76782FCA8C7000227D26 /* TTGTextTagStyle.m */; };
|
||||
305A77192FCA8C7000227D26 /* CollectionHFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A767A2FCA8C7000227D26 /* CollectionHFlowLayout.swift */; };
|
||||
305A771A2FCA8C7000227D26 /* JJPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A767B2FCA8C7000227D26 /* JJPageControl.swift */; };
|
||||
305A771B2FCA8C7000227D26 /* ReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A767C2FCA8C7000227D26 /* ReusableView.swift */; };
|
||||
|
|
@ -187,8 +180,22 @@
|
|||
305A77FC2FCA8C7000227D26 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 305A76842FCA8C7000227D26 /* Main.storyboard */; };
|
||||
305A798C2FCAB99300227D26 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A798B2FCAB99300227D26 /* HomeViewModel.swift */; };
|
||||
305A79902FCAC61A00227D26 /* InviteMemberVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305A798F2FCAC61A00227D26 /* InviteMemberVC.swift */; };
|
||||
3062E8B52FCE6BBA00CEF511 /* ScanVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8B42FCE6BBA00CEF511 /* ScanVC.swift */; };
|
||||
3062E8B72FCE6BFE00CEF511 /* ScanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8B62FCE6BFE00CEF511 /* ScanView.swift */; };
|
||||
3062E8BA2FCEAC6500CEF511 /* CreateGroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8B92FCEAC6500CEF511 /* CreateGroupView.swift */; };
|
||||
3062E8BC2FCEAC7100CEF511 /* CreateGroupVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8BB2FCEAC7100CEF511 /* CreateGroupVC.swift */; };
|
||||
3062E8BE2FCEBD0E00CEF511 /* GroupIconListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8BD2FCEBD0E00CEF511 /* GroupIconListVC.swift */; };
|
||||
3062E8C02FCED7BB00CEF511 /* GroupIconListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8BF2FCED7BB00CEF511 /* GroupIconListView.swift */; };
|
||||
30A7A9112FCAEE3D00105780 /* GroupListPopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A7A9102FCAEE3D00105780 /* GroupListPopView.swift */; };
|
||||
C03BCA796B982B5ACA9611EE /* Pods_QuickLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E143BF7B4D1F77827EB9982E /* Pods_QuickLocation.framework */; };
|
||||
30BAB84D2FCD2FDE00C33B5C /* InviteJoinView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB84C2FCD2FDE00C33B5C /* InviteJoinView.swift */; };
|
||||
30BAB84F2FCD2FED00C33B5C /* InviteJoinVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB84E2FCD2FED00C33B5C /* InviteJoinVC.swift */; };
|
||||
30BAB8512FCD331C00C33B5C /* GroupAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8502FCD331C00C33B5C /* GroupAPI.swift */; };
|
||||
30BAB8532FCD337C00C33B5C /* GroupService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8522FCD337C00C33B5C /* GroupService.swift */; };
|
||||
30BAB8632FCD716C00C33B5C /* JoinGroupVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8622FCD716C00C33B5C /* JoinGroupVC.swift */; };
|
||||
30BAB8652FCD718A00C33B5C /* JoinGroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8642FCD718A00C33B5C /* JoinGroupView.swift */; };
|
||||
30BAB8682FCD750E00C33B5C /* Mask_group@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */; };
|
||||
30BAB8692FCD750E00C33B5C /* Mask_group@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */; };
|
||||
C49B37352A45A02C28FF41BA /* Pods_QuickLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1C77B42994F352054070537 /* Pods_QuickLocation.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
|
@ -361,21 +368,6 @@
|
|||
305A76662FCA8C7000227D26 /* DLSheetPopVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLSheetPopVC.swift; sourceTree = "<group>"; };
|
||||
305A76672FCA8C7000227D26 /* DLViewTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DLViewTransition.h; sourceTree = "<group>"; };
|
||||
305A76682FCA8C7000227D26 /* DLViewTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DLViewTransition.m; sourceTree = "<group>"; };
|
||||
305A766A2FCA8C7000227D26 /* TTGTagCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTagCollectionView.h; sourceTree = "<group>"; };
|
||||
305A766B2FCA8C7000227D26 /* TTGTagCollectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTagCollectionView.m; sourceTree = "<group>"; };
|
||||
305A766C2FCA8C7000227D26 /* TTGTagCollectionView-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TTGTagCollectionView-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
305A766D2FCA8C7000227D26 /* TTGTextTag.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTag.h; sourceTree = "<group>"; };
|
||||
305A766E2FCA8C7000227D26 /* TTGTextTag.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTag.m; sourceTree = "<group>"; };
|
||||
305A766F2FCA8C7000227D26 /* TTGTextTagAttributedStringContent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTagAttributedStringContent.h; sourceTree = "<group>"; };
|
||||
305A76702FCA8C7000227D26 /* TTGTextTagAttributedStringContent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTagAttributedStringContent.m; sourceTree = "<group>"; };
|
||||
305A76712FCA8C7000227D26 /* TTGTextTagCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTagCollectionView.h; sourceTree = "<group>"; };
|
||||
305A76722FCA8C7000227D26 /* TTGTextTagCollectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTagCollectionView.m; sourceTree = "<group>"; };
|
||||
305A76732FCA8C7000227D26 /* TTGTextTagContent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTagContent.h; sourceTree = "<group>"; };
|
||||
305A76742FCA8C7000227D26 /* TTGTextTagContent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTagContent.m; sourceTree = "<group>"; };
|
||||
305A76752FCA8C7000227D26 /* TTGTextTagStringContent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTagStringContent.h; sourceTree = "<group>"; };
|
||||
305A76762FCA8C7000227D26 /* TTGTextTagStringContent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTagStringContent.m; sourceTree = "<group>"; };
|
||||
305A76772FCA8C7000227D26 /* TTGTextTagStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTGTextTagStyle.h; sourceTree = "<group>"; };
|
||||
305A76782FCA8C7000227D26 /* TTGTextTagStyle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TTGTextTagStyle.m; sourceTree = "<group>"; };
|
||||
305A767A2FCA8C7000227D26 /* CollectionHFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionHFlowLayout.swift; sourceTree = "<group>"; };
|
||||
305A767B2FCA8C7000227D26 /* JJPageControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JJPageControl.swift; sourceTree = "<group>"; };
|
||||
305A767C2FCA8C7000227D26 /* ReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReusableView.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -388,11 +380,25 @@
|
|||
305A76862FCA8C7000227D26 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
305A798B2FCAB99300227D26 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
|
||||
305A798F2FCAC61A00227D26 /* InviteMemberVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteMemberVC.swift; sourceTree = "<group>"; };
|
||||
3062E8B42FCE6BBA00CEF511 /* ScanVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanVC.swift; sourceTree = "<group>"; };
|
||||
3062E8B62FCE6BFE00CEF511 /* ScanView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanView.swift; sourceTree = "<group>"; };
|
||||
3062E8B92FCEAC6500CEF511 /* CreateGroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateGroupView.swift; sourceTree = "<group>"; };
|
||||
3062E8BB2FCEAC7100CEF511 /* CreateGroupVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateGroupVC.swift; sourceTree = "<group>"; };
|
||||
3062E8BD2FCEBD0E00CEF511 /* GroupIconListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupIconListVC.swift; sourceTree = "<group>"; };
|
||||
3062E8BF2FCED7BB00CEF511 /* GroupIconListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupIconListView.swift; sourceTree = "<group>"; };
|
||||
30A7A9102FCAEE3D00105780 /* GroupListPopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupListPopView.swift; sourceTree = "<group>"; };
|
||||
30BAB84C2FCD2FDE00C33B5C /* InviteJoinView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteJoinView.swift; sourceTree = "<group>"; };
|
||||
30BAB84E2FCD2FED00C33B5C /* InviteJoinVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteJoinVC.swift; sourceTree = "<group>"; };
|
||||
30BAB8502FCD331C00C33B5C /* GroupAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupAPI.swift; sourceTree = "<group>"; };
|
||||
30BAB8522FCD337C00C33B5C /* GroupService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupService.swift; sourceTree = "<group>"; };
|
||||
30BAB8622FCD716C00C33B5C /* JoinGroupVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinGroupVC.swift; sourceTree = "<group>"; };
|
||||
30BAB8642FCD718A00C33B5C /* JoinGroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinGroupView.swift; sourceTree = "<group>"; };
|
||||
30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Mask_group@2x.png"; sourceTree = "<group>"; };
|
||||
30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Mask_group@3x.png"; sourceTree = "<group>"; };
|
||||
3E4359082FC48D26003470A5 /* QuickLocation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuickLocation.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C2BE08A1B1E96CAB0EE3C077 /* Pods-QuickLocation.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.release.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.release.xcconfig"; sourceTree = "<group>"; };
|
||||
DD686BFD90D3CEEEFABFE88F /* Pods-QuickLocation.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.debug.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
E143BF7B4D1F77827EB9982E /* Pods_QuickLocation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_QuickLocation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
93647DF3683AA5E71EC2FB1A /* Pods-QuickLocation.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.release.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D1C77B42994F352054070537 /* Pods_QuickLocation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_QuickLocation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E7FB0BC3883A7FF0C8CC59A7 /* Pods-QuickLocation.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.debug.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -400,17 +406,17 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C03BCA796B982B5ACA9611EE /* Pods_QuickLocation.framework in Frameworks */,
|
||||
C49B37352A45A02C28FF41BA /* Pods_QuickLocation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
1CFEE11C08437C3618FD06EF /* Frameworks */ = {
|
||||
03E642910A4324FD76561DF2 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E143BF7B4D1F77827EB9982E /* Pods_QuickLocation.framework */,
|
||||
D1C77B42994F352054070537 /* Pods_QuickLocation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -435,6 +441,7 @@
|
|||
305A74CD2FCA8C7000227D26 /* SignPlugin.swift */,
|
||||
305A74CE2FCA8C7000227D26 /* SystemAPI.swift */,
|
||||
305A74CF2FCA8C7000227D26 /* UserAPI.swift */,
|
||||
30BAB8502FCD331C00C33B5C /* GroupAPI.swift */,
|
||||
);
|
||||
path = API;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -771,9 +778,14 @@
|
|||
305A76262FCA8C7000227D26 /* Group */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
305A76232FCA8C7000227D26 /* GroupView.swift */,
|
||||
305A76242FCA8C7000227D26 /* GroupViewController.swift */,
|
||||
305A76252FCA8C7000227D26 /* GroupViewModel.swift */,
|
||||
305A76232FCA8C7000227D26 /* GroupView.swift */,
|
||||
3062E8B82FCEAC5600CEF511 /* CreateGroup */,
|
||||
30BAB8612FCD714700C33B5C /* Join */,
|
||||
30BAB84B2FCD2FA400C33B5C /* InviteJoin */,
|
||||
30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */,
|
||||
30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */,
|
||||
);
|
||||
path = Group;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -839,6 +851,7 @@
|
|||
305A76352FCA8C7000227D26 /* Map */,
|
||||
305A76392FCA8C7000227D26 /* Mine */,
|
||||
305A798E2FCAC5F600227D26 /* InviteMember */,
|
||||
3062E8B32FCE6BA400CEF511 /* Scan */,
|
||||
);
|
||||
path = Section;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -848,6 +861,7 @@
|
|||
children = (
|
||||
305A763B2FCA8C7000227D26 /* SystemService.swift */,
|
||||
305A763C2FCA8C7000227D26 /* UserService.swift */,
|
||||
30BAB8522FCD337C00C33B5C /* GroupService.swift */,
|
||||
);
|
||||
path = Service;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -952,28 +966,6 @@
|
|||
path = Pop;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
305A76792FCA8C7000227D26 /* TTGTagCollectionView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
305A766A2FCA8C7000227D26 /* TTGTagCollectionView.h */,
|
||||
305A766B2FCA8C7000227D26 /* TTGTagCollectionView.m */,
|
||||
305A766C2FCA8C7000227D26 /* TTGTagCollectionView-Bridging-Header.h */,
|
||||
305A766D2FCA8C7000227D26 /* TTGTextTag.h */,
|
||||
305A766E2FCA8C7000227D26 /* TTGTextTag.m */,
|
||||
305A766F2FCA8C7000227D26 /* TTGTextTagAttributedStringContent.h */,
|
||||
305A76702FCA8C7000227D26 /* TTGTextTagAttributedStringContent.m */,
|
||||
305A76712FCA8C7000227D26 /* TTGTextTagCollectionView.h */,
|
||||
305A76722FCA8C7000227D26 /* TTGTextTagCollectionView.m */,
|
||||
305A76732FCA8C7000227D26 /* TTGTextTagContent.h */,
|
||||
305A76742FCA8C7000227D26 /* TTGTextTagContent.m */,
|
||||
305A76752FCA8C7000227D26 /* TTGTextTagStringContent.h */,
|
||||
305A76762FCA8C7000227D26 /* TTGTextTagStringContent.m */,
|
||||
305A76772FCA8C7000227D26 /* TTGTextTagStyle.h */,
|
||||
305A76782FCA8C7000227D26 /* TTGTextTagStyle.m */,
|
||||
);
|
||||
path = TTGTagCollectionView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
305A767D2FCA8C7000227D26 /* UIKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -983,7 +975,6 @@
|
|||
305A765B2FCA8C7000227D26 /* MXParallaxHeader */,
|
||||
305A76632FCA8C7000227D26 /* PageView */,
|
||||
305A76692FCA8C7000227D26 /* Pop */,
|
||||
305A76792FCA8C7000227D26 /* TTGTagCollectionView */,
|
||||
305A767A2FCA8C7000227D26 /* CollectionHFlowLayout.swift */,
|
||||
305A767B2FCA8C7000227D26 /* JJPageControl.swift */,
|
||||
305A767C2FCA8C7000227D26 /* ReusableView.swift */,
|
||||
|
|
@ -1027,13 +1018,51 @@
|
|||
path = InviteMember;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3062E8B32FCE6BA400CEF511 /* Scan */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3062E8B42FCE6BBA00CEF511 /* ScanVC.swift */,
|
||||
3062E8B62FCE6BFE00CEF511 /* ScanView.swift */,
|
||||
);
|
||||
path = Scan;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3062E8B82FCEAC5600CEF511 /* CreateGroup */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3062E8BB2FCEAC7100CEF511 /* CreateGroupVC.swift */,
|
||||
3062E8B92FCEAC6500CEF511 /* CreateGroupView.swift */,
|
||||
3062E8BD2FCEBD0E00CEF511 /* GroupIconListVC.swift */,
|
||||
3062E8BF2FCED7BB00CEF511 /* GroupIconListView.swift */,
|
||||
);
|
||||
path = CreateGroup;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
30BAB84B2FCD2FA400C33B5C /* InviteJoin */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
30BAB84E2FCD2FED00C33B5C /* InviteJoinVC.swift */,
|
||||
30BAB84C2FCD2FDE00C33B5C /* InviteJoinView.swift */,
|
||||
);
|
||||
path = InviteJoin;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
30BAB8612FCD714700C33B5C /* Join */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
30BAB8622FCD716C00C33B5C /* JoinGroupVC.swift */,
|
||||
30BAB8642FCD718A00C33B5C /* JoinGroupView.swift */,
|
||||
);
|
||||
path = Join;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3E4358FF2FC48D26003470A5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
305A76872FCA8C7000227D26 /* QuickLocation */,
|
||||
3E4359092FC48D26003470A5 /* Products */,
|
||||
B07D45692FCECE07570D9B73 /* Pods */,
|
||||
1CFEE11C08437C3618FD06EF /* Frameworks */,
|
||||
03E642910A4324FD76561DF2 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
|
@ -1048,8 +1077,8 @@
|
|||
B07D45692FCECE07570D9B73 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DD686BFD90D3CEEEFABFE88F /* Pods-QuickLocation.debug.xcconfig */,
|
||||
C2BE08A1B1E96CAB0EE3C077 /* Pods-QuickLocation.release.xcconfig */,
|
||||
E7FB0BC3883A7FF0C8CC59A7 /* Pods-QuickLocation.debug.xcconfig */,
|
||||
93647DF3683AA5E71EC2FB1A /* Pods-QuickLocation.release.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1061,12 +1090,12 @@
|
|||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 3E43591B2FC48D2B003470A5 /* Build configuration list for PBXNativeTarget "QuickLocation" */;
|
||||
buildPhases = (
|
||||
6351E02EF2A14F505ED2090F /* [CP] Check Pods Manifest.lock */,
|
||||
02AAC6F447C63D6CFFF520A5 /* [CP] Check Pods Manifest.lock */,
|
||||
3E4359042FC48D26003470A5 /* Sources */,
|
||||
3E4359052FC48D26003470A5 /* Frameworks */,
|
||||
3E4359062FC48D26003470A5 /* Resources */,
|
||||
6DA31A37CE44CF6C53CFCC77 /* [CP] Embed Pods Frameworks */,
|
||||
F1F67E9D9FD03DDF6DB237AC /* [CP] Copy Pods Resources */,
|
||||
995DC2C35EFC977973355A8D /* [CP] Embed Pods Frameworks */,
|
||||
DA8D65EB369916390C2EFAEE /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
@ -1140,6 +1169,8 @@
|
|||
305A77F52FCA8C7000227D26 /* phone_search_no_vip.json in Resources */,
|
||||
305A77F62FCA8C7000227D26 /* phone_search_success.json in Resources */,
|
||||
305A77F72FCA8C7000227D26 /* sign_in_continuous_data.json in Resources */,
|
||||
30BAB8682FCD750E00C33B5C /* Mask_group@3x.png in Resources */,
|
||||
30BAB8692FCD750E00C33B5C /* Mask_group@2x.png in Resources */,
|
||||
305A77F82FCA8C7000227D26 /* sign_in_un_continuous_data.json in Resources */,
|
||||
305A77F92FCA8C7000227D26 /* Assets.xcassets in Resources */,
|
||||
305A77FB2FCA8C7000227D26 /* LaunchScreen.storyboard in Resources */,
|
||||
|
|
@ -1150,7 +1181,7 @@
|
|||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
6351E02EF2A14F505ED2090F /* [CP] Check Pods Manifest.lock */ = {
|
||||
02AAC6F447C63D6CFFF520A5 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
|
|
@ -1172,7 +1203,7 @@
|
|||
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;
|
||||
};
|
||||
6DA31A37CE44CF6C53CFCC77 /* [CP] Embed Pods Frameworks */ = {
|
||||
995DC2C35EFC977973355A8D /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
|
|
@ -1193,7 +1224,7 @@
|
|||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
F1F67E9D9FD03DDF6DB237AC /* [CP] Copy Pods Resources */ = {
|
||||
DA8D65EB369916390C2EFAEE /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
|
|
@ -1240,6 +1271,7 @@
|
|||
305A76982FCA8C7000227D26 /* ImagePicker.swift in Sources */,
|
||||
305A76992FCA8C7000227D26 /* ImagePickerPopup.swift in Sources */,
|
||||
305A769A2FCA8C7000227D26 /* PopupAnimator.swift in Sources */,
|
||||
3062E8BE2FCEBD0E00CEF511 /* GroupIconListVC.swift in Sources */,
|
||||
305A769B2FCA8C7000227D26 /* PopupAnimators.swift in Sources */,
|
||||
305A769C2FCA8C7000227D26 /* PopupViewController.swift in Sources */,
|
||||
305A769D2FCA8C7000227D26 /* PopupViewController+Extension.swift in Sources */,
|
||||
|
|
@ -1249,6 +1281,7 @@
|
|||
305A76A12FCA8C7000227D26 /* UIButton+RTL.m in Sources */,
|
||||
305A76A22FCA8C7000227D26 /* Array+Extension.swift in Sources */,
|
||||
305A76A32FCA8C7000227D26 /* ControlEvents+Block.swift in Sources */,
|
||||
3062E8B72FCE6BFE00CEF511 /* ScanView.swift in Sources */,
|
||||
305A76A42FCA8C7000227D26 /* Date+Extension.swift in Sources */,
|
||||
305A76A52FCA8C7000227D26 /* Dictionay+Extension.swift in Sources */,
|
||||
305A76A62FCA8C7000227D26 /* Int+Extension.swift in Sources */,
|
||||
|
|
@ -1280,6 +1313,7 @@
|
|||
305A76BF2FCA8C7000227D26 /* ListService.swift in Sources */,
|
||||
305A76C02FCA8C7000227D26 /* BaseNavigationController.swift in Sources */,
|
||||
305A76C12FCA8C7000227D26 /* BaseViewController.swift in Sources */,
|
||||
3062E8C02FCED7BB00CEF511 /* GroupIconListView.swift in Sources */,
|
||||
305A76C22FCA8C7000227D26 /* BaseViewModel.swift in Sources */,
|
||||
305A76C32FCA8C7000227D26 /* MainTabBarController.swift in Sources */,
|
||||
305A76C42FCA8C7000227D26 /* QuickLocationTabBar.swift in Sources */,
|
||||
|
|
@ -1313,19 +1347,26 @@
|
|||
305A76DE2FCA8C7000227D26 /* ObservableType+ObjectMapper.swift in Sources */,
|
||||
305A76DF2FCA8C7000227D26 /* Single+ObjectMapper.swift in Sources */,
|
||||
305A76E02FCA8C7000227D26 /* GroupView.swift in Sources */,
|
||||
30BAB8512FCD331C00C33B5C /* GroupAPI.swift in Sources */,
|
||||
305A76E12FCA8C7000227D26 /* GroupViewController.swift in Sources */,
|
||||
30BAB84D2FCD2FDE00C33B5C /* InviteJoinView.swift in Sources */,
|
||||
305A76E22FCA8C7000227D26 /* GroupViewModel.swift in Sources */,
|
||||
305A76E32FCA8C7000227D26 /* GroupMemberView.swift in Sources */,
|
||||
30BAB84F2FCD2FED00C33B5C /* InviteJoinVC.swift in Sources */,
|
||||
305A76E42FCA8C7000227D26 /* HomeView.swift in Sources */,
|
||||
305A76E52FCA8C7000227D26 /* HomeViewController.swift in Sources */,
|
||||
305A76E62FCA8C7000227D26 /* LaunchViewController.swift in Sources */,
|
||||
3062E8B52FCE6BBA00CEF511 /* ScanVC.swift in Sources */,
|
||||
305A76E72FCA8C7000227D26 /* LoginView.swift in Sources */,
|
||||
305A76E82FCA8C7000227D26 /* LoginViewController.swift in Sources */,
|
||||
305A76E92FCA8C7000227D26 /* LoginViewModel.swift in Sources */,
|
||||
3062E8BC2FCEAC7100CEF511 /* CreateGroupVC.swift in Sources */,
|
||||
30BAB8632FCD716C00C33B5C /* JoinGroupVC.swift in Sources */,
|
||||
305A76EA2FCA8C7000227D26 /* OneTapLoginView.swift in Sources */,
|
||||
305A76EB2FCA8C7000227D26 /* CircleMember.swift in Sources */,
|
||||
305A76EC2FCA8C7000227D26 /* MemberAnnotation.swift in Sources */,
|
||||
305A76ED2FCA8C7000227D26 /* MemberAnnotationView.swift in Sources */,
|
||||
30BAB8532FCD337C00C33B5C /* GroupService.swift in Sources */,
|
||||
305A76EE2FCA8C7000227D26 /* MineView.swift in Sources */,
|
||||
305A76EF2FCA8C7000227D26 /* MineViewController.swift in Sources */,
|
||||
305A76F02FCA8C7000227D26 /* MineViewModel.swift in Sources */,
|
||||
|
|
@ -1350,6 +1391,7 @@
|
|||
305A77032FCA8C7000227D26 /* ProgressHUD.swift in Sources */,
|
||||
305A77042FCA8C7000227D26 /* MXParallaxHeader.m in Sources */,
|
||||
305A77052FCA8C7000227D26 /* MXScrollView.m in Sources */,
|
||||
30BAB8652FCD718A00C33B5C /* JoinGroupView.swift in Sources */,
|
||||
305A77062FCA8C7000227D26 /* MXScrollViewController.m in Sources */,
|
||||
305A77072FCA8C7000227D26 /* Helper.swift in Sources */,
|
||||
305A77082FCA8C7000227D26 /* PageCollectionViewFlowLayout.swift in Sources */,
|
||||
|
|
@ -1362,13 +1404,7 @@
|
|||
305A770F2FCA8C7000227D26 /* DLCustomPopVC.swift in Sources */,
|
||||
305A77102FCA8C7000227D26 /* DLSheetPopVC.swift in Sources */,
|
||||
305A77112FCA8C7000227D26 /* DLViewTransition.m in Sources */,
|
||||
305A77122FCA8C7000227D26 /* TTGTagCollectionView.m in Sources */,
|
||||
305A77132FCA8C7000227D26 /* TTGTextTag.m in Sources */,
|
||||
305A77142FCA8C7000227D26 /* TTGTextTagAttributedStringContent.m in Sources */,
|
||||
305A77152FCA8C7000227D26 /* TTGTextTagCollectionView.m in Sources */,
|
||||
305A77162FCA8C7000227D26 /* TTGTextTagContent.m in Sources */,
|
||||
305A77172FCA8C7000227D26 /* TTGTextTagStringContent.m in Sources */,
|
||||
305A77182FCA8C7000227D26 /* TTGTextTagStyle.m in Sources */,
|
||||
3062E8BA2FCEAC6500CEF511 /* CreateGroupView.swift in Sources */,
|
||||
305A77192FCA8C7000227D26 /* CollectionHFlowLayout.swift in Sources */,
|
||||
305A771A2FCA8C7000227D26 /* JJPageControl.swift in Sources */,
|
||||
305A771B2FCA8C7000227D26 /* ReusableView.swift in Sources */,
|
||||
|
|
@ -1401,7 +1437,7 @@
|
|||
/* Begin XCBuildConfiguration section */
|
||||
3E43591C2FC48D2B003470A5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = DD686BFD90D3CEEEFABFE88F /* Pods-QuickLocation.debug.xcconfig */;
|
||||
baseConfigurationReference = E7FB0BC3883A7FF0C8CC59A7 /* Pods-QuickLocation.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
|
|
@ -1443,7 +1479,7 @@
|
|||
};
|
||||
3E43591D2FC48D2B003470A5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = C2BE08A1B1E96CAB0EE3C077 /* Pods-QuickLocation.release.xcconfig */;
|
||||
baseConfigurationReference = 93647DF3683AA5E71EC2FB1A /* Pods-QuickLocation.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// GroupAPI.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import Moya
|
||||
import SwiftyUserDefaults
|
||||
internal import Alamofire
|
||||
|
||||
/// 圈子相关API
|
||||
enum GroupAPI {
|
||||
/// 圈子信息
|
||||
case groupInfo
|
||||
/// 圈子操作(创建、解散、设为默认等)
|
||||
/// - Parameters:
|
||||
/// - opType: create、dismiss、setdefault
|
||||
/// - requestData:[String: Any] 根据操作传入对应的值
|
||||
case operate(opType: String, requestData: [String: Any])
|
||||
}
|
||||
|
||||
extension GroupAPI: MultiTargetProtocol {
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .groupInfo:
|
||||
return "mapi/user/fullinfo"
|
||||
case .operate:
|
||||
return "mapi/group/operate"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .groupInfo:
|
||||
return .get
|
||||
default:
|
||||
return .post
|
||||
}
|
||||
}
|
||||
|
||||
var task: Moya.Task {
|
||||
switch self {
|
||||
case .groupInfo:
|
||||
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
|
||||
|
||||
case let .operate(opType, requestData):
|
||||
var params = Parameters()
|
||||
params["op_type"] = opType
|
||||
params.merge(requestData) { _, new in new }
|
||||
return .requestParameters(parameters: params, encoding: JSONEncoding())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,8 +21,6 @@ enum UserAPI {
|
|||
|
||||
/// 用户信息
|
||||
case userInfo
|
||||
/// 圈子信息
|
||||
case groupInfo
|
||||
|
||||
/// 退出登录
|
||||
case logout
|
||||
|
|
@ -36,8 +34,6 @@ extension UserAPI: MultiTargetProtocol {
|
|||
return "api/user/login"
|
||||
case .userInfo:
|
||||
return "api/user"
|
||||
case .groupInfo:
|
||||
return "mapi/user/fullinfo"
|
||||
case .logout:
|
||||
return "api/user/logout"
|
||||
}
|
||||
|
|
@ -45,7 +41,7 @@ extension UserAPI: MultiTargetProtocol {
|
|||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .userInfo, .groupInfo:
|
||||
case .userInfo:
|
||||
return .get
|
||||
default:
|
||||
return .post
|
||||
|
|
@ -64,9 +60,6 @@ extension UserAPI: MultiTargetProtocol {
|
|||
case .userInfo:
|
||||
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
|
||||
|
||||
case .groupInfo:
|
||||
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
|
||||
|
||||
case .logout:
|
||||
return .requestParameters(parameters: Parameters(), encoding: JSONEncoding())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Rectangle 320.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Rectangle 320@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/Common/gradient_bg.imageset/Rectangle 320.png
vendored
Normal file
|
After Width: | Height: | Size: 277 B |
BIN
QuickLocation/Assets.xcassets/Common/gradient_bg.imageset/Rectangle 320@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 594 B |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_272@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_272@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 678 B |
|
After Width: | Height: | Size: 779 B |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_297@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_297@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1725@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1725@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Vector@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Vector@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "battery@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "battery@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 325 B |
|
After Width: | Height: | Size: 379 B |
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"provides-namespace" : true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1102@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1102@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1055@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1055@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
|
@ -484,3 +484,31 @@ extension String {
|
|||
return (preStr ?? "") + "****" + (suffixStr ?? "")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 生成二维码
|
||||
extension String {
|
||||
func createQRCode(size: CGSize = CGSize(width: 200, height: 200)) -> UIImage? {
|
||||
// 1. 字符串转 Data
|
||||
guard let data = self.data(using: .utf8) else { return nil }
|
||||
|
||||
// 2. 创建二维码滤镜
|
||||
guard let qrFilter = CIFilter(name: "CIQRCodeGenerator") else { return nil }
|
||||
qrFilter.setDefaults()
|
||||
qrFilter.setValue(data, forKey: "inputMessage")
|
||||
// 容错率:L(7%)/M(15%)/Q(25%)/H(30%),越高容错越强
|
||||
qrFilter.setValue("H", forKey: "inputCorrectionLevel")
|
||||
|
||||
// 3. 获取 CIImage 并放大(原生默认很小,必须放大否则模糊)
|
||||
guard let ciImage = qrFilter.outputImage else { return nil }
|
||||
let scaleX = size.width / ciImage.extent.width
|
||||
let scaleY = size.height / ciImage.extent.height
|
||||
let transform = CGAffineTransform(scaleX: scaleX, y: scaleY)
|
||||
let scaledCI = ciImage.transformed(by: transform)
|
||||
|
||||
// 4. 转 UIImage
|
||||
if let cgImage = CIContext(options: [.useSoftwareRenderer: false]).createCGImage(scaledCI, from: scaledCI.extent) {
|
||||
return UIImage(cgImage: cgImage)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,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>NSCameraUsageDescription</key>
|
||||
<string>您的相机将被用于扫描二维码、拍摄照片和视频。</string>
|
||||
<key>UIAppFonts</key>
|
||||
<array>
|
||||
<string>douyu.otf</string>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class BaseViewController: UIViewController {
|
|||
// Do any additional setup after loading the view.
|
||||
fd_prefersNavigationBarHidden = isNavigationBarHidden
|
||||
|
||||
view.backgroundColor = ThemeManager.shared.color.backgroundColor
|
||||
view.backgroundColor = .white//ThemeManager.shared.color.backgroundColor
|
||||
// setupNavigationBar()
|
||||
setupLeftItem()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@ enum Route: String {
|
|||
case web = "web"
|
||||
/// 登录
|
||||
case login = "login"
|
||||
/// 邀请加入
|
||||
case inviteJoin = "inviteJoin"
|
||||
/// 加入圈子
|
||||
case joinGroup = "joinGroup"
|
||||
/// 创建圈子
|
||||
case createGroup = "createGroup"
|
||||
/// 扫一扫
|
||||
case scan = "scan"
|
||||
/// 圈子图标
|
||||
case groupIconList = "groupIconList"
|
||||
}
|
||||
|
||||
extension Route: RouterTarget {
|
||||
|
|
@ -94,6 +104,34 @@ extension AppRouter: AppRouterProtocol {
|
|||
AppRouter.register(Route.login) { url, parameters in
|
||||
LoginViewController()
|
||||
}
|
||||
|
||||
// MARK: - 邀请加入
|
||||
AppRouter.register(Route.inviteJoin) { url, parameters in
|
||||
let vc = InviteJoinVC(groupInfo: parameters["groupInfo"].safeDictionary as! [String : Any])
|
||||
// vc.isNeedLogin = true
|
||||
return vc
|
||||
}
|
||||
|
||||
// MARK: - 加入圈子
|
||||
AppRouter.register(Route.joinGroup) { url, parameters in
|
||||
JoinGroupVC()
|
||||
}
|
||||
|
||||
// MARK: - 创建圈子
|
||||
AppRouter.register(Route.createGroup) { url, parameters in
|
||||
CreateGroupVC()
|
||||
}
|
||||
|
||||
// MARK: - 扫一扫
|
||||
AppRouter.register(Route.scan) { url, parameters in
|
||||
ScanVC()
|
||||
}
|
||||
|
||||
// MARK: - 扫一扫
|
||||
AppRouter.register(Route.groupIconList) { url, parameters in
|
||||
let vc = GroupIconListVC(iconIndex: parameters["iconIndex"].safeString)
|
||||
return vc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,27 +28,16 @@ extension DefaultsKeys {
|
|||
}
|
||||
}
|
||||
|
||||
/// OpenIM SDK
|
||||
var openIM_API = ""
|
||||
var openIM_WS = ""
|
||||
|
||||
/// 用户协议
|
||||
var userAgreementUrl: String { "https://sd.zuom8.cn/Agreement.html" }
|
||||
/// 隐私政策
|
||||
var privacyPolicyUrl: String { "https://sd.zuom8.cn/Privacy.html" }
|
||||
/// 注销须知
|
||||
var cancellationNoticeUrl: String { "https://h5.yiwen618.com.cn/yiwen_h5_logoff.html" }
|
||||
/// 在线客服
|
||||
var onlineCustomerServiceUrl: String { "https://h5.zywmwl.com/kefu.html" }
|
||||
/// 建议有奖规则
|
||||
var feedbackRuleUrl: String { "https://h5.zywmwl.com/suggestion_rule.html" }
|
||||
/// 使用说明
|
||||
var useGuideUrl: String { "https://activity.zywmwl.com/web_acitvtiy/#/pages/index/useGoldDetail" }
|
||||
|
||||
// /// 物流跟踪
|
||||
// var orderTrackUrl: String { "\(apiServerURL)/webapp/h5/dist/index.html#/order-track" }
|
||||
// /// 延误赔付详情
|
||||
// var delayDetailUrl: String { "\(apiServerURL)/webapp/delayedpayment/detail.html" }
|
||||
// /// FAQ
|
||||
// var faqUrl: String { "\(apiServerURL)/webapp/faq/detail.html?service_im_id=\(IMService.shared.customServiceId)" }
|
||||
// /// CRM
|
||||
// var crmUrl: String { apiServerURL + "/webapp/h5/dist/index.html#/crm/bd" }
|
||||
|
||||
private override init() {
|
||||
super.init()
|
||||
|
|
@ -58,10 +47,16 @@ extension DefaultsKeys {
|
|||
func setupNetworkMode() {
|
||||
#if DEBUG
|
||||
setupApiEnv(1)
|
||||
openIM_API = "https://imapi.zuom8.cn"
|
||||
openIM_WS = "ws://imws.zuom8.cn"
|
||||
#elseif AdHoc
|
||||
setupApiEnv(-1)
|
||||
openIM_API = "http://38.207.176.65:10002"
|
||||
openIM_WS = "ws://38.207.176.65:10010"
|
||||
#else
|
||||
setupApiEnv(1)
|
||||
openIM_API = "http://38.207.176.65:10002"
|
||||
openIM_WS = "ws://38.207.176.65:10010"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ struct GroupInfoModel: Mappable, Equatable {
|
|||
/// 圈子icon
|
||||
var icon_index: Int = 1
|
||||
var groupIcon: UIImage {
|
||||
UIImage(named: "GroupIcon\(icon_index)") ?? UIImage()
|
||||
UIImage(named: "GroupIcon/\(icon_index)") ?? UIImage()
|
||||
}
|
||||
///
|
||||
var description: String = ""
|
||||
|
|
|
|||
|
|
@ -20,13 +20,5 @@
|
|||
// Pop
|
||||
#import "DLViewTransition.h"
|
||||
|
||||
// TTGTagCollectionView
|
||||
#import "TTGTagCollectionView.h"
|
||||
#import "TTGTextTagCollectionView.h"
|
||||
#import "TTGTextTag.h"
|
||||
#import "TTGTextTagContent.h"
|
||||
#import "TTGTextTagStringContent.h"
|
||||
#import "TTGTextTagAttributedStringContent.h"
|
||||
#import "TTGTextTagStyle.h"
|
||||
|
||||
#endif /* QuickLocation_Bridging_Header_h */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// CreateGroupVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class CreateGroupVC: BaseViewController {
|
||||
|
||||
fileprivate var rootView: CreateGroupView!
|
||||
|
||||
override func loadView() {
|
||||
rootView = CreateGroupView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
rootView.groupIconInputView.rx.tapGesture.subscribe { _ in
|
||||
let vc = GroupIconListVC(iconIndex: "1")
|
||||
vc.onSelectIcon = { index in
|
||||
|
||||
}
|
||||
self.navigationController?.pushViewController(vc, animated: true)
|
||||
}.disposed(by: disposeBag)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,493 @@
|
|||
//
|
||||
// CreateGroupView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class CreateGroupView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
private let limitCount = 50
|
||||
private let tagList = ["私密", "游戏", "运动", "美食",
|
||||
"自驾", "聚会", "旅行", "学习"]
|
||||
|
||||
private func setupRx() {
|
||||
groupNameTF.rx.text.orEmpty
|
||||
.subscribe(onNext: { [weak self] text in
|
||||
guard let self = self else { return }
|
||||
if text.count > 10 {
|
||||
self.groupNameTF.text = String(text.prefix(10))
|
||||
}
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
Observable.merge(
|
||||
groupContentTV.rx.didChange.asObservable(),
|
||||
groupContentTV.rx.text.map { _ in () },
|
||||
groupContentTV.rx.methodInvoked(#selector(UITextView.paste(_:))).map { _ in () }
|
||||
)
|
||||
.throttle(.milliseconds(100), scheduler: MainScheduler.instance)
|
||||
.subscribe(onNext: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
let count = self.groupContentTV.text.count
|
||||
self.placeholderLab.isHidden = count != 0
|
||||
|
||||
if count > self.limitCount {
|
||||
self.groupContentTV.text = String(self.groupContentTV.text.prefix(self.limitCount))
|
||||
self.groupContentTV.selectedRange = NSRange(location: self.limitCount, length: 0)
|
||||
return
|
||||
}
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
addSubview(navBgView)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(backBtn)
|
||||
|
||||
addSubview(submitBtn)
|
||||
addSubview(titleLab)
|
||||
addSubview(infoView)
|
||||
infoView.addSubview(groupNameInputView)
|
||||
groupNameInputView.addSubview(groupNameTitleLab)
|
||||
groupNameInputView.addSubview(groupNameTF)
|
||||
|
||||
infoView.addSubview(groupIconInputView)
|
||||
groupIconInputView.addSubview(groupIconTitleLab)
|
||||
groupIconInputView.addSubview(groupIconImgView)
|
||||
|
||||
infoView.addSubview(groupContentInputView)
|
||||
groupContentInputView.addSubview(groupContentTitleLab)
|
||||
groupContentInputView.addSubview(groupContentTV)
|
||||
groupContentInputView.addSubview(placeholderLab)
|
||||
|
||||
infoView.addSubview(tagInfoView)
|
||||
tagInfoView.addSubview(tagTitleLab)
|
||||
tagInfoView.addSubview(tagView)
|
||||
tagInfoView.addSubview(tipsLab)
|
||||
|
||||
navBgView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.heightToWidth(160/375)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerY(backBtn)
|
||||
.centerX()
|
||||
|
||||
backBtn.layoutChain
|
||||
.centerY(navTitleLabel)
|
||||
.left(15)
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
titleLab.layoutChain
|
||||
.topToBottomOfView(navBarView, offset: 20)
|
||||
.left(15)
|
||||
|
||||
submitBtn.layoutChain
|
||||
.bottom(kSafeBottomMargin + 36)
|
||||
.centerX()
|
||||
.edgesHorzontal(30)
|
||||
.height(50)
|
||||
|
||||
infoView.layoutChain
|
||||
.topToBottomOfView(titleLab, offset: 20)
|
||||
.edgesHorzontal(15)
|
||||
|
||||
groupNameInputView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
|
||||
groupNameTitleLab.layoutChain
|
||||
.left(15)
|
||||
.centerY()
|
||||
.width(50)
|
||||
|
||||
groupNameTF.layoutChain
|
||||
.edgesVertical()
|
||||
.leftToRightOfView(groupNameTitleLab, offset: 20)
|
||||
.right(43)
|
||||
|
||||
groupIconInputView.layoutChain
|
||||
.topToBottomOfView(groupNameInputView)
|
||||
.leftToView(groupNameInputView)
|
||||
.rightToView(groupNameInputView)
|
||||
|
||||
groupIconTitleLab.layoutChain
|
||||
.left(15)
|
||||
.centerY()
|
||||
.width(50)
|
||||
|
||||
groupIconImgView.layoutChain
|
||||
.leftToRightOfView(groupIconTitleLab, offset: 20)
|
||||
.edgesVertical(10)
|
||||
.width(40)
|
||||
.height(40)
|
||||
|
||||
groupContentInputView.layoutChain
|
||||
.topToBottomOfView(groupIconInputView)
|
||||
.leftToView(groupNameInputView)
|
||||
.rightToView(groupNameInputView)
|
||||
|
||||
groupContentTitleLab.layoutChain
|
||||
.top(20)
|
||||
.left(15)
|
||||
.width(50)
|
||||
|
||||
groupContentTV.layoutChain
|
||||
.topToView(groupContentTitleLab, offset: -9)
|
||||
.leftToRightOfView(groupContentTitleLab, offset: 18)
|
||||
.right(52)
|
||||
.bottom(10)
|
||||
.height(20, relation: .greaterThanOrEqual)
|
||||
|
||||
placeholderLab.layoutChain
|
||||
.topToView(groupContentTV, offset: 8)
|
||||
.leftToView(groupContentTV, offset: 5)
|
||||
|
||||
tagInfoView.layoutChain
|
||||
.topToBottomOfView(groupContentInputView)
|
||||
.leftToView(groupNameInputView)
|
||||
.rightToView(groupNameInputView)
|
||||
.bottom(20)
|
||||
|
||||
tagTitleLab.layoutChain
|
||||
.top(20)
|
||||
.left(15)
|
||||
|
||||
tagView.layoutChain
|
||||
.topToBottomOfView(tagTitleLab, offset: 10)
|
||||
.edgesHorzontal(15)
|
||||
.height(64)
|
||||
|
||||
tipsLab.layoutChain
|
||||
.topToBottomOfView(tagView, offset: 10)
|
||||
.left(15)
|
||||
.bottom()
|
||||
}
|
||||
|
||||
lazy var navBgView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.image = UIImage(named: "Common/navBar_bg_2")
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "创建圈子"
|
||||
label.font = .systemFont(ofSize: 18, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var titleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "编辑信息"
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var infoView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#F5FBFF")
|
||||
view.cornerRadius = 10
|
||||
return view
|
||||
}()
|
||||
|
||||
// 圈子名称
|
||||
lazy var groupNameInputView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
|
||||
let icon = UIImageView()
|
||||
icon.image = UIImage(named: "Group/edit")
|
||||
view.addSubview(icon)
|
||||
icon.layoutChain
|
||||
.right(15)
|
||||
.edgesVertical(20)
|
||||
.width(20)
|
||||
.height(20)
|
||||
|
||||
let line = UIView()
|
||||
line.backgroundColor = UIColor(hexStr: "#EEEEEE")
|
||||
view.addSubview(line)
|
||||
line.layoutChain
|
||||
.edgesHorzontal(15)
|
||||
.height(0.5)
|
||||
.bottom()
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupNameTitleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "圈子名称"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var groupNameTF: UITextField = {
|
||||
let textField = UITextField(frame: .zero)
|
||||
textField.font = UIFont.systemFont(ofSize: 14, weight: .medium)
|
||||
textField.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
textField.placeholderColor(placeholder: "请输入圈子名称",
|
||||
color: UIColor(hexStr: "#999999", alpha: 1.0))
|
||||
return textField
|
||||
}()
|
||||
|
||||
// 圈子图标
|
||||
lazy var groupIconInputView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
|
||||
let icon = UIImageView()
|
||||
icon.image = UIImage(named: "Group/arrow")
|
||||
view.addSubview(icon)
|
||||
icon.layoutChain
|
||||
.right(15)
|
||||
.centerY()
|
||||
.width(14)
|
||||
.height(14)
|
||||
|
||||
let line = UIView()
|
||||
line.backgroundColor = UIColor(hexStr: "#EEEEEE")
|
||||
view.addSubview(line)
|
||||
line.layoutChain
|
||||
.edgesHorzontal(15)
|
||||
.height(0.5)
|
||||
.bottom()
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupIconTitleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "圈子图标"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var groupIconImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "GroupIcon/1")
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
// 圈子描述
|
||||
lazy var groupContentInputView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
|
||||
let icon = UIImageView()
|
||||
icon.image = UIImage(named: "Group/edit")
|
||||
view.addSubview(icon)
|
||||
icon.layoutChain
|
||||
.top(20)
|
||||
.right(15)
|
||||
.width(20)
|
||||
.height(20)
|
||||
|
||||
let line = UIView()
|
||||
line.backgroundColor = UIColor(hexStr: "#EEEEEE")
|
||||
view.addSubview(line)
|
||||
line.layoutChain
|
||||
.edgesHorzontal(15)
|
||||
.height(0.5)
|
||||
.bottom()
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupContentTitleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "圈子描述"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var groupContentTV: UITextView = {
|
||||
let textView = UITextView()
|
||||
textView.backgroundColor = .clear
|
||||
textView.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
textView.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
textView.isScrollEnabled = false
|
||||
return textView
|
||||
}()
|
||||
|
||||
lazy var placeholderLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "请输入圈子描述"
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
return label
|
||||
}()
|
||||
|
||||
// 标签
|
||||
lazy var tagInfoView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var tagTitleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "选择标签"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var tagView: UICollectionView = {
|
||||
let layout = UICollectionViewFlowLayout()
|
||||
let cvWidth = kScreenWidth - 60
|
||||
let spacing: CGFloat = 6
|
||||
let itemW = (cvWidth - spacing * 3) / 4
|
||||
layout.itemSize = CGSize(width: itemW, height: 27)
|
||||
layout.minimumInteritemSpacing = spacing
|
||||
layout.minimumLineSpacing = 10
|
||||
|
||||
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
cv.backgroundColor = .clear
|
||||
cv.isScrollEnabled = false
|
||||
cv.register(TagCell.self, forCellWithReuseIdentifier: TagCell.reuseId)
|
||||
cv.delegate = self
|
||||
cv.dataSource = self
|
||||
return cv
|
||||
}()
|
||||
|
||||
lazy var tipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "如选择为私密圈子,将不能被分享到探索和被搜索。"
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
label.font = .systemFont(ofSize: 10, weight: .regular)
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var submitBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("创建", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 25
|
||||
|
||||
return btn
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
backgroundColor = .white
|
||||
setupUI()
|
||||
setupRx()
|
||||
tagView.reloadData()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
|
||||
extension CreateGroupView: UICollectionViewDelegate, UICollectionViewDataSource {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return tagList.count
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TagCell.reuseId, for: indexPath) as! TagCell
|
||||
cell.configure(tagList[indexPath.item], isSelected: false)
|
||||
return cell
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
if let cell = collectionView.cellForItem(at: indexPath) as? TagCell {
|
||||
cell.toggleSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TagCell
|
||||
final class TagCell: UICollectionViewCell {
|
||||
static let reuseId = "TagCell"
|
||||
|
||||
private let label: UILabel = {
|
||||
let l = UILabel()
|
||||
l.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
l.textAlignment = .center
|
||||
return l
|
||||
}()
|
||||
|
||||
private var isTagSelected = false
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
contentView.addSubview(label)
|
||||
label.layoutChain.edges()
|
||||
contentView.layer.cornerRadius = 4
|
||||
contentView.backgroundColor = UIColor(hexStr: "#E3F6FF")
|
||||
updateStyle()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(_ text: String, isSelected: Bool) {
|
||||
label.text = text
|
||||
self.isTagSelected = isSelected
|
||||
updateStyle()
|
||||
}
|
||||
|
||||
func toggleSelection() {
|
||||
isTagSelected.toggle()
|
||||
updateStyle()
|
||||
}
|
||||
|
||||
private func updateStyle() {
|
||||
if isTagSelected {
|
||||
label.textColor = UIColor(hexStr: "#16B3FF")
|
||||
contentView.layer.borderWidth = 1
|
||||
contentView.layer.borderColor = UIColor(hexStr: "#16B3FF").cgColor
|
||||
} else {
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
contentView.layer.borderWidth = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// GroupIconListVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class GroupIconListVC: BaseViewController {
|
||||
|
||||
fileprivate var rootView: GroupIconListView!
|
||||
|
||||
override func loadView() {
|
||||
rootView = GroupIconListView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
private var iconIndex: String
|
||||
var onSelectIcon: ((Int) -> Void)?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
rootView.selectedIndex = iconIndex.integer
|
||||
rootView.iconCollectionView.delegate = self
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
init(iconIndex: String) {
|
||||
self.iconIndex = iconIndex
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
extension GroupIconListVC: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
rootView.selectedIndex = indexPath.row + 1
|
||||
onSelectIcon?(rootView.selectedIndex)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
//
|
||||
// GroupIconListView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class GroupIconListView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
var selectedIndex: Int = 1 {
|
||||
didSet {
|
||||
selectedIconView.image = UIImage(named: "GroupIcon/\(selectedIndex)")
|
||||
iconCollectionView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
private var iconImgList: [UIImage] = []
|
||||
|
||||
private func setupRx() {
|
||||
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
addSubview(navBgView)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(backBtn)
|
||||
addSubview(selectedIconView)
|
||||
addSubview(titleLab)
|
||||
addSubview(iconCollectionView)
|
||||
|
||||
navBgView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.heightToWidth(160/375)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerY(backBtn)
|
||||
.centerX()
|
||||
|
||||
backBtn.layoutChain
|
||||
.centerY(navTitleLabel)
|
||||
.left(15)
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
selectedIconView.layoutChain
|
||||
.topToBottomOfView(navBarView, offset: 30)
|
||||
.centerX()
|
||||
.width(80)
|
||||
.height(80)
|
||||
|
||||
titleLab.layoutChain
|
||||
.topToBottomOfView(selectedIconView, offset: 39)
|
||||
.left(40)
|
||||
|
||||
iconCollectionView.layoutChain
|
||||
.topToBottomOfView(titleLab, offset: 13)
|
||||
.edgesHorzontal(40)
|
||||
.bottom(kSafeBottomMargin + 10)
|
||||
}
|
||||
|
||||
lazy var navBgView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.image = UIImage(named: "Common/navBar_bg_2")
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "更换图标"
|
||||
label.font = .systemFont(ofSize: 18, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var selectedIconView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.cornerRadius = 40
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var titleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "选择图标"
|
||||
label.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var iconCollectionView: UICollectionView = {
|
||||
let layout = UICollectionViewFlowLayout()
|
||||
let cvWidth = kScreenWidth - 80
|
||||
let spacing: CGFloat = 18
|
||||
let itemW = (cvWidth - spacing * 3) / 4
|
||||
layout.itemSize = CGSize(width: itemW, height: itemW)
|
||||
layout.minimumInteritemSpacing = spacing
|
||||
layout.minimumLineSpacing = 20
|
||||
|
||||
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
cv.backgroundColor = .clear
|
||||
cv.isScrollEnabled = false
|
||||
cv.register(GroupIconCell.self)
|
||||
cv.delegate = self
|
||||
cv.dataSource = self
|
||||
return cv
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
backgroundColor = .white
|
||||
setupUI()
|
||||
setupRx()
|
||||
|
||||
for i in 1...11 {
|
||||
if let img = UIImage(named: "GroupIcon/\(i)") {
|
||||
iconImgList.append(img)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
|
||||
extension GroupIconListView: UICollectionViewDelegate, UICollectionViewDataSource {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return iconImgList.count
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(for: indexPath) as GroupIconCell
|
||||
cell.configure(img: iconImgList[indexPath.row], isSelected: selectedIndex == indexPath.row+1)
|
||||
return cell
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
selectedIndex = indexPath.row + 1
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TagCell
|
||||
final class GroupIconCell: UICollectionViewCell {
|
||||
|
||||
func configure(img: UIImage, isSelected: Bool) {
|
||||
iconImgView.image = img
|
||||
selectedMaskView.isHidden = !isSelected
|
||||
selectedIcon.isHidden = !isSelected
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
contentView.addSubview(iconImgView)
|
||||
contentView.addSubview(selectedMaskView)
|
||||
contentView.addSubview(selectedIcon)
|
||||
|
||||
iconImgView.layoutChain.edges()
|
||||
selectedMaskView.layoutChain.edges()
|
||||
|
||||
selectedIcon.layoutChain
|
||||
.right(3)
|
||||
.bottom(4)
|
||||
}
|
||||
|
||||
lazy var iconImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .clear
|
||||
view.contentMode = .scaleAspectFill
|
||||
view.cornerRadius = 10
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var selectedMaskView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .black.withAlphaComponent(0.5)
|
||||
view.cornerRadius = 10
|
||||
view.isHidden = true
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var selectedIcon: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "GroupIcon/selected")
|
||||
view.isHidden = true
|
||||
return view
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setupUI()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
|
@ -10,29 +10,33 @@ import RxSwift
|
|||
import RxCocoa
|
||||
import SDCycleScrollView
|
||||
|
||||
// MARK: - PanScrollView(参考 PanScrollView,允许嵌套手势同时识别)
|
||||
class PanScrollView: UIScrollView {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
|
||||
shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class GroupView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
// MARK: - Scroll State (参考 ShopDetailNestView)
|
||||
enum ScrollState { case pending, scrolling, ended }
|
||||
var scrollState: ScrollState = .pending
|
||||
/// 当前是否吸顶
|
||||
private var isSticky = false
|
||||
/// 内部 tableview 是否可滚动
|
||||
private var isSubCanScroll = false
|
||||
|
||||
/// segment 所在 Y(在 contentView 中的位置)
|
||||
var segmentY: CGFloat {
|
||||
let bannerH = bounds.width * (100.0 / 375.0)
|
||||
return 10 + bannerH + 12 + 60 + 12 + 16 + 8 + 140 + 4
|
||||
}
|
||||
|
||||
/// 吸顶临界值(mainScrollView 达到此值后锁定)
|
||||
var stickThreshold: CGFloat {
|
||||
return segmentY - kNaviHeight
|
||||
return segmentView.dl.y
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
private func setupUI() {
|
||||
addSubview(navBgView)
|
||||
navBgView.addSubview(navTitleLabel)
|
||||
navBgView.addSubview(scanBtn)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(scanBtn)
|
||||
|
||||
addSubview(mainScrollView)
|
||||
mainScrollView.addSubview(contentView)
|
||||
|
|
@ -55,6 +59,10 @@ class GroupView: UIView {
|
|||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerX()
|
||||
|
|
@ -79,34 +87,37 @@ class GroupView: UIView {
|
|||
.heightToWidth(100/375)
|
||||
|
||||
// 创建/加入圈子
|
||||
let btnWidth = (UIScreen.main.bounds.width - 48) / 2
|
||||
actionButtonsView.layoutChain
|
||||
.topToBottomOfView(cycleScrollView, offset: 12)
|
||||
.topToBottomOfView(cycleScrollView, offset: 38)
|
||||
.edgesHorzontal()
|
||||
.height(60)
|
||||
|
||||
createGroupBtn.layoutChain
|
||||
.left(16).centerY()
|
||||
.width(btnWidth).height(44)
|
||||
|
||||
.left(15)
|
||||
.edgesVertical()
|
||||
.widthToView(joinGroupBtn)
|
||||
.height(40)
|
||||
|
||||
joinGroupBtn.layoutChain
|
||||
.right(16).centerY()
|
||||
.width(btnWidth).height(44)
|
||||
.topToView(createGroupBtn)
|
||||
.bottomToView(createGroupBtn)
|
||||
.leftToRightOfView(createGroupBtn, offset: 21)
|
||||
.right(15)
|
||||
.widthToView(joinGroupBtn)
|
||||
|
||||
// 热门酷圈
|
||||
hotGroupTitleLabel.layoutChain
|
||||
.topToBottomOfView(actionButtonsView, offset: 12)
|
||||
.topToBottomOfView(actionButtonsView, offset: 21)
|
||||
.left(16)
|
||||
|
||||
hotGroupsCollectionView.layoutChain
|
||||
.topToBottomOfView(hotGroupTitleLabel, offset: 8)
|
||||
.edgesHorzontal()
|
||||
.height(140)
|
||||
.height(88)
|
||||
|
||||
// Segment
|
||||
let labelWidth = (UIScreen.main.bounds.width - 60) / 2
|
||||
segmentView.layoutChain
|
||||
.topToBottomOfView(hotGroupsCollectionView, offset: 4)
|
||||
.topToBottomOfView(hotGroupsCollectionView)
|
||||
.edgesHorzontal()
|
||||
.height(44)
|
||||
|
||||
|
|
@ -119,14 +130,15 @@ class GroupView: UIView {
|
|||
.width(labelWidth)
|
||||
|
||||
tabIndicator.layoutChain
|
||||
.bottom(2).centerX(createdTabLabel)
|
||||
.width(30).height(3)
|
||||
.bottom().centerX(createdTabLabel)
|
||||
.width(14).height(3)
|
||||
|
||||
// 横向 segmentScrollView
|
||||
segmentScrollView.layoutChain
|
||||
.topToBottomOfView(segmentView)
|
||||
.edgesHorzontal()
|
||||
.bottom()
|
||||
.height(kScreenHeight - kNaviHeight - 44)
|
||||
|
||||
segmentContentView.layoutChain
|
||||
.edges()
|
||||
|
|
@ -145,13 +157,8 @@ class GroupView: UIView {
|
|||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
segmentContentView.layoutChain.width(bounds.width * 2)
|
||||
|
||||
let minContentHeight = segmentY + bounds.height
|
||||
if contentView.frame.height < minContentHeight {
|
||||
contentView.layoutChain.height(minContentHeight)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Nav
|
||||
|
|
@ -161,6 +168,12 @@ class GroupView: UIView {
|
|||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
|
|
@ -178,8 +191,8 @@ class GroupView: UIView {
|
|||
}()
|
||||
|
||||
// MARK: - Main Scroll
|
||||
lazy var mainScrollView: UIScrollView = {
|
||||
let sv = UIScrollView()
|
||||
lazy var mainScrollView: PanScrollView = {
|
||||
let sv = PanScrollView()
|
||||
sv.backgroundColor = .clear
|
||||
sv.delegate = self
|
||||
sv.showsVerticalScrollIndicator = false
|
||||
|
|
@ -204,7 +217,7 @@ class GroupView: UIView {
|
|||
view.currentPageDotColor = UIColor(hexStr: "#16B3FF")
|
||||
view.pageDotColor = UIColor(hexStr: "#7AD6FF").withAlphaComponent(0.4)
|
||||
view.pageControlDotSize = CGSize(width: 8, height: 8)
|
||||
view.localizationImageNamesGroup = ["map_avatar_1", "map_avatar_2", "map_avatar_3"]
|
||||
view.localizationImageNamesGroup = ["Mask_group", "Mask_group", "Mask_group"]
|
||||
view.clipsToBounds = false
|
||||
view.pageControlBottomOffset = -34
|
||||
return view
|
||||
|
|
@ -213,60 +226,45 @@ class GroupView: UIView {
|
|||
// MARK: - 创建 / 加入 圈子
|
||||
private lazy var actionButtonsView: UIView = {
|
||||
let v = UIView()
|
||||
v.backgroundColor = .white
|
||||
v.backgroundColor = .clear
|
||||
return v
|
||||
}()
|
||||
|
||||
private(set) lazy var createGroupBtn: UIView = {
|
||||
return makeActionButton(title: "创建圈子", icon: "Home/group_icon")
|
||||
lazy var createGroupBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("创建圈子", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 20
|
||||
return btn
|
||||
}()
|
||||
|
||||
private(set) lazy var joinGroupBtn: UIView = {
|
||||
return makeActionButton(title: "加入圈子", icon: "Home/group")
|
||||
|
||||
lazy var joinGroupBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("加入圈子", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 20
|
||||
return btn
|
||||
}()
|
||||
|
||||
private func makeActionButton(title: String, icon: String) -> UIView {
|
||||
let v = UIView()
|
||||
v.backgroundColor = UIColor(hexStr: "#F5F7FA")
|
||||
v.layer.cornerRadius = 12
|
||||
v.isUserInteractionEnabled = true
|
||||
|
||||
let imgView = UIImageView(image: UIImage(named: icon))
|
||||
imgView.contentMode = .scaleAspectFit
|
||||
v.addSubview(imgView)
|
||||
|
||||
let label = UILabel()
|
||||
label.text = title
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
v.addSubview(label)
|
||||
|
||||
imgView.layoutChain
|
||||
.left(16).centerY()
|
||||
.width(24).height(24)
|
||||
|
||||
label.layoutChain
|
||||
.leftToRightOfView(imgView, offset: 8)
|
||||
.centerY()
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// MARK: - 热门酷圈
|
||||
private lazy var hotGroupTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "热门酷圈"
|
||||
label.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
label.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
label.font = .systemFont(ofSize: 16, weight: .semibold)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
private(set) lazy var hotGroupsCollectionView: UICollectionView = {
|
||||
let layout = UICollectionViewFlowLayout()
|
||||
layout.scrollDirection = .horizontal
|
||||
layout.itemSize = CGSize(width: 120, height: 140)
|
||||
layout.minimumLineSpacing = 12
|
||||
layout.sectionInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
|
||||
layout.itemSize = CGSize(width: 75, height: 88)
|
||||
layout.minimumLineSpacing = 10
|
||||
layout.sectionInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
|
||||
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
cv.backgroundColor = .clear
|
||||
cv.showsHorizontalScrollIndicator = false
|
||||
|
|
@ -278,6 +276,15 @@ class GroupView: UIView {
|
|||
private(set) lazy var segmentView: UIView = {
|
||||
let v = UIView()
|
||||
v.backgroundColor = .white
|
||||
|
||||
let line = UIView()
|
||||
line.backgroundColor = UIColor(hexStr: "#B5B5B5").withAlphaComponent(0.12)
|
||||
v.addSubview(line)
|
||||
line.layoutChain
|
||||
.edgesHorzontal()
|
||||
.height(1)
|
||||
.bottom(4)
|
||||
|
||||
return v
|
||||
}()
|
||||
|
||||
|
|
@ -308,9 +315,9 @@ class GroupView: UIView {
|
|||
return v
|
||||
}()
|
||||
|
||||
// MARK: - 横向滚动容器
|
||||
private(set) lazy var segmentScrollView: UIScrollView = {
|
||||
let sv = UIScrollView()
|
||||
// MARK: - 横向滚动容器 (PanScrollView)
|
||||
private(set) lazy var segmentScrollView: PanScrollView = {
|
||||
let sv = PanScrollView()
|
||||
sv.isPagingEnabled = true
|
||||
sv.showsHorizontalScrollIndicator = false
|
||||
sv.bounces = false
|
||||
|
|
@ -324,32 +331,32 @@ class GroupView: UIView {
|
|||
return v
|
||||
}()
|
||||
|
||||
// MARK: - 两个列表 (使用 PagerTableView 支持手势转发)
|
||||
private(set) lazy var createdTableView: PagerTableView = {
|
||||
let tv = PagerTableView(frame: .zero, style: .plain)
|
||||
// MARK: - 两个列表
|
||||
private(set) lazy var createdTableView: UITableView = {
|
||||
let tv = UITableView(frame: .zero, style: .plain)
|
||||
tv.backgroundColor = .clear
|
||||
tv.separatorStyle = .none
|
||||
tv.showsVerticalScrollIndicator = false
|
||||
tv.register(CircleGroupCell.self)
|
||||
tv.rowHeight = 72
|
||||
tv.bounces = true
|
||||
tv.panDelegate = self
|
||||
tv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 97 + kSafeBottomMargin, right: 0)
|
||||
return tv
|
||||
}()
|
||||
|
||||
private(set) lazy var joinedTableView: PagerTableView = {
|
||||
let tv = PagerTableView(frame: .zero, style: .plain)
|
||||
private(set) lazy var joinedTableView: UITableView = {
|
||||
let tv = UITableView(frame: .zero, style: .plain)
|
||||
tv.backgroundColor = .clear
|
||||
tv.separatorStyle = .none
|
||||
tv.showsVerticalScrollIndicator = false
|
||||
tv.register(CircleGroupCell.self)
|
||||
tv.rowHeight = 72
|
||||
tv.bounces = true
|
||||
tv.panDelegate = self
|
||||
tv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 97 + kSafeBottomMargin, right: 0)
|
||||
return tv
|
||||
}()
|
||||
|
||||
// MARK: - 当前 segment
|
||||
// MARK: - Segment
|
||||
var currentSegmentIndex: Int = 0
|
||||
|
||||
func selectSegment(at index: Int) {
|
||||
|
|
@ -377,59 +384,56 @@ class GroupView: UIView {
|
|||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
/// 由子 tableView 回调(GroupViewController 转发 Rx 事件)
|
||||
func childTableViewDidScroll(_ scrollView: UIScrollView) {
|
||||
self.scrollViewDidScroll(scrollView)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIScrollViewDelegate + UIGestureRecognizerDelegate
|
||||
extension GroupView: UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
||||
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
// 允许 mainScrollView 和内部 tableView 同时识别手势
|
||||
if otherGestureRecognizer == mainScrollView.panGestureRecognizer {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
// MARK: - UIScrollViewDelegate(参考 PanView + PanSubItemView 通知模式)
|
||||
extension GroupView: UIScrollViewDelegate {
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if scrollView == mainScrollView {
|
||||
let offsetY = scrollView.contentOffset.y
|
||||
|
||||
if offsetY >= stickThreshold {
|
||||
// 到达吸顶位置 → 锁定 mainScrollView,让内部 tableView 接管
|
||||
scrollState = .ended
|
||||
scrollView.contentOffset.y = stickThreshold
|
||||
scrollView.isScrollEnabled = false
|
||||
selectSegment(at: currentSegmentIndex)
|
||||
} else if offsetY > 0 {
|
||||
scrollState = .scrolling
|
||||
} else {
|
||||
scrollState = .pending
|
||||
scrollView.contentOffset.y = 0
|
||||
}
|
||||
handleMainScroll(scrollView)
|
||||
} else if scrollView == segmentScrollView {
|
||||
// 横向滚动同步 segment 指示器
|
||||
let page = Int(round(scrollView.contentOffset.x / scrollView.bounds.width))
|
||||
if page != currentSegmentIndex && page >= 0 && page < 2 {
|
||||
if page != currentSegmentIndex, page >= 0, page < 2 {
|
||||
currentSegmentIndex = page
|
||||
selectSegment(at: page)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
guard scrollView != mainScrollView, scrollView != segmentScrollView else { return }
|
||||
if scrollView.contentOffset.y > 0 {
|
||||
isSubCanScroll = true
|
||||
}
|
||||
}
|
||||
|
||||
/// 由 GroupViewController 通过 rx.didScroll 转发调用
|
||||
func handleTableViewScroll(_ scrollView: UIScrollView) {
|
||||
if isSubCanScroll {
|
||||
if scrollView.contentOffset.y <= 0 {
|
||||
isSubCanScroll = false
|
||||
isSticky = false
|
||||
scrollView.contentOffset.y = 0
|
||||
}
|
||||
} else {
|
||||
// 内部 tableView 滚动
|
||||
if scrollState == .scrolling {
|
||||
scrollView.contentOffset = .zero
|
||||
} else if scrollState == .ended {
|
||||
if scrollView.contentOffset.y <= 0 {
|
||||
scrollView.contentOffset.y = 0
|
||||
scrollState = .pending
|
||||
mainScrollView.isScrollEnabled = true
|
||||
// 把 mainScrollView 降到阈值以下,避免立即重新吸顶
|
||||
mainScrollView.contentOffset.y = stickThreshold - 20
|
||||
}
|
||||
scrollView.contentOffset.y = 0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 主 scroll 逻辑
|
||||
private func handleMainScroll(_ scrollView: UIScrollView) {
|
||||
if isSubCanScroll {
|
||||
scrollView.contentOffset.y = stickThreshold
|
||||
isSticky = true
|
||||
selectSegment(at: currentSegmentIndex)
|
||||
} else {
|
||||
let offsetY = scrollView.contentOffset.y
|
||||
if offsetY >= stickThreshold {
|
||||
scrollView.contentOffset.y = stickThreshold
|
||||
isSticky = true
|
||||
isSubCanScroll = true
|
||||
selectSegment(at: currentSegmentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -442,24 +446,24 @@ final class HotGroupCell: UICollectionViewCell {
|
|||
private let iconView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.layer.cornerRadius = 8
|
||||
iv.layer.cornerRadius = 10
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#F0F0F0")
|
||||
iv.backgroundColor = .clear
|
||||
return iv
|
||||
}()
|
||||
|
||||
private let nameLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 13, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
private let countLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 11, weight: .regular)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
label.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
|
@ -472,7 +476,7 @@ final class HotGroupCell: UICollectionViewCell {
|
|||
|
||||
iconView.layoutChain
|
||||
.top().centerX()
|
||||
.width(60).height(60)
|
||||
.width(50).height(50)
|
||||
|
||||
nameLabel.layoutChain
|
||||
.topToBottomOfView(iconView, offset: 6)
|
||||
|
|
|
|||
|
|
@ -94,19 +94,19 @@ final class GroupViewController: BaseViewController {
|
|||
rootView.segmentScrollView.setContentOffset(offset, animated: false)
|
||||
}
|
||||
|
||||
// MARK: - 内层 tableView 滚动监听(吸顶/脱离)
|
||||
// MARK: - 内层 tableView 滚动 → 转发给 GroupView 处理吸顶脱离
|
||||
private func observeTableViews() {
|
||||
rootView.createdTableView.rx.didScroll
|
||||
.subscribe(onNext: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.rootView.childTableViewDidScroll(self.rootView.createdTableView)
|
||||
self.rootView.handleTableViewScroll(self.rootView.createdTableView)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
rootView.joinedTableView.rx.didScroll
|
||||
.subscribe(onNext: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.rootView.childTableViewDidScroll(self.rootView.joinedTableView)
|
||||
self.rootView.handleTableViewScroll(self.rootView.joinedTableView)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// InviteJoinVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import ObjectMapper
|
||||
import RxSwift
|
||||
|
||||
class InviteJoinVC: BaseViewController {
|
||||
|
||||
fileprivate var rootView: InviteJoinView!
|
||||
|
||||
override func loadView() {
|
||||
rootView = InviteJoinView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
private let groupInModel: GroupInfoModel?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
guard let model = groupInModel else { return }
|
||||
|
||||
rootView.groupIcon.image = model.groupIcon
|
||||
rootView.groupNameLab.text = model.name
|
||||
requestOperateGroup(key: model.group_key)
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestOperateGroup(key: String) {
|
||||
DLToast.showLoading()
|
||||
GroupService.operate(opType: "share", requestData: ["group_key" : key]).subscribe(onNext: { [weak self] response in
|
||||
guard let self = self,
|
||||
let data = response.data,
|
||||
let code = data["share_code"] as? String else { return }
|
||||
self.rootView.inviteCodeLab.text = code
|
||||
self.rootView.qrCodeImgView.image = code.createQRCode(size: self.rootView.qrCodeImgView.dl.size)
|
||||
}, onError: { (error) in
|
||||
DLToast.show(text: "获取错误,请重试") {
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
init(groupInfo: [String: Any]) {
|
||||
self.groupInModel = GroupInfoModel.init(JSON: groupInfo)
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,286 @@
|
|||
//
|
||||
// InviteJoinView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class InviteJoinView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
private func setupRx() {
|
||||
|
||||
inviteCodeView.rx.tapGesture.subscribe { _ in
|
||||
guard let code = self.inviteCodeLab.text else { return }
|
||||
UIPasteboard.general.string = code
|
||||
DLToast.showSuccess(text: "已复制")
|
||||
}.disposed(by: disposeBag)
|
||||
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
addSubview(navBgView)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(backBtn)
|
||||
addSubview(groupIcon)
|
||||
addSubview(groupNameLab)
|
||||
addSubview(inviteInfoView)
|
||||
inviteInfoView.addSubview(inviteInfoTitleLab)
|
||||
inviteInfoView.addSubview(inviteTipsLab)
|
||||
inviteInfoView.addSubview(inviteCodeView)
|
||||
inviteCodeView.addSubview(inviteCodeTipsLab)
|
||||
inviteCodeView.addSubview(inviteCodeLab)
|
||||
inviteInfoView.addSubview(scanTipsLab)
|
||||
inviteInfoView.addSubview(qrCodeView)
|
||||
qrCodeView.addSubview(qrCodeBgImg)
|
||||
qrCodeView.addSubview(qrCodeImgView)
|
||||
addSubview(shareAppBtn)
|
||||
addSubview(shareCodeBtn)
|
||||
|
||||
navBgView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.heightToWidth(160/375)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerY(backBtn)
|
||||
.centerX()
|
||||
|
||||
backBtn.layoutChain
|
||||
.centerY(navTitleLabel)
|
||||
.left(15)
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
groupIcon.layoutChain
|
||||
.topToBottomOfView(navBarView, offset: 24)
|
||||
.width(80)
|
||||
.height(80)
|
||||
.centerX()
|
||||
|
||||
groupNameLab.layoutChain
|
||||
.topToBottomOfView(groupIcon, offset: 4)
|
||||
.centerX()
|
||||
|
||||
shareAppBtn.layoutChain
|
||||
.left(44)
|
||||
.bottom(kSafeBottomMargin + 10)
|
||||
.widthToView(shareCodeBtn)
|
||||
.height(50)
|
||||
|
||||
shareCodeBtn.layoutChain
|
||||
.leftToRightOfView(shareAppBtn, offset: 20)
|
||||
.right(44)
|
||||
.bottomToView(shareAppBtn)
|
||||
.widthToView(shareAppBtn)
|
||||
.heightToView(shareAppBtn)
|
||||
|
||||
inviteInfoView.layoutChain
|
||||
.topToBottomOfView(groupIcon, offset: 50)
|
||||
.edgesHorzontal(30)
|
||||
.bottomToTopOfView(shareAppBtn, offset: -32)
|
||||
|
||||
inviteInfoTitleLab.layoutChain
|
||||
.top(20)
|
||||
.centerX()
|
||||
|
||||
inviteTipsLab.layoutChain
|
||||
.topToBottomOfView(inviteInfoTitleLab, offset: 9)
|
||||
.centerX()
|
||||
|
||||
inviteCodeView.layoutChain
|
||||
.topToBottomOfView(inviteTipsLab, offset: 10)
|
||||
.centerX()
|
||||
.width(180)
|
||||
.height(50)
|
||||
|
||||
inviteCodeTipsLab.layoutChain
|
||||
.top(10)
|
||||
.centerX()
|
||||
|
||||
inviteCodeLab.layoutChain
|
||||
.topToBottomOfView(inviteCodeTipsLab)
|
||||
.centerX()
|
||||
|
||||
scanTipsLab.layoutChain
|
||||
.topToBottomOfView(inviteCodeView, offset: 20)
|
||||
.centerX()
|
||||
|
||||
qrCodeView.layoutChain
|
||||
.topToBottomOfView(scanTipsLab, offset: 15)
|
||||
.centerX()
|
||||
.widthToHeight(1)
|
||||
.bottom(20)
|
||||
|
||||
qrCodeBgImg.layoutChain.edges()
|
||||
|
||||
qrCodeImgView.layoutChain
|
||||
.edgesHorzontal(4)
|
||||
.edgesVertical(4)
|
||||
}
|
||||
|
||||
lazy var navBgView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.image = UIImage(named: "Common/navBar_bg_2")
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "邀请成员"
|
||||
label.font = .systemFont(ofSize: 18, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var groupIcon: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .clear
|
||||
view.cornerRadius = 40
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupNameLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var inviteInfoView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#F5FBFF")
|
||||
view.cornerRadius = 20
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var inviteInfoTitleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "将此邀请码分享给加入圈子的人"
|
||||
label.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var inviteTipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "此邀请码有效期为24小时"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#16B3FF")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var inviteCodeView: UIView = {
|
||||
let view = UIView()
|
||||
view.borderColor = UIColor(hexStr: "#CCCCCC")
|
||||
view.borderWidth = 1
|
||||
view.cornerRadius = 10
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var inviteCodeTipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "点击复制邀请码"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var inviteCodeLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 16, weight: .heavy)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var scanTipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "— 或扫描以下二维码 —"
|
||||
label.font = .systemFont(ofSize: 10)
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var qrCodeView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var qrCodeBgImg: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "Group/scan_bg")
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var qrCodeImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .clear
|
||||
view.contentMode = .scaleAspectFill
|
||||
view.cornerRadius = 10
|
||||
view.clipsToBounds = true
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var shareAppBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("分享APP", for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setTitleColor(UIColor(hexStr: "#16B3FF"), for: .normal)
|
||||
btn.backgroundColor = .white
|
||||
btn.borderWidth = 1
|
||||
btn.borderColor = UIColor(hexStr: "#16B3FF")
|
||||
btn.cornerRadius = 25
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var shareCodeBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("分享邀请码", for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.backgroundColor = .clear
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 25
|
||||
return btn
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
backgroundColor = .white
|
||||
setupUI()
|
||||
setupRx()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// JoinGroupVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class JoinGroupVC: BaseViewController {
|
||||
|
||||
fileprivate var rootView: JoinGroupView!
|
||||
|
||||
override func loadView() {
|
||||
rootView = JoinGroupView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
rootView.textField.rx.controlEvent(.editingDidEndOnExit).subscribe(onNext: {
|
||||
self.rootView.textField.resignFirstResponder()
|
||||
self.requestOperateGroup()
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
rootView.submitBtn.rx.tap.subscribe(onNext: { _ in
|
||||
self.requestOperateGroup()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
rootView.textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestOperateGroup() {
|
||||
guard rootView.inviteCode.count == 6 else {
|
||||
DLToast.show(text: "请填写完整的邀请码")
|
||||
return
|
||||
}
|
||||
DLToast.showLoading()
|
||||
GroupService.operate(opType: "join", requestData: ["share_code" : rootView.inviteCode]).subscribe(onNext: { response in
|
||||
DLToast.showSuccess(text: "申请成功") {
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
//
|
||||
// JoinGroupView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class JoinGroupView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
var numberBtns: [UIButton] = []
|
||||
|
||||
var inviteCode: String = "" {
|
||||
didSet {
|
||||
for btn in numberBtns {
|
||||
btn.setTitle("", for: .normal)
|
||||
btn.isSelected = false
|
||||
}
|
||||
|
||||
let characters = inviteCode.map { String($0) }
|
||||
for (index, character) in characters.enumerated() {
|
||||
numberBtns[index].setTitle(character, for: .normal)
|
||||
if index < numberBtns.count-1 {
|
||||
numberBtns[index].isSelected = false
|
||||
numberBtns[index+1].isSelected = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func numAction(button: UIButton) {
|
||||
textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
private func setupRx() {
|
||||
textField.rx.text
|
||||
.orEmpty
|
||||
.subscribe(onNext: { text in
|
||||
if text.count < 7 {
|
||||
self.inviteCode = text
|
||||
}
|
||||
else {
|
||||
self.inviteCode = String(text.dropLast(2) + [text.last!])
|
||||
self.textField.text = self.inviteCode
|
||||
}
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
scanBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.push(Route.scan)
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
addSubview(navBgView)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(backBtn)
|
||||
navBarView.addSubview(scanBtn)
|
||||
addSubview(titleLab)
|
||||
addSubview(number1)
|
||||
addSubview(number2)
|
||||
addSubview(number3)
|
||||
addSubview(lineView)
|
||||
addSubview(number4)
|
||||
addSubview(number5)
|
||||
addSubview(number6)
|
||||
addSubview(tipsLab)
|
||||
addSubview(submitBtn)
|
||||
addSubview(textField)
|
||||
|
||||
navBgView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.heightToWidth(160/375)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerY(backBtn)
|
||||
.centerX()
|
||||
|
||||
scanBtn.layoutChain
|
||||
.right(15)
|
||||
.centerY(navTitleLabel)
|
||||
.width(24).height(24)
|
||||
|
||||
backBtn.layoutChain
|
||||
.centerY(navTitleLabel)
|
||||
.left(15)
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
titleLab.layoutChain
|
||||
.topToBottomOfView(navBarView, offset: 21)
|
||||
.centerX()
|
||||
|
||||
lineView.layoutChain
|
||||
.topToBottomOfView(titleLab, offset: 58)
|
||||
.centerX()
|
||||
.width(10)
|
||||
.height(4)
|
||||
|
||||
number3.layoutChain
|
||||
.centerY(lineView)
|
||||
.rightToLeftOfView(lineView, offset: -8)
|
||||
.width(28)
|
||||
.height(40)
|
||||
|
||||
number2.layoutChain
|
||||
.topToView(number3)
|
||||
.rightToLeftOfView(number3, offset: -8)
|
||||
.widthToView(number3)
|
||||
.heightToView(number3)
|
||||
|
||||
number1.layoutChain
|
||||
.topToView(number3)
|
||||
.rightToLeftOfView(number2, offset: -8)
|
||||
.widthToView(number3)
|
||||
.heightToView(number3)
|
||||
|
||||
number4.layoutChain
|
||||
.centerY(lineView)
|
||||
.leftToRightOfView(lineView, offset: 8)
|
||||
.widthToView(number3)
|
||||
.heightToView(number3)
|
||||
|
||||
number5.layoutChain
|
||||
.topToView(number3)
|
||||
.leftToRightOfView(number4, offset: 8)
|
||||
.widthToView(number3)
|
||||
.heightToView(number3)
|
||||
|
||||
number6.layoutChain
|
||||
.topToView(number3)
|
||||
.leftToRightOfView(number5, offset: 8)
|
||||
.widthToView(number3)
|
||||
.heightToView(number3)
|
||||
|
||||
tipsLab.layoutChain
|
||||
.topToBottomOfView(lineView, offset: 38)
|
||||
.centerX()
|
||||
|
||||
submitBtn.layoutChain
|
||||
.bottom(kSafeBottomMargin + 36)
|
||||
.centerX()
|
||||
.edgesHorzontal(30)
|
||||
.height(50)
|
||||
}
|
||||
|
||||
lazy var navBgView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.image = UIImage(named: "Common/navBar_bg_2")
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "加入圈子"
|
||||
label.font = .systemFont(ofSize: 18, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var scanBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Group/scan"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var titleLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "输入邀请码"
|
||||
label.font = .systemFont(ofSize: 24, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var tipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "向圈子创建者询问邀请码"
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var number1: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF").withAlphaComponent(0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.cornerRadius = 4
|
||||
button.isSelected = true
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var number2: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF").withAlphaComponent(0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
button.cornerRadius = 4
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var number3: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF").withAlphaComponent(0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
button.cornerRadius = 4
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var number4: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF").withAlphaComponent(0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
button.cornerRadius = 4
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var number5: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF").withAlphaComponent(0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
button.cornerRadius = 4
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var number6: UIButton = {
|
||||
let button = UIButton (type: .custom)
|
||||
button.setTitleColor(ThemeManager.shared.color.titleColor, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#16B3FF", alpha: 0.3), for: .normal)
|
||||
button.setBackgroundColor(UIColor(hexStr: "#5CBBFF"), for: .selected)
|
||||
button.addTarget(self, action: #selector(numAction), for: .touchUpInside)
|
||||
button.cornerRadius = 4
|
||||
return button
|
||||
}()
|
||||
|
||||
lazy var lineView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#16B3FF", alpha: 0.3)
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var submitBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("加入", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 25
|
||||
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var textField: UITextField = {
|
||||
let tf = UITextField()
|
||||
tf.isHidden = true
|
||||
tf.keyboardType = .asciiCapable
|
||||
tf.autocorrectionType = .no
|
||||
tf.returnKeyType = .done
|
||||
return tf
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
backgroundColor = .white
|
||||
setupUI()
|
||||
setupRx()
|
||||
|
||||
numberBtns = [number1, number2, number3, number4, number5, number6]
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 424 KiB |
|
|
@ -11,7 +11,22 @@ class GroupListPopView: UIView {
|
|||
|
||||
private static let shared = GroupListPopView(frame: CGRect(origin: .zero, size: kScreenSize))
|
||||
|
||||
private var groupList: [GroupInfoModel] = []
|
||||
private var groupModel: GroupModel? {
|
||||
didSet {
|
||||
guard let model = groupModel else { return }
|
||||
groupNameLab.text = model.groups.first(where: { $0.group_key == model.default_group_key })?.name ?? ""
|
||||
defaultGroupKey = model.default_group_key
|
||||
groupList = model.groups
|
||||
}
|
||||
}
|
||||
|
||||
private var defaultGroupKey: String = ""
|
||||
|
||||
private var groupList: [GroupInfoModel] = [] {
|
||||
didSet {
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
/// 完成选中进行回调
|
||||
private var completion: ((String?) -> Void)?
|
||||
|
|
@ -20,10 +35,14 @@ class GroupListPopView: UIView {
|
|||
completion?(nil)
|
||||
}
|
||||
|
||||
private var defaultGroupKey: String = "" {
|
||||
didSet {
|
||||
tableView.reloadData()
|
||||
}
|
||||
@objc func createAction(button: UIButton) {
|
||||
completion?(nil)
|
||||
AppRouter.push(Route.createGroup)
|
||||
}
|
||||
|
||||
@objc func joinAction(button: UIButton) {
|
||||
completion?(nil)
|
||||
AppRouter.push(Route.joinGroup)
|
||||
}
|
||||
|
||||
private lazy var bgView: UIView = {
|
||||
|
|
@ -33,15 +52,47 @@ class GroupListPopView: UIView {
|
|||
return view
|
||||
}()
|
||||
|
||||
// 圈子选择
|
||||
lazy var groupView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
view.cornerRadius = 18
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupIconView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "Home/group")
|
||||
view.backgroundColor = .clear
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var groupNameLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#0F2846")
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var groupArrowIconView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "Home/arrow_down")
|
||||
view.backgroundColor = .clear
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var infoView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
view.cornerRadius = 20
|
||||
view.cornerRadius = 10
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var tableView: UITableView = {
|
||||
let tableView = UITableView(frame: .zero, style: .plain)
|
||||
let tableView = UITableView(frame: .zero, style: .grouped)
|
||||
tableView.backgroundColor = .white
|
||||
tableView.separatorStyle = .none
|
||||
tableView.estimatedRowHeight = 68
|
||||
|
|
@ -49,17 +100,95 @@ class GroupListPopView: UIView {
|
|||
tableView.bounces = false
|
||||
tableView.isScrollEnabled = false
|
||||
tableView.register(GroupListPopCell.self)
|
||||
tableView.tableHeaderView = UIView(frame: CGRectMake(0, 0, kScreenWidth, 10))
|
||||
tableView.dataSource = self
|
||||
tableView.delegate = self
|
||||
return tableView
|
||||
}()
|
||||
|
||||
lazy var createGroupBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("创建圈子", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 22
|
||||
btn.addTarget(self, action: #selector(createAction), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var joinGroupBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("加入圈子", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 22
|
||||
btn.addTarget(self, action: #selector(joinAction), for: .touchUpInside)
|
||||
|
||||
return btn
|
||||
}()
|
||||
|
||||
// MARK: - Init
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = .clear
|
||||
addSubview(bgView)
|
||||
bgView.addSubview(tableView)
|
||||
bgView.addSubview(infoView)
|
||||
infoView.addSubview(tableView)
|
||||
infoView.addSubview(createGroupBtn)
|
||||
infoView.addSubview(joinGroupBtn)
|
||||
|
||||
bgView.addSubview(groupView)
|
||||
groupView.addSubview(groupIconView)
|
||||
groupView.addSubview(groupNameLab)
|
||||
groupView.addSubview(groupArrowIconView)
|
||||
|
||||
groupView.layoutChain
|
||||
.top(59)
|
||||
.height(36)
|
||||
.centerX()
|
||||
.width(185, relation: .greaterThanOrEqual)
|
||||
|
||||
groupIconView.layoutChain
|
||||
.left(11)
|
||||
.centerY()
|
||||
.width(30)
|
||||
.height(30)
|
||||
|
||||
groupArrowIconView.layoutChain
|
||||
.right(15)
|
||||
.centerY()
|
||||
.width(15)
|
||||
.height(8.5)
|
||||
|
||||
groupNameLab.layoutChain
|
||||
.edgesVertical()
|
||||
.leftToRightOfView(groupIconView)
|
||||
.rightToLeftOfView(groupArrowIconView)
|
||||
|
||||
infoView.layoutChain
|
||||
.topToBottomOfView(groupView, offset: 20)
|
||||
.edgesHorzontal(15)
|
||||
|
||||
createGroupBtn.layoutChain
|
||||
.left(15)
|
||||
.bottom(20)
|
||||
.widthToView(joinGroupBtn)
|
||||
.height(44)
|
||||
|
||||
joinGroupBtn.layoutChain
|
||||
.leftToRightOfView(createGroupBtn, offset: 7)
|
||||
.right(15)
|
||||
.bottom(20)
|
||||
.height(44)
|
||||
.widthToView(joinGroupBtn)
|
||||
|
||||
tableView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(78, relation: .greaterThanOrEqual)
|
||||
.bottomToTopOfView(createGroupBtn, offset: -17)
|
||||
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(tap))
|
||||
tap.delegate = self
|
||||
addGestureRecognizer(tap)
|
||||
|
|
@ -71,10 +200,6 @@ class GroupListPopView: UIView {
|
|||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
tableView.setNeedsLayout()
|
||||
tableView.layoutIfNeeded()
|
||||
tableView.setCornerRadius(corners: [.bottomLeft, .bottomRight], withCornerRadii: CGSize(width: 16, height: 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,8 +210,7 @@ extension GroupListPopView {
|
|||
/// - Parameters:
|
||||
/// - start: 显示起始点
|
||||
static func show(start: CGPoint,
|
||||
defaultGroupKey: String,
|
||||
groupList: [GroupInfoModel],
|
||||
groupModel: GroupModel,
|
||||
completion: @escaping ((String?) -> Void)) {
|
||||
guard let superView = kKeyWindow else {
|
||||
return
|
||||
|
|
@ -94,39 +218,38 @@ extension GroupListPopView {
|
|||
|
||||
if GroupListPopView.shared.superview != nil {
|
||||
GroupListPopView.shared.removeFromSuperview()
|
||||
GroupListPopView.shared.tableView.frame = .zero
|
||||
GroupListPopView.shared.bgView.frame = .zero
|
||||
}
|
||||
GroupListPopView.shared.defaultGroupKey = defaultGroupKey
|
||||
GroupListPopView.shared.groupModel = groupModel
|
||||
GroupListPopView.shared.bgView.alpha = 1
|
||||
GroupListPopView.shared.bgView.frame = CGRect(origin: start, size: CGSize(width: kScreenWidth, height: kScreenHeight - start.y))
|
||||
GroupListPopView.shared.bgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
|
||||
superView.addSubview(GroupListPopView.shared)
|
||||
superView.bringSubviewToFront(GroupListPopView.shared)
|
||||
let tableViewHeight = CGFloat(GroupListPopView.shared.groupList.count * 30) + 6
|
||||
GroupListPopView.shared.tableView.frame = CGRect(x: 0, y: -tableViewHeight, width: kScreenWidth, height: tableViewHeight)
|
||||
GroupListPopView.shared.tableView.alpha = 0
|
||||
let viewHeight = CGFloat(GroupListPopView.shared.groupList.count * 68) + 10 + 81
|
||||
GroupListPopView.shared.tableView.dl.height = viewHeight
|
||||
GroupListPopView.shared.infoView.alpha = 0
|
||||
GroupListPopView.shared.completion = { (text) in
|
||||
completion(text)
|
||||
GroupListPopView.dismiss()
|
||||
}
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
GroupListPopView.shared.tableView.alpha = 1
|
||||
GroupListPopView.shared.tableView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: tableViewHeight)
|
||||
GroupListPopView.shared.infoView.alpha = 1
|
||||
// GroupListPopView.shared.infoView.dl.y = start.y
|
||||
}
|
||||
}
|
||||
|
||||
/// 关闭
|
||||
static func dismiss() {
|
||||
guard GroupListPopView.shared.superview != nil else { return }
|
||||
let tableViewHeight = GroupListPopView.shared.frame.height
|
||||
let viewHeight = GroupListPopView.shared.infoView.frame.height
|
||||
UIView.animate(withDuration: 0.15) {
|
||||
GroupListPopView.shared.tableView.alpha = 0
|
||||
GroupListPopView.shared.tableView.frame = CGRect(x: 0, y: -tableViewHeight, width: kScreenWidth, height: tableViewHeight)
|
||||
GroupListPopView.shared.infoView.alpha = 0
|
||||
// GroupListPopView.shared.infoView.dl.y = -viewHeight
|
||||
}
|
||||
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseIn]) {
|
||||
GroupListPopView.shared.bgView.alpha = 0
|
||||
} completion: { _ in
|
||||
GroupListPopView.shared.removeFromSuperview()
|
||||
GroupListPopView.shared.tableView.frame = .zero
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -190,6 +313,7 @@ class GroupListPopCell: UITableViewCell {
|
|||
.height(40)
|
||||
|
||||
nameLab.layoutChain
|
||||
.centerY(avaterImgView)
|
||||
.leftToRightOfView(avaterImgView, offset: 11)
|
||||
.right(100, relation: .greaterThanOrEqual)
|
||||
}
|
||||
|
|
@ -237,15 +361,15 @@ class GroupListPopCell: UITableViewCell {
|
|||
|
||||
lazy var avaterImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .lightGray
|
||||
// view.backgroundColor = .lightGray
|
||||
view.contentMode = .scaleAspectFill
|
||||
view.cornerRadius = 20
|
||||
// view.cornerRadius = 20
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var nameLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.font = .systemFont(ofSize: 15, weight: .medium)
|
||||
return label
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ class GroupMemberView: UIView {
|
|||
tableView.backgroundColor = .clear
|
||||
tableView.separatorStyle = .none
|
||||
tableView.estimatedRowHeight = 76
|
||||
tableView.bounces = false
|
||||
tableView.showsVerticalScrollIndicator = false
|
||||
tableView.register(GroupMemberCell.self)
|
||||
return tableView
|
||||
|
|
@ -158,15 +159,25 @@ class GroupMemberCell: UITableViewCell {
|
|||
avaterImgView.image = model.userIcon
|
||||
vipIcon.image = model.vipIcon
|
||||
nameLab.text = model.nick_name
|
||||
// 位置
|
||||
locationLab.text = "在 " + model.lastLocation
|
||||
|
||||
nameLab.textColor = UIColor(hexStr: isCurrentUser ? "#16B3FF" : "#0F2846")
|
||||
|
||||
// 电量 16是电池图标宽度,右边有电池造型需要减去
|
||||
batteryView.layoutChain.width(CGFloat((16 - 1) * (model.battery.int / 100)))
|
||||
batteryLab.text = "\(model.battery)%"
|
||||
}
|
||||
|
||||
private func setupSubviews() {
|
||||
contentView.addSubview(ownBgView)
|
||||
contentView.addSubview(avaterImgView)
|
||||
contentView.addSubview(vipIcon)
|
||||
contentView.addSubview(batteryInfoView)
|
||||
batteryInfoView.addSubview(cornerView)
|
||||
cornerView.addSubview(batteryView)
|
||||
cornerView.addSubview(batteryIcon)
|
||||
cornerView.addSubview(batteryLab)
|
||||
contentView.addSubview(nameLab)
|
||||
contentView.addSubview(locationIcon)
|
||||
contentView.addSubview(locationLab)
|
||||
|
|
@ -187,6 +198,30 @@ class GroupMemberCell: UITableViewCell {
|
|||
.width(50)
|
||||
.height(50)
|
||||
|
||||
batteryInfoView.layoutChain
|
||||
.leftToView(avaterImgView)
|
||||
.rightToView(avaterImgView)
|
||||
.bottomToView(avaterImgView)
|
||||
.height(12)
|
||||
|
||||
cornerView.layoutChain.edges()
|
||||
|
||||
batteryIcon.layoutChain
|
||||
.left(7)
|
||||
.centerY()
|
||||
.width(16)
|
||||
.height(8)
|
||||
|
||||
batteryView.layoutChain
|
||||
.topToView(batteryIcon)
|
||||
.leftToView(batteryIcon, offset: -1)
|
||||
.bottomToView(batteryIcon)
|
||||
|
||||
batteryLab.layoutChain
|
||||
.leftToRightOfView(batteryIcon, offset: 4)
|
||||
.right(5)
|
||||
.centerY()
|
||||
|
||||
vipIcon.layoutChain
|
||||
.topToView(avaterImgView, offset: -8)
|
||||
.leftToView(avaterImgView, offset: -6)
|
||||
|
|
@ -237,6 +272,43 @@ class GroupMemberCell: UITableViewCell {
|
|||
return view
|
||||
}()
|
||||
|
||||
lazy var batteryInfoView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
view.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
|
||||
view.layer.shadowOffset = CGSize(width: 0, height: 2)
|
||||
view.layer.shadowOpacity = 1
|
||||
view.layer.shadowRadius = 6
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var cornerView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
view.cornerRadius = 6
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var batteryView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#75E582")
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var batteryIcon: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .clear
|
||||
view.image = UIImage(named: "Home/battery")
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var batteryLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = UIColor(hexStr: "#D4D4D4")
|
||||
label.font = .systemFont(ofSize: 6, weight: .medium)
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var vipIcon: UIImageView = {
|
||||
let view = UIImageView()
|
||||
return view
|
||||
|
|
@ -320,7 +392,7 @@ class GroupMemberCell: UITableViewCell {
|
|||
dot.cornerRadius = 4
|
||||
|
||||
let label = UILabel()
|
||||
label.textColor = ThemeManager.shared.color.subTitleColor
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
label.text = "在线"
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class HomeView: UIView {
|
|||
|
||||
signInView.layoutChain.height(58)
|
||||
|
||||
signInIcon.layoutChain
|
||||
signInIcon.layoutChain
|
||||
.top()
|
||||
.centerX()
|
||||
.width(28)
|
||||
|
|
@ -301,7 +301,6 @@ class HomeView: UIView {
|
|||
|
||||
lazy var groupNameLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "我的圈子"
|
||||
label.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#0F2846")
|
||||
label.textAlignment = .center
|
||||
|
|
@ -357,6 +356,7 @@ class HomeView: UIView {
|
|||
lazy var toolsView: UIStackView = {
|
||||
let view = UIStackView(arrangedSubviews: [bubbleView, signInView, sosView])
|
||||
view.axis = .vertical
|
||||
view.distribution = .fillEqually
|
||||
view.alignment = .center
|
||||
view.spacing = 0
|
||||
view.backgroundColor = .black.withAlphaComponent(0.5)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class HomeViewController: BaseViewController {
|
|||
private var members: [CircleMember] = []
|
||||
private var currentUserMember: CircleMember?
|
||||
private var currentUserAnnotation: MemberAnnotation?
|
||||
private var hasCenteredOnUserLocation = false
|
||||
|
||||
override func loadView() {
|
||||
#if !targetEnvironment(simulator)
|
||||
|
|
@ -57,10 +56,25 @@ class HomeViewController: BaseViewController {
|
|||
}
|
||||
|
||||
private func reactiveAction() {
|
||||
rootView.groupView.rx.tapGesture.subscribe { _ in
|
||||
guard let groupModel = self.viewModel.groupModel else { return }
|
||||
let groupViewFrame = self.view.convert(self.rootView.groupView.frame, from: self.rootView)
|
||||
let startPointY = groupViewFrame.origin.y + groupViewFrame.height
|
||||
GroupListPopView.show(start: CGPoint(x: 0, y: startPointY + 20),
|
||||
groupModel: groupModel) { groupKey in
|
||||
guard let key = groupKey else { return }
|
||||
self.requestOperateGroup(groupKey: key)
|
||||
}
|
||||
}.disposed(by: disposeBag)
|
||||
|
||||
rootView.groupMemberView.refreshBtn.rx.tap.subscribe(onNext: { _ in
|
||||
self.requestGroupInfo()
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
rootView.groupMemberView.inviteJoinBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.push(Route.inviteJoin, userInfo: ["groupInfo": self.viewModel.groupInfo])
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
rootView.locationView.rx.tapGesture.subscribe { _ in
|
||||
if let ann = self.currentUserAnnotation {
|
||||
self.rootView.mapView.setCenter(ann.coordinate, animated: true)
|
||||
|
|
@ -105,7 +119,7 @@ class HomeViewController: BaseViewController {
|
|||
}
|
||||
|
||||
private func requestGroupInfo() {
|
||||
UserService.groupInfo().subscribe { response in
|
||||
GroupService.groupInfo().subscribe { response in
|
||||
guard let model = response.model else { return }
|
||||
self.viewModel.groupModel = model
|
||||
self.rootView.groupMemberView.setupCountData(self.viewModel.memberCount, self.viewModel.memberOnlineCount)
|
||||
|
|
@ -114,6 +128,12 @@ class HomeViewController: BaseViewController {
|
|||
}.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func requestOperateGroup(groupKey: String) {
|
||||
GroupService.operate(opType: "setdefault", requestData: ["group_key" : groupKey]).subscribe { response in
|
||||
self.requestGroupInfo()
|
||||
}.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Map Setup
|
||||
private func setupMap() {
|
||||
#if !targetEnvironment(simulator)
|
||||
|
|
@ -239,12 +259,8 @@ extension HomeViewController: MAMapViewDelegate {
|
|||
ann.coordinate = coordinate
|
||||
}
|
||||
|
||||
// 首次定位后居中
|
||||
if !hasCenteredOnUserLocation {
|
||||
hasCenteredOnUserLocation = true
|
||||
mapView.setCenter(coordinate, animated: true)
|
||||
mapView.setUserTrackingMode(.follow, animated: true)
|
||||
}
|
||||
mapView.setCenter(coordinate, animated: true)
|
||||
mapView.setUserTrackingMode(.follow, animated: true)
|
||||
}
|
||||
|
||||
func mapViewRequireLocationAuth(_ locationManager: CLLocationManager!) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import RxSwift
|
||||
import RxDataSources
|
||||
import ObjectMapper
|
||||
|
||||
typealias GroupMemberListSectionModel = SectionModel<String, GroupMemberModel>
|
||||
|
||||
|
|
@ -35,6 +36,15 @@ class HomeViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
// 当前选中的圈子
|
||||
var groupInfo: [String: Any] {
|
||||
get {
|
||||
guard let model = groupModel,
|
||||
let groupInfoModel = model.groups.first(where: { $0.group_key == model.default_group_key }) else { return [:] }
|
||||
return groupInfoModel.toJSON()
|
||||
}
|
||||
}
|
||||
|
||||
// 圈子名字
|
||||
var groupName: String {
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
//
|
||||
// ScanVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
import RxSwift
|
||||
|
||||
class ScanVC: BaseViewController {
|
||||
|
||||
override var isNavigationBarHidden: Bool { true }
|
||||
|
||||
fileprivate var rootView: ScanView!
|
||||
|
||||
override func loadView() {
|
||||
rootView = ScanView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
private var captureSession: AVCaptureSession!
|
||||
private var previewLayer: AVCaptureVideoPreviewLayer!
|
||||
private var isScanning = false
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setupCamera()
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
previewLayer?.frame = view.bounds
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
if let session = captureSession, !session.isRunning {
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
session.startRunning()
|
||||
}
|
||||
}
|
||||
startScanAnimation()
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
if let session = captureSession, session.isRunning {
|
||||
session.stopRunning()
|
||||
}
|
||||
rootView.scanLineView.layer.removeAllAnimations()
|
||||
}
|
||||
|
||||
private func handleScanResult(text: String) {
|
||||
guard !isScanning else { return }
|
||||
isScanning = true
|
||||
captureSession.stopRunning()
|
||||
rootView.scanLineView.alpha = 0
|
||||
rootView.scanLineView.layer.removeAllAnimations()
|
||||
requestOperateGroup(code: text)
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestOperateGroup(code: String) {
|
||||
DLToast.showLoading()
|
||||
GroupService.operate(opType: "join", requestData: ["share_code" : code]).subscribe(onNext: { response in
|
||||
|
||||
}, onError: { [weak self] (error) in
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
||||
self?.isScanning = false
|
||||
self?.startSession()
|
||||
}
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func startSession() {
|
||||
if let session = captureSession, !session.isRunning {
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
session.startRunning()
|
||||
}
|
||||
}
|
||||
startScanAnimation()
|
||||
}
|
||||
|
||||
// MARK: - 扫描线动画
|
||||
private func startScanAnimation() {
|
||||
rootView.scanLineView.layer.removeAllAnimations()
|
||||
rootView.scanLineView.alpha = 1
|
||||
rootView.scanLineView.frame.origin.y = 0
|
||||
|
||||
let boxH = rootView.scanBoxView.bounds.height
|
||||
guard boxH > 0 else {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
|
||||
self?.startScanAnimation()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
UIView.animate(withDuration: 2.0, delay: 0, options: [.repeat, .curveLinear]) {
|
||||
self.rootView.scanLineView.frame.origin.y = boxH - 2
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 相机配置
|
||||
private func setupCamera() {
|
||||
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
switch status {
|
||||
case .authorized:
|
||||
break
|
||||
case .notDetermined:
|
||||
AVCaptureDevice.requestAccess(for: .video) { [weak self] granted in
|
||||
DispatchQueue.main.async {
|
||||
if granted { self?.setupCamera() }
|
||||
}
|
||||
}
|
||||
return
|
||||
default:
|
||||
DLToast.show(text: "请在设置中开启相机权限")
|
||||
return
|
||||
}
|
||||
|
||||
captureSession = AVCaptureSession()
|
||||
captureSession.sessionPreset = .high
|
||||
|
||||
guard let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else {
|
||||
DLToast.show(text: "未检测到摄像头")
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
let input = try AVCaptureDeviceInput(device: videoDevice)
|
||||
if captureSession.canAddInput(input) {
|
||||
captureSession.addInput(input)
|
||||
}
|
||||
|
||||
let output = AVCaptureMetadataOutput()
|
||||
if captureSession.canAddOutput(output) {
|
||||
captureSession.addOutput(output)
|
||||
output.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
|
||||
output.metadataObjectTypes = [.qr, .code128, .ean13, .ean8, .upce, .code39, .code39Mod43]
|
||||
}
|
||||
|
||||
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
|
||||
previewLayer.frame = view.bounds
|
||||
previewLayer.videoGravity = .resizeAspectFill
|
||||
view.layer.insertSublayer(previewLayer, at: 0)
|
||||
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
self.captureSession.startRunning()
|
||||
}
|
||||
|
||||
} catch {
|
||||
DLToast.show(text: "相机初始化失败:\(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - AVCaptureMetadataOutputObjectsDelegate
|
||||
extension ScanVC: AVCaptureMetadataOutputObjectsDelegate {
|
||||
func metadataOutput(_ output: AVCaptureMetadataOutput,
|
||||
didOutput metadataObjects: [AVMetadataObject],
|
||||
from connection: AVCaptureConnection) {
|
||||
guard let obj = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
|
||||
let result = obj.stringValue else { return }
|
||||
handleScanResult(text: result)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
//
|
||||
// ScanView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/2.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
import AVFoundation
|
||||
|
||||
class ScanView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
private func setupRx() {
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
torchBtn.rx.tap.subscribe(onNext: { _ in
|
||||
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else { return }
|
||||
do {
|
||||
try device.lockForConfiguration()
|
||||
device.torchMode = device.torchMode == .on ? .off : .on
|
||||
device.unlockForConfiguration()
|
||||
} catch {
|
||||
DLToast.show(text: "闪光灯开启失败")
|
||||
}
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(backBtn)
|
||||
navBarView.addSubview(torchBtn)
|
||||
|
||||
addSubview(scanBoxView)
|
||||
scanBoxView.addSubview(scanImgView)
|
||||
scanBoxView.addSubview(scanLineView)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
backBtn.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.left(15)
|
||||
.width(35)
|
||||
.height(24)
|
||||
|
||||
torchBtn.layoutChain
|
||||
.centerY(backBtn)
|
||||
.right(15)
|
||||
.width(100)
|
||||
.height(24)
|
||||
|
||||
scanBoxView.layoutChain
|
||||
.centerY()
|
||||
.edgesHorzontal(35)
|
||||
.heightToWidth(1)
|
||||
|
||||
scanImgView.layoutChain.edges()
|
||||
|
||||
// scanLineView 用 frame 动画,不设置 AutoLayout
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
scanLineView.frame = CGRect(x: 5, y: 0, width: scanBoxView.bounds.width - 10, height: 2)
|
||||
}
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("取消", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var torchBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("打开手电筒", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var scanBoxView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var scanImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.backgroundColor = .clear
|
||||
view.image = UIImage(named: "Scan/scan")
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var scanLineView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#16B3FF")
|
||||
return view
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
backgroundColor = .clear
|
||||
setupUI()
|
||||
setupRx()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// GroupService.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/1.
|
||||
//
|
||||
|
||||
import RxSwift
|
||||
import Moya
|
||||
|
||||
struct GroupService {
|
||||
static let disposeBag = DisposeBag()
|
||||
|
||||
/// 圈子信息
|
||||
static func groupInfo() -> Observable<UserGroupResponse> {
|
||||
let api = GroupAPI.groupInfo.multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(UserGroupResponse.self)
|
||||
.asObservable()
|
||||
}
|
||||
|
||||
/// 圈子操作(创建、解散、设为默认等)
|
||||
/// - Parameters:
|
||||
/// - opType: create、dismiss、setdefault
|
||||
/// - requestData:[String: Any] 根据操作传入对应的值
|
||||
static func operate(opType: String, requestData: [String: Any]) -> Observable<ResponseModel> {
|
||||
let api = GroupAPI.operate(opType: opType, requestData: requestData).multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(ResponseModel.self)
|
||||
.asObservable()
|
||||
}
|
||||
}
|
||||
|
|
@ -34,14 +34,6 @@ struct UserService {
|
|||
.asObservable()
|
||||
}
|
||||
|
||||
/// 圈子信息
|
||||
static func groupInfo() -> Observable<UserGroupResponse> {
|
||||
let api = UserAPI.groupInfo.multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(UserGroupResponse.self)
|
||||
.asObservable()
|
||||
}
|
||||
|
||||
/// 退出登录
|
||||
static func logout() -> Observable<ResponseModel> {
|
||||
let api = UserAPI.logout.multiTarget
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// TTGTagCollectionView-Bridging-Header.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2021/4/21.
|
||||
//
|
||||
|
||||
#ifndef TTGTagCollectionView_Bridging_Header_h
|
||||
#define TTGTagCollectionView_Bridging_Header_h
|
||||
|
||||
#import "TTGTagCollectionView.h"
|
||||
#import "TTGTextTagCollectionView.h"
|
||||
#import "TTGTextTag.h"
|
||||
#import "TTGTextTagContent.h"
|
||||
#import "TTGTextTagStringContent.h"
|
||||
#import "TTGTextTagAttributedStringContent.h"
|
||||
#import "TTGTextTagStyle.h"
|
||||
|
||||
#endif /* TTGTagCollectionView_Bridging_Header_h */
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
//
|
||||
// TTGTagCollectionView.h
|
||||
// Pods
|
||||
//
|
||||
// Created by zekunyan on 15/12/26.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TTGTagCollectionView;
|
||||
|
||||
/**
|
||||
* Tags scroll direction
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, TTGTagCollectionScrollDirection) {
|
||||
TTGTagCollectionScrollDirectionVertical = 0, // Default
|
||||
TTGTagCollectionScrollDirectionHorizontal = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Tags alignment
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, TTGTagCollectionAlignment) {
|
||||
TTGTagCollectionAlignmentLeft = 0, // Default
|
||||
TTGTagCollectionAlignmentCenter, // Center
|
||||
TTGTagCollectionAlignmentRight, // Right
|
||||
TTGTagCollectionAlignmentFillByExpandingSpace, // Expand horizontal spacing and fill
|
||||
TTGTagCollectionAlignmentFillByExpandingWidth, // Expand width and fill
|
||||
TTGTagCollectionAlignmentFillByExpandingWidthExceptLastLine // Expand width and fill, except last line
|
||||
};
|
||||
|
||||
/**
|
||||
* Tags delegate
|
||||
*/
|
||||
@protocol TTGTagCollectionViewDelegate <NSObject>
|
||||
@required
|
||||
- (CGSize)tagCollectionView:(TTGTagCollectionView *)tagCollectionView sizeForTagAtIndex:(NSUInteger)index;
|
||||
|
||||
@optional
|
||||
- (BOOL)tagCollectionView:(TTGTagCollectionView *)tagCollectionView shouldSelectTag:(UIView *)tagView atIndex:(NSUInteger)index;
|
||||
|
||||
- (void)tagCollectionView:(TTGTagCollectionView *)tagCollectionView didSelectTag:(UIView *)tagView atIndex:(NSUInteger)index;
|
||||
|
||||
- (void)tagCollectionView:(TTGTagCollectionView *)tagCollectionView updateContentSize:(CGSize)contentSize;
|
||||
@end
|
||||
|
||||
/**
|
||||
* Tags dataSource
|
||||
*/
|
||||
@protocol TTGTagCollectionViewDataSource <NSObject>
|
||||
@required
|
||||
- (NSUInteger)numberOfTagsInTagCollectionView:(TTGTagCollectionView *)tagCollectionView;
|
||||
|
||||
- (UIView *)tagCollectionView:(TTGTagCollectionView *)tagCollectionView tagViewForIndex:(NSUInteger)index;
|
||||
@end
|
||||
|
||||
@interface TTGTagCollectionView : UIView
|
||||
@property (nonatomic, weak) id <TTGTagCollectionViewDataSource> dataSource;
|
||||
@property (nonatomic, weak) id <TTGTagCollectionViewDelegate> delegate;
|
||||
|
||||
// Inside scrollView
|
||||
@property (nonatomic, strong, readonly) UIScrollView *scrollView;
|
||||
|
||||
// Tags scroll direction, default is vertical.
|
||||
@property (nonatomic, assign) TTGTagCollectionScrollDirection scrollDirection;
|
||||
|
||||
// Tags layout alignment, default is left.
|
||||
@property (nonatomic, assign) TTGTagCollectionAlignment alignment;
|
||||
|
||||
// Number of lines. 0 means no limit, default is 0 for vertical and 1 for horizontal.
|
||||
@property (nonatomic, assign) NSUInteger numberOfLines;
|
||||
// The real number of lines ignoring the numberOfLines value
|
||||
@property (nonatomic, assign, readonly) NSUInteger actualNumberOfLines;
|
||||
|
||||
// Horizontal and vertical space between tags, default is 4.
|
||||
@property (nonatomic, assign) CGFloat horizontalSpacing;
|
||||
@property (nonatomic, assign) CGFloat verticalSpacing;
|
||||
|
||||
// Content inset, default is UIEdgeInsetsMake(2, 2, 2, 2).
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
|
||||
// The true tags content size, readonly
|
||||
@property (nonatomic, assign, readonly) CGSize contentSize;
|
||||
|
||||
// Manual content height
|
||||
// Default = NO, set will update content
|
||||
@property (nonatomic, assign) BOOL manualCalculateHeight;
|
||||
// Default = 0, set will update content
|
||||
@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;
|
||||
|
||||
// Scroll indicator
|
||||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
||||
|
||||
// Tap blank area callback
|
||||
@property (nonatomic, copy) void (^onTapBlankArea)(CGPoint location);
|
||||
// Tap all area callback
|
||||
@property (nonatomic, copy) void (^onTapAllArea)(CGPoint location);
|
||||
|
||||
/**
|
||||
* Reload all tag cells
|
||||
*/
|
||||
- (void)reload;
|
||||
|
||||
/**
|
||||
* Returns the index of the tag located at the specified point.
|
||||
* If item at point is not found, returns NSNotFound.
|
||||
*/
|
||||
- (NSInteger)indexOfTagAt:(CGPoint)point;
|
||||
|
||||
@end
|
||||
|
|
@ -1,490 +0,0 @@
|
|||
//
|
||||
// TTGTagCollectionView.m
|
||||
// Pods
|
||||
//
|
||||
// Created by zekunyan on 15/12/26.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTagCollectionView.h"
|
||||
|
||||
@interface TTGTagCollectionView ()
|
||||
@property (nonatomic, strong) UIScrollView *scrollView;
|
||||
@property (nonatomic, strong) UIView *containerView;
|
||||
@property (nonatomic, assign) BOOL needsLayoutTagViews;
|
||||
@property (nonatomic, assign) NSUInteger actualNumberOfLines;
|
||||
@end
|
||||
|
||||
@implementation TTGTagCollectionView
|
||||
|
||||
#pragma mark - Init
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
if (_scrollView) {
|
||||
return;
|
||||
}
|
||||
|
||||
_horizontalSpacing = 4;
|
||||
_verticalSpacing = 4;
|
||||
_contentInset = UIEdgeInsetsMake(2, 2, 2, 2);
|
||||
|
||||
_scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
|
||||
_scrollView.backgroundColor = [UIColor clearColor];
|
||||
_scrollView.userInteractionEnabled = YES;
|
||||
[self addSubview:_scrollView];
|
||||
|
||||
_containerView = [[UIView alloc] initWithFrame:_scrollView.bounds];
|
||||
_containerView.backgroundColor = [UIColor clearColor];
|
||||
_containerView.userInteractionEnabled = YES;
|
||||
[_scrollView addSubview:_containerView];
|
||||
|
||||
UITapGestureRecognizer *tapGesture = [UITapGestureRecognizer new];
|
||||
[tapGesture addTarget:self action:@selector(onTapGesture:)];
|
||||
[_containerView addGestureRecognizer:tapGesture];
|
||||
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
#pragma mark - Public methods
|
||||
|
||||
- (void)reload {
|
||||
if (![self isDelegateAndDataSourceValid]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove all tag views
|
||||
[_containerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
|
||||
// Add tag view
|
||||
for (NSUInteger i = 0; i < [_dataSource numberOfTagsInTagCollectionView:self]; i++) {
|
||||
[_containerView addSubview:[_dataSource tagCollectionView:self tagViewForIndex:i]];
|
||||
}
|
||||
|
||||
// Update tag view frame
|
||||
[self setNeedsLayoutTagViews];
|
||||
[self layoutTagViews];
|
||||
}
|
||||
|
||||
- (NSInteger)indexOfTagAt:(CGPoint)point {
|
||||
// We expect the point to be a point wrt to the TTGTagCollectionView.
|
||||
// so convert this point first to a point wrt to the container view.
|
||||
CGPoint convertedPoint = [self convertPoint:point toView:_containerView];
|
||||
for (NSUInteger i = 0; i < [self.dataSource numberOfTagsInTagCollectionView:self]; i++) {
|
||||
UIView *tagView = [self.dataSource tagCollectionView:self tagViewForIndex:i];
|
||||
if (CGRectContainsPoint(tagView.frame, convertedPoint) && !tagView.isHidden) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
#pragma mark - Gesture
|
||||
|
||||
- (void)onTapGesture:(UITapGestureRecognizer *)tapGesture {
|
||||
CGPoint tapPointInCollectionView = [tapGesture locationInView:self];
|
||||
|
||||
if (![self.dataSource respondsToSelector:@selector(numberOfTagsInTagCollectionView:)] ||
|
||||
![self.dataSource respondsToSelector:@selector(tagCollectionView:tagViewForIndex:)] ||
|
||||
![self.delegate respondsToSelector:@selector(tagCollectionView:didSelectTag:atIndex:)]) {
|
||||
if (_onTapBlankArea) {
|
||||
_onTapBlankArea(tapPointInCollectionView);
|
||||
}
|
||||
if (_onTapAllArea) {
|
||||
_onTapAllArea(tapPointInCollectionView);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CGPoint tapPointInScrollView = [tapGesture locationInView:_containerView];
|
||||
BOOL hasLocatedToTag = NO;
|
||||
|
||||
for (NSUInteger i = 0; i < [self.dataSource numberOfTagsInTagCollectionView:self]; i++) {
|
||||
UIView *tagView = [self.dataSource tagCollectionView:self tagViewForIndex:i];
|
||||
if (CGRectContainsPoint(tagView.frame, tapPointInScrollView) && !tagView.isHidden) {
|
||||
hasLocatedToTag = YES;
|
||||
if ([self.delegate respondsToSelector:@selector(tagCollectionView:shouldSelectTag:atIndex:)]) {
|
||||
if ([self.delegate tagCollectionView:self shouldSelectTag:tagView atIndex:i]) {
|
||||
[self.delegate tagCollectionView:self didSelectTag:tagView atIndex:i];
|
||||
}
|
||||
} else {
|
||||
[self.delegate tagCollectionView:self didSelectTag:tagView atIndex:i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasLocatedToTag) {
|
||||
if (_onTapBlankArea) {
|
||||
_onTapBlankArea(tapPointInCollectionView);
|
||||
}
|
||||
}
|
||||
if (_onTapAllArea) {
|
||||
_onTapAllArea(tapPointInCollectionView);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Override
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
if (!CGRectEqualToRect(_scrollView.frame, self.bounds)) {
|
||||
_scrollView.frame = self.bounds;
|
||||
[self setNeedsLayoutTagViews];
|
||||
[self layoutTagViews];
|
||||
_containerView.frame = (CGRect){CGPointZero, _scrollView.contentSize};
|
||||
}
|
||||
[self layoutTagViews];
|
||||
}
|
||||
|
||||
- (CGSize)intrinsicContentSize {
|
||||
return _scrollView.contentSize;
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
return self.contentSize;
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)layoutTagViews {
|
||||
if (!_needsLayoutTagViews || ![self isDelegateAndDataSourceValid]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_scrollDirection == TTGTagCollectionScrollDirectionVertical) {
|
||||
[self layoutTagViewsForVerticalDirection];
|
||||
} else {
|
||||
[self layoutTagViewsForHorizontalDirection];
|
||||
}
|
||||
|
||||
_needsLayoutTagViews = NO;
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
|
||||
- (void)layoutTagViewsForVerticalDirection {
|
||||
NSUInteger count = [_dataSource numberOfTagsInTagCollectionView:self];
|
||||
NSUInteger currentLineTagsCount = 0;
|
||||
CGFloat totalWidth = (_manualCalculateHeight && _preferredMaxLayoutWidth > 0) ? _preferredMaxLayoutWidth : CGRectGetWidth(self.bounds);
|
||||
CGFloat maxLineWidth = totalWidth - _contentInset.left - _contentInset.right;
|
||||
CGFloat currentLineX = 0;
|
||||
CGFloat currentLineMaxHeight = 0;
|
||||
|
||||
NSMutableArray <NSNumber *> *eachLineMaxHeightNumbers = [NSMutableArray new];
|
||||
NSMutableArray <NSNumber *> *eachLineWidthNumbers = [NSMutableArray new];
|
||||
NSMutableArray <NSNumber *> *eachLineTagCountNumbers = [NSMutableArray new];
|
||||
|
||||
NSMutableArray <NSArray <NSNumber *> *> *eachLineTagIndexs = [NSMutableArray new];
|
||||
NSMutableArray <NSNumber *> *tmpTagIndexNumbers = [NSMutableArray new];
|
||||
|
||||
// Get each line max height ,width and tag count
|
||||
for (NSUInteger i = 0; i < count; i++) {
|
||||
CGSize tagSize = [_delegate tagCollectionView:self sizeForTagAtIndex:i];
|
||||
|
||||
if (currentLineX + tagSize.width > maxLineWidth && tmpTagIndexNumbers.count > 0) {
|
||||
// New Line
|
||||
[eachLineMaxHeightNumbers addObject:@(currentLineMaxHeight)];
|
||||
[eachLineWidthNumbers addObject:@(currentLineX - _horizontalSpacing)];
|
||||
[eachLineTagCountNumbers addObject:@(currentLineTagsCount)];
|
||||
[eachLineTagIndexs addObject:tmpTagIndexNumbers];
|
||||
tmpTagIndexNumbers = [NSMutableArray new];
|
||||
currentLineTagsCount = 0;
|
||||
currentLineMaxHeight = 0;
|
||||
currentLineX = 0;
|
||||
}
|
||||
|
||||
// Line limit
|
||||
if (_numberOfLines != 0) {
|
||||
UIView *tagView = [_dataSource tagCollectionView:self tagViewForIndex:i];
|
||||
tagView.hidden = eachLineWidthNumbers.count >= _numberOfLines;
|
||||
}
|
||||
|
||||
currentLineX += tagSize.width + _horizontalSpacing;
|
||||
currentLineTagsCount += 1;
|
||||
currentLineMaxHeight = MAX(tagSize.height, currentLineMaxHeight);
|
||||
[tmpTagIndexNumbers addObject:@(i)];
|
||||
}
|
||||
|
||||
// Add last
|
||||
[eachLineMaxHeightNumbers addObject:@(currentLineMaxHeight)];
|
||||
[eachLineWidthNumbers addObject:@(currentLineX - _horizontalSpacing)];
|
||||
[eachLineTagCountNumbers addObject:@(currentLineTagsCount)];
|
||||
[eachLineTagIndexs addObject:tmpTagIndexNumbers];
|
||||
|
||||
// Actual number of lines
|
||||
_actualNumberOfLines = eachLineTagCountNumbers.count;
|
||||
|
||||
// Line limit
|
||||
if (_numberOfLines != 0) {
|
||||
eachLineMaxHeightNumbers = [[eachLineMaxHeightNumbers subarrayWithRange:NSMakeRange(0, MIN(eachLineMaxHeightNumbers.count, _numberOfLines))] mutableCopy];
|
||||
eachLineWidthNumbers = [[eachLineWidthNumbers subarrayWithRange:NSMakeRange(0, MIN(eachLineWidthNumbers.count, _numberOfLines))] mutableCopy];
|
||||
eachLineTagCountNumbers = [[eachLineTagCountNumbers subarrayWithRange:NSMakeRange(0, MIN(eachLineTagCountNumbers.count, _numberOfLines))] mutableCopy];
|
||||
eachLineTagIndexs = [[eachLineTagIndexs subarrayWithRange:NSMakeRange(0, MIN(eachLineTagIndexs.count, _numberOfLines))] mutableCopy];
|
||||
}
|
||||
|
||||
// Prepare
|
||||
[self layoutEachLineTagsWithMaxLineWidth:maxLineWidth
|
||||
numberOfLines:eachLineTagCountNumbers.count
|
||||
eachLineTagIndexs:eachLineTagIndexs
|
||||
eachLineTagCount:eachLineTagCountNumbers
|
||||
eachLineWidth:eachLineWidthNumbers
|
||||
eachLineMaxHeight:eachLineMaxHeightNumbers];
|
||||
}
|
||||
|
||||
- (void)layoutTagViewsForHorizontalDirection {
|
||||
NSInteger count = [_dataSource numberOfTagsInTagCollectionView:self];
|
||||
_numberOfLines = _numberOfLines == 0 ? 1 : _numberOfLines;
|
||||
|
||||
CGFloat maxLineWidth = 0;
|
||||
|
||||
NSMutableArray <NSNumber *> *eachLineMaxHeightNumbers = [NSMutableArray new];
|
||||
NSMutableArray <NSNumber *> *eachLineWidthNumbers = [NSMutableArray new];
|
||||
NSMutableArray <NSNumber *> *eachLineTagCountNumbers = [NSMutableArray new];
|
||||
|
||||
NSMutableArray <NSMutableArray <NSNumber *> *> *eachLineTagIndexs = [NSMutableArray new];
|
||||
|
||||
// Init each line
|
||||
for (NSInteger currentLine = 0; currentLine < _numberOfLines; currentLine++) {
|
||||
[eachLineMaxHeightNumbers addObject:@0];
|
||||
[eachLineWidthNumbers addObject:@0];
|
||||
[eachLineTagCountNumbers addObject:@0];
|
||||
[eachLineTagIndexs addObject:[NSMutableArray new]];
|
||||
}
|
||||
|
||||
// Add tags
|
||||
for (NSUInteger tagIndex = 0; tagIndex < count; tagIndex++) {
|
||||
NSUInteger currentLine = tagIndex % _numberOfLines;
|
||||
|
||||
NSUInteger currentLineTagsCount = eachLineTagCountNumbers[currentLine].unsignedIntegerValue;
|
||||
CGFloat currentLineMaxHeight = eachLineMaxHeightNumbers[currentLine].floatValue;
|
||||
CGFloat currentLineX = eachLineWidthNumbers[currentLine].floatValue;
|
||||
NSMutableArray *currentLineTagIndexNumbers = eachLineTagIndexs[currentLine];
|
||||
|
||||
CGSize tagSize = [_delegate tagCollectionView:self sizeForTagAtIndex:tagIndex];
|
||||
currentLineX += tagSize.width + _horizontalSpacing;
|
||||
currentLineMaxHeight = MAX(tagSize.height, currentLineMaxHeight);
|
||||
currentLineTagsCount += 1;
|
||||
[currentLineTagIndexNumbers addObject:@(tagIndex)];
|
||||
|
||||
eachLineTagCountNumbers[currentLine] = @(currentLineTagsCount);
|
||||
eachLineMaxHeightNumbers[currentLine] = @(currentLineMaxHeight);
|
||||
eachLineWidthNumbers[currentLine] = @(currentLineX);
|
||||
eachLineTagIndexs[currentLine] = currentLineTagIndexNumbers;
|
||||
}
|
||||
|
||||
// Remove extra space
|
||||
for (NSInteger currentLine = 0; currentLine < _numberOfLines; currentLine++) {
|
||||
CGFloat currentLineWidth = eachLineWidthNumbers[currentLine].floatValue;
|
||||
currentLineWidth -= _horizontalSpacing;
|
||||
eachLineWidthNumbers[currentLine] = @(currentLineWidth);
|
||||
|
||||
maxLineWidth = MAX(currentLineWidth, maxLineWidth);
|
||||
}
|
||||
|
||||
// Prepare
|
||||
[self layoutEachLineTagsWithMaxLineWidth:maxLineWidth
|
||||
numberOfLines:eachLineTagCountNumbers.count
|
||||
eachLineTagIndexs:eachLineTagIndexs
|
||||
eachLineTagCount:eachLineTagCountNumbers
|
||||
eachLineWidth:eachLineWidthNumbers
|
||||
eachLineMaxHeight:eachLineMaxHeightNumbers];
|
||||
}
|
||||
|
||||
- (void)layoutEachLineTagsWithMaxLineWidth:(CGFloat)maxLineWidth
|
||||
numberOfLines:(NSUInteger)numberOfLines
|
||||
eachLineTagIndexs:(NSArray <NSArray <NSNumber *> *> *)eachLineTagIndexs
|
||||
eachLineTagCount:(NSArray <NSNumber *> *)eachLineTagCount
|
||||
eachLineWidth:(NSArray <NSNumber *> *)eachLineWidth
|
||||
eachLineMaxHeight:(NSArray <NSNumber *> *)eachLineMaxHeight {
|
||||
|
||||
CGFloat currentYBase = _contentInset.top;
|
||||
|
||||
for (NSUInteger currentLine = 0; currentLine < numberOfLines; currentLine++) {
|
||||
CGFloat currentLineMaxHeight = eachLineMaxHeight[currentLine].floatValue;
|
||||
CGFloat currentLineWidth = eachLineWidth[currentLine].floatValue;
|
||||
CGFloat currentLineTagsCount = eachLineTagCount[currentLine].unsignedIntegerValue;
|
||||
|
||||
// Alignment x offset
|
||||
CGFloat currentLineXOffset = 0;
|
||||
CGFloat currentLineAdditionWidth = 0;
|
||||
CGFloat acturalHorizontalSpacing = _horizontalSpacing;
|
||||
__block CGFloat currentLineX = 0;
|
||||
|
||||
switch (_alignment) {
|
||||
case TTGTagCollectionAlignmentLeft:
|
||||
currentLineXOffset = _contentInset.left;
|
||||
break;
|
||||
case TTGTagCollectionAlignmentCenter:
|
||||
currentLineXOffset = (maxLineWidth - currentLineWidth) / 2 + _contentInset.left;
|
||||
break;
|
||||
case TTGTagCollectionAlignmentRight:
|
||||
currentLineXOffset = maxLineWidth - currentLineWidth + _contentInset.left;
|
||||
break;
|
||||
case TTGTagCollectionAlignmentFillByExpandingSpace:
|
||||
currentLineXOffset = _contentInset.left;
|
||||
acturalHorizontalSpacing = _horizontalSpacing +
|
||||
(maxLineWidth - currentLineWidth) / (CGFloat)(currentLineTagsCount - 1);
|
||||
currentLineWidth = maxLineWidth;
|
||||
break;
|
||||
case TTGTagCollectionAlignmentFillByExpandingWidth:
|
||||
case TTGTagCollectionAlignmentFillByExpandingWidthExceptLastLine:
|
||||
currentLineXOffset = _contentInset.left;
|
||||
currentLineAdditionWidth = (maxLineWidth - currentLineWidth) / (CGFloat)currentLineTagsCount;
|
||||
currentLineWidth = maxLineWidth;
|
||||
|
||||
if (_alignment == TTGTagCollectionAlignmentFillByExpandingWidthExceptLastLine &&
|
||||
currentLine == numberOfLines - 1 &&
|
||||
numberOfLines != 1) {
|
||||
// Reset last line width for TTGTagCollectionAlignmentFillByExpandingWidthExceptLastLine
|
||||
currentLineAdditionWidth = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Current line
|
||||
[eachLineTagIndexs[currentLine] enumerateObjectsUsingBlock:^(NSNumber * _Nonnull tagIndexNumber, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
NSUInteger tagIndex = tagIndexNumber.unsignedIntegerValue;
|
||||
|
||||
UIView *tagView = [self.dataSource tagCollectionView:self tagViewForIndex:tagIndex];
|
||||
CGSize tagSize = [self.delegate tagCollectionView:self sizeForTagAtIndex:tagIndex];
|
||||
|
||||
CGPoint origin;
|
||||
origin.x = currentLineXOffset + currentLineX;
|
||||
origin.y = currentYBase + (currentLineMaxHeight - tagSize.height) / 2;
|
||||
|
||||
tagSize.width += currentLineAdditionWidth;
|
||||
if (self.scrollDirection == TTGTagCollectionScrollDirectionVertical && tagSize.width > maxLineWidth) {
|
||||
tagSize.width = maxLineWidth;
|
||||
}
|
||||
|
||||
tagView.hidden = NO;
|
||||
tagView.frame = (CGRect){origin, tagSize};
|
||||
|
||||
currentLineX += tagSize.width + acturalHorizontalSpacing;
|
||||
}];
|
||||
|
||||
// Next line
|
||||
currentYBase += currentLineMaxHeight + _verticalSpacing;
|
||||
}
|
||||
|
||||
// Content size
|
||||
maxLineWidth += _contentInset.right + _contentInset.left;
|
||||
CGSize contentSize = CGSizeMake(maxLineWidth, currentYBase - _verticalSpacing + _contentInset.bottom);
|
||||
if (!CGSizeEqualToSize(contentSize, _scrollView.contentSize)) {
|
||||
_scrollView.contentSize = contentSize;
|
||||
_containerView.frame = (CGRect){CGPointZero, contentSize};
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(tagCollectionView:updateContentSize:)]) {
|
||||
[self.delegate tagCollectionView:self updateContentSize:contentSize];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setNeedsLayoutTagViews {
|
||||
_needsLayoutTagViews = YES;
|
||||
}
|
||||
|
||||
#pragma mark - Check delegate and dataSource
|
||||
|
||||
- (BOOL)isDelegateAndDataSourceValid {
|
||||
BOOL isValid = _delegate != nil && _dataSource != nil;
|
||||
isValid = isValid && [_delegate respondsToSelector:@selector(tagCollectionView:sizeForTagAtIndex:)];
|
||||
isValid = isValid && [_dataSource respondsToSelector:@selector(tagCollectionView:tagViewForIndex:)];
|
||||
isValid = isValid && [_dataSource respondsToSelector:@selector(numberOfTagsInTagCollectionView:)];
|
||||
return isValid;
|
||||
}
|
||||
|
||||
#pragma mark - Setter Getter
|
||||
|
||||
- (UIScrollView *)scrollView {
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
- (void)setScrollDirection:(TTGTagCollectionScrollDirection)scrollDirection {
|
||||
_scrollDirection = scrollDirection;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setAlignment:(TTGTagCollectionAlignment)alignment {
|
||||
_alignment = alignment;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setNumberOfLines:(NSUInteger)numberOfLines {
|
||||
_numberOfLines = numberOfLines;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (NSUInteger)actualNumberOfLines {
|
||||
if (_scrollDirection == TTGTagCollectionScrollDirectionHorizontal) {
|
||||
return _numberOfLines;
|
||||
} else {
|
||||
return _actualNumberOfLines;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHorizontalSpacing:(CGFloat)horizontalSpacing {
|
||||
_horizontalSpacing = horizontalSpacing;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setVerticalSpacing:(CGFloat)verticalSpacing {
|
||||
_verticalSpacing = verticalSpacing;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setContentInset:(UIEdgeInsets)contentInset {
|
||||
_contentInset = contentInset;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (CGSize)contentSize {
|
||||
[self layoutTagViews];
|
||||
return _scrollView.contentSize;
|
||||
}
|
||||
|
||||
- (void)setManualCalculateHeight:(BOOL)manualCalculateHeight {
|
||||
_manualCalculateHeight = manualCalculateHeight;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setPreferredMaxLayoutWidth:(CGFloat)preferredMaxLayoutWidth {
|
||||
_preferredMaxLayoutWidth = preferredMaxLayoutWidth;
|
||||
[self setNeedsLayoutTagViews];
|
||||
}
|
||||
|
||||
- (void)setShowsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator {
|
||||
_scrollView.showsHorizontalScrollIndicator = showsHorizontalScrollIndicator;
|
||||
}
|
||||
|
||||
- (BOOL)showsHorizontalScrollIndicator {
|
||||
return _scrollView.showsHorizontalScrollIndicator;
|
||||
}
|
||||
|
||||
- (void)setShowsVerticalScrollIndicator:(BOOL)showsVerticalScrollIndicator {
|
||||
_scrollView.showsVerticalScrollIndicator = showsVerticalScrollIndicator;
|
||||
}
|
||||
|
||||
- (BOOL)showsVerticalScrollIndicator {
|
||||
return _scrollView.showsVerticalScrollIndicator;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
//
|
||||
// TTGTextTag.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "TTGTextTagStyle.h"
|
||||
#import "TTGTextTagContent.h"
|
||||
|
||||
@interface TTGTextTag : NSObject <NSCopying>
|
||||
|
||||
/// ID
|
||||
@property (nonatomic, assign, readonly) NSUInteger tagId; // Auto increase. The only identifier and main key for a tag
|
||||
|
||||
/// Attachment object. You can use this to bind any object you want to each tag.
|
||||
@property (nonatomic, strong) id _Nullable attachment;
|
||||
|
||||
/// Normal state content and style
|
||||
@property (nonatomic, copy) TTGTextTagContent * _Nonnull content;
|
||||
@property (nonatomic, copy) TTGTextTagStyle * _Nonnull style;
|
||||
|
||||
/// Selected state content and style
|
||||
@property (nonatomic, copy) TTGTextTagContent * _Nullable selectedContent;
|
||||
@property (nonatomic, copy) TTGTextTagStyle * _Nullable selectedStyle;
|
||||
|
||||
/// Selection state
|
||||
@property (nonatomic, assign) BOOL selected;
|
||||
|
||||
/// Init
|
||||
|
||||
/**
|
||||
Init with single content and style
|
||||
|
||||
@param content content for both normal and selection state.
|
||||
@param style style for both normal and selection state.
|
||||
@return instance
|
||||
*/
|
||||
- (instancetype _Nonnull)initWithContent:(TTGTextTagContent *_Nonnull)content
|
||||
style:(TTGTextTagStyle *_Nonnull)style;
|
||||
|
||||
/**
|
||||
Init with different content and style
|
||||
|
||||
@param content content for normal state
|
||||
@param style style for normal state
|
||||
@param selectedContent content for selection state
|
||||
@param selectedStyle style for selection state
|
||||
@return instance
|
||||
*/
|
||||
- (instancetype _Nonnull)initWithContent:(TTGTextTagContent *_Nonnull)content
|
||||
style:(TTGTextTagStyle *_Nonnull)style
|
||||
selectedContent:(TTGTextTagContent *_Nullable)selectedContent
|
||||
selectedStyle:(TTGTextTagStyle *_Nullable)selectedStyle;
|
||||
|
||||
/**
|
||||
Tag with single content and style
|
||||
|
||||
@param content content for both normal and selection state.
|
||||
@param style style for both normal and selection state.
|
||||
@return instance
|
||||
*/
|
||||
+ (instancetype _Nonnull)tagWithContent:(TTGTextTagContent *_Nonnull)content
|
||||
style:(TTGTextTagStyle *_Nonnull)style;
|
||||
|
||||
/**
|
||||
Tag with different content and style
|
||||
|
||||
@param content content for normal state
|
||||
@param style style for normal state
|
||||
@param selectedContent content for selection state
|
||||
@param selectedStyle style for selection state
|
||||
@return instance
|
||||
*/
|
||||
+ (instancetype _Nonnull)tagWithContent:(TTGTextTagContent *_Nonnull)content
|
||||
style:(TTGTextTagStyle *_Nonnull)style
|
||||
selectedContent:(TTGTextTagContent *_Nullable)selectedContent
|
||||
selectedStyle:(TTGTextTagStyle *_Nullable)selectedStyle;
|
||||
|
||||
/**
|
||||
Get current state rightful content
|
||||
|
||||
@return content
|
||||
*/
|
||||
- (TTGTextTagContent *_Nonnull)getRightfulContent;
|
||||
|
||||
/**
|
||||
Get current state rightful style
|
||||
|
||||
@return style
|
||||
*/
|
||||
- (TTGTextTagStyle *_Nonnull)getRightfulStyle;
|
||||
|
||||
/// Base system methods
|
||||
- (BOOL)isEqual:(id _Nullable)other;
|
||||
- (BOOL)isEqualToTag:(TTGTextTag *_Nullable)tag;
|
||||
- (NSUInteger)hash;
|
||||
|
||||
/// Copy
|
||||
- (id _Nonnull)copyWithZone:(NSZone *_Nullable)zone;
|
||||
|
||||
@end
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
//
|
||||
// TTGTextTag.m
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTag.h"
|
||||
#import "TTGTextTagStringContent.h"
|
||||
|
||||
static NSUInteger TTGTextTagAutoIncreasedId = 0;
|
||||
|
||||
@implementation TTGTextTag
|
||||
|
||||
- (instancetype)initWithContent:(TTGTextTagContent *)content
|
||||
style:(TTGTextTagStyle *)style {
|
||||
self = [self init];
|
||||
if (self) {
|
||||
self.content = content;
|
||||
self.style = style;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithContent:(TTGTextTagContent *)content
|
||||
style:(TTGTextTagStyle *)style
|
||||
selectedContent:(TTGTextTagContent *)selectedContent
|
||||
selectedStyle:(TTGTextTagStyle *)selectedStyle {
|
||||
self = [self init];
|
||||
if (self) {
|
||||
self.content = content;
|
||||
self.style = style;
|
||||
self.selectedContent = selectedContent;
|
||||
self.selectedStyle = selectedStyle;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)tagWithContent:(TTGTextTagContent *)content
|
||||
style:(TTGTextTagStyle *)style {
|
||||
return [[self alloc] initWithContent:content style:style];
|
||||
}
|
||||
|
||||
+ (instancetype)tagWithContent:(TTGTextTagContent *)content
|
||||
style:(TTGTextTagStyle *)style
|
||||
selectedContent:(TTGTextTagContent *)selectedContent
|
||||
selectedStyle:(TTGTextTagStyle *)selectedStyle {
|
||||
return [[self alloc] initWithContent:content
|
||||
style:style
|
||||
selectedContent:selectedContent
|
||||
selectedStyle:selectedStyle];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_tagId = TTGTextTagAutoIncreasedId++;
|
||||
_attachment = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (TTGTextTagContent *)selectedContent {
|
||||
if (_selectedContent == nil) {
|
||||
_selectedContent = [_content copy];
|
||||
}
|
||||
return _selectedContent;
|
||||
}
|
||||
|
||||
- (TTGTextTagStyle *)selectedStyle {
|
||||
if (_selectedStyle == nil) {
|
||||
_selectedStyle = [_style copy];
|
||||
}
|
||||
return _selectedStyle;
|
||||
}
|
||||
|
||||
- (TTGTextTagContent *)getRightfulContent {
|
||||
return _selected ? self.selectedContent : self.content;
|
||||
}
|
||||
|
||||
- (TTGTextTagStyle *)getRightfulStyle {
|
||||
return _selected ? self.selectedStyle : self.style;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)other {
|
||||
if (other == self)
|
||||
return YES;
|
||||
if (!other || ![[other class] isEqual:[self class]])
|
||||
return NO;
|
||||
|
||||
return [self isEqualToTag:other];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToTag:(TTGTextTag *)tag {
|
||||
if (self == tag)
|
||||
return YES;
|
||||
if (tag == nil)
|
||||
return NO;
|
||||
if (self.tagId != tag.tagId)
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return (NSUInteger)self.tagId;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(nullable NSZone *)zone {
|
||||
TTGTextTag *copy = (TTGTextTag *)[[[self class] allocWithZone:zone] init];
|
||||
if (copy != nil) {
|
||||
copy->_tagId = TTGTextTagAutoIncreasedId++;
|
||||
copy.attachment = self.attachment;
|
||||
copy.content = self.content;
|
||||
copy.style = self.style;
|
||||
copy.selected = self.selected;
|
||||
copy.selectedContent = self.selectedContent;
|
||||
copy.selectedStyle = self.selectedStyle;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
//
|
||||
// TTGTextTagAttributedStringContent.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagContent.h"
|
||||
|
||||
/**
|
||||
Rich text content for tag
|
||||
*/
|
||||
@interface TTGTextTagAttributedStringContent : TTGTextTagContent
|
||||
|
||||
/// Attributed text
|
||||
@property (nonatomic, copy) NSAttributedString * _Nonnull attributedText;
|
||||
|
||||
/// Init with rich text
|
||||
- (instancetype _Nonnull)initWithAttributedText:(NSAttributedString *_Nonnull)attributedText;
|
||||
|
||||
/// Content with rich text
|
||||
+ (instancetype _Nonnull)contentWithAttributedText:(NSAttributedString *_Nonnull)attributedText;
|
||||
|
||||
/// Base system methods
|
||||
- (id _Nonnull)copyWithZone:(NSZone *_Nullable)zone;
|
||||
- (NSString *_Nonnull)description;
|
||||
|
||||
@end
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
//
|
||||
// TTGTextTagAttributedStringContent.m
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagAttributedStringContent.h"
|
||||
|
||||
@implementation TTGTextTagAttributedStringContent
|
||||
|
||||
- (instancetype)initWithAttributedText:(NSAttributedString *)attributedText {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.attributedText = attributedText;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)contentWithAttributedText:(NSAttributedString *)attributedText {
|
||||
return [[self alloc] initWithAttributedText:attributedText];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)getContentAttributedString {
|
||||
return self.attributedText;
|
||||
}
|
||||
|
||||
- (NSAttributedString *)attributedText {
|
||||
return _attributedText ?: [NSAttributedString new];
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
TTGTextTagAttributedStringContent *copy = (TTGTextTagAttributedStringContent *)[super copyWithZone:zone];
|
||||
if (copy != nil) {
|
||||
copy.attributedText = self.attributedText;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: ", NSStringFromClass([self class])];
|
||||
[description appendFormat:@"self.attributedText=%@", self.attributedText];
|
||||
[description appendString:@">"];
|
||||
return description;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
//
|
||||
// TTGTextTagCollectionView.h
|
||||
// Pods
|
||||
//
|
||||
// Created by zekunyan on 15/12/26.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "TTGTagCollectionView.h"
|
||||
#import "TTGTextTag.h"
|
||||
#import "TTGTextTagStringContent.h"
|
||||
#import "TTGTextTagAttributedStringContent.h"
|
||||
|
||||
/**
|
||||
Highly useful for text tag display.
|
||||
*/
|
||||
|
||||
@class TTGTextTagCollectionView;
|
||||
|
||||
/// Delegate
|
||||
@protocol TTGTextTagCollectionViewDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
- (BOOL)textTagCollectionView:(TTGTextTagCollectionView *)textTagCollectionView
|
||||
canTapTag:(TTGTextTag *)tag
|
||||
atIndex:(NSUInteger)index;
|
||||
|
||||
- (void)textTagCollectionView:(TTGTextTagCollectionView *)textTagCollectionView
|
||||
didTapTag:(TTGTextTag *)tag
|
||||
atIndex:(NSUInteger)index;
|
||||
|
||||
- (void)textTagCollectionView:(TTGTextTagCollectionView *)textTagCollectionView
|
||||
updateContentSize:(CGSize)contentSize;
|
||||
@end
|
||||
|
||||
/// Main Class
|
||||
@interface TTGTextTagCollectionView : UIView
|
||||
/// Delegate
|
||||
@property (weak, nonatomic) id <TTGTextTagCollectionViewDelegate> delegate;
|
||||
|
||||
/// Inside scrollView
|
||||
@property (nonatomic, strong, readonly) UIScrollView *scrollView;
|
||||
|
||||
/// Define if the tag can be selected.
|
||||
@property (assign, nonatomic) BOOL enableTagSelection;
|
||||
|
||||
/// Tags scroll direction, default is vertical.
|
||||
@property (nonatomic, assign) TTGTagCollectionScrollDirection scrollDirection;
|
||||
|
||||
/// Tags layout alignment, default is left.
|
||||
@property (nonatomic, assign) TTGTagCollectionAlignment alignment;
|
||||
|
||||
/// Number of lines. 0 means no limit, default is 0 for vertical and 1 for horizontal.
|
||||
@property (nonatomic, assign) NSUInteger numberOfLines;
|
||||
/// The real number of lines ignoring the numberOfLines value
|
||||
@property (nonatomic, assign, readonly) NSUInteger actualNumberOfLines;
|
||||
|
||||
/// Tag selection limit, default is 0, means no limit
|
||||
@property (nonatomic, assign) NSUInteger selectionLimit;
|
||||
|
||||
/// Horizontal and vertical space between tags, default is 4.
|
||||
@property (assign, nonatomic) CGFloat horizontalSpacing;
|
||||
@property (assign, nonatomic) CGFloat verticalSpacing;
|
||||
|
||||
/// Content inset, like padding, default is UIEdgeInsetsMake(2, 2, 2, 2).
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
|
||||
/// The true tags content size, readonly
|
||||
@property (nonatomic, assign, readonly) CGSize contentSize;
|
||||
|
||||
/// Manual content height
|
||||
/// Default = NO, set will update content
|
||||
@property (nonatomic, assign) BOOL manualCalculateHeight;
|
||||
/// Default = 0, set will update content
|
||||
@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;
|
||||
|
||||
/// Scroll indicator
|
||||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
||||
|
||||
/// Tap blank area callback
|
||||
@property (nonatomic, copy) void (^onTapBlankArea)(CGPoint location);
|
||||
/// Tap all area callback
|
||||
@property (nonatomic, copy) void (^onTapAllArea)(CGPoint location);
|
||||
|
||||
/// Reload
|
||||
- (void)reload;
|
||||
|
||||
/// Add
|
||||
- (void)addTag:(TTGTextTag *)tag;
|
||||
- (void)addTags:(NSArray <TTGTextTag *> *)tags;
|
||||
|
||||
/// Insert
|
||||
- (void)insertTag:(TTGTextTag *)tag atIndex:(NSUInteger)index;
|
||||
- (void)insertTags:(NSArray <TTGTextTag *> *)tags atIndex:(NSUInteger)index;
|
||||
|
||||
/// Update
|
||||
- (void)updateTagAtIndex:(NSUInteger)index selected:(BOOL)selected;
|
||||
- (void)updateTagAtIndex:(NSUInteger)index withNewTag:(TTGTextTag *)tag;
|
||||
|
||||
/// Remove
|
||||
- (void)removeTag:(TTGTextTag *)tag;
|
||||
- (void)removeTagById:(NSUInteger)tagId;
|
||||
- (void)removeTagAtIndex:(NSUInteger)index;
|
||||
- (void)removeAllTags;
|
||||
|
||||
/// Get tag
|
||||
- (TTGTextTag *)getTagAtIndex:(NSUInteger)index;
|
||||
- (NSArray <TTGTextTag *> *)getTagsInRange:(NSRange)range;
|
||||
|
||||
/// Get all
|
||||
- (NSArray <TTGTextTag *> *)allTags;
|
||||
- (NSArray <TTGTextTag *> *)allSelectedTags;
|
||||
- (NSArray <TTGTextTag *> *)allNotSelectedTags;
|
||||
|
||||
/**
|
||||
* Returns the index of the tag located at the specified point.
|
||||
* If item at point is not found, returns NSNotFound.
|
||||
*/
|
||||
- (NSInteger)indexOfTagAtPoint:(CGPoint)point;
|
||||
|
||||
@end
|
||||
|
|
@ -1,639 +0,0 @@
|
|||
//
|
||||
// TTGTextTagCollectionView.m
|
||||
// Pods
|
||||
//
|
||||
// Created by zekunyan on 15/12/26.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagCollectionView.h"
|
||||
|
||||
#pragma mark - TTGTextTagGradientLabel
|
||||
|
||||
@interface TTGTextTagGradientLabel : UILabel
|
||||
@end
|
||||
|
||||
@implementation TTGTextTagGradientLabel
|
||||
+ (Class)layerClass {
|
||||
return [CAGradientLayer class];
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - TTGTextTagLabel
|
||||
|
||||
@interface TTGTextTagComponentView : UIView
|
||||
@property (nonatomic, strong) TTGTextTag *config;
|
||||
@property (nonatomic, strong) TTGTextTagGradientLabel *label;
|
||||
@property (nonatomic, strong) CAShapeLayer *borderLayer;
|
||||
|
||||
- (BOOL)isEqual:(id)other;
|
||||
|
||||
- (BOOL)isEqualToComponentView:(TTGTextTagComponentView *)label;
|
||||
|
||||
- (NSUInteger)hash;
|
||||
@end
|
||||
|
||||
@implementation TTGTextTagComponentView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
_label = [[TTGTextTagGradientLabel alloc] initWithFrame:self.bounds];
|
||||
_label.textAlignment = NSTextAlignmentCenter;
|
||||
_label.userInteractionEnabled = YES;
|
||||
[self addSubview:_label];
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
// Update frame
|
||||
_label.frame = self.bounds;
|
||||
|
||||
// Get new path
|
||||
UIBezierPath *path = [self getNewPath];
|
||||
// Mask
|
||||
[self updateMaskWithPath:path];
|
||||
// Border
|
||||
[self updateBorderWithPath:path];
|
||||
// Shadow
|
||||
[self updateShadowWithPath:path];
|
||||
}
|
||||
|
||||
#pragma mark - intrinsicContentSize
|
||||
|
||||
- (CGSize)intrinsicContentSize {
|
||||
return _label.intrinsicContentSize;
|
||||
}
|
||||
|
||||
#pragma mark - Apply config
|
||||
|
||||
- (void)updateContent {
|
||||
// Content
|
||||
_label.attributedText = _config.getRightfulContent.getContentAttributedString;
|
||||
}
|
||||
|
||||
- (void)updateContentStyle {
|
||||
// Normal background
|
||||
_label.backgroundColor = _config.getRightfulStyle.backgroundColor;
|
||||
|
||||
// Text alignment
|
||||
_label.textAlignment = _config.getRightfulStyle.textAlignment;
|
||||
|
||||
// Gradient background
|
||||
if (_config.getRightfulStyle.enableGradientBackground) {
|
||||
_label.backgroundColor = [UIColor clearColor];
|
||||
((CAGradientLayer *)_label.layer).colors = @[(id)_config.getRightfulStyle.gradientBackgroundStartColor.CGColor,
|
||||
(id)_config.getRightfulStyle.gradientBackgroundEndColor.CGColor];
|
||||
((CAGradientLayer *)_label.layer).startPoint = _config.getRightfulStyle.gradientBackgroundStartPoint;
|
||||
((CAGradientLayer *)_label.layer).endPoint = _config.getRightfulStyle.gradientBackgroundEndPoint;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateFrameWithMaxSize:(CGSize)maxSize {
|
||||
[_label sizeToFit];
|
||||
|
||||
CGSize finalSize = _label.frame.size;
|
||||
|
||||
finalSize.width += _config.getRightfulStyle.extraSpace.width;
|
||||
finalSize.height += _config.getRightfulStyle.extraSpace.height;
|
||||
|
||||
if (_config.getRightfulStyle.maxWidth > 0 && finalSize.width > _config.getRightfulStyle.maxWidth) {
|
||||
finalSize.width = _config.getRightfulStyle.maxWidth;
|
||||
}
|
||||
if (_config.getRightfulStyle.minWidth > 0 && finalSize.width < _config.getRightfulStyle.minWidth) {
|
||||
finalSize.width = _config.getRightfulStyle.minWidth;
|
||||
}
|
||||
if (_config.getRightfulStyle.exactWidth > 0) {
|
||||
finalSize.width = _config.getRightfulStyle.exactWidth;
|
||||
}
|
||||
if (_config.getRightfulStyle.exactHeight > 0) {
|
||||
finalSize.height = _config.getRightfulStyle.exactHeight;
|
||||
}
|
||||
|
||||
if (maxSize.width > 0) {
|
||||
finalSize.width = MIN(maxSize.width, finalSize.width);
|
||||
}
|
||||
if (maxSize.height > 0) {
|
||||
finalSize.height = MIN(maxSize.height, finalSize.height);
|
||||
}
|
||||
|
||||
CGRect frame = self.frame;
|
||||
frame.size = finalSize;
|
||||
self.frame = frame;
|
||||
_label.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)updateShadowWithPath:(UIBezierPath *)path {
|
||||
self.layer.shadowColor = _config.getRightfulStyle.shadowColor.CGColor;
|
||||
self.layer.shadowOffset = _config.getRightfulStyle.shadowOffset;
|
||||
self.layer.shadowRadius = _config.getRightfulStyle.shadowRadius;
|
||||
self.layer.shadowOpacity = (float)_config.getRightfulStyle.shadowOpacity;
|
||||
self.layer.shadowPath = path.CGPath;
|
||||
self.layer.shouldRasterize = YES;
|
||||
[self.layer setRasterizationScale:[[UIScreen mainScreen] scale]];
|
||||
}
|
||||
|
||||
- (void)updateMaskWithPath:(UIBezierPath *)path {
|
||||
CAShapeLayer *maskLayer = [CAShapeLayer layer];
|
||||
maskLayer.frame = self.bounds;
|
||||
maskLayer.path = path.CGPath;
|
||||
_label.layer.mask = maskLayer;
|
||||
}
|
||||
|
||||
- (void)updateBorderWithPath:(UIBezierPath *)path {
|
||||
if (!_borderLayer) {
|
||||
_borderLayer = [CAShapeLayer new];
|
||||
}
|
||||
[_borderLayer removeFromSuperlayer];
|
||||
_borderLayer.frame = self.bounds;
|
||||
_borderLayer.path = path.CGPath;
|
||||
_borderLayer.fillColor = nil;
|
||||
_borderLayer.opacity = 1;
|
||||
_borderLayer.lineWidth = _config.getRightfulStyle.borderWidth;
|
||||
_borderLayer.strokeColor = _config.getRightfulStyle.borderColor.CGColor;
|
||||
_borderLayer.lineCap = kCALineCapRound;
|
||||
_borderLayer.lineJoin = kCALineJoinRound;
|
||||
[self.layer addSublayer:_borderLayer];
|
||||
}
|
||||
|
||||
- (UIBezierPath *)getNewPath {
|
||||
// Round corner
|
||||
UIRectCorner corners = (UIRectCorner)-1;
|
||||
if (_config.getRightfulStyle.cornerTopLeft) {
|
||||
corners = UIRectCornerTopLeft;
|
||||
}
|
||||
if (_config.getRightfulStyle.cornerTopRight) {
|
||||
if (corners == -1) {
|
||||
corners = UIRectCornerTopRight;
|
||||
} else {
|
||||
corners = corners | UIRectCornerTopRight;
|
||||
}
|
||||
}
|
||||
if (_config.getRightfulStyle.cornerBottomLeft) {
|
||||
if (corners == -1) {
|
||||
corners = UIRectCornerBottomLeft;
|
||||
} else {
|
||||
corners = corners | UIRectCornerBottomLeft;
|
||||
}
|
||||
}
|
||||
if (_config.getRightfulStyle.cornerBottomRight) {
|
||||
if (corners == -1) {
|
||||
corners = UIRectCornerBottomRight;
|
||||
} else {
|
||||
corners = corners | UIRectCornerBottomRight;
|
||||
}
|
||||
}
|
||||
|
||||
// Corner radius
|
||||
CGFloat currentCornerRadius = _config.getRightfulStyle.cornerRadius;
|
||||
|
||||
// Path
|
||||
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
|
||||
byRoundingCorners:corners
|
||||
cornerRadii:CGSizeMake(currentCornerRadius, currentCornerRadius)];
|
||||
return path;
|
||||
}
|
||||
|
||||
#pragma mark - Base
|
||||
|
||||
- (BOOL)isEqual:(id)other {
|
||||
if (other == self)
|
||||
return YES;
|
||||
if (!other || ![[other class] isEqual:[self class]])
|
||||
return NO;
|
||||
return [self isEqualToComponentView:other];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToComponentView:(TTGTextTagComponentView *)label {
|
||||
if (self == label)
|
||||
return YES;
|
||||
if (label == nil)
|
||||
return NO;
|
||||
if (self.config != label.config && ![self.config isEqualToTag:label.config])
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return [self.config hash];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - TTGTextTagCollectionView
|
||||
|
||||
@interface TTGTextTagCollectionView () <TTGTagCollectionViewDataSource, TTGTagCollectionViewDelegate>
|
||||
@property (strong, atomic) NSMutableArray <TTGTextTagComponentView *> *tagLabels;
|
||||
@property (strong, nonatomic) TTGTagCollectionView *tagCollectionView;
|
||||
@end
|
||||
|
||||
@implementation TTGTextTagCollectionView
|
||||
|
||||
#pragma mark - Init
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
if (_tagCollectionView) {
|
||||
return;
|
||||
}
|
||||
|
||||
_enableTagSelection = YES;
|
||||
_tagLabels = [NSMutableArray new];
|
||||
|
||||
_tagCollectionView = [[TTGTagCollectionView alloc] initWithFrame:self.bounds];
|
||||
_tagCollectionView.delegate = self;
|
||||
_tagCollectionView.dataSource = self;
|
||||
_tagCollectionView.horizontalSpacing = 8;
|
||||
_tagCollectionView.verticalSpacing = 8;
|
||||
[self addSubview:_tagCollectionView];
|
||||
}
|
||||
|
||||
#pragma mark - Override
|
||||
|
||||
- (CGSize)intrinsicContentSize {
|
||||
return [_tagCollectionView intrinsicContentSize];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
if (!CGRectEqualToRect(_tagCollectionView.frame, self.bounds)) {
|
||||
[self updateAllLabelStyleAndFrame];
|
||||
_tagCollectionView.frame = self.bounds;
|
||||
[_tagCollectionView setNeedsLayout];
|
||||
[_tagCollectionView layoutIfNeeded];
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
return self.contentSize;
|
||||
}
|
||||
|
||||
#pragma mark - Public methods
|
||||
|
||||
- (void)reload {
|
||||
[self updateAllLabelStyleAndFrame];
|
||||
[_tagCollectionView reload];
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
|
||||
- (void)addTag:(TTGTextTag *)tag {
|
||||
[self insertTag:tag atIndex:_tagLabels.count];
|
||||
}
|
||||
|
||||
- (void)addTags:(NSArray <TTGTextTag *> *)tags {
|
||||
[self insertTags:tags atIndex:_tagLabels.count];
|
||||
}
|
||||
|
||||
- (void)insertTag:(TTGTextTag *)tag atIndex:(NSUInteger)index {
|
||||
if ([tag isKindOfClass:[TTGTextTag class]]) {
|
||||
[self insertTags:@[tag] atIndex:index];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertTags:(NSArray<TTGTextTag *> *)tags atIndex:(NSUInteger)index {
|
||||
if (![tags isKindOfClass:[NSArray class]] || index > _tagLabels.count || tags.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *newTagLabels = [NSMutableArray new];
|
||||
for (TTGTextTag *tag in tags) {
|
||||
if ([tag isKindOfClass:[TTGTextTag class]]) {
|
||||
TTGTextTagComponentView *label = [self newLabelWithConfig:tag];
|
||||
[newTagLabels addObject:label];
|
||||
}
|
||||
}
|
||||
[_tagLabels insertObjects:newTagLabels atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(index, newTagLabels.count)]];
|
||||
}
|
||||
|
||||
- (void)removeTag:(TTGTextTag *)tag {
|
||||
if ([tag isKindOfClass:[TTGTextTag class]]) {
|
||||
[self removeTagById:tag.tagId];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeTagById:(NSUInteger)tagId {
|
||||
TTGTextTagComponentView *labelToRemove = nil;
|
||||
for (TTGTextTagComponentView *label in _tagLabels) {
|
||||
if (label.config.tagId == tagId) {
|
||||
labelToRemove = label;
|
||||
}
|
||||
}
|
||||
if (labelToRemove) {
|
||||
[_tagLabels removeObject:labelToRemove];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeTagAtIndex:(NSUInteger)index {
|
||||
if (index >= _tagLabels.count) {
|
||||
return;
|
||||
}
|
||||
[_tagLabels removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (void)removeAllTags {
|
||||
[_tagLabels removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)updateTagAtIndex:(NSUInteger)index selected:(BOOL)selected {
|
||||
TTGTextTag *tag = [self getTagAtIndex:index];
|
||||
tag.selected = selected;
|
||||
}
|
||||
|
||||
- (void)updateTagAtIndex:(NSUInteger)index withNewTag:(TTGTextTag *)tag {
|
||||
if (index < _tagLabels.count && [tag isKindOfClass:[TTGTextTag class]]) {
|
||||
TTGTextTagComponentView *label = _tagLabels[index];
|
||||
label.config = tag;
|
||||
[label updateContent];
|
||||
}
|
||||
}
|
||||
|
||||
- (TTGTextTag *)getTagAtIndex:(NSUInteger)index {
|
||||
if (index < _tagLabels.count) {
|
||||
return _tagLabels[index].config;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray<TTGTextTag *> *)getTagsInRange:(NSRange)range {
|
||||
if (NSMaxRange(range) <= _tagLabels.count) {
|
||||
NSMutableArray *tags = [NSMutableArray new];
|
||||
for (TTGTextTagComponentView *label in [_tagLabels subarrayWithRange:range]) {
|
||||
if (label.config) {
|
||||
[tags addObject:label.config];
|
||||
}
|
||||
}
|
||||
return [tags copy];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray <TTGTextTag *> *)allTags {
|
||||
NSMutableArray *allTags = [NSMutableArray new];
|
||||
|
||||
for (TTGTextTagComponentView *label in _tagLabels) {
|
||||
if (label.config) {
|
||||
[allTags addObject:label.config];
|
||||
}
|
||||
}
|
||||
|
||||
return [allTags copy];
|
||||
}
|
||||
|
||||
- (NSArray <TTGTextTag *> *)allSelectedTags {
|
||||
NSMutableArray *allTags = [NSMutableArray new];
|
||||
|
||||
for (TTGTextTagComponentView *label in _tagLabels) {
|
||||
if (label.config.selected) {
|
||||
[allTags addObject:label.config];
|
||||
}
|
||||
}
|
||||
|
||||
return [allTags copy];
|
||||
}
|
||||
|
||||
- (NSArray <TTGTextTag *> *)allNotSelectedTags {
|
||||
NSMutableArray *allTags = [NSMutableArray new];
|
||||
|
||||
for (TTGTextTagComponentView *label in _tagLabels) {
|
||||
if (label.config && !label.config.selected) {
|
||||
[allTags addObject:label.config];
|
||||
}
|
||||
}
|
||||
|
||||
return [allTags copy];
|
||||
}
|
||||
|
||||
- (NSInteger)indexOfTagAtPoint:(CGPoint)point {
|
||||
CGPoint convertedPoint = [self convertPoint:point toView:_tagCollectionView];
|
||||
return [_tagCollectionView indexOfTagAt:convertedPoint];
|
||||
}
|
||||
|
||||
#pragma mark - TTGTagCollectionViewDataSource
|
||||
|
||||
- (NSUInteger)numberOfTagsInTagCollectionView:(TTGTagCollectionView *)tagCollectionView {
|
||||
return _tagLabels.count;
|
||||
}
|
||||
|
||||
- (UIView *)tagCollectionView:(TTGTagCollectionView *)tagCollectionView tagViewForIndex:(NSUInteger)index {
|
||||
return _tagLabels[index];
|
||||
}
|
||||
|
||||
#pragma mark - TTGTagCollectionViewDelegate
|
||||
|
||||
- (BOOL)tagCollectionView:(TTGTagCollectionView *)tagCollectionView shouldSelectTag:(UIView *)tagView atIndex:(NSUInteger)index {
|
||||
if (_enableTagSelection) {
|
||||
TTGTextTagComponentView *label = _tagLabels[index];
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(textTagCollectionView:canTapTag:atIndex:)]) {
|
||||
return [self.delegate textTagCollectionView:self canTapTag:label.config atIndex:index];
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tagCollectionView:(TTGTagCollectionView *)tagCollectionView didSelectTag:(UIView *)tagView atIndex:(NSUInteger)index {
|
||||
if (_enableTagSelection) {
|
||||
TTGTextTagComponentView *label = _tagLabels[index];
|
||||
|
||||
|
||||
if (_selectionLimit == 1) {
|
||||
for (TTGTextTagComponentView *tag in _tagLabels) {
|
||||
tag.config.selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
label.config.selected = !label.config.selected;
|
||||
|
||||
if (self.alignment == TTGTagCollectionAlignmentFillByExpandingWidth ||
|
||||
self.alignment == TTGTagCollectionAlignmentFillByExpandingWidthExceptLastLine) {
|
||||
[self reload];
|
||||
} else {
|
||||
[self updateStyleAndFrameForLabel:label];
|
||||
}
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(textTagCollectionView:didTapTag:atIndex:)]) {
|
||||
[_delegate textTagCollectionView:self didTapTag:label.config atIndex:index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CGSize)tagCollectionView:(TTGTagCollectionView *)tagCollectionView sizeForTagAtIndex:(NSUInteger)index {
|
||||
return _tagLabels[index].frame.size;
|
||||
}
|
||||
|
||||
- (void)tagCollectionView:(TTGTagCollectionView *)tagCollectionView updateContentSize:(CGSize)contentSize {
|
||||
if ([_delegate respondsToSelector:@selector(textTagCollectionView:updateContentSize:)]) {
|
||||
[_delegate textTagCollectionView:self updateContentSize:contentSize];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Setter and Getter
|
||||
|
||||
- (UIScrollView *)scrollView {
|
||||
return _tagCollectionView.scrollView;
|
||||
}
|
||||
|
||||
- (CGFloat)horizontalSpacing {
|
||||
return _tagCollectionView.horizontalSpacing;
|
||||
}
|
||||
|
||||
- (void)setHorizontalSpacing:(CGFloat)horizontalSpacing {
|
||||
_tagCollectionView.horizontalSpacing = horizontalSpacing;
|
||||
}
|
||||
|
||||
- (CGFloat)verticalSpacing {
|
||||
return _tagCollectionView.verticalSpacing;
|
||||
}
|
||||
|
||||
- (void)setVerticalSpacing:(CGFloat)verticalSpacing {
|
||||
_tagCollectionView.verticalSpacing = verticalSpacing;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize {
|
||||
return _tagCollectionView.contentSize;
|
||||
}
|
||||
|
||||
- (TTGTagCollectionScrollDirection)scrollDirection {
|
||||
return _tagCollectionView.scrollDirection;
|
||||
}
|
||||
|
||||
- (void)setScrollDirection:(TTGTagCollectionScrollDirection)scrollDirection {
|
||||
_tagCollectionView.scrollDirection = scrollDirection;
|
||||
}
|
||||
|
||||
- (TTGTagCollectionAlignment)alignment {
|
||||
return _tagCollectionView.alignment;
|
||||
}
|
||||
|
||||
- (void)setAlignment:(TTGTagCollectionAlignment)alignment {
|
||||
_tagCollectionView.alignment = alignment;
|
||||
}
|
||||
|
||||
- (NSUInteger)numberOfLines {
|
||||
return _tagCollectionView.numberOfLines;
|
||||
}
|
||||
|
||||
- (void)setNumberOfLines:(NSUInteger)numberOfLines {
|
||||
_tagCollectionView.numberOfLines = numberOfLines;
|
||||
}
|
||||
|
||||
- (NSUInteger)actualNumberOfLines {
|
||||
return _tagCollectionView.actualNumberOfLines;
|
||||
}
|
||||
|
||||
- (UIEdgeInsets)contentInset {
|
||||
return _tagCollectionView.contentInset;
|
||||
}
|
||||
|
||||
- (void)setContentInset:(UIEdgeInsets)contentInset {
|
||||
_tagCollectionView.contentInset = contentInset;
|
||||
}
|
||||
|
||||
- (BOOL)manualCalculateHeight {
|
||||
return _tagCollectionView.manualCalculateHeight;
|
||||
}
|
||||
|
||||
- (void)setManualCalculateHeight:(BOOL)manualCalculateHeight {
|
||||
_tagCollectionView.manualCalculateHeight = manualCalculateHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)preferredMaxLayoutWidth {
|
||||
return _tagCollectionView.preferredMaxLayoutWidth;
|
||||
}
|
||||
|
||||
- (void)setPreferredMaxLayoutWidth:(CGFloat)preferredMaxLayoutWidth {
|
||||
_tagCollectionView.preferredMaxLayoutWidth = preferredMaxLayoutWidth;
|
||||
}
|
||||
|
||||
- (void)setShowsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator {
|
||||
_tagCollectionView.showsHorizontalScrollIndicator = showsHorizontalScrollIndicator;
|
||||
}
|
||||
|
||||
- (BOOL)showsHorizontalScrollIndicator {
|
||||
return _tagCollectionView.showsHorizontalScrollIndicator;
|
||||
}
|
||||
|
||||
- (void)setShowsVerticalScrollIndicator:(BOOL)showsVerticalScrollIndicator {
|
||||
_tagCollectionView.showsVerticalScrollIndicator = showsVerticalScrollIndicator;
|
||||
}
|
||||
|
||||
- (BOOL)showsVerticalScrollIndicator {
|
||||
return _tagCollectionView.showsVerticalScrollIndicator;
|
||||
}
|
||||
|
||||
- (void)setOnTapBlankArea:(void (^)(CGPoint location))onTapBlankArea {
|
||||
_tagCollectionView.onTapBlankArea = onTapBlankArea;
|
||||
}
|
||||
|
||||
- (void (^)(CGPoint location))onTapBlankArea {
|
||||
return _tagCollectionView.onTapBlankArea;
|
||||
}
|
||||
|
||||
- (void)setOnTapAllArea:(void (^)(CGPoint location))onTapAllArea {
|
||||
_tagCollectionView.onTapAllArea = onTapAllArea;
|
||||
}
|
||||
|
||||
- (void (^)(CGPoint location))onTapAllArea {
|
||||
return _tagCollectionView.onTapAllArea;
|
||||
}
|
||||
|
||||
#pragma mark - Private methods
|
||||
|
||||
- (void)updateAllLabelStyleAndFrame {
|
||||
for (TTGTextTagComponentView *label in _tagLabels) {
|
||||
[self updateStyleAndFrameForLabel:label];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateStyleAndFrameForLabel:(TTGTextTagComponentView *)label {
|
||||
// Update content
|
||||
[label updateContent];
|
||||
// Update content style
|
||||
[label updateContentStyle];
|
||||
// Width limit for vertical scroll direction
|
||||
CGSize maxSize = CGSizeZero;
|
||||
if (self.scrollDirection == TTGTagCollectionScrollDirectionVertical &&
|
||||
CGRectGetWidth(self.bounds) > 0) {
|
||||
maxSize.width = (CGRectGetWidth(self.bounds) - self.contentInset.left - self.contentInset.right);
|
||||
}
|
||||
// Update frame
|
||||
[label updateFrameWithMaxSize:maxSize];
|
||||
}
|
||||
|
||||
- (TTGTextTagComponentView *)newLabelWithConfig:(TTGTextTag *)config {
|
||||
TTGTextTagComponentView *label = [TTGTextTagComponentView new];
|
||||
label.config = config;
|
||||
return label;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
//
|
||||
// TTGTextTagContent.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
Base content class.
|
||||
Do not use this class directly!
|
||||
*/
|
||||
@interface TTGTextTagContent : NSObject <NSCopying>
|
||||
|
||||
/// Must be override by subClass
|
||||
- (NSAttributedString *_Nonnull)getContentAttributedString;
|
||||
|
||||
/// Must be override by subClass
|
||||
- (id _Nonnull)copyWithZone:(NSZone *_Nullable)zone;
|
||||
|
||||
@end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
//
|
||||
// TTGTextTagContent.m
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagContent.h"
|
||||
|
||||
@implementation TTGTextTagContent
|
||||
|
||||
- (NSAttributedString *)getContentAttributedString {
|
||||
NSAssert(NO, @"Do not use TTGTextTagContent directly.");
|
||||
return [NSAttributedString new];
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
return [[[self class] allocWithZone:zone] init];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
//
|
||||
// TTGTextTagStringContent.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagContent.h"
|
||||
|
||||
/**
|
||||
Normal text content with custom font and color.
|
||||
*/
|
||||
@interface TTGTextTagStringContent : TTGTextTagContent
|
||||
|
||||
/// Text
|
||||
@property (nonatomic, copy) NSString * _Nonnull text;
|
||||
/// Text font
|
||||
@property (nonatomic, copy) UIFont * _Nonnull textFont;
|
||||
/// Text color
|
||||
@property (nonatomic, copy) UIColor * _Nonnull textColor;
|
||||
|
||||
/// Init
|
||||
- (instancetype _Nonnull)initWithText:(NSString *_Nonnull)text;
|
||||
- (instancetype _Nonnull)initWithText:(NSString *_Nonnull)text
|
||||
textFont:(UIFont *_Nullable)textFont
|
||||
textColor:(UIColor *_Nullable)textColor;
|
||||
|
||||
/// Content
|
||||
+ (instancetype _Nonnull)contentWithText:(NSString *_Nonnull)text;
|
||||
+ (instancetype _Nonnull)contentWithText:(NSString *_Nonnull)text
|
||||
textFont:(UIFont *_Nullable)textFont
|
||||
textColor:(UIColor *_Nullable)textColor;
|
||||
|
||||
/// Base system methods
|
||||
- (id _Nonnull)copyWithZone:(NSZone *_Nullable)zone;
|
||||
- (NSString *_Nonnull)description;
|
||||
|
||||
@end
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
//
|
||||
// TTGTextTagStringContent.m
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagStringContent.h"
|
||||
|
||||
@implementation TTGTextTagStringContent
|
||||
|
||||
- (instancetype)initWithText:(NSString *)text {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.text = text;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)contentWithText:(NSString *)text {
|
||||
return [[self alloc] initWithText:text];
|
||||
}
|
||||
|
||||
- (instancetype)initWithText:(NSString *)text
|
||||
textFont:(UIFont *)textFont
|
||||
textColor:(UIColor *)textColor {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.text = text;
|
||||
self.textFont = textFont;
|
||||
self.textColor = textColor;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)contentWithText:(NSString *)text
|
||||
textFont:(UIFont *)textFont
|
||||
textColor:(UIColor *)textColor {
|
||||
return [[self alloc] initWithText:text
|
||||
textFont:textFont
|
||||
textColor:textColor];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)getContentAttributedString {
|
||||
return [[NSAttributedString alloc] initWithString:self.text
|
||||
attributes:@{NSForegroundColorAttributeName: self.textColor,
|
||||
NSFontAttributeName: self.textFont}];
|
||||
}
|
||||
|
||||
- (NSString *)text {
|
||||
return _text ?: @"";
|
||||
}
|
||||
|
||||
- (UIFont *)textFont {
|
||||
return _textFont ?: [UIFont systemFontOfSize:14];
|
||||
}
|
||||
|
||||
- (UIColor *)textColor {
|
||||
return _textColor ?: [UIColor blackColor];
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
TTGTextTagStringContent *copy = (TTGTextTagStringContent *)[super copyWithZone:zone];
|
||||
if (copy != nil) {
|
||||
copy.text = self.text;
|
||||
copy.textFont = self.textFont;
|
||||
copy.textColor = self.textColor;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: ", NSStringFromClass([self class])];
|
||||
[description appendFormat:@"self.text=%@", self.text];
|
||||
[description appendString:@">"];
|
||||
return description;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// TTGTextTagStyle.h
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TTGTextTagStyle : NSObject <NSCopying>
|
||||
|
||||
/// Background color
|
||||
@property (nonatomic, copy) UIColor * _Nonnull backgroundColor; // Default is [UIColor lightGrayColor]
|
||||
|
||||
/// Text alignment
|
||||
@property (nonatomic, assign) NSTextAlignment textAlignment; // Default is NSTextAlignmentCenter
|
||||
|
||||
/// Gradient background color
|
||||
@property (nonatomic, assign) BOOL enableGradientBackground; // Default is NO
|
||||
@property (nonatomic, copy) UIColor * _Nonnull gradientBackgroundStartColor;
|
||||
@property (nonatomic, copy) UIColor * _Nonnull gradientBackgroundEndColor;
|
||||
@property (nonatomic, assign) CGPoint gradientBackgroundStartPoint;
|
||||
@property (nonatomic, assign) CGPoint gradientBackgroundEndPoint;
|
||||
|
||||
/// Corner radius
|
||||
@property (nonatomic, assign) CGFloat cornerRadius; // Default is 4
|
||||
@property (nonatomic, assign) Boolean cornerTopRight;
|
||||
@property (nonatomic, assign) Boolean cornerTopLeft;
|
||||
@property (nonatomic, assign) Boolean cornerBottomRight;
|
||||
@property (nonatomic, assign) Boolean cornerBottomLeft;
|
||||
|
||||
/// Border
|
||||
@property (nonatomic, assign) CGFloat borderWidth; // Default is [UIColor whiteColor]
|
||||
@property (nonatomic, copy) UIColor * _Nonnull borderColor; // Default is 1
|
||||
|
||||
/// Shadow.
|
||||
@property (nonatomic, copy) UIColor * _Nonnull shadowColor; // Default is [UIColor blackColor]
|
||||
@property (nonatomic, assign) CGSize shadowOffset; // Default is (2, 2)
|
||||
@property (nonatomic, assign) CGFloat shadowRadius; // Default is 2f
|
||||
@property (nonatomic, assign) CGFloat shadowOpacity; // Default is 0.3f
|
||||
|
||||
/// Extra space in width and height, will expand each tag's size
|
||||
@property (nonatomic, assign) CGSize extraSpace;
|
||||
|
||||
/// Max width for a text tag. 0 and below means no max width.
|
||||
@property (nonatomic, assign) CGFloat maxWidth;
|
||||
/// Min width for a text tag. 0 and below means no min width.
|
||||
@property (nonatomic, assign) CGFloat minWidth;
|
||||
|
||||
/// Max height for a text tag. 0 and below means no max height.
|
||||
@property (nonatomic, assign) CGFloat maxHeight;
|
||||
/// Min height for a text tag. 0 and below means no min height.
|
||||
@property (nonatomic, assign) CGFloat minHeight;
|
||||
|
||||
/// Exact width. 0 and below means no work
|
||||
@property (nonatomic, assign) CGFloat exactWidth;
|
||||
/// Exact height. 0 and below means no work
|
||||
@property (nonatomic, assign) CGFloat exactHeight;
|
||||
|
||||
/// Copy
|
||||
- (id _Nonnull)copyWithZone:(NSZone *_Nullable)zone;
|
||||
|
||||
@end
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
//
|
||||
// TTGTextTagStyle.m
|
||||
// TTGTagCollectionView
|
||||
//
|
||||
// Created by zekunyan on 2019/5/24.
|
||||
// Copyright (c) 2021 zekunyan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TTGTextTagStyle.h"
|
||||
|
||||
@implementation TTGTextTagStyle
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_backgroundColor = [UIColor lightGrayColor];
|
||||
_textAlignment = NSTextAlignmentCenter;
|
||||
_enableGradientBackground = NO;
|
||||
_cornerRadius = 4;
|
||||
_borderColor = [UIColor whiteColor];
|
||||
_borderWidth = 1;
|
||||
_shadowColor = [UIColor blackColor];
|
||||
_shadowOffset = CGSizeMake(2, 2);
|
||||
_shadowRadius = 2;
|
||||
_shadowOpacity = 0.3;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
TTGTextTagStyle *copy = (TTGTextTagStyle *)[[[self class] allocWithZone:zone] init];
|
||||
|
||||
if (copy != nil) {
|
||||
copy.backgroundColor = self.backgroundColor;
|
||||
copy.textAlignment = self.textAlignment;
|
||||
copy.enableGradientBackground = self.enableGradientBackground;
|
||||
copy.gradientBackgroundStartColor = self.gradientBackgroundStartColor;
|
||||
copy.gradientBackgroundEndColor = self.gradientBackgroundEndColor;
|
||||
copy.gradientBackgroundStartPoint = self.gradientBackgroundStartPoint;
|
||||
copy.gradientBackgroundEndPoint = self.gradientBackgroundEndPoint;
|
||||
copy.cornerRadius = self.cornerRadius;
|
||||
copy.cornerTopRight = self.cornerTopRight;
|
||||
copy.cornerTopLeft = self.cornerTopLeft;
|
||||
copy.cornerBottomRight = self.cornerBottomRight;
|
||||
copy.cornerBottomLeft = self.cornerBottomLeft;
|
||||
copy.borderWidth = self.borderWidth;
|
||||
copy.borderColor = self.borderColor;
|
||||
copy.shadowColor = self.shadowColor;
|
||||
copy.shadowOffset = self.shadowOffset;
|
||||
copy.shadowRadius = self.shadowRadius;
|
||||
copy.shadowOpacity = self.shadowOpacity;
|
||||
copy.extraSpace = self.extraSpace;
|
||||
copy.maxWidth = self.maxWidth;
|
||||
copy.minWidth = self.minWidth;
|
||||
copy.maxHeight = self.maxHeight;
|
||||
copy.minHeight = self.minHeight;
|
||||
copy.exactWidth = self.exactWidth;
|
||||
copy.exactHeight = self.exactHeight;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (UIColor *)backgroundColor {
|
||||
return _backgroundColor ?: [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (UIColor *)gradientBackgroundStartColor {
|
||||
return _gradientBackgroundStartColor ?: [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (UIColor *)gradientBackgroundEndColor {
|
||||
return _gradientBackgroundEndColor ?: [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (UIColor *)borderColor {
|
||||
return _borderColor ?: [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (UIColor *)shadowColor {
|
||||
return _shadowColor ?: [UIColor clearColor];
|
||||
}
|
||||
|
||||
@end
|
||||