This commit is contained in:
2025-12-08 16:39:47 +08:00
parent 0a1c30f669
commit fd8c08316b
30 changed files with 306 additions and 85 deletions

View File

@@ -22,6 +22,8 @@
#import "KBStreamOverlayView.h" //
#import "KBFunctionTagListView.h"
#import "KBStreamFetcher.h" //
#import "KBTagItemModel.h"
#import <MJExtension/MJExtension.h>
@interface KBFunctionView () <KBFunctionBarViewDelegate, KBStreamOverlayViewDelegate, KBFunctionTagListViewDelegate>
// UI
@@ -44,7 +46,8 @@
@property (nonatomic, copy, nullable) NSString *loadingTagTitle;
// Data
@property (nonatomic, strong) NSArray<NSString *> *itemsInternal;
//@property (nonatomic, strong) NSArray<NSString *> *itemsInternal;
@property (nonatomic, strong) NSMutableArray<KBTagItemModel *> *modelArray;
//
@property (nonatomic, strong) NSTimer *pasteboardTimer; // 线
@@ -63,7 +66,9 @@
[self kb_applyTheme];
[self setupUI];
[self reloadDemoData];
// [self reloadDemoData];
[self kb_reloadTagsFromSharedDefaults];
//
_lastHandledPBCount = [UIPasteboard generalPasteboard].changeCount;
@@ -82,6 +87,27 @@
return self;
}
#pragma mark - Data
/// App Group NSUserDefaults JSON model +
- (void)kb_reloadTagsFromSharedDefaults {
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
NSDictionary *jsonDict = [sharedDefaults objectForKey:AppGroup_MyKbJson];
if (jsonDict != nil) {
id dataObj = jsonDict[@"data"];
NSArray<KBTagItemModel *> *modelList = [KBTagItemModel mj_objectArrayWithKeyValuesArray:(NSArray *)dataObj];
if (modelList.count > 0) {
self.modelArray = [NSMutableArray array];
[self.modelArray addObjectsFromArray:modelList];
// [self.collectionView reloadData];
[self.tagListView setItems:self.modelArray];
}
}else{
NSLog(@"json❎");
}
}
#pragma mark - Theme
- (void)kb_applyTheme {
@@ -176,20 +202,20 @@
#pragma mark - Data
- (void)reloadDemoData {
//
self.itemsInternal = @[KBLocalized(@"Warm hearted man"),
KBLocalized(@"Warm2 hearted man"),
KBLocalized(@"Warm3 hearted man"),
KBLocalized(@"撩女生啊u发顺丰大师傅"),
KBLocalized(@"Warm = man"),
KBLocalized(@"Warm hearted man"),
KBLocalized(@"一枚暖男发放"),
KBLocalized(@"聊天搭子"),
KBLocalized(@"表达爱意"),
KBLocalized(@"更多话术")];
[self.tagListView setItems:self.itemsInternal];
}
//- (void)reloadDemoData {
// //
// self.itemsInternal = @[KBLocalized(@"Warm hearted man"),
// KBLocalized(@"Warm2 hearted man"),
// KBLocalized(@"Warm3 hearted man"),
// KBLocalized(@"撩女生啊u发顺丰大师傅"),
// KBLocalized(@"Warm = man"),
// KBLocalized(@"Warm hearted man"),
// KBLocalized(@"一枚暖男发放"),
// KBLocalized(@"聊天搭子"),
// KBLocalized(@"表达爱意"),
// KBLocalized(@"更多话术")];
// [self.tagListView setItems:self.itemsInternal];
//}
// UICollectionView KBFunctionTagListView
@@ -409,8 +435,8 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// + 访访
if ([[KBFullAccessManager shared] hasFullAccess]) {
NSString *title = (indexPath.item < self.itemsInternal.count) ? self.itemsInternal[indexPath.item] : @"";
[self kb_showStreamTextViewIfNeededWithTitle:title];
KBTagItemModel *selModel = self.modelArray[indexPath.item];
[self kb_showStreamTextViewIfNeededWithTitle:selModel.characterName];
return;
}
@@ -419,7 +445,7 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
UIInputViewController *ivc = KBFindInputViewController(self);
if (!ivc) return;
NSString *title = (indexPath.item < self.itemsInternal.count) ? self.itemsInternal[indexPath.item] : @"";
NSString *title = self.modelArray[indexPath.item].characterName;
NSString *encodedTitle = [title stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]] ?: @"";
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=functionView&index=%ld&title=%@", KB_UL_LOGIN, (long)indexPath.item, encodedTitle]];
@@ -676,7 +702,7 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
#pragma mark - Expose
- (UICollectionView *)collectionView { return self.tagListView.collectionView; }
- (NSArray<NSString *> *)items { return self.itemsInternal; }
//- (NSArray<NSString *> *)items { return self.itemsInternal; }
- (KBFunctionBarView *)barView { return self.barViewInternal; }
- (KBFunctionPasteView *)pasteView { return self.pasteViewInternal; }
- (UIButton *)pasteButton { return self.pasteButtonInternal; }