添加HWPanModal和FLAnimatedImage

This commit is contained in:
2025-11-05 22:04:56 +08:00
parent efdcf60ed1
commit abf32e8457
97 changed files with 10853 additions and 2067 deletions

View File

@@ -0,0 +1,17 @@
//
// KBDirectionIndicatorView.h
// keyBoard
//
// Created by Mac on 2025/11/5.
//
#import <UIKit/UIKit.h>
#import <HWPanModal/HWPanModalPresentable.h>
#import <HWPanModal/HWPanModalIndicatorProtocol.h>
NS_ASSUME_NONNULL_BEGIN
@interface KBDirectionIndicatorView : UIView<HWPanModalIndicatorProtocol>
- (void)applyPresentationState:(PresentationState)state;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,66 @@
//
// KBDirectionIndicatorView.m
// keyBoard
//
// Created by Mac on 2025/11/5.
//
#import "KBDirectionIndicatorView.h"
#import "UIView+HW_Frame.h"
@interface KBDirectionIndicatorView ()
@property (nonatomic, strong) UIView *leftView;
@property (nonatomic, strong) UIView *rightView;
@end
@implementation KBDirectionIndicatorView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:CGRectZero];
if (self) {
self.backgroundColor = UIColor.clearColor;
_leftView = [UIView new];
_rightView = [UIView new];
_leftView.backgroundColor = _rightView.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
[self addSubview:_leftView];
[self addSubview:_rightView];
}
return self;
}
- (CGSize)indicatorSize { return CGSizeMake(34, 13); }
- (void)setupSubviews {
CGSize size = [self indicatorSize];
self.hw_size = size;
CGFloat h = 5, c = h/2.0;
_leftView.frame = CGRectMake(0, 0, size.width/2 + c, h);
_rightView.frame = CGRectMake(size.width/2 - c, 0, size.width/2 + c, h);
_leftView.hw_centerY = _rightView.hw_centerY = self.hw_height/2.0;
_leftView.layer.cornerRadius = MIN(_leftView.hw_width, _leftView.hw_height)/2;
_rightView.layer.cornerRadius = MIN(_rightView.hw_width, _rightView.hw_height)/2;
}
// HWIndicatorStateNormal
- (void)didChangeToState:(HWIndicatorState)state {
// no-op
}
- (void)applyPresentationState:(PresentationState)state {
CGFloat angle = (CGFloat)(20.0 * M_PI / 180.0);
void (^animate)(void) = ^{
switch (state) {
case PresentationStateShort: // ()
self.leftView.transform = CGAffineTransformMakeRotation(-angle);
self.rightView.transform = CGAffineTransformMakeRotation(angle);
break;
case PresentationStateLong: // ()
default:
self.leftView.transform = CGAffineTransformMakeRotation(angle);
self.rightView.transform = CGAffineTransformMakeRotation(-angle);
break;
}
};
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseOut animations:animate completion:nil];
}
@end

View File

@@ -0,0 +1,18 @@
//
// HomeSheetVC.h
// keyBoard
//
// Created by Mac on 2025/11/5.
//
#import <UIKit/UIKit.h>
#import <HWPanModal/HWPanModal.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeSheetVC : UIViewController<HWPanModalPresentable>
@property (nonatomic, assign) CGFloat minHeight; // 例如 150
@property (nonatomic, assign) CGFloat topInset; // 例如 100
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,73 @@
//
// HomeSheetVC.m
// keyBoard
//
// Created by Mac on 2025/11/5.
//
#import "HomeSheetVC.h"
#import "KBDirectionIndicatorView.h"
@interface HomeSheetVC ()
@property (nonatomic, strong) KBDirectionIndicatorView *indicator;
@end
@implementation HomeSheetVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor redColor];
}
- (UIView<HWPanModalIndicatorProtocol> *)customIndicatorView {
if (!_indicator) _indicator = [KBDirectionIndicatorView new];
return _indicator;
}
- (void)panModalTransitionDidFinish {
//
[self.indicator applyPresentationState:self.hw_presentationState];
}
- (void)didChangeTransitionToState:(PresentationState)state {
//
[self.indicator applyPresentationState:state];
}
- (PanModalHeight)shortFormHeight {
return PanModalHeightMake(PanModalHeightTypeContent, self.minHeight ?: 300);
}
- (PanModalHeight)longFormHeight {
return PanModalHeightMake(PanModalHeightTypeMaxTopInset, self.topInset ?: 100);
}
- (PresentationState)originPresentationState {
return PresentationStateShort; //
}
- (BOOL)anchorModalToLongForm {
return YES; // long
}
- (BOOL)allowsPullDownWhenShortState {
return NO; // short
}
//
- (BOOL)allowsDragToDismiss {
return NO;
}
//- (BOOL)showDragIndicator{
// return NO;
//}
//
- (BOOL)allowsTapBackgroundToDismiss {
return NO;
}
@end

View File

@@ -8,6 +8,7 @@
#import "HomeVC.h"
#import "KBGuideVC.h"
#import "KBLangTestVC.h"
#import "HomeSheetVC.h"
@interface HomeVC () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITextView *textView; //
@@ -21,37 +22,42 @@
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
CGFloat width = [UIScreen mainScreen].bounds.size.width;
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 220)];
CGRect frame = CGRectMake(16, 16, width - 32, 188);
self.textView = [[UITextView alloc] initWithFrame:frame];
self.textView.text = KBLocalized(@"home_input_placeholder");
self.textView.layer.borderColor = [UIColor blackColor].CGColor;
self.textView.layer.borderWidth = 0.5;
[header addSubview:self.textView];
//
self.tableView = [[BaseTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.tableHeaderView = header;
[self.view addSubview:self.tableView];
self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
dispatch_async(dispatch_get_main_queue(), ^{ [self.textView becomeFirstResponder]; });
[[KBNetworkManager shared] GET:@"app/config" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSLog(@"====");
}];
// CGFloat width = [UIScreen mainScreen].bounds.size.width;
// UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 220)];
// CGRect frame = CGRectMake(16, 16, width - 32, 188);
// self.textView = [[UITextView alloc] initWithFrame:frame];
// self.textView.text = KBLocalized(@"home_input_placeholder");
// self.textView.layer.borderColor = [UIColor blackColor].CGColor;
// self.textView.layer.borderWidth = 0.5;
// [header addSubview:self.textView];
//
// //
// self.tableView = [[BaseTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
// self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// self.tableView.delegate = self;
// self.tableView.dataSource = self;
// self.tableView.tableHeaderView = header;
// [self.view addSubview:self.tableView];
//
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
//
// dispatch_async(dispatch_get_main_queue(), ^{ [self.textView becomeFirstResponder]; });
//
// [[KBNetworkManager shared] GET:@"app/config" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
// NSLog(@"====");
// }];
HomeSheetVC *vc = [HomeSheetVC new];
vc.minHeight = 300;
vc.topInset = 100;
[self presentPanModal:vc];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.title = KBLocalized(@"home_title");
self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
[self.tableView reloadData];
// self.title = KBLocalized(@"home_title");
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
// [self.tableView reloadData];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{