浏览代码

3.6.17(2)
1.App改名为 Chibii
2.修正分享为文字+图片

100Years 1 周之前
父节点
当前提交
4a46c3e2bd

+ 10 - 2
AIEmoji.xcodeproj/project.pbxproj

@@ -265,6 +265,8 @@
 		A8FB02B72D3E3A3D0031A396 /* TSEmojisChildViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FB02B62D3E3A3B0031A396 /* TSEmojisChildViewModel.swift */; };
 		A8FB02BA2D3E3BB20031A396 /* TSEmojisCoLItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FB02B92D3E3BB00031A396 /* TSEmojisCoLItemCell.swift */; };
 		A8FB02D12D3E6B2A0031A396 /* Cat🐱.json in Resources */ = {isa = PBXBuildFile; fileRef = A8FB02D02D3E6B240031A396 /* Cat🐱.json */; };
+		A8FD8F2D2DFAD6C6008CAACF /* CustomActivityItemProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FD8F2C2DFAD6C3008CAACF /* CustomActivityItemProvider.swift */; };
+		A8FD8F2F2DFADE0D008CAACF /* ShareHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FD8F2E2DFADE0C008CAACF /* ShareHelper.swift */; };
 		A8FDB1712DCC4B1100E9919B /* TSLoadState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FDB16F2DCC4B1100E9919B /* TSLoadState.swift */; };
 		A8FDB17C2DCC5A1000E9919B /* TSTTPInputVC+Col.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FDB17B2DCC5A0000E9919B /* TSTTPInputVC+Col.swift */; };
 		A8FDB17E2DCC5D8500E9919B /* TSTTPInputVC+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FDB17D2DCC5D8000E9919B /* TSTTPInputVC+Style.swift */; };
