feat:增加途经点,完善规划,导航;

This commit is contained in:
xiaogg
2026-03-27 15:39:36 +08:00
parent 0123025296
commit 5843ef6e87
54 changed files with 2596 additions and 506 deletions

View File

@@ -0,0 +1,204 @@
//
// ABottomBarView.m
// AMapNavIOSSDK
//
// Created by admin on 2026/3/25.
//
#import "ABottomBarView.h"
#import "AMapNavCommonUtil.h"
#import <Masonry/Masonry.h>
// 绿
static inline UIColor *ABottomBarThemeGreen(void) {
return [UIColor colorWithRed:0x1A/255.0 green:0x6E/255.0 blue:0x45/255.0 alpha:1.0];
}
@interface ABottomBarView () <UITextFieldDelegate>
///
@property (nonatomic, strong) UIView *cardView;
///
@property (nonatomic, strong) UIImageView *searchIconView;
///
@property (nonatomic, strong) UITextField *searchField;
/// 线
@property (nonatomic, strong) UIButton *calRouteButton;
@end
@implementation ABottomBarView
#pragma mark - Init
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
[self _buildUI];
}
return self;
}
- (instancetype)init {
return [self initWithFrame:CGRectZero];
}
#pragma mark - Build UI
- (void)_buildUI {
//
UIView *card = [[UIView alloc] init];
// card.backgroundColor = [UIColor colorWithRed:0.96 green:0.97 blue:0.98 alpha:0.96];
card.backgroundColor = [UIColor whiteColor];
card.layer.cornerRadius = 16;
//
card.layer.shadowColor = [UIColor blackColor].CGColor;
card.layer.shadowOpacity = 0.10;
card.layer.shadowRadius = 10;
card.layer.shadowOffset = CGSizeMake(0, -3);
card.layer.masksToBounds = NO;
[self addSubview:card];
self.cardView = card;
[card mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
//
UIView *searchRow = [[UIView alloc] init];
searchRow.backgroundColor = [UIColor whiteColor];
searchRow.layer.cornerRadius = 5;
searchRow.layer.masksToBounds = YES;
searchRow.layer.borderColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1].CGColor;
searchRow.layer.borderWidth = 1;
[card addSubview:searchRow];
[searchRow mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(card).offset(-18);
make.left.equalTo(card).offset(16);
make.right.equalTo(card).offset(-16);
make.height.mas_equalTo(50);
}];
//
UIImageView *searchIcon = [[UIImageView alloc] init];
searchIcon.contentMode = UIViewContentModeScaleAspectFit;
searchIcon.image = [AMapNavCommonUtil imageWithName3x:@"search_icon"];
[searchRow addSubview:searchIcon];
self.searchIconView = searchIcon;
[searchIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(searchRow);
make.left.equalTo(searchRow).offset(12);
make.width.height.mas_equalTo(18);
}];
//
UITextField *field = [[UITextField alloc] init];
field.placeholder = @"请输入目的地,不输入则自动匹配附近成本最低加氢站";
field.font = [UIFont systemFontOfSize:14];
field.textColor = [UIColor colorWithWhite:0.1 alpha:1];
field.borderStyle = UITextBorderStyleNone;
field.backgroundColor = [UIColor clearColor];
field.delegate = self;
// placeholder
if (field.placeholder) {
field.attributedPlaceholder = [[NSAttributedString alloc]
initWithString:field.placeholder
attributes:@{NSForegroundColorAttributeName:
[UIColor colorWithWhite:0.65 alpha:1],
NSFontAttributeName:
[UIFont systemFontOfSize:13]}];
}
[searchRow addSubview:field];
self.searchField = field;
[field mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(searchRow);
make.left.equalTo(searchIcon.mas_right).offset(8);
make.right.equalTo(searchRow).offset(-12);
make.top.bottom.equalTo(searchRow);
}];
// 线
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.backgroundColor = ABottomBarThemeGreen();
btn.layer.cornerRadius = 24;
btn.layer.masksToBounds = YES;
//
UIImageView *routeIcon = [[UIImageView alloc] init];
routeIcon.contentMode = UIViewContentModeScaleAspectFit;
routeIcon.image = [AMapNavCommonUtil imageWithName3x:@"cal_ruoute_icon"];
routeIcon.userInteractionEnabled = NO;
[btn addSubview:routeIcon];
//
UILabel *titleLbl = [[UILabel alloc] init];
titleLbl.text = @"规划路线";
titleLbl.textColor = [UIColor whiteColor];
titleLbl.font = [UIFont boldSystemFontOfSize:16];
titleLbl.userInteractionEnabled = NO;
[btn addSubview:titleLbl];
//
[routeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(btn);
make.right.equalTo(titleLbl.mas_left).offset(-8);
make.width.height.mas_equalTo(22);
}];
[titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(btn);
// titleLbl (22+8)/2 = 15pt
make.centerX.equalTo(btn).offset(15);
}];
[btn addTarget:self action:@selector(_onCalRouteTapped) forControlEvents:UIControlEventTouchUpInside];
[card addSubview:btn];
self.calRouteButton = btn;
CGFloat off_y = AMP_TabbarHeight;
#ifdef kAMapSDKDebugFlag
off_y = 0;
#endif
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(searchRow.mas_bottom).offset(20);
make.left.equalTo(card).offset(16);
make.right.equalTo(card).offset(-16);
make.height.mas_equalTo(48);
make.bottom.equalTo(card).offset(-40 - off_y);
}];
}
#pragma mark - Public
- (void)setDestinationText:(NSString *)destinationText {
_destinationText = destinationText;
self.searchField.text = destinationText;
}
#pragma mark - Actions
- (void)_onCalRouteTapped {
if ([self.delegate respondsToSelector:@selector(bottomBarViewDidTapCalRoute:)]) {
[self.delegate bottomBarViewDidTapCalRoute:self];
}
}
#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
//
if ([self.delegate respondsToSelector:@selector(bottomBarViewDidTapSearchField:)]) {
[self.delegate bottomBarViewDidTapSearchField:self];
}
return NO;
}
@end