@@ -562,6 +564,8 @@
 		A8FB02B62D3E3A3B0031A396 /* TSEmojisChildViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSEmojisChildViewModel.swift; sourceTree = "<group>"; };
 		A8FB02B92D3E3BB00031A396 /* TSEmojisCoLItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSEmojisCoLItemCell.swift; sourceTree = "<group>"; };
 		A8FB02D02D3E6B240031A396 /* Cat🐱.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "Cat🐱.json"; sourceTree = "<group>"; };
+		A8FD8F2C2DFAD6C3008CAACF /* CustomActivityItemProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomActivityItemProvider.swift; sourceTree = "<group>"; };
+		A8FD8F2E2DFADE0C008CAACF /* ShareHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareHelper.swift; sourceTree = "<group>"; };
 		A8FDB16F2DCC4B1100E9919B /* TSLoadState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSLoadState.swift; sourceTree = "<group>"; };
 		A8FDB17B2DCC5A0000E9919B /* TSTTPInputVC+Col.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TSTTPInputVC+Col.swift"; sourceTree = "<group>"; };
 		A8FDB17D2DCC5D8000E9919B /* TSTTPInputVC+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TSTTPInputVC+Style.swift"; sourceTree = "<group>"; };
@@ -1989,6 +1993,8 @@
 		A8F776402D3B75EA00AA6E93 /* General */ = {
 			isa = PBXGroup;
 			children = (
+				A8FD8F2C2DFAD6C3008CAACF /* CustomActivityItemProvider.swift */,
+				A8FD8F2E2DFADE0C008CAACF /* ShareHelper.swift */,
 				A8990DE82DDF241300DD55FE /* TYCycleImageView.swift */,
 				A82D609C2DBA0FDD00596190 /* TSAppBtnView */,
 				A85E47992D6808B30018D62D /* TSBigIconBrowseVC */,
@@ -2271,6 +2277,7 @@
 				A89EA6582D59A9F4000EB181 /* TSLayoutSizeCalculator.swift in Sources */,
 				A83404DD2D9E1D8C00C140E4 /* ImagesAnimateScrollView.swift in Sources */,
 				A89EA6592D59A9F4000EB181 /* CustomMessageFlowLayout.swift in Sources */,
+				A8FD8F2D2DFAD6C6008CAACF /* CustomActivityItemProvider.swift in Sources */,
 				A80E72792D42285500C64288 /* TSBootPageVC.swift in Sources */,
 				A80E726A2D409E5400C64288 /* TSDiyTLYFlowersView.swift in Sources */,
 				A8F7764E2D3E00A800AA6E93 /* TSEmojisColViewModel.swift in Sources */,
@@ -2451,6 +2458,7 @@
 				A85E479D2D6809DC0018D62D /* TSBigIconBrowseCell.swift in Sources */,
 				A89EA6832D59F4F9000EB181 /* TSChatViewController+ChatDelegate.swift in Sources */,
 				605E20592DCCAF3C0069F4B6 /* SchemeHandler+Ext.swift in Sources */,
+				A8FD8F2F2DFADE0D008CAACF /* ShareHelper.swift in Sources */,
 				A89EA6A32D5B26E3000EB181 /* TSDBAIChatList.swift in Sources */,
 				A8F7753F2D39340E00AA6E93 /* TSSetingVC.swift in Sources */,
 				A8F7762B2D3A70B200AA6E93 /* PaddedLabel.swift in Sources */,
@@ -2549,7 +2557,7 @@
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIEmoji/Info.plist;
-				INFOPLIST_KEY_CFBundleDisplayName = Picguru;
+				INFOPLIST_KEY_CFBundleDisplayName = Chibii;
 				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Allow us to access photos to upload your photos to generate new styles.";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
@@ -2588,7 +2596,7 @@
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIEmoji/Info.plist;
-				INFOPLIST_KEY_CFBundleDisplayName = Picguru;
+				INFOPLIST_KEY_CFBundleDisplayName = Chibii;
 				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Allow us to access photos to upload your photos to generate new styles.";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;

+ 57 - 0
AIEmoji/Business/General/CustomActivityItemProvider.swift

@@ -0,0 +1,57 @@
+//
+//  CustomActivityItemProvider.swift
+//  AIEmoji
+//
+//  Created by 100Years on 2025/6/12.
+//
+
+//class CustomActivityItemProvider: UIActivityItemProvider {
+//    enum ContentType {
+//        case imageOnly
+//        case imageAndText
+//        case fullContent
+//    }
+//    
+//    let image: UIImage?
+//    let text: String?
+//    let url: URL?
+//    var contentType: ContentType = .fullContent
+//    
+//    init(image: UIImage?, text: String?, url: URL?) {
+//        self.image = image
+//        self.text = text
+//        self.url = url
+//        super.init(placeholderItem: "")
+//    }
+//    
+//    override var item: Any {
+//        switch contentType {
+//        case .imageOnly:
+//            return image ?? NSNull()
+//        case .fullContent:
+//            var items: [Any] = []
+//            if let image = image { items.append(image) }
+//            if let text = text { items.append(text) }
+//            if let url = url { items.append(url) }
+//            return items
+//        case .imageAndText:
+//            var items: [Any] = []
+//            if let image = image { items.append(image) }
+//            if let text = text { items.append(text) }
+//            return items
+//        }
+//    }
+//    
+//    override func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
+//        // 根据分享类型决定内容
+//        if activityType == .message {
+//            contentType = .imageOnly
+//        } else if activityType == .airDrop {
+//            contentType = .imageOnly
+//        } else {
+//            contentType = .fullContent
+//        }
+//        return item
+//    }
+//    
+//}

+ 125 - 0
AIEmoji/Business/General/ShareHelper.swift

@@ -0,0 +1,125 @@
+//
+//  ShareHelper.swift
+//  AIEmoji
+//
+//  Created by 100Years on 2025/6/12.
+//
+
+import UIKit
+
+class ShareHelper {
+    
+    /// 分享内容
+    /// - Parameters:
+    ///   - image: 要分享的图片
+    ///   - text: 要分享的文本
+    ///   - url: 要分享的URL
+    ///   - viewController: 呈现分享控制器的视图控制器
+    ///   - sourceView: iPad上弹出框的锚点视图
+    static func share(image: UIImage?,
+                     text: String? = nil,
+                     url: URL? = nil,
+                     from viewController: UIViewController,
+                     sourceView: UIView? = nil) {
+        
+        // 确保至少有一个可分享的内容
+        guard image != nil || text != nil || url != nil else {
+            print("没有可分享的内容")
+            return
+        }
+        
+        var activityItems: [Any] = []
+        
+        // 创建自定义活动项提供者
+        let activityProvider = CustomActivityItemProvider { activityType in
+            // 根据活动类型决定分享内容
+            if let type = activityType {
+                if type == .airDrop {
+                    // 隔空投送只分享图片
+                    return image
+                } else if type == .message {
+                    // 短信分享图片+文本
+                    var items: [Any] = []
+                    if let image = image { items.append(image) }
+                    if let text = text { items.append(text) }
+                    return items.count > 0 ? items : nil
+                } else if type == .addToReadingList || type == .copyToPasteboard || type == .saveToCameraRoll {
+                    // 这些活动只处理URL
+                    return url
+                } else {
+                    // 其他情况(如备忘录)分享所有内容
+                    var items: [Any] = []
+                    if let image = image { items.append(image) }
+                    if let text = text { items.append(text) }
+                    if let url = url { items.append(url) }
+                    return items.count > 0 ? items : nil
+                }
+            }
+            
+            // 默认情况分享所有内容
+            var items: [Any] = []
+            if let image = image { items.append(image) }
+            if let text = text { items.append(text) }
+            if let url = url { items.append(url) }
+            return items.count > 0 ? items : nil
+        }
+        
+        activityItems.append(activityProvider)
+        
+        // 创建活动视图控制器
+        let activityViewController = UIActivityViewController(
+            activityItems: activityItems,
+            applicationActivities: nil
+        )
+        
+        // 排除某些活动类型
+        activityViewController.excludedActivityTypes = [
+            .assignToContact,
+            .print,
+            .postToWeibo,
+            .postToTencentWeibo
+        ]
+        
+        // 设置完成回调
+        activityViewController.completionWithItemsHandler = { activityType, completed, returnedItems, error in
+            if completed {
+                print("分享成功: \(activityType?.rawValue ?? "未知")")
+            } else if let error = error {
+                print("分享失败: \(error.localizedDescription)")
+            } else {
+                print("分享取消")
+            }
+        }
+        
+        // 配置iPad上的弹出框
+        if let popoverController = activityViewController.popoverPresentationController {
+            popoverController.sourceView = sourceView ?? viewController.view
+            popoverController.sourceRect = sourceView?.bounds ?? CGRect(x: viewController.view.bounds.midX,
+                                                                      y: viewController.view.bounds.midY,
+                                                                      width: 0,
+                                                                      height: 0)
+            popoverController.permittedArrowDirections = []
+        }
+        
+        // 呈现分享控制器
+        viewController.present(activityViewController, animated: true)
+    }
+}
+
+// 自定义活动项提供者,根据活动类型动态返回分享内容
+class CustomActivityItemProvider: UIActivityItemProvider {
+    private let handler: (UIActivity.ActivityType?) -> Any?
+    
+    init(handler: @escaping (UIActivity.ActivityType?) -> Any?) {
+        self.handler = handler
+        super.init(placeholderItem: "")
+    }
+    
+    override var item: Any {
+        return handler(activityType) ?? ""
+    }
+    
+    override func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
+        return handler(activityType)
+    }
+}

+ 69 - 8
AIEmoji/Common/Tool/TSCommonTool/TSCommonTool.swift

@@ -222,31 +222,70 @@ func kExecuteOnMainThread(_ block: @escaping () -> Void) {
 }
 
 let appid = "6740220736"
-let kAppName:String = "Picguru" //Picguru Chibii Chibi Ghiblii AI Image Picguru
+let kAppName:String = "Chibii" //Picguru Chibii Chibi Ghiblii AI Image Picguru
 let kUploadImageMaxBit10Size:Int = 10 * 1024 * 1024 //10M
 let kUploadImageMaxBit5Size:Int = 5 * 1024 * 1024 //5M
 
 func kShareImage(target: UIViewController,image:UIImage) {
-    let httpAppStoreLink = "https://apps.apple.com/app/id\(appid)"
+    
     let text = "Turn yourself into a Ghibli style with AI magic! 🎨✨ This app creates stunning anime, cyberpunk & more—just upload a photo. Try it now!"
     kShareContent(target: target, image: image, text: text)
+    
+//    shareApplication(target: target)
 }
 
+//func kShareContent(target: UIViewController,image:UIImage?,text:String?) {
+//
+//    let url = URL(string: "https://apps.apple.com/app/id\(appid)")
+//    
+//    let provider = CustomActivityItemProvider(image: image, text: text, url: url)
+//    let vc = UIActivityViewController(activityItems: [provider], applicationActivities: nil)
+//    vc.completionWithItemsHandler = { activity, _, _, _ in
+//        switch activity {
+//        case .copyToPasteboard:
+//            UIPasteboard.general.string = text
+//        default:
+//            dePrint("")
+//        }
+////        if let type = activity, type == .copyToPasteboard {
+////            UIPasteboard.general.string = text
+////        }else
+//    }
+//
+//    if UIDevice.current.userInterfaceIdiom == .pad {
+//        vc.modalPresentationStyle = .popover
+//        vc.popoverPresentationController?.sourceView = target.view
+//        vc.popoverPresentationController?.sourceRect = target.view.bounds
+//    }
+//    
+//    target.present(vc, animated: true)
+//}
+
 func kShareContent(target: UIViewController,image:UIImage?,text:String?) {
+//    
+//    let url = URL(string: "https://apps.apple.com/app/id\(appid)")
+//    ShareHelper.share(
+//        image: image,
+//        text: text,
+//        url: url,
+//        from: target,
+//        sourceView: target.view // 可以是按钮或其他UIView
+//    )
+//    return
+    let urlString = "https://apps.apple.com/app/id\(appid)"
     var activityItems:[Any] = []
-    
 
     if let image = image {
         activityItems.append(image)
     }
     
     if let text = text {
-        activityItems.append(text)
+        activityItems.append(text+"\nApp:"+urlString)
     }
     
-    if let url = URL(string: "https://apps.apple.com/app/id\(appid)") {
-        activityItems.append(url)
-    }
+//    if let url = URL(string: "https://apps.apple.com/app/id\(appid)") {
+//        activityItems.append(url)
+//    }
     
     if activityItems.isEmpty {
         return
@@ -254,8 +293,11 @@ func kShareContent(target: UIViewController,image:UIImage?,text:String?) {
 
     let vc = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
     vc.completionWithItemsHandler = { activity, _, _, _ in
-        if let type = activity, type == .copyToPasteboard {
+        switch activity {
+        case .copyToPasteboard:
             UIPasteboard.general.string = text
+        default:
+            dePrint("")
         }
     }
 
@@ -269,6 +311,25 @@ func kShareContent(target: UIViewController,image:UIImage?,text:String?) {
 }
 
 
+//func shareApplication(target: UIViewController) {
+//    let text = "I'm using Sweeter to decorate my phone, there are not only themes, wallpapers, widgets, but also dynamic island and super useful tools, come and try with me!"
+//    let httpAppStoreLink = "https://apps.apple.com/app/id\(appid)"
+//    let url = URL(string: httpAppStoreLink)!
+//    let image = UIImage(named: "App-Icon")!.compressImageSize(to: CGSize(width: 100, height: 100))
+//    let vc = UIActivityViewController(activityItems: [image, text, url], applicationActivities: nil)
+//    vc.completionWithItemsHandler = { activity, value, _, error in
+//        if let type = activity, type == .copyToPasteboard {
+//            UIPasteboard.general.string = httpAppStoreLink
+//        }
+//    }
+//    if UIDevice.current.userInterfaceIdiom == .pad {
+//        vc.modalPresentationStyle = .popover
+//        vc.popoverPresentationController?.sourceView = target.view
+//        vc.popoverPresentationController?.sourceRect = target.view.bounds
+//    }
+//    target.present(vc, animated: true)
+//}
+
 //// todo.kailen-logo
 //func shareApp(parent: UIViewController) {
 //    let httpAppStoreLink = "https://apps.apple.com/app/id\(appid)"

+ 0 - 2
Podfile

@@ -20,8 +20,6 @@ target 'AIEmoji' do
   pod 'RealmSwift', '~>10'
   pod 'SwipeCellKit'
   pod 'TSSmalCoacopods', :path => '../TSSmalCoacopods'
-#  pod 'SwiftyMarkdown'
-#  pod "MarkdownKit"
   pod "MXParallaxHeader"
   pod "DynamicBlurView"
   pod 'BetterSegmentedControl', '~> 2.0'

+ 1 - 1
Podfile.lock

@@ -151,6 +151,6 @@ SPEC CHECKSUMS:
   TSSmalCoacopods: 6aa97167f0c76b16fc7d1fd1eb198bb6aece4f68
   TYCyclePagerView: 2b051dade0615c70784aa34f40c646feeddb7344
 
-PODFILE CHECKSUM: 96ce9226d2d7d5271b0e285aaad4af1514dbdd82
+PODFILE CHECKSUM: a3c8fcf2d7ce56c8dc3fd11eebfc9bc5b5d65559
 
 COCOAPODS: 1.16.2